Spaces:
Runtime error
Runtime error
[update]threshold
Browse files
app.py
CHANGED
@@ -7,21 +7,19 @@ model = "cc.en.300.bin"
|
|
7 |
model = fasttext.load_model(model)
|
8 |
|
9 |
def get_cosine(a, b):
|
10 |
-
# vectorize
|
11 |
-
# a = model.get_word_vector(a.lower())
|
12 |
-
# b = model.get_word_vector(b.lower())
|
13 |
cosine_similarity = np.dot(a, b) / (np.linalg.norm(a) * np.linalg.norm(b))
|
14 |
return cosine_similarity
|
15 |
|
16 |
|
17 |
-
def get_score(targets, answers):
|
|
|
18 |
|
19 |
results = []
|
20 |
targets = targets.split(",")
|
21 |
target_len = len(targets)
|
22 |
answers = answers.split(",")
|
23 |
|
24 |
-
th = 0.6
|
25 |
for i, target in enumerate(targets):
|
26 |
if target[0]==" ": target=target[1:]
|
27 |
# if i>2:break
|
@@ -50,12 +48,13 @@ def get_score(targets, answers):
|
|
50 |
return result
|
51 |
|
52 |
|
53 |
-
def my_app(
|
54 |
-
return get_score(
|
55 |
|
56 |
inputs = [
|
57 |
-
components.Textbox(label="
|
58 |
-
components.Textbox(label="
|
|
|
59 |
]
|
60 |
output = components.Textbox(label="Output")
|
61 |
|
|
|
7 |
model = fasttext.load_model(model)
|
8 |
|
9 |
def get_cosine(a, b):
|
|
|
|
|
|
|
10 |
cosine_similarity = np.dot(a, b) / (np.linalg.norm(a) * np.linalg.norm(b))
|
11 |
return cosine_similarity
|
12 |
|
13 |
|
14 |
+
def get_score(targets, answers, th):
|
15 |
+
th = float(th)
|
16 |
|
17 |
results = []
|
18 |
targets = targets.split(",")
|
19 |
target_len = len(targets)
|
20 |
answers = answers.split(",")
|
21 |
|
22 |
+
# th = 0.6
|
23 |
for i, target in enumerate(targets):
|
24 |
if target[0]==" ": target=target[1:]
|
25 |
# if i>2:break
|
|
|
48 |
return result
|
49 |
|
50 |
|
51 |
+
def my_app(targets, answers, th):
|
52 |
+
return get_score(targets, answers, th)
|
53 |
|
54 |
inputs = [
|
55 |
+
components.Textbox(label="Targets"),
|
56 |
+
components.Textbox(label="Answers"),
|
57 |
+
components.Textbox(label="Threshold", value=0.6),
|
58 |
]
|
59 |
output = components.Textbox(label="Output")
|
60 |
|