Client library for communicating with LaBB-CAT servers
Project description
nzilbb-labbcat
Client library for communicating with LaBB-CAT servers using Python.
LaBB-CAT is a web-based linguistic annotation store that stores audio or video recordings, text transcripts, and other annotations.
Annotations of various types can be automatically generated or manually added.
LaBB-CAT servers are usually password-protected linguistic corpora, and can be accessed manually via a web browser, or programmatically using a client library like this one.
Documentation
Detailed documentation is available here
Basic usage
nzilbb-labbcat is available in the Python Package Index here
To install the module:
pip install nzilbb-labbcat
The following example shows how to:
- upload a transcript to LaBB-CAT,
- wait for the automatic annotation tasks to finish,
- extract the annotation labels, and
- delete the transcript from LaBB-CAT.
import labbcat
# Connect to the LaBB-CAT annotation store
store = labbcat.Labbcat("http://localhost:8080/labbcat", "labbcat", "labbcat")
# List the corpora on the server
corpora = store.getCorpusIds()
# List the transcript types
transcript_type_layer = store.getLayer("transcript_type")
transcript_types = transcript_type_layer["validLabels"]
# Upload a transcript
corpus_id = corpora[0]
transcript_type = next(iter(transcript_types))
taskId = store.newTranscript(
"test/labbcat-py.test.txt", None, None, transcript_type, corpus_id, "test")
# wait for the annotation generation to finish
store.waitForTask(taskId)
store.releaseTask(taskId)
# get the "POS" layer annotations
annotations = store.getAnnotations("labbcat-py.test.txt", "pos")
labels = list(map(lambda annotation: annotation["label"], annotations))
# delete tha transcript from the corpus
store.deleteTranscript("labbcat-py.test.txt")
For batch uploading and other example code, see the examples subdirectory.
Developers
To build, test, release, and document the module, the following prerequisites are required:
pip install twine
pip install pathlib
apt install python3-sphinx
Unit tests
python -m unittest
Documentation generation
cd docs
make clean
make
Publishing
rm dist/*
python setup.py sdist bdist_wheel
twine check dist/*
twine upload dist/*
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for nzilbb_labbcat-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 69c56dfb733d7291d9f92224ccfb3ade166c16539c818eb79a6953dd2686bccc |
|
MD5 | c53167b82c7f84b73b227e520ba9cae9 |
|
BLAKE2b-256 | f87556c870b2833cba567594edc36347daefad1b6e20dbc689da1beababb8f34 |