Description
Pretrained Part of Speech model, adapted from Hugging Face and curated to provide scalability and production-readiness using Spark NLP. uk-morph
is a Ukrainian model orginally trained by ukr-models
.
How to use
documentAssembler = DocumentAssembler() \
.setInputCol("text") \
.setOutputCol("document")
sentenceDetector = SentenceDetectorDLModel.pretrained("sentence_detector_dl", "xx")\
.setInputCols(["document"])\
.setOutputCol("sentence")
tokenizer = Tokenizer() \
.setInputCols("sentence") \
.setOutputCol("token")
tokenClassifier = XlmRoBertaForTokenClassification.pretrained("xlmroberta_pos_uk_morph","uk") \
.setInputCols(["sentence", "token"]) \
.setOutputCol("pos")
pipeline = Pipeline(stages=[documentAssembler, sentenceDetector, tokenizer, tokenClassifier])
data = spark.createDataFrame([["Я люблю Spark NLP"]]).toDF("text")
result = pipeline.fit(data).transform(data)
val documentAssembler = new DocumentAssembler()
.setInputCol("text")
.setOutputCol("document")
val sentenceDetector = SentenceDetectorDLModel.pretrained("sentence_detector_dl", "xx")
.setInputCols(Array("document"))
.setOutputCol("sentence")
val tokenizer = new Tokenizer()
.setInputCols(Array("sentence"))
.setOutputCol("token")
val tokenClassifier = XlmRoBertaForTokenClassification.pretrained("xlmroberta_pos_uk_morph","uk")
.setInputCols(Array("sentence", "token"))
.setOutputCol("pos")
val pipeline = new Pipeline().setStages(Array(documentAssembler,sentenceDetector, tokenizer, tokenClassifier))
val data = Seq("Я люблю Spark NLP").toDF("text")
val result = pipeline.fit(data).transform(data)
Model Information
Model Name: | xlmroberta_pos_uk_morph |
Compatibility: | Spark NLP 3.4.2+ |
License: | Open Source |
Edition: | Official |
Input Labels: | [document, token] |
Output Labels: | [ner] |
Language: | uk |
Size: | 409.7 MB |
Case sensitive: | true |
Max sentence length: | 128 |
References
- https://huggingface.co/ukr-models/uk-morph
- https://pypi.org/project/tokenize_uk/