NLTK

by: Amay1212, 7 years ago

Last edited: 7 years ago

Ya, Im looking at your tutorial and its really really good ,I do have some doubts though!!

Sorry ,But what do we mean by training a part ?My questions might be dumb ,pardon me for that.
Im a newbie you see.

Also,One more thing i wanna ask that when i tried using one of those files ,it gave me the same result as earlier.So,Please make me understand all this mess.
Thanks Im expecting your reply :)

#Here is the code ,have a look and please if you can tell me the difference between the following two,would appreciate that#


import nltk
from nltk.corpus import state_union
from nltk.tokenize import PunktSentenceTokenizer
train_text=state_union.raw("2005-GWBush.txt")
sample_text=state_union.raw("1988-Reagan.txt")

net_tokenizer=PunktSentenceTokenizer()
final_tokenizer=net_tokenizer.tokenize(sample_text)

for final in final_tokenizer[:2] :
    words=nltk.word_tokenize(final)
    taggedWords=nltk.pos_tag(words)
    print(taggedWords)


#When using only one file #

import nltk
from nltk.corpus import state_union
from nltk.tokenize import PunktSentenceTokenizer
train_text=state_union.raw("2005-GWBush.txt")

net_tokenizer=PunktSentenceTokenizer()
final_tokenizer=net_tokenizer.tokenize(train_text)

for final in final_tokenizer[:1] :
    words=nltk.word_tokenize(final)
    taggedWords=nltk.pos_tag(words)
    print(taggedWords)


#Let me know the difference between these two and also tell me what difference  in
the following 1 and 2.

like

1.PunktSentenceTokenizer(any_text)

AND

2.PunktSentenceTokenizer( )

























You must be logged in to post. Please login or register an account.