@@ -203,9 +203,9 @@ def get_text_and_words(
203203 )
204204 if config .add_prefixes_and_suffixes_as_words :
205205 final_words = (
206- ([Word (str (uuid .uuid4 ()), BoundingBox .enclosing_bbox (final_words ), config .header_prefix , is_structure = True )] if config .title_prefix else []) +
206+ ([Word (str (uuid .uuid4 ()), BoundingBox .enclosing_bbox (final_words ), config .header_prefix , is_structure = True )] if config .header_prefix else []) +
207207 final_words +
208- ([Word (str (uuid .uuid4 ()), BoundingBox .enclosing_bbox (final_words ), config .header_suffix , is_structure = True )] if config .title_suffix else [])
208+ ([Word (str (uuid .uuid4 ()), BoundingBox .enclosing_bbox (final_words ), config .header_suffix , is_structure = True )] if config .header_suffix else [])
209209 )
210210 elif self .layout_type == LAYOUT_SECTION_HEADER :
211211 final_text , final_words = linearize_children (
@@ -217,9 +217,9 @@ def get_text_and_words(
217217 )
218218 if config .add_prefixes_and_suffixes_as_words :
219219 final_words = (
220- ([Word (str (uuid .uuid4 ()), BoundingBox .enclosing_bbox (final_words ), config .section_header_prefix , is_structure = True )] if config .title_prefix else []) +
220+ ([Word (str (uuid .uuid4 ()), BoundingBox .enclosing_bbox (final_words ), config .section_header_prefix , is_structure = True )] if config .section_header_prefix else []) +
221221 final_words +
222- ([Word (str (uuid .uuid4 ()), BoundingBox .enclosing_bbox (final_words ), config .section_header_suffix , is_structure = True )] if config .title_suffix else [])
222+ ([Word (str (uuid .uuid4 ()), BoundingBox .enclosing_bbox (final_words ), config .section_header_suffix , is_structure = True )] if config .section_header_suffix else [])
223223 )
224224 elif self .layout_type == LAYOUT_TEXT :
225225 final_text , final_words = linearize_children (
@@ -235,6 +235,29 @@ def get_text_and_words(
235235 is_layout_table = self .layout_type == LAYOUT_TABLE ,
236236 )
237237
238+ if config .add_prefixes_and_suffixes_in_text :
239+ if self .layout_type == LAYOUT_TABLE :
240+ final_text = (
241+ config .table_layout_prefix + final_text + config .table_layout_suffix
242+ )
243+ elif self .layout_type == LAYOUT_KEY_VALUE :
244+ final_text = (
245+ config .table_layout_prefix + final_text + config .table_layout_suffix
246+ )
247+ if config .add_prefixes_and_suffixes_as_words :
248+ if self .layout_type == LAYOUT_TABLE :
249+ final_words = (
250+ ([Word (str (uuid .uuid4 ()), BoundingBox .enclosing_bbox (final_words ), config .table_layout_prefix , is_structure = True )] if config .table_layout_prefix else []) +
251+ final_words +
252+ ([Word (str (uuid .uuid4 ()), BoundingBox .enclosing_bbox (final_words ), config .table_layout_suffix , is_structure = True )] if config .table_layout_suffix else [])
253+ )
254+ elif self .layout_type == LAYOUT_KEY_VALUE :
255+ final_words = (
256+ ([Word (str (uuid .uuid4 ()), BoundingBox .enclosing_bbox (final_words ), config .key_value_layout_prefix , is_structure = True )] if config .key_value_layout_prefix else []) +
257+ final_words +
258+ ([Word (str (uuid .uuid4 ()), BoundingBox .enclosing_bbox (final_words ), config .key_value_layout_suffix , is_structure = True )] if config .key_value_layout_suffix else [])
259+ )
260+
238261 while (
239262 config .layout_element_separator * (config .max_number_of_consecutive_new_lines + 1 ) in final_text
240263 ):
0 commit comments