-
Notifications
You must be signed in to change notification settings - Fork 1
/
ir.py
64 lines (50 loc) · 1.06 KB
/
ir.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
58
59
60
61
62
63
64
import spacy
import sys
def spacy_data(docu):
nlp = spacy.load('en_core_web_sm')
doc = nlp(docu)
iterator = doc.__getitem__
i = 0
add = []
for gpe in doc.ents:
# print (gpe.label_)
if gpe.label_ == 'GPE':
add.append(gpe.text)
#print (doc.ents[3])
#sys.exit()
flag = 0
for ent in doc:
i = i + 1
if ent.text == ('at' or 'stuck' or 'stranded' or 'locked'):
for k in range(i, len(doc)):
for z in doc.ents:
#print (z)
#print (str(z))
#print (doc[k])
if (str(z)== str(doc[k])):
add.append(doc[k])
#print ("YEsjskdfjdkjfkdjf")
flag = 1
break
else:
add.append(doc[k])
if (flag == 1):
break
if (flag == 1):
break
a = set(add)
# print (list(a))
donation = []
for r in doc.ents:
if r.label_ == 'MONEY' or 'TIME' or 'CARDINAL' or 'PRODUCT':
#print r.label_
donation.append(r.text)
activity = []
for r in doc:
if r.pos_ == 'VERB':
activity.append(r.text)
name = []
for k in doc.ents:
if k.label_ == 'PERSON':
name.append(k.text)
return (name,activity,donation,add)