Skip to content

Commit

Permalink
Update run_knn_similarity_search.py
Browse files Browse the repository at this point in the history
- Improved printing format
  • Loading branch information
tfnribeiro committed Nov 25, 2024
1 parent 732ae8c commit b7ae60c
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions tools/run_knn_similarity_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,6 @@ def search_similar_to_keyword(keyword):
app = create_app()
app.app_context().push()

es = Elasticsearch(ES_CONN_STRING)

a_found, hits = find_articles_based_on_text(keyword)
print("------------------------------------------------")

Expand All @@ -100,13 +98,7 @@ def search_similar_to_keyword(keyword):
print("Similar articles:")
for hit in hits:
print(
hit["_id"],
hit["_source"]["old_topics"],
hit["_source"]["language"],
f"New Topics: {hit['_source']['topics']}",
hit["_source"].get("url_keywords", []),
hit["_source"].get("url", ""),
hit["_score"],
f"{hit["_id"]} {hit["_score"]:.4f} {hit["_source"]["language"]}, Topics: {hit['_source']['topics']} {hit["_source"].get("url_keywords", [])} {hit["_source"].get("url", "")}"
)
print("Article list: ")
print(a_found)
Expand All @@ -120,3 +112,5 @@ def search_similar_to_keyword(keyword):
search_similar_to_article(article_id)
if keyword:
search_similar_to_keyword(keyword)
if not keyword and not article_id:
parser.print_help()

0 comments on commit b7ae60c

Please sign in to comment.