Hash partitioning method based on document multilevel structure

By using multi-level structure parsing and tree modeling, double hash calculation, and hierarchical hash index construction, the problems of incomplete multi-level structure parsing and mismatched hash blocks in document segmentation are solved. This achieves efficient and accurate segmentation and difference location of document logical units, improving the accuracy and efficiency of document processing scenarios.

CN121328536APending Publication Date: 2026-01-13SHANGHAI HUIFU PAYMENT CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511489945.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-10-17
Publication Date
2026-01-13

AI Technical Summary

Technical Problem

Existing technologies cannot effectively parse multi-level structures during document segmentation, resulting in a mismatch between hash segmentation and document logical units. They cannot support coarse-grained, fine-grained, and cross-level mixed segmentation in the same process. Furthermore, hash segmentation results cannot quickly locate overall changes or partial modifications to the document, and semantic coherence and traceability are insufficient.

Method used

By using multi-level structure parsing and tree modeling, combined with dual hash calculation and hierarchical hash index construction, and dynamically selecting the block partitioning strategy, a high degree of fit between hash partitioning and document logical units is achieved. Boundary verification is performed using primary hash and secondary hash, and a multi-level hash index is constructed to support multi-level differential positioning.

Benefits of technology

It improves the accuracy and efficiency of document storage, copyright protection and intelligent retrieval, improves the precision of block boundaries, reduces the cross-logical unit splitting rate, improves version comparison efficiency by 60 times, and increases the copyright verification recall rate to 95%.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121328536A_ABST
    Figure CN121328536A_ABST
Patent Text Reader

Abstract

The invention discloses a Hash partitioning method based on a document multilevel structure, which realizes high matching of Hash blocks and document logic units, and improves the accuracy and efficiency in scenes such as document evidence storage, copyright protection, intelligent retrieval and the like. According to the technical scheme, multi-level structure analysis and tree modeling are carried out, wherein a document is analyzed into a'chapter-paragraph-sentence 'three-level structure tree for the first time, and a complete logic unit basis is provided for partitioning; parallel calculation and verification of double Hash: ensuring uniqueness by main Hash, realizing semantic and structure verification by auxiliary Hash, and solving the problem of cross-logic unit splitting; hierarchical hash index construction: constructing a four-level hash index based on a Merkle tree thought, supporting multi-level difference positioning from documents to sentences, and improving comparison and retrieval efficiency; and dynamic partitioning strategy switching: supporting a coarse / fine / mixed partitioning strategy, and adapting to multi-scene requirements of version comparison, copyright verification and the like.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of artificial intelligence technology, and specifically to a hash-based block partitioning method for documents with multi-level structures. Background Technology

[0002] With the explosive growth of digital content, downstream tasks such as document comparison, copyright verification, and intelligent retrieval have an increasingly urgent need for text segmentation that "maintains semantic integrity while supporting rapid location." Traditional fixed-length segmentation methods (such as cutting every N characters) are simple to implement, but they easily fragment logical units such as paragraphs, tables, and formulas, resulting in disjointed semantic segments and large hash value drift, making them unsuitable for high-precision scenarios. In recent years, academia and industry have proposed a series of "structure-aware" improvement schemes, the main idea of ​​which is to adaptively adjust the segmentation boundaries by leveraging the explicit or implicit structural information of the document itself. In summary, existing technologies can be roughly divided into the following three categories:

[0003] (a) Recursive chunking technique based on the natural hierarchy of documents

[0004] This type of method segments documents at the initial granularity of natural logical units such as chapters and paragraphs. If the length of the resulting block exceeds a set threshold, it continues to recursively segment within the block at smaller granularities (such as sentences and sub-paragraphs) until the length constraint is met. For example, it first segments sub-documents by "first-level chapter headings," then segments excessively long sub-documents a second time by "paragraphs," and finally breaks down extremely long paragraphs into sentence-level fragments by "periods and semicolons." Through hierarchical segmentation, this technique preserves the hierarchical relationship of "chapter-paragraph-sentence" to a certain extent and is widely used in the document preprocessing stage of retrieval enhancement generation (RAG) systems.

[0005] However, recursive strategies still essentially use a "length threshold" as the stopping condition, and can only "cut down layer by layer" and cannot "roll up across layers" in the same process. Therefore, it is difficult to flexibly switch between coarse, fine, and mixed granularity according to business scenarios.

[0006] (ii) Hybrid segmentation strategy (coarse-grained segmentation + adaptive adjustment)

[0007] To balance efficiency and semantic integrity, some systems (such as Beihang Easy Dataset) adopt a "coarse-to-fine" process: first, coarse-grained segmentation is performed using line separators or heading labels; then, excessively long blocks are further subdivided using user-defined separators or algorithmic rules, and excessively short segments are merged, supplemented by a visual interface for manual fine-tuning. This approach improves adaptability to structured text such as code and tables through an adaptive mechanism of "segmentation-merging-manual calibration".

[0008] However, its block segmentation logic mainly relies on length thresholds and local features, and does not systematically parse the multi-level hierarchical constraints between "chapter title - subordinate paragraph - nested sentence", which may lead to problems such as truncated cross-paragraph formulas and distorted chapter-paragraph mapping in complex documents.

[0009] (III) Structured segmentation technology based on semantic boundaries

[0010] For unstructured text, existing technologies further incorporate semantic features for boundary determination: in structured documents such as legal provisions and academic papers, the text is segmented according to inherent chapter structures such as "clause number" and "abstract-introduction-conclusion"; in unstructured texts such as novels and reports, topic jumps are detected through semantic similarity between paragraphs (such as cosine distance), and new segments are triggered when the similarity is below a threshold. This method significantly improves the fit between segmentation and content theme.

[0011] However, semantic boundary detection often requires a lot of computing resources and still remains at the single granular level of "paragraph" or "sentence". It lacks systematic utilization of the complete multi-level structure of "chapter-paragraph-sentence", which makes it impossible to support macro (chapter-level) difference positioning and micro (sentence-level) accurate comparison in the same index system at the same time.

[0012] Despite the progress made by the above three types of technologies in "structure-aware segmentation", the following significant drawbacks still exist:

[0013] 1. Incomplete parsing of multi-level structures

[0014] Existing solutions are often limited to a single level (such as only paragraphs or only sentences), lacking a unified parsing of the complete three-level structure of "chapter-paragraph-sentence". This makes it impossible to dynamically support on-demand switching of coarse-grained (chapter level), fine-grained (sentence level) and cross-level hybrid block strategies in the same process.

[0015] 2. Insufficient integration of hash partitioning and structure indexing

[0016] Existing block-based results are mostly used for direct text processing (such as vector embedding and retrieval), failing to deeply integrate block-based processing with hash calculations to generate a "structured hash index". In scenarios such as version comparison and copyright verification, it is impossible to quickly locate whether "overall chapter changes" or "partial modifications within paragraphs" through hash values, resulting in coarse-grained difference location.

[0017] 3. Dynamic boundary determination lacks hierarchical correlation.

[0018] Existing boundary decisions mainly rely on length thresholds or local semantic features, failing to utilize the hierarchical relationships of the document's multi-level structure (such as the logical constraints of chapter titles on subordinate paragraphs). This results in misalignment between block boundaries and the inherent logical units of the document, leading to insufficient semantic coherence and traceability. Summary of the Invention

[0019] The following provides a brief overview of one or more aspects to offer a basic understanding of them. This overview is not an exhaustive summary of all conceived aspects, nor is it intended to identify key or decisive elements of all aspects, nor to define the scope of any or all aspects. Its sole purpose is to present some concepts of one or more aspects in a simplified form to prepare for the more detailed descriptions that follow.

[0020] The purpose of this invention is to solve the above problems and provide a hash block method based on a multi-level document structure. Based on the dynamic hash block and structured index construction of the complete multi-level document structure, the hash block achieves a high degree of fit between the document logical unit and the document, improving the accuracy and efficiency in scenarios such as document evidence preservation, copyright protection, and intelligent retrieval.

[0021] The technical solution of this invention is as follows: This invention discloses a hash block partitioning method based on a multi-level document structure, the method comprising:

[0022] Step 1: Document input, extracting the plain text content and formatting tags of the document;

[0023] Step 2: Multi-level structure parsing, parsing the inherent hierarchical structure of the document, identifying logical unit boundaries, and outputting structured hierarchical information;

[0024] Step 3: Generation of hierarchical structure tree. The structured hierarchical information parsed in Step 2 is organized into a tree data structure to intuitively present the logical relationship of the document in the form of a hierarchical structure tree.

[0025] Step 4: Blocking strategy selection. Receive the output hierarchical structure tree and user configuration parameters. Based on user configuration or scenario requirements, dynamically select a coarse-grained, fine-grained, or hybrid blocking strategy and output the blocking strategy instruction.

[0026] Steps 5 / 6 / 7: Block boundary extraction. Based on the different block strategy instructions in step 4, extract the block boundaries of the corresponding level from the hierarchical structure tree.

[0027] Step 8: Dynamic chunk generation. Receive the chunk boundaries and text content output from Steps 5 / 6 / 7, integrate the boundary extraction results from Steps 5 / 6 / 7 to generate a preliminary chunk set. Each chunk in the set contains: hierarchical path, text content, and boundary marker.

[0028] Step 9: Block hash calculation. Receive the initial block set output from Step 8, generate a primary hash and an auxiliary hash for each block in the set. The primary hash is used as a unique identifier to ensure uniqueness in index construction and is transmitted to Step 10. The auxiliary hash is used as a feature description to support subsequent semantic and structural verification and is transmitted to Step 11.

[0029] Step 10 / 11: Hash value storage, receive the main hash and auxiliary hash output from step 9, temporarily store the main hash and auxiliary hash values ​​to provide data support for subsequent boundary verification, and output the hash value pair to step 12;

[0030] Step 12: Hash-assisted boundary verification. Receive the hash value pairs output from Step 10 / 11 and the hierarchical structure tree output from Step 3. Verify whether the block boundaries conform to the document logical units through the hash values ​​to avoid cross-level / cross-semantic splits. Output the verification results to Step 13.

[0031] Step 13: Block compliance judgment. Based on the verification result output in Step 12, determine whether the block needs to be adjusted: if the verification result is compliant, proceed to Step 15; if the verification result is non-compliant, proceed to the adjustment instruction in Step 14.

[0032] Step 14: Dynamic boundary adjustment. Based on the adjustment instructions and preliminary block set output in Step 13, non-compliant blocks are merged / split, block boundaries are regenerated, and the adjusted block set is obtained. Then, the process returns to the dynamic block generation process in Step 8.

[0033] Step 15: Hierarchical hash index construction. Based on the hash values ​​and hierarchical paths of each block in the compliant block set, construct a multi-level hierarchical hash index structure.

[0034] Step 16: Index metadata supplementation and output. Add metadata to the hierarchical hash index output in Step 15 to generate a complete structured hash index to support fast retrieval of corresponding logical units by hash value.

[0035] Step 17: Output the structured hash index.

[0036] According to an embodiment of the hash block method based on document multi-level structure of the present invention, the structured hierarchical information output in step 2 includes: hierarchical identifier, text content, and format features.

[0037] According to an embodiment of the hash block method based on document multi-level structure of the present invention, the structure of the hierarchical structure tree generated in step 3 is defined as follows: the root node is the entire document, the first-level node is the chapter unit, the second-level node is the paragraph unit, and the leaf node is the sentence unit.

[0038] According to an embodiment of the hash-based block partitioning method for documents based on a multi-level document structure of the present invention, in step 4, the block partitioning strategy instructions include three types: coarse-grained, fine-grained, and mixed-grained. The coarse-grained type is a chapter-level block partitioning instruction, which is suitable for overall document comparison and directly uses chapter nodes as the block partitioning unit. The fine-grained type is a sentence-level block partitioning instruction, which is suitable for precise copyright verification and uses sentence nodes as the smallest block partitioning unit, combined with rolling hashing to split long sentences. The mixed-grained type is a cross-level combination rule, which is suitable for complex documents, using sentence-level block partitioning for core chapters and chapter-level block partitioning for summaries and tables of contents.

[0039] According to an embodiment of the hash-based multi-level document structure hashing method of the present invention, step 5 corresponds to the coarse-grained chapter level, extracting the text content of all chapter nodes, with the boundary being the starting position of the chapter title to the ending position before the next chapter title; step 6 corresponds to the fine-grained sentence level, traversing all sentence nodes, and if the sentence length exceeds the threshold, using rolling hashing to split at the semantic pause; step 7 corresponds to the mixed-grained level, combining different level units through a rule engine.

[0040] According to an embodiment of the hash block method based on a multi-level document structure of the present invention, the verification logic in step 12 includes: intra-block semantic continuity verification, inter-block hierarchical correlation verification, and length reasonableness verification.

[0041] According to an embodiment of the hash block method based on a multi-level document structure of the present invention, the main hash is SHA-256, the first auxiliary hash is SimHash, and the second auxiliary hash is rolling hash.

[0042] According to an embodiment of the hash block method based on a multi-level document structure of the present invention, the hierarchical hash index construction in step 15 is based on a Merkle tree, and the constructed four-level hash index supports multi-level differential localization from document to sentence.

[0043] According to one embodiment of the document-based multilevel structure hash block method of the present invention, a memory, a processor, and program instructions stored in the memory that are executable by the processor are included, wherein the processor executes the program instructions to implement the steps of the document-based multilevel structure hash block method as described above.

[0044] According to one embodiment of the document-based multi-level structure hash block method of the present invention, it stores program instructions executable by a processor to implement the steps of the document-based multi-level structure hash block method as described above.

[0045] Compared with existing technologies, the present invention has the following beneficial effects: The technical solution of the present invention forms a closed-loop technology of "parsing-blocking-verification-indexing": multi-level structure parsing provides a logical basis for blocking, double hash verification ensures the accuracy of block boundaries, hierarchical hash indexing transforms the blocking results into structured data that can be used efficiently, and dynamic strategy switching realizes multi-scenario adaptation; ultimately, it upgrades hash blocking from "text fragment cutting" to "structured hash mapping of document logical units", improving the accuracy and efficiency of document preservation, copyright protection, intelligent retrieval and other fields by 1-2 orders of magnitude compared with traditional technologies.

[0046] In detail, the method of the present invention includes the following four innovative aspects:

[0047] (1) Innovative approach 1: Multi-level structure analysis and tree modeling:

[0048] Technical implementation methods:

[0049] Complete hierarchical parsing: Parsing via XML / Markdown tags (such as...) <h1>-< / h1> <h6>It uses NLP semantic segmentation (based on the HanLP sentence boundary detection model) to extract the three-level inherent structure of "chapter-paragraph-sentence" from the document, breaking through the limitation of traditional methods that only recognize the single level of "paragraph".

[0050] Tree-structured data modeling: The parsed results are constructed into a hierarchical structure tree. The root node is the entire document, the first-level nodes are chapters (including titles and start / end offsets), the second-level nodes are paragraphs (including the number of sentences and character length), and the leaf nodes are sentences (including word segmentation results and semantic vectors). The nodes are associated with each other through parent and child node IDs (e.g., chapter ID "C1" → paragraph ID "C1-P1" → sentence ID "C1-P1-S1").

[0051] Achieved technical effect:

[0052] The chunking logic is deeply bound to the document structure: the chunk boundaries no longer depend on fixed length or a single punctuation mark, but are based on the inherent logical units of the document (such as chapters being indivisible and sentences being the smallest semantic units), making hash chunking completely consistent with the "chapter → paragraph → sentence" logic of human reading habits, reducing the cross-logical unit splitting rate by more than 90% (the traditional fixed-length chunking splitting rate is about 35%-50%).

[0053] Hierarchical path traceability: Each block can be located to a specific level through a tree structure (such as "C2-P3-S2" corresponding to "Chapter 2 - Paragraph 3 - Sentence 2"), providing precise location capabilities for "which level of logical unit has changed" for subsequent version comparisons.

[0054] (2) Innovative approach 2: Dual hash parallel computing and dynamic boundary verification

[0055] Technical implementation methods:

[0056] Primary hash + secondary hash dual-track calculation:

[0057] Master hash (SHA-256): Hash the chunked text to generate a unique identifier (such as a1b2c3...) to ensure the immutability of the chunked content;

[0058] Auxiliary hash (SimHash + rolling hash):

[0059] SimHash: Converts chunked text into 64-bit semantic feature vectors (trained using TF-IDF weighted word vectors) to calculate the semantic similarity (Hamming distance) between adjacent chunks.

[0060] Rolling hash (Rabin-Karp algorithm): Performs sliding window hashing (window size = 50 characters) on long paragraphs (>1000 characters) to generate a hash sequence and identify boundary abrupt changes in special formats such as formulas and code blocks.

[0061] Hash-driven boundary verification mechanism:

[0062] Semantic continuity check: If the SimHash Hamming distance between adjacent sentences is > 3 (preset threshold), it is determined to be a semantic gap, triggering block splitting;

[0063] Hierarchical correlation verification: Using the Merkle tree concept, the chapter hash is recursively generated by aggregating the hashes of the subordinate paragraphs (e.g., chapter hash = SHA-256(paragraph 1 hash + paragraph 2 hash + ...)). If the block hash is not contained in the parent level hash, it is determined as a hierarchical break, and automatic backtracking adjustment is performed.

[0064] Achieved technical effect:

[0065] Improved accuracy of block boundaries: Through SimHash semantic verification, the semantic coherence rate of sentence-level blocks is increased from 75% to 98% of the traditional method; through rolling hash format recognition, the complete block rate of special content (formulas, code blocks) reaches 100% (traditional methods are prone to truncation due to length threshold, with a completeness rate of <60%).

[0066] Deep integration of hash verification and block generation: The hash algorithm is upgraded from a "post-block identification tool" to a "decision core in block generation", dynamically correcting unreasonable boundaries and solving the logical fragmentation problem caused by the traditional "cutting before verification" block generation method.

[0067] (3) Innovative approach 3: Hierarchical hash index construction

[0068] Technical implementation methods:

[0069] Multi-level hash aggregation structure: Constructing a four-level hash index based on a hierarchical structure tree: "Document - Chapter - Paragraph - Sentence".

[0070] Root node: The overall hash of the document (calculated by SHA-256 after concatenating the hashes of all chapters in order), used to quickly determine whether the entire document has been changed;

[0071] Chapter / Paragraph Nodes: Store a hash list and metadata (such as chapter title and paragraph length) for the corresponding level.

[0072] Leaf nodes: store sentence-level master hash, SimHash, and hierarchical path (e.g., "C2-P3-S2").

[0073] Enhanced index metadata: Added block timestamps, version numbers, and inverted indexes (mapping hash values ​​to hierarchical paths), supporting fast retrieval of corresponding logical units by hash value.

[0074] Achieved technical effect:

[0075] Version comparison efficiency is improved exponentially: Through hierarchical hash indexing, version comparison can locate differences layer by layer from the document level to the chapter level, paragraph level, and sentence level, eliminating the need for word-by-word comparison. Experimental data shows that the time to locate version differences in a 100,000-word document is reduced from 30 seconds using traditional methods to 0.5 seconds (a 60-fold improvement).

[0076] Improved accuracy in copyright verification: Infringing fragments can be located down to the sentence level. Combined with SimHash semantic similarity calculation, the recall rate of plagiarism detection reaches 95% (the recall rate of traditional full-text hash-based detection is <70%).

[0077] (4) Innovative approach 4: Dynamic block segmentation strategy switching

[0078] Technical implementation methods:

[0079] Multi-strategy configuration mechanism: Supports user-defined or scenario-adaptive selection of block strategies.

[0080] Coarse-grained segmentation: directly using chapter nodes as the segmentation unit (suitable for document-wide archiving);

[0081] Fine-grained segmentation: Using sentences as the smallest unit, long sentences are split using rolling hashing (suitable for copyright verification);

[0082] Hybrid segmentation: Combining hierarchical units through a rule engine (such as "Summary section → coarse segmentation, Implementation example section → fine segmentation").

[0083] Adaptive strategy logic: Automatically recommends a segmentation strategy based on document type (such as technical papers, novels, code documents, etc.). For example, code documents are segmented by default according to the "function-code block-statement" hierarchy.

[0084] Achieved technical effect:

[0085] Multi-scenario adaptability: One device meets the needs of all scenarios, including "document storage (coarse-grained) - version management (medium-grained) - copyright verification (fine-grained)," without the need to develop separate modules for different scenarios, reducing development costs by 60%.

[0086] Balancing block efficiency and precision: Under the hybrid strategy, the number of blocks is reduced by 40%-60% compared to full fine-grained block partitioning, and the index storage cost is reduced by 50%, while maintaining the block precision of the core logical unit. Attached Figure Description

[0087] The above-described features and advantages of the present invention will be better understood after reading the following detailed description of embodiments of the present disclosure in conjunction with the accompanying drawings. In the drawings, components are not necessarily drawn to scale, and components having similar related characteristics or features may have the same or similar reference numerals.

[0088] Figure 1 A flowchart of an embodiment of the hash block method based on a multi-level document structure of the present invention is shown. Detailed Implementation

[0089] The present invention will now be described in detail with reference to the accompanying drawings and specific embodiments. It should be noted that the aspects described below with reference to the accompanying drawings and specific embodiments are merely exemplary and should not be construed as limiting the scope of protection of the present invention in any way.

[0090] Figure 1 The flowchart of an embodiment of the hash block partitioning method based on a multi-level document structure of the present invention is shown. (See reference...) Figure 1 The implementation steps of the hash block method in this embodiment are detailed below.

[0091] Step 1: Document input.

[0092] It receives the raw document to be processed (binary stream or text format), supporting various formats such as XML, Markdown, PDF, and rich text. It extracts the plain text content and formatting tags (such as heading tags) from the document using a file parsing interface (such as Apache Tika or PDFBox).< / h6> <h1>Paragraph tags (including sentence punctuation, etc.), outputting the original document data.

[0093] Step 2: Multi-level structure analysis.

[0094] Receive the original document data containing text content and formatting tags output from step 1, parse the inherent hierarchical structure of the document ("chapter-paragraph-sentence"), identify logical unit boundaries, and output structured hierarchical information.

[0095] In this step, the parsing process includes tag parsing and NLP word segmentation. Tag parsing identifies format markers (such as # corresponding to chapters and ## corresponding to sub-chapters in Markdown) through regular expression matching or DOM tree traversal. NLP word segmentation uses sentence boundary detection models such as HanLP or Stanford CoreNLP to split paragraphs into sentences (based on punctuation marks such as periods, question marks, and exclamation marks, as well as semantic pause detection).

[0096] The output structured hierarchical information includes: hierarchical identifiers (such as chapter ID, paragraph ID, sentence ID), text content (the original text of each hierarchical unit), and formatting features (such as heading level, paragraph indentation, and sentence punctuation type).

[0097] This step breaks through the traditional "single-level parsing" (such as only recognizing paragraphs), and for the first time realizes fully automatic parsing of the three-level structure of "chapter-paragraph-sentence", providing a complete logical unit foundation for subsequent block segmentation.

[0098] Step 3: Generate the hierarchical structure tree.

[0099] The structured hierarchical information parsed in step 2 is organized into a tree data structure, which intuitively presents the logical relationships of the document in the form of a hierarchical tree structure.

[0100] The structure of a hierarchical tree structure is defined as follows:

[0101] Root node: The entire document (including document ID, total length, and format type);

[0102] First-level node: Chapter unit (including chapter title, start / end position, number of subordinate paragraphs);

[0103] Second-level node: Paragraph unit (including paragraph text, number of sentences, and character length);

[0104] Leaf nodes: Sentence units (including sentence text, word segmentation results, and SimHash feature values).

[0105] Here is an example of a data structure:

[0106]

[0107]

[0108] The role of the hierarchical structure tree is to connect logical units at all levels through its tree structure, providing a basis for "hierarchical path traceability" for the selection of block division strategy (such as subsequent block division can be accurately located to "Chapter C1 - Paragraph P1-1 - Sentence S1-1-1").

[0109] Step 4: Selecting a partitioning strategy.

[0110] The system receives the output hierarchical structure tree and user configuration parameters (such as chunking granularity preferences and maximum chunk length thresholds). Based on user configuration or scenario requirements, it dynamically selects coarse-grained, fine-grained, or hybrid chunking strategies and outputs chunking strategy instructions. This dynamic switching of multiple strategies solves the problem that traditional fixed-granularity chunking cannot adapt to multiple scenarios such as "version comparison—copyright verification—retrieval." The scenario-requirement-corresponding strategy adaptive logic automatically recommends chunking strategies based on document type (such as technical papers, novels, and code documents) (e.g., code documents are chunked by default according to the "function—code block—statement" hierarchy).

[0111] The chunking strategy instruction package includes three levels: coarse-grained, fine-grained, and hybrid-grained. The coarse-grained level consists of chapter-level chunking instructions (including a list of chapter IDs), suitable for overall document comparison (such as detecting chapter additions and deletions between versions), directly using chapter nodes as the chunking unit. The fine-grained level consists of sentence-level chunking instructions (including sentence splitting thresholds), suitable for precise copyright verification (such as sentence-level plagiarism detection), using sentence nodes as the smallest chunking unit, combined with rolling hashing to split long sentences. The hybrid-grained level consists of cross-level combination rules (such as "chapter title + key paragraph + long sentence splitting"), suitable for complex documents (such as technical manuals), using sentence-level chunking for core chapters (such as "examples"), and chapter-level chunking for abstracts and tables of contents.

[0112] Steps 5 / 6 / 7: Extracting block boundaries (coarse / fine / mixed granularity).

[0113] Based on the different partitioning strategy instructions in step 4 (i.e., coarse-grained / fine-grained / mixed-grained), extract the partitioning boundaries of the corresponding level from the hierarchical structure tree.

[0114] Step 5 corresponds to the coarse-grained chapter level, extracting the text content of all chapter nodes, with the boundary being the starting position of the chapter title to the ending position before the next chapter title.

[0115] Step 6 corresponds to the fine-grained sentence level. It iterates through all sentence nodes. If the sentence length exceeds the threshold (e.g., 500 characters), it uses rolling hashing (Rabin-Karp algorithm) to split the sentence at semantic pauses (e.g., commas, semicolons).

[0116] Step 7 corresponds to the mixing level of the mixing granularity, which combines different level units through the rule engine. The following is an example.

[0117]

[0118] Step 8: Dynamic block generation.

[0119] Receive the block boundaries and text content output from steps 5 / 6 / 7, integrate the boundary extraction results from steps 5 / 6 / 7 to generate a preliminary block set. Each block in the set contains: hierarchical path (e.g., "C1-P1-1-S1-1-1"), text content (original text of the block), and boundary marker (start / end character offset).

[0120] The initial chunk generation process includes data cleaning, which involves filtering empty chunks (such as paragraphs with only spaces / line breaks) and merging very small chunks (such as isolated sentences with less than 10 characters).

[0121] Step 9: Block hash calculation.

[0122] The initial block set output from step 8 is received, and a primary hash and an auxiliary hash are generated for each block in the set to support subsequent verification and index construction. The primary hash, such as SHA-256, is used as a unique identifier to ensure uniqueness during index construction and is transmitted to step 10. The auxiliary hash, such as SimHash and rolling hash, is used as a feature description to support subsequent semantic and structural verification and is transmitted to step 11. This "dual-hash parallel computation" mechanism solves the deficiency of traditional single hashes, which can only identify but not verify.

[0123] The process of generating the master hash SHA-256 is as follows: Encrypt the block text using SHA-256 to generate a unique 64-bit string (such as a1b2c3...), used for block uniqueness identification. SHA-256 (Secure Hash Algorithm 256-bit) is a cryptographic hash algorithm defined by the National Institute of Standards and Technology (NIST) in the United States. It belongs to the SHA-2 family and can map input data of arbitrary length to a fixed-length (256-bit) hash value (usually represented as a 64-bit hexadecimal string).

[0124] The generation process of the first auxiliary hash, SimHash, is as follows: After segmenting the text into words, word weights are calculated using TF-IDF to generate 64-bit feature vectors (such as 0101...) for semantic similarity comparison. SimHash (Similarity Hash) is a hash algorithm for measuring the semantic similarity of text. It was proposed by Moses Charikar in 2002. It can map high-dimensional text features into low-dimensional (usually 64-bit or 128-bit) binary vectors and quickly determine text similarity by calculating the Hamming distance (the number of different bits) between vectors.

[0125] The second auxiliary hash, the Rabin-Karp rolling hash, involves dividing long text into blocks and performing sliding window hash calculations (window size = 50 characters) to generate a hash sequence used to locate the optimal split point (e.g., to avoid truncating formulas / code blocks). Rolling hashing is an efficient algorithm for calculating the hash value of string substrings. The Rabin-Karp algorithm is one of the most classic implementations, proposed by Richard M. Karp and Michael O. Rabin in 1987. Its core is used for fast multi-pattern string matching, and its key feature is that it uses a sliding window mechanism to calculate the hash value of all substrings in O(n) time complexity (n is the string length).

[0126] Step 10 / 11: Hash value storage.

[0127] Receive the main hash (corresponding to step 10) and auxiliary hash (corresponding to step 11) output from step 9, temporarily store the main hash and auxiliary hash values ​​to provide data support for subsequent boundary verification, and output hash value pairs to step 12. The format of the hash value pairs is (main hash, SimHash, rolling hash sequence).

[0128] Step 12: Hash-assisted boundary verification.

[0129] Receive the hash value pairs output from step 10 / 11 and the hierarchical structure tree output from step 3. Verify whether the block boundaries conform to the document logical unit through the hash values ​​to avoid cross-level / cross-semantic separation. Output the verification result (compliant / non-compliant) to step 13.

[0130] The verification logic in this step is as follows:

[0131] (1) Intra-block semantic continuity verification (based on SimHash):

[0132] Calculate the SimHash Hamming distance between adjacent blocks (e.g., the SimHash difference between sentences S1 and S2). If the distance is greater than 3 (preset threshold), it is determined as "semantic discontinuity" and triggers the splitting of blocks; if the distance is less than 1, it is determined as "semantic redundancy" and the blocks need to be merged.

[0133] (2) Inter-block hierarchical correlation verification (based on the Merkle tree concept, a tree-like data structure composed of hash values, proposed by Ralph Merkle in 1979. The leaf nodes are the hash values ​​of the original data, the non-leaf nodes are the aggregate hash values ​​of all their child nodes, and the root node is the hash digest of the entire tree. The core is used to efficiently verify data integrity and locate the tampering location):

[0134] Chapter hashes are generated by recursively aggregating the hashes of their subordinate paragraphs:

[0135] Chapter-level block hash = SHA-256 (Paragraph 1 hash + Paragraph 2 hash + ... + Paragraph n hash)

[0136] Paragraph-level block hash = SHA-256 (Sentence 1 hash + Sentence 2 hash + ... + Sentence m hash)

[0137] If a block hash is not included in its parent level hash (e.g., paragraph P1 hash is not included in chapter C1 hash), it is determined as "hierarchical association break", and the boundary is automatically adjusted.

[0138] For long blocks (e.g., > 1000 characters), the system detects local hash mutation points (e.g., hash value jumps at the beginning of formulas) through a rolling hash sequence and automatically splits the blocks at the mutation points.

[0139] Step 13: Block compliance assessment.

[0140] Based on the verification result output in step 12, determine whether the block needs adjustment. That is, if the verification result is compliant, proceed to step 15; if the verification result is non-compliant, execute the adjustment instruction in step 14.

[0141] Step 14: Dynamic adjustment of boundaries.

[0142] Based on the adjustment instructions and preliminary block set output in step 13, non-compliant blocks are merged / split, block boundaries are regenerated, and after obtaining the adjusted block set, the process returns to the dynamic block generation process in step 8, entering a loop of "block generation - hash calculation - verification" until compliance is achieved.

[0143] Here is an example of the adjustment process:

[0144] If SimHash verification finds "semantic gap between sentence S1 and S2", then S1 is set as an independent block and S2 is assigned to the next block;

[0145] If the hierarchy check finds that "paragraph P1 is not contained in chapter C1", then the text of P1 will be reassigned to the correct chapter.

[0146] Step 15: Hierarchical hash index construction.

[0147] Based on the hash values ​​and hierarchical paths of each block in the compliant block set, a multi-level hierarchical hash index structure is constructed:

[0148] Root node: Document overall hash = SHA-256 (ordered concatenation of hashes of all chapters), used to quickly determine whether the entire document has been changed;

[0149] First-level node: Chapter Hash List = [Chapter 1 Hash, Chapter 2 Hash, ...] (Each chapter hash is associated with the chapter title and starting position), used to store the hash list and metadata (such as chapter title, paragraph length) of the corresponding level;

[0150] Second-level node: Paragraph hash list = [Paragraph 1 hash, Paragraph 2 hash, ...] (each paragraph hash is associated with the chapter ID and the number of sentences), used to store the sentence-level master hash, SimHash and hierarchical path (such as "C2-P3-S2");

[0151] Leaf node: Sentence hash = (Main hash, SimHash, Rolling hash sequence) (Associated hierarchical path "Cx-Py-Sz").

[0152] The "document-chapter-paragraph-sentence" four-level hash index in this embodiment, as a multi-level hash aggregation structure, supports multi-level differential location from macro (overall changes to the document) to micro (local modifications to sentences), solving the problem that traditional flat indexes cannot trace logical units.

[0153] An example of a JSON-formatted data structure for this is:

[0154]

[0155]

[0156] Step 16: Index metadata supplementation and output.

[0157] Add metadata to the hierarchical hash index output in step 15 to generate a complete structured hash index, supporting fast retrieval of corresponding logical units by hash value to improve retrieval and comparison efficiency. Metadata includes: block timestamp (generation time), document version number (e.g., V1.0), block statistics (total number of blocks, percentage of blocks at each level), and inverted index (mapping hash values ​​to hierarchical paths to support fast retrieval).

[0158] Step 17: Output the structured hash index.

[0159] The final index will be stored or transmitted to external application systems (such as document storage platforms and copyright verification systems).

[0160] External application scenarios include:

[0161] Version comparison: Compare the root node hash → chapter hash → paragraph hash → sentence hash of two versions of the document to quickly locate the change level (e.g., "Chapter C2 hash changed → Paragraph P2-3 hash changed → Sentence S2-3-2 content modified").

[0162] Copyright verification: The SimHash of suspected infringing documents is compared with the index to quickly identify semantically similar blocks using Hamming distance, and the plagiarized fragments are located by combining hierarchical paths;

[0163] Search acceleration: Based on the inverted index, the logical unit containing the target content can be directly located by the hash value (e.g., "retrieve all chapters containing the hash of sentence S1-1-1").

[0164] Furthermore, this invention also discloses a computer system based on hash-based multi-level document structures. The computer system includes a memory, a processor, and program instructions stored in the memory that are executable by the processor, wherein the processor executes the program instructions to implement, for example... Figure 1 The steps of the hash-based block partitioning method based on a multi-level document structure are shown.

[0165] Furthermore, this invention also discloses a computer-readable storage medium based on hash-blocking of a multi-level document structure, storing program instructions executable by a processor to achieve, for example... Figure 1 The steps of the hash-based block partitioning method based on a multi-level document structure are shown.

[0166] The above-described implementation steps of the present invention include:

[0167] Multi-level structure parsing and tree modeling: For the first time, documents are parsed into a three-level tree structure of "chapter - paragraph - sentence", providing a complete logical unit foundation for block segmentation;

[0168] Parallel computation and verification of dual hashes: The main hash (SHA-256) ensures uniqueness, while the auxiliary hash (SimHash + rolling hash) performs semantic and structural verification, solving the problem of fragmentation across logical units;

[0169] Hierarchical hash index construction: A four-level hash index is built based on the Merkle tree concept, which supports multi-level difference location from document to sentence, improving comparison and retrieval efficiency;

[0170] Dynamic segmentation strategy switching: Supports coarse / fine / hybrid segmentation strategies to adapt to various scenarios such as version comparison and copyright verification.

[0171] Through the above technical solutions, the method of the present invention achieves a high degree of fit between hash block division and document logical units, significantly improving the accuracy and efficiency of document processing scenarios.

[0172] Although the methods described above are illustrated and depicted as a series of actions for the sake of simplicity, it should be understood and appreciated that these methods are not limited by the order of the actions, as some actions may occur in a different order and / or concurrently with other actions from the illustrations and descriptions herein or not illustrated and described herein but which may be understood by those skilled in the art, according to one or more embodiments.

[0173] Those skilled in the art will further appreciate that the various illustrative logic blocks, modules, circuits, and algorithm steps described in conjunction with the embodiments disclosed herein can be implemented as electronic hardware, computer software, or a combination of both. To clearly illustrate this interchangeability between hardware and software, the various illustrative components, blocks, modules, circuits, and steps are described above in a generalized manner in terms of their functionality. Whether such functionality is implemented as hardware or software depends on the specific application and the design constraints imposed on the overall system. Those skilled in the art may implement the described functionality in different ways for each specific application, but such implementation decisions should not be construed as departing from the scope of the invention.

[0174] The various illustrative logic blocks, modules, and circuits described in conjunction with the embodiments disclosed herein can be implemented or performed using a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic device, discrete gate or transistor logic, discrete hardware components, or any combination thereof designed to perform the functions described herein. The general-purpose processor may be a microprocessor, but in alternatives, it may be any conventional processor, controller, microcontroller, or state machine. The processor may also be implemented as a combination of computing devices, such as a combination of a DSP and a microprocessor, multiple microprocessors, one or more microprocessors cooperating with a DSP core, or any other such configuration.

[0175] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein may be embodied directly in hardware, in a software module executed by a processor, or in a combination of both. The software module may reside in RAM memory, flash memory, ROM memory, EPROM memory, EEPROM memory, registers, hard disk, removable disk, CD-ROM, or any other form of storage medium known in the art. An exemplary storage medium is coupled to a processor such that the processor can read and write information to / from the storage medium. In an alternative, the storage medium may be integrated into the processor. The processor and storage medium may reside in an ASIC. The ASIC may reside in a user terminal. In an alternative, the processor and storage medium may reside as discrete components in the user terminal.

[0176] In one or more exemplary embodiments, the described functionality may be implemented in hardware, software, firmware, or any combination thereof. If implemented in software as a computer program product, the functionality may be stored or transmitted as one or more instructions or code on or through a computer-readable medium. A computer-readable medium includes both computer storage media and communication media, encompassing any medium that facilitates the transfer of a computer program from one location to another. A storage medium may be any available medium accessible to a computer. By way of example and not limitation, such a computer-readable medium may include RAM, ROM, EEPROM, CD-ROM or other optical disc storage, disk storage or other magnetic storage devices, or any other medium that can be used to carry or store desired program code in the form of instructions or data structures and is accessible to a computer. Any connection is also legitimately referred to as a computer-readable medium. For example, if the software is transmitted from a website, server, or other remote source using coaxial cable, fiber optic cable, twisted pair, digital subscriber line (DSL), or wireless technologies such as infrared, radio, and microwave, then the coaxial cable, fiber optic cable, twisted pair, DSL, or wireless technologies such as infrared, radio, and microwave are included in the definition of a medium. As used in this article, disk and disc include compact discs (CDs), laser discs, optical discs, digital multi-purpose discs (DVDs), floppy disks, and Blu-ray discs. Disks typically reproduce data magnetically, while discs reproduce data optically using lasers. Combinations of these should also be included within the scope of computer-readable media.

[0177] The prior description of this disclosure is provided to enable any person skilled in the art to make or use this disclosure. Various modifications to this disclosure will be apparent to those skilled in the art, and the general principles defined herein may be applied to other variations without departing from the spirit or scope of this disclosure. Therefore, this disclosure is not intended to be limited to the examples and designs described herein, but should be accorded the widest scope consistent with the principles and novel features disclosed herein. < / h1>

Claims

1. A hash-based block partitioning method based on a multi-level document structure, characterized in that, The methods include: Step 1: Document input, extracting the plain text content and formatting tags of the document; Step 2: Multi-level structure parsing, parsing the inherent hierarchical structure of the document, identifying logical unit boundaries, and outputting structured hierarchical information; Step 3: Generation of hierarchical structure tree. The structured hierarchical information parsed in Step 2 is organized into a tree data structure to intuitively present the logical relationship of the document in the form of a hierarchical structure tree. Step 4: Blocking strategy selection. Receive the output hierarchical structure tree and user configuration parameters. Based on user configuration or scenario requirements, dynamically select a coarse-grained, fine-grained, or hybrid blocking strategy and output the blocking strategy instruction. Steps 5 / 6 / 7: Block boundary extraction. Based on the different block strategy instructions in step 4, extract the block boundaries of the corresponding level from the hierarchical structure tree. Step 8: Dynamic chunk generation. Receive the chunk boundaries and text content output from Steps 5 / 6 / 7, integrate the boundary extraction results from Steps 5 / 6 / 7 to generate a preliminary chunk set. Each chunk in the set contains: hierarchical path, text content, and boundary marker. Step 9: Block hash calculation. Receive the initial block set output from Step 8, generate a primary hash and an auxiliary hash for each block in the set. The primary hash is used as a unique identifier to ensure uniqueness in index construction and is transmitted to Step 10. The auxiliary hash is used as a feature description to support subsequent semantic and structural verification and is transmitted to Step 11. Step 10 / 11: Hash value storage, receive the main hash and auxiliary hash output from step 9, temporarily store the main hash and auxiliary hash values ​​to provide data support for subsequent boundary verification, and output the hash value pair to step 12; Step 12: Hash-assisted boundary verification. Receive the hash value pairs output from Step 10 / 11 and the hierarchical structure tree output from Step 3. Verify whether the block boundaries conform to the document logical units through the hash values ​​to avoid cross-level / cross-semantic splits. Output the verification results to Step 13. Step 13: Block compliance judgment. Based on the verification result output in Step 12, determine whether the block needs to be adjusted: if the verification result is compliant, proceed to Step 15; if the verification result is non-compliant, proceed to the adjustment instruction in Step 14. Step 14: Dynamic boundary adjustment. Based on the adjustment instructions and preliminary block set output in Step 13, non-compliant blocks are merged / split, block boundaries are regenerated, and the adjusted block set is obtained. Then, the process returns to the dynamic block generation process in Step 8. Step 15: Hierarchical hash index construction. Based on the hash values ​​and hierarchical paths of each block in the compliant block set, construct a multi-level hierarchical hash index structure. Step 16: Index metadata supplementation and output. Add metadata to the hierarchical hash index output in Step 15 to generate a complete structured hash index to support fast retrieval of corresponding logical units by hash value. Step 17: Output the structured hash index.

2. The hash block partitioning method based on a multi-level document structure according to claim 1, characterized in that, The structured hierarchical information output in step 2 includes: hierarchical identifier, text content, and formatting features.

3. The hash block partitioning method based on a multi-level document structure according to claim 1, characterized in that, The hierarchical structure tree generated in step 3 is defined as follows: the root node is the entire document, the first-level nodes are chapter units, the second-level nodes are paragraph units, and the leaf nodes are sentence units.

4. The hash block partitioning method based on a multi-level document structure according to claim 1, characterized in that, In step 4, the chunking strategy instruction package includes three types: coarse-grained, fine-grained, and mixed-grained. The coarse-grained instruction is a chapter-level chunking instruction, which is suitable for overall document comparison and directly uses chapter nodes as chunking units. The fine-grained instruction is a sentence-level chunking instruction, which is suitable for precise copyright verification and uses sentence nodes as the smallest chunking unit, combined with rolling hashing to split long sentences. Hybrid granularity is a cross-level combination rule, suitable for complex documents. It uses sentence-level chunking for core chapters and chapter-level chunking for abstracts and tables of contents.

5. The hash block partitioning method based on a multi-level document structure according to claim 4, characterized in that, Step 5 corresponds to the coarse-grained chapter level, extracting the text content of all chapter nodes, with the boundary being the starting position of the chapter title to the ending position before the next chapter title; Step 6 corresponds to the fine-grained sentence level, traversing all sentence nodes, and if the sentence length exceeds the threshold, using rolling hashing to split at semantic pauses; Step 7 corresponds to the mixed-grained level, combining different level units through a rule engine.

6. The hash block partitioning method based on a multi-level document structure according to claim 1, characterized in that, The verification logic in step 12 includes: intra-block semantic continuity verification, inter-block hierarchical correlation verification, and length reasonableness verification.

7. The hash block partitioning method based on a multi-level document structure according to claim 1, characterized in that, The primary hash is SHA-256, the first secondary hash is SimHash, and the second secondary hash is a rolling hash.

8. The hash block partitioning method based on a multi-level document structure according to claim 1, characterized in that, The hierarchical hash index construction in step 15 is based on a Merkle tree, and the constructed four-level hash index supports multi-level differential localization from document to sentence.

9. A computer system based on hash-based multi-level document structure, characterized in that, It includes a memory, a processor, and program instructions stored in the memory that are executable by the processor, wherein the processor executes the program instructions to implement the steps of the hash block method based on a document multilevel structure as described in any one of claims 1 to 8.

10. A computer-readable storage medium based on hash-blocking of a multi-level document structure, characterized in that, It stores program instructions executable by a processor to implement the steps of the hash block method based on a document multilevel structure as described in any one of claims 1 to 8.