1
1
import logging
2
+
3
+ import numpy as np
4
+
2
5
import augmentation_retrieval
3
6
import calculation
4
7
import json_controller
8
11
9
12
def debiasing (methods , content , bar ):
10
13
logging .info ("Debiasing-Engine: Started" )
11
-
12
14
# bar params: lower, uploaded, pca, space
13
15
if content is None :
14
16
return 'BAD REQUEST - NO BIAS SPEC JSON FOUND' , 400
@@ -21,6 +23,7 @@ def debiasing(methods, content, bar):
21
23
lex = 'false'
22
24
if 'space' in bar :
23
25
space = bar ['space' ]
26
+ print (space )
24
27
if 'uploaded' in bar :
25
28
uploaded = bar ['uploaded' ]
26
29
if 'lower' in bar :
@@ -32,23 +35,19 @@ def debiasing(methods, content, bar):
32
35
t1_list , t2_list , a1_list , a2_list , aug1_list , aug2_list = json_controller .json_to_debias_spec (content )
33
36
if len (aug1_list ) == 0 :
34
37
aug1_list , computed = augmentation_retrieval .retrieve_multiple_augmentations (t1_list )
35
- print ("here" )
36
38
if len (aug2_list ) == 0 :
37
39
aug2_list , computed = augmentation_retrieval .retrieve_multiple_augmentations (t2_list )
38
- print ("here" )
39
40
if lower == 'true' :
40
41
t1_list = [x .lower () for x in t1_list ]
41
42
t2_list = [x .lower () for x in t2_list ]
42
43
a1_list = [x .lower () for x in a1_list ]
43
44
a2_list = [x .lower () for x in a2_list ]
44
45
aug1_list = [x .lower () for x in aug1_list ]
45
46
aug2_list = [x .lower () for x in aug2_list ]
46
- print (aug1_list )
47
- print (aug2_list )
48
47
equality_sets = []
49
- for i in range ( len ( aug1_list )) :
50
- for j in range ( len ( aug2_list )) :
51
- equality_sets .append ([ aug1_list [ i ], aug2_list [ j ]] )
48
+ for t1 in aug1_list :
49
+ for t2 in aug2_list :
50
+ equality_sets .append (( t1 , t2 ) )
52
51
53
52
t1 , t2 , a1 , a2 , aug1 , aug2 , not_found , deleted = specification_controller . \
54
53
get_vectors_for_spec (space , lower , uploaded , t1_list , t2_list , a1_list , a2_list , aug1_list , aug2_list )
@@ -59,9 +58,8 @@ def debiasing(methods, content, bar):
59
58
else :
60
59
vocab , vecs = calculation .create_vocab_and_vecs (t1 , t2 , a1 , a2 , aug1 , aug2 )
61
60
62
- t1_deb , t2_deb , a1_deb , a2_deb , new_vecs = [], [], [], [], []
61
+ t1_deb , t2_deb , a1_deb , a2_deb , new_vecs = [], [], [], [], []
63
62
# print("Debiasing-Engine: Specs loaded, starting computing")
64
-
65
63
if methods == 'bam' :
66
64
t1_deb , t2_deb , a1_deb , a2_deb , new_vecs = debiasing_bam (equality_sets , vocab , vecs , t1_list , t2_list , a1_list ,
67
65
a2_list )
0 commit comments