Lemmatizer (Romania, SpacyLookup)

Description

This Romania Lemmatizer is an scalable, production-ready version of the Rule-based Lemmatizer available in Spacy Lookups Data repository.

Download

How to use

documentAssembler = DocumentAssembler() \
    .setInputCol("text") \
    .setOutputCol("document")

tokenizer = Tokenizer() \
    .setInputCols(["document"]) \
    .setOutputCol("token")

lemmatizer = LemmatizerModel.pretrained("lemma_spacylookup","ro") \
    .setInputCols(["token"]) \
    .setOutputCol("lemma")

pipeline = Pipeline(stages=[documentAssembler, tokenizer, lemmatizer]) 

example = spark.createDataFrame([["Nu ești mai bun decât mine"]], ["text"]) 

results = pipeline.fit(example).transform(example)
val documentAssembler = new DocumentAssembler() 
            .setInputCol("text") 
            .setOutputCol("document")

val tokenizer = new Tokenizer() 
    .setInputCols(Array("document")) 
    .setOutputCol("token")

val lemmatizer = LemmatizerModel.pretrained("lemma_spacylookup","ro") 
    .setInputCols(Array("token")) 
    .setOutputCol("lemma")

val pipeline = new Pipeline().setStages(Array(documentAssembler, tokenizer, lemmatizer))
val data = Seq("Nu ești mai bun decât mine").toDF("text")
val results = pipeline.fit(data).transform(data)
import nlu
nlu.load("ro.lemma").predict("""Nu ești mai bun decât mine""")

Results

+-------------------------------+
|result                         |
+-------------------------------+
|[Nu, fi, mai, bun, decât, mină]|
+-------------------------------+

Model Information

Model Name: lemma_spacylookup
Compatibility: Spark NLP 3.4.1+
License: Open Source
Edition: Official
Input Labels: [token]
Output Labels: [lemma]
Language: ro
Size: 3.4 MB