forked from codingsoo/REST_Go
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathproof_of_concept1.py
More file actions
49 lines (43 loc) · 1.35 KB
/
proof_of_concept1.py
File metadata and controls
49 lines (43 loc) · 1.35 KB
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
import sys
import stanza
text = sys.argv[1]
args = sys.argv[2]
nlp = stanza.Pipeline(lang='en', processors='tokenize,mwt,pos,lemma,depparse')
rels = ["case", "nsubj", "dep"]
noMeaningRels = ["cc", "det"]
pos = ["NOUN", "PROPN", "NUM"]
doc = nlp(text)
examples = []
for sentence in doc.sentences:
startPoint = -1
foundWord = ""
isConjunction = False
for word in sentence.words:
if word.deprel in rels:
startPoint = word.head
if word.id >= startPoint > -1:
if word.deprel in noMeaningRels:
pass
elif word.upos == "PUNCT":
if foundWord != "":
examples.append(foundWord)
foundWord = ""
elif isConjunction:
foundWord = foundWord + word.text
isConjunction = False
elif word.deprel == "conj":
foundWord = foundWord + word.text
isConjunction = True
elif word.upos in pos:
examples.append(word.text)
else:
foundWord = word.text
for example in list(set(examples)):
flag = True
for arg in args.replace(" ", "").split(','):
if arg in example:
print("InterParamDep: " + example)
flag = False
break
if flag:
print("Example Value: " + example)