Skip to main content

ScienceBeam Parser, parse scientific documents.

Project description

ScienceBeam Parser Python Library

ScienceBeam Parser allows you to parse scientific documents. It provides a REST API Service, as well as a Python API.

Installation

pip install sciencebeam-parser

CLI

CLI: Start Server

python -m sciencebeam_parser.service.server --port=8080

The server will start to listen on port 8080.

The default config.yml defines what models to load.

Python API

Python API: Start Server

from sciencebeam_parser.config.config import AppConfig
from sciencebeam_parser.resources.default_config import DEFAULT_CONFIG_FILE
from sciencebeam_parser.service.server import create_app


config = AppConfig.load_yaml(DEFAULT_CONFIG_FILE)
app = create_app(config)
app.run(port=8080, host='127.0.0.1', threaded=True)

The server will start to listen on port 8080.

Python API: Parse Multiple Files

from sciencebeam_parser.resources.default_config import DEFAULT_CONFIG_FILE
from sciencebeam_parser.config.config import AppConfig
from sciencebeam_parser.utils.media_types import MediaTypes
from sciencebeam_parser.app.parser import ScienceBeamParser


config = AppConfig.load_yaml(DEFAULT_CONFIG_FILE)

# the parser contains all of the models
sciencebeam_parser = ScienceBeamParser.from_config(config)

# a session provides a scope and temporary directory for intermediate files
# it is recommended to create a separate session for every document
with sciencebeam_parser.get_new_session() as session:
    session_source = session.get_source(
        'test-data/minimal-example.pdf',
        MediaTypes.PDF
    )
    converted_file = session_source.get_local_file_for_response_media_type(
        MediaTypes.TEI_XML
    )
    # Note: the converted file will be in the temporary directory of the session
    print('converted file:', converted_file)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sciencebeam_parser-0.1.3.tar.gz (88.1 kB view details)

Uploaded Source

File details

Details for the file sciencebeam_parser-0.1.3.tar.gz.

File metadata

  • Download URL: sciencebeam_parser-0.1.3.tar.gz
  • Upload date:
  • Size: 88.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.2.0 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.10

File hashes

Hashes for sciencebeam_parser-0.1.3.tar.gz
Algorithm Hash digest
SHA256 665e1dd57c836ec7cba3219301f0d25aa248dec15002b6f52b1a1bc8e65de91b
MD5 0b467dfa651dcea6c5263a1c5d20d2b1
BLAKE2b-256 ca637a1ed89158aaf4c77a620423bae8b0fa9fc028ecb5f465c1b258bb30c646

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page