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)

More Usage Examples

For more usage examples see sciencebeam-usage-examples.

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.8.tar.gz (108.6 kB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: sciencebeam_parser-0.1.8.tar.gz
  • Upload date:
  • Size: 108.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.26.0 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.2.0 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.7.10

File hashes

Hashes for sciencebeam_parser-0.1.8.tar.gz
Algorithm Hash digest
SHA256 a7c0849ed22bdaaafb3fc70ba680599383a32f1b58eeca419196f3eaa3d80ce2
MD5 fd44b885f77d98343502997faadc6c06
BLAKE2b-256 6001b6d127c5aef89c27e750081b036c78a9be406cc29bc546710aeb3ef126a4

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 Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page