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
- ADP
- ADV
- ADJ
- NOUN
- NUM
- AUX
- PUNCT
- PRON
- VERB
- CCONJ
- PART
- SCONJ
- X
- 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")
pos = PerceptronModel.pretrained("pos_ud_hdtb", "hi") \
.setInputCols(["document", "token"]) \
.setOutputCol("pos")
pipeline = Pipeline(stages=[
document_assembler,
sentence_detector,
posTagger
])
example = spark.createDataFrame([['जॉन स्नो लैब्स से नमस्ते! ']], ["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_hdtb", "hi")
.setInputCols(Array("document", "token"))
.setOutputCol("pos")
val pipeline = new Pipeline().setStages(Array(document_assembler, sentence_detector, pos))
val data = Seq("जॉन स्नो लैब्स से नमस्ते! ").toDF("text")
val result = pipeline.fit(data).transform(data)
import nlu
text = [""जॉन स्नो लैब्स से नमस्ते! ""]
token_df = nlu.load('hi.pos').predict(text)
token_df
Results
token pos
0 जॉन PROPN
1 स्नो PROPN
2 लैब्स PROPN
3 से ADP
4 नमस्ते NOUN
5 ! VERB
Model Information
Model Name: | pos_ud_hdtb |
Compatibility: | Spark NLP 3.0.0+ |
License: | Open Source |
Edition: | Official |
Input Labels: | [document, token] |
Output Labels: | [pos] |
Language: | hi |