Skip to content

Commit

Permalink
Merge pull request #22 from takuyaa/table-column-texts
Browse files Browse the repository at this point in the history
Implement texts() method for TableColumn
  • Loading branch information
takuyaa authored Jan 14, 2024
2 parents a933eac + 76579fa commit da356af
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
22 changes: 21 additions & 1 deletion ja_law_parser/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -1859,8 +1859,28 @@ class TableColumn(WithSentences, tag="TableColumn", search_mode="unordered"):
columns: Optional[list["Column"]] = None

def texts(self) -> Generator[str, None, None]:
# TODO Other fields
yield from texts_opt_list_texts(self.parts)
yield from texts_opt_list_texts(self.chapters)
yield from texts_opt_list_texts(self.sections)
yield from texts_opt_list_texts(self.subsections)
yield from texts_opt_list_texts(self.divisions)
yield from texts_opt_list_texts(self.articles)
yield from texts_opt_list_texts(self.paragraphs)
yield from texts_opt_list_texts(self.items)
yield from texts_opt_list_texts(self.subitems1)
yield from texts_opt_list_texts(self.subitems2)
yield from texts_opt_list_texts(self.subitems3)
yield from texts_opt_list_texts(self.subitems4)
yield from texts_opt_list_texts(self.subitems5)
yield from texts_opt_list_texts(self.subitems6)
yield from texts_opt_list_texts(self.subitems7)
yield from texts_opt_list_texts(self.subitems8)
yield from texts_opt_list_texts(self.subitems9)
yield from texts_opt_list_texts(self.subitems10)
yield from texts_opt_list_texts(self.fig_structs)
yield from texts_opt_texts(self.remarks)
yield from texts_opt_list_text(self.sentences)
yield from texts_opt_list_texts(self.columns)


class TableRow(BaseXmlModel, tag="TableRow"):
Expand Down
8 changes: 8 additions & 0 deletions tests/test_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ def test_sentence(self) -> None:
table_column: TableColumn = table_row.table_columns[0]
assert len(table_column.subitems1) == 1
assert table_column.valign == "top"
assert list(table_column.texts()) == [
"イ",
"Subitem1 sentence",
"(1)",
"Subitem2 sentence 1",
"(2)",
"Subitem2 sentence 2",
]

subitem1: Subitem1 = table_column.subitems1[0]
assert subitem1.num == "1"
Expand Down

0 comments on commit da356af

Please sign in to comment.