GithubHelp home page GithubHelp logo

robertdigital / grobid-client-python Goto Github PK

View Code? Open in Web Editor NEW

This project forked from sutdbrainlab/grobid-client-python

0.0 1.0 0.0 36 KB

Simple python client for GROBID REST services

License: Apache License 2.0

Python 100.00%

grobid-client-python's Introduction

Simple python client for GROBID REST services

This Python client can be used to process in an efficient concurrent manner a set of PDF in a given directory by the GROBID service. Results are written in a given output directory and include the resulting XML TEI representation of the PDF.

Build and run

You need first to install and start the grobid service, latest stable version, see the documentation. It is assumed that the server will run on the address http://localhost:8070. You can change the server address by editing the file config.json.

Requirements

This client has been developed and tested with Python 3.5.

Install

Get the github repo:

git clone https://github.com/kermitt2/grobid-client-python

cd grobid-client-python

It is advised to setup first a virtual environment to avoid falling into one of these gloomy python dependency marshlands:

virtualenv --system-site-packages -p python3 env

source env/bin/activate

Usage and options

usage: grobid-client.py [-h] [--input INPUT] [--config CONFIG]
                        [--output OUTPUT] [--n N]
                        service

Client for GROBID services

positional arguments:
  service          one of [processFulltextDocument, processHeaderDocument,
                   processReferences]

optional arguments:
  -h, --help       show this help message and exit
  --input INPUT    path to the directory containing PDF to process
  --output OUTPUT  path to the directory where to put the results
  --config CONFIG  path to the config file, default is ./config.json
  --n N            Concurrency for service usage

Example:

python3 grobid-client.py --input ~/tmp/in2 --output ~/tmp/out processFulltextDocument

This command will process all the PDF files present in the input directory (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 (.tei.xml), using the default 10 concurrent workers.

python3 grobid-client.py --input ~/tmp/in2 --output ~/tmp/out --n 20 processHeaderDocument

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 (.tei.xml), using 20 concurrent workers.

Benchmarking

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:

n runtime (s) s/PDF
1 209.0 1.54
2 112.0 0.82
3 80.4 0.59
5 62.9 0.46
8 55.7 0.41
10 55.3 0.40

Runtime Plot

As complementary info, GROBID processing of header, with 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). In similar conditions, extraction and structuring of bibliographical references takes 26.9 s.

Todo

Benchmarking with more files (e.g. million ISTEX PDF). Also implement existing GROBID services for text input (date, name, affiliation/address, raw bibliographical references, etc.). Better support for parameters (including elements where to put coordinates).

License and contact

Distributed under Apache 2.0 license.

Main author and contact: Patrice Lopez ([email protected])

grobid-client-python's People

Contributors

kermitt2 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.