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_lfg", "pl") \
.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("Oprócz bycia królem północy, John Snow jest angielskim lekarzem i liderem w rozwoju anestezjologii i higieny medycznej.")
...
val pos = PerceptronModel.pretrained("pos_ud_lfg", "pl")
.setInputCols(Array("document", "token"))
.setOutputCol("pos")
val pipeline = new Pipeline().setStages(Array(document_assembler, sentence_detector, tokenizer, pos))
val data = Seq("Oprócz bycia królem północy, John Snow jest angielskim lekarzem i liderem w rozwoju anestezjologii i higieny medycznej.").toDF("text")
val result = pipeline.fit(data).transform(data)
import nlu
text = ["""Oprócz bycia królem północy, John Snow jest angielskim lekarzem i liderem w rozwoju anestezjologii i higieny medycznej."""]
pos_df = nlu.load('pl.pos.ud_lfg').predict(text, output_level='token')
pos_df
Results
[Row(annotatorType='pos', begin=0, end=5, result='ADP', metadata={'word': 'Oprócz'}),
Row(annotatorType='pos', begin=7, end=11, result='NOUN', metadata={'word': 'bycia'}),
Row(annotatorType='pos', begin=13, end=18, result='NOUN', metadata={'word': 'królem'}),
Row(annotatorType='pos', begin=20, end=26, result='NOUN', metadata={'word': 'północy'}),
Row(annotatorType='pos', begin=27, end=27, result='PUNCT', metadata={'word': ','}),
...]
Model Information
Model Name: | pos_ud_lfg |
Type: | pos |
Compatibility: | Spark NLP 2.5.0+ |
Edition: | Official |
Input labels: | [token] |
Output labels: | [pos] |
Language: | pl |
Case sensitive: | false |
License: | Open Source |
Data Source
The model is imported from https://universaldependencies.org
PREVIOUSPolish Lemmatizer
NEXTDutch Lemmatizer