LLM-5W1H
This project is a LLM-based System for extracting main events from news articles.
Step-by-Step Tutorial on how to use News Analyzer API
-
Ensure you have OpenAI's Python library installed by running the following command in the Python shell.
pip install openai -
Import News Analyzer API.
from src.NewsAnalyzerAPI import NewsArticle
from src.NewsAnalyzerAPI import LLMConnector
from src.NewsAnalyzerAPI import NewsAnalyzer
- Instantiate your LLMConnector and NewsAnalyzer objects.
connector = LLMConnector("your_llm_endpoint", "your_llm_key", "your_llm_model")
analyzer = NewsAnalyzer(connector)
- Give an example article to the analyzer, with the following parameters: title, description, text, date, url.
title = "Taliban attacks German consulate in northern Afghan city of Mazar-i-Sharif with truck bomb"
description = "The death toll from a powerful Taliban truck bombing at the German consulate in Afghanistan's Mazar-i-Sharif city rose to at least six Friday, with more than 100 others wounded in a major militant assault."
text = "The death toll from a powerful Taliban truck bombing at the German consulate in Afghanistan's Mazar-i-Sharif city rose to at least six Friday, with more than 100 others wounded in a major militant assault. The Taliban said the bombing late Thursday, which tore a massive crater in the road and overturned cars, was a \"revenge attack\" for US air strikes this month in the volatile province of Kunduz that left 32 civilians dead. The explosion, followed by sporadic gunfire, reverberated across the usually tranquil northern city, smashing windows of nearby shops and leaving terrified local residents fleeing for cover. \"The suicide attacker rammed his explosives-laden car into the wall of the German consulate,\" local police chief Sayed Kamal Sadat told AFP. All German staff from the consulate were unharmed, according to the foreign ministry in Berlin."
date = "2016-11-11 08:42:13"
url = "http://www.telegraph.co.uk/news/2016/11/10/taliban-attack-german-consulate-in-northern-afghan-city-of-mazar/"
article_example = NewsArticle(title, description, text, date, url)
- Extract the article components by calling process_article(article) function (or process_articles(articles) for a list of articles) in the created NewsAnalyzer object:
analyzer.process_article(article_example)
This function extracts all of the article components: what, where, when, who, why, how (5W1H). It is also possible to extract each of them separately by calling the function identify_component(article, component) in the same NewsAnalyzer object, where the 'component' parameter must be one of the components from 5W1H. For example:
analyzer.identify_component(article_example, 'what')
This line returns the 'what' component from the article as a result.
Metadata
Release files for llm5w1h 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| llm5w1h-0.0.2.tar.gz | 5.6 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| llm5w1h-0.0.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 12.1 kB
Release files / llm5w1h-0.0.2.tar.gz
| Download URL | llm5w1h-0.0.2.tar.gz |
|---|---|
| Size | 5.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a88404744e419c11397902b56b64aca65daa3cd0c0d06a3efbc7268518958456
|
|
BLAKE2b-256 checksum How to use checksums |
afac8eaa592e5c187cbd17497195aa7c26545391332958ff78594e207e543c7e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.12
|
Release files / llm5w1h-0.0.2-py3-none-any.whl
| Download URL | llm5w1h-0.0.2-py3-none-any.whl |
|---|---|
| Size | 6.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fcea2ec8fae637909e9683863bda9b823cfa290f331d0f10840f512ff61a9d2d
|
|
BLAKE2b-256 checksum How to use checksums |
c7e14b9501fba73e931ce359ebf7b1c37da36aab225dce4384f8a0556868daa5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.12
|
Security for llm5w1h 0.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.