88from .text_corpus import TextCorpus
99from .text_corpus_enumerator import TextCorpusEnumerator
1010from .text_row import TextRow , TextRowFlags
11+ from .text_row_content_type import TextRowContentType
1112
1213
1314class _RangeRow :
1415 refs : List [Any ]
1516 segment : List [str ]
1617 is_sentence_start : bool = False
18+ content_type : TextRowContentType = TextRowContentType .SEGMENT
1719
1820 @property
1921 def is_in_range (self ):
@@ -36,6 +38,7 @@ def __init__(self, n: int):
3638 self .text_id = ""
3739 self .versifications : Optional [List [Versification ]] = None
3840 self .row_ref_comparer = None
41+ self .content_type = TextRowContentType .SEGMENT
3942
4043 @property
4144 def is_in_range (self ) -> bool :
@@ -44,6 +47,7 @@ def is_in_range(self) -> bool:
4447 def add_text_row (self , row : TextRow , index : int ):
4548 self .text_id = row .text_id
4649 self .rows [index ].refs .append (row .ref )
50+ self .rows [index ].content_type = row .content_type
4751 if self .rows [index ].is_empty :
4852 self .rows [index ].is_sentence_start = row .is_sentence_start
4953 self .rows [index ].segment .extend (row .segment )
@@ -53,6 +57,7 @@ def create_row(self) -> NParallelTextRow:
5357 reference_refs : List [Any ] = [r .refs [0 ] if len (r .refs ) > 0 else None for r in self .rows if len (r .refs ) > 0 ]
5458 for i in range (len (self .rows )):
5559 row = self .rows [i ]
60+ self .content_type = row .content_type
5661
5762 if (
5863 self .versifications is not None
@@ -62,7 +67,7 @@ def create_row(self) -> NParallelTextRow:
6267 refs [i ] = [cast (ScriptureRef , r ).change_versification (self .versifications [i ]) for r in reference_refs ]
6368 else :
6469 refs [i ] = row .refs .copy ()
65- n_parallel_text_row = NParallelTextRow (self .text_id , refs )
70+ n_parallel_text_row = NParallelTextRow (self .text_id , refs , self . content_type )
6671 n_parallel_text_row .n_segments = [r .segment .copy () for r in self .rows ]
6772 n_parallel_text_row .n_flags = [
6873 TextRowFlags .SENTENCE_START if r .is_sentence_start else TextRowFlags .NONE for r in self .rows
@@ -288,6 +293,7 @@ def _create_rows(
288293 yield range_info .create_row ()
289294
290295 default_refs = [[r .ref for r in rows if r is not None ][0 ]]
296+ content_type = TextRowContentType .SEGMENT
291297
292298 text_id : Optional [str ] = None
293299 refs : List [List [Any ]] = []
@@ -298,6 +304,7 @@ def _create_rows(
298304 for i in range (len (rows )):
299305 row = rows [i ]
300306 if row is not None :
307+ content_type = row .content_type
301308 text_id = text_id or row .text_id
302309 if self .corpora [i ].is_scripture :
303310 refs [i ] = self ._correct_versification ([row .ref ] if row .ref is None else default_refs , i )
@@ -314,7 +321,7 @@ def _create_rows(
314321 )
315322 refs = [r or default_refs for r in refs ]
316323
317- new_row = NParallelTextRow (cast (str , text_id ), refs )
324+ new_row = NParallelTextRow (cast (str , text_id ), refs , content_type )
318325 new_row .n_segments = [r .segment if r is not None else [] for r in rows ]
319326 new_row .n_flags = flags
320327 yield new_row
0 commit comments