-
Notifications
You must be signed in to change notification settings - Fork 0
/
names entity recognition .py
61 lines (30 loc) · 1.02 KB
/
names entity recognition .py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/env python
# coding: utf-8
# In[1]:
import nltk
from nltk.tokenize import word_tokenize,sent_tokenize
from nltk.corpus import state_union
# In[1]:
#these are the lasssifications madde by ne_chunk and shows the classified words with the type like organisation,person,etc..
"""NE Type and Examples
ORGANIZATION - Georgia-Pacific Corp., WHO
PERSON - Eddy Bonte, President Obama
LOCATION - Murray River, Mount Everest
DATE - June, 2008-06-29
TIME - two fifty a m, 1:30 p.m.
MONEY - 175 million Canadian Dollars, GBP 10.40
PERCENT - twenty pct, 18.75 %
FACILITY - Washington Monument, Stonehenge
GPE - South East Asia, Midlothian"""
# In[3]:
data = state_union.raw("2005-GWBush.txt")
# In[4]:
sentences = sent_tokenize(data)
# In[5]:
for i in sentences:
words = word_tokenize(i)
tokenised_pos = nltk.pos_tag(words)
classified = nltk.ne_chunk(tokenised_pos,binary = True) #when binary is used then the type of word like person time,date is not shown.
classified.draw()
# In[ ]:
# In[ ]: