Ntlk book is here: http://www.nltk.org/book/
NLP applications: http://blog.mashape.com/list-of-25-natural-language-processing-apis/
In [1]:
import nltk.classify.util
from nltk.classify import NaiveBayesClassifier
from nltk.corpus import movie_reviews
from nltk.corpus import stopwords
from nltk.tokenize import word_tokenize
from nltk.corpus import wordnet
In [2]:
sentence = "The Quick brown fox, Jumps over the lazy little dog. Hello World."
In [3]:
sentence.split(" ")
Out[3]:
In [4]:
word_tokenize(sentence)
Out[4]:
In [5]:
w = word_tokenize(sentence)
nltk.pos_tag(w)
Out[5]:
In [ ]:
# List of tages: http://www.ling.upenn.edu/courses/Fall_2003/ling001/penn_treebank_pos.html
nltk.help.upenn_tagset()
In [10]:
syn = wordnet.synsets("computer")
print(syn)
print(syn[0].name())
print(syn[0].definition())
print(syn[1].name())
print(syn[1].definition())
In [11]:
syn = wordnet.synsets("talk")
syn[0].examples()
Out[11]:
In [16]:
syn = wordnet.synsets("speak")[0]
print(syn.hypernyms())
print(syn.hyponyms())
In [24]:
syn = wordnet.synsets("good")
for s in syn:
for l in s.lemmas():
if (l.antonyms()):
print(l.antonyms())
In [25]:
syn = wordnet.synsets("book")
for s in syn:
print(s.lemmas())
In [ ]: