Python Forum
serious n00b.. NLTK in python 2.7 and 3.5
Thread Rating:
  • 2 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
serious n00b.. NLTK in python 2.7 and 3.5
#21
Yes and "tokenized" should be given as a argument to function.
When you test out stuff is best to remove try:except,so then it look like this.
import nltk
from nltk import pos_tag, PunktSentenceTokenizer
from nltk.corpus import state_union

def process_content(tokenized):
   for i in tokenized:
       words = nltk.word_tokenize(i)
       tagged = pos_tag(words)
       print(tagged)

if __name__ == '__main__':
   train_text = state_union.raw("2005-GWBush.txt")
   sample_text = state_union.raw("2006-GWBush.txt")
   custom_sent_tokenizer = PunktSentenceTokenizer(train_text)
   tokenized = custom_sent_tokenizer.tokenize(sample_text)
   process_content(tokenized)
Reply


Messages In This Thread
RE: serious n00b.. NLTK in python 2.7 and 3.5 - by snippsat - Oct-20-2016, 06:36 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Help with simple nltk Chatbot Extra 3 1,900 Jan-02-2022, 07:50 AM
Last Post: bepammoifoge
  Saving a download of stopwords (nltk) Drone4four 1 9,350 Nov-19-2020, 11:50 PM
Last Post: snippsat
  Installing nltk dependency Eshwar 0 1,847 Aug-30-2020, 06:10 PM
Last Post: Eshwar
  n00b question millpond 6 3,383 Jul-13-2019, 06:41 AM
Last Post: Gribouillis
  Clean Data using NLTK disruptfwd8 0 3,341 May-12-2018, 11:21 PM
Last Post: disruptfwd8
  n00b help with referencing files theturd 8 5,130 Jul-21-2017, 04:16 PM
Last Post: nilamo
  n00b needs help theturd 8 5,820 Jun-12-2017, 01:55 PM
Last Post: theturd
  Text Processing and NLTK (POS tagging) TwelveMoons 2 4,908 Mar-16-2017, 02:53 AM
Last Post: TwelveMoons
  NLTK create corpora pythlang 5 10,211 Oct-26-2016, 07:31 PM
Last Post: Larz60+
  Corpora catalof for NLTK Larz60+ 1 4,121 Oct-20-2016, 02:31 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020