eliwill commited on
Commit
bf09a10
·
1 Parent(s): 335b9d0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -47,10 +47,10 @@ def get_similar_quotes(philosopher, question):
47
  df = philosopher_dictionary[philosopher]['dataframe']
48
  question_embedding = model.encode(question)
49
  sims = [util.dot_score(question_embedding, quote_embedding) for quote_embedding in df['Embedding']]
50
- ind = np.argpartition(sims, -3)[-3:]
51
  similar_sentences = [df['quote'][i] for i in ind]
52
- top3quotes = pd.DataFrame(data = similar_sentences, columns=["Quotes"], index=range(1,4))
53
- top3quotes['Quotes'] = top3quotes['Quotes'].str[:-1].str[:250] + "..."
54
  return top3quotes
55
 
56
  def main(question, philosopher):
 
47
  df = philosopher_dictionary[philosopher]['dataframe']
48
  question_embedding = model.encode(question)
49
  sims = [util.dot_score(question_embedding, quote_embedding) for quote_embedding in df['Embedding']]
50
+ ind = np.argpartition(sims, -4)[-4:]
51
  similar_sentences = [df['quote'][i] for i in ind]
52
+ top4quotes = pd.DataFrame(data = similar_sentences, columns=["Quotes"], index=range(1,5))
53
+ top4quotes['Quotes'] = top4quotes['Quotes'].str[:-1].str[:250] + "..."
54
  return top3quotes
55
 
56
  def main(question, philosopher):