Skip to content

Commit

Permalink
FreeDict: add some sense support in TEI cit, #529
Browse files Browse the repository at this point in the history
  • Loading branch information
ilius committed Nov 18, 2023
1 parent 106c31f commit 8116a54
Showing 1 changed file with 23 additions and 7 deletions.
30 changes: 23 additions & 7 deletions pyglossary/plugins/freedict.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,9 @@ def writeTransCit(
hf: "T_htmlfile",
elem: "Element",
) -> None:
from lxml import etree as ET
quotes = []
sense = ET.Element(f"{tei}sense")
for child in elem.xpath("child::node()"):
if isinstance(child, str):
child = child.strip()
Expand All @@ -209,21 +211,31 @@ def writeTransCit(
if child.__class__.__name__ == "_Comment":
continue

if child.tag != f"{tei}quote":
log.warning(
f"unknown tag {child.tag!r} inside translation <cit>"
f": {self.tostring(child)}",
)
if child.tag == f"{tei}quote":
quotes.append(child)
continue

if child.tag in (f"{tei}gramGrp", f"{tei}usg", f"{tei}note"):
sense.append(child)
continue

if child.tag == f"{tei}cit":
# TODO
continue

quotes.append(child)
log.warning(
f"unknown tag {child.tag!r} inside translation <cit>"
f": {self.tostring(child)}",
)

self.makeList(
hf,
quotes,
self.writeQuote,
single_prefix="",
)
if next(sense.iterchildren(), False) is not None:
self.writeSense(hf, sense)

def writeDef(
self,
Expand Down Expand Up @@ -622,7 +634,11 @@ def normalizeGramGrpChild(self, elem: "Element") -> str:

if tag == f"{tei}note":
return text
log.warning(f"unrecognize GramGrp child tag: {self.tostring(elem)}")

if tag == f"{tei}colloc":
return ""

log.warning(f"unrecognize GramGrp child tag: {elem.tag!r}: {self.tostring(elem)}")
return ""

def getEntryByElem(
Expand Down

0 comments on commit 8116a54

Please sign in to comment.