def display_document()

in obelics/visualization/web_document_and_filtering_visualization.py [0:0]


    def display_document(self):
        def display_single_doc(doc, subheader_name=None):
            if subheader_name:
                st.subheader(subheader_name)
            texts = doc["texts"]
            images = doc["images"]
            metadata = json.loads(doc["metadata"])
            for text, image, meta in zip(texts, images, metadata):
                if text:
                    st.text(f"{text}\n\n")
                elif image:
                    st.markdown(f"![img]({meta['src']})\n\n")

        if self.current_doc:
            st.header("Document")

            if self.mode == "All original web documents":
                display_single_doc(self.current_doc)

            else:
                display_original_doc = st.checkbox("Display the original document sibe by side", value=True)
                if not display_original_doc:
                    display_single_doc(doc=self.current_doc, subheader_name="Filtered document")
                else:
                    col1, col2 = st.columns(2)
                    with col1:
                        display_single_doc(doc=self.current_doc_original, subheader_name="Original document")
                    with col2:
                        display_single_doc(doc=self.current_doc, subheader_name="Filtered document")