Persian Lemmatizer


This model uses context and language knowledge to assign all forms and inflections of a word to a single root. This enables the pipeline to treat the past and present tense of a verb, for example, as the same word instead of two completely different words. The lemmatizer takes into consideration the context surrounding a word to determine which root is correct when the word form alone is ambiguous.

Open in Colab Download

How to use

Use as part of a pipeline after tokenisation.

lemmatizer = LemmatizerModel.pretrained("lemma", "fa") \
        .setInputCols(["token"]) \

nlp_pipeline = Pipeline(stages=[document_assembler, tokenizer, lemmatizer])
light_pipeline = LightPipeline([['']]).toDF("text")))
results = light_pipeline.fullAnnotate(['فرماندهان	فرماندهی	فرمانده	فرمانده‌ای	فرماندهٔ	فرماند'])
val lemmatizer = LemmatizerModel.pretrained("lemma", "fa")
val pipeline = new Pipeline().setStages(Array(document_assembler, tokenizer, lemmatizer))
val result =["فرماندهان	فرماندهی	فرمانده	فرماندهای	فرماندهٔ	فرماند"].toDS.toDF("text")).transform(data)
import nlu

text = ["""فرماندهان	فرماندهی	فرمانده	فرمانده‌ای	فرماندهٔ	فرماند"""]
lemma_df = nlu.load('fa.lemma').predict(text)


{'lemma': [Annotation(token, 0, 8, فرمانده, {'sentence': '0'}),
   Annotation(token, 10, 17, فرماندهی, {'sentence': '0'}),
   Annotation(token, 19, 25, فرمانده, {'sentence': '0'}),
   Annotation(token, 27, 36, فرمانده, {'sentence': '0'}),
   Annotation(token, 38, 45, فرمانده, {'sentence': '0'}),
   Annotation(token, 47, 52, فرماند, {'sentence': '0'})]}

Model Information

Model Name: lemma
Compatibility: Spark NLP 2.7.0+
Edition: Official
Input Labels: [token]
Output Labels: [lemma]
Language: fa

Data Source

This model is trained on data obtained from