Description
A Part of Speech classifier predicts a grammatical label for every token in the input text. Implemented with an averaged perceptron architecture
.
Predicted Entities
- DET
- PROPN
- PRON
- VERB
- NOUN
- ADP
- NUM
- ADV
- PUNCT
- CCONJ
- ADJ
- PART
- AUX
- SCONJ
- INTJ
- SYM
- X
Live Demo Open in Colab Download Copy S3 URI
How to use
document_assembler = DocumentAssembler() \
.setInputCol("text") \
.setOutputCol("document")
sentence_detector = SentenceDetector() \
.setInputCols(["document"]) \
.setOutputCol("sentence")
pos = PerceptronModel.pretrained("pos_ud_rrt", "ro") \
.setInputCols(["document", "token"]) \
.setOutputCol("pos")
pipeline = Pipeline(stages=[
document_assembler,
sentence_detector,
posTagger
])
example = spark.createDataFrame([['Bună ziua de la John Snow Labs! ']], ["text"])
result = pipeline.fit(example).transform(example)
val document_assembler = DocumentAssembler()
.setInputCol("text")
.setOutputCol("document")
val sentence_detector = SentenceDetector()
.setInputCols("document")
.setOutputCol("sentence")
val pos = PerceptronModel.pretrained("pos_ud_rrt", "ro")
.setInputCols(Array("document", "token"))
.setOutputCol("pos")
val pipeline = new Pipeline().setStages(Array(document_assembler, sentence_detector, pos))
val data = Seq("Bună ziua de la John Snow Labs! ").toDF("text")
val result = pipeline.fit(data).transform(data)
import nlu
text = [""Bună ziua de la John Snow Labs! ""]
token_df = nlu.load('ro.pos.ud_rrt').predict(text)
token_df
Results
token pos
0 Bună ADJ
1 ziua NOUN
2 de ADP
3 la ADP
4 John PROPN
5 Snow PROPN
6 Labs PROPN
7 ! PUNCT
Model Information
Model Name: | pos_ud_rrt |
Compatibility: | Spark NLP 3.0.0+ |
License: | Open Source |
Edition: | Official |
Input Labels: | [document, token] |
Output Labels: | [pos] |
Language: | ro |