-
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.
Merge pull request #932 from xxyzz/pt
[pt] add parser function aliases configurations
- Loading branch information
Showing
8 changed files
with
173 additions
and
9 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
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,9 @@ | ||
{ | ||
"parser_function_aliases": { | ||
"#se": "#if", | ||
"#seigual": "#ifeq", | ||
"#seerro": "#iferror", | ||
"#seexiste": "#ifexist", | ||
"#seexpr": "#ifexpr" | ||
} | ||
} |
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
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
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
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
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
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,76 @@ | ||
from unittest import TestCase | ||
|
||
from wikitextprocessor import Wtp | ||
|
||
from wiktextract.config import WiktionaryConfig | ||
from wiktextract.extractor.pt.page import parse_page | ||
from wiktextract.wxr_context import WiktextractContext | ||
|
||
|
||
class TestPtGloss(TestCase): | ||
maxDiff = None | ||
|
||
def setUp(self) -> None: | ||
conf = WiktionaryConfig( | ||
dump_file_lang_code="pt", | ||
capture_language_codes=None, | ||
) | ||
self.wxr = WiktextractContext( | ||
Wtp( | ||
lang_code="pt", | ||
parser_function_aliases=conf.parser_function_aliases, | ||
), | ||
conf, | ||
) | ||
|
||
def test_escopo(self): | ||
self.wxr.wtp.add_page( | ||
"Predefinição:-pt-", | ||
10, | ||
"Português[[Categoria:!Entrada (Português)]]", | ||
) | ||
self.wxr.wtp.add_page( | ||
"Predefinição:Substantivo", | ||
10, | ||
"Substantivo[[Categoria:Substantivo (Português)]]", | ||
) | ||
self.wxr.wtp.add_page( | ||
"Predefinição:escopo", | ||
10, | ||
"""(''<span style="color:navy;">[[Categoria:Português brasileiro]]Brasil e [[Categoria:Coloquialismo (Português)]]popular</span>'')""", | ||
) | ||
data = parse_page( | ||
self.wxr, | ||
"cão", | ||
"""={{-pt-}}= | ||
=={{Substantivo|pt}}== | ||
# {{escopo|pt|Brasil|popular}} [[gênio]] do [[mal]] em geral ("capeta") | ||
#* ''O '''cão''' em forma de gente.''""", | ||
) | ||
self.assertEqual( | ||
data, | ||
[ | ||
{ | ||
"lang": "Português", | ||
"lang_code": "pt", | ||
"pos": "noun", | ||
"pos_title": "Substantivo", | ||
"categories": [ | ||
"!Entrada (Português)", | ||
"Substantivo (Português)", | ||
], | ||
"senses": [ | ||
{ | ||
"categories": [ | ||
"Português brasileiro", | ||
"Coloquialismo (Português)", | ||
], | ||
"glosses": ['gênio do mal em geral ("capeta")'], | ||
"raw_tags": ["Brasil", "popular"], | ||
"examples": [{"text": "O cão em forma de gente."}], | ||
} | ||
], | ||
"word": "cão", | ||
} | ||
], | ||
) |