Closed ManfredBernhard closed 5 years ago
This is a limitation in the underlying spaCy language model for German (see https://spacy.io/models/de). While spacyr can identify the proper names, it wrongly tags Mädchen Gretel as a location. The model also warns that lemmatization may not work correctly, although it's also possible that it will not lemmatize named entities.
So: I am afraid that this is not something we would fix in spacyr, although you could contact the authors of spaCy. The spaCy team is based in Berlin and @ines is German, so they are likely to understand these issues with the German language model very well.
library("spacyr")
txt <- "Vor einem großen Walde wohnte ein armer Holzhacker mit seiner Frau und seinen zwei Kindern;
das Bübchen hieß Hänsel und das Mädchen Gretel. Er hatte wenig zu beißen und zu brechen,
und einmal, als große Teuerung ins Land kam, konnte er das tägliche Brot nicht mehr schaffen."
spacy_initialize(model = "de")
## Found 'spacy_condaenv'. spacyr will use this environment
## successfully initialized (spaCy Version: 2.0.18, language model: de)
## (python options: type = "condaenv", value = "spacy_condaenv")
sp <- spacy_parse(txt, tag = TRUE, pos = TRUE)
## Warning in spacy_parse.character(txt, tag = TRUE, pos = TRUE):
## lemmatization may not work properly in model 'de'
entity_consolidate(sp)
## doc_id sentence_id token_id token lemma pos
## 1 text1 1 1 Vor Vor ADP
## 2 text1 1 2 einem einer DET
## 3 text1 1 3 großen groß ADJ
## 4 text1 1 4 Walde Wald NOUN
## 5 text1 1 5 wohnte wohnen VERB
## 6 text1 1 6 ein einen DET
## 7 text1 1 7 armer arm ADJ
## 8 text1 1 8 Holzhacker Holzhacker NOUN
## 9 text1 1 9 mit mit ADP
## 10 text1 1 10 seiner sich DET
## 11 text1 1 11 Frau Frau NOUN
## 12 text1 1 12 und und CONJ
## 13 text1 1 13 seinen seinen DET
## 14 text1 1 14 zwei zwei NUM
## 15 text1 1 15 Kindern Kind NOUN
## 16 text1 1 16 ; ; PUNCT
## 17 text1 1 17 \n \n SPACE
## 18 text1 2 1 das der DET
## 19 text1 2 2 Bübchen Bübchen NOUN
## 20 text1 2 3 hieß heißen VERB
## 21 text1 2 4 Hänsel Hänsel ENTITY
## 22 text1 2 5 und und CONJ
## 23 text1 2 6 das der DET
## 24 text1 2 7 Mädchen_Gretel Mädchen_Gretel ENTITY
## 25 text1 2 8 . . PUNCT
## 26 text1 3 1 Er ich PRON
## 27 text1 3 2 hatte haben AUX
## 28 text1 3 3 wenig wenig PRON
## 29 text1 3 4 zu zu PART
## 30 text1 3 5 beißen beißen VERB
## 31 text1 3 6 und und CONJ
## 32 text1 3 7 zu zu PART
## 33 text1 3 8 brechen brechen VERB
## 34 text1 3 9 , , PUNCT
## 35 text1 3 10 \n \n SPACE
## 36 text1 3 11 und und CONJ
## 37 text1 3 12 einmal einmal ADV
## 38 text1 3 13 , , PUNCT
## 39 text1 3 14 als als ADP
## 40 text1 3 15 große groß ADJ
## 41 text1 3 16 Teuerung Teuerung NOUN
## 42 text1 3 17 ins ins ADP
## 43 text1 3 18 Land Land NOUN
## 44 text1 3 19 kam kommen VERB
## 45 text1 3 20 , , PUNCT
## 46 text1 3 21 konnte können VERB
## 47 text1 3 22 er ich PRON
## 48 text1 3 23 das der DET
## 49 text1 3 24 tägliche tägliche ADJ
## 50 text1 3 25 Brot Brot NOUN
## 51 text1 3 26 nicht nicht PART
## 52 text1 3 27 mehr mehr ADV
## 53 text1 3 28 schaffen schaffen VERB
## 54 text1 3 29 . . PUNCT
## tag entity_type
## 1 APPR
## 2 ART
## 3 ADJA
## 4 NN
## 5 VVFIN
## 6 ART
## 7 ADJA
## 8 NN
## 9 APPR
## 10 PPOSAT
## 11 NN
## 12 KON
## 13 PPOSAT
## 14 CARD
## 15 NN
## 16 $.
## 17 _SP
## 18 ART
## 19 NN
## 20 VVFIN
## 21 ENTITY PER
## 22 KON
## 23 ART
## 24 ENTITY LOC
## 25 $.
## 26 PPER
## 27 VAFIN
## 28 PIS
## 29 PTKZU
## 30 VVINF
## 31 KON
## 32 PTKZU
## 33 VVINF
## 34 $,
## 35 _SP
## 36 KON
## 37 ADV
## 38 $,
## 39 APPR
## 40 ADJA
## 41 NN
## 42 APPRART
## 43 NN
## 44 VVFIN
## 45 $,
## 46 VMFIN
## 47 PPER
## 48 ART
## 49 ADJA
## 50 NN
## 51 PTKNEG
## 52 ADV
## 53 VVINF
## 54 $.
Dear Ken, thank you very much for the comment and the explanation of the problem. As suggested, I'll contact the providers of the spacyr-package. Best, ManfredBernhard
Question: What is the most efficient and economic way to correct this problem either inside or outside R/spacyr. It is clear to me that taggers are not foolproof and that we therefore need a good strategy to correct the mistakes. Also: Lemmatization has several mistakes, e.g. token: das Mädchen, and lemma "der Mädchen" (=genitive and dative plural). Best, ManfredBernhard