Extract causal relation sentences from macroeconomic news articles
Project description
macroextract
Extract and flag causal relation sentences from macroeconomic news articles.
Installation
pip install macroextract
python -m spacy download en_core_web_md
Quick Start
import macroextract
article = """
Inflation rose to 3.5% in December, driven by higher energy costs.
The Federal Reserve maintained interest rates at 5.25%.
Consumer spending increased amid holiday shopping.
"""
# Get all sentences with relation flags
results = macroextract.extract(article)
for r in results:
marker = "✓" if r["relations"] else "✗"
print(f"{marker} {r['sentence']}")
Output:
✓ Inflation rose to 3.5% in December, driven by higher energy costs.
✗ The Federal Reserve maintained interest rates at 5.25%.
✗ Consumer spending increased amid holiday shopping.
API
extract(article_text)
Returns all extracted sentences with relation flags.
results = macroextract.extract(article_text)
# [{"sentence": "...", "relations": True}, {"sentence": "...", "relations": False}, ...]
extract_relations(article_text)
Returns only sentences containing causal relations.
relations = macroextract.extract_relations(article_text)
# [{"sentence": "...", "relations": True}, ...]
CLI
# Run extraction on test articles
macro bench extract_all
# Show relation sentences only
macro bench extract_all -v
# Show all sentences with flags (✓/✗)
macro bench extract_all -vv
# Filter by pattern
macro bench extract_all "bbc*"
# Debug sentence structure
macro debug sentence "Inflation rose due to supply constraints."
Causal Markers
The extractor identifies sentences containing:
- Connectors: because, due to, after, following, amid
- Verbs: cause, trigger, fuel, drive, support, spark, spur, dampen, contribute, push
- Nouns: contributor, driver, factor, catalyst, impact
How It Works
- Sentence Extraction: Identifies economically relevant sentences
- Relation Flagging: Marks sentences containing causal language
- Output: Returns all sentences with boolean
relationsflag
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file macroextract-0.2.0.tar.gz.
File metadata
- Download URL: macroextract-0.2.0.tar.gz
- Upload date:
- Size: 8.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.0rc1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aacc2cf5856e7e2058adcedf1bb8e926aed4952fd6990f6b87c39dbd1288bd78
|
|
| MD5 |
9c29ef5d5a7bec6ce89260e8d9d8909e
|
|
| BLAKE2b-256 |
2f6746461e06f34c1b3577171a98990170367cdbdf887f384125beb2955249f9
|
File details
Details for the file macroextract-0.2.0-py3-none-any.whl.
File metadata
- Download URL: macroextract-0.2.0-py3-none-any.whl
- Upload date:
- Size: 9.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.0rc1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a88ddb2b77265ac36b5d07a56cb40451d65733dfdca6915a559b4688ee61ea58
|
|
| MD5 |
d1d67d16565a4f1e807312dc9e2fca33
|
|
| BLAKE2b-256 |
73c1938dec9481e371166e4abd20ae8fe72d735def00abd82155f1e48399a6af
|