-
Notifications
You must be signed in to change notification settings - Fork 2
/
PCA_test.py
41 lines (29 loc) · 1.11 KB
/
PCA_test.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
from BusquedasSem import *
import pandas as pd
import seaborn as sns
def main():
df = pd.read_csv('./client0-sort.csv')
abstracts = df['Abstract'].values
# abstracts_aux = abstracts
abstracts_aux = []
for abstract in abstracts:
text = minimizar(abstract)
text = deletePunt(text=text)
text = deleteStop(text=text, leng='english')
#text = nltk.tokenize.word_tokenize(text)
text = deleteWord('CD', text)
text = stemmingLemmatizer(text)
abstracts_aux.append(text)
print(abstracts_aux[0])
words = getWordsText(
'explosive emulsion; plastic explosive; oil with water; robust')
X = thoughtobeat(words=words, abstracts=abstracts_aux)
pca_score = PCAscore2(X)
print(pca_score)
df_pca_score = pd.DataFrame(pca_score, columns=['PCA Score'])
df_abstracts = pd.DataFrame(abstracts, columns=['Abstract'])
df_pca_abstracts = pd.concat([df_pca_score, df_abstracts], axis=1)
df = df_pca_abstracts.sort_values(['PCA Score'], ascending=False)
df.to_csv('PCA_Sorted_Abstracts1.csv')
if __name__ == '__main__':
main()