Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lfoppiano/grobid-quantities-python-client
Python client for Grobid Quantities
https://github.com/lfoppiano/grobid-quantities-python-client
client multithread pdf python quantities
Last synced: 17 days ago
JSON representation
Python client for Grobid Quantities
- Host: GitHub
- URL: https://github.com/lfoppiano/grobid-quantities-python-client
- Owner: lfoppiano
- License: apache-2.0
- Created: 2019-04-04T06:47:36.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-05-21T05:48:16.000Z (6 months ago)
- Last Synced: 2024-05-21T06:52:12.936Z (6 months ago)
- Topics: client, multithread, pdf, python, quantities
- Language: Python
- Homepage: http://github.com/kermitt2/grobid-quantities
- Size: 45.9 KB
- Stars: 3
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
- License: LICENSE.txt
Awesome Lists containing this project
README
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-pythonPython 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.ioInstallation
------------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 (without the suffix `/service/`)
--n N concurrency for service usage
--force force re-processing pdf input files when tei output files already existAPI Usage
---------
Initialisation::from grobid_quantities.quantities import Quantities
client = QuantitiesAPI(base_url=http(s)://server_url:port/base/url)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
}
}
]
}
)