Introduction
onf-parser is a lightweight pure Python library for parsing the OntoNotes Normal Form format (.onf – cf. section 6.3).
Installation
Note that Python >=3.7 is required due to our dependency on dataclasses.
pip install onf-parser
Usage
There are three top-level functions:
from onf_parser import parse_files, parse_file, parse_file_string
# read a single file
sections = parse_file('ontonotes/some/file.onf')
# or parse a raw string
sections = parse_file_string(s)
# read all .onf files in a single directory
files = parse_file('ontonotes/')
For each file, a list of Section objects (which correspond to documents for the purposes of annotation) will be available:
for filepath, sections in files:
for section in sections:
coref_chains = section.chains
for chain in coref_chains:
print(chain.type)
print(chain.id)
print(chain.mentions)
for mention in chain.mentions:
print(mention.sentence_id)
print(mention.tokens)
for sentence in section.sentences:
print(sentence.plain_sentence)
print(sentence.plain_sentence.string)
print(sentence.treebanked_sentence)
print(sentence.treebanked_sentence.string)
print(sentence.treebanked_sentence.tokens)
print(sentence.speaker_information)
print(sentence.speaker_information.name)
print(sentence.speaker_information.start_time)
print(sentence.speaker_information.stop_time)
print(sentence.tree)
print(sentence.tree.tree_string)
print(sentence.leaves)
for leaf in sentence.leaves:
print(leaf.token)
print(leaf.token_id)
# NER
print(leaf.name)
print(leaf.name.type)
print(leaf.name.token_id_range)
print(leaf.name.tokens)
# Coreference
print(leaf.coref)
print(leaf.coref.type)
print(leaf.coref.token_id_range)
print(leaf.coref.tokens)
# WordNet sense
print(leaf.sense)
print(leaf.sense.label)
# PropBank
print(leaf.prop.label)
print(leaf.prop)
for arg_label, arg_spans in leaf.prop.args.items():
print(arg_label)
for arg_span in arg_spans:
print(arg_span)
See model classes for more information.
Metadata
Release files for onf-parser 0.2.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| onf_parser-0.2.3-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details for onf_parser-0.2.3-py2.py3-none-any.whl |
Release files / onf_parser-0.2.3-py2.py3-none-any.whl
| Download URL | onf_parser-0.2.3-py2.py3-none-any.whl |
|---|---|
| Size | 8.8 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
5748eec425573c5f2eacf787f62641389e758b8f0ae576fe4ae35346dd5fa19a
|
|
BLAKE2b-256 checksum How to use checksums |
24b972ad5b67eda95c456b90fc58bb23f1bc142de5b632bfe93079f5ce852a11
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.5
|
Security for onf-parser 0.2.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.