grobid-client-python 0.0.7__tar.gz → 0.0.9__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.
Files changed (38) hide show
  1. grobid_client_python-0.0.9/.github/workflows/ci-build.yml +39 -0
  2. grobid_client_python-0.0.9/.github/workflows/ci-release.yml +43 -0
  3. grobid_client_python-0.0.9/.gitignore +23 -0
  4. {grobid_client_python-0.0.7 → grobid_client_python-0.0.9}/LICENSE +1 -1
  5. grobid_client_python-0.0.9/PKG-INFO +431 -0
  6. grobid_client_python-0.0.7/grobid_client_python.egg-info/PKG-INFO → grobid_client_python-0.0.9/Readme.md +35 -15
  7. grobid_client_python-0.0.9/config.json +7 -0
  8. grobid_client_python-0.0.9/example.py +5 -0
  9. {grobid_client_python-0.0.7 → grobid_client_python-0.0.9}/grobid_client/grobid_client.py +26 -6
  10. grobid_client_python-0.0.9/grobid_client_python.egg-info/PKG-INFO +431 -0
  11. grobid_client_python-0.0.9/grobid_client_python.egg-info/SOURCES.txt +32 -0
  12. grobid_client_python-0.0.9/pyproject.toml +40 -0
  13. grobid_client_python-0.0.9/requirements.txt +1 -0
  14. grobid_client_python-0.0.9/resources/20180928112135.png +0 -0
  15. grobid_client_python-0.0.9/resources/20180928112138.csv +7 -0
  16. grobid_client_python-0.0.9/resources/test_out/0046d83a-edd6-4631-b57c-755cdcce8b7f.tei.xml +1781 -0
  17. grobid_client_python-0.0.9/resources/test_out/test_1/0f318087-b211-4ace-8ac9-3d9372a73c1c.tei.xml +1094 -0
  18. grobid_client_python-0.0.9/resources/test_pdf/0046d83a-edd6-4631-b57c-755cdcce8b7f.pdf +5331 -4
  19. grobid_client_python-0.0.9/resources/test_pdf/0046d83a-edd6-4631-b57c-755cdcce8b7f.tei.xml +1781 -0
  20. grobid_client_python-0.0.9/resources/test_txt/reference-strings-1.txt +500 -0
  21. grobid_client_python-0.0.9/resources/test_txt/reference-strings-2.txt +500 -0
  22. grobid_client_python-0.0.9/resources/test_txt/reference-strings-3.txt +500 -0
  23. grobid_client_python-0.0.9/resources/test_txt/reference-strings-4.txt +500 -0
  24. grobid_client_python-0.0.9/resources/test_txt/reference-strings-5.txt +500 -0
  25. grobid_client_python-0.0.9/resources/test_txt/reference-strings-6.txt +500 -0
  26. grobid_client_python-0.0.9/resources/test_txt/reference-strings-7.txt +500 -0
  27. grobid_client_python-0.0.7/PKG-INFO +0 -194
  28. grobid_client_python-0.0.7/Readme.md +0 -184
  29. grobid_client_python-0.0.7/grobid_client_python.egg-info/SOURCES.txt +0 -13
  30. grobid_client_python-0.0.7/setup.py +0 -18
  31. {grobid_client_python-0.0.7 → grobid_client_python-0.0.9}/MANIFEST.in +0 -0
  32. {grobid_client_python-0.0.7 → grobid_client_python-0.0.9}/grobid_client/__init__.py +0 -0
  33. {grobid_client_python-0.0.7 → grobid_client_python-0.0.9}/grobid_client/client.py +0 -0
  34. {grobid_client_python-0.0.7 → grobid_client_python-0.0.9}/grobid_client_python.egg-info/dependency_links.txt +0 -0
  35. {grobid_client_python-0.0.7 → grobid_client_python-0.0.9}/grobid_client_python.egg-info/entry_points.txt +0 -0
  36. {grobid_client_python-0.0.7 → grobid_client_python-0.0.9}/grobid_client_python.egg-info/requires.txt +0 -0
  37. {grobid_client_python-0.0.7 → grobid_client_python-0.0.9}/grobid_client_python.egg-info/top_level.txt +0 -0
  38. {grobid_client_python-0.0.7 → grobid_client_python-0.0.9}/setup.cfg +0 -0
@@ -0,0 +1,39 @@
1
+ name: Build unstable
2
+
3
+ on: [push]
4
+
5
+ concurrency:
6
+ group: unstable
7
+
8
+
9
+ jobs:
10
+ build:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ matrix:
14
+ python-version: [ '3.8', '3.9', '3.10', '3.11', '3.12', '3.13' ]
15
+ fail-fast: true
16
+
17
+ steps:
18
+ - uses: actions/checkout@v4
19
+ - name: Set up Python ${{ matrix.python-version }}
20
+ uses: actions/setup-python@v5
21
+ with:
22
+ python-version: ${{ matrix.python-version }}
23
+ cache: 'pip'
24
+ - name: Cleanup more disk space
25
+ run: sudo rm -rf /usr/share/dotnet && sudo rm -rf /opt/ghc && sudo rm -rf "/usr/local/share/boost" && sudo rm -rf "$AGENT_TOOLSDIRECTORY"
26
+ - name: Install dependencies
27
+ run: |
28
+ python -m pip install --upgrade pip
29
+ pip install --upgrade flake8 pytest pycodestyle pytest-cov
30
+ if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
31
+ - name: Lint with flake8
32
+ run: |
33
+ # stop the build if there are Python syntax errors or undefined names
34
+ flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
35
+ # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
36
+ flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
37
+ # - name: Test with pytest
38
+ # run: |
39
+ # pytest
@@ -0,0 +1,43 @@
1
+ name: Build release
2
+
3
+ on:
4
+ workflow_dispatch:
5
+ push:
6
+ tags:
7
+ - 'v*'
8
+
9
+ concurrency:
10
+ group: docker
11
+ cancel-in-progress: true
12
+
13
+ jobs:
14
+ build:
15
+ runs-on: ubuntu-latest
16
+ steps:
17
+ - uses: actions/checkout@v4
18
+ - name: Set up Python 3.9
19
+ uses: actions/setup-python@v5
20
+ with:
21
+ python-version: "3.9"
22
+ cache: 'pip'
23
+ - name: Cleanup more disk space
24
+ run: sudo rm -rf /usr/share/dotnet && sudo rm -rf /opt/ghc && sudo rm -rf "/usr/local/share/boost" && sudo rm -rf "$AGENT_TOOLSDIRECTORY"
25
+ - name: Install dependencies
26
+ run: |
27
+ python -m pip install --upgrade pip
28
+ pip install --upgrade flake8 pytest pycodestyle
29
+ if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
30
+ - name: Lint with flake8
31
+ run: |
32
+ # stop the build if there are Python syntax errors or undefined names
33
+ flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
34
+ # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
35
+ flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
36
+ # - name: Test with pytest
37
+ # run: |
38
+ # pytest
39
+
40
+ - name: Build and Publish to PyPI
41
+ uses: conchylicultor/pypi-build-publish@v1
42
+ with:
43
+ pypi-token: ${{ secrets.PYPI_API_TOKEN }}
@@ -0,0 +1,23 @@
1
+ target
2
+ .DS_Store
3
+ .project
4
+ .settings
5
+ .classpath
6
+ .idea
7
+ *.iml
8
+ *.log
9
+ *.log.*
10
+ *.old
11
+ *.obj
12
+ *.zip
13
+ data/doi
14
+ data/entries
15
+ data/fail
16
+ data/*.pdf
17
+ data/*.png
18
+ my_config.json
19
+ __pycache__
20
+ doc/
21
+ build/
22
+ dist/
23
+ grobid_client_python.egg-info/
@@ -187,7 +187,7 @@
187
187
  same "printed page" as the copyright notice for easier
188
188
  identification within third-party archives.
189
189
 
190
- Copyright 2018-2023 The Contributors
190
+ Copyright 2018-2024 The Contributors
191
191
 
192
192
  Licensed under the Apache License, Version 2.0 (the "License");
193
193
  you may not use this file except in compliance with the License.
@@ -0,0 +1,431 @@
1
+ Metadata-Version: 2.1
2
+ Name: grobid-client-python
3
+ Version: 0.0.9
4
+ Summary: Simple python client for GROBID REST services
5
+ Author-email: Patrice Lopez <patrice.lopez@science-miner.com>
6
+ Maintainer-email: Patrice Lopez <patrice.lopez@science-miner.com>, Luca Foppiano <lucanoro@duck.com>
7
+ License:
8
+ Apache License
9
+ Version 2.0, January 2004
10
+ http://www.apache.org/licenses/
11
+
12
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
13
+
14
+ 1. Definitions.
15
+
16
+ "License" shall mean the terms and conditions for use, reproduction,
17
+ and distribution as defined by Sections 1 through 9 of this document.
18
+
19
+ "Licensor" shall mean the copyright owner or entity authorized by
20
+ the copyright owner that is granting the License.
21
+
22
+ "Legal Entity" shall mean the union of the acting entity and all
23
+ other entities that control, are controlled by, or are under common
24
+ control with that entity. For the purposes of this definition,
25
+ "control" means (i) the power, direct or indirect, to cause the
26
+ direction or management of such entity, whether by contract or
27
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
28
+ outstanding shares, or (iii) beneficial ownership of such entity.
29
+
30
+ "You" (or "Your") shall mean an individual or Legal Entity
31
+ exercising permissions granted by this License.
32
+
33
+ "Source" form shall mean the preferred form for making modifications,
34
+ including but not limited to software source code, documentation
35
+ source, and configuration files.
36
+
37
+ "Object" form shall mean any form resulting from mechanical
38
+ transformation or translation of a Source form, including but
39
+ not limited to compiled object code, generated documentation,
40
+ and conversions to other media types.
41
+
42
+ "Work" shall mean the work of authorship, whether in Source or
43
+ Object form, made available under the License, as indicated by a
44
+ copyright notice that is included in or attached to the work
45
+ (an example is provided in the Appendix below).
46
+
47
+ "Derivative Works" shall mean any work, whether in Source or Object
48
+ form, that is based on (or derived from) the Work and for which the
49
+ editorial revisions, annotations, elaborations, or other modifications
50
+ represent, as a whole, an original work of authorship. For the purposes
51
+ of this License, Derivative Works shall not include works that remain
52
+ separable from, or merely link (or bind by name) to the interfaces of,
53
+ the Work and Derivative Works thereof.
54
+
55
+ "Contribution" shall mean any work of authorship, including
56
+ the original version of the Work and any modifications or additions
57
+ to that Work or Derivative Works thereof, that is intentionally
58
+ submitted to Licensor for inclusion in the Work by the copyright owner
59
+ or by an individual or Legal Entity authorized to submit on behalf of
60
+ the copyright owner. For the purposes of this definition, "submitted"
61
+ means any form of electronic, verbal, or written communication sent
62
+ to the Licensor or its representatives, including but not limited to
63
+ communication on electronic mailing lists, source code control systems,
64
+ and issue tracking systems that are managed by, or on behalf of, the
65
+ Licensor for the purpose of discussing and improving the Work, but
66
+ excluding communication that is conspicuously marked or otherwise
67
+ designated in writing by the copyright owner as "Not a Contribution."
68
+
69
+ "Contributor" shall mean Licensor and any individual or Legal Entity
70
+ on behalf of whom a Contribution has been received by Licensor and
71
+ subsequently incorporated within the Work.
72
+
73
+ 2. Grant of Copyright License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ copyright license to reproduce, prepare Derivative Works of,
77
+ publicly display, publicly perform, sublicense, and distribute the
78
+ Work and such Derivative Works in Source or Object form.
79
+
80
+ 3. Grant of Patent License. Subject to the terms and conditions of
81
+ this License, each Contributor hereby grants to You a perpetual,
82
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
83
+ (except as stated in this section) patent license to make, have made,
84
+ use, offer to sell, sell, import, and otherwise transfer the Work,
85
+ where such license applies only to those patent claims licensable
86
+ by such Contributor that are necessarily infringed by their
87
+ Contribution(s) alone or by combination of their Contribution(s)
88
+ with the Work to which such Contribution(s) was submitted. If You
89
+ institute patent litigation against any entity (including a
90
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
91
+ or a Contribution incorporated within the Work constitutes direct
92
+ or contributory patent infringement, then any patent licenses
93
+ granted to You under this License for that Work shall terminate
94
+ as of the date such litigation is filed.
95
+
96
+ 4. Redistribution. You may reproduce and distribute copies of the
97
+ Work or Derivative Works thereof in any medium, with or without
98
+ modifications, and in Source or Object form, provided that You
99
+ meet the following conditions:
100
+
101
+ (a) You must give any other recipients of the Work or
102
+ Derivative Works a copy of this License; and
103
+
104
+ (b) You must cause any modified files to carry prominent notices
105
+ stating that You changed the files; and
106
+
107
+ (c) You must retain, in the Source form of any Derivative Works
108
+ that You distribute, all copyright, patent, trademark, and
109
+ attribution notices from the Source form of the Work,
110
+ excluding those notices that do not pertain to any part of
111
+ the Derivative Works; and
112
+
113
+ (d) If the Work includes a "NOTICE" text file as part of its
114
+ distribution, then any Derivative Works that You distribute must
115
+ include a readable copy of the attribution notices contained
116
+ within such NOTICE file, excluding those notices that do not
117
+ pertain to any part of the Derivative Works, in at least one
118
+ of the following places: within a NOTICE text file distributed
119
+ as part of the Derivative Works; within the Source form or
120
+ documentation, if provided along with the Derivative Works; or,
121
+ within a display generated by the Derivative Works, if and
122
+ wherever such third-party notices normally appear. The contents
123
+ of the NOTICE file are for informational purposes only and
124
+ do not modify the License. You may add Your own attribution
125
+ notices within Derivative Works that You distribute, alongside
126
+ or as an addendum to the NOTICE text from the Work, provided
127
+ that such additional attribution notices cannot be construed
128
+ as modifying the License.
129
+
130
+ You may add Your own copyright statement to Your modifications and
131
+ may provide additional or different license terms and conditions
132
+ for use, reproduction, or distribution of Your modifications, or
133
+ for any such Derivative Works as a whole, provided Your use,
134
+ reproduction, and distribution of the Work otherwise complies with
135
+ the conditions stated in this License.
136
+
137
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
138
+ any Contribution intentionally submitted for inclusion in the Work
139
+ by You to the Licensor shall be under the terms and conditions of
140
+ this License, without any additional terms or conditions.
141
+ Notwithstanding the above, nothing herein shall supersede or modify
142
+ the terms of any separate license agreement you may have executed
143
+ with Licensor regarding such Contributions.
144
+
145
+ 6. Trademarks. This License does not grant permission to use the trade
146
+ names, trademarks, service marks, or product names of the Licensor,
147
+ except as required for reasonable and customary use in describing the
148
+ origin of the Work and reproducing the content of the NOTICE file.
149
+
150
+ 7. Disclaimer of Warranty. Unless required by applicable law or
151
+ agreed to in writing, Licensor provides the Work (and each
152
+ Contributor provides its Contributions) on an "AS IS" BASIS,
153
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
154
+ implied, including, without limitation, any warranties or conditions
155
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
156
+ PARTICULAR PURPOSE. You are solely responsible for determining the
157
+ appropriateness of using or redistributing the Work and assume any
158
+ risks associated with Your exercise of permissions under this License.
159
+
160
+ 8. Limitation of Liability. In no event and under no legal theory,
161
+ whether in tort (including negligence), contract, or otherwise,
162
+ unless required by applicable law (such as deliberate and grossly
163
+ negligent acts) or agreed to in writing, shall any Contributor be
164
+ liable to You for damages, including any direct, indirect, special,
165
+ incidental, or consequential damages of any character arising as a
166
+ result of this License or out of the use or inability to use the
167
+ Work (including but not limited to damages for loss of goodwill,
168
+ work stoppage, computer failure or malfunction, or any and all
169
+ other commercial damages or losses), even if such Contributor
170
+ has been advised of the possibility of such damages.
171
+
172
+ 9. Accepting Warranty or Additional Liability. While redistributing
173
+ the Work or Derivative Works thereof, You may choose to offer,
174
+ and charge a fee for, acceptance of support, warranty, indemnity,
175
+ or other liability obligations and/or rights consistent with this
176
+ License. However, in accepting such obligations, You may act only
177
+ on Your own behalf and on Your sole responsibility, not on behalf
178
+ of any other Contributor, and only if You agree to indemnify,
179
+ defend, and hold each Contributor harmless for any liability
180
+ incurred by, or claims asserted against, such Contributor by reason
181
+ of your accepting any such warranty or additional liability.
182
+
183
+ END OF TERMS AND CONDITIONS
184
+
185
+ APPENDIX: How to apply the Apache License to your work.
186
+
187
+ To apply the Apache License to your work, attach the following
188
+ boilerplate notice, with the fields enclosed by brackets "[]"
189
+ replaced with your own identifying information. (Don't include
190
+ the brackets!) The text should be enclosed in the appropriate
191
+ comment syntax for the file format. We also recommend that a
192
+ file or class name and description of purpose be included on the
193
+ same "printed page" as the copyright notice for easier
194
+ identification within third-party archives.
195
+
196
+ Copyright 2018-2024 The Contributors
197
+
198
+ Licensed under the Apache License, Version 2.0 (the "License");
199
+ you may not use this file except in compliance with the License.
200
+ You may obtain a copy of the License at
201
+
202
+ http://www.apache.org/licenses/LICENSE-2.0
203
+
204
+ Unless required by applicable law or agreed to in writing, software
205
+ distributed under the License is distributed on an "AS IS" BASIS,
206
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
207
+ See the License for the specific language governing permissions and
208
+ limitations under the License.
209
+
210
+
211
+ Project-URL: Homepage, https://github.com/kermitt2/grobid_client_python
212
+ Project-URL: Repository, https://github.com/kermitt2/grobid_client_python
213
+ Project-URL: Changelog, https://github.com/kermitt2/grobid_client_python
214
+ Description-Content-Type: text/markdown
215
+ License-File: LICENSE
216
+ Requires-Dist: requests
217
+
218
+ [![PyPI version](https://badge.fury.io/py/grobid_client_python.svg)](https://badge.fury.io/py/grobid_client_python)
219
+ [![SWH](https://archive.softwareheritage.org/badge/origin/https://github.com/kermitt2/grobid_client_python/)](https://archive.softwareheritage.org/browse/origin/https://github.com/kermitt2/grobid_client_python/)
220
+ [![License](http://img.shields.io/:license-apache-blue.svg)](http://www.apache.org/licenses/LICENSE-2.0.html)
221
+
222
+ # Simple python client for GROBID REST services
223
+
224
+ This Python client can be used to process in an efficient concurrent manner a set of PDF in a given directory by the [GROBID](https://github.com/kermitt2/grobid) service. It includes a command line for processing PDF on a file system and write results in a given output directory and a library for import in other python scripts. The client can also process similarly a list of files with reference strings (one per line) and patents in XML ST36 formats.
225
+
226
+ ## Before you start
227
+
228
+ Please be aware that, at the moment, [grobid does not support Windows](https://grobid.readthedocs.io/en/latest/Troubleshooting/#windows-related-issues).
229
+ If you are a Windows user, don't worry. You can still [run grobid
230
+ via Docker](https://grobid.readthedocs.io/en/latest/Grobid-docker/).
231
+
232
+ ## Build and run
233
+
234
+ You need first a running *grobid* service, latest stable version, see the [documentation](http://grobid.readthedocs.io/) for installation.
235
+ By default, it is assumed that the server will run on the address `http://localhost:8070`.
236
+ You can change the server address by editing the file `config.json`, see below.
237
+
238
+ ## Requirements
239
+
240
+ This client has been developed and was tested with Python `3.5`-`3.9` and should work with any higher `3.*` versions. It uses `requests` as dependency beyond the Standard Python Library.
241
+
242
+ ## Install
243
+
244
+ The client can be installed with any of the following ways:
245
+
246
+ * Install *latest stable release* from PyPI:
247
+
248
+ ```console
249
+ python3 -m pip install grobid-client-python
250
+ ```
251
+
252
+ * Install *current master development version* from GitHub:
253
+
254
+ ```console
255
+ python3 -m pip install git+https://github.com/kermitt2/grobid_client_python.git
256
+ ```
257
+
258
+ * Install and build from a clone of the repo (*current master development version*):
259
+
260
+ ```
261
+ git clone https://github.com/kermitt2/grobid_client_python
262
+ cd grobid_client_python
263
+ python3 setup.py install
264
+ ```
265
+
266
+ There is nothing more needed to start using the python command lines, see the next section.
267
+
268
+ ## Usage and options
269
+
270
+ The call to the script can normally be realized interchangeably with `python3 -m grobid_client.grobid_client` or simply `grobid_client`.
271
+
272
+ ```
273
+ usage: grobid_client [-h] [--input INPUT] [--output OUTPUT] [--config CONFIG]
274
+ [--n N] [--generateIDs] [--consolidate_header]
275
+ [--consolidate_citations] [--include_raw_citations]
276
+ [--include_raw_affiliations] [--force] [--teiCoordinates]
277
+ [--verbose]
278
+ service
279
+
280
+ Client for GROBID services
281
+
282
+ positional arguments:
283
+ service one of ['processFulltextDocument',
284
+ 'processHeaderDocument', 'processReferences',
285
+ 'processCitationList','processCitationPatentST36',
286
+ 'processCitationPatentPDF']
287
+
288
+ optional arguments:
289
+ -h, --help show this help message and exit
290
+ --input INPUT path to the directory containing PDF files or .txt
291
+ (for processCitationList only, one reference per line)
292
+ to process
293
+ --output OUTPUT path to the directory where to put the results
294
+ (optional)
295
+ --config CONFIG path to the config file, default is ./config.json
296
+ --n N concurrency for service usage
297
+ --generateIDs generate random xml:id to textual XML elements of the
298
+ result files
299
+ --consolidate_header call GROBID with consolidation of the metadata
300
+ extracted from the header
301
+ --consolidate_citations
302
+ call GROBID with consolidation of the extracted
303
+ bibliographical references
304
+ --include_raw_citations
305
+ call GROBID requesting the extraction of raw citations
306
+ --include_raw_affiliations
307
+ call GROBID requestiong the extraciton of raw
308
+ affiliations
309
+ --force force re-processing pdf input files when tei output
310
+ files already exist
311
+ --teiCoordinates add the original PDF coordinates (bounding boxes) to
312
+ the extracted elements
313
+ --segmentSentences segment sentences in the text content of the document
314
+ with additional <s> elements
315
+ --verbose print information about processed files in the console
316
+
317
+
318
+ ```
319
+
320
+ Examples:
321
+
322
+ ```console
323
+ > grobid_client --input ~/tmp/in2 --output ~/tmp/out processFulltextDocument
324
+ ```
325
+
326
+ This command will process all the PDF files present under the input directory recursively (files with extension `.pdf` only) with the `processFulltextDocument` service of GROBID, and write the resulting XML TEI files under the output directory, reusing the file name with a different file extension (`.grobid.tei.xml`), using the default `10` concurrent workers.
327
+
328
+ If `--output` is omitted, the resulting XML TEI documents will be produced alongside the PDF in the `--input` directory.
329
+
330
+ ```console
331
+ > grobid_client --input ~/tmp/in2 --output ~/tmp/out --n 20 processHeaderDocument
332
+ ```
333
+
334
+ This command will process all the PDF files present in the input directory (files with extension `.pdf` only) with the `processHeaderDocument` service of GROBID, and write the resulting XML TEI files under the output directory, reusing the file name with a different file extension (`.grobid.tei.xml`), using `20` concurrent workers.
335
+
336
+ By default if an existing `.grobid.tei.xml` file is present in the output directory corresponding to a PDF in the input directory, this PDF will be skipped to avoid reprocessing several times the same PDF. To force the processing of PDF and over-write of existing TEI files, use the parameter `--force`.
337
+
338
+ `processCitationList` does not take a repertory of PDF as input, but a repertory of `.txt` files, with one reference raw string per line, for example:
339
+
340
+ ```console
341
+ > grobid_client --input resources/test_txt/ --output resources/test_out/ --n 20 processCitationList
342
+ ```
343
+
344
+ The following command example will process all the PDF files present in the input directory and add bounding box coordinates (`--teiCoordinates`) relative to the original PDFs for the elements listed in the config file. It will also segment the sentences (`--segmentSentences`, this is a "layout aware" sentence segmentation) in the identified paragraphs with bounding box coordinates for the sentences.
345
+
346
+ ```console
347
+ > grobid_client --input ~/tmp/in2 --output ~/tmp/out --teiCoordinates --segmentSentences processFulltextDocument
348
+ ```
349
+
350
+ The file `example.py` gives an example of usage as a library, from a another python script.
351
+
352
+ ## Using the client in your python
353
+
354
+ Import and call the client as follow:
355
+
356
+ ```python
357
+ from grobid_client.grobid_client import GrobidClient
358
+
359
+ client = GrobidClient(config_path="./config.json")
360
+ client.process("processFulltextDocument", "/mnt/data/covid/pdfs", n=20)
361
+ ```
362
+
363
+ See also `example.py`.
364
+
365
+ ## Configuration of the client
366
+
367
+ There are a few parameters that can be set with the `config.json` file.
368
+
369
+ - `grobid_server` indicates the URL of the GROBID server to be used by the client.
370
+
371
+ - `batch_size` is the the size of the pool of threads used by ThreadPoolExecutor, you normally don't want to change this. This should be a high number (default 1000) - but not too high to protect the memory on the machine running the client. This should not be confused with the concurrency parameter `n` which indicates how many parallel requests can be send to GROBID.
372
+
373
+ - `sleep_time` indicates in seconds the time to wait for sending a new request to GROBID when the server indicates that all its threads are currently used. The client need to re-send the query after a wait time that will allow the server to free some threads. This wait time usually depends on the service and the capacities of the server, we suggest 5-10 seconds for the `processFulltextDocument` service and 2 seconds for `processHeaderDocument` service.
374
+
375
+ - `timeout` is a client side timeout - the process on server side will still be running until the server finished the task or the server timeout is reached.
376
+
377
+ - `coordinates` indicates the structure XML elements that should contains PDF coordinates when the parameters `--teiCoordinates` is used see [here](https://grobid.readthedocs.io/en/latest/Coordinates-in-PDF/) for more details.
378
+
379
+ Here is the default `config.json` file for the client:
380
+
381
+ ```
382
+ {
383
+ "grobid_server": "http://localhost:8070",
384
+ "batch_size": 1000,
385
+ "sleep_time": 5,
386
+ "timeout": 60,
387
+ "coordinates": [ "persName", "figure", "ref", "biblStruct", "formula", "s" ]
388
+ }
389
+ ```
390
+
391
+ ## Benchmarking
392
+
393
+ Full text processing of __136 PDF__ (total 3443 pages, in average 25 pages per PDF) on Intel Core i7-4790K CPU 4.00GHz, 4 cores (8 threads), 16GB memory, `n` being the concurrency parameter:
394
+
395
+ | n | runtime (s)| s/PDF | PDF/s |
396
+ |----|------------|-------|-------|
397
+ | 1 | 209.0 | 1.54 | 0.65 |
398
+ | 2 | 112.0 | 0.82 | 1.21 |
399
+ | 3 | 80.4 | 0.59 | 1.69 |
400
+ | 5 | 62.9 | 0.46 | 2.16 |
401
+ | 8 | 55.7 | 0.41 | 2.44 |
402
+ | 10 | 55.3 | 0.40 | 2.45 |
403
+
404
+ ![Runtime Plot](resources/20180928112135.png)
405
+
406
+ As complementary info, GROBID processing of header of the 136 PDF and with `n=10` takes 3.74 s (15 times faster than the complete full text processing because only the two first pages of the PDF are considered), 36 PDF/s.
407
+
408
+ In similar conditions, extraction and structuring of bibliographical references takes 26.9 s (5.1 PDF/s).
409
+
410
+ Processing of 3500 raw bibliographical take 4.3 s with `n=10` (814 references parsed per second).
411
+
412
+
413
+ ## Developer notes
414
+
415
+ ### New release
416
+
417
+ New releases can be published by using `bump-my-version`:
418
+
419
+ ```shell
420
+ pip install bump-my-version
421
+ bump-my-version bump patch
422
+ ```
423
+
424
+ Use of `major`, `minor`, or `patch` or will increment the first, second or the third digit of the version, respectively.
425
+ The release will be published automatically on pypy.
426
+
427
+ ## License and contact
428
+
429
+ Distributed under [Apache 2.0 license](http://www.apache.org/licenses/LICENSE-2.0).
430
+
431
+ Main author and contact: Patrice Lopez (<patrice.lopez@science-miner.com>)
@@ -1,20 +1,10 @@
1
- Metadata-Version: 2.1
2
- Name: grobid-client-python
3
- Version: 0.0.7
4
- Summary: Simple python client for GROBID REST services
5
- Home-page: https://github.com/kermitt2/grobid_client_python
6
- Author: kermitt2
7
- License: LICENSE
8
- Description-Content-Type: text/markdown
9
- License-File: LICENSE
10
-
11
1
  [![PyPI version](https://badge.fury.io/py/grobid_client_python.svg)](https://badge.fury.io/py/grobid_client_python)
12
2
  [![SWH](https://archive.softwareheritage.org/badge/origin/https://github.com/kermitt2/grobid_client_python/)](https://archive.softwareheritage.org/browse/origin/https://github.com/kermitt2/grobid_client_python/)
13
3
  [![License](http://img.shields.io/:license-apache-blue.svg)](http://www.apache.org/licenses/LICENSE-2.0.html)
14
4
 
15
5
  # Simple python client for GROBID REST services
16
6
 
17
- This Python client can be used to process in an efficient concurrent manner a set of PDF in a given directory by the [GROBID](https://github.com/kermitt2/grobid) service. It includes a command line for processing PDF on a file system and write results in a given output directory and a library for import in other python scripts. The client can also process similarly a list of files with reference strings (one per line).
7
+ This Python client can be used to process in an efficient concurrent manner a set of PDF in a given directory by the [GROBID](https://github.com/kermitt2/grobid) service. It includes a command line for processing PDF on a file system and write results in a given output directory and a library for import in other python scripts. The client can also process similarly a list of files with reference strings (one per line) and patents in XML ST36 formats.
18
8
 
19
9
  ## Before you start
20
10
 
@@ -30,13 +20,27 @@ You can change the server address by editing the file `config.json`, see below.
30
20
 
31
21
  ## Requirements
32
22
 
33
- This client has been developed and was tested with Python `3.5`-`3.8` and should work with any higher `3.*` versions. It does not require any dependencies beyond the standard Python ones.
23
+ This client has been developed and was tested with Python `3.5`-`3.9` and should work with any higher `3.*` versions. It uses `requests` as dependency beyond the Standard Python Library.
34
24
 
35
25
  ## Install
36
26
 
37
- Get the github repo:
27
+ The client can be installed with any of the following ways:
28
+
29
+ * Install *latest stable release* from PyPI:
38
30
 
39
31
  ```console
32
+ python3 -m pip install grobid-client-python
33
+ ```
34
+
35
+ * Install *current master development version* from GitHub:
36
+
37
+ ```console
38
+ python3 -m pip install git+https://github.com/kermitt2/grobid_client_python.git
39
+ ```
40
+
41
+ * Install and build from a clone of the repo (*current master development version*):
42
+
43
+ ```
40
44
  git clone https://github.com/kermitt2/grobid_client_python
41
45
  cd grobid_client_python
42
46
  python3 setup.py install
@@ -44,9 +48,10 @@ python3 setup.py install
44
48
 
45
49
  There is nothing more needed to start using the python command lines, see the next section.
46
50
 
47
-
48
51
  ## Usage and options
49
52
 
53
+ The call to the script can normally be realized interchangeably with `python3 -m grobid_client.grobid_client` or simply `grobid_client`.
54
+
50
55
  ```
51
56
  usage: grobid_client [-h] [--input INPUT] [--output OUTPUT] [--config CONFIG]
52
57
  [--n N] [--generateIDs] [--consolidate_header]
@@ -60,7 +65,8 @@ Client for GROBID services
60
65
  positional arguments:
61
66
  service one of ['processFulltextDocument',
62
67
  'processHeaderDocument', 'processReferences',
63
- 'processCitationList']
68
+ 'processCitationList','processCitationPatentST36',
69
+ 'processCitationPatentPDF']
64
70
 
65
71
  optional arguments:
66
72
  -h, --help show this help message and exit
@@ -187,6 +193,20 @@ In similar conditions, extraction and structuring of bibliographical references
187
193
  Processing of 3500 raw bibliographical take 4.3 s with `n=10` (814 references parsed per second).
188
194
 
189
195
 
196
+ ## Developer notes
197
+
198
+ ### New release
199
+
200
+ New releases can be published by using `bump-my-version`:
201
+
202
+ ```shell
203
+ pip install bump-my-version
204
+ bump-my-version bump patch
205
+ ```
206
+
207
+ Use of `major`, `minor`, or `patch` or will increment the first, second or the third digit of the version, respectively.
208
+ The release will be published automatically on pypy.
209
+
190
210
  ## License and contact
191
211
 
192
212
  Distributed under [Apache 2.0 license](http://www.apache.org/licenses/LICENSE-2.0).
@@ -0,0 +1,7 @@
1
+ {
2
+ "grobid_server": "http://localhost:8070",
3
+ "batch_size": 100,
4
+ "sleep_time": 5,
5
+ "timeout": 60,
6
+ "coordinates": [ "persName", "figure", "ref", "biblStruct", "formula", "s", "note", "title" ]
7
+ }
@@ -0,0 +1,5 @@
1
+ from grobid_client.grobid_client import GrobidClient
2
+
3
+ if __name__ == "__main__":
4
+ client = GrobidClient(config_path="./config.json")
5
+ client.process("processFulltextDocument", "./resources/test_pdf", output="./resources/test_out/", consolidate_citations=True, tei_coordinates=True, force=True)