nzilbb-labbcat


Namenzilbb-labbcat JSON
Version 0.7.3 PyPI version JSON
download
home_pagehttps://github.com/nzilbb/labbcat-py/
SummaryClient library for communicating with LaBB-CAT servers
upload_time2023-06-06 21:03:59
maintainer
docs_urlNone
authorRobert Fromont
requires_python
licenseGPL-3.0-or-later
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # nzilbb-labbcat

[![DOI](https://zenodo.org/badge/243340359.svg)](https://zenodo.org/badge/latestdoi/243340359)

Client library for communicating with [LaBB-CAT](https://labbcat.canterbury.ac.nz/)
servers using Python.

e.g.

```python
import labbcat

# Connect to the LaBB-CAT corpus
corpus = labbcat.LabbcatView("https://labbcat.canterbury.ac.nz/demo", "demo", "demo")

# Find all tokens of a word
matches = corpus.getMatches({"orthography":"quake"})

# Get the recording of that utterance
audio = corpus.getSoundFragments(matches)

# Get Praat TextGrids for the utterances
textgrids = corpus.getFragments(
    matches, ["utterance", "word","segment"],
    "text/praat-textgrid")
```

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.

The current version of this library requires LaBB-CAT version 20220307.1126.

## Documentation

Detailed documentation is available [here](https://nzilbb.github.io/labbcat-py/)

# Basic usage

*nzilbb-labbcat* is available in the Python Package Index
[here](https://pypi.org/project/nzilbb-labbcat/)

To install the module:

```
pip install nzilbb-labbcat
```

The following example shows how to:
1. upload a transcript to LaBB-CAT,
2. wait for the automatic annotation tasks to finish,
3. extract the annotation labels, and
4. delete the transcript from LaBB-CAT.

```python
import labbcat

# Connect to the LaBB-CAT corpus
corpus = labbcat.LabbcatEdit("http://localhost:8080/labbcat", "labbcat", "labbcat")

# List the corpora on the server
corpora = corpus.getCorpusIds()

# List the transcript types
transcript_type_layer = corpus.getLayer("transcript_type")
transcript_types = transcript_type_layer["validLabels"]

# Upload a transcript
corpus_id = corpora[0]
transcript_type = next(iter(transcript_types))
taskId = corpus.newTranscript(
    "test/labbcat-py.test.txt", None, None, transcript_type, corpus_id, "test")

# wait for the annotation generation to finish
corpus.waitForTask(taskId)
corpus.releaseTask(taskId)

# get the "POS" layer annotations
annotations = corpus.getAnnotations("labbcat-py.test.txt", "pos")
labels = list(map(lambda annotation: annotation["label"], annotations))

# delete tha transcript from the corpus
corpus.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:
 - `pip3 install twine`
 - `pip3 install pathlib`
 - `apt install python3-sphinx`

## Unit tests

```
python3 -m unittest
```

...or for specific tests:

```
python3 -m unittest test.TestLabbcatAdmin
```

## Documentation generation

```
cd docs
make clean
make
```

## Publishing

```
rm dist/*
python3 setup.py sdist bdist_wheel
twine check dist/*
twine upload dist/*
```


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/nzilbb/labbcat-py/",
    "name": "nzilbb-labbcat",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "",
    "author": "Robert Fromont",
    "author_email": "robert@fromont.net.nz",
    "download_url": "https://files.pythonhosted.org/packages/25/59/e98e70889074d2557a49cb9d1446ae1fdff3664760bf99d394cc3fae8ab3/nzilbb-labbcat-0.7.3.tar.gz",
    "platform": null,
    "description": "# nzilbb-labbcat\n\n[![DOI](https://zenodo.org/badge/243340359.svg)](https://zenodo.org/badge/latestdoi/243340359)\n\nClient library for communicating with [LaBB-CAT](https://labbcat.canterbury.ac.nz/)\nservers using Python.\n\ne.g.\n\n```python\nimport labbcat\n\n# Connect to the LaBB-CAT corpus\ncorpus = labbcat.LabbcatView(\"https://labbcat.canterbury.ac.nz/demo\", \"demo\", \"demo\")\n\n# Find all tokens of a word\nmatches = corpus.getMatches({\"orthography\":\"quake\"})\n\n# Get the recording of that utterance\naudio = corpus.getSoundFragments(matches)\n\n# Get Praat TextGrids for the utterances\ntextgrids = corpus.getFragments(\n    matches, [\"utterance\", \"word\",\"segment\"],\n    \"text/praat-textgrid\")\n```\n\nLaBB-CAT is a web-based linguistic annotation store that stores audio or video\nrecordings, text transcripts, and other annotations.\n\nAnnotations of various types can be automatically generated or manually added.\n\nLaBB-CAT servers are usually password-protected linguistic corpora, and can be\naccessed manually via a web browser, or programmatically using a client library like\nthis one.\n\nThe current version of this library requires LaBB-CAT version 20220307.1126.\n\n## Documentation\n\nDetailed documentation is available [here](https://nzilbb.github.io/labbcat-py/)\n\n# Basic usage\n\n*nzilbb-labbcat* is available in the Python Package Index\n[here](https://pypi.org/project/nzilbb-labbcat/)\n\nTo install the module:\n\n```\npip install nzilbb-labbcat\n```\n\nThe following example shows how to:\n1. upload a transcript to LaBB-CAT,\n2. wait for the automatic annotation tasks to finish,\n3. extract the annotation labels, and\n4. delete the transcript from LaBB-CAT.\n\n```python\nimport labbcat\n\n# Connect to the LaBB-CAT corpus\ncorpus = labbcat.LabbcatEdit(\"http://localhost:8080/labbcat\", \"labbcat\", \"labbcat\")\n\n# List the corpora on the server\ncorpora = corpus.getCorpusIds()\n\n# List the transcript types\ntranscript_type_layer = corpus.getLayer(\"transcript_type\")\ntranscript_types = transcript_type_layer[\"validLabels\"]\n\n# Upload a transcript\ncorpus_id = corpora[0]\ntranscript_type = next(iter(transcript_types))\ntaskId = corpus.newTranscript(\n    \"test/labbcat-py.test.txt\", None, None, transcript_type, corpus_id, \"test\")\n\n# wait for the annotation generation to finish\ncorpus.waitForTask(taskId)\ncorpus.releaseTask(taskId)\n\n# get the \"POS\" layer annotations\nannotations = corpus.getAnnotations(\"labbcat-py.test.txt\", \"pos\")\nlabels = list(map(lambda annotation: annotation[\"label\"], annotations))\n\n# delete tha transcript from the corpus\ncorpus.deleteTranscript(\"labbcat-py.test.txt\")\n```\n\nFor batch uploading and other example code, see the *examples* subdirectory.\n\n# Developers\n\nTo build, test, release, and document the module, the following prerequisites are required:\n - `pip3 install twine`\n - `pip3 install pathlib`\n - `apt install python3-sphinx`\n\n## Unit tests\n\n```\npython3 -m unittest\n```\n\n...or for specific tests:\n\n```\npython3 -m unittest test.TestLabbcatAdmin\n```\n\n## Documentation generation\n\n```\ncd docs\nmake clean\nmake\n```\n\n## Publishing\n\n```\nrm dist/*\npython3 setup.py sdist bdist_wheel\ntwine check dist/*\ntwine upload dist/*\n```\n\n",
    "bugtrack_url": null,
    "license": "GPL-3.0-or-later",
    "summary": "Client library for communicating with LaBB-CAT servers",
    "version": "0.7.3",
    "project_urls": {
        "Homepage": "https://github.com/nzilbb/labbcat-py/"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2375dcb203b41a6d224008db94d3d584ce9392888c8b1f015aed5f06cd2bf792",
                "md5": "040d170580dd4afeda05100b36b5333a",
                "sha256": "282f078a174c9d4cd6a163d00196e545da9fe1228ce895b67cacd3a15f978623"
            },
            "downloads": -1,
            "filename": "nzilbb_labbcat-0.7.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "040d170580dd4afeda05100b36b5333a",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 50236,
            "upload_time": "2023-06-06T21:03:57",
            "upload_time_iso_8601": "2023-06-06T21:03:57.327648Z",
            "url": "https://files.pythonhosted.org/packages/23/75/dcb203b41a6d224008db94d3d584ce9392888c8b1f015aed5f06cd2bf792/nzilbb_labbcat-0.7.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2559e98e70889074d2557a49cb9d1446ae1fdff3664760bf99d394cc3fae8ab3",
                "md5": "7e7c9a9235a0cfc8aabec75d326ff527",
                "sha256": "954f1483d0392cfb5818657f9951a81074c30355bc8fe1ac7e5455c06b78133b"
            },
            "downloads": -1,
            "filename": "nzilbb-labbcat-0.7.3.tar.gz",
            "has_sig": false,
            "md5_digest": "7e7c9a9235a0cfc8aabec75d326ff527",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 29366,
            "upload_time": "2023-06-06T21:03:59",
            "upload_time_iso_8601": "2023-06-06T21:03:59.097314Z",
            "url": "https://files.pythonhosted.org/packages/25/59/e98e70889074d2557a49cb9d1446ae1fdff3664760bf99d394cc3fae8ab3/nzilbb-labbcat-0.7.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-06-06 21:03:59",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "nzilbb",
    "github_project": "labbcat-py",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "nzilbb-labbcat"
}
        
Elapsed time: 0.12880s