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_bosque", "pt") \
.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("Além de ser o rei do norte, John Snow é um médico inglês e líder no desenvolvimento de anestesia e higiene médica.")
...
val pos = PerceptronModel.pretrained("pos_ud_bosque", "pt")
.setInputCols(Array("document", "token"))
.setOutputCol("pos")
val pipeline = new Pipeline().setStages(Array(document_assembler, sentence_detector, tokenizer, pos))
val data = Seq("Annet enn å være kongen i nord, er John Snow en engelsk lege og en leder innen utvikling av anestesi og medisinsk hygiene.").toDF("text")
val result = pipeline.fit(data).transform(data)
import nlu
text = ["""Além de ser o rei do norte, John Snow é um médico inglês e líder no desenvolvimento de anestesia e higiene médica."""]
pos_df = nlu.load('pt.pos.ud_bosque').predict(text, output_level='token')
pos_df
Results
[Row(annotatorType='pos', begin=0, end=3, result='ADV', metadata={'word': 'Além'}),
Row(annotatorType='pos', begin=5, end=6, result='ADP', metadata={'word': 'de'}),
Row(annotatorType='pos', begin=8, end=10, result='AUX', metadata={'word': 'ser'}),
Row(annotatorType='pos', begin=12, end=12, result='DET', metadata={'word': 'o'}),
Row(annotatorType='pos', begin=14, end=16, result='NOUN', metadata={'word': 'rei'}),
...]
Model Information
Model Name: | pos_ud_bosque |
Type: | pos |
Compatibility: | Spark NLP 2.5.0+ |
Edition: | Official |
Input labels: | [token] |
Output labels: | [pos] |
Language: | pt |
Case sensitive: | false |
License: | Open Source |
Data Source
The model is imported from https://universaldependencies.org
PREVIOUSPortuguese Lemmatizer