Skip to content

Instantly share code, notes, and snippets.

@akshayjh
Forked from gupul2k/pos_tagging.py
Created March 21, 2017 09:43
Show Gist options
  • Save akshayjh/490ac93cec4871cd8ba9e032b7e931ab to your computer and use it in GitHub Desktop.
Save akshayjh/490ac93cec4871cd8ba9e032b7e931ab 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