langchain/docs/docs
Luke f69695069d
text_splitters: Add HTMLSemanticPreservingSplitter (#25911)
**Description:** 

With current HTML splitters, they rely on secondary use of the
`RecursiveCharacterSplitter` to further chunk the document into
manageable chunks. The issue with this is it fails to maintain important
structures such as tables, lists, etc within HTML.

This Implementation of a HTML splitter, allows the user to define a
maximum chunk size, HTML elements to preserve in full, options to
preserve `<a>` href links in the output and custom handlers.

The core splitting begins with headers, similar to `HTMLHeaderSplitter`.
If these sections exceed the length of the `max_chunk_size` further
recursive splitting is triggered. During this splitting, elements listed
to preserve, will be excluded from the splitting process. This can cause
chunks to be slightly larger then the max size, depending on preserved
length. However, all contextual relevance of the preserved item remains
intact.

**Custom Handlers**: Sometimes, companies such as Atlassian have custom
HTML elements, that are not parsed by default with `BeautifulSoup`.
Custom handlers allows a user to provide a function to be ran whenever a
specific html tag is encountered. This allows the user to preserve and
gather information within custom html tags that `bs4` will potentially
miss during extraction.

**Dependencies:** User will need to install `bs4` in their project to
utilise this class

I have also added in `how_to` and unit tests, which require `bs4` to
run, otherwise they will be skipped.

Flowchart of process:


![HTMLSemanticPreservingSplitter](https://github.com/user-attachments/assets/20873c36-22ed-4c80-884b-d3c6f433f5a7)

---------

Co-authored-by: Bagatur <baskaryan@gmail.com>
Co-authored-by: Chester Curme <chester.curme@gmail.com>
2024-12-19 12:09:22 -05:00
..
_templates Docs: Fixed grammatical mistake (#16858) 2024-02-01 11:28:15 -08:00
additional_resources docs: Update additional_resources/tutorials.mdx (#28005) 2024-12-14 00:21:30 +00:00
changes/changelog docs: Add langchain over time (#21434) 2024-05-10 00:34:35 +00:00
concepts text_splitters: Add HTMLSemanticPreservingSplitter (#25911) 2024-12-19 12:09:22 -05:00
contributing docs: added a link to the taxonomy of labels in the contributing guide for easy access (#28719) 2024-12-18 16:08:18 -05:00
example_data docs[minor]: Add "Build a PDF ingestion and Question/Answering system" tutorial (#22570) 2024-06-05 17:09:28 -07:00
how_to text_splitters: Add HTMLSemanticPreservingSplitter (#25911) 2024-12-19 12:09:22 -05:00
integrations community: tablestore vector store check the dimension of the embedding when writing it to store. (#28812) 2024-12-19 09:30:43 -05:00
troubleshooting/errors docs: Fixed wrong link redirect from JS ToolMessage to Python ToolMes… (#28083) 2024-11-13 10:05:19 -05:00
tutorials docs: correct variable name from formatted_docs to docs_content (#28735) 2024-12-15 22:09:58 -08:00
versions docs: more api ref links, add linting step to prevent more (#28495) 2024-12-04 04:19:42 +00:00
.gitignore
introduction.mdx docs: update intro page (#28639) 2024-12-13 15:24:14 -05:00
people.mdx 👥 Update LangChain people data (#17743) 2024-02-20 18:30:11 -08:00