From 8b36d380b7c93c67c3d78afeca2bdc2ab5c660bf Mon Sep 17 00:00:00 2001 From: asajatovic Date: Sun, 18 Oct 2020 14:33:04 +0200 Subject: [PATCH] Feature/spacy requirements (#29) * Update requirements :pushpin: * Bump version :bookmark: * :art: * Update readme file :memo: * :white_check_mark: --- README.md | 13 +++++-------- requirements.txt | 2 +- setup.py | 2 +- spacy_udpipe/__init__.py | 2 +- spacy_udpipe/utils.py | 2 +- tests/test_spacy_udpipe.py | 2 +- 6 files changed, 10 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 079a958..f93497e 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,8 @@ pip install spacy-udpipe After installation, use `spacy_udpipe.download()` to download the pre-trained model for the desired language. +A full list of pre-trained UDPipe models for supported languages can be found in [`languages.json`](https://github.com/TakeLab/spacy-udpipe/blob/master/spacy_udpipe/languages.json). + ## Usage The loaded UDPipeLanguage class returns a spaCy [`Language` object](https://spacy.io/api/language), i.e., the object you can use to process text and create a [`Doc` object](https://spacy.io/api/doc). @@ -39,7 +41,7 @@ The type of `text` can be one of the following: * presegmented: `List[str]`, * pretokenized: `List[List[str]]`. -#### Loading a custom model +### Loading a custom model The following code snippet demonstrates how to load a custom `UDPipe` model (for the Croatian language): ```python import spacy_udpipe @@ -55,9 +57,6 @@ for token in doc: ``` This can be done for any of the languages supported by spaCy. For an exhaustive list, see [spaCy languages](https://spacy.io/usage/models#languages). -## Authors and acknowledgment -Created by [Antonio Šajatović](http://github.com/asajatovic) during an internship at [Text Analysis and Knowledge Engineering Lab (TakeLab)](http://takelab.fer.hr/). - ## Contributing Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change. @@ -65,15 +64,13 @@ Please make sure to update the tests as appropriate. Tests are run automatically To start the tests locally, first, install the package with `pip install -e .`, then run [`pytest`](https://docs.pytest.org/en/latest/contents.html) in the root source directory. ## License -[MIT](https://choosealicense.com/licenses/mit/) © Text Analysis and Knowledge Engineering Lab (TakeLab) +* Source code: [MIT](https://choosealicense.com/licenses/mit/) © Text Analysis and Knowledge Engineering Lab (TakeLab) +* Available pre-trained models: [CC BY-NC-SA 4.0](https://creativecommons.org/licenses/by-nc-sa/4.0/) ## Project status Maintained by [Text Analysis and Knowledge Engineering Lab (TakeLab)](http://takelab.fer.hr/). ## Notes -* All available pre-trained models are licensed under [CC BY-NC-SA 4.0](https://creativecommons.org/licenses/by-nc-sa/4.0/). - -* A full list of pre-trained models for supported languages is available in [`languages.json`](https://github.com/TakeLab/spacy-udpipe/blob/master/spacy_udpipe/languages.json). * This package exposes a `spacy_languages` entry point in its [`setup.py`](https://github.com/TakeLab/spacy-udpipe/blob/master/setup.py) so full suport for serialization is enabled: ```python diff --git a/requirements.txt b/requirements.txt index 1976972..d811a59 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -spacy>=2.1.0 +spacy>=2.1.0,<3.0.0 ufal.udpipe>=1.2.0 # Development dependencies pytest>=5.0.0 \ No newline at end of file diff --git a/setup.py b/setup.py index 65bb8c5..94a6ff5 100644 --- a/setup.py +++ b/setup.py @@ -54,7 +54,7 @@ def get_version(fname: str) -> str: license="MIT", keywords="nlp udpipe spacy python", packages=setuptools.find_packages(), - install_requires=["spacy>=2.1.0", "ufal.udpipe>=1.2.0"], + install_requires=["spacy>=2.1.0,<3.0.0", "ufal.udpipe>=1.2.0"], python_requires=">=3.6", entry_points=ENTRY_POINTS, tests_require=["pytest>=5.0.0"], diff --git a/spacy_udpipe/__init__.py b/spacy_udpipe/__init__.py index 0db0fa6..dbccc4d 100644 --- a/spacy_udpipe/__init__.py +++ b/spacy_udpipe/__init__.py @@ -1,4 +1,4 @@ -__version__ = "0.3.1" +__version__ = "0.3.2" __all__ = ["UDPipeLanguage", "UDPipeModel", "load", "load_from_path", "download"] diff --git a/spacy_udpipe/utils.py b/spacy_udpipe/utils.py index fa26e2e..6667953 100644 --- a/spacy_udpipe/utils.py +++ b/spacy_udpipe/utils.py @@ -14,7 +14,7 @@ def _check_language(lang: str) -> None: if lang not in LANGUAGES: - raise Exception("'{}' language not available".format(lang)) + raise Exception(f"'{lang}' language not available") def _check_models_dir(lang: str) -> None: diff --git a/tests/test_spacy_udpipe.py b/tests/test_spacy_udpipe.py index f20da18..bf2013b 100644 --- a/tests/test_spacy_udpipe.py +++ b/tests/test_spacy_udpipe.py @@ -7,7 +7,7 @@ EN = "en" RO = "ro" -SPACY_VERSION = "2.2.4" +SPACY_VERSION = "3.0.0" @pytest.fixture