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[delft,cpu]

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.

You can find the API docs under /api/docs, e.g.:

http://localhost:8080/api/docs

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

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sciencebeam_parser-0.1.13-py3-none-any.whl (159.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: sciencebeam_parser-0.1.13.tar.gz
  • Upload date:
  • Size: 109.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for sciencebeam_parser-0.1.13.tar.gz
Algorithm Hash digest
SHA256 fea25fe3954cec6e63a42b26a946b4507ad5376bb58732a5460c2cb24aa2ae90
MD5 150d4d9a93ab9a51dd0a59c18e78ebf0
BLAKE2b-256 b934ecf43b23003da9be352edb21ba797b7bf4f8d059924a387898e267e0ed48

See more details on using hashes here.

File details

Details for the file sciencebeam_parser-0.1.13-py3-none-any.whl.

File metadata

File hashes

Hashes for sciencebeam_parser-0.1.13-py3-none-any.whl
Algorithm Hash digest
SHA256 57cd38434430807c2469976833926ee3e10bfb4182e10c7af67cb5e39bd36ce8
MD5 2ed30f9faa8426c41b78c3a71f4554b7
BLAKE2b-256 64103a709ea0444bb2aeba87c9cc5c4e6c7abb071e05669056d55292783291ee

See more details on using hashes here.

Supported by

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