Skip to content

Commit

Permalink
Avoid dict-like assignment to pydantic classes in 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 28, 2023
1 parent b3dbc29 commit 2d10d32
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
12 changes: 7 additions & 5 deletions src/wiktextract/extractor/es/gloss.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import re
from typing import List

from wikitextprocessor import NodeKind, WikiNode
from wikitextprocessor.parser import WikiNodeChildrenList

from wiktextract.extractor.es.models import Sense, WordEntry
from wiktextract.page import clean_node
from wiktextract.wxr_context import WiktextractContext
from wikitextprocessor import WikiNode, NodeKind
from wikitextprocessor.parser import WikiNodeChildrenList


def extract_gloss(
Expand Down Expand Up @@ -34,10 +36,10 @@ def extract_gloss(
match = re.match(r"^(\d+)", gloss_note)

if match:
gloss_data["senseid"] = int(match.group(1))
gloss_data.senseid = int(match.group(1))
tag_string = gloss_note[len(match.group(1)) :].strip()
else:
tag_string = gloss_data["tags"] = gloss_note.strip()
tag_string = gloss_data.tags = gloss_note.strip()

# split tags by comma or "y"
tags = re.split(r",|y", tag_string)
Expand All @@ -49,7 +51,7 @@ def extract_gloss(
.removeprefix("Main")
)
if tag:
gloss_data["tags"].append(tag)
gloss_data.tags.append(tag)

if other:
wxr.wtp.debug(
Expand Down
6 changes: 3 additions & 3 deletions src/wiktextract/extractor/es/page.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
from typing import Dict, List

from wikitextprocessor import NodeKind, WikiNode

from wiktextract.datautils import append_base_data
from wiktextract.extractor.es.gloss import extract_gloss
from wiktextract.extractor.es.models import PydanticLogger, WordEntry
from wiktextract.extractor.es.pronunciation import extract_pronunciation
from wiktextract.extractor.es.models import WordEntry, PydanticLogger

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

Expand Down Expand Up @@ -63,7 +63,7 @@ def process_pos_block(
):
pos_type = wxr.config.POS_SUBTITLES[pos_template_name]["pos"]
append_base_data(page_data, "pos", pos_type, base_data)
page_data[-1]["pos_title"] = pos_title
page_data[-1].pos_title = pos_title
child_nodes = list(pos_level_node.filter_empty_str_child())

for child in child_nodes:
Expand Down

0 comments on commit 2d10d32

Please sign in to comment.