Skip to main content

Read and an write web anno tsv

Project description

Inception Webanno tsv

Read and write webanno tsv 3.2 files

Install

 pip install git+https://github.com/Pangeamt/web_anno_tsv

Read a webanno tsv file

from web_anno_tsv import open_web_anno_tsv

tsv1 = 'test.tsv'

with open_web_anno_tsv(tsv1) as f:
    for i, sentence in enumerate(f):
        print(f"Sentence {i}:", sentence.text)
        for j, annotation in enumerate(sentence.annotations):
            print(f'\tAnnotation {j}:')
            print('\t\tText:', annotation.text)
            print("\t\tLabel:", annotation.label)
            print("\t\tOffsets", f"{annotation.start}, {annotation.stop}")

Write a webanno tsv file

from web_anno_tsv import open_web_anno_tsv

tsv1 = 'test.tsv'
tsv2 = 'test_write.tsv'

with open_web_anno_tsv(tsv1) as f1:
    with open_web_anno_tsv(tsv2, 'w') as f2:
        for sentence in f1:
            f2.write(sentence)

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

web_anno_tsv-0.0.1.tar.gz (5.4 kB view hashes)

Uploaded Source

Built Distribution

web_anno_tsv-0.0.1-py3-none-any.whl (5.9 kB view hashes)

Uploaded Python 3

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