Morphy
Morphy is a Python library for morphological analysis. Presents a set of simple interfaces for segmentation,
tokenization, lemmatization, and text filtering. Based on nltk, spacy and pymorphy2.
Features
- Fully supported multilanguage support (English, German, Spanish, Portuguese, French, Italian, Dutch, Russian)
- Part-of-speech tagging
- Sentence segmentation
- Named entity recognition
- Dependency parsing
- Flexible customizability
- Caching
Usage
Language detection
from morphy import Language
text = 'Lorem Ipsum is simply dummy text of the printing and typesetting industry'
lang = Language(text=text)
print(lang)
Sentence segmentation
from morphy import MultiLang
text = 'Lorem Ipsum is simply dummy text of the printing and typesetting industry'
english_proc = MultiLang(lang='en')
doc = english_proc(text)
for sent in doc.sentences:
print('%s\n%s' % (sent, '\n'.join(str(sent.tokens))))
Lemmatization
from morphy import MultiLang
text = 'Lorem Ipsum is simply dummy text of the printing and typesetting industry'
english_proc = MultiLang(lang='en')
doc = english_proc(text)
for token in doc.tokens:
print('%s --> %s' % (token.text, token.lemma))
Installation
Option 1: Via PyPi
Using pip, morphy releases are available as source packages and binary wheels (as of v0.1.0).
pip install morphy
When using pip it is generally recommended to install packages in a virtual environment to avoid modifying system state:
python -m virtualenv venv
source venv/bin/activate
pip install morphy
Option 2: Source Via Git
git clone git@bitbucket.org:igor_ezersky/morphy.git
cd morphy
python -m virtualenv venv
source venv/bin/activate
python setup.py install
Option 3: Source Zip
Download a zip of the code via GitHub or PyPi. Then follow the same instructions in option 2.
IMPORTANT
After package was installed, it is necessary to download nltk and spacy data.
python -c "import nltk; nltk.download('punkt')"
python -m spacy download en
python -m spacy download xx
# the line above should be repeated for each language that you need
You can specify which spacy model would you like to install, check their documentation.
Requirements
- Python 3.3+
spacynltkcached_propertylangdetect
Notes
If you are using Windows there can be some errors while installing morphy requirements (e.g. ujson, cytoolz):
error: command 'cl.exe' failed: No such file or directory
Manual installation from compiled binaries of this two packages can be a solution. You can find them at this unofficial Python distributive repo.
Current limitations
- Installing
spacymodels for each language is required. - Downloading
nltktokenizer data is required.
Metadata
Release files for morphy 0.2
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 | |
|---|---|---|---|---|
| morphy-0.2.tar.gz | 9.3 kB | Without provenance | Details |
Release files / morphy-0.2.tar.gz
| Download URL | morphy-0.2.tar.gz |
|---|---|
| Size | 9.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0bd8a29aaf6153058caaac487c06afdcd13f9c46d968a2f61a97fdc0ce6dfdc7
|
|
BLAKE2b-256 checksum How to use checksums |
eb4be3dee0696eef3bac39eb6aeb0e50b41cbcf9e50dd4b9fb1961a1fae71c9e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.7.2rc1
|
Security for morphy 0.2
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.