Spaces:
Runtime error
Runtime error
Commit
·
e0f69b2
1
Parent(s):
9d76eac
Update app.py
Browse files
app.py
CHANGED
@@ -63,13 +63,13 @@ def gr_cosine_similarity(sentence1, sentence2):
|
|
63 |
print(temp)
|
64 |
# extract scores (as many entries as exist in pred_texts)
|
65 |
for i in range(len(lines_s)):
|
66 |
-
anger.append(temp[i][0])
|
67 |
-
disgust.append(temp[i][1])
|
68 |
-
fear.append(temp[i][2])
|
69 |
-
joy.append(temp[i][3])
|
70 |
-
neutral.append(temp[i][4])
|
71 |
-
sadness.append(temp[i][5])
|
72 |
-
surprise.append(temp[i][6])
|
73 |
|
74 |
# define both vectors for the dot product
|
75 |
# each include all values for both predictions
|
@@ -80,7 +80,8 @@ def gr_cosine_similarity(sentence1, sentence2):
|
|
80 |
dot_product = dot(v1, v2)
|
81 |
|
82 |
# define df
|
83 |
-
df = pd.DataFrame(list(zip(lines_s,labels, anger, disgust, fear, joy, neutral, sadness, surprise)),
|
|
|
84 |
|
85 |
# compute cosine similarity
|
86 |
# is dot product of vectors n / norms 1*..*n vectors
|
@@ -94,8 +95,8 @@ def gr_cosine_similarity(sentence1, sentence2):
|
|
94 |
|
95 |
gr.Interface(gr_cosine_similarity,
|
96 |
[
|
97 |
-
gr.inputs.Textbox(lines=1, placeholder="This movie always makes me cry..",
|
98 |
-
gr.inputs.Textbox(lines=1, placeholder="Her dog is sad.",
|
99 |
|
100 |
],
|
101 |
["dataframe","text"]
|
|
|
63 |
print(temp)
|
64 |
# extract scores (as many entries as exist in pred_texts)
|
65 |
for i in range(len(lines_s)):
|
66 |
+
anger.append(round(temp[i][0], 3))
|
67 |
+
disgust.append(round(temp[i][1], 3))
|
68 |
+
fear.append(round(temp[i][2], 3))
|
69 |
+
joy.append(round(temp[i][3], 3))
|
70 |
+
neutral.append(round(temp[i][4], 3))
|
71 |
+
sadness.append(round(temp[i][5], 3))
|
72 |
+
surprise.append(round(temp[i][6], 3))
|
73 |
|
74 |
# define both vectors for the dot product
|
75 |
# each include all values for both predictions
|
|
|
80 |
dot_product = dot(v1, v2)
|
81 |
|
82 |
# define df
|
83 |
+
df = pd.DataFrame(list(zip(lines_s,labels, anger, disgust, fear, joy, neutral, sadness, surprise)),
|
84 |
+
columns=['text', 'max_label', 'anger', 'disgust', 'fear', 'joy', 'neutral', 'sadness', 'surprise'])
|
85 |
|
86 |
# compute cosine similarity
|
87 |
# is dot product of vectors n / norms 1*..*n vectors
|
|
|
95 |
|
96 |
gr.Interface(gr_cosine_similarity,
|
97 |
[
|
98 |
+
gr.inputs.Textbox(lines=1, placeholder="", default="This movie always makes me cry..", label="Text 1"),
|
99 |
+
gr.inputs.Textbox(lines=1, placeholder="", default="Her dog is sad.", label="Text 2"),
|
100 |
|
101 |
],
|
102 |
["dataframe","text"]
|