An API wrapper for a set of API's related to NLP.
Project description
API wrapper for the Political ML API
About Political ML
Political ML is a set of API that can perform multiple NLP related tasks. Currently three things are supported:
- extracting entities
- categorising texts
- extracting meaningful content from a webpage or html
These tasks currently work best for Dutch texts. Political ML is developed by Wepublic. It only has a private API available, that's not meant for public use.
How to use
These clients are available: NerClient, CategoriseClient, ArticleExtractionClient. Below are some examples:
from political_ml import NerClient
client = NerClient(endpoint, token)
texts = [
{
"id": 1,
"text": "Mark Rutte eet wel bitterballen."
},
{
"id": 2,
"text": "Jesse Klaver eet geen bitterballen."
}
]
entities = client.ner(texts)
from political_ml import CategoriseClient
client = CategoriseClient(endpoint, token)
texts = [
{
"id": 1,
"text": "In Assendelft (gemeente Zaanstad, provincie Noord-Holland) is bij legkippen op een kleinschalige houderij vogelgriep (H5) vastgesteld. Het gaat waarschijnlijk om een hoogpathogene variant van de vogelgriep. Om verspreiding van het virus te voorkomen worden de circa 140 legkippen en 50 loopeenden van de besmette locatie geruimd. De ruiming wordt uitgevoerd door de Nederlandse Voedsel- en Warenautoriteit (NVWA)."
},
]
categories = client.categorise(texts)
from political_ml import ArticleExtractionClient
client = ArticleExtractionClient(endpoint, token)
meaningful_data = client.by_url("https://news.website/article/1")
other_meaningful_data = client.by_html("<html><body><h1>this is a title</h1><p>this is body text</p></body></html>")
For development
Requirements
- Python 3.8+
- Make
Setup for development
- Create a virtual env:
python -m virtualenv venv - Install development dependencies:
python -m pip install -e ".[dev]" - Run
make unit-testto run unit tests or runtoxto run unit tests for all support python versions. - If you have an instance of the API's available, you can run integration tests with
make integration-test.
New PRs are opened against develop.
Publishing a new version
- Bump version numbers in meta.py
- Publish a new release and create a git tag equal to the version number set in step 1.
A Github Action workflow takes care of building and publishing to PyPi.
Contact / maintainers
Jonathan (stakeholderintel@wepublic.nl) is the maintainer of this package.
Project details
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 political_ml-0.4.0.tar.gz.
File metadata
- Download URL: political_ml-0.4.0.tar.gz
- Upload date:
- Size: 5.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.10.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5a52455edc069b6d3a1e1374ec4b038c472eeb36bc0bee39cce78ace0e5faf23
|
|
| MD5 |
eac30788d85cea8e281bc9e7ef0bd6ab
|
|
| BLAKE2b-256 |
75d56aafe1f01ac47b2a24735cd3b196fe7ffb8e8dc16d144c3b8404ce5f545b
|
File details
Details for the file political_ml-0.4.0-py2.py3-none-any.whl.
File metadata
- Download URL: political_ml-0.4.0-py2.py3-none-any.whl
- Upload date:
- Size: 5.2 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.10.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
def3f214c4bcef0dbbadc6390a055d3e7926b0dd94e78c26a51ec915df1c1f78
|
|
| MD5 |
b2bb34dbad208489568e4fb399705a37
|
|
| BLAKE2b-256 |
155305ad1492007714a4cdbf13ffb9fcf9b89ff97e9c68b149bd98e7821d1502
|