grobid-client-python 0.0.15__tar.gz → 0.0.16__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {grobid_client_python-0.0.15 → grobid_client_python-0.0.16}/PKG-INFO +300 -141
- grobid_client_python-0.0.16/Readme.md +378 -0
- grobid_client_python-0.0.16/example.py +14 -0
- {grobid_client_python-0.0.15 → grobid_client_python-0.0.16}/grobid_client/grobid_client.py +132 -94
- {grobid_client_python-0.0.15 → grobid_client_python-0.0.16}/grobid_client_python.egg-info/PKG-INFO +300 -141
- {grobid_client_python-0.0.15 → grobid_client_python-0.0.16}/pyproject.toml +1 -1
- {grobid_client_python-0.0.15 → grobid_client_python-0.0.16}/tests/test_grobid_client.py +2 -2
- {grobid_client_python-0.0.15 → grobid_client_python-0.0.16}/tests/test_integration.py +4 -4
- grobid_client_python-0.0.15/Readme.md +0 -219
- grobid_client_python-0.0.15/example.py +0 -5
- {grobid_client_python-0.0.15 → grobid_client_python-0.0.16}/.github/workflows/ci-build.yml +0 -0
- {grobid_client_python-0.0.15 → grobid_client_python-0.0.16}/.github/workflows/ci-release.yml +0 -0
- {grobid_client_python-0.0.15 → grobid_client_python-0.0.16}/.gitignore +0 -0
- {grobid_client_python-0.0.15 → grobid_client_python-0.0.16}/LICENSE +0 -0
- {grobid_client_python-0.0.15 → grobid_client_python-0.0.16}/MANIFEST.in +0 -0
- {grobid_client_python-0.0.15 → grobid_client_python-0.0.16}/config.json +0 -0
- {grobid_client_python-0.0.15 → grobid_client_python-0.0.16}/grobid_client/__init__.py +0 -0
- {grobid_client_python-0.0.15 → grobid_client_python-0.0.16}/grobid_client/client.py +0 -0
- {grobid_client_python-0.0.15 → grobid_client_python-0.0.16}/grobid_client_python.egg-info/SOURCES.txt +0 -0
- {grobid_client_python-0.0.15 → grobid_client_python-0.0.16}/grobid_client_python.egg-info/dependency_links.txt +0 -0
- {grobid_client_python-0.0.15 → grobid_client_python-0.0.16}/grobid_client_python.egg-info/entry_points.txt +0 -0
- {grobid_client_python-0.0.15 → grobid_client_python-0.0.16}/grobid_client_python.egg-info/requires.txt +0 -0
- {grobid_client_python-0.0.15 → grobid_client_python-0.0.16}/grobid_client_python.egg-info/top_level.txt +0 -0
- {grobid_client_python-0.0.15 → grobid_client_python-0.0.16}/pytest.ini +0 -0
- {grobid_client_python-0.0.15 → grobid_client_python-0.0.16}/requirements.txt +0 -0
- {grobid_client_python-0.0.15 → grobid_client_python-0.0.16}/resources/20180928112135.png +0 -0
- {grobid_client_python-0.0.15 → grobid_client_python-0.0.16}/resources/20180928112138.csv +0 -0
- {grobid_client_python-0.0.15 → grobid_client_python-0.0.16}/resources/test_out/0046d83a-edd6-4631-b57c-755cdcce8b7f.tei.xml +0 -0
- {grobid_client_python-0.0.15 → grobid_client_python-0.0.16}/resources/test_out/test_1/0f318087-b211-4ace-8ac9-3d9372a73c1c.tei.xml +0 -0
- {grobid_client_python-0.0.15 → grobid_client_python-0.0.16}/resources/test_pdf/0046d83a-edd6-4631-b57c-755cdcce8b7f.pdf +0 -0
- {grobid_client_python-0.0.15 → grobid_client_python-0.0.16}/resources/test_pdf/0046d83a-edd6-4631-b57c-755cdcce8b7f.tei.xml +0 -0
- {grobid_client_python-0.0.15 → grobid_client_python-0.0.16}/resources/test_txt/reference-strings-1.txt +0 -0
- {grobid_client_python-0.0.15 → grobid_client_python-0.0.16}/resources/test_txt/reference-strings-2.txt +0 -0
- {grobid_client_python-0.0.15 → grobid_client_python-0.0.16}/resources/test_txt/reference-strings-3.txt +0 -0
- {grobid_client_python-0.0.15 → grobid_client_python-0.0.16}/resources/test_txt/reference-strings-4.txt +0 -0
- {grobid_client_python-0.0.15 → grobid_client_python-0.0.16}/resources/test_txt/reference-strings-5.txt +0 -0
- {grobid_client_python-0.0.15 → grobid_client_python-0.0.16}/resources/test_txt/reference-strings-6.txt +0 -0
- {grobid_client_python-0.0.15 → grobid_client_python-0.0.16}/resources/test_txt/reference-strings-7.txt +0 -0
- {grobid_client_python-0.0.15 → grobid_client_python-0.0.16}/setup.cfg +0 -0
- {grobid_client_python-0.0.15 → grobid_client_python-0.0.16}/tests/__init__.py +0 -0
- {grobid_client_python-0.0.15 → grobid_client_python-0.0.16}/tests/conftest.py +0 -0
- {grobid_client_python-0.0.15 → grobid_client_python-0.0.16}/tests/run_tests.py +0 -0
- {grobid_client_python-0.0.15 → grobid_client_python-0.0.16}/tests/test_client.py +0 -0
- {grobid_client_python-0.0.15 → grobid_client_python-0.0.16}/tests/test_config.json +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: grobid-client-python
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.16
|
|
4
4
|
Summary: Simple python client for GROBID REST services
|
|
5
5
|
Author-email: Patrice Lopez <patrice.lopez@science-miner.com>
|
|
6
6
|
Maintainer-email: Patrice Lopez <patrice.lopez@science-miner.com>, Luca Foppiano <lucanoro@duck.com>
|
|
@@ -214,222 +214,381 @@ Project-URL: Changelog, https://github.com/kermitt2/grobid_client_python
|
|
|
214
214
|
Description-Content-Type: text/markdown
|
|
215
215
|
Requires-Dist: requests
|
|
216
216
|
|
|
217
|
+
# GROBID Client Python
|
|
218
|
+
|
|
217
219
|
[](https://badge.fury.io/py/grobid_client_python)
|
|
218
220
|
[](https://archive.softwareheritage.org/browse/origin/https://github.com/kermitt2/grobid_client_python/)
|
|
219
221
|
[](http://www.apache.org/licenses/LICENSE-2.0.html)
|
|
220
222
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
223
|
+
A simple, efficient Python client for [GROBID](https://github.com/kermitt2/grobid) REST services that provides concurrent processing capabilities for PDF documents, reference strings, and patents.
|
|
224
|
+
|
|
225
|
+
## 📋 Table of Contents
|
|
226
|
+
|
|
227
|
+
- [Features](#-features)
|
|
228
|
+
- [Prerequisites](#-prerequisites)
|
|
229
|
+
- [Installation](#-installation)
|
|
230
|
+
- [Quick Start](#-quick-start)
|
|
231
|
+
- [Usage](#-usage)
|
|
232
|
+
- [Command Line Interface](#command-line-interface)
|
|
233
|
+
- [Python Library](#python-library)
|
|
234
|
+
- [Configuration](#-configuration)
|
|
235
|
+
- [Services](#-services)
|
|
236
|
+
- [Testing](#-testing)
|
|
237
|
+
- [Performance](#-performance)
|
|
238
|
+
- [Development](#-development)
|
|
239
|
+
- [License](#-license)
|
|
240
|
+
|
|
241
|
+
## ✨ Features
|
|
242
|
+
|
|
243
|
+
- **Concurrent Processing**: Efficiently process multiple documents in parallel
|
|
244
|
+
- **Flexible Input**: Process PDF files, text files with references, and XML patents
|
|
245
|
+
- **Configurable**: Customizable server settings, timeouts, and processing options
|
|
246
|
+
- **Command Line & Library**: Use as a standalone CLI tool or import into your Python projects
|
|
247
|
+
- **Coordinate Extraction**: Optional PDF coordinate extraction for precise element positioning
|
|
248
|
+
- **Sentence Segmentation**: Layout-aware sentence segmentation capabilities
|
|
249
|
+
|
|
250
|
+
## 📋 Prerequisites
|
|
251
|
+
|
|
252
|
+
- **Python**: 3.8 - 3.13 (tested versions)
|
|
253
|
+
- **GROBID Server**: A running GROBID service instance
|
|
254
|
+
- Local installation: [GROBID Documentation](http://grobid.readthedocs.io/)
|
|
255
|
+
- Docker: `docker run -t --rm -p 8070:8070 lfoppiano/grobid:0.8.2`
|
|
256
|
+
- Default server: `http://localhost:8070`
|
|
257
|
+
- Online demo: https://lfoppiano-grobid.hf.space (usage limits apply)
|
|
224
258
|
|
|
225
259
|
> [!IMPORTANT]
|
|
226
|
-
>
|
|
260
|
+
> GROBID supports Windows only through Docker containers. See the [Docker documentation](https://grobid.readthedocs.io/en/latest/Grobid-docker/) for details.
|
|
227
261
|
|
|
228
|
-
##
|
|
262
|
+
## 🚀 Installation
|
|
229
263
|
|
|
230
|
-
|
|
231
|
-
By default, it is assumed that the server will run on the address `http://localhost:8070`.
|
|
232
|
-
You can change the server address by editing the file `config.json`, see below.
|
|
264
|
+
Choose one of the following installation methods:
|
|
233
265
|
|
|
234
|
-
|
|
266
|
+
### PyPI (Recommended)
|
|
267
|
+
```bash
|
|
268
|
+
pip install grobid-client-python
|
|
269
|
+
```
|
|
235
270
|
|
|
236
|
-
|
|
237
|
-
|
|
271
|
+
### Development Version
|
|
272
|
+
```bash
|
|
273
|
+
pip install git+https://github.com/kermitt2/grobid_client_python.git
|
|
274
|
+
```
|
|
238
275
|
|
|
239
|
-
|
|
276
|
+
### Local Development
|
|
277
|
+
```bash
|
|
278
|
+
git clone https://github.com/kermitt2/grobid_client_python
|
|
279
|
+
cd grobid_client_python
|
|
280
|
+
pip install -e .
|
|
281
|
+
```
|
|
240
282
|
|
|
241
|
-
|
|
283
|
+
## ⚡ Quick Start
|
|
242
284
|
|
|
243
|
-
|
|
285
|
+
### Command Line
|
|
286
|
+
```bash
|
|
287
|
+
# Process PDFs in a directory
|
|
288
|
+
grobid_client --input ./pdfs --output ./output processFulltextDocument
|
|
244
289
|
|
|
245
|
-
|
|
246
|
-
|
|
290
|
+
# Process with custom server
|
|
291
|
+
grobid_client --server https://your-grobid-server.com --input ./pdfs processFulltextDocument
|
|
247
292
|
```
|
|
248
293
|
|
|
249
|
-
|
|
294
|
+
### Python Library
|
|
295
|
+
```python
|
|
296
|
+
from grobid_client.grobid_client import GrobidClient
|
|
297
|
+
|
|
298
|
+
# Create client instance
|
|
299
|
+
client = GrobidClient(config_path="./config.json")
|
|
250
300
|
|
|
251
|
-
|
|
252
|
-
|
|
301
|
+
# Process documents
|
|
302
|
+
client.process("processFulltextDocument", "/path/to/pdfs", n=10)
|
|
253
303
|
```
|
|
254
304
|
|
|
255
|
-
|
|
305
|
+
## 📖 Usage
|
|
306
|
+
|
|
307
|
+
### Command Line Interface
|
|
256
308
|
|
|
309
|
+
The client provides a comprehensive CLI with the following syntax:
|
|
310
|
+
|
|
311
|
+
```bash
|
|
312
|
+
grobid_client [OPTIONS] SERVICE
|
|
257
313
|
```
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
314
|
+
|
|
315
|
+
#### Available Services
|
|
316
|
+
|
|
317
|
+
| Service | Description | Input Format |
|
|
318
|
+
|---------|-------------|--------------|
|
|
319
|
+
| `processFulltextDocument` | Extract full document structure | PDF files |
|
|
320
|
+
| `processHeaderDocument` | Extract document metadata | PDF files |
|
|
321
|
+
| `processReferences` | Extract bibliographic references | PDF files |
|
|
322
|
+
| `processCitationList` | Parse citation strings | Text files (one citation per line) |
|
|
323
|
+
| `processCitationPatentST36` | Process patent citations | XML ST36 format |
|
|
324
|
+
| `processCitationPatentPDF` | Process patent PDFs | PDF files |
|
|
325
|
+
|
|
326
|
+
#### Common Options
|
|
327
|
+
|
|
328
|
+
| Option | Description | Default |
|
|
329
|
+
|--------|-------------|---------|
|
|
330
|
+
| `--input` | Input directory path | Required |
|
|
331
|
+
| `--output` | Output directory path | Same as input |
|
|
332
|
+
| `--server` | GROBID server URL | `http://localhost:8070` |
|
|
333
|
+
| `--n` | Concurrency level | 10 |
|
|
334
|
+
| `--config` | Config file path | Optional |
|
|
335
|
+
| `--force` | Overwrite existing files | False |
|
|
336
|
+
| `--verbose` | Enable verbose logging | False |
|
|
337
|
+
|
|
338
|
+
#### Processing Options
|
|
339
|
+
|
|
340
|
+
| Option | Description |
|
|
341
|
+
|--------|-------------|
|
|
342
|
+
| `--generateIDs` | Generate random XML IDs |
|
|
343
|
+
| `--consolidate_header` | Consolidate header metadata |
|
|
344
|
+
| `--consolidate_citations` | Consolidate bibliographic references |
|
|
345
|
+
| `--include_raw_citations` | Include raw citation text |
|
|
346
|
+
| `--include_raw_affiliations` | Include raw affiliation text |
|
|
347
|
+
| `--teiCoordinates` | Add PDF coordinates to XML |
|
|
348
|
+
| `--segmentSentences` | Segment sentences with coordinates |
|
|
349
|
+
| `--flavor` | Processing flavor for fulltext extraction |
|
|
350
|
+
|
|
351
|
+
#### Examples
|
|
352
|
+
|
|
353
|
+
```bash
|
|
354
|
+
# Basic fulltext processing
|
|
355
|
+
grobid_client --input ~/documents --output ~/results processFulltextDocument
|
|
356
|
+
|
|
357
|
+
# High concurrency with coordinates
|
|
358
|
+
grobid_client --input ~/pdfs --output ~/tei --n 20 --teiCoordinates processFulltextDocument
|
|
359
|
+
|
|
360
|
+
# Process citations with custom server
|
|
361
|
+
grobid_client --server https://grobid.example.com --input ~/citations.txt processCitationList
|
|
362
|
+
|
|
363
|
+
# Force reprocessing with sentence segmentation
|
|
364
|
+
grobid_client --input ~/docs --force --segmentSentences processFulltextDocument
|
|
261
365
|
```
|
|
262
366
|
|
|
263
|
-
|
|
367
|
+
### Python Library
|
|
264
368
|
|
|
265
|
-
|
|
369
|
+
#### Basic Usage
|
|
266
370
|
|
|
267
|
-
|
|
371
|
+
```python
|
|
372
|
+
from grobid_client.grobid_client import GrobidClient
|
|
268
373
|
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
[--n N] [--generateIDs] [--consolidate_header]
|
|
272
|
-
[--consolidate_citations] [--include_raw_citations]
|
|
273
|
-
[--include_raw_affiliations] [--force] [--teiCoordinates]
|
|
274
|
-
[--verbose] [--flavor FLAVOR]
|
|
275
|
-
service
|
|
276
|
-
|
|
277
|
-
Client for GROBID services
|
|
278
|
-
|
|
279
|
-
positional arguments:
|
|
280
|
-
service one of ['processFulltextDocument',
|
|
281
|
-
'processHeaderDocument', 'processReferences',
|
|
282
|
-
'processCitationList','processCitationPatentST36',
|
|
283
|
-
'processCitationPatentPDF']
|
|
284
|
-
|
|
285
|
-
optional arguments:
|
|
286
|
-
-h, --help show this help message and exit
|
|
287
|
-
--input INPUT path to the directory containing PDF files or .txt
|
|
288
|
-
(for processCitationList only, one reference per line)
|
|
289
|
-
to process
|
|
290
|
-
--output OUTPUT path to the directory where to put the results
|
|
291
|
-
(optional)
|
|
292
|
-
--config CONFIG path to the config file, default is ./config.json
|
|
293
|
-
--n N concurrency for service usage
|
|
294
|
-
--generateIDs generate random xml:id to textual XML elements of the
|
|
295
|
-
result files
|
|
296
|
-
--consolidate_header call GROBID with consolidation of the metadata
|
|
297
|
-
extracted from the header
|
|
298
|
-
--consolidate_citations
|
|
299
|
-
call GROBID with consolidation of the extracted
|
|
300
|
-
bibliographical references
|
|
301
|
-
--include_raw_citations
|
|
302
|
-
call GROBID requesting the extraction of raw citations
|
|
303
|
-
--include_raw_affiliations
|
|
304
|
-
call GROBID requestiong the extraciton of raw
|
|
305
|
-
affiliations
|
|
306
|
-
--force force re-processing pdf input files when tei output
|
|
307
|
-
files already exist
|
|
308
|
-
--teiCoordinates add the original PDF coordinates (bounding boxes) to
|
|
309
|
-
the extracted elements
|
|
310
|
-
--segmentSentences segment sentences in the text content of the document
|
|
311
|
-
with additional <s> elements
|
|
312
|
-
--verbose print information about processed files in the console
|
|
313
|
-
--flavor specifcy the flavor to be used. Current accepted
|
|
314
|
-
values: `article/light`, `article/light-ref`, `sdo/ietf`.
|
|
315
|
-
```
|
|
374
|
+
# Initialize with default localhost server
|
|
375
|
+
client = GrobidClient()
|
|
316
376
|
|
|
317
|
-
|
|
318
|
-
|
|
377
|
+
# Initialize with custom server
|
|
378
|
+
client = GrobidClient(grobid_server="https://your-server.com")
|
|
379
|
+
|
|
380
|
+
# Initialize with config file
|
|
381
|
+
client = GrobidClient(config_path="./config.json")
|
|
319
382
|
|
|
383
|
+
# Process documents
|
|
384
|
+
client.process(
|
|
385
|
+
service="processFulltextDocument",
|
|
386
|
+
input_path="/path/to/pdfs",
|
|
387
|
+
output_path="/path/to/output",
|
|
388
|
+
n=20
|
|
389
|
+
)
|
|
390
|
+
```
|
|
320
391
|
|
|
321
|
-
|
|
392
|
+
#### Advanced Usage
|
|
322
393
|
|
|
323
|
-
```
|
|
324
|
-
|
|
394
|
+
```python
|
|
395
|
+
# Process with specific options
|
|
396
|
+
client.process(
|
|
397
|
+
service="processFulltextDocument",
|
|
398
|
+
input_path="/path/to/pdfs",
|
|
399
|
+
output_path="/path/to/output",
|
|
400
|
+
n=10,
|
|
401
|
+
generateIDs=True,
|
|
402
|
+
consolidate_header=True,
|
|
403
|
+
teiCoordinates=True,
|
|
404
|
+
segmentSentences=True
|
|
405
|
+
)
|
|
406
|
+
|
|
407
|
+
# Process citation lists
|
|
408
|
+
client.process(
|
|
409
|
+
service="processCitationList",
|
|
410
|
+
input_path="/path/to/citations.txt",
|
|
411
|
+
output_path="/path/to/output"
|
|
412
|
+
)
|
|
325
413
|
```
|
|
326
414
|
|
|
327
|
-
|
|
415
|
+
## ⚙️ Configuration
|
|
416
|
+
|
|
417
|
+
Configuration can be provided via a JSON file. When using the CLI, the `--server` argument overrides the config file settings.
|
|
328
418
|
|
|
329
|
-
|
|
419
|
+
### Default Configuration
|
|
330
420
|
|
|
331
|
-
```
|
|
332
|
-
|
|
421
|
+
```json
|
|
422
|
+
{
|
|
423
|
+
"grobid_server": "http://localhost:8070",
|
|
424
|
+
"batch_size": 1000,
|
|
425
|
+
"sleep_time": 5,
|
|
426
|
+
"timeout": 60,
|
|
427
|
+
"coordinates": ["persName", "figure", "ref", "biblStruct", "formula", "s"]
|
|
428
|
+
}
|
|
333
429
|
```
|
|
334
430
|
|
|
335
|
-
|
|
431
|
+
### Configuration Parameters
|
|
336
432
|
|
|
337
|
-
|
|
433
|
+
| Parameter | Description | Default |
|
|
434
|
+
|-----------|-------------|---------|
|
|
435
|
+
| `grobid_server` | GROBID server URL | `http://localhost:8070` |
|
|
436
|
+
| `batch_size` | Thread pool size | 1000 |
|
|
437
|
+
| `sleep_time` | Wait time when server is busy (seconds) | 5 |
|
|
438
|
+
| `timeout` | Client-side timeout (seconds) | 60 |
|
|
439
|
+
| `coordinates` | XML elements for coordinate extraction | See above |
|
|
338
440
|
|
|
339
|
-
|
|
441
|
+
> [!TIP]
|
|
442
|
+
> Since version 0.0.12, the config file is optional. The client will use default localhost settings if no configuration is provided.
|
|
340
443
|
|
|
341
|
-
|
|
342
|
-
> grobid_client --input resources/test_txt/ --output resources/test_out/ --n 20 processCitationList
|
|
343
|
-
```
|
|
444
|
+
## 🔬 Services
|
|
344
445
|
|
|
345
|
-
|
|
446
|
+
### Fulltext Document Processing
|
|
447
|
+
Extracts complete document structure including headers, body text, figures, tables, and references.
|
|
346
448
|
|
|
347
|
-
```
|
|
348
|
-
|
|
449
|
+
```bash
|
|
450
|
+
grobid_client --input pdfs/ --output results/ processFulltextDocument
|
|
349
451
|
```
|
|
350
452
|
|
|
351
|
-
|
|
453
|
+
### Header Document Processing
|
|
454
|
+
Extracts only document metadata (title, authors, abstract, etc.).
|
|
352
455
|
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
456
|
+
```bash
|
|
457
|
+
grobid_client --input pdfs/ --output headers/ processHeaderDocument
|
|
458
|
+
```
|
|
356
459
|
|
|
357
|
-
|
|
358
|
-
from
|
|
460
|
+
### Reference Processing
|
|
461
|
+
Extracts and structures bibliographic references from documents.
|
|
359
462
|
|
|
360
|
-
|
|
361
|
-
|
|
463
|
+
```bash
|
|
464
|
+
grobid_client --input pdfs/ --output refs/ processReferences
|
|
362
465
|
```
|
|
363
466
|
|
|
364
|
-
|
|
467
|
+
### Citation List Processing
|
|
468
|
+
Parses raw citation strings from text files.
|
|
365
469
|
|
|
366
|
-
|
|
470
|
+
```bash
|
|
471
|
+
grobid_client --input citations.txt --output parsed/ processCitationList
|
|
472
|
+
```
|
|
367
473
|
|
|
368
474
|
> [!TIP]
|
|
369
|
-
>
|
|
475
|
+
> For citation lists, input should be text files with one citation string per line.
|
|
370
476
|
|
|
371
|
-
|
|
477
|
+
## 🧪 Testing
|
|
372
478
|
|
|
373
|
-
|
|
479
|
+
The project includes comprehensive unit and integration tests using pytest.
|
|
374
480
|
|
|
375
|
-
|
|
481
|
+
### Running Tests
|
|
376
482
|
|
|
377
|
-
|
|
483
|
+
```bash
|
|
484
|
+
# Install development dependencies
|
|
485
|
+
pip install -e .[dev]
|
|
378
486
|
|
|
379
|
-
|
|
487
|
+
# Run all tests
|
|
488
|
+
pytest
|
|
380
489
|
|
|
381
|
-
|
|
490
|
+
# Run with coverage
|
|
491
|
+
pytest --cov=grobid_client
|
|
382
492
|
|
|
383
|
-
|
|
493
|
+
# Run specific test file
|
|
494
|
+
pytest tests/test_client.py
|
|
384
495
|
|
|
496
|
+
# Run with verbose output
|
|
497
|
+
pytest -v
|
|
385
498
|
```
|
|
386
|
-
{
|
|
387
|
-
"grobid_server": "http://localhost:8070",
|
|
388
|
-
"batch_size": 1000,
|
|
389
|
-
"sleep_time": 5,
|
|
390
|
-
"timeout": 60,
|
|
391
|
-
"coordinates": [ "persName", "figure", "ref", "biblStruct", "formula", "s" ]
|
|
392
|
-
}
|
|
393
|
-
```
|
|
394
499
|
|
|
395
|
-
|
|
500
|
+
### Test Structure
|
|
501
|
+
|
|
502
|
+
- `tests/test_client.py` - Unit tests for the base API client
|
|
503
|
+
- `tests/test_grobid_client.py` - Unit tests for the GROBID client
|
|
504
|
+
- `tests/test_integration.py` - Integration tests with real GROBID server
|
|
505
|
+
- `tests/conftest.py` - Test configuration and fixtures
|
|
396
506
|
|
|
397
|
-
|
|
507
|
+
### Continuous Integration
|
|
398
508
|
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
509
|
+
Tests are automatically run via GitHub Actions on:
|
|
510
|
+
- Push to main branch
|
|
511
|
+
- Pull requests
|
|
512
|
+
- Multiple Python versions (3.8-3.13)
|
|
513
|
+
|
|
514
|
+
## 📊 Performance
|
|
515
|
+
|
|
516
|
+
Benchmark results for processing **136 PDFs** (3,443 pages total, ~25 pages per PDF) on Intel Core i7-4790K CPU 4.00GHz:
|
|
517
|
+
|
|
518
|
+
| Concurrency | Runtime (s) | s/PDF | PDF/s |
|
|
519
|
+
|-------------|-------------|-------|-------|
|
|
520
|
+
| 1 | 209.0 | 1.54 | 0.65 |
|
|
521
|
+
| 2 | 112.0 | 0.82 | 1.21 |
|
|
522
|
+
| 3 | 80.4 | 0.59 | 1.69 |
|
|
523
|
+
| 5 | 62.9 | 0.46 | 2.16 |
|
|
524
|
+
| 8 | 55.7 | 0.41 | 2.44 |
|
|
525
|
+
| 10 | 55.3 | 0.40 | 2.45 |
|
|
407
526
|
|
|
408
527
|

|
|
409
528
|
|
|
410
|
-
|
|
529
|
+
### Additional Benchmarks
|
|
530
|
+
|
|
531
|
+
- **Header processing**: 3.74s for 136 PDFs (36 PDF/s) with n=10
|
|
532
|
+
- **Reference extraction**: 26.9s for 136 PDFs (5.1 PDF/s) with n=10
|
|
533
|
+
- **Citation parsing**: 4.3s for 3,500 citations (814 citations/s) with n=10
|
|
411
534
|
|
|
412
|
-
|
|
535
|
+
## 🛠️ Development
|
|
413
536
|
|
|
414
|
-
|
|
537
|
+
### Setting Up Development Environment
|
|
415
538
|
|
|
539
|
+
```bash
|
|
540
|
+
# Clone the repository
|
|
541
|
+
git clone https://github.com/kermitt2/grobid_client_python
|
|
542
|
+
cd grobid_client_python
|
|
416
543
|
|
|
417
|
-
|
|
544
|
+
# Create virtual environment
|
|
545
|
+
python -m venv venv
|
|
546
|
+
source venv/bin/activate # On Windows: venv\Scripts\activate
|
|
418
547
|
|
|
419
|
-
|
|
548
|
+
# Install in development mode with test dependencies
|
|
549
|
+
pip install -e .[dev]
|
|
550
|
+
|
|
551
|
+
# Install pre-commit hooks (optional)
|
|
552
|
+
pre-commit install
|
|
553
|
+
```
|
|
420
554
|
|
|
421
|
-
|
|
555
|
+
### Creating a New Release
|
|
422
556
|
|
|
423
|
-
|
|
557
|
+
The project uses `bump-my-version` for version management:
|
|
558
|
+
|
|
559
|
+
```bash
|
|
560
|
+
# Install bump-my-version
|
|
424
561
|
pip install bump-my-version
|
|
425
|
-
|
|
562
|
+
|
|
563
|
+
# Bump version (patch, minor, or major)
|
|
564
|
+
bump-my-version bump patch
|
|
565
|
+
|
|
566
|
+
# The release will be automatically published to PyPI
|
|
426
567
|
```
|
|
427
568
|
|
|
428
|
-
|
|
429
|
-
|
|
569
|
+
### Contributing
|
|
570
|
+
|
|
571
|
+
1. Fork the repository
|
|
572
|
+
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
|
|
573
|
+
3. Make your changes
|
|
574
|
+
4. Add tests for new functionality
|
|
575
|
+
5. Run the test suite (`pytest`)
|
|
576
|
+
6. Commit your changes (`git commit -m 'Add amazing feature'`)
|
|
577
|
+
7. Push to the branch (`git push origin feature/amazing-feature`)
|
|
578
|
+
8. Open a Pull Request
|
|
579
|
+
|
|
580
|
+
## 📄 License
|
|
581
|
+
|
|
582
|
+
Distributed under the [Apache 2.0 License](http://www.apache.org/licenses/LICENSE-2.0). See `LICENSE` for more information.
|
|
583
|
+
|
|
584
|
+
## 👥 Authors & Contact
|
|
430
585
|
|
|
431
|
-
|
|
586
|
+
**Main Author**: Patrice Lopez (patrice.lopez@science-miner.com)
|
|
587
|
+
**Maintainer**: Luca Foppiano (luca@sciencialab.com)
|
|
432
588
|
|
|
433
|
-
|
|
589
|
+
## 🔗 Links
|
|
434
590
|
|
|
435
|
-
|
|
591
|
+
- [GROBID Documentation](https://grobid.readthedocs.io/)
|
|
592
|
+
- [PyPI Package](https://pypi.org/project/grobid-client-python/)
|
|
593
|
+
- [GitHub Repository](https://github.com/kermitt2/grobid_client_python)
|
|
594
|
+
- [Issue Tracker](https://github.com/kermitt2/grobid_client_python/issues)
|