File tree Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -89,6 +89,9 @@ def to_html(self, add_children=True) -> str:
8989
9090 return result_html
9191
92+ def to_text (self , add_children = True ) -> str :
93+ return BeautifulSoup (self .to_html (), "html.parser" ).get_text ().strip ()
94+
9295 def _construct_attribute_string (self , attributes : dict ) -> str :
9396 return " " .join (
9497 f'{ key } ="{ value } "' if value else f"{ key } " for key , value in attributes .items ()
@@ -481,6 +484,9 @@ def to_html(self, add_children=True) -> str:
481484
482485 return f"<{ self .html_tag_name } { combined_attr_str } />"
483486
487+ def to_text (self , add_children = True ) -> str :
488+ return super ().to_text () + self .text
489+
484490
485491class Checkbox (OntologyElement ):
486492 description : str = Field ("A small box that can be checked or unchecked" , frozen = True )
Original file line number Diff line number Diff line change @@ -96,10 +96,8 @@ def ontology_to_unstructured_elements(
9696 ]
9797 element_class = TYPE_TO_TEXT_ELEMENT_MAP [unstructured_element_class_name ]
9898 html_code_of_ontology_element = ontology_element .to_html ()
99- element_text = (
100- BeautifulSoup (html_code_of_ontology_element , "html.parser" ).get_text ().strip ()
101- )
102- # TODO value attribute from form input should be added to the text
99+ element_text = ontology_element .to_text ()
100+
103101 unstructured_element = element_class (
104102 text = element_text ,
105103 element_id = ontology_element .id ,
You can’t perform that action at this time.
0 commit comments