diff --git a/3-tidy-up.js b/3-tidy-up.js index 0bb0d39..5bf57cd 100644 --- a/3-tidy-up.js +++ b/3-tidy-up.js @@ -203,6 +203,33 @@ function handleLine(parsedLine) { } +/** + * @param {Example} example + * @returns {StandardizedExample} + * */ +function standardizeExample(example) { + return { + text: example.text ? example.text.trim() : '', + translation: getTranslationFromExample(example), + }; +} + +/** + * @param {Example} example + * @returns {string} + * */ +function getTranslationFromExample(example) { + if(example.translation) { + return example.translation; + } + switch(targetIso) { + case 'en': + return example.english || example.roman || ''; + default: + return ''; + } +} + /** * @param {TidySense[]} sensesWithoutInflectionGlosses * @returns {GlossTree} @@ -215,14 +242,16 @@ function getGlossTree(sensesWithoutInflectionGlosses) { let { examples = [] } = sense; examples = examples - .filter(({text, english}) => text && (text.length <= 70 || text.length <= 90 && !english)) // Filter out verbose examples + .filter(example => example.text) + .map(example => standardizeExample(example)) + .filter(({text, translation}) => text.length <= 70 || text.length <= 90 && !translation) // Filter out verbose examples .map((example, index) => ({ ...example, originalIndex: index })) // Step 1: Decorate with original index - .sort(({ english: englishA, originalIndex: indexA }, { english: englishB, originalIndex: indexB }) => { - if (englishA && !englishB) return -1; // English items first - if (!englishA && englishB) return 1; // Non-English items last + .sort(({ translation: translationA, originalIndex: indexA }, { translation: translationB, originalIndex: indexB }) => { + if (translationA && !translationB) return -1; // translation items first + if (!translationA && translationB) return 1; // Non-translation items last return indexA - indexB; // Step 2: Stable sort by original index if equal }) - .map(({text, english}) => ({text, english})) // Step 3: Pick only properties that will be used + .map(({text, translation}) => ({text, translation})) // Step 3: Pick only properties that will be used .slice(0, 2); /** @type {GlossTree|GlossBranch} */ diff --git a/4-make-yomitan.js b/4-make-yomitan.js index 1bf212b..a967785 100644 --- a/4-make-yomitan.js +++ b/4-make-yomitan.js @@ -111,11 +111,11 @@ function findModifiedTag(tag){ } /** - * @param {Example[]} examples + * @param {StandardizedExample[]} examples * @returns {import('types').TermBank.StructuredContent[]} */ function getStructuredExamples(examples) { - return examples.map(({text, english}) => { + return examples.map(({text, translation}) => { return { "tag": "div", "data": { @@ -138,7 +138,7 @@ function getStructuredExamples(examples) { "data": { "content": "example-sentence-b" }, - "content": english + "content": translation } ]} } diff --git a/data/test/dict/de/de/term_bank_1.json b/data/test/dict/de/de/term_bank_1.json index 8dc9b81..295d6de 100644 --- a/data/test/dict/de/de/term_bank_1.json +++ b/data/test/dict/de/de/term_bank_1.json @@ -35,7 +35,8 @@ "tag": "div", "data": { "content": "example-sentence-b" - } + }, + "content": "" } ] } diff --git a/data/test/dict/en/en/term_bank_1.json b/data/test/dict/en/en/term_bank_1.json index d689da0..1438980 100644 --- a/data/test/dict/en/en/term_bank_1.json +++ b/data/test/dict/en/en/term_bank_1.json @@ -35,7 +35,8 @@ "tag": "div", "data": { "content": "example-sentence-b" - } + }, + "content": "" } ] } @@ -84,7 +85,8 @@ "tag": "div", "data": { "content": "example-sentence-b" - } + }, + "content": "" } ] } @@ -133,7 +135,8 @@ "tag": "div", "data": { "content": "example-sentence-b" - } + }, + "content": "" } ] } @@ -204,7 +207,8 @@ "tag": "div", "data": { "content": "example-sentence-b" - } + }, + "content": "" } ] } @@ -242,7 +246,8 @@ "tag": "div", "data": { "content": "example-sentence-b" - } + }, + "content": "" } ] } @@ -291,7 +296,8 @@ "tag": "div", "data": { "content": "example-sentence-b" - } + }, + "content": "" } ] } diff --git a/data/test/dict/en/es/tag_bank_1.json b/data/test/dict/en/es/tag_bank_1.json new file mode 100644 index 0000000..0637a08 --- /dev/null +++ b/data/test/dict/en/es/tag_bank_1.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/data/test/dict/en/es/term_bank_1.json b/data/test/dict/en/es/term_bank_1.json new file mode 100644 index 0000000..619aea9 --- /dev/null +++ b/data/test/dict/en/es/term_bank_1.json @@ -0,0 +1,85 @@ +[ + [ + "fast", + "", + "", + "adj", + 0, + [ + { + "type": "structured-content", + "content": [ + { + "tag": "div", + "content": [ + "Rápido, veloz." + ] + } + ] + }, + { + "type": "structured-content", + "content": [ + { + "tag": "div", + "content": [ + "Adelantado.", + { + "tag": "div", + "data": { + "content": "extra-info" + }, + "content": { + "tag": "div", + "data": { + "content": "example-sentence" + }, + "content": [ + { + "tag": "div", + "data": { + "content": "example-sentence-a" + }, + "content": "Your watch is some minutes fast" + }, + { + "tag": "div", + "data": { + "content": "example-sentence-b" + }, + "content": "→ Tu reloj va algunos minutos adelantado." + } + ] + } + } + ] + } + ] + }, + { + "type": "structured-content", + "content": [ + { + "tag": "div", + "content": [ + "Firme, fijo, sólido." + ] + } + ] + }, + { + "type": "structured-content", + "content": [ + { + "tag": "div", + "content": [ + "Cachondo, entregado a los placeres." + ] + } + ] + } + ], + 0, + "" + ] +] \ No newline at end of file diff --git a/data/test/dict/en/es/term_bank_2.json b/data/test/dict/en/es/term_bank_2.json new file mode 100644 index 0000000..8c5e637 --- /dev/null +++ b/data/test/dict/en/es/term_bank_2.json @@ -0,0 +1,19 @@ +[ + [ + "faster fastest", + "", + "non-lemma", + "", + 0, + [ + [ + "fast", + [ + "comparative" + ] + ] + ], + 0, + "" + ] +] \ No newline at end of file diff --git a/data/test/dict/fr/fr/term_bank_1.json b/data/test/dict/fr/fr/term_bank_1.json index c696105..9a532c7 100644 --- a/data/test/dict/fr/fr/term_bank_1.json +++ b/data/test/dict/fr/fr/term_bank_1.json @@ -46,7 +46,8 @@ "tag": "div", "data": { "content": "example-sentence-b" - } + }, + "content": "" } ] } @@ -73,7 +74,8 @@ "tag": "div", "data": { "content": "example-sentence-b" - } + }, + "content": "" } ] } @@ -122,7 +124,8 @@ "tag": "div", "data": { "content": "example-sentence-b" - } + }, + "content": "" } ] } diff --git a/data/test/dict/ja/en/term_bank_1.json b/data/test/dict/ja/en/term_bank_1.json index febd4ba..ccb7f1b 100644 --- a/data/test/dict/ja/en/term_bank_1.json +++ b/data/test/dict/ja/en/term_bank_1.json @@ -257,7 +257,8 @@ "tag": "div", "data": { "content": "example-sentence-b" - } + }, + "content": "" } ] } @@ -579,7 +580,8 @@ "tag": "div", "data": { "content": "example-sentence-b" - } + }, + "content": "" } ] } diff --git a/data/test/ipa/en/es/tag_bank_1.json b/data/test/ipa/en/es/tag_bank_1.json new file mode 100644 index 0000000..0637a08 --- /dev/null +++ b/data/test/ipa/en/es/tag_bank_1.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/data/test/ipa/en/es/term_meta_bank_1.json b/data/test/ipa/en/es/term_meta_bank_1.json new file mode 100644 index 0000000..1f8a864 --- /dev/null +++ b/data/test/ipa/en/es/term_meta_bank_1.json @@ -0,0 +1,19 @@ +[ + [ + "fast", + "ipa", + { + "reading": "fast", + "transcriptions": [ + { + "ipa": "/fɑːst/", + "tags": [] + }, + { + "ipa": "/fæst/", + "tags": [] + } + ] + } + ] +] \ No newline at end of file diff --git a/data/test/kaikki/en-es.json b/data/test/kaikki/en-es.json new file mode 100644 index 0000000..ee70518 --- /dev/null +++ b/data/test/kaikki/en-es.json @@ -0,0 +1 @@ +{"word": "fast", "pos": "adj", "pos_title": "adjetivo", "lang_code": "en", "lang": "Inglés", "senses": [{"glosses": ["Rápido, veloz."], "sense_index": "1"}, {"glosses": ["Adelantado."], "raw_tags": ["en situaciones relacionadas con el tiempo"], "examples": [{"text": "Your watch is some minutes fast", "translation": "→ Tu reloj va algunos minutos adelantado.", "example_templates": [{"name": "ejemplo", "args": {"1": "Your watch is some minutes fast", "trad": "Tu reloj va algunos minutos adelantado."}, "expansion": ":*Ejemplo:\n::Your watch is some minutes fast→ Tu reloj va algunos minutos adelantado."}]}], "sense_index": "2"}, {"glosses": ["Firme, fijo, sólido."], "sense_index": "3"}, {"glosses": ["Cachondo, entregado a los placeres."], "sense_index": "4"}], "categories": ["EN:Adjetivos", "Inglés"], "sounds": [{"ipa": "/fɑːst/", "raw_tags": ["Australia"]}, {"ipa": "/fæst/", "audio": "en-us-fast.ogg", "ogg_url": "https://commons.wikimedia.org/wiki/Special:FilePath/en-us-fast.ogg", "mp3_url": "https://upload.wikimedia.org/wikipedia/commons/transcoded/e/e5/En-us-fast.ogg/En-us-fast.ogg.mp3", "raw_tags": ["Estados Unidos"]}, {"ipa": "/fɑːst/", "raw_tags": ["Nueva Zelanda"]}, {"ipa": "/fɑːst/", "audio": "en-uk-fast.ogg", "ogg_url": "https://commons.wikimedia.org/wiki/Special:FilePath/en-uk-fast.ogg", "mp3_url": "https://upload.wikimedia.org/wikipedia/commons/transcoded/6/6a/En-uk-fast.ogg/En-uk-fast.ogg.mp3", "raw_tags": ["Londres", "Received Pronunciation"]}, {"audio": "LL-Q1860 (eng)-Back ache-fast.wav", "wav_url": "https://commons.wikimedia.org/wiki/Special:FilePath/LL-Q1860 (eng)-Back ache-fast.wav", "ogg_url": "https://upload.wikimedia.org/wikipedia/commons/transcoded/4/4c/LL-Q1860_(eng)-Back_ache-fast.wav/LL-Q1860_(eng)-Back_ache-fast.wav.ogg", "mp3_url": "https://upload.wikimedia.org/wikipedia/commons/transcoded/4/4c/LL-Q1860_(eng)-Back_ache-fast.wav/LL-Q1860_(eng)-Back_ache-fast.wav.mp3", "raw_tags": ["Londres", "Received Pronunciation"]}, {"ipa": "/fæst/", "raw_tags": ["Reino Unido"]}, {"ipa": "/fɑːst/", "raw_tags": ["Sudáfrica"]}], "etymology_text": "Del inglés medio fast, del inglés antiguo fæst.", "etymology_templates": [{"name": "etimología", "args": {"leng": "en", "1": "enm", "2": "fast"}, "expansion": "Del inglés medio fast"}, {"name": "etim", "args": {"leng": "en", "1": "ang", "2": "fæst"}, "expansion": "del inglés antiguo fæst"}], "forms": [{"form": "fast", "tags": ["positive"]}, {"form": "faster fastest", "tags": ["comparative"]}]} diff --git a/data/test/tidy/cs-en-lemmas.json b/data/test/tidy/cs-en-lemmas.json index b3fb7a3..469d24f 100644 --- a/data/test/tidy/cs-en-lemmas.json +++ b/data/test/tidy/cs-en-lemmas.json @@ -28,11 +28,11 @@ [ { "text": "textová zpráva", - "english": "text message" + "translation": "text message" }, { "text": "Chcete nechat zprávu?", - "english": "Would you like to leave a message?" + "translation": "Would you like to leave a message?" } ] ] @@ -55,11 +55,11 @@ [ { "text": "lékařská zpráva", - "english": "medical report" + "translation": "medical report" }, { "text": "podat zprávu", - "english": "to file a report" + "translation": "to file a report" } ] ] @@ -99,7 +99,7 @@ [ { "text": "Zabili ho pro peníze.", - "english": "They killed him for his money." + "translation": "They killed him for his money." } ] ] diff --git a/data/test/tidy/de-de-lemmas.json b/data/test/tidy/de-de-lemmas.json index 9613eef..a770c1d 100644 --- a/data/test/tidy/de-de-lemmas.json +++ b/data/test/tidy/de-de-lemmas.json @@ -31,7 +31,8 @@ "_examples", [ { - "text": "Der Rock ist nicht totzukriegen." + "text": "Der Rock ist nicht totzukriegen.", + "translation": "" } ] ] diff --git a/data/test/tidy/de-en-lemmas.json b/data/test/tidy/de-en-lemmas.json index 1b3869d..5a1044e 100644 --- a/data/test/tidy/de-en-lemmas.json +++ b/data/test/tidy/de-en-lemmas.json @@ -47,11 +47,11 @@ [ { "text": "jemanden gesund pflegen", - "english": "to nurse someone back to health" + "translation": "to nurse someone back to health" }, { "text": "Kranke pflegen", - "english": "to care for the sick" + "translation": "to care for the sick" } ] ] @@ -68,11 +68,11 @@ [ { "text": "sein Äußeres pflegen", - "english": "to take care of one's appearance" + "translation": "to take care of one's appearance" }, { "text": "die Zähne pflegen", - "english": "to take care of (one's) teeth" + "translation": "to take care of (one's) teeth" } ] ], @@ -120,11 +120,11 @@ [ { "text": "Freundschaften pflegen", - "english": "to cultivate friendships" + "translation": "to cultivate friendships" }, { "text": "Beziehungen pflegen", - "english": "to cultivate relationships" + "translation": "to cultivate relationships" } ] ], @@ -138,11 +138,11 @@ [ { "text": "der Liebe pflegen", - "english": "to cultivate/nurture love" + "translation": "to cultivate/nurture love" }, { "text": "der Ruhe pflegen", - "english": "to foster tranquility" + "translation": "to foster tranquility" } ] ] @@ -177,11 +177,11 @@ [ { "text": "Umgang pflegen", - "english": "to regularly be in contact" + "translation": "to regularly be in contact" }, { "text": "Geselligkeit pflegen", - "english": "to socialize regularly (literally, “to regularly engage in gregariousness”)" + "translation": "to socialize regularly (literally, “to regularly engage in gregariousness”)" } ] ] @@ -198,11 +198,11 @@ [ { "text": "Ich pflege zu laufen.", - "english": "I usually walk." + "translation": "I usually walk." }, { "text": "Er pflegte zu reisen.", - "english": "He used to travel." + "translation": "He used to travel." } ] ] @@ -248,7 +248,7 @@ [ { "text": "Fuchs, du hast die Gans gestohlen. Gib sie wieder her!", - "english": "(line from a popular children’s song)" + "translation": "(line from a popular children’s song)" } ] ] @@ -273,7 +273,7 @@ [ { "text": "Er ist ein ganz schöner Fuchs.", - "english": "He is a really handsome fox." + "translation": "He is a really handsome fox." } ] ] @@ -298,7 +298,7 @@ [ { "text": "Unser Paul ist ja ein kleiner Fuchs.", - "english": "Our Paul is a little redhead." + "translation": "Our Paul is a little redhead." } ] ] @@ -361,7 +361,7 @@ [ { "text": "Ich hatte nur vier Trümpfe und darunter beide Füchse.", - "english": "I had only four trumps and among them were both aces of diamonds." + "translation": "I had only four trumps and among them were both aces of diamonds." } ] ] @@ -610,11 +610,11 @@ [ { "text": "Ich fahre von Köln nach Hamburg.", - "english": "I'm travelling from Cologne to Hamburg." + "translation": "I'm travelling from Cologne to Hamburg." }, { "text": "Ich hab’s von meiner Schwester gehört.", - "english": "I heard it from my sister." + "translation": "I heard it from my sister." } ] ] @@ -635,7 +635,7 @@ [ { "text": "das Auto meines Vaters = das Auto von meinem Vater", - "english": "my father’s car / the car of my father" + "translation": "my father’s car / the car of my father" } ] ] @@ -656,7 +656,7 @@ [ { "text": "Das Hotel wird von der Firma bezahlt.", - "english": "The hotel is paid for by the company." + "translation": "The hotel is paid for by the company." } ] ] @@ -677,11 +677,11 @@ [ { "text": "Er hat von seiner Jugend erzählt.", - "english": "He told about his youth." + "translation": "He told about his youth." }, { "text": "Von dem Nomine Substantivo, oder dem Hauptworte.", - "english": "About the substantive noun, or the [alternative term]. (headline)" + "translation": "About the substantive noun, or the [alternative term]. (headline)" } ] ] @@ -702,11 +702,11 @@ [ { "text": "Von welchem Geld soll ich als Arbeitsloser in Urlaub fahren?", - "english": "Being unemployed, on what money should I go on holidays?" + "translation": "Being unemployed, on what money should I go on holidays?" }, { "text": "Man kann nicht nur von Luft und Liebe leben.", - "english": "You can’t live on air and love alone. (proverb)" + "translation": "You can’t live on air and love alone. (proverb)" } ] ] diff --git a/data/test/tidy/en-en-lemmas.json b/data/test/tidy/en-en-lemmas.json index f1f25b2..dfe20d3 100644 --- a/data/test/tidy/en-en-lemmas.json +++ b/data/test/tidy/en-en-lemmas.json @@ -28,7 +28,8 @@ "_examples", [ { - "text": "Waiter, please bring me a single malt whiskey." + "text": "Waiter, please bring me a single malt whiskey.", + "translation": "" } ] ] @@ -51,7 +52,8 @@ "_examples", [ { - "text": "The new company director brought a fresh perspective on sales and marketing." + "text": "The new company director brought a fresh perspective on sales and marketing.", + "translation": "" } ] ] @@ -73,7 +75,8 @@ "_examples", [ { - "text": "The controversial TV broadcast brought a storm of complaints." + "text": "The controversial TV broadcast brought a storm of complaints.", + "translation": "" } ] ] @@ -127,7 +130,8 @@ "_examples", [ { - "text": "What does coal bring per ton?" + "text": "What does coal bring per ton?", + "translation": "" } ] ] @@ -147,7 +151,8 @@ "_examples", [ { - "text": "The closer Jones can really bring it." + "text": "The closer Jones can really bring it.", + "translation": "" } ] ] @@ -189,7 +194,8 @@ "_examples", [ { - "text": "\"The Hay Wain\" is a famous painting by John Constable." + "text": "\"The Hay Wain\" is a famous painting by John Constable.", + "translation": "" } ] ] diff --git a/data/test/tidy/en-es-forms-0.json b/data/test/tidy/en-es-forms-0.json new file mode 100644 index 0000000..25e8b0a --- /dev/null +++ b/data/test/tidy/en-es-forms-0.json @@ -0,0 +1,27 @@ +{ + "_type": "map", + "map": [ + [ + "fast", + { + "_type": "map", + "map": [ + [ + "faster fastest", + { + "_type": "map", + "map": [ + [ + "adj", + [ + "comparative" + ] + ] + ] + } + ] + ] + } + ] + ] +} \ No newline at end of file diff --git a/data/test/tidy/en-es-lemmas.json b/data/test/tidy/en-es-lemmas.json new file mode 100644 index 0000000..9028f8b --- /dev/null +++ b/data/test/tidy/en-es-lemmas.json @@ -0,0 +1,96 @@ +{ + "fast": { + "fast": { + "adj": { + "0": { + "ipa": [ + { + "ipa": "/fɑːst/", + "tags": [] + }, + { + "ipa": "/fæst/", + "tags": [] + } + ], + "glossTree": { + "_type": "map", + "map": [ + [ + "Rápido, veloz.", + { + "_type": "map", + "map": [ + [ + "_tags", + [] + ], + [ + "_examples", + [] + ] + ] + } + ], + [ + "Adelantado.", + { + "_type": "map", + "map": [ + [ + "_tags", + [ + "en situaciones relacionadas con el tiempo" + ] + ], + [ + "_examples", + [ + { + "text": "Your watch is some minutes fast", + "translation": "→ Tu reloj va algunos minutos adelantado." + } + ] + ] + ] + } + ], + [ + "Firme, fijo, sólido.", + { + "_type": "map", + "map": [ + [ + "_tags", + [] + ], + [ + "_examples", + [] + ] + ] + } + ], + [ + "Cachondo, entregado a los placeres.", + { + "_type": "map", + "map": [ + [ + "_tags", + [] + ], + [ + "_examples", + [] + ] + ] + } + ] + ] + } + } + } + } + } +} \ No newline at end of file diff --git a/data/test/tidy/es-en-lemmas.json b/data/test/tidy/es-en-lemmas.json index 95db7e1..afdce2a 100644 --- a/data/test/tidy/es-en-lemmas.json +++ b/data/test/tidy/es-en-lemmas.json @@ -50,7 +50,7 @@ [ { "text": "Vive de migas, nada más.", - "english": "He lives on crumbs, nothing more." + "translation": "He lives on crumbs, nothing more." } ] ] @@ -73,11 +73,11 @@ [ { "text": "Vive en la casa roja.", - "english": "She lives in the red house." + "translation": "She lives in the red house." }, { "text": "La pobrecita vive con dos hermanas crueles.", - "english": "The poor girl lives with two cruel sisters." + "translation": "The poor girl lives with two cruel sisters." } ] ] diff --git a/data/test/tidy/fa-en-lemmas.json b/data/test/tidy/fa-en-lemmas.json index 5a1015b..b7e42ab 100644 --- a/data/test/tidy/fa-en-lemmas.json +++ b/data/test/tidy/fa-en-lemmas.json @@ -113,7 +113,7 @@ [ { "text": "بَرادَرِ شُوْهَرِش فارْسی بَلَدِه.", - "english": "Her husband's brother knows Persian." + "translation": "Her husband's brother knows Persian." } ] ] @@ -150,7 +150,7 @@ [ { "text": "فارْسی هَسْتیم.", - "english": "We are Persian." + "translation": "We are Persian." } ] ] diff --git a/data/test/tidy/fr-en-lemmas.json b/data/test/tidy/fr-en-lemmas.json index e0fb978..1a670ff 100644 --- a/data/test/tidy/fr-en-lemmas.json +++ b/data/test/tidy/fr-en-lemmas.json @@ -28,7 +28,7 @@ [ { "text": "prends ma main", - "english": "take my hand" + "translation": "take my hand" } ] ] @@ -51,7 +51,7 @@ [ { "text": "elle prend un café", - "english": "she is drinking a coffee" + "translation": "she is drinking a coffee" } ] ] @@ -74,7 +74,7 @@ [ { "text": "Je vais prendre le plat du jour.", - "english": "I'll get the dish of the day." + "translation": "I'll get the dish of the day." } ] ] @@ -97,7 +97,7 @@ [ { "text": "prendre quelque chose à quelqu’un", - "english": "to take something from someone" + "translation": "to take something from someone" } ] ] @@ -120,11 +120,11 @@ [ { "text": "prendre une décision", - "english": "to make a decision" + "translation": "to make a decision" }, { "text": "prendre des mesures draconiennes", - "english": "to take draconian measures" + "translation": "to take draconian measures" } ] ] @@ -147,11 +147,11 @@ [ { "text": "le feu ne prend pas", - "english": "the fire won't start" + "translation": "the fire won't start" }, { "text": "la sauce ne prend pas", - "english": "the sauce isn't thickening" + "translation": "the sauce isn't thickening" } ] ] @@ -174,11 +174,11 @@ [ { "text": "je me suis pris la main dans la porte", - "english": "I caught my hand in the door" + "translation": "I caught my hand in the door" }, { "text": "je me suis pris la porte dans la figure", - "english": "the door hit me in the face" + "translation": "the door hit me in the face" } ] ] @@ -208,11 +208,11 @@ [ { "text": "Qu’est-ce qui t’a pris ? Qu’est-ce qui t’est passé par la tête ?", - "english": "What were you thinking? What got into you? What came over you?" + "translation": "What were you thinking? What got into you? What came over you?" }, { "text": "Qu’est-ce qui lui a pris ? Quelle mouche l’a piqué ?", - "english": "What was he thinking? What got into him?" + "translation": "What was he thinking? What got into him?" } ] ] @@ -239,11 +239,11 @@ [ { "text": "prendre de la vitesse", - "english": "to gain speed" + "translation": "to gain speed" }, { "text": "prendre du galon", - "english": "to gain a promotion" + "translation": "to gain a promotion" } ] ] @@ -267,7 +267,7 @@ [ { "text": "Ça va me prendre au moins deux heures pour le mettre à jour.", - "english": "It's going to take me at least two hours to update it." + "translation": "It's going to take me at least two hours to update it." } ] ] @@ -292,7 +292,7 @@ [ { "text": "Pour finir dans deux heures, ça prend trois personnes.", - "english": "To finish in two hours, it'll take three people." + "translation": "To finish in two hours, it'll take three people." } ] ] @@ -315,11 +315,11 @@ [ { "text": "il prend [quelque chose] à [quelqu’un]", - "english": "[something] comes over [someone]" + "translation": "[something] comes over [someone]" }, { "text": "Il lui prend une fantaisie de mettre le feu à la maison.", - "english": "A fancy comes over him to set fire to the house." + "translation": "A fancy comes over him to set fire to the house." } ] ] diff --git a/data/test/tidy/fr-fr-lemmas.json b/data/test/tidy/fr-fr-lemmas.json index beee2a5..accce50 100644 --- a/data/test/tidy/fr-fr-lemmas.json +++ b/data/test/tidy/fr-fr-lemmas.json @@ -45,10 +45,12 @@ "_examples", [ { - "text": "Que d’avatars dans la vie politique de cet homme d’État !" + "text": "Que d’avatars dans la vie politique de cet homme d’État !", + "translation": "" }, { - "text": "Batman est l’avatar moderne de Zorro." + "text": "Batman est l’avatar moderne de Zorro.", + "translation": "" } ] ] @@ -71,7 +73,8 @@ "_examples", [ { - "text": "Le service social du travail – Avatars d’une fonction, vicissitudes d’un métier" + "text": "Le service social du travail – Avatars d’une fonction, vicissitudes d’un métier", + "translation": "" } ] ] diff --git a/data/test/tidy/ja-en-lemmas.json b/data/test/tidy/ja-en-lemmas.json index 7e93704..3a821bc 100644 --- a/data/test/tidy/ja-en-lemmas.json +++ b/data/test/tidy/ja-en-lemmas.json @@ -69,11 +69,11 @@ [ { "text": "好きな食べ物は? アイスクリームです。", - "english": "What's your favorite food? - It's ice cream." + "translation": "What's your favorite food? - It's ice cream." }, { "text": "君が好きだからこそこれほど頑張っているんだよ。", - "english": "It's precisely because I like you [because of my fondness for you] that I'm working this hard." + "translation": "It's precisely because I like you [because of my fondness for you] that I'm working this hard." } ] ] @@ -113,7 +113,7 @@ [ { "text": "アライグマなら尻尾にシマがある。どう見でもタヌキだ。", - "english": "If you're a raccoon, you'd have stripes on your tail. No matter how you look at it, you're a raccoon dog." + "translation": "If you're a raccoon, you'd have stripes on your tail. No matter how you look at it, you're a raccoon dog." } ] ] @@ -136,7 +136,7 @@ [ { "text": "やいやい、其処な狸め", - "english": "Hey there, you sly dog!" + "translation": "Hey there, you sly dog!" } ] ] @@ -179,7 +179,8 @@ "_examples", [ { - "text": "狸を決め込む ― tanuki o kimekomu ― pretend to be a raccoon dog → feign sleep" + "text": "狸を決め込む ― tanuki o kimekomu ― pretend to be a raccoon dog → feign sleep", + "translation": "" } ] ] @@ -245,7 +246,7 @@ [ { "text": "車が走っている。", - "english": "A car is running. / Cars are running." + "translation": "A car is running. / Cars are running." } ] ] @@ -262,7 +263,7 @@ [ { "text": "石の上を水が走る。", - "english": "The water runs over the stones." + "translation": "The water runs over the stones." } ] ] @@ -274,7 +275,7 @@ [ { "text": "マラソン選手が走り出した。", - "english": "Marathon athlete(s) started running." + "translation": "Marathon athlete(s) started running." } ] ] @@ -297,7 +298,7 @@ [ { "text": "彼はこの道をよく走る。", - "english": "He often runs down this street." + "translation": "He often runs down this street." } ] ] @@ -318,7 +319,7 @@ [ { "text": "刀が鞘から走る。", - "english": "The sword slides out of its sheath." + "translation": "The sword slides out of its sheath." } ] ] @@ -371,11 +372,11 @@ [ { "text": "彼は敵に走った。", - "english": "He defected to the enemy." + "translation": "He defected to the enemy." }, { "text": "立場を忘れて感情に走ってはいけない。", - "english": "Don't forget your stance and give in to emotions." + "translation": "Don't forget your stance and give in to emotions." } ] ] @@ -411,7 +412,8 @@ "_examples", [ { - "text": "山脈が南北に走る。\nSanmyaku ga nanboku ni hashiru.\nThe mountain range runs north–south." + "text": "山脈が南北に走る。\nSanmyaku ga nanboku ni hashiru.\nThe mountain range runs north–south.", + "translation": "" } ] ] @@ -432,11 +434,11 @@ [ { "text": "稲妻が走る", - "english": "lightning flashes by" + "translation": "lightning flashes by" }, { "text": "背中に痛みが走った。", - "english": "I felt a brief pain in my back." + "translation": "I felt a brief pain in my back." } ] ] diff --git a/data/test/tidy/la-en-lemmas.json b/data/test/tidy/la-en-lemmas.json index f2449a0..3ddace5 100644 --- a/data/test/tidy/la-en-lemmas.json +++ b/data/test/tidy/la-en-lemmas.json @@ -61,11 +61,11 @@ [ { "text": "hascine propter rēs maledicās fāmās ferunt.", - "english": "Is it on account of these things that they spread slanderous reports?" + "translation": "Is it on account of these things that they spread slanderous reports?" }, { "text": "“Oenōtrī coluēre virī; nunc fāma minōrēs", - "english": "“Oenotrian men tilled [the land]; now rumor [has it that their] descendants call the nation ‘Italy’ after the name of its leader, [Italus].”" + "translation": "“Oenotrian men tilled [the land]; now rumor [has it that their] descendants call the nation ‘Italy’ after the name of its leader, [Italus].”" } ] ] @@ -88,11 +88,11 @@ [ { "text": "Dīmīcantī dē fāmā dēesse.", - "english": "To abandon one whose reputation is attacked." + "translation": "To abandon one whose reputation is attacked." }, { "text": "Fāma tamen clāra est; et adhūc sine crīmine vīxī.", - "english": "My good name is nevertheless unstained; and so far I have lived without blame." + "translation": "My good name is nevertheless unstained; and so far I have lived without blame." } ] ] @@ -262,11 +262,11 @@ [ { "text": "Librōs lege.", - "english": "Read books." + "translation": "Read books." }, { "text": "Lēgistīne hunc librum?", - "english": "Have you read this book?" + "translation": "Have you read this book?" } ] ] @@ -452,7 +452,7 @@ [ { "text": "ab ōvō ū̆sque ad māla", - "english": "from the beginning to the end\n(literally, “from the egg to the apples”)" + "translation": "from the beginning to the end\n(literally, “from the egg to the apples”)" } ] ] @@ -519,7 +519,7 @@ [ { "text": "Quae rectis lineis suos ordines servant", - "english": "Which preserve their order in straight lines" + "translation": "Which preserve their order in straight lines" } ] ] @@ -572,7 +572,7 @@ [ { "text": "Via stultī rēcta in oculīs eius; quī autem sapiēns est audit cōnsilia.", - "english": "The way of a fool is right in his own eyes: but he that is wise hearkeneth unto counsels. (Douay-Rheims trans., Challoner rev.: 1752 CE)" + "translation": "The way of a fool is right in his own eyes: but he that is wise hearkeneth unto counsels. (Douay-Rheims trans., Challoner rev.: 1752 CE)" } ] ] @@ -632,11 +632,11 @@ [ { "text": "Deō domuīque", - "english": "For God and for home (motto of Methodist Ladies' College, Melbourne)" + "translation": "For God and for home (motto of Methodist Ladies' College, Melbourne)" }, { "text": "Stet fortūna domūs", - "english": "Let the good fortune of the house stand (motto of Harrow School, England)" + "translation": "Let the good fortune of the house stand (motto of Harrow School, England)" } ] ], @@ -770,11 +770,11 @@ [ { "text": "domum trahere", - "english": "to drag into one's pocket" + "translation": "to drag into one's pocket" }, { "text": "Domī versūra fit.", - "english": "One is one's own creditor. (proverb)" + "translation": "One is one's own creditor. (proverb)" } ] ] @@ -802,7 +802,7 @@ [ { "text": "ut non quietior populus domi esset quam militiae", - "english": "so that the people should not become lazier in the time of peace than that of war" + "translation": "so that the people should not become lazier in the time of peace than that of war" } ] ] diff --git a/data/test/tidy/sq-en-lemmas.json b/data/test/tidy/sq-en-lemmas.json index b1d3f2f..f42c688 100644 --- a/data/test/tidy/sq-en-lemmas.json +++ b/data/test/tidy/sq-en-lemmas.json @@ -103,11 +103,11 @@ [ { "text": "Mbaje gjuhën!", - "english": "Hold your tongue!" + "translation": "Hold your tongue!" }, { "text": "E ka gjuhën të gjatë.", - "english": "(literally, “She has a long tongue.”)" + "translation": "(literally, “She has a long tongue.”)" } ] ] @@ -143,11 +143,11 @@ [ { "text": "gjuhë lope e zier", - "english": "boiled beef tongue" + "translation": "boiled beef tongue" }, { "text": "Dogji gjuhën.", - "english": "I burned my tongue." + "translation": "I burned my tongue." } ] ] @@ -175,11 +175,11 @@ [ { "text": "gjuha e fëmijëve", - "english": "children speech" + "translation": "children speech" }, { "text": "gjuhë e trashë", - "english": "foul language" + "translation": "foul language" } ] ] @@ -196,11 +196,11 @@ [ { "text": "gjuha e muzikës", - "english": "music's language" + "translation": "music's language" }, { "text": "gjuha e bletëve", - "english": "bees' language" + "translation": "bees' language" } ] ] @@ -236,7 +236,7 @@ [ { "text": "gjuha shqipe", - "english": "the Albanian language" + "translation": "the Albanian language" } ] ] diff --git a/types.ts b/types.ts index 8d0f0d1..410bae4 100644 --- a/types.ts +++ b/types.ts @@ -53,6 +53,12 @@ declare global { type?: "example" | "quotation" | "quote"; english?: string; roman?: string; + translation?: string; + } + + type StandardizedExample = { + text: string; + translation?: string; } type Glosses = string | string[]; @@ -69,8 +75,8 @@ declare global { } ; type GlossTwig = Map & { - get(key: '_examples'): Example[] | undefined; - set(key: '_examples', value: Example[]): GlossTwig; + get(key: '_examples'): StandardizedExample[] | undefined; + set(key: '_examples', value: StandardizedExample[]): GlossTwig; } type TidySense = Omit & {