MARu: Morphological Analyzer for Russian
MARu is a morphological analyzer for Russian, written in Python, powered by machine learning and neural networks.
$ pipenv install maru
$ pipenv install maru[gpu]
for installation with Tensorflow GPU support.
You can also just use pip (though you should definitely take a look at pipenv).
What's in the Box?
✨Morphological analysis with contextual disambiguation using Universal Dependencies tags.
🌈Trained via various machine learning methods: linear model, CRF, deep neural network.
🔮Speed/accuracy trade-off between different methods.
🍰Vocabulary-based lemmatization, built on top of pymorphy2.
First, create a maru.analyzer.Analyzer object using the factory method:
>> import maru >> analyzer = maru.get_analyzer(tagger='crf', lemmatizer='pymorphy')
Then, analyze some text:
>> analyzed = analyzer.analyze(['мама', 'мыла', 'раму']) # note that this returns an iterator >> for morph in analyzed: ... print(morph) ... Morph(word='мама', lemma='мама', tag=Tag(pos=NOUN,animacy=Anim,case=Nom,gender=Fem,number=Sing)) Morph(word='мыла', lemma='мыть', tag=Tag(pos=VERB,aspect=Imp,gender=Fem,mood=Ind,number=Sing,tense=Past,verbform=Fin,voice=Act)) Morph(word='раму', lemma='рама', tag=Tag(pos=NOUN,animacy=Inan,case=Acc,gender=Fem,number=Sing))
Other available taggers that you can pass to
Another available lemmatizer is
'dummy' (no actual lemmatization, slightly improves inference speed).
You can refer to the following table when choosing an algorithm to use:
|Full tag accuracy (per token, per sentence) and inference speed|
|Tagger||News (Lenta)||Social (VK)||Literature (JZ)||All||Inference speed|
Accuracy was measured on the MorphoRuEval-2017 test set. Inference speed was estimated on a system with 32 GB RAM, Intel i7 6700K as CPU and GeForce GTX 1060 as GPU. RNN performance is given for single sentence inference on GPU. An addition of batch inference in the future can greatly improve it.