PYthon Multilingual Ucrel Semantic Analysis System
Project description
PyMUSAS
Python Multilingual Ucrel Semantic Analysis System, is a rule based token and Multi Word Expression semantic tagger. The tagger can support any semantic tagset, however the tagset we have concentrated on and released pre-configured spaCy components for is the Ucrel Semantic Analysis System (USAS).
Documentation
- 📚 Usage Guides - What the package is, tutorials, how to guides, and explanations.
- 🔎 API Reference - The docstrings of the library, with minimum working examples.
- 🚀 Roadmap
Language support
PyMUSAS currently support 10 different languages with pre-configured spaCy components that can be downloaded, each language has it's own guide on how to tag text using PyMUSAS. Below we show the languages supported, if the model for that language supports Multi Word Expression (MWE) identification and tagging (all languages support token level tagging by default), and size of the model:
| Language (BCP 47 language code) | MWE Support | Size |
|---|---|---|
| Mandarin Chinese (cmn) | :heavy_check_mark: | 1.28MB |
| Welsh (cy) | :heavy_check_mark: | 1.09MB |
| Spanish, Castilian (es) | :heavy_check_mark: | 0.20MB |
| Finnish (fi) | :x: | 0.63MB |
| French (fr) | :x: | 0.08MB |
| Indonesian (id) | :x: | 0.24MB |
| Italian (it) | :heavy_check_mark: | 0.50MB |
| Dutch, Flemish (nl) | :x: | 0.15MB |
| Portuguese (pt) | :heavy_check_mark: | 0.27MB |
| English (en) | :heavy_check_mark: | 0.88MB |
Install PyMUSAS
Can be installed on all operating systems and supports Python version >= 3.10 < 3.15, to install run:
pip install pymusas
If using uv:
uv add pymusas
With neural models
If you want to use the Neural Network / Transformer models then you will need to install the neural extra like so:
pip install pymusas[neural]
or for uv:
uv add pymusas[neural]
Custom accelerator (torch and spaCy)
When installing the neural extra we use the default version of pytorch for your Operating System (OS), in the case for Linux this is likely to be the cuda version and for all other OSs this will be cpu. If you would like to use a different version of torch please either install it before install pymusas or add the package index like so uv add --index-strategy unsafe-best-match --index https://download.pytorch.org/whl/cu130 pymusas[neural] in this example we are downloading torch for cuda version 13.
Note we do not require the GPU version of spaCy spacy[cuda12x] to run pymusas with a custom accelerator like cuda but pymusas does support the GPU version of spaCy in case you are using it, but pymusas does not require it.
Development
Setup
You can either use the dev container with your favourite editor, e.g. VSCode. Or you can create your setup locally below we demonstrate both. To note in both cases we will be installing the CPU version and not the GPU version.
In both cases they share the same tools, of which these tools are:
- uv for Python packaging and development
- node for building and serving the documentation.
- make (OPTIONAL) for automation of tasks, not strictly required but makes life easier.
Dev Container
A dev container uses a docker container to create the required development environment, the Dockerfile we use for this dev container can be found at ./.devcontainer/Dockerfile. To run it locally it requires docker to be installed, you can also run it in a cloud based code editor, for a list of supported editors/cloud editors see the following webpage.
To run for the first time on a local VSCode editor (a slightly more detailed and better guide on the VSCode website):
- Ensure docker is running.
- Ensure the VSCode Dev Containers extension is installed in your VSCode editor.
- Open the command pallete
CMD + SHIFT + Pand then selectDev Containers: Rebuild and Reopen in Container
You should now have everything you need to develop, uv, node, npx, yarn, make, for VSCode various extensions like Pylance, etc.
If you have any trouble see the VSCode website..
Local
To run locally first ensure you have the following tools installted locally:
- uv for Python packaging and development. (version
0.9.6) - node using
nvmwithyarn. (version24). After installing this run the followingcd docs && corepack use yarnit install the correct version ofyarn. - make (OPTIONAL) for automation of tasks, not strictly required but makes life easier.
- Ubuntu:
apt-get install make - Mac: Xcode command line tools includes
makeelse you can use brew. - Windows: Various solutions proposed in this blog post on how to install on Windows, inclduing
Cygwin, andWindows Subsystem for Linux.
- Ubuntu:
When developing on the project you will want to install the Python package locally in editable format with all the extra requirements, this can be done like so:
uv sync --all-extras
Running linters and tests
This code base uses isort, flake8 and mypy to ensure that the format of the code is consistent and contain type hints. ISort and mypy settings can be found within ./pyproject.toml and the flake8 settings can be found in ./.flake8. To run these linters:
make lint
To run the unit tests with code coverage of the unit tests:
make tests
To run the doc tests, these are tests to ensure that examples within the documentation run as expected, the coverage results of these tests will also be reported:
make doc-tests
To run the all the tests (unit, documentation, and functional tests) with coverage that takes all of these tests into account:
make full-coverage-tests
To note the functional tests that are ran within this make command are the tests that build the pymusas package and then use the built package to test that the output of the taggers are what is to be expected.
Running GPU tests
NOTE We do not expect contributors to run these tests, the UCREL team can run these tests as part of the pull request before we merge into the main branch.
The GPU tests are the same tests as we run in make full-coverage-tests but some of these tests are skipped when we request the model to run in GPU mode this is why we have this docker image. The image if you run it assumes you have an Nvidia GPU and a Nvidia driver that supports CUDA 12.
These tests also allow us to test that the codebase can be used with the GPU version of spaCy spacy[cuda12x].
As we do not have GPU infrastructure on the CI pipeline, we can run the GPU tests locally use the following docker container (to note the 0.1.0 version number of the container is not meaningful at the moment):
docker build -t pymusas-gpu:0.1.0 -f ./tests/gpu-docker.dockerfile .
And then we can run the tests like so:
docker run --gpus all --shm-size 4g --rm pymusas-gpu:0.1.0
Note at the moment when running these tests only 2 errors should occur: tests/unit_tests/spacy_api/test_spacy_api_utils.py ..EE this at the moment is expected and we hope to resolve this in the future, all other tests should and are expected to pass.
Setting a different default python version
The default or recommended Python version is shown in [.python-version](./.python-version, currently 3.12, this can be changed using the uv command:
uv python pin
# uv python pin 3.13
Team
PyMUSAS is an open-source project that has been created and funded by the University Centre for Computer Corpus Research on Language (UCREL) at Lancaster University. For more information on who has contributed to this code base see the contributions page.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pymusas-0.4.0.tar.gz.
File metadata
- Download URL: pymusas-0.4.0.tar.gz
- Upload date:
- Size: 54.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2d050256c501b6d4bfe538e623463e0b648f1d9d3148aa2821ed67480cb94e8e
|
|
| MD5 |
3f39a92bd4e0c73f6457de51de9f160e
|
|
| BLAKE2b-256 |
313bb5915fd3f8f4d75ce111a7504b1fb449098fe0fc7f454e561abc9b54f205
|
Provenance
The following attestation bundles were made for pymusas-0.4.0.tar.gz:
Publisher:
publish.yml on UCREL/pymusas
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pymusas-0.4.0.tar.gz -
Subject digest:
2d050256c501b6d4bfe538e623463e0b648f1d9d3148aa2821ed67480cb94e8e - Sigstore transparency entry: 763934483
- Sigstore integration time:
-
Permalink:
UCREL/pymusas@a581ff6c9be415817cb6ee0da01571bcea9567c7 -
Branch / Tag:
refs/tags/v0.4.0 - Owner: https://github.com/UCREL
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@a581ff6c9be415817cb6ee0da01571bcea9567c7 -
Trigger Event:
release
-
Statement type:
File details
Details for the file pymusas-0.4.0-py3-none-any.whl.
File metadata
- Download URL: pymusas-0.4.0-py3-none-any.whl
- Upload date:
- Size: 74.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e58938feb9eb1fd80685b38cf56b5cb3d092ad5801c2edf8b442eae210e3242d
|
|
| MD5 |
62d8914f5665fccf1498bddfc770d6cb
|
|
| BLAKE2b-256 |
9ec87648735b8022e9d363ed27e58022c80877e42ddccf20d63bbcf62e219d95
|
Provenance
The following attestation bundles were made for pymusas-0.4.0-py3-none-any.whl:
Publisher:
publish.yml on UCREL/pymusas
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pymusas-0.4.0-py3-none-any.whl -
Subject digest:
e58938feb9eb1fd80685b38cf56b5cb3d092ad5801c2edf8b442eae210e3242d - Sigstore transparency entry: 763934484
- Sigstore integration time:
-
Permalink:
UCREL/pymusas@a581ff6c9be415817cb6ee0da01571bcea9567c7 -
Branch / Tag:
refs/tags/v0.4.0 - Owner: https://github.com/UCREL
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@a581ff6c9be415817cb6ee0da01571bcea9567c7 -
Trigger Event:
release
-
Statement type: