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
- NOUN
- ADP
- VERB
- SCONJ
- AUX
- PUNCT
- PART
- DET
- NUM
- ADV
- PRON
- ADJ
- PROPN
- CCONJ
- SYM
- 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_gsd", "ja") \
.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_gsd", "ja")
.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('ja.pos.ud_gsd').predict(text)
token_df
Results
token pos
0 ジョンス NOUN
1 ノ NOUN
2 ー NOUN
3 ラ NOUN
4 ボ NOUN
5 から ADP
6 こん NOUN
7 に ADP
8 ち NOUN
9 は ADP
10 ! VERB
Model Information
Model Name: | pos_ud_gsd |
Compatibility: | Spark NLP 3.0.0+ |
License: | Open Source |
Edition: | Official |
Input Labels: | [document, token] |
Output Labels: | [pos] |
Language: | ja |