1111
1212
1313class _RangeRow :
14- refs : List [object ]
14+ refs : List [Any ]
1515 segment : List [str ]
1616 is_sentence_start : bool = False
1717
@@ -49,8 +49,8 @@ def add_text_row(self, row: TextRow, index: int):
4949 self .rows [index ].segment .extend (row .segment )
5050
5151 def create_row (self ) -> NParallelTextRow :
52- refs : List [List [object ]] = [[] for _ in range (self .n )]
53- reference_refs : List [object ] = [r .refs [0 ] if len (r .refs ) > 0 else None for r in self .rows if len (r .refs ) > 0 ]
52+ refs : List [List [Any ]] = [[] for _ in range (self .n )]
53+ reference_refs : List [Any ] = [r .refs [0 ] if len (r .refs ) > 0 else None for r in self .rows if len (r .refs ) > 0 ]
5454 for i in range (len (self .rows )):
5555 row = self .rows [i ]
5656
@@ -76,12 +76,10 @@ def create_row(self) -> NParallelTextRow:
7676
7777
7878class NParallelTextCorpus (NParallelTextCorpusBase ):
79- def __init__ (
80- self , corpora : Sequence [TextCorpus ], row_ref_comparer : Optional [Callable [[object , object ], int ]] = None
81- ):
79+ def __init__ (self , corpora : Sequence [TextCorpus ], row_ref_comparer : Optional [Callable [[Any , Any ], int ]] = None ):
8280 self ._corpora = corpora
8381 self ._row_ref_comparer = row_ref_comparer if row_ref_comparer is not None else default_row_ref_comparer
84- self .all_rows : Sequence [bool ] = tuple ( False for _ in range (len (corpora )))
82+ self ._all_rows : Sequence [bool ] = [ False for _ in range (len (corpora ))]
8583
8684 def is_tokenized (self , i : int ) -> bool :
8785 return self .corpora [i ].is_tokenized
@@ -95,9 +93,13 @@ def corpora(self) -> Sequence[TextCorpus]:
9593 return list (self ._corpora )
9694
9795 @property
98- def row_ref_comparer (self ) -> Callable [[object , object ], int ]:
96+ def row_ref_comparer (self ) -> Callable [[Any , Any ], int ]:
9997 return self ._row_ref_comparer
10098
99+ @property
100+ def all_rows (self ) -> Sequence [bool ]:
101+ return self ._all_rows
102+
101103 def _get_text_ids_from_corpora (self ) -> Set [str ]:
102104 text_ids : Set [str ] = set ()
103105 all_rows_text_ids : Set [str ] = set ()
@@ -107,7 +109,7 @@ def _get_text_ids_from_corpora(self) -> Set[str]:
107109 else :
108110 text_ids = text_ids .intersection ({text .id for text in self .corpora [i ].texts })
109111
110- if self .all_rows [i ]:
112+ if self ._all_rows [i ]:
111113 all_rows_text_ids = all_rows_text_ids .union ({text .id for text in self .corpora [i ].texts })
112114 text_ids = text_ids .union (all_rows_text_ids )
113115 return text_ids
@@ -129,7 +131,7 @@ def get_rows(self, text_ids: Optional[Iterable[str]] = None) -> Iterable[NParall
129131 def _all_ranges_are_new_ranges (rows : List [TextRow ]):
130132 return all ([True if row .is_range_start or not row .is_in_range else False for row in rows ])
131133
132- def _min_ref_indexes (self , refs : Sequence [object ]) -> Sequence [int ]:
134+ def _min_ref_indexes (self , refs : Sequence [Any ]) -> Sequence [int ]:
133135 min_ref = refs [0 ]
134136 min_ref_indexes = [0 ]
135137 for i in range (len (refs )):
@@ -181,7 +183,7 @@ def _get_rows(self, generators: List[TextCorpusEnumerator]) -> Iterable[NParalle
181183 or len ([i for i in min_ref_indexes if not completed [i ]]) == 1
182184 ):
183185 # then there are some non-min refs or only one incomplete generator
184- if any ([not self .all_rows [i ] for i in non_min_ref_indexes ]) and any (
186+ if any ([not self ._all_rows [i ] for i in non_min_ref_indexes ]) and any (
185187 [not completed [i ] and current_rows [i ].is_in_range for i in min_ref_indexes ]
186188 ):
187189 # At least one of the non-min rows has not been marked as 'all rows'
@@ -231,7 +233,7 @@ def _get_rows(self, generators: List[TextCorpusEnumerator]) -> Iterable[NParalle
231233 if any (
232234 [
233235 current_rows [i ].is_in_range
234- and all ([j == i or not self .all_rows [j ] for j in min_ref_indexes ])
236+ and all ([j == i or not self ._all_rows [j ] for j in min_ref_indexes ])
235237 for i in min_ref_indexes
236238 ]
237239 ):
@@ -271,7 +273,7 @@ def _get_rows(self, generators: List[TextCorpusEnumerator]) -> Iterable[NParalle
271273 if range_info .is_in_range :
272274 yield range_info .create_row ()
273275
274- def _correct_versification (self , refs : List [object ], i : int ) -> List [object ]:
276+ def _correct_versification (self , refs : List [Any ], i : int ) -> List [Any ]:
275277 if any ([not c .is_scripture for c in self .corpora ]) or len (refs ) == 0 :
276278 return refs
277279 return [
@@ -288,7 +290,7 @@ def _create_rows(
288290 default_refs = [[r .ref for r in rows if r is not None ][0 ]]
289291
290292 text_id : Optional [str ] = None
291- refs : List [List [object ]] = []
293+ refs : List [List [Any ]] = []
292294 flags : List [TextRowFlags ] = []
293295 for i in range (self .n ):
294296 refs .append ([])
@@ -342,7 +344,7 @@ def _create_min_ref_rows(
342344 text_rows = [None for _ in range (self .n )]
343345 rows_have_content = False
344346 for i in min_ref_indexes :
345- if not self .all_rows [i ] or i in already_yielded :
347+ if not self ._all_rows [i ] or i in already_yielded :
346348 continue
347349 text_row = current_rows [i ]
348350 text_rows [i ] = text_row
0 commit comments