Part of Speech for Danish

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_ddt", "da") \
.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("John Snow er bortset fra at være kongen i nord, en engelsk læge og en leder inden for udvikling af anæstesi og medicinsk hygiejne.")
...
val pos = PerceptronModel.pretrained("pos_ud_ddt", "da")
.setInputCols(Array("document", "token"))
.setOutputCol("pos")
val pipeline = new Pipeline().setStages(Array(document_assembler, sentence_detector, tokenizer, pos))
val data = Seq("John Snow er bortset fra at være kongen i nord, en engelsk læge og en leder inden for udvikling af anæstesi og medicinsk hygiejne.").toDF("text")
val result = pipeline.fit(data).transform(data)
import nlu

text = ["""John Snow er bortset fra at være kongen i nord, en engelsk læge og en leder inden for udvikling af anæstesi og medicinsk hygiejne."""]
pos_df = nlu.load('da.pos').predict(text, output_level='token')
pos_df

Results

[Row(annotatorType='pos', begin=0, end=3, result='PROPN', metadata={'word': 'John'}),
Row(annotatorType='pos', begin=5, end=8, result='PROPN', metadata={'word': 'Snow'}),
Row(annotatorType='pos', begin=10, end=11, result='AUX', metadata={'word': 'er'}),
Row(annotatorType='pos', begin=13, end=19, result='VERB', metadata={'word': 'bortset'}),
Row(annotatorType='pos', begin=21, end=23, result='ADP', metadata={'word': 'fra'}),
...]

Model Information

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

Data Source

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