Skip to content

Instantly share code, notes, and snippets.

View Mantej-Singh's full-sized avatar
💭
~Life is Beautiful~

Mantej Singh Dhanjal Mantej-Singh

💭
~Life is Beautiful~
View GitHub Profile
@Mantej-Singh
Mantej-Singh / example1.py
Created January 6, 2017 18:13 — forked from onyxfish/example1.py
Basic example of using NLTK for name entity extraction.
import nltk
with open('sample.txt', 'r') as f:
sample = f.read()
sentences = nltk.sent_tokenize(sample)
tokenized_sentences = [nltk.word_tokenize(sentence) for sentence in sentences]
tagged_sentences = [nltk.pos_tag(sentence) for sentence in tokenized_sentences]
chunked_sentences = nltk.batch_ne_chunk(tagged_sentences, binary=True)