Part of Speech Tagging - French

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
  • NOUN
  • ADJ
  • AUX
  • VERB
  • ADV
  • ADP
  • SCONJ
  • PRON
  • PUNCT
  • PROPN
  • CCONJ
  • NUM
  • SYM
  • X
  • PART
  • INTJ

Live Demo Open in Colab Download

How to use

document_assembler = DocumentAssembler()
  .setInputCol("text")
  .setOutputCol("document")

sentence_detector = SentenceDetector()
  .setInputCols(["document"])
  .setOutputCol("sentence")

pos = PerceptronModel.pretrained("pos_ud_gsd", "fr")
  .setInputCols(["document", "token"])
  .setOutputCol("pos")

pipeline = Pipeline(stages=[
  document_assembler,
  sentence_detector,
  posTagger
])

example = spark.createDataFrame(pd.DataFrame({'text': ["Bonjour de John Snow Labs!"]}))

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", "fr")
        .setInputCols(Array("document", "token"))
        .setOutputCol("pos")

val pipeline = new Pipeline().setStages(Array(document_assembler, sentence_detector, pos))

val result = pipeline.fit(Seq.empty["Bonjour de John Snow Labs! "].toDS.toDF("text")).transform(data)
import nlu
text = ""Bonjour de John Snow Labs! ""
pos_df = nlu.load('pos_ud_gsd').predict(text)

Results

  token_result pos_result
0      Bonjour       INTJ
1           de        ADP
2         John      PROPN
3         Snow      PROPN
4         Labs      PROPN
5            !      PUNCT

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: fr