Apertium + Python
Introduction
- The codebase is in development for the GSoC '19 project called Apertium API in Python
- The Apertium core modules are written in C++.
- This project makes the Apertium modules available in Python, which because of its simplicity is more appealing to users.
About the Exisiting Code Base
- The existing codebase has
Subprocessand SWIG wrapper implementations of the higher level functions of Apertium and CG modules.
Installation
-
Installation on Debian/Ubuntu and Windows is natively supported:
pip install apertium -
For developers,
pipenvcan be used to install the development dependencies and enter a shell with them:pip install pipenv pipenv install --dev pipenv shell -
Apertium packages can be installed from Python interpreter as well.
- Install
apertium-all-devby callingapertium.installer.install_apertium() - Install language packages with
apertium.installer.install_module(language_name). For exampleapertium-engcan be installed by executingapertium.installer.install_module('eng')
- Install
Usage
- For multiple invocations
Method 1is more performant, as the dictionary needs to be loaded only once.
Analysis
Performing Morphological Analysis
Method 1: Create an Analyzer object and call its analyze method.
In [1]: import apertium
In [2]: a = apertium.Analyzer('en')
In [3]: a.analyze('cats')
Out[3]: [cats/cat<n><pl>, ./.<sent>]
Method 2: Calling analyze() directly.
In [1]: import apertium
In [2]: apertium.analyze('en', 'cats')
Out[2]: cats/cat<n><pl>
Generation
Performing Morphological Generation
Method 1: Create a Generator object and call its generate method.
In [1]: import apertium
In [2]: g = apertium.Generator('en')
In [3]: g.generate('^cat<n><pl>$')
Out[3]: 'cats'
Method 2: Calling generate() directly.
In [1]: import apertium
In [2]: apertium.generate('en', '^cat<n><pl>$')
Out[2]: 'cats'
Tagger
Method 1: Create a Tagger object and call its tag method.
In [1]: import apertium
In [2]: tagger = apertium.Tagger('eng')
In [3]: tagger.tag('cats')
Out[3]: [cats/cat<n><pl>]
Method 2: Calling tag() directly.
In [1]: import apertium
In [2]: apertium.tag('en', 'cats')
Out[2]: [cats/cat<n><pl>]
Translation
Method 1: Create a Translator object and call its translate method.
In [1]: import apertium
In [2]: t = apertium.Translator('eng', 'spa')
In [3]: t.translate('cats')
Out[3]: 'Gatos'
Method 2: Calling translate() directly.
In [1]: import apertium
In [2]: apertium.translate('en', 'spa', 'cats')
Out[2]: 'Gatos'
Installing more modes from other language data
One can also install modes by providing the path to the lang-data:
In [1]: import apertium
In [2]: apertium.append_pair_path('..')
Metadata
Release files for apertium 0.2.4
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 |
|---|---|---|---|---|
| apertium-0.2.4.tar.gz | 26.3 kB | Without provenance | Details for apertium-0.2.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| apertium-0.2.4-py3-none-any.whl | Python 3 | none | any | Details for apertium-0.2.4-py3-none-any.whl |
Total release size: 53.4 kB
Release files / apertium-0.2.4.tar.gz
| Download URL | apertium-0.2.4.tar.gz |
|---|---|
| Size | 26.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d032d0cc08890214da7663fea407b98087841c3b6142dfebbd0623a30aca12a6
|
|
BLAKE2b-256 checksum How to use checksums |
25d4530ae0ab90ad39dda5280fd95d609bdfd1f111e44507615a66650c96eba0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.10.12
|
Release files / apertium-0.2.4-py3-none-any.whl
| Download URL | apertium-0.2.4-py3-none-any.whl |
|---|---|
| Size | 27.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
79dff4cc8774106be459ae56daf63fdb8a6734f1fd988776670539d9075ee5eb
|
|
BLAKE2b-256 checksum How to use checksums |
e71f176519db93739933a17875d18e61ec9b9a815e8b6d88b4bfb9ce82adb0a3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.10.12
|
Security for apertium 0.2.4
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.