Part of Speech for Bulgarian

Description

This model annotates the part of speech of tokens in a text. The parts of speech annotated include PRON (pronoun), CCONJ (coordinating conjunction), and 15 others. The part of speech model is useful for extracting the grammatical structure of a piece of text automatically.

Open in Colab Download Copy S3 URI

How to use

...
pos = PerceptronModel.pretrained("pos_ud_btb", "bg") \
.setInputCols(["document", "token"]) \
.setOutputCol("pos")
nlp_pipeline = Pipeline(stages=[document_assembler, sentence_detector, tokenizer, pos])
light_pipeline = LightPipeline(nlp_pipeline.fit(spark.createDataFrame([['']]).toDF("text")))
results = light_pipeline.fullAnnotate("Освен че е крал на север, Джон Сноу е английски лекар и лидер в развитието на анестезия и медицинска хигиена.")
...
val pos = PerceptronModel.pretrained("pos_ud_btb", "bg")
.setInputCols(Array("document", "token"))
.setOutputCol("pos")
val pipeline = new Pipeline().setStages(Array(document_assembler, sentence_detector, tokenizer, pos))
val data = Seq("Освен че е крал на север, Джон Сноу е английски лекар и лидер в развитието на анестезия и медицинска хигиена.").toDF("text")
val result = pipeline.fit(data).transform(data)
import nlu

text = ["""Освен че е крал на север, Джон Сноу е английски лекар и лидер в развитието на анестезия и медицинска хигиена."""]
pos_df = nlu.load('bg.pos.ud_btb').predict(text, output_level='token')
pos_df

Results

[Row(annotatorType='pos', begin=0, end=4, result='ADP', metadata={'word': 'Освен'}),
Row(annotatorType='pos', begin=6, end=7, result='SCONJ', metadata={'word': 'че'}),
Row(annotatorType='pos', begin=9, end=9, result='AUX', metadata={'word': 'е'}),
Row(annotatorType='pos', begin=11, end=14, result='VERB', metadata={'word': 'крал'}),
Row(annotatorType='pos', begin=16, end=17, result='ADP', metadata={'word': 'на'}),
...]

Model Information

Model Name: pos_ud_btb
Type: pos
Compatibility: Spark NLP 2.5.0+
Edition: Official
Input labels: [token]
Output labels: [pos]
Language: bg
Case sensitive: false
License: Open Source

Data Source

The model is imported from https://universaldependencies.org