forked from Abishek10/verb
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.py
More file actions
22 lines (14 loc) · 701 Bytes
/
Copy pathutils.py
File metadata and controls
22 lines (14 loc) · 701 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from sklearn.decomposition import PCA
from vectors import compute_weat_score
def process_seedwords(seedword_string):
return [seedword.strip() for seedword in seedword_string.split(',')]
def make_projector(method='PCA'):
if method == 'PCA':
projector = PCA(n_components=2)
else:
raise AttributeError('Unknown method type for dimensionality reduction')
return projector
def get_weat_score(embedding, seedwords1, seedwords2, male_words, female_words):
return compute_weat_score(embedding, male_words, female_words, seedwords1, seedwords2)
def project_to_2d(projector, embedding, wordlist):
return projector.transform(embedding.get_many(wordlist)).tolist()