Skip to content

Commit

Permalink
Dictionary ouput: use list form definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
stscoundrel committed Feb 18, 2024
1 parent be185b2 commit 2194360
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions parser/src/parser/entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def definitions_list(self) -> list[str]:
if "1) " not in self.definitions:
return [self.definitions]

lines = []
lines: list[str] = []
line = ""

words = self.definitions.split(" ")
Expand All @@ -77,6 +77,8 @@ def definitions_list(self) -> list[str]:
# Sanity: we want each line to be properly numbered with no jumps.
expected_number = 1

lines = [line for line in lines if len(line)]

for line in lines:
first = line[0]
if first.isnumeric():
Expand All @@ -87,10 +89,10 @@ def definitions_list(self) -> list[str]:

return lines

def to_json(self) -> dict[str, str]:
def to_json(self) -> dict[str, str | list[str]]:
return {
"headword": self.headword,
"definitions": self.definitions,
"definitions": self.definitions_list,
}

@staticmethod
Expand Down

0 comments on commit 2194360

Please sign in to comment.