Home / Function/ _reinsert_preserved_elements() — langchain Function Reference

_reinsert_preserved_elements() — langchain Function Reference

Architecture documentation for the _reinsert_preserved_elements() function in html.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  f7ca6eae_27af_591b_5082_e978259ac965["_reinsert_preserved_elements()"]
  5af47ada_f6e1_33df_ed07_12ca64351fa0["HTMLSemanticPreservingSplitter"]
  f7ca6eae_27af_591b_5082_e978259ac965 -->|defined in| 5af47ada_f6e1_33df_ed07_12ca64351fa0
  5c2975ee_08fc_2de6_69ef_e1ab9fb5ded8["_create_documents()"]
  5c2975ee_08fc_2de6_69ef_e1ab9fb5ded8 -->|calls| f7ca6eae_27af_591b_5082_e978259ac965
  1ad208c7_864b_e6dd_1344_b5ed70211298["_further_split_chunk()"]
  1ad208c7_864b_e6dd_1344_b5ed70211298 -->|calls| f7ca6eae_27af_591b_5082_e978259ac965
  style f7ca6eae_27af_591b_5082_e978259ac965 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/text-splitters/langchain_text_splitters/html.py lines 1046–1060

    def _reinsert_preserved_elements(
        content: str, preserved_elements: dict[str, str]
    ) -> str:
        """Reinserts preserved elements into the content into their original positions.

        Args:
            content: The content where placeholders need to be replaced.
            preserved_elements: Preserved elements to be reinserted.

        Returns:
            The content with placeholders replaced by preserved elements.
        """
        for placeholder, preserved_content in reversed(preserved_elements.items()):
            content = content.replace(placeholder, preserved_content.strip())
        return content

Subdomains

Frequently Asked Questions

What does _reinsert_preserved_elements() do?
_reinsert_preserved_elements() is a function in the langchain codebase, defined in libs/text-splitters/langchain_text_splitters/html.py.
Where is _reinsert_preserved_elements() defined?
_reinsert_preserved_elements() is defined in libs/text-splitters/langchain_text_splitters/html.py at line 1046.
What calls _reinsert_preserved_elements()?
_reinsert_preserved_elements() is called by 2 function(s): _create_documents, _further_split_chunk.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free