chunked content to 512

This commit is contained in:
Simon Moisy 2025-03-22 08:00:58 +08:00
parent 3864d7e93c
commit 679f1bd941

View File

@ -44,16 +44,24 @@ if __name__ == "__main__":
Base.metadata.create_all(engine)
result = analyzer.classify_article_finbert("Strong earning growth and expending market shares have positionned the company for long term success.")
print(f'result {result}')
# for file, content in html_files.items():
# result = analyzer.classify_article_finbert(content)
# filename = os.path.basename(file)
# result = analyzer.classify_article_finbert("Strong earning growth and expending market shares have positionned the company for long term success.")
# print(f'result {result}')
for file, content in html_files.items():
chunk_size = 512
chunks = [content[i:i+chunk_size] for i in range(0, len(content), chunk_size)]
results = []
for chunk in chunks:
if chunk.strip():
chunk_result = analyzer.classify_article_finbert(chunk)
results.extend(chunk_result)
result = results if results else [{'label': 'neutral', 'score': 0.0}]
filename = os.path.basename(file)
print(f'result {result}')
# label = result[0]['label']
# score = result[0]['score']