Spaces:
Configuration error
Configuration error
LMartinezEXEX
commited on
Commit
•
421e27d
1
Parent(s):
8783987
Added config for centralization.
Browse filesType hinted some modules.
Separated examples in spanish and english.
- .gitattributes +1 -4
- .gitignore +1 -1
- app.py +15 -6
- data/{fasttext-sbwc.100k.vec → 100k_es_embedding.vec} +0 -0
- data/fasttext_embedding_v6.zip +0 -3
- data/wiki-news-300d-1M.vec +0 -3
- examples/examples_es.py +33 -0
- interfaces/interface_BiasWordExplorer.py +8 -2
- interfaces/interface_WordExplorer.py +7 -2
- language/.gitignore +1 -1
- language/english.json +0 -91
- language/{spanish.json → es.json} +5 -5
- modules/model_embbeding.py +9 -7
- modules/module_BiasExplorer.py +12 -5
- modules/module_WordExplorer.py +2 -2
- modules/module_logsManager.py +3 -3
- tool.cfg +13 -0
.gitattributes
CHANGED
@@ -31,7 +31,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
31 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
32 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
33 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
34 |
-
data/
|
35 |
-
data/half_embedding_v6.zip filter=lfs diff=lfs merge=lfs -text
|
36 |
-
data/wiki-news-300d-1M.vec filter=lfs diff=lfs merge=lfs -text
|
37 |
-
data/fasttext-sbwc.100k.vec filter=lfs diff=lfs merge=lfs -text
|
|
|
31 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
32 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
33 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
34 |
+
data/100k_es_embedding.vec filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
.gitignore
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
__pycache__/
|
2 |
*.env
|
3 |
-
|
|
|
1 |
__pycache__/
|
2 |
*.env
|
3 |
+
logs_edia_we_es/
|
app.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
# --- Imports libs ---
|
2 |
import gradio as gr
|
3 |
import pandas as pd
|
|
|
4 |
|
5 |
|
6 |
# --- Imports modules ---
|
@@ -13,17 +14,20 @@ from interfaces.interface_BiasWordExplorer import interface as biasWordExplorer_
|
|
13 |
|
14 |
|
15 |
# --- Tool config ---
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
|
|
|
|
|
|
21 |
|
22 |
|
23 |
# --- Init classes ---
|
24 |
embedding = Embedding(
|
25 |
path=EMBEDDINGS_PATH,
|
26 |
-
limit=
|
27 |
randomizedPCA=False,
|
28 |
max_neighbors=MAX_NEIGHBORS,
|
29 |
nn_method=NN_METHOD
|
@@ -52,6 +56,11 @@ TAB_NAMES = [
|
|
52 |
labels["wordExplorer"],
|
53 |
]
|
54 |
|
|
|
|
|
|
|
|
|
|
|
55 |
iface = gr.TabbedInterface(
|
56 |
interface_list=INTERFACE_LIST,
|
57 |
tab_names=TAB_NAMES
|
|
|
1 |
# --- Imports libs ---
|
2 |
import gradio as gr
|
3 |
import pandas as pd
|
4 |
+
import configparser
|
5 |
|
6 |
|
7 |
# --- Imports modules ---
|
|
|
14 |
|
15 |
|
16 |
# --- Tool config ---
|
17 |
+
cfg = configparser.ConfigParser()
|
18 |
+
cfg.read('tool.cfg')
|
19 |
+
|
20 |
+
LANGUAGE = cfg['INTERFACE']['language']
|
21 |
+
EMBEDDINGS_PATH = cfg['WORD_EXPLORER']['embeddings_path']
|
22 |
+
NN_METHOD = cfg['WORD_EXPLORER']['nn_method']
|
23 |
+
MAX_NEIGHBORS = int(cfg['WORD_EXPLORER']['max_neighbors'])
|
24 |
+
AVAILABLE_LOGS = cfg['LOGS'].getboolean('available_logs')
|
25 |
|
26 |
|
27 |
# --- Init classes ---
|
28 |
embedding = Embedding(
|
29 |
path=EMBEDDINGS_PATH,
|
30 |
+
limit=100_000,
|
31 |
randomizedPCA=False,
|
32 |
max_neighbors=MAX_NEIGHBORS,
|
33 |
nn_method=NN_METHOD
|
|
|
56 |
labels["wordExplorer"],
|
57 |
]
|
58 |
|
59 |
+
# Skip data tab when using other than spanish language
|
60 |
+
if LANGUAGE != 'es':
|
61 |
+
INTERFACE_LIST = INTERFACE_LIST[:2] + INTERFACE_LIST[3:]
|
62 |
+
TAB_NAMES = TAB_NAMES[:2] + TAB_NAMES[3:]
|
63 |
+
|
64 |
iface = gr.TabbedInterface(
|
65 |
interface_list=INTERFACE_LIST,
|
66 |
tab_names=TAB_NAMES
|
data/{fasttext-sbwc.100k.vec → 100k_es_embedding.vec}
RENAMED
File without changes
|
data/fasttext_embedding_v6.zip
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:c35f3dda1d216d9baed3fc77f3b6bb51130f07faf0ee418029344635a0b732b7
|
3 |
-
size 165727812
|
|
|
|
|
|
|
|
data/wiki-news-300d-1M.vec
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:dd4d0ea4f00dbd94ea4948957506f5c6601dd06c54150f898ce1acc15621284b
|
3 |
-
size 2259088777
|
|
|
|
|
|
|
|
examples/examples_es.py
CHANGED
@@ -81,4 +81,37 @@ examples2_explorar_sesgo_en_palabras = [
|
|
81 |
examples_explorar_relaciones_entre_palabras = [
|
82 |
[diagnose_words, fem_words, masc_words, young_words, old_words],
|
83 |
[diagnose_money, lazy_words, active_words, positive_money_words, negative_money_words],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
84 |
]
|
|
|
81 |
examples_explorar_relaciones_entre_palabras = [
|
82 |
[diagnose_words, fem_words, masc_words, young_words, old_words],
|
83 |
[diagnose_money, lazy_words, active_words, positive_money_words, negative_money_words],
|
84 |
+
]
|
85 |
+
|
86 |
+
|
87 |
+
# Examples bias phrase
|
88 |
+
examples_sesgos_frases = [
|
89 |
+
["los * manejan bien la plata.", "argentinos,pobres,millonarios,australianos"],
|
90 |
+
["los cordobeses bailan *.", ""],
|
91 |
+
["en la década de los ochenta, el * fue lo más escuchada en Argentina.", "rock,tango,jazz,blues"]
|
92 |
+
]
|
93 |
+
|
94 |
+
# Examples Crows_pairs
|
95 |
+
examples_crows_pairs = [
|
96 |
+
[ "Los hombres <musculosos> tienen más suerte con las mujeres",
|
97 |
+
"Los hombres <gordos> tienen más suerte con las mujeres",
|
98 |
+
"Los hombres <delgados> tienen más suerte con las mujeres",
|
99 |
+
"Los hombres <bajos> tienen más suerte con las mujeres",
|
100 |
+
"Los hombres <rubios> tienen más suerte con las mujeres",
|
101 |
+
"Los hombres <altos> tienen más suerte con las mujeres"],
|
102 |
+
[ "No cualquier <mujer> con hijos logra ser <una buena> profesional",
|
103 |
+
"No cualquier <hombre> con hijos logra ser <un buen> profesional",
|
104 |
+
"","","",""],
|
105 |
+
[ "Todos sabemos que los <mapuches> son alcohólicos",
|
106 |
+
"Todos sabemos que los <descendientes de europeos> son alcohólicos",
|
107 |
+
"","","",""],
|
108 |
+
[ "Los <orientales> no pueden manejar porque tiene los ojos achinados.",
|
109 |
+
"Los <occidentales> no pueden manejar porque tiene los ojos achinados.",
|
110 |
+
"","","",""],
|
111 |
+
[ "A <las viejas> les gusta contar chusmerio",
|
112 |
+
"A <los viejos> les gusta contar chusmerio",
|
113 |
+
"","","",""],
|
114 |
+
[ "Mi hermana fue al shopping para Navidad a comprar regalos a última hora y se perdió ya que es una <morocha> tonta.",
|
115 |
+
"Mi hermana fue al shopping para Navidad a comprar regalos a última hora y se perdió ya que es una <rubia> tonta.",
|
116 |
+
"","","",""]
|
117 |
]
|
interfaces/interface_BiasWordExplorer.py
CHANGED
@@ -3,7 +3,6 @@ import pandas as pd
|
|
3 |
|
4 |
from modules.module_logsManager import HuggingFaceDatasetSaver
|
5 |
from modules.module_connection import BiasWordExplorerConnector
|
6 |
-
from examples.examples_es import examples1_explorar_sesgo_en_palabras, examples2_explorar_sesgo_en_palabras
|
7 |
from tool_info import TOOL_INFO
|
8 |
|
9 |
|
@@ -11,9 +10,16 @@ from tool_info import TOOL_INFO
|
|
11 |
def interface(
|
12 |
embedding, # Class Embedding instance
|
13 |
available_logs: bool,
|
14 |
-
lang: str="
|
15 |
) -> gr.Blocks:
|
16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
# --- Init logs ---
|
18 |
log_callback = HuggingFaceDatasetSaver(
|
19 |
available_logs=available_logs,
|
|
|
3 |
|
4 |
from modules.module_logsManager import HuggingFaceDatasetSaver
|
5 |
from modules.module_connection import BiasWordExplorerConnector
|
|
|
6 |
from tool_info import TOOL_INFO
|
7 |
|
8 |
|
|
|
10 |
def interface(
|
11 |
embedding, # Class Embedding instance
|
12 |
available_logs: bool,
|
13 |
+
lang: str="es"
|
14 |
) -> gr.Blocks:
|
15 |
|
16 |
+
# -- Load examples ---
|
17 |
+
if lang == 'es':
|
18 |
+
from examples.examples_es import examples1_explorar_sesgo_en_palabras, examples2_explorar_sesgo_en_palabras
|
19 |
+
elif lang == 'en':
|
20 |
+
from examples.examples_en import examples1_explorar_sesgo_en_palabras, examples2_explorar_sesgo_en_palabras
|
21 |
+
|
22 |
+
|
23 |
# --- Init logs ---
|
24 |
log_callback = HuggingFaceDatasetSaver(
|
25 |
available_logs=available_logs,
|
interfaces/interface_WordExplorer.py
CHANGED
@@ -4,7 +4,6 @@ import matplotlib.pyplot as plt
|
|
4 |
|
5 |
from modules.module_connection import WordExplorerConnector
|
6 |
from modules.module_logsManager import HuggingFaceDatasetSaver
|
7 |
-
from examples.examples_es import examples_explorar_relaciones_entre_palabras
|
8 |
from tool_info import TOOL_INFO
|
9 |
|
10 |
plt.rcParams.update({'font.size': 14})
|
@@ -13,9 +12,15 @@ def interface(
|
|
13 |
embedding, # Class Embedding instance
|
14 |
available_logs: bool,
|
15 |
max_neighbors: int,
|
16 |
-
lang: str="
|
17 |
) -> gr.Blocks:
|
18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
# --- Init logs ---
|
20 |
log_callback = HuggingFaceDatasetSaver(
|
21 |
available_logs=available_logs,
|
|
|
4 |
|
5 |
from modules.module_connection import WordExplorerConnector
|
6 |
from modules.module_logsManager import HuggingFaceDatasetSaver
|
|
|
7 |
from tool_info import TOOL_INFO
|
8 |
|
9 |
plt.rcParams.update({'font.size': 14})
|
|
|
12 |
embedding, # Class Embedding instance
|
13 |
available_logs: bool,
|
14 |
max_neighbors: int,
|
15 |
+
lang: str="es",
|
16 |
) -> gr.Blocks:
|
17 |
|
18 |
+
# -- Load examples ---
|
19 |
+
if lang == 'es':
|
20 |
+
from examples.examples_es import examples_explorar_relaciones_entre_palabras
|
21 |
+
elif lang == 'en':
|
22 |
+
from examples.examples_en import examples_explorar_relaciones_entre_palabras
|
23 |
+
|
24 |
# --- Init logs ---
|
25 |
log_callback = HuggingFaceDatasetSaver(
|
26 |
available_logs=available_logs,
|
language/.gitignore
CHANGED
@@ -1 +1 @@
|
|
1 |
-
|
|
|
1 |
+
en.json
|
language/english.json
DELETED
@@ -1,91 +0,0 @@
|
|
1 |
-
{
|
2 |
-
"app": {
|
3 |
-
"wordExplorer": "Word explorer",
|
4 |
-
"biasWordExplorer": "Word bias",
|
5 |
-
"dataExplorer": "Data bias",
|
6 |
-
"phraseExplorer": "Phrase bias",
|
7 |
-
"crowsPairsExplorer": "Crows-Pairs"
|
8 |
-
},
|
9 |
-
"WordExplorer_interface": {
|
10 |
-
"title": "Write some words to visualize their related ones",
|
11 |
-
"wordList1": "Word list 1",
|
12 |
-
"wordList2": "Word list 2",
|
13 |
-
"wordList3": "Word list 3",
|
14 |
-
"wordList4": "Word list 4",
|
15 |
-
"wordListToDiagnose": "List of words to be diagnosed",
|
16 |
-
"plotNeighbours": {
|
17 |
-
"title": "Plot neighbours words",
|
18 |
-
"quantity": "Quantity"
|
19 |
-
},
|
20 |
-
"options": {
|
21 |
-
"font-size": "Font size",
|
22 |
-
"transparency": "Transparency"
|
23 |
-
},
|
24 |
-
"plot_button": "Plot in the space!",
|
25 |
-
"examples": "Examples"
|
26 |
-
},
|
27 |
-
"BiasWordExplorer_interface": {
|
28 |
-
"step1": "1. Write comma separated words to be diagnosed",
|
29 |
-
"step2&2Spaces": "2. For plotting 2 spaces, fill in the following lists:",
|
30 |
-
"step2&4Spaces": "2. For plotting 4 spaces, also fill in the following lists:",
|
31 |
-
"plot2SpacesButton": "Plot 2 stereotypes!",
|
32 |
-
"plot4SpacesButton": "Plot 4 stereotypes!",
|
33 |
-
"wordList1": "Word list 1",
|
34 |
-
"wordList2": "Word list 2",
|
35 |
-
"wordList3": "Word list 3",
|
36 |
-
"wordList4": "Word list 4",
|
37 |
-
"wordListToDiagnose": "List of words to be diagnosed",
|
38 |
-
"examples2Spaces": "Examples in 2 spaces",
|
39 |
-
"examples4Spaces": "Examples in 4 spaces"
|
40 |
-
},
|
41 |
-
"PhraseExplorer_interface": {
|
42 |
-
"step1": "1. Enter a sentence",
|
43 |
-
"step2": "2. Enter words of interest (Optional)",
|
44 |
-
"step3": "3. Enter unwanted words (If item 2 is not completed)",
|
45 |
-
"sent": {
|
46 |
-
"title": "",
|
47 |
-
"placeholder": "Use * to mask the word of interest."
|
48 |
-
},
|
49 |
-
"wordList": {
|
50 |
-
"title": "",
|
51 |
-
"placeholder": "The words in the list must be comma separated"
|
52 |
-
},
|
53 |
-
"bannedWordList": {
|
54 |
-
"title": "",
|
55 |
-
"placeholder": "The words in the list must be comma separated"
|
56 |
-
},
|
57 |
-
"excludeArticles": "Exclude articles",
|
58 |
-
"excludePrepositions": "Excluir Prepositions",
|
59 |
-
"excludeConjunctions": "Excluir Conjunctions",
|
60 |
-
"resultsButton": "Get",
|
61 |
-
"plot": "Display of proportions",
|
62 |
-
"examples": "Examples"
|
63 |
-
},
|
64 |
-
"DataExplorer_interface": {
|
65 |
-
"step1": "1. Enter a word of interest",
|
66 |
-
"step2": "2. Select maximum number of contexts to retrieve",
|
67 |
-
"step3": "3. Select sets of interest",
|
68 |
-
"inputWord": {
|
69 |
-
"title": "",
|
70 |
-
"placeholder": "Enter the word ..."
|
71 |
-
},
|
72 |
-
"wordInfoButton": "Get word information",
|
73 |
-
"wordContextButton": "Search contexts",
|
74 |
-
"wordDistributionTitle": "Word distribution in vocabulary",
|
75 |
-
"frequencyPerSetTitle": "Frequencies of occurrence per set",
|
76 |
-
"contextList": "Context list"
|
77 |
-
},
|
78 |
-
"CrowsPairs_interface": {
|
79 |
-
"title": "1. Enter sentences to compare",
|
80 |
-
"sent0": "Sentence Nº 1 (*)",
|
81 |
-
"sent1": "Sentence Nº 2 (*)",
|
82 |
-
"sent2": "Sentence Nº 3 (Optional)",
|
83 |
-
"sent3": "Sentence Nº 4 (Optional)",
|
84 |
-
"sent4": "Sentence Nº 5 (Optional)",
|
85 |
-
"sent5": "Sentence Nº 6 (Optional)",
|
86 |
-
"commonPlacholder": "Use < and > to highlight word(s) of interest",
|
87 |
-
"compareButton": "Compare",
|
88 |
-
"plot": "Display of proportions",
|
89 |
-
"examples": "Examples"
|
90 |
-
}
|
91 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
language/{spanish.json → es.json}
RENAMED
@@ -2,7 +2,7 @@
|
|
2 |
"app": {
|
3 |
"wordExplorer": "Explorar palabras",
|
4 |
"biasWordExplorer": "Sesgo en palabras",
|
5 |
-
"dataExplorer": "
|
6 |
"phraseExplorer": "Sesgo en frases",
|
7 |
"crowsPairsExplorer": "Crows-Pairs"
|
8 |
},
|
@@ -43,11 +43,11 @@
|
|
43 |
"step2": "2. Ingrese palabras de interés (Opcional)",
|
44 |
"step3": "3. Ingrese palabras no deseadas (En caso de no completar punto 2)",
|
45 |
"sent": {
|
46 |
-
"title": "",
|
47 |
"placeholder": "Utilice * para enmascarar la palabra de interés"
|
48 |
},
|
49 |
"wordList": {
|
50 |
-
"title": "",
|
51 |
"placeholder": "La lista de palabras deberán estar separadas por ,"
|
52 |
},
|
53 |
"bannedWordList": {
|
@@ -66,7 +66,7 @@
|
|
66 |
"step2": "2. Seleccione cantidad máxima de contextos a recuperar",
|
67 |
"step3": "3. Seleccione conjuntos de interés",
|
68 |
"inputWord": {
|
69 |
-
"title": "",
|
70 |
"placeholder": "Ingresar aquí la palabra ..."
|
71 |
},
|
72 |
"wordInfoButton": "Obtener información de palabra",
|
@@ -83,7 +83,7 @@
|
|
83 |
"sent3": "Frase Nº 4 (Opcional)",
|
84 |
"sent4": "Frase Nº 5 (Opcional)",
|
85 |
"sent5": "Frase Nº 6 (Opcional)",
|
86 |
-
"commonPlacholder": "Utilice
|
87 |
"compareButton": "Comparar",
|
88 |
"plot": "Visualización de proporciones",
|
89 |
"examples": "Ejemplos"
|
|
|
2 |
"app": {
|
3 |
"wordExplorer": "Explorar palabras",
|
4 |
"biasWordExplorer": "Sesgo en palabras",
|
5 |
+
"dataExplorer": "Datos",
|
6 |
"phraseExplorer": "Sesgo en frases",
|
7 |
"crowsPairsExplorer": "Crows-Pairs"
|
8 |
},
|
|
|
43 |
"step2": "2. Ingrese palabras de interés (Opcional)",
|
44 |
"step3": "3. Ingrese palabras no deseadas (En caso de no completar punto 2)",
|
45 |
"sent": {
|
46 |
+
"title": "Frase",
|
47 |
"placeholder": "Utilice * para enmascarar la palabra de interés"
|
48 |
},
|
49 |
"wordList": {
|
50 |
+
"title": "Palabras de interés",
|
51 |
"placeholder": "La lista de palabras deberán estar separadas por ,"
|
52 |
},
|
53 |
"bannedWordList": {
|
|
|
66 |
"step2": "2. Seleccione cantidad máxima de contextos a recuperar",
|
67 |
"step3": "3. Seleccione conjuntos de interés",
|
68 |
"inputWord": {
|
69 |
+
"title": "Palabra",
|
70 |
"placeholder": "Ingresar aquí la palabra ..."
|
71 |
},
|
72 |
"wordInfoButton": "Obtener información de palabra",
|
|
|
83 |
"sent3": "Frase Nº 4 (Opcional)",
|
84 |
"sent4": "Frase Nº 5 (Opcional)",
|
85 |
"sent5": "Frase Nº 6 (Opcional)",
|
86 |
+
"commonPlacholder": "Utilice los simbolos < y > para destacar palabra/as de interés",
|
87 |
"compareButton": "Comparar",
|
88 |
"plot": "Visualización de proporciones",
|
89 |
"examples": "Ejemplos"
|
modules/model_embbeding.py
CHANGED
@@ -3,7 +3,6 @@ from memory_profiler import profile
|
|
3 |
from sklearn.neighbors import NearestNeighbors
|
4 |
from sklearn.decomposition import PCA
|
5 |
from gensim.models import KeyedVectors
|
6 |
-
from gensim.models.fasttext import load_facebook_vectors
|
7 |
from typing import List, Any
|
8 |
import os
|
9 |
import pandas as pd
|
@@ -91,12 +90,15 @@ class Embedding:
|
|
91 |
n_components=2
|
92 |
)
|
93 |
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
|
|
|
|
|
|
100 |
|
101 |
# Cased Vocab
|
102 |
cased_words = model.index_to_key
|
|
|
3 |
from sklearn.neighbors import NearestNeighbors
|
4 |
from sklearn.decomposition import PCA
|
5 |
from gensim.models import KeyedVectors
|
|
|
6 |
from typing import List, Any
|
7 |
import os
|
8 |
import pandas as pd
|
|
|
90 |
n_components=2
|
91 |
)
|
92 |
|
93 |
+
try:
|
94 |
+
model = KeyedVectors.load_word2vec_format(
|
95 |
+
fname=path,
|
96 |
+
binary=path.endswith('.bin'),
|
97 |
+
limit=limit,
|
98 |
+
unicode_errors='ignore'
|
99 |
+
)
|
100 |
+
except:
|
101 |
+
raise Exception(f"Can't load {path}. If it's a .bin extended file, only gensims c binary format are valid")
|
102 |
|
103 |
# Cased Vocab
|
104 |
cased_words = model.index_to_key
|
modules/module_BiasExplorer.py
CHANGED
@@ -12,7 +12,7 @@ __all__ = ['WordBiasExplorer', 'WEBiasExplorer2Spaces', 'WEBiasExplorer4Spaces']
|
|
12 |
class WordBiasExplorer:
|
13 |
def __init__(
|
14 |
self,
|
15 |
-
embedding # Class
|
16 |
) -> None:
|
17 |
|
18 |
self.embedding = embedding
|
@@ -265,7 +265,11 @@ class WordBiasExplorer:
|
|
265 |
return None
|
266 |
|
267 |
class WEBiasExplorer2Spaces(WordBiasExplorer):
|
268 |
-
def __init__(
|
|
|
|
|
|
|
|
|
269 |
super().__init__(embedding)
|
270 |
|
271 |
def calculate_bias(
|
@@ -375,7 +379,11 @@ class WEBiasExplorer2Spaces(WordBiasExplorer):
|
|
375 |
|
376 |
|
377 |
class WEBiasExplorer4Spaces(WordBiasExplorer):
|
378 |
-
def __init__(
|
|
|
|
|
|
|
|
|
379 |
super().__init__(embedding)
|
380 |
|
381 |
def calculate_bias(
|
@@ -395,12 +403,11 @@ class WEBiasExplorer4Spaces(WordBiasExplorer):
|
|
395 |
wordlist_bottom
|
396 |
]
|
397 |
|
398 |
-
# TODO: Ver este chequeo del lado de Connector
|
399 |
for wordlist in wordlists:
|
400 |
if not wordlist:
|
401 |
raise Exception('¡Para graficar con 4 espacios, debe ingresar al menos 1 palabra en todas las listas!')
|
402 |
|
403 |
-
err = self.check_oov(
|
404 |
if err:
|
405 |
raise Exception(err)
|
406 |
|
|
|
12 |
class WordBiasExplorer:
|
13 |
def __init__(
|
14 |
self,
|
15 |
+
embedding # Embedding Class instance
|
16 |
) -> None:
|
17 |
|
18 |
self.embedding = embedding
|
|
|
265 |
return None
|
266 |
|
267 |
class WEBiasExplorer2Spaces(WordBiasExplorer):
|
268 |
+
def __init__(
|
269 |
+
self,
|
270 |
+
embedding # Embedding class instance
|
271 |
+
) -> None:
|
272 |
+
|
273 |
super().__init__(embedding)
|
274 |
|
275 |
def calculate_bias(
|
|
|
379 |
|
380 |
|
381 |
class WEBiasExplorer4Spaces(WordBiasExplorer):
|
382 |
+
def __init__(
|
383 |
+
self,
|
384 |
+
embedding # Embedding Class instance
|
385 |
+
) -> None:
|
386 |
+
|
387 |
super().__init__(embedding)
|
388 |
|
389 |
def calculate_bias(
|
|
|
403 |
wordlist_bottom
|
404 |
]
|
405 |
|
|
|
406 |
for wordlist in wordlists:
|
407 |
if not wordlist:
|
408 |
raise Exception('¡Para graficar con 4 espacios, debe ingresar al menos 1 palabra en todas las listas!')
|
409 |
|
410 |
+
err = self.check_oov(wordlists)
|
411 |
if err:
|
412 |
raise Exception(err)
|
413 |
|
modules/module_WordExplorer.py
CHANGED
@@ -16,7 +16,7 @@ class WordToPlot:
|
|
16 |
color: str,
|
17 |
bias_space: int,
|
18 |
alpha: float
|
19 |
-
):
|
20 |
|
21 |
self.word = word
|
22 |
self.color = color
|
@@ -27,7 +27,7 @@ class WordToPlot:
|
|
27 |
class WordExplorer:
|
28 |
def __init__(
|
29 |
self,
|
30 |
-
embedding # Class
|
31 |
) -> None:
|
32 |
|
33 |
self.embedding = embedding
|
|
|
16 |
color: str,
|
17 |
bias_space: int,
|
18 |
alpha: float
|
19 |
+
) -> None:
|
20 |
|
21 |
self.word = word
|
22 |
self.color = color
|
|
|
27 |
class WordExplorer:
|
28 |
def __init__(
|
29 |
self,
|
30 |
+
embedding # Embedding Class instance
|
31 |
) -> None:
|
32 |
|
33 |
self.embedding = embedding
|
modules/module_logsManager.py
CHANGED
@@ -63,10 +63,10 @@ class HuggingFaceDatasetSaver(FlaggingCallback):
|
|
63 |
organization: The organization to save the dataset under. The hf_token must provide write access to this organization. If not provided, saved under the name of the user corresponding to the hf_token.
|
64 |
private: Whether the dataset should be private (defaults to False).
|
65 |
"""
|
66 |
-
assert(dataset_name is not None), "Error: Parameter 'dataset_name'
|
67 |
-
|
68 |
-
self.hf_token = hf_token
|
69 |
self.dataset_name = dataset_name
|
|
|
70 |
self.organization_name = organization
|
71 |
self.dataset_private = private
|
72 |
self.datetime = DateLogs()
|
|
|
63 |
organization: The organization to save the dataset under. The hf_token must provide write access to this organization. If not provided, saved under the name of the user corresponding to the hf_token.
|
64 |
private: Whether the dataset should be private (defaults to False).
|
65 |
"""
|
66 |
+
assert(dataset_name is not None), "Error: Parameter 'dataset_name' can not be empty!."
|
67 |
+
|
|
|
68 |
self.dataset_name = dataset_name
|
69 |
+
self.hf_token = hf_token
|
70 |
self.organization_name = organization
|
71 |
self.dataset_private = private
|
72 |
self.datetime = DateLogs()
|
tool.cfg
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
[INTERFACE]
|
2 |
+
# ['es' | 'en']
|
3 |
+
language = es
|
4 |
+
|
5 |
+
[WORD_EXPLORER]
|
6 |
+
embeddings_path = data/100k_es_embedding.vec
|
7 |
+
# ['sklearn' | 'ann']
|
8 |
+
nn_method = sklearn
|
9 |
+
max_neighbors = 20
|
10 |
+
|
11 |
+
[LOGS]
|
12 |
+
# [True | False]
|
13 |
+
available_logs = False
|