A minimal client for grobid-quantities service.
Project description
Python client for Grobid Quantities
.. image:: http://img.shields.io/:license-apache-blue.svg :target: http://www.apache.org/licenses/LICENSE-2.0.html
.. image:: https://travis-ci.org/hirmeos/entity-fishing-client-python.svg?branch=master :target: https://travis-ci.org/hirmeos/entity-fishing-client-python
Python client to query the Grobid Quantities service API
_
For more information about Grobid Quantities, please check the Grobid Quantities Documentation
_.
.. _Grobid Quantities service API: http://github.com/kermitt2/grobid-quantities .. _Grobid Quantities Documentation: http://nerd.readthedocs.io
Installation
The client can be installed using pip
:
pip install grobid-quantities-client
Command Line Interface (CLI)
The CLI follows the following parameters:
python -m grobid_quantities.quantities --help
usage: quantities.py [-h] --input INPUT [--output OUTPUT] [--base-url BASE_URL] [--config CONFIG] [--n N] [--force] [--verbose]
Client for the Grobid-quantities service
optional arguments:
-h, --help show this help message and exit
--input INPUT path to the directory containing PDF files or .txt (for processCitationList only, one reference per line) to process
--output OUTPUT path to the directory where to put the results (optional)
--base-url BASE_URL Base url of the service
--config CONFIG path to the config file, default is ./config.json
--n N concurrency for service usage
--force force re-processing pdf input files when tei output files already exist
--verbose print information about processed files in the console
API Usage
Initialisation
from grobid_quantities.quantities import Quantities
client = QuantitiesAPI(base_url=server_url:port)
Process raw text: ^^^^^^^^^^^^^^
client.process_text(
"I lost two minutes"
)
Process PDF document ^^^^^^^^^^^^^^
client.process_pdf(pdfFile)
Parse the measurements ^^^^^^^^^^^^^^^^^^^^^^
client.parse_measures("from": "10", "to": "20", "unit": "km")
The response is a tuple where the first element is the status code and and the second element the response body as a dictionary. Here an example:
(
200,
{
"runtime": 123,
"measurements": [
{
"type": "value",
"quantity": {
"type": "time",
"rawValue": "two",
"rawUnit": {
"name": "minutes",
"type": "time",
"system": "non SI",
"offsetStart": 11,
"offsetEnd": 18
},
"parsedValue": {
"numeric": 2,
"structure": {
"type": "ALPHABETIC",
"formatted": "two"
},
"parsed": "two"
},
"normalizedQuantity": 120,
"normalizedUnit": {
"name": "s",
"type": "time",
"system": "SI base"
},
"offsetStart": 7,
"offsetEnd": 11
}
}
]
}
)
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
Hashes for grobid-quantities-client-0.3.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5b3d5a981b8716f0718bffb2de939cc137a974b5a7f114ec39d742aec85708a7 |
|
MD5 | 7afc33abe1e9cae6becdabe90e47dab2 |
|
BLAKE2b-256 | 63700aa81f54f65b50cd27eb92a6b5e4e618d70ea6d48a7faa1c04f44c36ad6b |