mirror of
https://github.com/explosion/spaCy.git
synced 2024-12-26 01:46:28 +03:00
Update German tokenizer exceptions and tests
This commit is contained in:
parent
d77c2cc8bb
commit
e47eef5e03
|
@ -8,7 +8,7 @@ from ...deprecated import PRON_LEMMA
|
||||||
_exc = {
|
_exc = {
|
||||||
"auf'm": [
|
"auf'm": [
|
||||||
{ORTH: "auf", LEMMA: "auf"},
|
{ORTH: "auf", LEMMA: "auf"},
|
||||||
{ORTH: "'m", LEMMA: "der", NORM: "dem" }],
|
{ORTH: "'m", LEMMA: "der", NORM: "dem"}],
|
||||||
|
|
||||||
"du's": [
|
"du's": [
|
||||||
{ORTH: "du", LEMMA: PRON_LEMMA, TAG: "PPER"},
|
{ORTH: "du", LEMMA: PRON_LEMMA, TAG: "PPER"},
|
||||||
|
@ -53,97 +53,97 @@ _exc = {
|
||||||
|
|
||||||
|
|
||||||
for exc_data in [
|
for exc_data in [
|
||||||
{ORTH: "'S", LEMMA: PRON_LEMMA, TAG: "PPER"},
|
{ORTH: "'S", LEMMA: PRON_LEMMA, NORM: "'s", TAG: "PPER"},
|
||||||
{ORTH: "'s", LEMMA: PRON_LEMMA, TAG: "PPER"},
|
{ORTH: "'s", LEMMA: PRON_LEMMA, NORM: "'s", TAG: "PPER"},
|
||||||
{ORTH: "S'", LEMMA: PRON_LEMMA, TAG: "PPER"},
|
{ORTH: "S'", LEMMA: PRON_LEMMA, NORM: "'s", TAG: "PPER"},
|
||||||
{ORTH: "s'", LEMMA: PRON_LEMMA, TAG: "PPER"},
|
{ORTH: "s'", LEMMA: PRON_LEMMA, NORM: "'s", TAG: "PPER"},
|
||||||
{ORTH: "'n", LEMMA: "ein", NORM: "ein"},
|
{ORTH: "'n", LEMMA: "ein", NORM: "ein"},
|
||||||
{ORTH: "'ne", LEMMA: "eine", NORM: "eine"},
|
{ORTH: "'ne", LEMMA: "eine", NORM: "eine"},
|
||||||
{ORTH: "'nen", LEMMA: "ein", NORM: "einen"},
|
{ORTH: "'nen", LEMMA: "ein", NORM: "einen"},
|
||||||
{ORTH: "'nem", LEMMA: "ein", NORM: "einem"},
|
{ORTH: "'nem", LEMMA: "ein", NORM: "einem"},
|
||||||
{ORTH: "Abb.", LEMMA: "Abbildung"},
|
{ORTH: "Abb.", LEMMA: "Abbildung", NORM: "Abbildung"},
|
||||||
{ORTH: "Abk.", LEMMA: "Abkürzung"},
|
{ORTH: "Abk.", LEMMA: "Abkürzung", NORM: "Abkürzung"},
|
||||||
{ORTH: "Abt.", LEMMA: "Abteilung"},
|
{ORTH: "Abt.", LEMMA: "Abteilung", NORM: "Abteilung"},
|
||||||
{ORTH: "Apr.", LEMMA: "April"},
|
{ORTH: "Apr.", LEMMA: "April", NORM: "April"},
|
||||||
{ORTH: "Aug.", LEMMA: "August"},
|
{ORTH: "Aug.", LEMMA: "August", NORM: "August"},
|
||||||
{ORTH: "Bd.", LEMMA: "Band"},
|
{ORTH: "Bd.", LEMMA: "Band", NORM: "Band"},
|
||||||
{ORTH: "Betr.", LEMMA: "Betreff"},
|
{ORTH: "Betr.", LEMMA: "Betreff", NORM: "Betreff"},
|
||||||
{ORTH: "Bf.", LEMMA: "Bahnhof"},
|
{ORTH: "Bf.", LEMMA: "Bahnhof", NORM: "Bahnhof"},
|
||||||
{ORTH: "Bhf.", LEMMA: "Bahnhof"},
|
{ORTH: "Bhf.", LEMMA: "Bahnhof", NORM: "Bahnhof"},
|
||||||
{ORTH: "Bsp.", LEMMA: "Beispiel"},
|
{ORTH: "Bsp.", LEMMA: "Beispiel", NORM: "Beispiel"},
|
||||||
{ORTH: "Dez.", LEMMA: "Dezember"},
|
{ORTH: "Dez.", LEMMA: "Dezember", NORM: "Dezember"},
|
||||||
{ORTH: "Di.", LEMMA: "Dienstag"},
|
{ORTH: "Di.", LEMMA: "Dienstag", NORM: "Dienstag"},
|
||||||
{ORTH: "Do.", LEMMA: "Donnerstag"},
|
{ORTH: "Do.", LEMMA: "Donnerstag", NORM: "Donnerstag"},
|
||||||
{ORTH: "Fa.", LEMMA: "Firma"},
|
{ORTH: "Fa.", LEMMA: "Firma", NORM: "Firma"},
|
||||||
{ORTH: "Fam.", LEMMA: "Familie"},
|
{ORTH: "Fam.", LEMMA: "Familie", NORM: "Familie"},
|
||||||
{ORTH: "Feb.", LEMMA: "Februar"},
|
{ORTH: "Feb.", LEMMA: "Februar", NORM: "Februar"},
|
||||||
{ORTH: "Fr.", LEMMA: "Frau"},
|
{ORTH: "Fr.", LEMMA: "Frau", NORM: "Frau"},
|
||||||
{ORTH: "Frl.", LEMMA: "Fräulein"},
|
{ORTH: "Frl.", LEMMA: "Fräulein", NORM: "Fräulein"},
|
||||||
{ORTH: "Hbf.", LEMMA: "Hauptbahnhof"},
|
{ORTH: "Hbf.", LEMMA: "Hauptbahnhof", NORM: "Hauptbahnhof"},
|
||||||
{ORTH: "Hr.", LEMMA: "Herr"},
|
{ORTH: "Hr.", LEMMA: "Herr", NORM: "Herr"},
|
||||||
{ORTH: "Hrn.", LEMMA: "Herr"},
|
{ORTH: "Hrn.", LEMMA: "Herr", NORM: "Herrn"},
|
||||||
{ORTH: "Jan.", LEMMA: "Januar"},
|
{ORTH: "Jan.", LEMMA: "Januar", NORM: "Januar"},
|
||||||
{ORTH: "Jh.", LEMMA: "Jahrhundert"},
|
{ORTH: "Jh.", LEMMA: "Jahrhundert", NORM: "Jahrhundert"},
|
||||||
{ORTH: "Jhd.", LEMMA: "Jahrhundert"},
|
{ORTH: "Jhd.", LEMMA: "Jahrhundert", NORM: "Jahrhundert"},
|
||||||
{ORTH: "Jul.", LEMMA: "Juli"},
|
{ORTH: "Jul.", LEMMA: "Juli", NORM: "Juli"},
|
||||||
{ORTH: "Jun.", LEMMA: "Juni"},
|
{ORTH: "Jun.", LEMMA: "Juni", NORM: "Juni"},
|
||||||
{ORTH: "Mi.", LEMMA: "Mittwoch"},
|
{ORTH: "Mi.", LEMMA: "Mittwoch", NORM: "Mittwoch"},
|
||||||
{ORTH: "Mio.", LEMMA: "Million"},
|
{ORTH: "Mio.", LEMMA: "Million", NORM: "Million"},
|
||||||
{ORTH: "Mo.", LEMMA: "Montag"},
|
{ORTH: "Mo.", LEMMA: "Montag", NORM: "Montag"},
|
||||||
{ORTH: "Mrd.", LEMMA: "Milliarde"},
|
{ORTH: "Mrd.", LEMMA: "Milliarde", NORM: "Milliarde"},
|
||||||
{ORTH: "Mrz.", LEMMA: "März"},
|
{ORTH: "Mrz.", LEMMA: "März", NORM: "März"},
|
||||||
{ORTH: "MwSt.", LEMMA: "Mehrwertsteuer"},
|
{ORTH: "MwSt.", LEMMA: "Mehrwertsteuer", NORM: "Mehrwertsteuer"},
|
||||||
{ORTH: "Mär.", LEMMA: "März"},
|
{ORTH: "Mär.", LEMMA: "März", NORM: "März"},
|
||||||
{ORTH: "Nov.", LEMMA: "November"},
|
{ORTH: "Nov.", LEMMA: "November", NORM: "November"},
|
||||||
{ORTH: "Nr.", LEMMA: "Nummer"},
|
{ORTH: "Nr.", LEMMA: "Nummer", NORM: "Nummer"},
|
||||||
{ORTH: "Okt.", LEMMA: "Oktober"},
|
{ORTH: "Okt.", LEMMA: "Oktober", NORM: "Oktober"},
|
||||||
{ORTH: "Orig.", LEMMA: "Original"},
|
{ORTH: "Orig.", LEMMA: "Original", NORM: "Original"},
|
||||||
{ORTH: "Pkt.", LEMMA: "Punkt"},
|
{ORTH: "Pkt.", LEMMA: "Punkt", NORM: "Punkt"},
|
||||||
{ORTH: "Prof.", LEMMA: "Professor"},
|
{ORTH: "Prof.", LEMMA: "Professor", NORM: "Professor"},
|
||||||
{ORTH: "Red.", LEMMA: "Redaktion"},
|
{ORTH: "Red.", LEMMA: "Redaktion", NORM: "Redaktion"},
|
||||||
{ORTH: "Sa.", LEMMA: "Samstag"},
|
{ORTH: "Sa.", LEMMA: "Samstag", NORM: "Samstag"},
|
||||||
{ORTH: "Sep.", LEMMA: "September"},
|
{ORTH: "Sep.", LEMMA: "September", NORM: "September"},
|
||||||
{ORTH: "Sept.", LEMMA: "September"},
|
{ORTH: "Sept.", LEMMA: "September", NORM: "September"},
|
||||||
{ORTH: "So.", LEMMA: "Sonntag"},
|
{ORTH: "So.", LEMMA: "Sonntag", NORM: "Sonntag"},
|
||||||
{ORTH: "Std.", LEMMA: "Stunde"},
|
{ORTH: "Std.", LEMMA: "Stunde", NORM: "Stunde"},
|
||||||
{ORTH: "Str.", LEMMA: "Straße"},
|
{ORTH: "Str.", LEMMA: "Straße", NORM: "Straße"},
|
||||||
{ORTH: "Tel.", LEMMA: "Telefon"},
|
{ORTH: "Tel.", LEMMA: "Telefon", NORM: "Telefon"},
|
||||||
{ORTH: "Tsd.", LEMMA: "Tausend"},
|
{ORTH: "Tsd.", LEMMA: "Tausend", NORM: "Tausend"},
|
||||||
{ORTH: "Univ.", LEMMA: "Universität"},
|
{ORTH: "Univ.", LEMMA: "Universität", NORM: "Universität"},
|
||||||
{ORTH: "abzgl.", LEMMA: "abzüglich"},
|
{ORTH: "abzgl.", LEMMA: "abzüglich", NORM: "abzüglich"},
|
||||||
{ORTH: "allg.", LEMMA: "allgemein"},
|
{ORTH: "allg.", LEMMA: "allgemein", NORM: "allgemein"},
|
||||||
{ORTH: "bspw.", LEMMA: "beispielsweise"},
|
{ORTH: "bspw.", LEMMA: "beispielsweise", NORM: "beispielsweise"},
|
||||||
{ORTH: "bzgl.", LEMMA: "bezüglich"},
|
{ORTH: "bzgl.", LEMMA: "bezüglich", NORM: "bezüglich"},
|
||||||
{ORTH: "bzw.", LEMMA: "beziehungsweise"},
|
{ORTH: "bzw.", LEMMA: "beziehungsweise", NORM: "beziehungsweise"},
|
||||||
{ORTH: "d.h.", LEMMA: "das heißt"},
|
{ORTH: "d.h.", LEMMA: "das heißt"},
|
||||||
{ORTH: "dgl.", LEMMA: "dergleichen"},
|
{ORTH: "dgl.", LEMMA: "dergleichen", NORM: "dergleichen"},
|
||||||
{ORTH: "ebd.", LEMMA: "ebenda"},
|
{ORTH: "ebd.", LEMMA: "ebenda", NORM: "ebenda"},
|
||||||
{ORTH: "eigtl.", LEMMA: "eigentlich"},
|
{ORTH: "eigtl.", LEMMA: "eigentlich", NORM: "eigentlich"},
|
||||||
{ORTH: "engl.", LEMMA: "englisch"},
|
{ORTH: "engl.", LEMMA: "englisch", NORM: "englisch"},
|
||||||
{ORTH: "evtl.", LEMMA: "eventuell"},
|
{ORTH: "evtl.", LEMMA: "eventuell", NORM: "eventuell"},
|
||||||
{ORTH: "frz.", LEMMA: "französisch"},
|
{ORTH: "frz.", LEMMA: "französisch", NORM: "französisch"},
|
||||||
{ORTH: "gegr.", LEMMA: "gegründet"},
|
{ORTH: "gegr.", LEMMA: "gegründet", NORM: "gegründet"},
|
||||||
{ORTH: "ggf.", LEMMA: "gegebenenfalls"},
|
{ORTH: "ggf.", LEMMA: "gegebenenfalls", NORM: "gegebenenfalls"},
|
||||||
{ORTH: "ggfs.", LEMMA: "gegebenenfalls"},
|
{ORTH: "ggfs.", LEMMA: "gegebenenfalls", NORM: "gegebenenfalls"},
|
||||||
{ORTH: "ggü.", LEMMA: "gegenüber"},
|
{ORTH: "ggü.", LEMMA: "gegenüber", NORM: "gegenüber"},
|
||||||
{ORTH: "i.O.", LEMMA: "in Ordnung"},
|
{ORTH: "i.O.", LEMMA: "in Ordnung"},
|
||||||
{ORTH: "i.d.R.", LEMMA: "in der Regel"},
|
{ORTH: "i.d.R.", LEMMA: "in der Regel"},
|
||||||
{ORTH: "incl.", LEMMA: "inklusive"},
|
{ORTH: "incl.", LEMMA: "inklusive", NORM: "inklusive"},
|
||||||
{ORTH: "inkl.", LEMMA: "inklusive"},
|
{ORTH: "inkl.", LEMMA: "inklusive", NORM: "inklusive"},
|
||||||
{ORTH: "insb.", LEMMA: "insbesondere"},
|
{ORTH: "insb.", LEMMA: "insbesondere", NORM: "insbesondere"},
|
||||||
{ORTH: "kath.", LEMMA: "katholisch"},
|
{ORTH: "kath.", LEMMA: "katholisch", NORM: "katholisch"},
|
||||||
{ORTH: "lt.", LEMMA: "laut"},
|
{ORTH: "lt.", LEMMA: "laut", NORM: "laut"},
|
||||||
{ORTH: "max.", LEMMA: "maximal"},
|
{ORTH: "max.", LEMMA: "maximal", NORM: "maximal"},
|
||||||
{ORTH: "min.", LEMMA: "minimal"},
|
{ORTH: "min.", LEMMA: "minimal", NORM: "minimal"},
|
||||||
{ORTH: "mind.", LEMMA: "mindestens"},
|
{ORTH: "mind.", LEMMA: "mindestens", NORM: "mindestens"},
|
||||||
{ORTH: "mtl.", LEMMA: "monatlich"},
|
{ORTH: "mtl.", LEMMA: "monatlich", NORM: "monatlich"},
|
||||||
{ORTH: "n.Chr.", LEMMA: "nach Christus"},
|
{ORTH: "n.Chr.", LEMMA: "nach Christus"},
|
||||||
{ORTH: "orig.", LEMMA: "original"},
|
{ORTH: "orig.", LEMMA: "original", NORM: "original"},
|
||||||
{ORTH: "röm.", LEMMA: "römisch"},
|
{ORTH: "röm.", LEMMA: "römisch", NORM: "römisch"},
|
||||||
{ORTH: "s.o.", LEMMA: "siehe oben"},
|
{ORTH: "s.o.", LEMMA: "siehe oben"},
|
||||||
{ORTH: "sog.", LEMMA: "so genannt"},
|
{ORTH: "sog.", LEMMA: "so genannt"},
|
||||||
{ORTH: "stellv.", LEMMA: "stellvertretend"},
|
{ORTH: "stellv.", LEMMA: "stellvertretend"},
|
||||||
{ORTH: "tägl.", LEMMA: "täglich"},
|
{ORTH: "tägl.", LEMMA: "täglich", NORM: "täglich"},
|
||||||
{ORTH: "u.U.", LEMMA: "unter Umständen"},
|
{ORTH: "u.U.", LEMMA: "unter Umständen"},
|
||||||
{ORTH: "u.s.w.", LEMMA: "und so weiter"},
|
{ORTH: "u.s.w.", LEMMA: "und so weiter"},
|
||||||
{ORTH: "u.v.m.", LEMMA: "und vieles mehr"},
|
{ORTH: "u.v.m.", LEMMA: "und vieles mehr"},
|
||||||
|
@ -153,9 +153,9 @@ for exc_data in [
|
||||||
{ORTH: "v.Chr.", LEMMA: "vor Christus"},
|
{ORTH: "v.Chr.", LEMMA: "vor Christus"},
|
||||||
{ORTH: "v.a.", LEMMA: "vor allem"},
|
{ORTH: "v.a.", LEMMA: "vor allem"},
|
||||||
{ORTH: "v.l.n.r.", LEMMA: "von links nach rechts"},
|
{ORTH: "v.l.n.r.", LEMMA: "von links nach rechts"},
|
||||||
{ORTH: "vgl.", LEMMA: "vergleiche"},
|
{ORTH: "vgl.", LEMMA: "vergleiche", NORM: "vergleiche"},
|
||||||
{ORTH: "vllt.", LEMMA: "vielleicht"},
|
{ORTH: "vllt.", LEMMA: "vielleicht", NORM: "vielleicht"},
|
||||||
{ORTH: "vlt.", LEMMA: "vielleicht"},
|
{ORTH: "vlt.", LEMMA: "vielleicht", NORM: "vielleicht"},
|
||||||
{ORTH: "z.B.", LEMMA: "zum Beispiel"},
|
{ORTH: "z.B.", LEMMA: "zum Beispiel"},
|
||||||
{ORTH: "z.Bsp.", LEMMA: "zum Beispiel"},
|
{ORTH: "z.Bsp.", LEMMA: "zum Beispiel"},
|
||||||
{ORTH: "z.T.", LEMMA: "zum Teil"},
|
{ORTH: "z.T.", LEMMA: "zum Teil"},
|
||||||
|
@ -163,7 +163,7 @@ for exc_data in [
|
||||||
{ORTH: "z.Zt.", LEMMA: "zur Zeit"},
|
{ORTH: "z.Zt.", LEMMA: "zur Zeit"},
|
||||||
{ORTH: "z.b.", LEMMA: "zum Beispiel"},
|
{ORTH: "z.b.", LEMMA: "zum Beispiel"},
|
||||||
{ORTH: "zzgl.", LEMMA: "zuzüglich"},
|
{ORTH: "zzgl.", LEMMA: "zuzüglich"},
|
||||||
{ORTH: "österr.", LEMMA: "österreichisch"}]:
|
{ORTH: "österr.", LEMMA: "österreichisch", NORM: "österreichisch"}]:
|
||||||
_exc[exc_data[ORTH]] = [dict(exc_data)]
|
_exc[exc_data[ORTH]] = [dict(exc_data)]
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -8,20 +8,33 @@ import pytest
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('text', ["auf'm", "du's", "über'm", "wir's"])
|
@pytest.mark.parametrize('text', ["auf'm", "du's", "über'm", "wir's"])
|
||||||
def test_tokenizer_splits_contractions(de_tokenizer, text):
|
def test_de_tokenizer_splits_contractions(de_tokenizer, text):
|
||||||
tokens = de_tokenizer(text)
|
tokens = de_tokenizer(text)
|
||||||
assert len(tokens) == 2
|
assert len(tokens) == 2
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('text', ["z.B.", "d.h.", "Jan.", "Dez.", "Chr."])
|
@pytest.mark.parametrize('text', ["z.B.", "d.h.", "Jan.", "Dez.", "Chr."])
|
||||||
def test_tokenizer_handles_abbr(de_tokenizer, text):
|
def test_de_tokenizer_handles_abbr(de_tokenizer, text):
|
||||||
tokens = de_tokenizer(text)
|
tokens = de_tokenizer(text)
|
||||||
assert len(tokens) == 1
|
assert len(tokens) == 1
|
||||||
|
|
||||||
|
|
||||||
def test_tokenizer_handles_exc_in_text(de_tokenizer):
|
def test_de_tokenizer_handles_exc_in_text(de_tokenizer):
|
||||||
text = "Ich bin z.Zt. im Urlaub."
|
text = "Ich bin z.Zt. im Urlaub."
|
||||||
tokens = de_tokenizer(text)
|
tokens = de_tokenizer(text)
|
||||||
assert len(tokens) == 6
|
assert len(tokens) == 6
|
||||||
assert tokens[2].text == "z.Zt."
|
assert tokens[2].text == "z.Zt."
|
||||||
assert tokens[2].lemma_ == "zur Zeit"
|
assert tokens[2].lemma_ == "zur Zeit"
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize('text,norms', [("vor'm", ["vor", "dem"]), ("du's", ["du", "es"])])
|
||||||
|
def test_de_tokenizer_norm_exceptions(de_tokenizer, text, norms):
|
||||||
|
tokens = de_tokenizer(text)
|
||||||
|
assert [token.norm_ for token in tokens] == norms
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.xfail
|
||||||
|
@pytest.mark.parametrize('text,norm', [("daß", "dass")])
|
||||||
|
def test_de_lex_attrs_norm_exceptions(de_tokenizer, text, norm):
|
||||||
|
tokens = de_tokenizer(text)
|
||||||
|
assert tokens[0].norm_ == norm
|
||||||
|
|
Loading…
Reference in New Issue
Block a user