graph-knowledge-doc-parser 0.2.15__tar.gz → 0.2.16__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {graph_knowledge_doc_parser-0.2.15 → graph_knowledge_doc_parser-0.2.16}/PKG-INFO +1 -1
- {graph_knowledge_doc_parser-0.2.15 → graph_knowledge_doc_parser-0.2.16}/kg_doc_parser/workflow_ingest/page_index.py +68 -13
- {graph_knowledge_doc_parser-0.2.15 → graph_knowledge_doc_parser-0.2.16}/kg_doc_parser/workflow_ingest/semantics.py +3 -1
- {graph_knowledge_doc_parser-0.2.15 → graph_knowledge_doc_parser-0.2.16}/pyproject.toml +1 -1
- {graph_knowledge_doc_parser-0.2.15 → graph_knowledge_doc_parser-0.2.16}/README.md +0 -0
- {graph_knowledge_doc_parser-0.2.15 → graph_knowledge_doc_parser-0.2.16}/kg_doc_parser/__init__.py +0 -0
- {graph_knowledge_doc_parser-0.2.15 → graph_knowledge_doc_parser-0.2.16}/kg_doc_parser/cast_hinting.py +0 -0
- {graph_knowledge_doc_parser-0.2.15 → graph_knowledge_doc_parser-0.2.16}/kg_doc_parser/document_ingest_log_config.py +0 -0
- {graph_knowledge_doc_parser-0.2.15 → graph_knowledge_doc_parser-0.2.16}/kg_doc_parser/document_ingester_logger.py +0 -0
- {graph_knowledge_doc_parser-0.2.15 → graph_knowledge_doc_parser-0.2.16}/kg_doc_parser/llm_structured_output.py +0 -0
- {graph_knowledge_doc_parser-0.2.15 → graph_knowledge_doc_parser-0.2.16}/kg_doc_parser/models.py +0 -0
- {graph_knowledge_doc_parser-0.2.15 → graph_knowledge_doc_parser-0.2.16}/kg_doc_parser/ocr.py +0 -0
- {graph_knowledge_doc_parser-0.2.15 → graph_knowledge_doc_parser-0.2.16}/kg_doc_parser/pdf2png.py +0 -0
- {graph_knowledge_doc_parser-0.2.15 → graph_knowledge_doc_parser-0.2.16}/kg_doc_parser/semantic_document_splitting_layerwise_edits.py +0 -0
- {graph_knowledge_doc_parser-0.2.15 → graph_knowledge_doc_parser-0.2.16}/kg_doc_parser/text_processing_utils.py +0 -0
- {graph_knowledge_doc_parser-0.2.15 → graph_knowledge_doc_parser-0.2.16}/kg_doc_parser/utils/__init__.py +0 -0
- {graph_knowledge_doc_parser-0.2.15 → graph_knowledge_doc_parser-0.2.16}/kg_doc_parser/utils/bounded_threadpool_executor.py +0 -0
- {graph_knowledge_doc_parser-0.2.15 → graph_knowledge_doc_parser-0.2.16}/kg_doc_parser/utils/file_loaders.py +0 -0
- {graph_knowledge_doc_parser-0.2.15 → graph_knowledge_doc_parser-0.2.16}/kg_doc_parser/utils/langchain.py +0 -0
- {graph_knowledge_doc_parser-0.2.15 → graph_knowledge_doc_parser-0.2.16}/kg_doc_parser/utils/log.py +0 -0
- {graph_knowledge_doc_parser-0.2.15 → graph_knowledge_doc_parser-0.2.16}/kg_doc_parser/utils/version_chaining.py +0 -0
- {graph_knowledge_doc_parser-0.2.15 → graph_knowledge_doc_parser-0.2.16}/kg_doc_parser/workflow_ingest/__init__.py +0 -0
- {graph_knowledge_doc_parser-0.2.15 → graph_knowledge_doc_parser-0.2.16}/kg_doc_parser/workflow_ingest/_kogwistar.py +0 -0
- {graph_knowledge_doc_parser-0.2.15 → graph_knowledge_doc_parser-0.2.16}/kg_doc_parser/workflow_ingest/adapters.py +0 -0
- {graph_knowledge_doc_parser-0.2.15 → graph_knowledge_doc_parser-0.2.16}/kg_doc_parser/workflow_ingest/cache.py +0 -0
- {graph_knowledge_doc_parser-0.2.15 → graph_knowledge_doc_parser-0.2.16}/kg_doc_parser/workflow_ingest/cli.py +0 -0
- {graph_knowledge_doc_parser-0.2.15 → graph_knowledge_doc_parser-0.2.16}/kg_doc_parser/workflow_ingest/clients.py +0 -0
- {graph_knowledge_doc_parser-0.2.15 → graph_knowledge_doc_parser-0.2.16}/kg_doc_parser/workflow_ingest/demo_harness.py +0 -0
- {graph_knowledge_doc_parser-0.2.15 → graph_knowledge_doc_parser-0.2.16}/kg_doc_parser/workflow_ingest/design.py +0 -0
- {graph_knowledge_doc_parser-0.2.15 → graph_knowledge_doc_parser-0.2.16}/kg_doc_parser/workflow_ingest/handlers.py +0 -0
- {graph_knowledge_doc_parser-0.2.15 → graph_knowledge_doc_parser-0.2.16}/kg_doc_parser/workflow_ingest/layered_contracts.py +0 -0
- {graph_knowledge_doc_parser-0.2.15 → graph_knowledge_doc_parser-0.2.16}/kg_doc_parser/workflow_ingest/layerwise_llm.py +0 -0
- {graph_knowledge_doc_parser-0.2.15 → graph_knowledge_doc_parser-0.2.16}/kg_doc_parser/workflow_ingest/models.py +0 -0
- {graph_knowledge_doc_parser-0.2.15 → graph_knowledge_doc_parser-0.2.16}/kg_doc_parser/workflow_ingest/ocr_pipeline.py +0 -0
- {graph_knowledge_doc_parser-0.2.15 → graph_knowledge_doc_parser-0.2.16}/kg_doc_parser/workflow_ingest/parser_core.py +0 -0
- {graph_knowledge_doc_parser-0.2.15 → graph_knowledge_doc_parser-0.2.16}/kg_doc_parser/workflow_ingest/parsing.py +0 -0
- {graph_knowledge_doc_parser-0.2.15 → graph_knowledge_doc_parser-0.2.16}/kg_doc_parser/workflow_ingest/probe.py +0 -0
- {graph_knowledge_doc_parser-0.2.15 → graph_knowledge_doc_parser-0.2.16}/kg_doc_parser/workflow_ingest/providers.py +0 -0
- {graph_knowledge_doc_parser-0.2.15 → graph_knowledge_doc_parser-0.2.16}/kg_doc_parser/workflow_ingest/runners.py +0 -0
- {graph_knowledge_doc_parser-0.2.15 → graph_knowledge_doc_parser-0.2.16}/kg_doc_parser/workflow_ingest/serialization.py +0 -0
- {graph_knowledge_doc_parser-0.2.15 → graph_knowledge_doc_parser-0.2.16}/kg_doc_parser/workflow_ingest/service.py +0 -0
- {graph_knowledge_doc_parser-0.2.15 → graph_knowledge_doc_parser-0.2.16}/kg_doc_parser/workflow_ingest/smoke_assets.py +0 -0
- {graph_knowledge_doc_parser-0.2.15 → graph_knowledge_doc_parser-0.2.16}/kg_doc_parser/workflow_ingest/strategy.py +0 -0
|
@@ -71,7 +71,9 @@ from .semantics import (
|
|
|
71
71
|
HydratedTextPointer,
|
|
72
72
|
SemanticNode,
|
|
73
73
|
compute_pointer_coverage,
|
|
74
|
+
compute_terminal_content_coverage,
|
|
74
75
|
correct_and_validate_pointer,
|
|
76
|
+
validate_semantic_tree_integrity,
|
|
75
77
|
)
|
|
76
78
|
from .serialization import JsonValue
|
|
77
79
|
|
|
@@ -2481,11 +2483,12 @@ def _rebase_page_index_subtree(
|
|
|
2481
2483
|
|
|
2482
2484
|
|
|
2483
2485
|
def _normalize_page_index_unary_nodes(node: SemanticNode) -> SemanticNode:
|
|
2484
|
-
"""Normalize
|
|
2486
|
+
"""Normalize PageIndex unary shapes without losing owned source or descendants.
|
|
2485
2487
|
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2488
|
+
Structural wrappers can be collapsed when their content is carried by
|
|
2489
|
+
descendants. A semantic parent with independent source content retains
|
|
2490
|
+
its real child and gets a source-owning leaf. An unresolved branch fails
|
|
2491
|
+
rather than being silently replaced by an atomic leaf.
|
|
2489
2492
|
"""
|
|
2490
2493
|
|
|
2491
2494
|
pending: list[tuple[SemanticNode, bool]] = [(node, False)]
|
|
@@ -2502,12 +2505,18 @@ def _normalize_page_index_unary_nodes(node: SemanticNode) -> SemanticNode:
|
|
|
2502
2505
|
child = normalized_children[0]
|
|
2503
2506
|
role = str(current.metadata.get("page_index_role", ""))
|
|
2504
2507
|
child_role = str(child.metadata.get("page_index_role", ""))
|
|
2505
|
-
is_document_wrapper =
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
) and
|
|
2509
|
-
|
|
2510
|
-
|
|
2508
|
+
is_document_wrapper = current.node_type == "DOCUMENT_ROOT" or role == "DOCUMENT_ROOT"
|
|
2509
|
+
is_section_wrapper = current.node_type == "PAGE" or role in {"page", "heading_container"}
|
|
2510
|
+
owns_content = not (is_document_wrapper or current.node_type == "PAGE" or role == "page")
|
|
2511
|
+
child_owns_content = bool(child.total_content_pointers) and not (
|
|
2512
|
+
child.node_type in {"DOCUMENT_ROOT", "PAGE"} or child_role == "page"
|
|
2513
|
+
)
|
|
2514
|
+
if (
|
|
2515
|
+
(is_document_wrapper or is_section_wrapper)
|
|
2516
|
+
and (not owns_content or not current.total_content_pointers)
|
|
2517
|
+
and not child_owns_content
|
|
2518
|
+
and len(child.child_nodes) >= 2
|
|
2519
|
+
):
|
|
2511
2520
|
normalized[marker] = current.model_copy(
|
|
2512
2521
|
update={
|
|
2513
2522
|
"child_nodes": _rebase_page_index_subtree(
|
|
@@ -2519,14 +2528,43 @@ def _normalize_page_index_unary_nodes(node: SemanticNode) -> SemanticNode:
|
|
|
2519
2528
|
)
|
|
2520
2529
|
continue
|
|
2521
2530
|
|
|
2531
|
+
if owns_content and current.total_content_pointers:
|
|
2532
|
+
own_content = SemanticNode(
|
|
2533
|
+
node_id=str(stable_id(
|
|
2534
|
+
"workflow_ingest.page_index.owned_content",
|
|
2535
|
+
_stable_part(current.node_id),
|
|
2536
|
+
)),
|
|
2537
|
+
parent_id=current.node_id,
|
|
2538
|
+
node_type=(
|
|
2539
|
+
"HEADING_TEXT" if current.node_type == "HEADING" else current.node_type
|
|
2540
|
+
),
|
|
2541
|
+
title=current.title,
|
|
2542
|
+
summary=current.summary,
|
|
2543
|
+
total_content_pointers=list(current.total_content_pointers),
|
|
2544
|
+
level_from_root=current.level_from_root + 1,
|
|
2545
|
+
metadata={"page_index_role": "owned_content"},
|
|
2546
|
+
)
|
|
2547
|
+
normalized[marker] = current.model_copy(
|
|
2548
|
+
update={
|
|
2549
|
+
"total_content_pointers": [],
|
|
2550
|
+
"child_nodes": [own_content, child],
|
|
2551
|
+
}
|
|
2552
|
+
)
|
|
2553
|
+
continue
|
|
2554
|
+
|
|
2555
|
+
if child.child_nodes:
|
|
2556
|
+
raise ValueError(
|
|
2557
|
+
f"cannot losslessly normalize unary PageIndex subtree at {current.node_id!r}"
|
|
2558
|
+
)
|
|
2559
|
+
|
|
2522
2560
|
metadata = dict(current.metadata)
|
|
2523
2561
|
metadata["atomic_retained"] = True
|
|
2524
2562
|
metadata["unary_normalization"] = "atomic_retained"
|
|
2525
|
-
total_pointers = list(
|
|
2563
|
+
total_pointers = list(child.total_content_pointers)
|
|
2526
2564
|
if not total_pointers:
|
|
2527
|
-
total_pointers = list(current.
|
|
2565
|
+
total_pointers = list(current.total_content_pointers)
|
|
2528
2566
|
if not total_pointers:
|
|
2529
|
-
total_pointers = list(
|
|
2567
|
+
total_pointers = list(current.aggregate_content_pointers)
|
|
2530
2568
|
if not total_pointers:
|
|
2531
2569
|
total_pointers = list(child.aggregate_content_pointers)
|
|
2532
2570
|
metadata["atomic_retained_child"] = {
|
|
@@ -2901,12 +2939,29 @@ def parse_page_index_document(
|
|
|
2901
2939
|
)
|
|
2902
2940
|
|
|
2903
2941
|
semantic_tree = root_node.model_copy(update={"child_nodes": page_nodes})
|
|
2942
|
+
# Check ancestry and source ownership before wrapper normalization. The
|
|
2943
|
+
# normalizer may intentionally reparent a valid structural wrapper; it
|
|
2944
|
+
# must never be allowed to hide a malformed provider parent reference.
|
|
2945
|
+
validate_semantic_tree_integrity(
|
|
2946
|
+
semantic_tree,
|
|
2947
|
+
parser_source_map=parser_source_map,
|
|
2948
|
+
max_depth=max_depth,
|
|
2949
|
+
validate_shape=False,
|
|
2950
|
+
)
|
|
2904
2951
|
semantic_tree = _normalize_page_index_unary_nodes(semantic_tree)
|
|
2905
2952
|
semantic_tree = finalize_semantic_tree(
|
|
2906
2953
|
semantic_tree,
|
|
2907
2954
|
parser_source_map=parser_source_map,
|
|
2908
2955
|
max_depth=max_depth,
|
|
2909
2956
|
)
|
|
2957
|
+
terminal_coverage = compute_terminal_content_coverage(
|
|
2958
|
+
semantic_tree, parser_source_map
|
|
2959
|
+
)
|
|
2960
|
+
if terminal_coverage["valid"] is not True:
|
|
2961
|
+
raise ValueError(
|
|
2962
|
+
"PageIndex terminal source ownership is incomplete or duplicated: "
|
|
2963
|
+
f"{terminal_coverage}"
|
|
2964
|
+
)
|
|
2910
2965
|
coverage = compute_pointer_coverage(
|
|
2911
2966
|
semantic_tree,
|
|
2912
2967
|
cast(dict[str, dict[str, JsonValue]], parser_source_map),
|
|
@@ -280,6 +280,7 @@ def validate_semantic_tree_integrity(
|
|
|
280
280
|
*,
|
|
281
281
|
parser_source_map: Mapping[str, Mapping[str, object]] | None = None,
|
|
282
282
|
max_depth: int | None = None,
|
|
283
|
+
validate_shape: bool = True,
|
|
283
284
|
) -> None:
|
|
284
285
|
"""Validate identity, ancestry, grounding, and branching in one pass.
|
|
285
286
|
|
|
@@ -329,7 +330,8 @@ def validate_semantic_tree_integrity(
|
|
|
329
330
|
pending.append((node, expected_parent_id, depth, True))
|
|
330
331
|
for child in reversed(node.child_nodes):
|
|
331
332
|
pending.append((cast(SemanticIntegrityNodeLike, child), node_id, depth + 1, False))
|
|
332
|
-
|
|
333
|
+
if validate_shape:
|
|
334
|
+
validate_semantic_tree_shape(root, max_depth=max_depth)
|
|
333
335
|
|
|
334
336
|
|
|
335
337
|
def compute_pointer_coverage(
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "graph-knowledge-doc-parser"
|
|
3
|
-
version = "0.2.
|
|
3
|
+
version = "0.2.16"
|
|
4
4
|
description = "doc parser using llm driven engine with graph knowledge awareness"
|
|
5
5
|
authors = ["humblemat810 <67593116+humblemat810@users.noreply.github.com>"]
|
|
6
6
|
readme = "README.md"
|
|
File without changes
|
{graph_knowledge_doc_parser-0.2.15 → graph_knowledge_doc_parser-0.2.16}/kg_doc_parser/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{graph_knowledge_doc_parser-0.2.15 → graph_knowledge_doc_parser-0.2.16}/kg_doc_parser/models.py
RENAMED
|
File without changes
|
{graph_knowledge_doc_parser-0.2.15 → graph_knowledge_doc_parser-0.2.16}/kg_doc_parser/ocr.py
RENAMED
|
File without changes
|
{graph_knowledge_doc_parser-0.2.15 → graph_knowledge_doc_parser-0.2.16}/kg_doc_parser/pdf2png.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{graph_knowledge_doc_parser-0.2.15 → graph_knowledge_doc_parser-0.2.16}/kg_doc_parser/utils/log.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|