hin/main.py

41 lines
1.2 KiB
Python
Raw Normal View History

2024-09-27 14:24:18 +02:00
import warnings
from datetime import datetime
2024-09-27 14:53:16 +02:00
from src.scrub import scrub_web
from src.key import create_queries
from src.evaluate import sort_results
2024-09-27 14:24:18 +02:00
# Suppress FutureWarnings and other warnings
warnings.simplefilter(action='ignore', category=FutureWarning)
2024-09-27 14:53:16 +02:00
#subject = input("Enter subject : ")
subject = "Experiments, numerical models and optimization of carbon-epoxy plates damped by a frequency-dependent interleaved viscoelastic layer"
2024-09-27 14:24:18 +02:00
2024-09-27 14:53:16 +02:00
current_time = datetime.now().strftime("%m-%d_%H-%M")
file_path = f"logs/run_{current_time}.log"
log_content = f"# Hin run, {current_time}\n\nSubject : {subject}\n\n"
2024-09-27 14:24:18 +02:00
2024-09-27 14:53:16 +02:00
queries, keyword_log = create_queries(subject)
log_content += keyword_log
2024-09-27 14:24:18 +02:00
2024-09-27 14:53:16 +02:00
results, scrub_log = scrub_web(queries)
log_content += scrub_log
2024-09-27 14:24:18 +02:00
2024-09-27 14:53:16 +02:00
sorted_results, results_log = sort_results(subject, results)
log_content += results_log
2024-09-27 14:24:18 +02:00
print("\n\n### Done ###\n")
# Print the top 10 results
2024-09-27 14:53:16 +02:00
for idx, result in enumerate(sorted_results[:10], 1):
2024-09-27 14:24:18 +02:00
print(f"Rank {idx} ({result['similarity']:.4f}):")
print(f"Title: {result['title']}")
print(f"URL: {result['url']}")
print(f"Snippet: {result['snippet']}")
print("-" * 40)
# Create and save the file
with open(file_path, 'w') as file:
2024-09-27 14:53:16 +02:00
file.write(log_content)