Skip to main content

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

  1. Ensure you have OpenAI's Python library installed by running the following command in the Python shell.

     pip install openai 
    
  2. Import News Analyzer API.

from src.NewsAnalyzerAPI import NewsArticle
from src.NewsAnalyzerAPI import LLMConnector
from src.NewsAnalyzerAPI import NewsAnalyzer
  1. Instantiate your LLMConnector and NewsAnalyzer objects.
connector = LLMConnector("your_llm_endpoint", "your_llm_key", "your_llm_model")
analyzer = NewsAnalyzer(connector)
  1. 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)
  1. 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)

Source distribution for llm5w1h 0.0.2
File Size Uploaded Provenance
llm5w1h-0.0.2.tar.gz 5.6 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for llm5w1h 0.0.2
File Interpreter ABI Platform
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.

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page