-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[it] extract "It-decl-agg*" table templates
- Loading branch information
Showing
5 changed files
with
117 additions
and
2 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
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,30 @@ | ||
from .models import WordEntry | ||
|
||
TABLE_TAGS = { | ||
# https://it.wiktionary.org/wiki/Template:It-decl-agg4 | ||
"singolare": "singular", | ||
"plurale": "plural", | ||
"positivo": "positive", | ||
"superlativo assoluto": ["absolute", "superlative"], | ||
"maschile": "masculine", | ||
"femminile": "feminine", | ||
# https://it.wiktionary.org/wiki/Template:It-decl-agg2 | ||
"m e f": ["masculine", "feminine"], | ||
} | ||
|
||
|
||
TAGS = {**TABLE_TAGS} | ||
|
||
|
||
def translate_raw_tags(data: WordEntry) -> None: | ||
raw_tags = [] | ||
for raw_tag in data.raw_tags: | ||
if raw_tag in TAGS: | ||
tr_tag = TAGS[raw_tag] | ||
if isinstance(tr_tag, str): | ||
data.tags.append(tr_tag) | ||
elif isinstance(tr_tag, list): | ||
data.tags.extend(tr_tag) | ||
else: | ||
raw_tags.append(raw_tag) | ||
data.raw_tags = raw_tags |
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