Spaces:
Build error
Build error
Update app.py
Browse files
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, -
|
51 |
similar_sentences = [df['quote'][i] for i in ind]
|
52 |
-
|
53 |
-
|
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):
|