cur_fs = fs    if fs == cur_fs:        cur_text += c.text    else:        snippets.append((cur_text,cur_fs))        cur_fs = fs        cur_text = c.textsnippets.append((cur_text,cur_fs))# Note: The above logic is very straightforward. One can also add more strategies such as removing duplicate snippets (as# headers/footers in a PDF appear on multiple pages so if we find duplicates it's safe to assume that it is redundant info)from langchain.docstore.document import Documentcur_idx = -1semantic_snippets = []# Assumption: headings have higher font size than their respective contentfor s in snippets:    # if current snippet's font size > previous section's heading => it is a new heading    if not semantic_snippets or s[1] > semantic_snippets[cur_idx].metadata['heading_font']:        metadata={'heading':s[0], 'content_font': 0, 'heading_font': s[1]}        metadata.update(data.metadata)        semantic_snippets.append(Document(page_content='',metadata=metadata))        cur_idx += 1        continue    # if current snippet's font size <= previous section's content => content belongs to the same section (one can also create    # a tree like structure for sub sections if needed but that may require some more thinking and may be data specific)    if not semantic_snippets[cur_idx].metadata['content_font'] or s[1] <= semantic_snippets[cur_idx].metadata['content_font']:        semantic_snippets[cur_idx].page_content += s[0]        semantic_snippets[cur_idx].metadata['content_font'] = max(s[1], semantic_snippets[cur_idx].metadata['content_font'])        continue    # if current snippet's font size > previous section's content but less than previous section's heading than also make a new    # section (e.g. title of a PDF will have the highest font size but we don't want it to subsume all sections)    metadata={'heading':s[0], 'content_font': 0, 'heading_font': s[1]}    metadata.update(data.metadata)    semantic_snippets.append(Document(page_content='',metadata=metadata))
Portable Document Format (PDF), standardized as ISO 32000, is a file format developed by Adobe in 1992 to present documents, including text formatting and images, in a manner independent of application software, hardware, and operating systems.
Portable Document Format (PDF), standardized as ISO 32000, is a file format developed by Adobe in 1992 to present documents, including text formatting and images, in a manner independent of application software, hardware, and operating systems. ->: cur_fs = fs    if fs == cur_fs:        cur_text += c.text    else:        snippets.append((cur_text,cur_fs))        cur_fs = fs        cur_text = c.textsnippets.append((cur_text,cur_fs))# Note: The above logic is very straightforward. One can also add more strategies such as removing duplicate snippets (as# headers/footers in a PDF appear on multiple pages so if we find duplicates it's safe to assume that it is redundant info)from langchain.docstore.document import Documentcur_idx = -1semantic_snippets = []# Assumption: headings have higher font size than their respective contentfor s in snippets:    # if current snippet's font size > previous section's heading => it is a new heading    if not semantic_snippets or s[1] > semantic_snippets[cur_idx].metadata['heading_font']:        metadata={'heading':s[0], 'content_font': 0, 'heading_font': s[1]}        metadata.update(data.metadata)        semantic_snippets.append(Document(page_content='',metadata=metadata))        cur_idx += 1        continue    # if current snippet's font size <= previous section's content => content belongs to the same section (one can also create    # a tree like structure for sub sections if needed but that may require some more thinking and may be data specific)    if not semantic_snippets[cur_idx].metadata['content_font'] or s[1] <= semantic_snippets[cur_idx].metadata['content_font']:        semantic_snippets[cur_idx].page_content += s[0]        semantic_snippets[cur_idx].metadata['content_font'] = max(s[1], semantic_snippets[cur_idx].metadata['content_font'])        continue    # if current snippet's font size > previous section's content but less than previous section's heading than also make a new    # section (e.g. title of a PDF will have the highest font size but we don't want it to subsume all sections)    metadata={'heading':s[0], 'content_font': 0, 'heading_font': s[1]}    metadata.update(data.metadata)    semantic_snippets.append(Document(page_content='',metadata=metadata))