grobid-client-python 0.0.16__tar.gz → 0.0.18__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.16 → grobid_client_python-0.0.18}/PKG-INFO +36 -36
- {grobid_client_python-0.0.16 → grobid_client_python-0.0.18}/Readme.md +35 -35
- {grobid_client_python-0.0.16 → grobid_client_python-0.0.18}/config.json +1 -1
- {grobid_client_python-0.0.16 → grobid_client_python-0.0.18}/grobid_client/grobid_client.py +13 -7
- {grobid_client_python-0.0.16 → grobid_client_python-0.0.18}/grobid_client_python.egg-info/PKG-INFO +36 -36
- {grobid_client_python-0.0.16 → grobid_client_python-0.0.18}/pyproject.toml +1 -1
- {grobid_client_python-0.0.16 → grobid_client_python-0.0.18}/tests/test_config.json +1 -1
- {grobid_client_python-0.0.16 → grobid_client_python-0.0.18}/tests/test_grobid_client.py +4 -4
- {grobid_client_python-0.0.16 → grobid_client_python-0.0.18}/tests/test_integration.py +2 -3
- {grobid_client_python-0.0.16 → grobid_client_python-0.0.18}/.github/workflows/ci-build.yml +0 -0
- {grobid_client_python-0.0.16 → grobid_client_python-0.0.18}/.github/workflows/ci-release.yml +0 -0
- {grobid_client_python-0.0.16 → grobid_client_python-0.0.18}/.gitignore +0 -0
- {grobid_client_python-0.0.16 → grobid_client_python-0.0.18}/LICENSE +0 -0
- {grobid_client_python-0.0.16 → grobid_client_python-0.0.18}/MANIFEST.in +0 -0
- {grobid_client_python-0.0.16 → grobid_client_python-0.0.18}/example.py +0 -0
- {grobid_client_python-0.0.16 → grobid_client_python-0.0.18}/grobid_client/__init__.py +0 -0
- {grobid_client_python-0.0.16 → grobid_client_python-0.0.18}/grobid_client/client.py +0 -0
- {grobid_client_python-0.0.16 → grobid_client_python-0.0.18}/grobid_client_python.egg-info/SOURCES.txt +0 -0
- {grobid_client_python-0.0.16 → grobid_client_python-0.0.18}/grobid_client_python.egg-info/dependency_links.txt +0 -0
- {grobid_client_python-0.0.16 → grobid_client_python-0.0.18}/grobid_client_python.egg-info/entry_points.txt +0 -0
- {grobid_client_python-0.0.16 → grobid_client_python-0.0.18}/grobid_client_python.egg-info/requires.txt +0 -0
- {grobid_client_python-0.0.16 → grobid_client_python-0.0.18}/grobid_client_python.egg-info/top_level.txt +0 -0
- {grobid_client_python-0.0.16 → grobid_client_python-0.0.18}/pytest.ini +0 -0
- {grobid_client_python-0.0.16 → grobid_client_python-0.0.18}/requirements.txt +0 -0
- {grobid_client_python-0.0.16 → grobid_client_python-0.0.18}/resources/20180928112135.png +0 -0
- {grobid_client_python-0.0.16 → grobid_client_python-0.0.18}/resources/20180928112138.csv +0 -0
- {grobid_client_python-0.0.16 → grobid_client_python-0.0.18}/resources/test_out/0046d83a-edd6-4631-b57c-755cdcce8b7f.tei.xml +0 -0
- {grobid_client_python-0.0.16 → grobid_client_python-0.0.18}/resources/test_out/test_1/0f318087-b211-4ace-8ac9-3d9372a73c1c.tei.xml +0 -0
- {grobid_client_python-0.0.16 → grobid_client_python-0.0.18}/resources/test_pdf/0046d83a-edd6-4631-b57c-755cdcce8b7f.pdf +0 -0
- {grobid_client_python-0.0.16 → grobid_client_python-0.0.18}/resources/test_pdf/0046d83a-edd6-4631-b57c-755cdcce8b7f.tei.xml +0 -0
- {grobid_client_python-0.0.16 → grobid_client_python-0.0.18}/resources/test_txt/reference-strings-1.txt +0 -0
- {grobid_client_python-0.0.16 → grobid_client_python-0.0.18}/resources/test_txt/reference-strings-2.txt +0 -0
- {grobid_client_python-0.0.16 → grobid_client_python-0.0.18}/resources/test_txt/reference-strings-3.txt +0 -0
- {grobid_client_python-0.0.16 → grobid_client_python-0.0.18}/resources/test_txt/reference-strings-4.txt +0 -0
- {grobid_client_python-0.0.16 → grobid_client_python-0.0.18}/resources/test_txt/reference-strings-5.txt +0 -0
- {grobid_client_python-0.0.16 → grobid_client_python-0.0.18}/resources/test_txt/reference-strings-6.txt +0 -0
- {grobid_client_python-0.0.16 → grobid_client_python-0.0.18}/resources/test_txt/reference-strings-7.txt +0 -0
- {grobid_client_python-0.0.16 → grobid_client_python-0.0.18}/setup.cfg +0 -0
- {grobid_client_python-0.0.16 → grobid_client_python-0.0.18}/tests/__init__.py +0 -0
- {grobid_client_python-0.0.16 → grobid_client_python-0.0.18}/tests/conftest.py +0 -0
- {grobid_client_python-0.0.16 → grobid_client_python-0.0.18}/tests/run_tests.py +0 -0
- {grobid_client_python-0.0.16 → grobid_client_python-0.0.18}/tests/test_client.py +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.18
|
|
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>
|
|
@@ -254,7 +254,7 @@ A simple, efficient Python client for [GROBID](https://github.com/kermitt2/grobi
|
|
|
254
254
|
- Local installation: [GROBID Documentation](http://grobid.readthedocs.io/)
|
|
255
255
|
- Docker: `docker run -t --rm -p 8070:8070 lfoppiano/grobid:0.8.2`
|
|
256
256
|
- Default server: `http://localhost:8070`
|
|
257
|
-
- Online demo: https://lfoppiano-grobid.hf.space (usage limits apply)
|
|
257
|
+
- Online demo: https://lfoppiano-grobid.hf.space (usage limits apply), more details [here](https://grobid.readthedocs.io/en/latest/getting_started/#using-grobid-from-the-cloud).
|
|
258
258
|
|
|
259
259
|
> [!IMPORTANT]
|
|
260
260
|
> GROBID supports Windows only through Docker containers. See the [Docker documentation](https://grobid.readthedocs.io/en/latest/Grobid-docker/) for details.
|
|
@@ -314,39 +314,39 @@ grobid_client [OPTIONS] SERVICE
|
|
|
314
314
|
|
|
315
315
|
#### Available Services
|
|
316
316
|
|
|
317
|
-
| Service
|
|
318
|
-
|
|
319
|
-
| `processFulltextDocument`
|
|
320
|
-
| `processHeaderDocument`
|
|
321
|
-
| `processReferences`
|
|
322
|
-
| `processCitationList`
|
|
323
|
-
| `processCitationPatentST36` | Process patent citations
|
|
324
|
-
| `processCitationPatentPDF`
|
|
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
325
|
|
|
326
326
|
#### Common Options
|
|
327
327
|
|
|
328
|
-
| Option
|
|
329
|
-
|
|
330
|
-
| `--input`
|
|
331
|
-
| `--output`
|
|
332
|
-
| `--server`
|
|
333
|
-
| `--n`
|
|
334
|
-
| `--config`
|
|
335
|
-
| `--force`
|
|
336
|
-
| `--verbose` | Enable verbose logging
|
|
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
337
|
|
|
338
338
|
#### Processing Options
|
|
339
339
|
|
|
340
|
-
| Option
|
|
341
|
-
|
|
342
|
-
| `--generateIDs`
|
|
343
|
-
| `--consolidate_header`
|
|
344
|
-
| `--consolidate_citations`
|
|
345
|
-
| `--include_raw_citations`
|
|
346
|
-
| `--include_raw_affiliations` | Include raw affiliation text
|
|
347
|
-
| `--teiCoordinates`
|
|
348
|
-
| `--segmentSentences`
|
|
349
|
-
| `--flavor`
|
|
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
350
|
|
|
351
351
|
#### Examples
|
|
352
352
|
|
|
@@ -430,13 +430,13 @@ Configuration can be provided via a JSON file. When using the CLI, the `--server
|
|
|
430
430
|
|
|
431
431
|
### Configuration Parameters
|
|
432
432
|
|
|
433
|
-
| Parameter
|
|
434
|
-
|
|
435
|
-
| `grobid_server` | GROBID server URL
|
|
436
|
-
| `batch_size`
|
|
437
|
-
| `sleep_time`
|
|
438
|
-
| `timeout`
|
|
439
|
-
| `coordinates`
|
|
433
|
+
| Parameter | Description | Default |
|
|
434
|
+
|-----------------|------------------------------------------------------------------------------------------------------------------|-------------------------|
|
|
435
|
+
| `grobid_server` | GROBID server URL | `http://localhost:8070` |
|
|
436
|
+
| `batch_size` | Thread pool size. **Tune carefully: a large batch size will result in the data being written less frequently** | 1000 |
|
|
437
|
+
| `sleep_time` | Wait time when server is busy (seconds) | 5 |
|
|
438
|
+
| `timeout` | Client-side timeout (seconds) | 180 |
|
|
439
|
+
| `coordinates` | XML elements for coordinate extraction | See above |
|
|
440
440
|
|
|
441
441
|
> [!TIP]
|
|
442
442
|
> Since version 0.0.12, the config file is optional. The client will use default localhost settings if no configuration is provided.
|
|
@@ -38,7 +38,7 @@ A simple, efficient Python client for [GROBID](https://github.com/kermitt2/grobi
|
|
|
38
38
|
- Local installation: [GROBID Documentation](http://grobid.readthedocs.io/)
|
|
39
39
|
- Docker: `docker run -t --rm -p 8070:8070 lfoppiano/grobid:0.8.2`
|
|
40
40
|
- Default server: `http://localhost:8070`
|
|
41
|
-
- Online demo: https://lfoppiano-grobid.hf.space (usage limits apply)
|
|
41
|
+
- Online demo: https://lfoppiano-grobid.hf.space (usage limits apply), more details [here](https://grobid.readthedocs.io/en/latest/getting_started/#using-grobid-from-the-cloud).
|
|
42
42
|
|
|
43
43
|
> [!IMPORTANT]
|
|
44
44
|
> GROBID supports Windows only through Docker containers. See the [Docker documentation](https://grobid.readthedocs.io/en/latest/Grobid-docker/) for details.
|
|
@@ -98,39 +98,39 @@ grobid_client [OPTIONS] SERVICE
|
|
|
98
98
|
|
|
99
99
|
#### Available Services
|
|
100
100
|
|
|
101
|
-
| Service
|
|
102
|
-
|
|
103
|
-
| `processFulltextDocument`
|
|
104
|
-
| `processHeaderDocument`
|
|
105
|
-
| `processReferences`
|
|
106
|
-
| `processCitationList`
|
|
107
|
-
| `processCitationPatentST36` | Process patent citations
|
|
108
|
-
| `processCitationPatentPDF`
|
|
101
|
+
| Service | Description | Input Format |
|
|
102
|
+
|-----------------------------|-----------------------------------|------------------------------------|
|
|
103
|
+
| `processFulltextDocument` | Extract full document structure | PDF files |
|
|
104
|
+
| `processHeaderDocument` | Extract document metadata | PDF files |
|
|
105
|
+
| `processReferences` | Extract bibliographic references | PDF files |
|
|
106
|
+
| `processCitationList` | Parse citation strings | Text files (one citation per line) |
|
|
107
|
+
| `processCitationPatentST36` | Process patent citations | XML ST36 format |
|
|
108
|
+
| `processCitationPatentPDF` | Process patent PDFs | PDF files |
|
|
109
109
|
|
|
110
110
|
#### Common Options
|
|
111
111
|
|
|
112
|
-
| Option
|
|
113
|
-
|
|
114
|
-
| `--input`
|
|
115
|
-
| `--output`
|
|
116
|
-
| `--server`
|
|
117
|
-
| `--n`
|
|
118
|
-
| `--config`
|
|
119
|
-
| `--force`
|
|
120
|
-
| `--verbose` | Enable verbose logging
|
|
112
|
+
| Option | Description | Default |
|
|
113
|
+
|-------------|--------------------------|-------------------------|
|
|
114
|
+
| `--input` | Input directory path | Required |
|
|
115
|
+
| `--output` | Output directory path | Same as input |
|
|
116
|
+
| `--server` | GROBID server URL | `http://localhost:8070` |
|
|
117
|
+
| `--n` | Concurrency level | 10 |
|
|
118
|
+
| `--config` | Config file path | Optional |
|
|
119
|
+
| `--force` | Overwrite existing files | False |
|
|
120
|
+
| `--verbose` | Enable verbose logging | False |
|
|
121
121
|
|
|
122
122
|
#### Processing Options
|
|
123
123
|
|
|
124
|
-
| Option
|
|
125
|
-
|
|
126
|
-
| `--generateIDs`
|
|
127
|
-
| `--consolidate_header`
|
|
128
|
-
| `--consolidate_citations`
|
|
129
|
-
| `--include_raw_citations`
|
|
130
|
-
| `--include_raw_affiliations` | Include raw affiliation text
|
|
131
|
-
| `--teiCoordinates`
|
|
132
|
-
| `--segmentSentences`
|
|
133
|
-
| `--flavor`
|
|
124
|
+
| Option | Description |
|
|
125
|
+
|------------------------------|-------------------------------------------|
|
|
126
|
+
| `--generateIDs` | Generate random XML IDs |
|
|
127
|
+
| `--consolidate_header` | Consolidate header metadata |
|
|
128
|
+
| `--consolidate_citations` | Consolidate bibliographic references |
|
|
129
|
+
| `--include_raw_citations` | Include raw citation text |
|
|
130
|
+
| `--include_raw_affiliations` | Include raw affiliation text |
|
|
131
|
+
| `--teiCoordinates` | Add PDF coordinates to XML |
|
|
132
|
+
| `--segmentSentences` | Segment sentences with coordinates |
|
|
133
|
+
| `--flavor` | Processing flavor for fulltext extraction |
|
|
134
134
|
|
|
135
135
|
#### Examples
|
|
136
136
|
|
|
@@ -214,13 +214,13 @@ Configuration can be provided via a JSON file. When using the CLI, the `--server
|
|
|
214
214
|
|
|
215
215
|
### Configuration Parameters
|
|
216
216
|
|
|
217
|
-
| Parameter
|
|
218
|
-
|
|
219
|
-
| `grobid_server` | GROBID server URL
|
|
220
|
-
| `batch_size`
|
|
221
|
-
| `sleep_time`
|
|
222
|
-
| `timeout`
|
|
223
|
-
| `coordinates`
|
|
217
|
+
| Parameter | Description | Default |
|
|
218
|
+
|-----------------|------------------------------------------------------------------------------------------------------------------|-------------------------|
|
|
219
|
+
| `grobid_server` | GROBID server URL | `http://localhost:8070` |
|
|
220
|
+
| `batch_size` | Thread pool size. **Tune carefully: a large batch size will result in the data being written less frequently** | 1000 |
|
|
221
|
+
| `sleep_time` | Wait time when server is busy (seconds) | 5 |
|
|
222
|
+
| `timeout` | Client-side timeout (seconds) | 180 |
|
|
223
|
+
| `coordinates` | XML elements for coordinate extraction | See above |
|
|
224
224
|
|
|
225
225
|
> [!TIP]
|
|
226
226
|
> Since version 0.0.12, the config file is optional. The client will use default localhost settings if no configuration is provided.
|
|
@@ -41,7 +41,7 @@ class GrobidClient(ApiClient):
|
|
|
41
41
|
# Default configuration values
|
|
42
42
|
DEFAULT_CONFIG = {
|
|
43
43
|
'grobid_server': 'http://localhost:8070',
|
|
44
|
-
'batch_size':
|
|
44
|
+
'batch_size': 10,
|
|
45
45
|
'sleep_time': 5,
|
|
46
46
|
'timeout': 180,
|
|
47
47
|
'coordinates': [
|
|
@@ -60,7 +60,7 @@ class GrobidClient(ApiClient):
|
|
|
60
60
|
],
|
|
61
61
|
'logging': {
|
|
62
62
|
'level': 'INFO',
|
|
63
|
-
'format': '%(asctime)s - %(
|
|
63
|
+
'format': '%(asctime)s - %(levelname)s - %(message)s',
|
|
64
64
|
'console': True,
|
|
65
65
|
'file': None, # Disabled by default
|
|
66
66
|
'max_file_size': '10MB',
|
|
@@ -133,7 +133,7 @@ class GrobidClient(ApiClient):
|
|
|
133
133
|
log_level = getattr(logging, log_level_str, logging.INFO)
|
|
134
134
|
|
|
135
135
|
# Parse log format
|
|
136
|
-
log_format = log_config.get('format', '%(asctime)s - %(
|
|
136
|
+
log_format = log_config.get('format', '%(asctime)s - %(levelname)s - %(message)s')
|
|
137
137
|
|
|
138
138
|
# Create formatter
|
|
139
139
|
formatter = logging.Formatter(log_format)
|
|
@@ -347,6 +347,7 @@ class GrobidClient(ApiClient):
|
|
|
347
347
|
|
|
348
348
|
# Counter for actually processed files
|
|
349
349
|
processed_files_count = 0
|
|
350
|
+
errors_files_count = 0
|
|
350
351
|
input_files = []
|
|
351
352
|
|
|
352
353
|
for input_file in all_input_files:
|
|
@@ -363,7 +364,7 @@ class GrobidClient(ApiClient):
|
|
|
363
364
|
input_files.append(input_file)
|
|
364
365
|
|
|
365
366
|
if len(input_files) == batch_size_pdf:
|
|
366
|
-
batch_processed = self.process_batch(
|
|
367
|
+
batch_processed, batch_errors = self.process_batch(
|
|
367
368
|
service,
|
|
368
369
|
input_files,
|
|
369
370
|
input_path,
|
|
@@ -381,11 +382,12 @@ class GrobidClient(ApiClient):
|
|
|
381
382
|
flavor
|
|
382
383
|
)
|
|
383
384
|
processed_files_count += batch_processed
|
|
385
|
+
errors_files_count += batch_errors
|
|
384
386
|
input_files = []
|
|
385
387
|
|
|
386
388
|
# last batch
|
|
387
389
|
if len(input_files) > 0:
|
|
388
|
-
batch_processed = self.process_batch(
|
|
390
|
+
batch_processed, batch_errors = self.process_batch(
|
|
389
391
|
service,
|
|
390
392
|
input_files,
|
|
391
393
|
input_path,
|
|
@@ -402,9 +404,11 @@ class GrobidClient(ApiClient):
|
|
|
402
404
|
verbose,
|
|
403
405
|
)
|
|
404
406
|
processed_files_count += batch_processed
|
|
407
|
+
errors_files_count += batch_errors
|
|
405
408
|
|
|
406
409
|
# Log final statistics
|
|
407
410
|
self.logger.info(f"Processing completed: {processed_files_count} out of {total_files} files processed")
|
|
411
|
+
self.logger.info(f"Errors: {errors_files_count} out of {total_files} files processed")
|
|
408
412
|
|
|
409
413
|
def process_batch(
|
|
410
414
|
self,
|
|
@@ -428,6 +432,7 @@ class GrobidClient(ApiClient):
|
|
|
428
432
|
self.logger.info(f"{len(input_files)} files to process in current batch")
|
|
429
433
|
|
|
430
434
|
processed_count = 0
|
|
435
|
+
error_count = 0
|
|
431
436
|
|
|
432
437
|
# we use ThreadPoolExecutor and not ProcessPoolExecutor because it is an I/O intensive process
|
|
433
438
|
with concurrent.futures.ThreadPoolExecutor(max_workers=n) as executor:
|
|
@@ -468,10 +473,10 @@ class GrobidClient(ApiClient):
|
|
|
468
473
|
for r in concurrent.futures.as_completed(results):
|
|
469
474
|
input_file, status, text = r.result()
|
|
470
475
|
filename = self._output_file_name(input_file, input_path, output)
|
|
471
|
-
processed_count += 1
|
|
472
476
|
|
|
473
477
|
if status != 200 or text is None:
|
|
474
478
|
self.logger.error(f"Processing of {input_file} failed with error {status}: {text}")
|
|
479
|
+
error_count += 1
|
|
475
480
|
# writing error file with suffixed error code
|
|
476
481
|
try:
|
|
477
482
|
pathlib.Path(os.path.dirname(filename)).mkdir(parents=True, exist_ok=True)
|
|
@@ -485,6 +490,7 @@ class GrobidClient(ApiClient):
|
|
|
485
490
|
except OSError as e:
|
|
486
491
|
self.logger.error(f"Failed to write error file {filename}: {str(e)}")
|
|
487
492
|
else:
|
|
493
|
+
processed_count += 1
|
|
488
494
|
# writing TEI file
|
|
489
495
|
try:
|
|
490
496
|
pathlib.Path(os.path.dirname(filename)).mkdir(parents=True, exist_ok=True)
|
|
@@ -494,7 +500,7 @@ class GrobidClient(ApiClient):
|
|
|
494
500
|
except OSError as e:
|
|
495
501
|
self.logger.error(f"Failed to write TEI XML file {filename}: {str(e)}")
|
|
496
502
|
|
|
497
|
-
return processed_count
|
|
503
|
+
return processed_count, error_count
|
|
498
504
|
|
|
499
505
|
def process_pdf(
|
|
500
506
|
self,
|
{grobid_client_python-0.0.16 → grobid_client_python-0.0.18}/grobid_client_python.egg-info/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: grobid-client-python
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.18
|
|
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>
|
|
@@ -254,7 +254,7 @@ A simple, efficient Python client for [GROBID](https://github.com/kermitt2/grobi
|
|
|
254
254
|
- Local installation: [GROBID Documentation](http://grobid.readthedocs.io/)
|
|
255
255
|
- Docker: `docker run -t --rm -p 8070:8070 lfoppiano/grobid:0.8.2`
|
|
256
256
|
- Default server: `http://localhost:8070`
|
|
257
|
-
- Online demo: https://lfoppiano-grobid.hf.space (usage limits apply)
|
|
257
|
+
- Online demo: https://lfoppiano-grobid.hf.space (usage limits apply), more details [here](https://grobid.readthedocs.io/en/latest/getting_started/#using-grobid-from-the-cloud).
|
|
258
258
|
|
|
259
259
|
> [!IMPORTANT]
|
|
260
260
|
> GROBID supports Windows only through Docker containers. See the [Docker documentation](https://grobid.readthedocs.io/en/latest/Grobid-docker/) for details.
|
|
@@ -314,39 +314,39 @@ grobid_client [OPTIONS] SERVICE
|
|
|
314
314
|
|
|
315
315
|
#### Available Services
|
|
316
316
|
|
|
317
|
-
| Service
|
|
318
|
-
|
|
319
|
-
| `processFulltextDocument`
|
|
320
|
-
| `processHeaderDocument`
|
|
321
|
-
| `processReferences`
|
|
322
|
-
| `processCitationList`
|
|
323
|
-
| `processCitationPatentST36` | Process patent citations
|
|
324
|
-
| `processCitationPatentPDF`
|
|
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
325
|
|
|
326
326
|
#### Common Options
|
|
327
327
|
|
|
328
|
-
| Option
|
|
329
|
-
|
|
330
|
-
| `--input`
|
|
331
|
-
| `--output`
|
|
332
|
-
| `--server`
|
|
333
|
-
| `--n`
|
|
334
|
-
| `--config`
|
|
335
|
-
| `--force`
|
|
336
|
-
| `--verbose` | Enable verbose logging
|
|
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
337
|
|
|
338
338
|
#### Processing Options
|
|
339
339
|
|
|
340
|
-
| Option
|
|
341
|
-
|
|
342
|
-
| `--generateIDs`
|
|
343
|
-
| `--consolidate_header`
|
|
344
|
-
| `--consolidate_citations`
|
|
345
|
-
| `--include_raw_citations`
|
|
346
|
-
| `--include_raw_affiliations` | Include raw affiliation text
|
|
347
|
-
| `--teiCoordinates`
|
|
348
|
-
| `--segmentSentences`
|
|
349
|
-
| `--flavor`
|
|
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
350
|
|
|
351
351
|
#### Examples
|
|
352
352
|
|
|
@@ -430,13 +430,13 @@ Configuration can be provided via a JSON file. When using the CLI, the `--server
|
|
|
430
430
|
|
|
431
431
|
### Configuration Parameters
|
|
432
432
|
|
|
433
|
-
| Parameter
|
|
434
|
-
|
|
435
|
-
| `grobid_server` | GROBID server URL
|
|
436
|
-
| `batch_size`
|
|
437
|
-
| `sleep_time`
|
|
438
|
-
| `timeout`
|
|
439
|
-
| `coordinates`
|
|
433
|
+
| Parameter | Description | Default |
|
|
434
|
+
|-----------------|------------------------------------------------------------------------------------------------------------------|-------------------------|
|
|
435
|
+
| `grobid_server` | GROBID server URL | `http://localhost:8070` |
|
|
436
|
+
| `batch_size` | Thread pool size. **Tune carefully: a large batch size will result in the data being written less frequently** | 1000 |
|
|
437
|
+
| `sleep_time` | Wait time when server is busy (seconds) | 5 |
|
|
438
|
+
| `timeout` | Client-side timeout (seconds) | 180 |
|
|
439
|
+
| `coordinates` | XML elements for coordinate extraction | See above |
|
|
440
440
|
|
|
441
441
|
> [!TIP]
|
|
442
442
|
> Since version 0.0.12, the config file is optional. The client will use default localhost settings if no configuration is provided.
|
|
@@ -26,7 +26,7 @@ class TestGrobidClient:
|
|
|
26
26
|
'timeout': 60,
|
|
27
27
|
'logging': {
|
|
28
28
|
'level': 'INFO',
|
|
29
|
-
'format': '%(asctime)s - %(
|
|
29
|
+
'format': '%(asctime)s - %(levelname)s - %(message)s',
|
|
30
30
|
'console': True,
|
|
31
31
|
'file': None
|
|
32
32
|
}
|
|
@@ -41,7 +41,7 @@ class TestGrobidClient:
|
|
|
41
41
|
client = GrobidClient(check_server=False)
|
|
42
42
|
|
|
43
43
|
assert client.config['grobid_server'] == 'http://localhost:8070'
|
|
44
|
-
assert client.config['batch_size'] ==
|
|
44
|
+
assert client.config['batch_size'] == 10
|
|
45
45
|
assert client.config['sleep_time'] == 5
|
|
46
46
|
assert client.config['timeout'] == 180
|
|
47
47
|
assert 'persName' in client.config['coordinates']
|
|
@@ -258,7 +258,7 @@ class TestGrobidClient:
|
|
|
258
258
|
with patch('grobid_client.grobid_client.GrobidClient._test_server_connection'):
|
|
259
259
|
with patch('grobid_client.grobid_client.GrobidClient._configure_logging'):
|
|
260
260
|
with patch('grobid_client.grobid_client.GrobidClient.process_batch') as mock_batch:
|
|
261
|
-
mock_batch.return_value = 2
|
|
261
|
+
mock_batch.return_value = (2, 0) # Return tuple as expected
|
|
262
262
|
client = GrobidClient(check_server=False)
|
|
263
263
|
client.logger = Mock()
|
|
264
264
|
|
|
@@ -421,7 +421,7 @@ class TestGrobidClient:
|
|
|
421
421
|
verbose=False
|
|
422
422
|
)
|
|
423
423
|
|
|
424
|
-
assert result == 1 # One file processed
|
|
424
|
+
assert result == (1, 0) # One file processed, zero errors
|
|
425
425
|
|
|
426
426
|
|
|
427
427
|
class TestServerUnavailableException:
|
|
@@ -181,7 +181,7 @@ class TestGrobidClientIntegration:
|
|
|
181
181
|
force=True
|
|
182
182
|
)
|
|
183
183
|
|
|
184
|
-
assert processed_count == 5
|
|
184
|
+
assert processed_count == (5, 0)
|
|
185
185
|
|
|
186
186
|
def test_error_handling_and_recovery(self):
|
|
187
187
|
"""Test error handling and recovery mechanisms."""
|
|
@@ -342,5 +342,4 @@ class TestGrobidClientIntegration:
|
|
|
342
342
|
force=True
|
|
343
343
|
)
|
|
344
344
|
|
|
345
|
-
assert processed_count == 20
|
|
346
|
-
|
|
345
|
+
assert processed_count == (20, 0)
|
|
File without changes
|
{grobid_client_python-0.0.16 → grobid_client_python-0.0.18}/.github/workflows/ci-release.yml
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|