spaCy icon indicating copy to clipboard operation
spaCy copied to clipboard

German part-of-speech tagging

Open hermes-z opened this issue 7 years ago • 4 comments

Hi, I am encountering some problems with the German POS tagger. Even though the tokenizer works correctly on \u201e and \u201c, the part-of-speech does not work.

How to reproduce the behaviour

nlp = space.load('de_core_news_md')
text = "\u201eDas ist nicht gut.\u201c"
doc = nlp(text)
for tk in doc:
  print(tk.text, tk.pos_)

In this case, is assigned VERB and \u201c PROPN.

However, the following works as expected:

nlp = space.load('de_core_news_md')
text = "'Das ist nicht gut.'"
doc = nlp(text)
for tk in doc:
  print(tk.text, tk.pos_)

Your Environment

  • Operating System: macOS 10.14.5
  • Python Version Used: 3.6.6
  • spaCy Version Used: 2.1.4
  • Environment Information:

hermes-z avatar Jul 03 '19 14:07 hermes-z

This seems to be simply related to an insufficient training of the model. With "de_core_news_sm" you get "XY" for tag_ and "X" for pos_ of \u201e.

And at least the \u201e is tagged correctly in the following:

import spacy
nlp = spacy.load('de_core_news_sm')

text = "\u201eSollen wir weiter gehen?\u201c"
doc = nlp(text)
for tk in doc:
    print(tk.text, tk.tag_, tk.pos_)

# Output
# „ $( PUNCT
# Sollen VMFIN VERB
# wir PPER PRON
# weiter ADV ADV
# gehen VVINF VERB
# ? $. PUNCT
# “ NE PROPN

With the "de_core_news_md" model however \u201e is tagged as "NOUN" for the second sentence.

BreakBB avatar Jul 04 '19 07:07 BreakBB

Thanks for thew answer. I thought that there was a rule-based system for dealing with quotation marks in spacy, but I guess I was wrong. What is interesting is that even in your example, if you process text2 = "'Sollen wir weiter gehen?'" it gets it right. Maybe a quick-and-solution would be to substitute \u201e and \u201c with '?

hermes-z avatar Jul 04 '19 08:07 hermes-z

Funny enough the "en_core_web_sm" model gets all the punctuation correct.

Maybe a quick-and-solution would be to substitute \u201e and \u201c with '?

Yes, you could easily preprocess your text to replace the quotations marks.

import spacy
nlp = spacy.load('de_core_news_md')

text = "\u201eDas ist nicht gut.\u201c"

text = text .replace("\u201e", "'")
text = text .replace("\u201c", "'")

doc = nlp(text)
for tk in doc:
    print(tk.text, tk.tag_, tk.pos_)

# Output
# ' $( PUNCT
# Das PDS PRON
# ist VAFIN AUX
# nicht PTKNEG PART
# gut ADJD ADJ
# . $. PUNCT
# ' $( PUNCT

BreakBB avatar Jul 04 '19 08:07 BreakBB

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

lock[bot] avatar Aug 03 '19 09:08 lock[bot]