This commit is contained in:
pepaskopec-blip 2026-09-11 21:04:12 +02:00
commit 1583c8b5de
2 changed files with 109 additions and 68 deletions

View file

@ -986,15 +986,18 @@ const TypedQ trans_p10[] = {
{"der Abend, -e", "večer|evening", "večer"}, {"der Abend, -e", "večer|evening", "večer"},
{"Guten Abend!", "dobrý večer|good evening", "Dobrý večer!"}, {"Guten Abend!", "dobrý večer|good evening", "Dobrý večer!"},
{"du", "ty|you", "ty"}, {"du", "ty|you", "ty"},
{"(Es) freut mich.", "těší mě|nice to meet you", "Těší mě."}, {"(Es) freut mich.", "těší mě|nice to meet you|pleased to meet you",
{"gut", "dobrý|good", "dobrý"}, "Těší mě."},
{"gut", "dobrý|dobře|good", "dobrý"},
{"Hallo!", "ahoj|hello", "Ahoj!"}, {"Hallo!", "ahoj|hello", "Ahoj!"},
{"heißen, er heißt", "jmenovat se|to be called|to be named", "jmenovat se"}, {"heißen, er heißt",
{"Ich heiße Jens.", "jmenuji se jens|my name is jens", "Jmenuji se Jens."}, "jmenovat se|jmenuje se|to be called|to be named", "jmenovat se"},
{"Hi!", "ahoj|hi", "Ahoj! (neformálně)"}, {"Ich heiße Jens.",
"jmenuji se jens|jmenuju se jens|my name is jens", "Jmenuji se Jens."},
{"Hi!", "ahoj|čau|hi", "Ahoj! (neformálně)"},
{"ich", "já|i", "já"}, {"ich", "já|i", "já"},
{"ihr", "vy|you", "vy"}, {"ihr", "vy|you", "vy"},
{"ja", "ano|yes", "ano"}, {"ja", "ano|jo|yes", "ano"},
{"der Morgen", "ráno|morning", "ráno"}, {"der Morgen", "ráno|morning", "ráno"},
{"Guten Morgen!", "dobré ráno|good morning", "Dobré ráno!"}, {"Guten Morgen!", "dobré ráno|good morning", "Dobré ráno!"},
{"der Name, -n", "jméno|name", "jméno"}, {"der Name, -n", "jméno|name", "jméno"},
@ -1004,23 +1007,28 @@ const TypedQ trans_p10[] = {
{"Guten Tag!", "dobrý den|good day", "Dobrý den!"}, {"Guten Tag!", "dobrý den|good day", "Dobrý den!"},
{"und", "a|and", "a"}, {"und", "a|and", "a"},
{"wer", "kdo|who", "kdo"}, {"wer", "kdo|who", "kdo"},
{"Wer bist du?", "kdo jsi|who are you", "Kdo jsi?"}, {"Wer bist du?", "kdo jsi|kdo jste|who are you", "Kdo jsi?"},
{"wie", "jak|how", "jak"}, {"wie", "jak|how", "jak"},
{"Wie heißt du?", "jak se jmenuješ|what is your name", "Jak se jmenuješ?"}, {"Wie heißt du?",
"jak se jmenuješ|jak se jmenujete|what is your name|what's your name",
"Jak se jmenuješ?"},
{"wir", "my|we", "my"}, {"wir", "my|we", "my"},
}; };
const TypedQ trans_p11[] = { const TypedQ trans_p11[] = {
{"in", "v|in", "v"}, {"in", "v|ve|in", "v"},
{"in der Nähe (von)", "poblíž|v blízkosti|near|nearby", "poblíž, v blízkosti"}, {"in der Nähe (von)",
"poblíž|v blízkosti|nedaleko|blízko|near|nearby|close to",
"poblíž, v blízkosti"},
{"das Spiel, -e", "hra|game", "hra"}, {"das Spiel, -e", "hra|game", "hra"},
{"wo", "kde|where", "kde"}, {"wo", "kde|where", "kde"},
{"wohnen, er wohnt", "bydlet|to live", "bydlet"}, {"wohnen, er wohnt", "bydlet|bydlí|to live", "bydlet"},
{"Wo wohnst du?", "kde bydlíš|where do you live", "Kde bydlíš?"}, {"Wo wohnst du?",
"kde bydlíš|kde bydlíte|where do you live", "Kde bydlíš?"},
{"Ich wohne in Prag.", "bydlím v praze|i live in prague", "Bydlím v Praze."}, {"Ich wohne in Prag.", "bydlím v praze|i live in prague", "Bydlím v Praze."},
{"null", "nula|zero", "nula"}, {"null", "nula|zero", "nula"},
{"eins", "jedna|one", "jedna"}, {"eins", "jedna|jeden|one", "jedna"},
{"zwei", "dvě|two", "dvě"}, {"zwei", "dvě|dva|two", "dvě"},
{"drei", "tři|three", "tři"}, {"drei", "tři|three", "tři"},
{"vier", "čtyři|four", "čtyři"}, {"vier", "čtyři|four", "čtyři"},
{"fünf", "pět|five", "pět"}, {"fünf", "pět|five", "pět"},
@ -1045,99 +1053,107 @@ const TypedQ trans_p12[] = {
{"alt", "starý|old", "starý"}, {"alt", "starý|old", "starý"},
{"er", "on|he", "on"}, {"er", "on|he", "on"},
{"der Monat, -e", "měsíc|month", "měsíc"}, {"der Monat, -e", "měsíc|month", "měsíc"},
{"sie", "ona|she", "ona"}, {"sie (Singular)", "ona|she", "ona"},
{"sie", "oni|they", "oni"}, {"sie (Plural)", "oni|they", "oni"},
}; };
const TypedQ trans_p13[] = { const TypedQ trans_p13[] = {
{"aber", "ale|but", "ale"}, {"aber", "ale|but", "ale"},
{"das Alter", "věk|age", "věk"}, {"das Alter", "věk|age", "věk"},
{"auch", "také|also|too", "také"}, {"auch", "také|taky|also|too", "také"},
{"aus", "z|from", "z"}, {"aus", "z|ze|from", "z"},
{"die Band, -s", "skupina|band", "(hudební) skupina"}, {"die Band, -s", "skupina|kapela|band", "(hudební) skupina"},
{"chatten, er chattet", "chatovat|to chat", "chatovat"}, {"chatten, er chattet", "chatovat|chatuje|to chat", "chatovat"},
{"das Computerspiel, -e", "počítačová hra|computer game", "počítačová hra"}, {"das Computerspiel, -e", "počítačová hra|computer game", "počítačová hra"},
{"die/das E-Mail, -s", "e-mail|email", "e-mail"}, {"die/das E-Mail, -s", "e-mail|email", "e-mail"},
{"das Englisch", "angličtina|anglicky|english", "angličtina, anglicky"}, {"das Englisch", "angličtina|anglicky|english", "angličtina, anglicky"},
{"der Fan, -s", "fanoušek|fan", "fanoušek"}, {"der Fan, -s", "fanoušek|fanda|fan", "fanoušek"},
{"das Französisch", "francouzština|francouzsky|french", {"das Französisch", "francouzština|francouzsky|french",
"francouzština, francouzsky"}, "francouzština, francouzsky"},
{"der Freund, -e", "kamarád|friend", "kamarád"}, {"der Freund, -e", "kamarád|přítel|friend", "kamarád"},
{"die Freundin, -nen", "kamarádka|friend", "kamarádka"}, {"die Freundin, -nen", "kamarádka|přítelkyně|friend", "kamarádka"},
{"beste Freundin", "nejlepší kamarádka|best friend", "nejlepší kamarádka"}, {"beste Freundin", "nejlepší kamarádka|nejlepší přítelkyně|best friend",
{"der Fußball", "fotbal|football", "fotbal"}, "nejlepší kamarádka"},
{"der Fußball", "fotbal|football|soccer", "fotbal"},
{"Er ist Fußballfanatiker.", "je fotbalový fanatik|he is a football fanatic", {"Er ist Fußballfanatiker.", "je fotbalový fanatik|he is a football fanatic",
"Je fotbalový fanatik."}, "Je fotbalový fanatik."},
{"gehen, er geht", "jít|to go", "jít"}, {"gehen, er geht", "jít|jde|chodit|to go", "jít"},
{"Ich gehe gern auf Konzerte.", {"Ich gehe gern auf Konzerte.",
"rád chodím na koncerty|ráda chodím na koncerty|i like going to concerts", "rád chodím na koncerty|ráda chodím na koncerty|i like going to concerts",
"Rád(a) chodím na koncerty."}, "Rád(a) chodím na koncerty."},
{"gern", "rád|ráda|gladly", "rád/a"}, {"gern", "rád|ráda|gladly", "rád/a"},
{"die Gitarre, -n", "kytara|guitar", "kytara"}, {"die Gitarre, -n", "kytara|guitar", "kytara"},
{"das Handy, -s", "mobil|mobile phone", "mobil"}, {"das Handy, -s", "mobil|mobilní telefon|mobile phone", "mobil"},
{"das Hobby, -s", "koníček|hobby", "koníček"}, {"das Hobby, -s", "koníček|hobby", "koníček"},
{"hören, er hört", "poslouchat|to listen", "poslouchat"}, {"hören, er hört", "poslouchat|poslouchá|slyšet|to listen|to hear",
"poslouchat"},
{"Er hört gern Musik.", "rád poslouchá hudbu|he likes listening to music", {"Er hört gern Musik.", "rád poslouchá hudbu|he likes listening to music",
"Rád poslouchá hudbu."}, "Rád poslouchá hudbu."},
{"im Internet surfen, er surft im Internet", {"im Internet surfen, er surft im Internet",
"surfovat na internetu|to surf the internet", "surfovat na internetu"}, "surfovat na internetu|to surf the internet", "surfovat na internetu"},
{"immer", "pořád|neustále|always", "pořád, neustále"}, {"immer", "pořád|neustále|vždy|vždycky|always", "pořád, neustále"},
{"das Jahr, -e", "rok|year", "rok"}, {"das Jahr, -e", "rok|year", "rok"},
{"kein/keine/kein", "žádný|žádná|žádné|no|none", "žádný/žádná/žádné"}, {"kein/keine/kein", "žádný|žádná|žádné|no|none", "žádný/žádná/žádné"},
{"das Klavier, -e", "klavír|piano", "klavír"}, {"das Klavier, -e", "klavír|piano", "klavír"},
{"kommen (aus), er kommt", "přicházet|pocházet|to come|to come from", {"kommen (aus), er kommt",
"přicházet|přijít|přichází|pochází|to come|to come from",
"přicházet, pocházet (z)"}, "přicházet, pocházet (z)"},
{"Er kommt aus Wien.", "pochází z vídně|he comes from vienna", {"Er kommt aus Wien.",
"pochází z vídně|he comes from vienna|he is from vienna",
"Pochází z Vídně."}, "Pochází z Vídně."},
{"das Konzert, -e", "koncert|concert", "koncert"}, {"das Konzert, -e", "koncert|concert", "koncert"},
{"lernen, er lernt", "učit se|to learn", "učit se"}, {"lernen, er lernt", "učit se|učí se|to learn", "učit se"},
{"liegen, er liegt", "ležet|to lie", "ležet"}, {"liegen, er liegt", "ležet|leží|to lie|to be located", "ležet"},
{"der Nachname, -n", "příjmení|surname|last name", "příjmení"}, {"der Nachname, -n", "příjmení|surname|last name", "příjmení"},
{"nicht weit von", "nedaleko od|not far from", "nedaleko od"}, {"nicht weit von", "nedaleko od|not far from", "nedaleko od"},
{"reisen, er reist", "cestovat|to travel", "cestovat"}, {"reisen, er reist", "cestovat|cestuje|to travel", "cestovat"},
{"schreiben, er schreibt", "psát|to write", "psát"}, {"schreiben, er schreibt", "psát|píše|to write", "psát"},
{"die Schule, -n", "škola|school", "škola"}, {"die Schule, -n", "škola|school", "škola"},
{"spielen, er spielt", "hrát|to play", "hrát"}, {"spielen, er spielt", "hrát|hraje|to play", "hrát"},
{"Sie spielt Gitarre.", "hraje na kytaru|she plays the guitar", {"Sie spielt Gitarre.", "hraje na kytaru|she plays the guitar",
"Hraje na kytaru."}, "Hraje na kytaru."},
{"tanzen, er tanzt", "tancovat|to dance", "tancovat"}, {"tanzen, er tanzt", "tancovat|tančí|tancuje|to dance", "tancovat"},
{"der Vorname, -n", "křestní jméno|first name", "křestní jméno"}, {"der Vorname, -n", "křestní jméno|first name", "křestní jméno"},
{"der Wohnort, -e", "bydliště|place of residence", "bydliště"}, {"der Wohnort, -e", "bydliště|místo bydliště|place of residence",
"bydliště"},
}; };
const TypedQ trans_p14[] = { const TypedQ trans_p14[] = {
{"falsch", "nesprávně|chybně|wrong|incorrect", "nesprávně, chybně"}, {"falsch", "nesprávně|chybně|špatně|wrong|incorrect", "nesprávně, chybně"},
{"die Flöte, -n", "flétna|flute", "flétna"}, {"die Flöte, -n", "flétna|flute", "flétna"},
{"haben, er hat", "mít|to have", "mít"}, {"haben, er hat", "mít|má|to have", "mít"},
{"das Instrument, -e", "nástroj|instrument", "(hudební) nástroj"}, {"das Instrument, -e", "nástroj|instrument", "(hudební) nástroj"},
{"jetzt", "teď|now", "teď"}, {"jetzt", "teď|nyní|now", "teď"},
{"machen, er macht", "dělat|to do|to make", "dělat"}, {"machen, er macht", "dělat|dělá|to do|to make", "dělat"},
{"richtig", "správně|correct|right", "správně"}, {"richtig", "správně|správný|correct|right", "správně"},
{"der Sport", "sport", "sport"}, {"der Sport", "sport", "sport"},
{"Sport treiben, er treibt Sport", "sportovat|to do sport", "sportovat"}, {"Sport treiben, er treibt Sport",
"sportovat|sportuje|provozovat sport|to do sport", "sportovat"},
{"das Squash", "squash", "squash"}, {"das Squash", "squash", "squash"},
{"das/der Yoga", "jóga|yoga", "jóga"}, {"das/der Yoga", "jóga|yoga", "jóga"},
}; };
const TypedQ trans_p15[] = { const TypedQ trans_p15[] = {
{"bald", "brzy|soon", "brzy"}, {"bald", "brzy|soon", "brzy"},
{"Bis bald!", "brzy na shledanou|see you soon", "Brzy na shledanou!"}, {"Bis bald!", "brzy na shledanou|brzy se uvidíme|see you soon",
{"bis", "do|until", "do"}, "Brzy na shledanou!"},
{"Bis zum nächsten Mal!", "do příštího setkání|until next time", {"bis", "do|až|until", "do"},
{"Bis zum nächsten Mal!", "do příštího setkání|do příště|until next time",
"Do příštího setkání!"}, "Do příštího setkání!"},
{"die Frau, -en", "paní|woman|mrs", "paní"}, {"die Frau, -en", "paní|žena|woman|mrs", "paní"},
{"der Herr, -en", "pan|man|mr", "pan"}, {"der Herr, -en", "pan|muž|man|mr", "pan"},
{"Mach's gut!", "měj se hezky|take care", "Měj se hezky!"}, {"Mach's gut!", "měj se hezky|měj se|take care", "Měj se hezky!"},
{"das Museum, Museen", "muzeum|museum", "muzeum"}, {"das Museum, Museen", "muzeum|museum", "muzeum"},
{"Sie gehen ins Museum.", "jdou do muzea|they are going to the museum", {"Sie gehen ins Museum.",
"jdou do muzea|they are going to the museum|they go to the museum",
"Jdou do muzea."}, "Jdou do muzea."},
{"schön", "hezký|beautiful|nice", "hezký"}, {"schön", "hezký|krásný|pěkný|beautiful|nice", "hezký"},
{"Einen schönen Tag noch!", "hezký zbytek dne|have a nice day", {"Einen schönen Tag noch!",
"Hezký zbytek dne!"}, "hezký zbytek dne|měj hezký den|have a nice day", "Hezký zbytek dne!"},
{"Servus!", "ahoj|hi", "Ahoj! (servus)"}, {"Servus!", "ahoj|servus|hi", "Ahoj! (servus)"},
{"Tschüs!", "ahoj|bye", "Ahoj! (při loučení)"}, {"Tschüs!", "ahoj|čau|bye", "Ahoj! (při loučení)"},
{"das Wiedersehen", "shledání|reunion", "shledání"}, {"das Wiedersehen", "shledání|reunion", "shledání"},
{"Auf Wiedersehen!", "na shledanou|goodbye", "Na shledanou!"}, {"Auf Wiedersehen!", "na shledanou|na viděnou|goodbye", "Na shledanou!"},
}; };
typedef struct { typedef struct {

47
util.c
View file

@ -5,34 +5,59 @@
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
char *normalize_answer(const char *input) { char *normalize_answer(const char *input) {
GString *pre = g_string_new(NULL);
GString *out = g_string_new(NULL); GString *out = g_string_new(NULL);
const gchar *down = g_utf8_strdown(input, -1); const gchar *down = g_utf8_strdown(input ? input : "", -1);
const gchar *p = down; gchar *decomp;
const gchar *p;
gboolean prev_space = FALSE; gboolean prev_space = FALSE;
while (*p) { /* German special letters first, so ä/ö/ü/ß keep their two-letter
* keyboard fallbacks (ae/oe/ue/ss). */
for (p = down; *p; p = g_utf8_next_char(p)) {
gunichar ch = g_utf8_get_char(p); gunichar ch = g_utf8_get_char(p);
p = g_utf8_next_char(p);
switch (ch) {
case 0x00e4: g_string_append(pre, "ae"); break; /* ä */
case 0x00f6: g_string_append(pre, "oe"); break; /* ö */
case 0x00fc: g_string_append(pre, "ue"); break; /* ü */
case 0x00df: g_string_append(pre, "ss"); break; /* ß */
default: g_string_append_unichar(pre, ch); break;
}
}
/* Decompose and drop combining accent marks so Czech letters such as
* é/ě/ř/ů/ž/š/č are treated as their base letters. */
decomp = g_utf8_normalize(pre->str, -1, G_NORMALIZE_NFD);
if (!decomp)
decomp = g_strdup(pre->str);
for (p = decomp; *p; p = g_utf8_next_char(p)) {
gunichar ch = g_utf8_get_char(p);
if (g_unichar_combining_class(ch) != 0)
continue; /* accent mark */
if (g_unichar_isspace(ch)) { if (g_unichar_isspace(ch)) {
if (out->len > 0 && !prev_space) if (out->len > 0 && !prev_space)
g_string_append_c(out, ' '); g_string_append_c(out, ' ');
prev_space = TRUE; prev_space = TRUE;
continue; continue;
} }
if (!g_unichar_isalnum(ch))
continue; /* ignore punctuation and symbols */
prev_space = FALSE; prev_space = FALSE;
switch (ch) { g_string_append_unichar(out, ch);
case 0x00e4: g_string_append(out, "ae"); break; /* ä */
case 0x00f6: g_string_append(out, "oe"); break; /* ö */
case 0x00fc: g_string_append(out, "ue"); break; /* ü */
case 0x00df: g_string_append(out, "ss"); break; /* ß */
default: g_string_append_unichar(out, ch); break;
}
} }
if (out->len > 0 && out->str[out->len - 1] == ' ') if (out->len > 0 && out->str[out->len - 1] == ' ')
g_string_truncate(out, out->len - 1); g_string_truncate(out, out->len - 1);
g_free(decomp);
g_free((gpointer)down); g_free((gpointer)down);
g_string_free(pre, TRUE);
return g_string_free(out, FALSE); return g_string_free(out, FALSE);
} }