-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test cases for extract_glosses from Spanish Wiktionary
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
Showing
1 changed file
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |