-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUI_API.py
More file actions
20 lines (18 loc) · 744 Bytes
/
Copy pathUI_API.py
File metadata and controls
20 lines (18 loc) · 744 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
from word2vec.UI_word2vec2 import most_similar
from newscollactor import newscollactor
from FastText.fasttext_UI import PN_classifier
def similar_words(query):
return most_similar(query)
def return_PN(words):
PNdict = dict()
for word in words:
sourceDF = newscollactor(word)
sourceDF["pn"] = PN_classifier(sourceDF["crawled"])
counted_PN = sourceDF["pn"].value_counts().sort_index()
total = counted_PN.loc('0') + counted_PN.loc('1')
positive_percentage = counted_PN.loc('1')/total*100
negative_percentage = counted_PN.loc('0')/total*100
PNdict[word] = (positive_percentage, negative_percentage)
return PNdict
if __name__ == "__main__":
return_PN(similar_words("CJ"))