j-hartmann commited on
Commit
eb1e32a
1 Parent(s): e0f69b2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -80,12 +80,12 @@ 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
  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
88
- cosine_similarity = dot_product / (norm(v1) * norm(v2))
89
 
90
 
91
  # return dataframe for space output
@@ -95,8 +95,8 @@ def gr_cosine_similarity(sentence1, sentence2):
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"]
 
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
88
+ cosine_similarity = round(dot_product / (norm(v1) * norm(v2)), 3)
89
 
90
 
91
  # return dataframe for space output
 
95
 
96
  gr.Interface(gr_cosine_similarity,
97
  [
98
+ gr.inputs.Textbox(lines=1, placeholder="This tool is awesome!", default="", label="Text 1"),
99
+ gr.inputs.Textbox(lines=1, placeholder="I am so happy right now.", default="", label="Text 2"),
100
 
101
  ],
102
  ["dataframe","text"]