Skip to content

Commit

Permalink
Add test cases for extract_glosses from Spanish Wiktionary
Browse files Browse the repository at this point in the history
This work is a contribution to the EWOK project, which receives funding from LABEX ASLAN (ANR–10–LABX–0081) at the Université de Lyon, as part of the "Investissements d'Avenir" program initiated and overseen by the Agence Nationale de la Recherche (ANR) in France.
  • Loading branch information
empiriker committed Nov 23, 2023
1 parent a821647 commit fbe7a3f
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions tests/test_es_gloss.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import unittest

from wikitextprocessor import Wtp, NodeKind

from wiktextract.page import clean_node
from wiktextract.config import WiktionaryConfig
from wiktextract.wxr_context import WiktextractContext


class TestESGloss(unittest.TestCase):
def setUp(self) -> None:
self.wxr = WiktextractContext(
Wtp(lang_code="es"),
WiktionaryConfig(dump_file_lang_code="es"),
)

def tearDown(self) -> None:
self.wxr.wtp.close_db_conn()

def test_es_extract_glosses(self):
# https://es.wiktionary.org/wiki/amor
self.wxr.wtp.start_page("")

root = self.wxr.wtp.parse(
";1 {{sentimientos}}: {{plm|sentimiento}} [[afectivo]] de [[atracción]], [[unión]] y [[afinidad]] que se experimenta hacia una persona, animal o cosa"
)

print(root)
self.assertEqual(root.children[0].kind, NodeKind.LIST)

gloss_text = clean_node(self.wxr, {}, root.children[0].children)

self.assertIn("afectivo de atracción", gloss_text)

def test_es_extract_glosses_2(self):
# https://es.wiktionary.org/wiki/ayudar
self.wxr.wtp.start_page("")

root = self.wxr.wtp.parse(
""";1: {{plm|contribuir}} [[esfuerzo]] o [[recurso]]s para la [[realización]] de algo.
{{sinónimo|asistir|auxiliar|colaborar|favorecer|arrimar el hombro|echar una mano|tender la mano|echar un cable|echar un capote|ir a una|socorrer la plaza}}
{{antónimo|estorbar}}
:*'''Ejemplos:'''
::"este comedio llegaron quatro naos de Portugal, e mosén Charles rogó al capitán que le ''ayudase'' a tomarlas, por quanto heran henemigos de Françia, que ayudavan a los yngleses. " Díaz de Games, Gutierre (1994 [1449]) ''El Victorial''. Madrid: Taurus, p. 429"""
)

print(root)

0 comments on commit fbe7a3f

Please sign in to comment.