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
- X
- VERB
- NOUN
- ADJ
- ADP
- PUNCT
- NUM
- None
- PRON
- SCONJ
- CCONJ
- DET
- PART
- ADV
- SYM
- AUX
- PROPN
- INTJ
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")
tokenizer = Tokenizer() \
.setInputCols("sentence") \
.setOutputCol("token")
pos_tagger = PerceptronModel.pretrained("pos_ud_padt", "ar") \
.setInputCols(["sentence", "token"]) \
.setOutputCol("pos")
pipeline = Pipeline(stages=[
document_assembler,
sentence_detector,
tokenizer,
pos_tagger
])
example = spark.createDataFrame([['مرحبا من جون سنو مختبرات! ']], ["text"])
result = pipeline.fit(example).transform(example)
val documentAssembler = DocumentAssembler()
.setInputCol("text")
.setOutputCol("document")
val sentenceDetector = SentenceDetector()
.setInputCols("document")
.setOutputCol("sentence")
val tokenizer = new Tokenizer()
.setInputCols("sentence")
.setOutputCol("token")
val posTagger = PerceptronModel.pretrained("pos_ud_padt", "ar")
.setInputCols("sentence", "token")
.setOutputCol("pos")
val pipeline = new Pipeline().setStages(Array(documentAssembler, sentenceDetector, tokenizer, posTagger))
val data = Seq("مرحبا من جون سنو مختبرات! ").toDF("text")
val result = pipeline.fit(data).transform(data)
import nlu
text = [""مرحبا من جون سنو مختبرات! ""]
token_df = nlu.load('ar.pos').predict(text)
token_df
Results
token pos
0 مرحبا NOUN
1 من ADP
2 جون X
3 سنو X
4 مختبرات NOUN
5 ! PUNCT
Model Information
Model Name: | pos_ud_padt |
Compatibility: | Spark NLP 3.0.0+ |
License: | Open Source |
Edition: | Official |
Input Labels: | [document, token] |
Output Labels: | [pos] |
Language: | ar |