-
Notifications
You must be signed in to change notification settings - Fork 0
/
TS_main.py
87 lines (70 loc) · 2.22 KB
/
TS_main.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import cwi_main
import sssg_main
import sr_main
import verb as en
text = "Automatic sense disambiguation using machine readable dictionaries"
model_CWI = "Model_Normal(LOG).txt"
treshold = 7.0
CWI_NER = True
SSSG_WSD = True
metode = "adapted_lesk"
model_SR = "Model_Simple(LOG).txt"
def main(text, model_CWI, treshold, CWI_NER, SSSG_WSD, metode, model_SR) :
definition = []
#CWI
hasil_CWI = []
if CWI_NER :
hasil_CWI = cwi_main.complexWordIdentificationNER(text, model_CWI, treshold)
else :
hasil_CWI = cwi_main.complexWordIdentification(text, model_CWI, treshold)
print("CWI ## Hasil ",hasil_CWI)
##SSSG
hasil_SSSG= []
tenses = []
if SSSG_WSD :
for word in hasil_CWI :
try :
tenses.append(en.verb_tense(word[0].lower()))
except :
tenses.append("")
tmp = sssg_main.get_synset(metode, word[0], text)
try :
print("SSSG ## Definition", word[0], ":", sssg_main.get_word_definition(tmp))
definition.append(word[0]+ " : "+ sssg_main.get_word_definition(tmp))
except :
print("SSSG ## Definition", word[0])
try :
tmp = sssg_main.get_word_synonym(tmp)
except :
tmp = [word[0]]
hasil_SSSG.append([tmp,word[1]])
else :
for word in hasil_CWI:
hasil_SSSG.append([sssg_main.get_word_synonym_noWSD(word[0]),word[1]])
print("SSSG ## Hasil",hasil_SSSG)
##SR
hasil_SR = []
for words in hasil_SSSG :
tmp = sr_main.wordRanking(model_SR,words[0])
print(tmp, words)
try:
hasil_SR.append([tmp[0][0],words[1]])
except :
continue
print("SR ## Hasil",hasil_SR)
##Hasil
hasil_text = text.split()
i = 0
for word in hasil_SR :
try:
hasil_text[word[1]] = en.verb_conjugate(word[0], tense=tenses[i])
except :
hasil_text[word[1]] = word[0]
i+=1
hasil_text = " ".join(hasil_text)
#Output
print("")
print(text)
print(hasil_text)
return hasil_text,definition
# main(text, model_CWI, treshold, CWI_NER, SSSG_WSD, metode, model_SR)