-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
36 lines (27 loc) · 1.32 KB
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import argparse
from datetime import datetime
from core import retrieval, summarization
def main(query):
# Initialize the start date for the query
start_date = datetime(2024, 1, 1)
# Retrieve topics and publications for the query
topics, publications_retrieved_for_topics = retrieval.initialize_for_query(query=query, start_date=start_date,
limit=100, num_topics=10)
# Get relevant works based on the query
works = retrieval.get_relevant_works_for_query(query=query, n=5, start_date=start_date)
# Display the top 5 retrieved works
print("Top 5 relevant works:")
for work in works[:5]:
print(work)
# Generate summaries for the top 3 retrieved works
summaries = summarization.summarize_works_for_query(query, works[:3])
print("\nSummaries for top 3 works:")
for summarized_work in summaries:
print(summarized_work)
if __name__ == "__main__":
# Set up command-line argument parsing
parser = argparse.ArgumentParser(description="Retrieve and summarize works related to a research query.")
parser.add_argument("query", type=str)
# Parse arguments and run the main function with the given query
args = parser.parse_args()
main(args.query)