Skip to content

Instantly share code, notes, and snippets.

@gupul2k
Created November 2, 2012 13:32
Show Gist options
  • Save gupul2k/4001384 to your computer and use it in GitHub Desktop.
Save gupul2k/4001384 to your computer and use it in GitHub Desktop.
NER and POS Tagging with NLTK and Python
#Script tags POS and NER[Named Entity Recognition] for a supplied text file.
#Date: Nov 2 2012
#Author: Hota Sobhan
import nltk
f = open('C:\Python27\Test_File.txt')
data = f.readlines()
#Parse the text file for NER with POS Tagging
for line in data:
tokens = nltk.word_tokenize(line)
tagged = nltk.pos_tag(tokens)
entities = nltk.chunk.ne_chunk(tagged)
print entities
f.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment