pyigt: Handling interlinear glossed text with Python
This library provides easy access to Interlinear Glossed Text (IGT) according to the Leipzig Glossing Rules, stored as CLDF examples.
Installation
Installing pyigt via pip
pip install pyigt
will install the Python package along with a command line interface igt.
Note: The methods Corpus.get_wordlist and Corpus.get_profile, to extract a wordlist and an orthography profile
from a corpus, require the lingpy package. To make sure it is installed, install pyigt as
pip install pyigt[lingpy]
CLI
$ igt -h
usage: igt [-h] [--log-level LOG_LEVEL] COMMAND ...
optional arguments:
-h, --help show this help message and exit
--log-level LOG_LEVEL
log level [ERROR|WARN|INFO|DEBUG] (default: 20)
available commands:
Run "COMAMND -h" to get help for a specific command.
COMMAND
ls List IGTs in a CLDF dataset
stats Describe the IGTs in a CLDF dataset
The igt ls command allows inspecting IGTs from the commandline, formatted using the
four standard lines described in the Leipzig Glossing Rules, where analyzed text and
glosses are aligned, e.g.
$ igt ls tests/fixtures/examples.csv
Example 1:
zəple: ȵike: peji qeʴlotʂuʁɑ,
zəp-le: ȵi-ke: pe-ji qeʴlotʂu-ʁɑ,
earth-DEF:CL WH-INDEF:CL become-CSM in.the.past-LOC
...
Example 5:
zuɑməɸu oʐgutɑ ipiχuɑȵi,
zuɑmə-ɸu o-ʐgu-tɑ i-pi-χuɑ-ȵi,
cypress-tree one-CL-LOC DIR-hide-because-ADV
IGT corpus at tests/fixtures/examples.csv
igt ls can be chained with other commandline tools such as commands from the
csvkit package for filtering:
$ csvgrep -c Primary_Text -m"ȵi" tests/fixtures/examples.csv | csvgrep -c Gloss -m"ADV" | igt ls -
Example 5:
zuɑməɸu oʐgutɑ ipiχuɑȵi,
zuɑmə-ɸu o-ʐgu-tɑ i-pi-χuɑ-ȵi,
cypress-tree one-CL-LOC DIR-hide-because-ADV
Python API
The Python API is documented in detail at readthedocs. Below is a quick overview.
You can read all IGT examples provided with a CLDF dataset
>>> from pyigt import Corpus
>>> corpus = Corpus.from_path('tests/fixtures/cldf-metadata.json')
>>> len(corpus)
5
>>> for igt in corpus:
... print(igt)
... break
...
zəple: ȵike: peji qeʴlotʂuʁɑ,
zəp-le: ȵi-ke: pe-ji qeʴlotʂu-ʁɑ,
earth-DEF:CL WH-INDEF:CL become-CSM in.the.past-LOC
or instantiate individual IGT examples, e.g. to check for validity:
>>> from pyigt import IGT
>>> ex = IGT(phrase="palasi=lu", gloss="priest-and")
>>> ex.check(strict=True, verbose=True)
palasi=lu
priest-and
...
ValueError: Rule 2 violated: Number of morphemes does not match number of morpheme glosses!
or to expand known gloss abbreviations:
>>> ex = IGT(phrase="Gila abur-u-n ferma hamišaluǧ güǧüna amuq’-da-č.",
... gloss="now they-OBL-GEN farm forever behind stay-FUT-NEG",
... translation="Now their farm will not stay behind forever.")
>>> ex.pprint()
Gila aburun ferma hamišaluǧ güǧüna amuq’dač.
Gila abur-u-n ferma hamišaluǧ güǧüna amuq’-da-č.
now they-OBL-GEN farm forever behind stay-FUT-NEG
‘Now their farm will not stay behind forever.’
OBL = oblique
GEN = genitive
FUT = future
NEG = negation, negative
And you can go deeper, parsing morphemes and glosses according to the LGR (see module pyigt.lgrmorphemes):
>>> igt = IGT(phrase="zəp-le: ȵi-ke: pe-ji qeʴlotʂu-ʁɑ,", gloss="earth-DEF:CL WH-INDEF:CL become-CSM in.the.past-LOC")
>>> igt.conformance
<LGRConformance.MORPHEME_ALIGNED: 2>
>>> igt[1, 1].gloss
<Morpheme "INDEF:CL">
>>> igt[1, 1].gloss.elements
[<GlossElement "INDEF">, <GlossElementAfterColon "CL">]
>>> igt[1, 1].morpheme
<Morpheme "ke:">
>>> print(igt[1, 1].morpheme)
ke:
See also
- interlineaR - an R package with similar functionality, but support for more input formats.
Metadata
Release files for pyigt 2.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pyigt-2.3.0.tar.gz | 47.0 kB | Without provenance | Details for pyigt-2.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pyigt-2.3.0-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details for pyigt-2.3.0-py2.py3-none-any.whl |
Total release size: 87.3 kB
Release files / pyigt-2.3.0.tar.gz
| Download URL | pyigt-2.3.0.tar.gz |
|---|---|
| Size | 47.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
365a5dfd9d77aeb65d9ecbacc86e68e5a758bd7101378980fcbbb96f149d4994
|
|
BLAKE2b-256 checksum How to use checksums |
d2737b2ca3f1eda2d8ffd4eb1a27578136bdfbd830edde0c7d8e9e1979c6645d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.3
|
Release files / pyigt-2.3.0-py2.py3-none-any.whl
| Download URL | pyigt-2.3.0-py2.py3-none-any.whl |
|---|---|
| Size | 40.3 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
73b28465ba5a3e70ff53a1157aa005d228ec51b4edd947ad25cf111d6f035893
|
|
BLAKE2b-256 checksum How to use checksums |
99905a9039c2d6e3b1b52b6a54ae06a19587d864fe620018d7e1fbc58d0d1a86
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.3
|
Security for pyigt 2.3.0
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.