Skip to main content

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:

  1. extracting entities
  2. categorising texts
  3. 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-test to run unit tests or run tox to 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

  1. Bump version numbers in meta.py
  2. 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

political_ml-0.4.0.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

political_ml-0.4.0-py2.py3-none-any.whl (5.2 kB view details)

Uploaded Python 2Python 3

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

Hashes for political_ml-0.4.0.tar.gz
Algorithm Hash digest
SHA256 5a52455edc069b6d3a1e1374ec4b038c472eeb36bc0bee39cce78ace0e5faf23
MD5 eac30788d85cea8e281bc9e7ef0bd6ab
BLAKE2b-256 75d56aafe1f01ac47b2a24735cd3b196fe7ffb8e8dc16d144c3b8404ce5f545b

See more details on using hashes here.

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

Hashes for political_ml-0.4.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 def3f214c4bcef0dbbadc6390a055d3e7926b0dd94e78c26a51ec915df1c1f78
MD5 b2bb34dbad208489568e4fb399705a37
BLAKE2b-256 155305ad1492007714a4cdbf13ffb9fcf9b89ff97e9c68b149bd98e7821d1502

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page