From 8b0f6ace7dc83ad85915a1b824bfc75e36339a2c Mon Sep 17 00:00:00 2001 From: lasconic Date: Tue, 27 Apr 2021 22:19:53 +0200 Subject: [PATCH] fix #198: Keep the whole etymology --- tests/data/fr/bath.wiki | 120 +++++++++++++++++++++++++++++++++++++ tests/test_4_check_word.py | 4 ++ tests/test_4_get_word.py | 8 ++- tests/test_ca.py | 36 +++++------ tests/test_en.py | 41 +++++++++---- tests/test_es.py | 38 +++++++----- tests/test_fr.py | 90 ++++++++++++++++++++-------- tests/test_pt.py | 36 ++++++----- wikidict/check_word.py | 7 ++- wikidict/convert.py | 24 ++++++-- wikidict/get_word.py | 8 ++- wikidict/render.py | 53 +++++++++------- wikidict/utils.py | 5 -- 13 files changed, 351 insertions(+), 119 deletions(-) create mode 100644 tests/data/fr/bath.wiki diff --git a/tests/data/fr/bath.wiki b/tests/data/fr/bath.wiki new file mode 100644 index 000000000..3b6a1127c --- /dev/null +++ b/tests/data/fr/bath.wiki @@ -0,0 +1,120 @@ +{{voir|Bath}} + +== {{langue|fr}} == +=== {{S|étymologie}} === +: (''[[#fr-adj|Adjectif]], [[#fr-nom-1|nom 1]]'') {{date|lang=fr|1846}} Origine discutée{{R|TLFi}} : +:# soit de ''{{lien|Bath|fr}}'', station thermale anglaise très prisée par la haute société au {{siècle2|XVIII}} siècle ; pour rendre compte de la forme ''bath'' ; +:# soit forme apocopée de l’argot ''{{lien|batif|fr}}''{{R|Larousse}} (« joli ») {{source|1837, Vidocq, [[s:Les Voleurs (Vidocq)/dico1/B|''Les Voleurs'']]}}, lui-même {{composé de|bat|battant|-if|lang=fr}} dans le syntagme ''battant neuf'', « fraîchement battu, tout neuf » ; +:# soit emploi adjectival de l’interjection onomatopéique ''bath, {{lien|bah|fr}}'' exprimant l’étonnement. +: Le nom du papier semble dérivé du sens « beau » plus que du nom de ''Bath'', ville où l’on aurait fabriqué cette sorte de papier{{R|TLFi}}. +: (''[[#fr-nom-2|Nom 2]]'') De l’{{étyl|he|fr|בת|bat}}. + +=== {{S|adjectif|fr}} === +{{fr-rég|bat|mf=1}} +'''bath''' {{pron|bat|fr}} {{mf|fr}} +# {{argot|fr}} {{désuet|fr}} [[super|Super]] ; [[bon]] ; [[agréable]]. +#* ''– C’est rien '''bath''' !
– Mince alors, on en a de la chance !'' {{source|{{nom w pc|Léon|Frapié}}, ''Le sou'', dans ''Les contes de la maternelle'', 1910, éditions Self, 1945, page 180}} +#* ''– Je suis content… Et toi, Polyte, t’as plus mal au pied ?
– Ah ! non ! … C’est trop '''bath''' !'' {{source|{{nom w pc|Léon|Frapié}}, ''Le sou'', dans ''Les contes de la maternelle'', 1910, éditions Self, 1945, page 181}} +#* ''T’es '''bath''', la Caille. Ta peau, c’est du satin. J’suis folle ! Ta peau me brûle et tes mirettes… Oh ! tes mirettes !…'' {{source|{{Citation/Francis Carco/Jésus-la-Caille/1914|II}}}} +#* ''— Pige-moi cet horizon, si c’est '''bath''' !'' {{source|{{w|Jules Romains}}, ''{{ws|Les Copains/Chapitre 4|Les Copains}}'', 1922, réédition Le Livre de Poche, page 104}} +#* ''Vous êtes bien '''bath'''. Ça me plairait drôlement d’être comme vous. Vzêtes drôlement bien roulée. Et d’une élégance avec ça.'' {{source|{{nom w pc|Raymond|Queneau}}, ''{{w|Zazie dans le métro}}'', chapitre 13, Gallimard, 1959}} +#* ''Ainsi, défilèrent consécutivement les qualificatifs de ''dément'', ''délirant'', ''chouette'', '''''bath''''', et ''pas mal''. On pouvait tout aussi bien dire d'une fille qu'elle était ''chouette'' et d'une capitale étrangère visitée à Pâques que c'était ''pas mal. {{source|{{w|Philippe Labro}}, ''Des Feux mal éteints'', Editions Gallimard, 1967, 2014, chapitre 2}} +#* ''T'es OK, t'es '''bath''', t'es in'' {{source|{{nom w pc|Ottawan}}, ''{{w|T'es OK}}''}} + +==== {{S|notes}} ==== +: Cité dès 1846, toujours en vogue dans les années 1960. + +==== {{S|synonymes}} ==== +* [[génial]] +* [[super]] {{familier|nocat=1}} + +==== {{S|traductions}} ==== +{{trad-début}} +* {{T|af}} : {{trad-|af|aardig}} +* {{T|de}} : {{trad+|de|hübsch}}, {{trad+|de|nett}} +* {{T|en}} : {{trad+|en|neat}}, {{trad+|en|great}}, {{trad+|en|pretty}} +* {{T|da}} : {{trad+|da|køn}} +* {{T|es}} : {{trad+|es|bonito}}, {{trad+|es|lindo}}, {{trad+|es|mono}} +* {{T|eo}} : {{trad-|eo|beleta}} +* {{T|fo}} : {{trad-|fo|fittur}} +* {{T|fy}} : {{trad-|fy|skoan}} +* {{T|gd}} : {{trad-|gd|bòidheach}} +* {{T|hu}} : {{trad+|hu|csinos}} +* {{T|it}} : {{trad-|it|bellino}}, {{trad+|it|grazioso}} +* {{T|la}} : {{trad+|la|bellus}} +* {{T|ms}} : {{trad+|ms|bagus}}, {{trad-|ms|baik}} +* {{T|nl}} : {{trad+|nl|aardig}}, {{trad+|nl|keurig}}, {{trad+|nl|leuk}} +* {{T|pap}} : {{trad--|pap|bunita}}, {{trad--|pap|nèchi}} +* {{T|pl}} : {{trad+|pl|ładny}} +* {{T|pt}} : {{trad+|pt|bonito}}, {{trad+|pt|lindo}} +* {{T|ro}} : {{trad+|ro|drăguț}} +* {{T|tr}} : {{trad+|tr|hoş}}, {{trad+|tr|nefis}} +* {{T|zu}} : {{trad+|zu|-hle}} +{{trad-fin}} + +=== {{S|nom|fr|num=1}} === +{{fr-rég|bat}} +'''bath''' {{pron|bat|fr}} {{m}} +# [[Papier]] à lettre de provenance [[anglais]]e, de belle [[qualité]], qui a joui d’une grande [[vogue]] au {{siècle2|XIX}} siècle. + +=== {{S|nom|fr|num=2}} === +{{fr-rég|bat|p2=bathim|pp2=ba.tim}} +'''bath''' {{pron|bat|fr}} {{m}} +# Mesure des liquides chez les Hébreux, valant 18,08 [[litre]]s{{R|Littré}} puis plus tard environ 38,88 litres. +#* '''''BATH''', pl. '''{{pc|Bathim}}'''. Mesure de capacité pour liquides, en usage chez les anciens.
Le '''bath''' asiatique et égyptien, ou des Hébreux, était la dixième partie du cor, et se divisait en 6 hin = 72 log = 288 rébiites = 432 cos = 3.981 gallons = 18.0879 litres. Le '''bath''' représentait le cube de la demi-coudée royale, et était égal à l’épha, mesure de grains. On prétend qu’il y avait en outre un ''petit '''bath''''', égal au cube de la demi-coudée naturelle = 2.507 gallons = 11.39 litres.
Dans la suite, cette mesure augmenta de valeur, et, d’après le système philétérien, établi en Égypte sous les Ptolémées, le '''bath''' philétérien, ou petit artaba d’Alexandrie (qui était égal aux ¾ du métrétès ou grand artaba) forma la dixième partie du cor philétérien et se divisa en 3 sat ou séa = 6 hin = 72 log = 96 cadaa = 288 rébiites = 432 cos = 7.703 gallons = 35 litres. Mais la valeur de cette mesure paraît ne pas avoir été constante, et diffère d’après les divers auteurs qui en font mention. Fannius, dans son poème sur les mesures, dit que l’artaba est égal à 3 fois et ⅓ le modius romain, ce qui ferait seulement 28.8 litres. Josèphe, Apollinaire, saint Jérôme, etc., assignent au hin la capacité de 2 conges, ce qui fait pour le '''bath''' 12 conges ou 38.88 litres. Saint Épiphane dit que le hin est de 9 xestès, ce qui fait pour le '''bath''' 54 xestès ou 29.16 litres.'' {{source|1=Horace {{pc|Doursther}}, [http://books.google.ca/books?id=KAibOR651tkC&pg=PA51&hl=fr ''Dictionnaire universel des poids et mesures, anciens et modernes''], M. Hayez, Bruxelles, 1840}} + +==== {{S|traductions}} ==== +{{trad-début}} +* {{T|en}} : {{trad+|en|bath}} +{{trad-fin}} + +=== {{S|prononciation}} === +==== {{S|homophones|fr}} ==== +* [[baht]] +* [[batte]], [[battent]], [[battes]] + +=== {{S|prononciation}} === +* {{écouter|lang=fr|France (Vosges)||audio=LL-Q150 (fra)-LoquaxFR-bath.wav}} + +=== {{S|anagrammes}} === +* [[baht]] + +=== {{S|voir aussi}} === +* {{WP}} +* {{Vikidia}} + +=== {{S|références}} === +{{Références}} + +== {{langue|en}} == +=== {{S|étymologie}} === +: {{dénominal|de=bathe|lang=en|m=1}} (« baigner »), apparenté à ''{{lien|Bad|de}}'' en allemand, ''{{lien|bad|nl}}'' en néerlandais. + +=== {{S|nom|en}} === +{{en-nom-rég|bɑːθ|pron2=bæθ|s=s}} +[[Image:Prilidiano Pueyrredón-El baño.jpg|thumb|bath]] +'''bath''' {{pron|bɑːθ|en}} {{UK|nocat=1}} ou {{pron|bæθ|en}} {{US|nocat=1}} +# Bain, action de se baigner. +#*''I'll take a '''bath'''.'' +# [[bain#fr|Bain]], [[baignoire]]. +# [[salle de bains|Salle de bains]]. + +==== {{S|dérivés}} ==== +* {{lien|bathtub|en}} +* {{lien|bloodbath|en}} + +=== {{S|prononciation}} === +* {{pron|bɑːθ|en}} {{UK|nocat=1}} +* {{pron|bæθ|en}} {{US|nocat=1}} +** {{écouter|États-Unis (Californie)|bæθ|audio=En-us-bath.ogg|lang=en}} +* {{écouter|lang=en|Suisse (Genève)|bɑːθ|audio=LL-Q1860 (eng)-Nattes à chat-bath.wav}} + +=== {{S|anagrammes}} === +* {{lien|baht|en}} + +=== {{S|voir aussi}} === +* {{WP|Bathing|bath|lang=en}} diff --git a/tests/test_4_check_word.py b/tests/test_4_check_word.py index 6d56232ab..d9054d868 100644 --- a/tests/test_4_check_word.py +++ b/tests/test_4_check_word.py @@ -11,6 +11,10 @@ def test_word_of_the_day(): assert check_word.main("fr", "") == 0 +def test_etymology_list(): + assert check_word.main("fr", "bath") == 0 + + def test_sublist(): assert check_word.main("fr", "éperon") == 0 diff --git a/tests/test_4_get_word.py b/tests/test_4_get_word.py index 4b0a4a432..45a1756d5 100644 --- a/tests/test_4_get_word.py +++ b/tests/test_4_get_word.py @@ -3,18 +3,22 @@ def test_simple(): # The word exists and contains subsublists. - assert get_word.main("fr", "marron") == 0 + assert get_word.main("fr", "base") == 0 def test_word_of_the_day(): assert get_word.main("fr", "") == 0 +def test_subdefinitions(): + assert get_word.main("fr", "mesure") == 0 + + def test_raw(): assert get_word.main("fr", "marron", raw=True) == 0 -def test_word_with_vairants(): +def test_word_with_variants(): assert get_word.main("fr", "suis") == 0 diff --git a/tests/test_ca.py b/tests/test_ca.py index efc98df84..3459b3eb3 100644 --- a/tests/test_ca.py +++ b/tests/test_ca.py @@ -11,14 +11,14 @@ "-ass-", ["as"], "", - "Del sufix -às amb valor augmentatiu.", + ["Del sufix -às amb valor augmentatiu."], ["Infix que afegeix un matís augmentatiu."], ), ( "-itzar", [], "", - "Del llatí -izare, provinent del grec antic -ίζειν.", + ["Del llatí -izare, provinent del grec antic -ίζειν."], [ "Aplicat a un substantiu o adjectiu forma un verb que expressa la seva realització o convertir-se'n.", # noqa ], @@ -27,25 +27,25 @@ "AFI", ["ˈa.fi"], "", - "sigles", + ["sigles"], [ "(m) Alfabet Fonètic Internacional.", "(f) Associació Fonètica Internacional.", ], ), - ("avui", [], "", "", ["En el dia actual.", "Metafòricament, en el present."]), + ("avui", [], "", [], ["En el dia actual.", "Metafòricament, en el present."]), ( "bio-", [], "", - "", + [], ['Element que entra en la composició de paraules amb el sentit de "vida".'], ), ( "cap", [], "m", - "Del llatí caput.", + ["Del llatí caput."], [ "(anatomia) Part superior del cos d'un animal.", "Cervell.", @@ -69,7 +69,7 @@ "cas", ["ˈkas"], "m", - "Del llatí casus.", + ["Del llatí casus."], [ "Situació particular que es produeix entre les diverses possibles.", "Objecte d'estudi d'alguna disciplina.", @@ -82,7 +82,7 @@ "Castell", [], "", - "De castell.", + ["De castell."], [ "Diversos topònims, especialment:", ( @@ -102,7 +102,9 @@ "català", [], "m", - "D’origen incert, paral·lel al de Catalunya, possiblement metàtesi del llatí lacetani («lacetans»).", # noqa + [ + "D’origen incert, paral·lel al de Catalunya, possiblement metàtesi del llatí lacetani («lacetans»)." # noqa + ], [ "Relatiu o pertanyent a Catalunya, als seus habitants o a la llengua catalana.", "Relatiu o pertanyent als Països Catalans o als seus habitants.", @@ -117,7 +119,7 @@ "ch", [], "", - "", + [], [ "Codi de llengua ISO 639-1 del chamorro.", "(arcaisme) Especialment a final de mot, dígraf amb una consonant muda per remarcar la grafia d’una oclusiva velar sorda [k] i no pas una de sonora [ɡ].", # noqa @@ -127,7 +129,7 @@ "compte", [], "m", - "Del llatí compŭtus, segle XIII.", + ["Del llatí compŭtus, segle XIII."], [ "Acte de comptar.", "Cura, atenció.", @@ -140,7 +142,7 @@ "disset", [], "m", - "Del llatí decem et septem («deu i set»).", + ["Del llatí decem et septem («deu i set»)."], [ "(cardinal) Nombre enter situat entre el setze i el divuit.", "(valor ordinal) Dissetè, dissetena.", @@ -152,7 +154,7 @@ "el", ["əɫ"], "f", - "", + [], [ "Codi de llengua ISO 639-1 del grec modern.", "Article determinat masculí singular que serveix per actualitzar i concretar el contingut del substantiu que acompanya.", # noqa @@ -161,14 +163,14 @@ "(obsolet) forma alternativa de ela", ], ), - ("Mn.", [], "", "", ["mossèn com a tractament davant el nom"]), - ("PMF", ["ˌpeˈe.məˌe.fə"], "", "", ["Preguntes Més Freqüents."]), - ("pen", [], "", "", []), + ("Mn.", [], "", [], ["mossèn com a tractament davant el nom"]), + ("PMF", ["ˌpeˈe.məˌe.fə"], "", [], ["Preguntes Més Freqüents."]), + ("pen", [], "", [], []), ( "si", ["si"], "m", - "", + [], [ "Codi de llengua ISO 639-1 del singalès.", "Cavitat interna del cos", diff --git a/tests/test_en.py b/tests/test_en.py index 2edfe23d7..1afc472cd 100644 --- a/tests/test_en.py +++ b/tests/test_en.py @@ -10,7 +10,7 @@ ( "ab", ["æb"], - "Abbreviation of abdominal muscles.", + ["Abbreviation of abdominal muscles."], [ "(informal) abdominal muscle. [Mid 20th century.]", "(slang) An abscess caused by injecting an illegal drug, usually heroin.", @@ -24,7 +24,7 @@ ( "cum", ["kʌm"], - "From Latin cum (“with”).", + ["From Latin cum (“with”)."], [ "Used in indicating a thing with two roles, functions, or natures, or a " "thing that has changed from one to another.", @@ -43,7 +43,9 @@ ( "efficient", ["ɪˈfɪʃənt"], - "1398, “making,” from Old French, from Latin efficientem, nominative efficiēns, participle of efficere (“work out, accomplish”) (see effect). Meaning “productive, skilled” is from 1787. Efficiency apartment is first recorded 1930, American English.", # noqa + [ + "1398, “making,” from Old French, from Latin efficientem, nominative efficiēns, participle of efficere (“work out, accomplish”) (see effect). Meaning “productive, skilled” is from 1787. Efficiency apartment is first recorded 1930, American English." # noqa + ], [ "making good, thorough, or careful use of resources; not consuming extra. Especially, making good use of time or energy", # noqa "expressing the proportion of consumed energy that was successfully used in a process; the ratio of useful output to total input", # noqa @@ -55,7 +57,7 @@ ( "it's", ["ɪts"], - "Contraction of ‘it is’ or ‘it has’.", + ["Contraction of ‘it is’ or ‘it has’."], [ "It is.", "It has.", @@ -66,7 +68,9 @@ ( "Mars", ["ˈmɑːz"], - "From Middle English Mars, from Latin Mars (“god of war”), from older Latin (older than 75 B.C.E.) Māvors. 𐌌𐌀𐌌𐌄𐌓𐌔 was his Oscan name. He was also known as Marmor, Marmar and Maris, the latter from the Etruscan deity Maris.", # noqa + [ + "From Middle English Mars, from Latin Mars (“god of war”), from older Latin (older than 75 B.C.E.) Māvors. 𐌌𐌀𐌌𐌄𐌓𐌔 was his Oscan name. He was also known as Marmor, Marmar and Maris, the latter from the Etruscan deity Maris." # noqa + ], [ "(astronomy) The fourth planet in the solar system. Symbol: ", "(Roman god) The Roman god of war.", @@ -78,7 +82,9 @@ ( "portmanteau", ["pɔːtˈmæn.təʊ"], - "French portemanteau (“coat stand”), from porte (“carry”) + manteau (“coat”).", + [ + "French portemanteau (“coat stand”), from porte (“carry”) + manteau (“coat”)." + ], [ "A large travelling case usually made of leather, and opening into two equal sections.", "(Australia, dated) A schoolbag.", @@ -91,7 +97,7 @@ ( "someone", ["ˈsʌmwʌn"], - "some + one", + ["some + one"], [ "Some person.", "A partially specified but unnamed person.", @@ -101,7 +107,11 @@ ( "the", ["ˈðiː"], - "From Middle English the, from Old English þē (“the, that”, demonstrative pronoun), a late variant of .", # noqa + [ + "From Middle English the, from Old English þē (“the, that”, demonstrative pronoun), a late variant of .", # noqa + "Originally masculine nominative, in Middle English it superseded all previous Old English forms (, sēo, þæt, þā), from Proto-West Germanic *siz, from Proto-Germanic *sa, ultimately from Proto-Indo-European *só.", # noqa + "Cognate with Saterland Frisian die (“the”), West Frisian de (“the”), Dutch de (“the”), German Low German de (“the”), German der (“the”), Danish de (“the”), Swedish de (“the”), Icelandic (“that”).", # noqa + ], [ "Definite grammatical article that implies necessarily that an entity it articulates is presupposed; something already mentioned, or completely specified later in that same sentence, or assumed already completely specified. [from 10th c.]", # noqa "Used before a noun modified by a restrictive relative clause, indicating that the noun refers to a single referent defined by the relative clause.", # noqa @@ -121,7 +131,7 @@ ( "um", [], - "Onomatopoeic.", + ["Onomatopoeic."], [ "Expression of hesitation, uncertainty or space filler in conversation. See uh.", "(chiefly, US) Dated spelling of mmm.", @@ -133,7 +143,9 @@ ( "us", ["ʌs", "ʌz"], - "From Middle English us, from Old English ūs (“us”, dative personal pronoun), from Proto-Germanic *uns (“us”), from Proto-Indo-European *ne-, *nō-, *n-ge-, *n-sme- (“us”). Cognate with West Frisian us, ús (“us”), Low German us (“us”), Dutch ons (“us”), German uns (“us”), Danish os (“us”), Latin nōs (“we, us”).", # noqa + [ + "From Middle English us, from Old English ūs (“us”, dative personal pronoun), from Proto-Germanic *uns (“us”), from Proto-Indo-European *ne-, *nō-, *n-ge-, *n-sme- (“us”). Cognate with West Frisian us, ús (“us”), Low German us (“us”), Dutch ons (“us”), German uns (“us”), Danish os (“us”), Latin nōs (“we, us”)." # noqa + ], [ "(personal) Me and at least one other person; the objective case of we.", "(UK, colloquial) Me.", @@ -145,7 +157,10 @@ ( "water", ["ˈwɔːtə"], - "From Middle English water, from Old English wæter (“water”), from Proto-West Germanic *watar, from Proto-Germanic *watōr (“water”), from Proto-Indo-European *wódr̥ (“water”).", # noqa + [ + "From Middle English water, from Old English wæter (“water”), from Proto-West Germanic *watar, from Proto-Germanic *watōr (“water”), from Proto-Indo-European *wódr̥ (“water”).", # noqa + "Cognate with cf, North Frisian weeter (“water”), Saterland Frisian Woater (“water”), West Frisian wetter (“water”), Dutch water (“water”), Low German Water (“water”), German Wasser, Old Norse vatn (Swedish vatten (“water”), Norwegian Bokmål vann (“water”), Norwegian Nynorsk and Icelandic vatn (“water”)), Old Irish coin fodorne (“otters”, literally “water-dogs”), Latin unda (“wave”), Lithuanian vanduõ (“water”), Russian вода́ (voda, “water”), Albanian ujë (“water”), Ancient Greek ὕδωρ (“water”), Armenian գետ (get, “river”), Sanskrit उदन् (udán, “wave, water”), Hittite 𒉿𒀀𒋻 (wa-a-tar).", # noqa + ], [ "(uncountable) A substance (of molecular formula H2O) found at room temperature and pressure as a clear liquid; it is present naturally as rain, and found in rivers, lakes and seas; its solid form is ice and its gaseous form is steam.", # noqa ( @@ -183,7 +198,9 @@ ( "word", ["wɜːd"], - "From Middle English word, from Old English word, from Proto-West Germanic *word, from Proto-Germanic *wurdą, from Proto-Indo-European *wr̥dʰh₁om. Doublet of verb.", # noqa + [ + "From Middle English word, from Old English word, from Proto-West Germanic *word, from Proto-Germanic *wurdą, from Proto-Indo-European *wr̥dʰh₁om. Doublet of verb." # noqa + ], [ "The smallest unit of language that has a particular meaning and can be expressed by itself; the smallest discrete, meaningful unit of language. (contrast morpheme.)", # noqa ( diff --git a/tests/test_es.py b/tests/test_es.py index e02dcfbe4..cc69a23b1 100644 --- a/tests/test_es.py +++ b/tests/test_es.py @@ -10,7 +10,7 @@ ( "-acho", ["ˈa.t͡ʃo"], - "Del latín -acĕus. De allí también -áceo.", + ["Del latín -acĕus. De allí también -áceo."], [ "Forma aumentativos, a veces despectivos, a partir de adjetivos y sustantivos.", ], @@ -18,7 +18,7 @@ ( "cartel", [], - "Del occitano cartel.", + ["Del occitano cartel."], [ "Lámina que se expone para dar información mediante palabras o imágenes.", "Prestigio.", @@ -27,7 +27,9 @@ ( "comer", ["koˈmeɾ"], - "Del latín comedĕre, infinitivo de comedō, el cual es un compuesto de edo (comer). Este verbo se forma a partir Com + edo, obteniendo el siginificado de devorar.", # noqa + [ + "Del latín comedĕre, infinitivo de comedō, el cual es un compuesto de edo (comer). Este verbo se forma a partir Com + edo, obteniendo el siginificado de devorar." # noqa + ], [ "Ingerir o tomar alimentos.", "Tomar la principal comida del día.", @@ -43,7 +45,7 @@ ( "es decir", ["es.ðeˈθiɾ"], - "", + [], [ "Úsase para introducir una aclaración, explicación o definición de lo precedente", ], @@ -51,7 +53,7 @@ ( "entrada", ["en̪ˈtɾa.ða"], - "De entrado y el sufijo flexivo -a para el femenino.", + ["De entrado y el sufijo flexivo -a para el femenino."], [ "Ticket o boleto; credencial, billete o documento que autoriza a entrar en un evento, espectáculo o lugar.", # noqa "(Gastronomía): Plato que se sirve al comienzo de la comida.", @@ -88,7 +90,7 @@ ( "extenuado", ["eks.teˈnwa.ðo"], - "", + [], [ "Cansado, debilitado.", "Se dice de un individuo: sin energía, debido a un gran esfuerzo físico o mental.", @@ -97,7 +99,9 @@ ( "futuro", ["fuˈtu.ɾo"], - 'Del latín futūrus, participio activo futuro irregular de esse ("ser"), y este el protoindoeuropeo *bhū-, *bʰew- ("existir", "llegar a ser").', # noqa + [ + 'Del latín futūrus, participio activo futuro irregular de esse ("ser"), y este el protoindoeuropeo *bhū-, *bʰew- ("existir", "llegar a ser").' # noqa + ], [ "Que está aún por ocurrir o hacerse efectivo.", "Tiempo que aún no ha llegado.", @@ -108,7 +112,7 @@ ( "gracias", ["ˈgɾa.θjas", "ˈgɾa.sjas"], - "", + [], [ "Úsase para expresar agradecimiento.", "Irónicamente expresa desagrado, desprecio o enfado", @@ -117,7 +121,9 @@ ( "hasta", ["ˈas.ta"], - 'Del castellano antiguo fasta, del más antiguo hata, fata, quizá préstamo del árabe حتى (ḥatta), o del latín ad ("a") ista ("esta"), o de ambos.', # noqa + [ + 'Del castellano antiguo fasta, del más antiguo hata, fata, quizá préstamo del árabe حتى (ḥatta), o del latín ad ("a") ista ("esta"), o de ambos.' # noqa + ], [ "Preposición que indica el fin o término de una actividad, sea en sentido locativo, cronológico o cuantitativo.", # noqa "Seguida de cuando o de un gerundio, preposición que indica valor inclusivo.", @@ -131,7 +137,7 @@ ( "hocico", [], - "De hocicar", + ["De hocicar"], [ "(Zootomía): Parte más o menos prolongada de la cabeza de algunos animales en que están la boca y las narices.", # noqa "(Anatomía): Hocico de una persona cuando tiene muy abultados los labios.", @@ -144,7 +150,9 @@ ( "los", [], - 'Del latín illōs, acusativo masculino plural de ille ("ese")', + [ + 'Del latín illōs, acusativo masculino plural de ille ("ese")' + ], [ "Artículo determinado masculino plural.", "Pronombre personal masculino de objeto directo (acusativo), tercera persona del plural.", @@ -153,13 +161,13 @@ ( "Mús.", [], - ".", + ["."], ["Abreviatura lexicográfica convencional de la palabra música"], ), ( "también", ["tamˈbjen"], - "Compuesto de tan y bien", + ["Compuesto de tan y bien"], [ "Utilizado para especificar que una o varias cosas son similares, o que comparten atributos con otra previamente nombrada.", # noqa "Usado para añadir algo a lo anteriormente mencionado.", @@ -168,7 +176,7 @@ ( "uni-", ["ˈu.ni"], - 'Del latín uni-, de unus ("uno")', + ['Del latín uni-, de unus ("uno")'], [ "Elemento compositivo que significa uno. un único, relativo a uno solo.", ], @@ -176,7 +184,7 @@ ( "zzz", [], - ".", + ["."], [ "Onomatopeya que representa el sonido del ronquido. Se usa para indicar que alguien está dormido.", ], diff --git a/tests/test_fr.py b/tests/test_fr.py index b1273f464..d9c559fc7 100644 --- a/tests/test_fr.py +++ b/tests/test_fr.py @@ -11,7 +11,7 @@ "a", ["ɑ", "a"], "m", - "", + [], [ "(Linguistique) Symbole de l’alphabet phonétique international pour la voyelle (ou vocoïde) ouverte antérieure non arrondie.", # noqa "(Métrologie) Symbole du Système international (SI) pour le préfixe atto- (×10−18).", # noqa @@ -28,7 +28,7 @@ "π", ["p"], "", - "", + [], [ "(Mathématiques) Symbole représentant le rapport constant entre la circonférence d’un cercle et son diamètre, aussi appelé en français la constante d’Archimède.", # noqa "(Bases de données) Symbole de la projection.", @@ -39,7 +39,7 @@ "42", ["ka.ʁɑ̃t.dø"], "msing", - "", + [], [ "Numéral en chiffres arabes du nombre quarante-deux, en notation décimale. Selon la base utilisée, ce numéral peut représenter d’autres nombres. En notation hexadécimale, par exemple, ce numéral représente le nombre soixante-six ; en octal, le nombre trente-quatre.", # noqa "(Par ellipse) (Dans la plupart des langues) Une année qui se termine par 42.", @@ -54,7 +54,7 @@ "accueil", ["a.kœj"], "m", - "(XIIe siècle) Déverbal de accueillir.", + ["(XIIe siècle) Déverbal de accueillir."], [ "Cérémonie ou prestation réservée à un nouvel arrivant, consistant généralement à lui souhaiter la bienvenue et à l’aider dans son intégration ou ses démarches.", # noqa "Lieu où sont accueillies les personnes.", @@ -68,7 +68,9 @@ "acrologie", ["a.kʁɔ.lɔ.ʒi"], "f", - "Du grec ancien ἄκρος, akros (« extrémité »), voir acro-, avec le suffixe -logie.", # noqa + [ + "Du grec ancien ἄκρος, akros (« extrémité »), voir acro-, avec le suffixe -logie." # noqa + ], [ "(Linguistique) (Rare) Système graphique qui consiste à peindre, pour représenter les idées, l’image des objets dont le nom commence par la même lettre que celui par lequel ces idées sont exprimées dans le langage ordinaire.", # noqa "(Linguistique) (Par extension) (Rare) Se dit lorsque deux termes commencent par la même lettre et qu’ils sont apparentés par le sens.", # noqa @@ -81,7 +83,7 @@ "aux", ["o"], "mf", - "", + [], [ "(Linguistique) Code ISO 639-3 de l’aurá.", "Contraction obligatoire de la préposition à et de l'article défini les.", @@ -92,7 +94,9 @@ "base", ["bɑz"], "f", - "(Date à préciser) Du latin basis (« id. »), du grec ancien βάσις, básis (« marche »).", # noqa + [ + "(Date à préciser) Du latin basis (« id. »), du grec ancien βάσις, básis (« marche »)." # noqa + ], [ "Partie inférieure d’un corps quelconque qui lui sert de soutien.", "(En particulier) (Architecture) Ce qui soutient le fût de la colonne.", @@ -123,11 +127,32 @@ ], [], ), + ( + "bath", + ["bat"], + "m", + [ + "(Adjectif, nom 1) (1846) Origine discutée :", + ( + "soit de Bath, station thermale anglaise très prisée par la haute société au XVIIIe siècle ; pour rendre compte de la forme bath ;", # noqa + "soit forme apocopée de l’argot batif (« joli ») , lui-même composé de bat, battant et -if dans le syntagme battant neuf, « fraîchement battu, tout neuf » ;", # noqa + "soit emploi adjectival de l’interjection onomatopéique bath, bah exprimant l’étonnement.", + ), + "Le nom du papier semble dérivé du sens « beau » plus que du nom de Bath, ville où l’on aurait fabriqué cette sorte de papier.", # noqa + "(Nom 2) De l’hébreu בת, bat.", + ], + [ + "(Argot) (Désuet) Super ; bon ; agréable.", + "Papier à lettre de provenance anglaise, de belle qualité, qui a joui d’une grande vogue au XIXe siècle.", # noqa + "Mesure des liquides chez les Hébreux, valant 18,08 litres puis plus tard environ 38,88 litres.", + ], + [], + ), ( "Bogotanais", ["bɔ.ɡɔ.ta.nɛ"], "m", - "Du nom Bogota avec le préfixe -ais.", + ["Du nom Bogota avec le préfixe -ais."], [], [], ), @@ -135,7 +160,7 @@ "colligeait", ["kɔ.li.ʒɛ"], "", - "", + [], [], ["colliger"], ), @@ -143,7 +168,7 @@ "corps portant", ["kɔʁ pɔʁ.tɑ̃"], "m", - "Locution composée de corps et de portant.", + ["Locution composée de corps et de portant."], [ "(Astronautique) Aéronef à fuselage porteur, sur lequel la portance est produite par le fuselage, destiné aux usages spatiaux ou hypersoniques, afin de limiter l'effet de traînée ou la surface de friction.", # noqa "(Astronautique) (Aérodynamique) Engin aérospatial possédant, à vitesse hypersonique, une portance qui lui assure une bonne manœuvrabilité lors de la rentrée atmosphérique.", # noqa @@ -154,7 +179,9 @@ "DES", ["deː,ʔeː,ʔɛs"], "m", - "(Commerce international) (1936) Terme créé par la Chambre de commerce internationale. Sigle de l’anglais delivered ex ship; « rendu par navire ».", # noqa + [ + "(Commerce international) (1936) Terme créé par la Chambre de commerce internationale. Sigle de l’anglais delivered ex ship; « rendu par navire »." # noqa + ], [ "(Aviation) Code AITA de l’aéroport de Desroches, aux Seychelles.", "(Commerce international) Incoterm qui signifie que le vendeur a dûment livré sa marchandise dès lors que celle-ci, dédouanée à l’exportation et non à l’importation, est mise à disposition de l’acheteur à bord du navire, au port de destination convenu. Les frais de déchargement sont à la charge de l’acheteur.", # noqa @@ -171,7 +198,7 @@ "dubitatif", [], "", - "Du latin dubitativus.", + ["Du latin dubitativus."], [ "Qui sert à exprimer le doute.", "Qui éprouve un doute.", @@ -182,7 +209,9 @@ "effluve", ["e.flyv"], "mf", - "Du latin effluvium, du préfixe ex- indiquant la séparation et de fluxus (« écoulement »).", # noqa + [ + "Du latin effluvium, du préfixe ex- indiquant la séparation et de fluxus (« écoulement »)." # noqa + ], [ "(Médecine) (Vieilli) Substances organiques altérées, tenues en suspension dans l’air, principalement aux endroits marécageux, et donnant particulièrement lieu à des fièvres intermittentes, rémittentes et continues.", # noqa "Émanation qui se dégage d’un corps quelconque.", @@ -193,7 +222,7 @@ "employer", ["ɑ̃.plwa.je"], "", - "Du latin implicāre (« impliquer »).", + ["Du latin implicāre (« impliquer »)."], [ "Utiliser ; user ; se servir de.", "(Spécialement) (Grammaire) S’en servir en parlant ou en écrivant, en parlant d'une phrase, d'un mot ou d'une locution.", # noqa @@ -205,7 +234,7 @@ "encyclopædie", ["ɑ̃.si.klɔ.pe.di"], "f", - "→ voir encyclopédie", + ["→ voir encyclopédie"], ["(Archaïsme) Variante orthographique de encyclopédie."], [], ), @@ -213,7 +242,7 @@ "éperon", ["e.pʁɔ̃"], "m", - "De l’ancien français esperon, du vieux-francique *sporo.", + ["De l’ancien français esperon, du vieux-francique *sporo."], [ "(Équitation) Pièce de métal à deux branches, qui s’adapte au talon du cavalier et dont l’extrémité pointue ou portant une molette sert à piquer les flancs du cheval pour le stimuler.", # noqa "(Botanique) Prolongement en forme de tube de la corolle ou du calice (ne concerne parfois qu’un pétale ou sépale particulier).", # noqa @@ -233,7 +262,10 @@ "greffier", ["ɡʁɛ.fje", "ɡʁe.fje"], "m", - "(Nom commun 1) (Date à préciser) Du latin graphiarius (« d’écriture, de style, de poinçon ») ou dérivé de greffe avec le suffixe -ier.", # noqa + [ + "(Nom commun 1) (Date à préciser) Du latin graphiarius (« d’écriture, de style, de poinçon ») ou dérivé de greffe avec le suffixe -ier.", # noqa + "(Nom commun 2) (Date à préciser) Sans doute par jeu de mot avec griffes → voir chat-fourré.", # noqa + ], [ "(Droit) Officier public préposé au greffe.", "(Figuré) Celui qui prend note et tient le registre de ses notes.", @@ -246,7 +278,7 @@ "ich", ["ɪç"], "", - "", + [], ["(Linguistique) Code ISO 639-3 de l’etkywan."], [], ), @@ -254,7 +286,7 @@ "koro", ["kɔʁo"], "m", - "", + [], [ "Langue tibéto-birmane parlée dans l’Arunachal Pradesh (Inde)", "Langue malayo-polynésienne parlée dans les îles de l'Amirauté (Papouasie-Nouvelle-Guinée)", @@ -266,7 +298,7 @@ "mutiner", ["my.ti.ne"], "", - "Dénominal de mutin.", + ["Dénominal de mutin."], [ "Se porter à la sédition, à la révolte.", "Enfant qui se dépite et manque à l’obéissance.", @@ -278,7 +310,7 @@ "naguère", ["na.ɡɛʁ"], "", - "De il n’y a guère (de temps). Voir aussi na.", + ["De il n’y a guère (de temps). Voir aussi na."], [ "Récemment ; il y a peu.", "Il y a longtemps. Note : contrairement à l’étymologie qui implique un temps passé récent, l’usage moderne consacre le sens d’un temps antérieur, lointain, révolu.", # noqa @@ -301,7 +333,9 @@ "précepte", ["pʁe.sɛpt"], "m", - "Emprunté au latin praeceptum (« précepte, leçon, règle »), dérivé de praecipere signifiant « prendre avant, prendre le premier » ou encore « recommander », « conseiller », « prescrire ».", # noqa + [ + "Emprunté au latin praeceptum (« précepte, leçon, règle »), dérivé de praecipere signifiant « prendre avant, prendre le premier » ou encore « recommander », « conseiller », « prescrire »." # noqa + ], [ "Règle ; leçon ; enseignement.", "(Philosophie) Ce qui ne peut pas ne pas être autrement.", @@ -313,7 +347,7 @@ "rance", ["ʁɑ̃s"], "mf", - "Du latin rancidus par l’intermédiaire de l’ancien occitan.", + ["Du latin rancidus par l’intermédiaire de l’ancien occitan."], [ "Se dit des corps gras qui, laissés au contact de l’air, ont pris une odeur forte et un goût désagréable.", # noqa "S’emploie quelquefois comme nom masculin.", @@ -325,7 +359,7 @@ "sapristi", ["sa.pʁis.ti"], "", - "Déformation de sacristi, afin de ne pas blasphémer ouvertement.", + ["Déformation de sacristi, afin de ne pas blasphémer ouvertement."], ["Pour marquer l’étonnement."], [], ), @@ -333,7 +367,9 @@ "silicone", ["si.li.kon"], "f", - "(1863) De l’allemand Silikon, mot créé par Friedrich Wöhler et, pour les équivalents français du mot allemand, dérivé de silicium avec le suffixe -one.", # noqa + [ + "(1863) De l’allemand Silikon, mot créé par Friedrich Wöhler et, pour les équivalents français du mot allemand, dérivé de silicium avec le suffixe -one." # noqa + ], [ "(Chimie) Composé inorganique formés d’une chaine silicium-oxygène (…-Si-O-Si-O-Si-O-…) sur laquelle des groupes se fixent, sur les atomes de silicium.", # noqa ], @@ -343,7 +379,9 @@ "suis", ["sɥi"], "", - "(Forme de verbe 1) De l’ancien français suis (forme du verbe estre), lui-même issu du latin sum (forme du verbe esse).", # noqa + [ + "(Forme de verbe 1) De l’ancien français suis (forme du verbe estre), lui-même issu du latin sum (forme du verbe esse)." # noqa + ], [], ["être", "suivre"], ), diff --git a/tests/test_pt.py b/tests/test_pt.py index 2ed570f68..ae1dfc561 100644 --- a/tests/test_pt.py +++ b/tests/test_pt.py @@ -7,26 +7,26 @@ @pytest.mark.parametrize( "word, pronunciations, genre, etymology, definitions", [ - ("ababalhar", [], "", "De baba.", ["(popular) babar; conspurcar"]), + ("ababalhar", [], "", ["De baba."], ["(popular) babar; conspurcar"]), ( "alguém", ["aw.ˈgẽj"], "", - "Do latim alĭquem (la).", + ["Do latim alĭquem (la)."], ["pessoa não identificada"], ), ( "algo", [], "", - "", + [], ["um pouco, de certo modo", "objeto (não-identificado) de que se fala"], ), ( "baiano", [], "", - "Derivado de Bahia, mais o sufixo ano, com perda do H.", + ["Derivado de Bahia, mais o sufixo ano, com perda do H."], [ "do Estado da Bahia, Brasil", "natural ou habitante do Estado da Bahia, Brasil", @@ -37,7 +37,7 @@ "cabrum", [], "mf", - 'Do latim caprunu (la) "cabra".', + ['Do latim caprunu (la) "cabra".'], [ "(Pecuária) de cabras:", "(Regionalismo, Brasil) marido de mulher adúltera", @@ -48,7 +48,7 @@ "COPOM", [], "m", - "", + [], [ "Centro de Operações da Polícia Militar", "(Brasil) Comitê de Política Monetária", @@ -58,7 +58,7 @@ "dezassete", [], "", - "Contração do latim vulgar decem + ac + septem.", + ["Contração do latim vulgar decem + ac + septem."], [ "o número dezassete (17, XVII)", "nota correspondente a dezassete valores", @@ -70,7 +70,7 @@ "etc", [], "", - "", + [], [ 'abreviação do latim et cetera, que significa "e outros", "e os restantes" e "e outras coisas mais"', # noqa ], @@ -79,7 +79,9 @@ "-ista", [], "", - "Do grego antigo -ιστεσ (-istes) através do latim -ista através do francês antigo -iste.", # noqa + [ + "Do grego antigo -ιστεσ (-istes) através do latim -ista através do francês antigo -iste." # noqa + ], [ "que segue um princípio", "que é estudioso ou profissional de um assunto", @@ -91,18 +93,18 @@ "neo-", [], "", - "Do grego antigo νέος.", + ["Do grego antigo νέος."], [ "exprime a ideia de novo", "Nota: Liga-se por hífen ao morfema seguinte quando este começa por vogal, h, r ou s.", # noqa ], ), - ("para", [], "", "", ["exprime fim, destino, lugar, tempo, direção etc"]), + ("para", [], "", [], ["exprime fim, destino, lugar, tempo, direção etc"]), ( "paulista", [], "", - "", + [], [ "diz-se de pessoa de origem do Estado de São Paulo, Brasil", "diz-se de artigo ou objeto do Estado de São Paulo", @@ -110,12 +112,12 @@ "artigo ou objeto do Estado de São Paulo", ], ), - ("tenui-", [], "", "", ["variante ortográfica de tenu-"]), + ("tenui-", [], "", [], ["variante ortográfica de tenu-"]), ( "to", [], "", - "", + [], [ '(antigo) contração do pronome pessoal "te" com o pronome pessoal ou demonstrativo "o"', "(coloquial e Brasil) forma aferética (muito comum na linguagem falada) de estou", @@ -125,10 +127,12 @@ "ũa", [], "", - "Do Latim una-: una- deu ũa por queda do n com a nasalação do ũ.", + [ + "Do Latim una-: una- deu ũa por queda do n com a nasalação do ũ." + ], ["ortografia antiga de uma"], ), - ("UTC", [], "", "", ["(estrangeirismo) ver TUC"]), + ("UTC", [], "", [], ["(estrangeirismo) ver TUC"]), ], ) def test_parse_word(word, pronunciations, genre, etymology, definitions, page): diff --git a/wikidict/check_word.py b/wikidict/check_word.py index af3186332..320a54aef 100644 --- a/wikidict/check_word.py +++ b/wikidict/check_word.py @@ -138,7 +138,12 @@ def main(locale: str, word: str) -> int: text = get_wiktionary_page(word, locale) if details.etymology: - errors += check(text, details.etymology, " !! Etymology") + for etymology in details.etymology: + if isinstance(etymology, tuple): + for i, sub_etymology in enumerate(etymology, 1): + errors += check(text, sub_etymology, f" !! Etymology {i}") + else: + errors += check(text, etymology, " !! Etymology") index = 1 for definition in details.definitions: diff --git a/wikidict/convert.py b/wikidict/convert.py index fd9234b4c..d5833376e 100644 --- a/wikidict/convert.py +++ b/wikidict/convert.py @@ -16,9 +16,8 @@ from .constants import WORD_FORMAT from .lang import wiktionary -from .stubs import Word, Words +from .stubs import Definitions, Word, Words from .utils import ( - convert_etymology, convert_genre, convert_pronunciation, format_description, @@ -59,8 +58,25 @@ def summary(file: Path) -> None: class KoboBaseFormat(BaseFormat): """Base class for Kobo-related dictionaries.""" + @staticmethod + def create_etymology(etymologies: List[Definitions]) -> str: + """Return the HTML code to include for the etymology of a word.""" + result = "" + if etymologies: + for etymology in etymologies: + if isinstance(etymology, str): + result += f"

{etymology}

" + else: + result += "
    " + for sub_etymology in etymology: + result += f"
  1. {sub_etymology}
  2. " + result += "
" + result += "
" + return result + @staticmethod def create_definitions(details: Word) -> str: + """Return the HTML code to include for the definitions of a word.""" definitions = "" for definition in details.definitions: if isinstance(definition, str): @@ -243,7 +259,7 @@ def save_html( pronunciation = convert_pronunciation(details.pronunciations) genre = convert_genre(details.genre) - etymology = convert_etymology(details.etymology) + etymology = self.create_etymology(details.etymology) var = "" if self.variants.get(word, []): @@ -284,7 +300,7 @@ def process(self) -> None: pronunciation = convert_pronunciation(details.pronunciations) genre = convert_genre(details.genre) - etymology = convert_etymology(details.etymology) + etymology = self.create_etymology(details.etymology) fh.write(f"@ {word}\n") if pronunciation or genre: fh.write(f": {pronunciation.strip()} {genre}\n") diff --git a/wikidict/get_word.py b/wikidict/get_word.py index 87eb259c8..920a7938b 100644 --- a/wikidict/get_word.py +++ b/wikidict/get_word.py @@ -42,7 +42,13 @@ def strip_html(text: str) -> str: ) if details.etymology: - print(strip_html(details.etymology), "\n") + for etymology in details.etymology: + if isinstance(etymology, tuple): + for i, sub_etymology in enumerate(etymology, 1): + print(f"{i}.".rjust(8), strip_html(sub_etymology)) + else: + print(strip_html(etymology)) + print("\n") index = 1 for definition in details.definitions: diff --git a/wikidict/render.py b/wikidict/render.py index 9a7a9ba65..532af3207 100644 --- a/wikidict/render.py +++ b/wikidict/render.py @@ -122,13 +122,18 @@ def find_section_definitions( return definitions -def find_etymology(word: str, locale: str, parsed_section: wtp.Section) -> str: +def find_etymology( + word: str, locale: str, parsed_section: wtp.Section +) -> List[Definitions]: """Find the etymology.""" - + definitions: List[Definitions] = [] etyl: str if locale == "ca": - return process_templates(word, clean(parsed_section.contents), locale) + definitions.append( + process_templates(word, clean(parsed_section.contents), locale) + ) + return definitions elif locale == "en": items = [ @@ -139,11 +144,13 @@ def find_etymology(word: str, locale: str, parsed_section: wtp.Section) -> str: for item in items: etyl = process_templates(word, clean(item), locale) if etyl: - return etyl + definitions.append(etyl) + return definitions elif locale == "es": etyl = parsed_section.get_lists(pattern=("",))[0].items[1] - return process_templates(word, clean(etyl), locale) + definitions.append(process_templates(word, clean(etyl), locale)) + return definitions elif locale == "pt": section_title = parsed_section.title.strip() @@ -158,21 +165,27 @@ def find_etymology(word: str, locale: str, parsed_section: wtp.Section) -> str: etyl = parsed_section.get_lists(pattern=("^:",))[0].items[0] except IndexError: etyl = parsed_section.get_lists(pattern=("",))[0].items[1] - return process_templates(word, clean(etyl), locale) + definitions.append(process_templates(word, clean(etyl), locale)) + return definitions - etymologies = chain.from_iterable( - section.items for section in parsed_section.get_lists() - ) - for etymology in etymologies: - if any( - ignore_me in etymology.lower() - for ignore_me in definitions_to_ignore[locale] - ): - continue - etyl = process_templates(word, clean(etymology), locale) - if etyl: - return etyl - return "" + for section in parsed_section.get_lists(): + for idx, section_item in enumerate(section.items): + if any( + ignore_me in section_item.lower() + for ignore_me in definitions_to_ignore[locale] + ): + continue + definitions.append(process_templates(word, clean(section_item), locale)) + subdefinitions: List[SubDefinitions] = [] + for sublist in section.sublists(i=idx): + for idx2, subcode in enumerate(sublist.items): + subdefinitions.append( + process_templates(word, clean(subcode), locale) + ) + if subdefinitions: + definitions.append(tuple(subdefinitions)) + + return definitions def find_genre(code: str, pattern: Pattern[str]) -> str: @@ -257,7 +270,7 @@ def parse_word(word: str, code: str, locale: str, force: bool = False) -> Word: parsed_sections = find_sections(code, locale) prons = [] nature = "" - etymology = "" + etymology = [] # Etymology sections = etyl_section[locale] diff --git a/wikidict/utils.py b/wikidict/utils.py index 1d6515b81..6878933ad 100644 --- a/wikidict/utils.py +++ b/wikidict/utils.py @@ -52,11 +52,6 @@ } -def convert_etymology(etymology: str) -> str: - """Return the HTML code to include for the etymology of a word.""" - return f"

{etymology}


" if etymology else "" - - def convert_genre(genre: str) -> str: """Return the HTML code to include for the genre of a word.""" return f" {genre}." if genre else ""