Document comparison tracing method and device and computer storage medium

By identifying the target text, splitting text fragments and comparing them with differential fragments in the document comparison task, the problem of inaccurate traceability in the existing technology is solved, and a higher accuracy of document comparison traceability is achieved.

CN119808752APending Publication Date: 2025-04-11CHINA MERCHANTS FINANCE HLDG CO LTD
View PDF 0 Cites 4 Cited by

Patent Information

Application Number
CN202411715268.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-27
Publication Date
2025-04-11

AI Technical Summary

Technical Problem

The prior art is difficult to ensure the accuracy of differential traceability in document comparison tasks, especially when using RAG framework-based methods, differential fragments that do not match the original fragment may be output.

Method used

In response to the traceability request for the differential fragment, determine the scope of the differential fragment in the original document, identify the target text, split it into independent text fragments, compare it with the differential fragment, determine the similarity, and return the traceability fragment with the highest similarity and its position coordinates.

Benefits of technology

It significantly improves the accuracy of document comparison and traceability, ensuring that the original text fragments and their specific coordinates of differential fragments in the original document can be accurately returned.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119808752A_ABST
    Figure CN119808752A_ABST
Patent Text Reader

Abstract

The invention discloses a document comparison traceability method and device and a computer storage medium, and relates to the technical field of artificial intelligence, and the method comprises the steps: in response to a traceability request for a difference fragment, determining the range of the difference fragment in an original document according to the difference fragment and a difference position corresponding to the difference fragment, identifying the text in the range as a target text; splitting the target text into independent text segments according to separators, comparing the text segments with the difference segments, and determining the similarity between each text segment and the difference segment; and taking the text fragments with the similarity reaching or exceeding a preset threshold as candidate fragments, determining the text fragment with the highest similarity from the candidate fragments as a tracing fragment, and returning position coordinates of the tracing fragment in the original document. By receiving the traceability requests of the difference fragments and the difference positions and positioning the difference range, the traceability analysis range is effectively reduced, and the accuracy of document comparison traceability is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of artificial intelligence technology, and in particular to a document comparison and tracing method, device and computer storage medium. Background Art

[0002] In the field of document processing and natural language processing, large models excel in understanding and generating text, but lack effective traceability mechanisms when performing document comparison tasks.

[0003] Specifically, current technical frameworks, such as methods based on the RAG (Retrieval-augmented Generation) framework, combine information retrieval and generation models. In the information retrieval stage, the method needs to segment the reference documents and store them in a vector library, and then use vector retrieval technology to match the similarity between the query and the document fragment to locate the most relevant document fragment.

[0004] However, in the document comparison scenario, it is usually necessary to compare and identify the overall differences between two documents rather than looking for fragments that match a single query. The RAG framework is mainly designed to enhance the answering ability of the generative model by retrieving relevant document fragments. It focuses more on the retrieval and utilization of local information rather than global document comparison and difference analysis. Therefore, when trying to apply the RAG framework to a comprehensive comparison between documents, a difference fragment that does not match the original fragment may be output. Therefore, when performing document comparison tasks, the RAG framework has difficulty in ensuring the accuracy of difference tracing. Summary of the invention

[0005] The main purpose of this application is to provide an invention name, aiming to solve the technical problem of how to improve the accuracy of document comparison and tracing.

[0006] To achieve the above purpose, the present application provides a document comparison and tracing method, which includes: In response to a tracing request for a difference segment, determining a range of the difference segment in the original document according to the difference segment and a difference position corresponding to the difference segment, and identifying text within the range as a target text; Splitting the target text into independent text segments according to the separators, and comparing the text segments with the difference segments to determine the similarity between each of the text segments and the difference segments; The text segments whose similarity reaches or exceeds a preset threshold are taken as candidate segments, and from the candidate segments, the text segment with the highest similarity is determined as the source segment, and the position coordinates of the source segment in the original document are returned.

[0007] In one embodiment, before the step of responding to the tracing request for the difference segment, determining the range of the difference segment in the original document according to the difference segment and the difference position corresponding to the difference segment, and identifying the text within the range as the target text, the method includes: receiving a comparison instruction, the comparison instruction including comparison parameters and an original document, and identifying differences between the original documents; Extracting continuous text containing the difference points as difference segments, and determining the difference position of each difference segment in the corresponding original document according to the positioning mark of the original document; The difference fragment and the difference position corresponding to the difference fragment are combined to generate a traceability request.

[0008] In one embodiment, the step of responding to the tracing request for the difference segment, determining the range of the difference segment in the original document according to the difference segment and the difference position corresponding to the difference segment, and identifying the text within the range as the target text, further includes: According to the difference position, locate the corresponding page or paragraph in the original document; The entire text content including the difference position or the difference segment is extracted from the original document as the target text.

[0009] In one embodiment, after the step of responding to the tracing request for the difference segment, determining the range of the difference segment in the original document according to the difference segment and the difference position corresponding to the difference segment, and identifying the text within the range as the target text, the following steps are included: Create a PDF parsing instance, and pass the difference segment and the target text as input parameters to the PDF parsing instance; Using the PDF parsing instance to search and match the target text, and determine the location information and the original text segment corresponding to the difference segment; Each of the difference segments is matched with the corresponding location information and the original segment to generate a tracing result.

[0010] In one embodiment, the step of determining the location information and the original text segment corresponding to the difference segment includes: Through the PDF parsing example, the layout structure of the target text is identified, and all text units in the target text are marked; Matching the difference segment with each of the text units to determine a matching result between the difference segment and each of the text units; Based on the matching result, the successfully matched text unit is used as the original text segment of the difference segment, and the position information of the original text segment in the target text is determined.

[0011] In one embodiment, the step of splitting the target text into independent text segments according to the delimiters, comparing the text segments with the difference segments, and determining the similarity between each of the text segments and the difference segments comprises: Identify delimiters in the target text, and use the delimiters to split the target text into independent text segments; Convert each of the text segments and the difference segments into character sequences respectively, and compare the character sequences of the text segments and the character sequences of the difference segments character by character; Counting the number of character matches and the number of character mismatches at the same position in the character sequence of the text segment and the character sequence of the difference segment; Based on the number of character matches and the number of character mismatches, the similarity between each of the text segments and the difference segment is calculated.

[0012] In one embodiment, the steps of taking the text segments whose similarity reaches or exceeds a preset threshold as candidate segments, determining the text segment with the highest similarity from the candidate segments as the source segment, and returning the position coordinates of the source segment in the original document include: In the target text, the text segments whose similarity reaches or exceeds a first preset threshold are selected as first candidate segments; Based on the first candidate segment, the text segment whose similarity reaches or exceeds a second preset threshold is used as the second candidate segment, and the text segment with the highest similarity in the second candidate segment is determined as the source segment, and the position coordinates of the source segment in the original document are returned.

[0013] In one embodiment, the step of taking the text segment whose similarity reaches or exceeds a second preset threshold as the second candidate segment based on the first candidate segment, determining the text segment with the highest similarity among the second candidate segments as the source segment, and returning the position coordinates of the source segment in the original document, further includes: If there is no text segment whose similarity reaches or exceeds the second preset threshold, respectively obtaining vector representations of the target text and the difference segment; Calculating the semantic similarity between each text segment in the target text and the difference segment; In the target text, a text segment with the highest semantic similarity to the difference segment is determined as the source segment, and the position coordinates of the source segment in the original document are returned.

[0014] An embodiment of the present application also provides a document comparison and tracing device, which includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the document comparison and tracing method described above.

[0015] An embodiment of the present application also provides a computer storage medium, which is a computer-readable storage medium. A computer program is stored on the computer storage medium. When the computer program is executed by a processor, the steps of the document comparison and tracing method described above are implemented.

[0016] The embodiment of the present application discloses a document comparison and tracing method, which responds to a tracing request for a difference segment, determines the range of the difference segment in the original document according to the difference segment and the difference position corresponding to the difference segment, and identifies the text within the range as the target text; splits the target text into independent text segments according to the delimiter, and compares the text segment with the difference segment to determine the similarity between each text segment and the difference segment; takes the text segment whose similarity reaches or exceeds the preset threshold as a candidate segment, and determines the text segment with the highest similarity from the candidate segment as the tracing segment, and returns the position coordinates of the tracing segment in the original document. The present application realizes the precise positioning of the target text by receiving a tracing request containing a difference segment and its position, thereby narrowing the scope of the tracing analysis. On this basis, by comparing and analyzing each text segment in the target text with the difference segment, the similarity between each text segment and the difference segment is determined, and the text segment with the highest similarity is obtained, and used as the tracing segment. Therefore, this application accurately returns the original text segment and its specific coordinates of the difference segment in the original document based on the tracing segment, which significantly improves the accuracy of document comparison and tracing. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] Figure 1 It is a flowchart of the first embodiment of the document comparison and tracing method involved in the embodiment scheme of the present application; Figure 2 This is a flow chart of a second embodiment of a document comparison and tracing method according to an embodiment of the present application; Figure 3 This is a flow chart of a third embodiment of the document comparison and tracing method involved in the embodiment of the present application; Figure 4This is a flow chart of a fourth embodiment of the document comparison and tracing method involved in the embodiment of the present application; Figure 5 This is a schematic diagram of the structure of the traceability equipment for this application document comparison.

[0018] The purpose, features and advantages of this application will be further described in conjunction with the embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION

[0019] It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0020] In the field of document processing and natural language processing, large models excel in understanding and generating text, but lack effective traceability mechanisms when performing document comparison tasks.

[0021] Specifically, current technical frameworks, such as methods based on the RAG (Retrieval-augmented Generation) framework, combine information retrieval and generation models. In the information retrieval stage, the method needs to segment the reference documents and store them in a vector library, and then use vector retrieval technology to match the similarity between the query and the document fragment to locate the most relevant document fragment.

[0022] However, in the document comparison scenario, it is usually necessary to compare and identify the overall differences between two documents rather than looking for fragments that match a single query. The RAG framework is mainly designed to enhance the answering ability of the generative model by retrieving relevant document fragments. It focuses more on the retrieval and utilization of local information rather than global document comparison and difference analysis. Therefore, when trying to apply the RAG framework to a comprehensive comparison between documents, a difference fragment that does not match the original fragment may be output. Therefore, when performing document comparison tasks, the RAG framework has difficulty in ensuring the accuracy of difference tracing.

[0023] In order to solve the above defects in the related art, the embodiment of the present application proposes a document comparison and tracing method, which responds to the tracing request for the difference segment, determines the range of the difference segment in the original document according to the difference segment and the difference position corresponding to the difference segment, and identifies the text within the range as the target text; splits the target text into independent text segments according to the delimiter, and compares the text segment with the difference segment to determine the similarity between each text segment and the difference segment; takes the text segment whose similarity reaches or exceeds the preset threshold as the candidate segment, and determines the text segment with the highest similarity from the candidate segment as the tracing segment, and returns the position coordinates of the tracing segment in the original document. The present application realizes the precise positioning of the target text by receiving the tracing request containing the difference segment and its position, thereby narrowing the scope of the tracing analysis. On this basis, by comparing and analyzing each text segment in the target text with the difference segment, the similarity between each text segment and the difference segment is determined, and the text segment with the highest similarity is obtained as the tracing segment. Therefore, this application accurately returns the original text segment and its specific coordinates of the difference segment in the original document based on the tracing segment, which significantly improves the accuracy of document comparison and tracing.

[0024] It should be noted that the execution subject of this embodiment can be a question-and-answer system, or a computing service device with data processing, network communication and program running functions, such as a tablet computer, a personal computer, a mobile phone, etc., or a document comparison and tracing device capable of realizing the above functions, etc. The following takes the question-and-answer system as an example (hereinafter referred to as the "system") to illustrate this embodiment and the following embodiments.

[0025] The document comparison and tracing method of the first embodiment proposed in this application, please refer to Figure 1 The method comprises steps S10 to S30: Step S10: In response to a tracing request for a difference segment, determining a range of the difference segment in the original document according to the difference segment and a difference position corresponding to the difference segment, and identifying text within the range as a target text.

[0026] In this embodiment, the traceability request refers to an instruction initiated by the user or the system to determine the source of the difference points of the original document through the traceability method. The difference fragments refer to the inconsistent parts of the two original documents to be compared, and these difference fragments are the basis for traceability analysis. The original document may be in PDF format, word format, text format or image format, etc. The difference position indicates the specific location of these difference fragments in the original document, narrowing the scope of traceability analysis.

[0027] Before receiving the traceability request, a comparison instruction is received, which includes comparison parameters and the original document, and the difference points of the original document are identified. The continuous text containing the difference points is extracted as a difference segment, and the difference position of each difference segment in the corresponding original document is determined according to the positioning mark of the original document. The difference segment and the difference position corresponding to the difference segment are combined to generate a traceability request.

[0028] Optionally, a general prompt engineering template is constructed, and the comparison instructions are input into the large model according to the prompt engineering template. The comparison instructions include but are not limited to two original documents to be compared and comparison parameters, such as comparison range, original text segments of difference points, positions of difference points, output format, word count requirements, etc. After receiving the comparison instruction, the large model will analyze the content of the comparison instruction and obtain the comparison requirements of the original documents to be compared. Then the difference points of the original documents are identified, and the continuous text containing the difference points is extracted from the original documents as difference segments, and the difference position information of the corresponding difference segments is obtained, and a comparison answer containing the difference segments and the corresponding difference positions of the difference segments is generated. Finally, a traceability request is generated based on the comparison answer. The comparison answer contains the basic information required to perform traceability analysis, such as the text content of the difference segment, the difference position of the difference segment in the original document, etc.

[0029] It should be noted that the difference segment refers to the part of the text that is identified as having differences between the two original documents. These difference segments may be different from the original text segments in the original text, because the difference segments are extracted to highlight the differences. The difference position points to the specific location of these difference segments in the original document, including page numbers, chapter identifiers and other information, so that when performing source tracing analysis, the approximate range of each difference segment can be located in the original document.

[0030] For example, suppose there is a prompt engineering template, and the content of the template is: "The text of Document 1 is as follows: abcThe text of Document 2 is as follows: abc123. Please point out the differences between Document 1 and Document 2. For each difference point, please provide the original text segment and corresponding position of the difference point in Document 1 and Document 2 respectively". According to the prompt engineering template, a comparison instruction is given and input into the big model. The comparison answer output by the big model is: "The difference segment of Document 1 is 'I am a college student', and the difference position is on page 2; the difference segment of Document 2 is 'I am a graduate student', and the difference position is on page 2". Based on the comparison question and answer, the system will generate a traceability request "Please perform traceability analysis based on the above difference segments and position information to determine the exact position of each difference segment in the original comparison document, including page numbers, paragraph marks and line numbers".

[0031] Optionally, directly submit the original document or paste the text content of the original document through the user interface, and enter the text corresponding to the difference segment and difference position in the original document. Based on the user input, the system automatically generates a traceability request, which is then processed by the traceability analysis component. The traceability request contains the original document submitted by the user, the text content of the difference segment, and the location information of the difference segment in the original document.

[0032] In this embodiment, based on the determined difference position, all text content within the range including the difference position or the difference fragment, such as a page or paragraph, is located in the original document according to the range of the difference position, and all text content within the range is extracted from the original document as the target text, thereby narrowing the scope of the tracing analysis and enabling the tracing analysis to focus on the page text content related to the difference fragment.

[0033] Optionally, the document content is read page by page through a PDF (Portable Document Format) parsing tool, and a specific page range containing the difference fragment is located based on the page number information read. The document object model can also be accessed through a COM (Component Object Model) automation interface or the python-docx library (a document processing library in the Python programming language), and a specific chapter or paragraph containing the difference fragment can be located based on the difference position, such as paragraph number, bookmark mark, etc. All text is extracted from the located specific chapter or paragraph and used as the target text, ensuring that the target text contains the complete context of the difference fragment.

[0034] Optionally, optical character recognition (OCR) technology can be used to pre-process the original document. After pre-processing, the system enables the OCR engine to perform text recognition on the original document. During the recognition process, the OCR engine analyzes the text area according to the layout of the original document, identifies text in different fonts, sizes and formats, and converts it into text information. When extracting the target text, the system locates the text area or text range containing the difference fragment based on the difference position, such as the scanned page number. In order to maintain the contextual integrity of the text, the system will also extract the text content before and after the difference fragment as needed, including the text content of adjacent paragraphs or chapters. Finally, the system uses the extracted text content as the target text.

[0035] Optionally, the system first performs a structural analysis on the original document to identify the hierarchical structure of the original document, including the main directory, subdirectories, chapter titles, and paragraph tags. Based on the structured information and the difference position, the system can quickly determine the chapter range where the difference fragment may be located. Then, according to the difference position, such as the chapter number, page number, or paragraph mark, the entire chapter, or all the text corresponding to the page number, or the paragraph text is extracted according to the start and end positions of the chapter, page number, or paragraph mark. If the difference fragment is located in a specific paragraph, when the system locates the paragraph, it will extract a certain range of text content from before the start position of the paragraph to after the end position of the difference fragment to ensure the contextual integrity of the traceability analysis. In addition, if the difference fragment is located near the page boundary, the system will also extract the text content of the adjacent page to ensure that the contextual information of the difference fragment is fully preserved. Finally, the system uses the extracted text content as the target text.

[0036] Step S20: split the target text into independent text segments according to the separators, and compare the text segments with the difference segments to determine the similarity between each of the text segments and the difference segments.

[0037] In this embodiment, since the difference segment may be different from the original text segment in the original document, it is necessary to compare the extracted text segment of the target text with the difference segment and calculate the similarity between each text segment and the difference segment.

[0038] Specifically, the system first needs to determine the delimiters used to split the target text, including but not limited to line breaks, paragraph marks (such as commas, periods), or other logical delimiters used to organize text in documents. In this way, the target text is divided into multiple independent text fragments, each of which may contain part of the text of the difference fragment. For example, the system uses line breaks to identify different paragraphs in the target text and treats each paragraph as an independent text fragment.

[0039] Next, the system uses a text comparison algorithm to compare the split text segments with the difference segments one by one. During the comparison process, the system calculates the similarity between each text segment and the difference segment. The calculation of similarity can be based on a variety of text analysis methods, including but not limited to string matching algorithms (such as edit distance function), semantic analysis algorithms (such as bag of words model), and sequence alignment algorithms. These algorithms can capture the similarity between texts from different angles. For example, cosine similarity evaluates similarity by calculating the cosine value of the angle between vectors, while edit distance measures similarity by calculating the minimum number of editing operations required to convert one string into another.

[0040] Optionally, the system can use an edit distance function to calculate the similarity between the text segment and the difference segment. Edit distance, also known as Levenshtein distance, is a calculation method used to measure the difference between two sequences. It determines the similarity of two strings by calculating the minimum number of single-character edit operations required to transform one string into another. Edit operations include inserting a character, deleting a character, or replacing a character.

[0041] Specifically, after the system splits the target text into multiple independent text fragments, it further needs to convert these text fragments into a form suitable for string comparison. The system first extracts each text fragment in the target text and converts it into plain text format, removing any possible formatting tags or non-text elements, such as HTML tags, image descriptions, etc. Then, the system cleans the extracted text fragments, including removing leading and trailing blank characters, unifying the case of characters, and processing special characters or symbols to ensure the consistency and comparability of the strings.

[0042] After the preprocessing operation is completed, each text segment is converted into a clean string that contains the entire content of the text segment and does not contain any elements that may interfere with the comparison. Then, the system uses these strings as input and applies the edit distance algorithm to calculate the similarity. The calculation process of the edit distance function is as follows: First, initialize a size The matrix of and are the lengths of the strings for each difference segment and text segment, respectively. Each cell of the matrix represents the minimum edit distance from the prefix of the difference segment to the prefix of the text segment. The calculation process starts from the first row and the first column of the matrix and gradually fills the entire matrix.

[0043] Initialize the first row and column of the matrix, and fill the first row and column of the matrix with values ​​from 0 to the length of the string, representing the edit distance from the difference segment to the empty string and from the empty string to the target text segment, respectively.

[0044] Next, we traverse the remaining cells of the matrix, that is, each character of the two strings. For each cell in the matrix, we calculate the value according to the following rules: If the current characters are the same, the value of the current cell is equal to the value of the upper left cell, so no editing operation is required.

[0045] If the current character is different, the value of the current cell is the minimum value of the three editing operations: the minimum value of the upper left cell (representing a replace operation), the left cell (representing an insert operation), and the upper cell (representing a delete operation) plus one.

[0046] In this way, each cell in the matrix will eventually contain the edit distance between the two substrings that would arrive at that point. Once the entire matrix is ​​populated, the lower right cell will contain the edit distance between the two complete strings. To convert the edit distance to similarity, the system can normalize the edit distance, for example, by subtracting the edit distance from the sum of the two string lengths and then dividing it by the sum of the two string lengths to get a similarity score between 0 and 1, where 0 means completely different and 1 means exactly the same.

[0047] For example, suppose we want to compare the strings "kitten" and "sitting". We need to create a 6x7 matrix and then fill it in according to the above rules. Finally, the cell in the lower right corner of the matrix represents the minimum number of edit operations required to convert "kitten" to "sitting", that is, the edit distance is 3 (replacing "k" with "s", inserting an "i", and replacing "e" with "i"). The similarity score is , indicating that the strings "kitten" and "sitting" have approximately 76.9% similarity.

[0048] Optionally, the system can use a cosine similarity algorithm to calculate the similarity between the text segment and the difference segment. Cosine similarity is a similarity measure that measures the angle between two non-zero vectors. It is often used in text processing to evaluate the similarity of two vectors by calculating the cosine value of the angle between them. In text analysis, cosine similarity can be calculated by converting text into vectors in a vector space.

[0049] After the target text is split into multiple independent text fragments and converted into strings, the system first needs to convert these strings into vectors. This step usually involves vectorization of the text, where each string (a string converted from a text fragment or a difference fragment) is represented as a vector in a high-dimensional space. Vectorization can be achieved through a variety of methods, such as Bag of Words or TF-IDF (Term Frequency-Inverse Document Frequency, a statistical method).

[0050] Once the difference segment and each text segment are converted into vectors, the system can calculate the cosine similarity between them. The formula for calculating cosine similarity is:

[0051] in, Representation vector and vector The dot product of and Represents vectors and vector The modulus (or length) of the two vectors; the dot product calculates the sum of the projections of the two vectors in the same direction, while the modulus normalizes the length of the vectors, ensuring that the similarity is not affected by the size of the vectors.

[0052] By calculating the cosine similarity between the text segment vector and the difference segment vector, the system can obtain a value between -1 and 1, where 1 indicates exactly the same direction (i.e., complete similarity), -1 indicates the exact opposite direction (i.e., complete dissimilarity), and 0 indicates that the vectors are orthogonal and have no similarity.

[0053] In order to convert the cosine similarity into a more intuitive similarity percentage, the system can normalize the calculated cosine value, for example, by adding 1 to the cosine value and dividing it by 2 to obtain a value between 0 and 1, where 0 means completely different and 1 means completely the same.

[0054] For example, if the cosine similarity between the text segment "kitten" and the difference segment "sitting" is 0.4, then the normalized similarity score is , which shows that the similarity between “kitten” and “sitting” is 70%.

[0055] In this way, the system can provide a quantitative assessment of the similarity between each text segment and the difference segment, thereby providing valuable information for traceability analysis.

[0056] Step S30: taking the text segments whose similarity reaches or exceeds a preset threshold as candidate segments, and determining the text segment with the highest similarity from the candidate segments as the source segment, and returning the position coordinates of the source segment in the original document.

[0057] In this embodiment, the system predetermines a preset threshold of similarity, which is predefined and used to determine whether the similarity between the text segment and the difference segment is high enough to screen and determine the text segment most likely to contain the source of the difference as a potential traceability segment. The preset threshold can be adjusted according to specific application scenarios and requirements to ensure the accuracy and flexibility of the screening process.

[0058] The system traverses the similarity scores of all text segments, and selects the text segments whose similarity scores reach or exceed the preset threshold to form a candidate segment list. These candidate segments in the candidate segment list are considered to be text segments that are highly related to the difference segment.

[0059] In the candidate segment list, the system further compares the similarity scores between each candidate segment and the difference segment to find the candidate segment with the highest similarity score. The text segment corresponding to this candidate segment will be determined as the source segment because it is most likely to contain the source information of the difference segment.

[0060] The system records the position coordinates of the traceability fragment in the original document. These position coordinates can be the starting and ending positions at the character level, or they can be line numbers and column numbers, depending on the design of the structure of the original document. The purpose of recording the position coordinates is to quickly locate the specific position of the traceability fragment in the original document during subsequent analysis or presentation.

[0061] Optionally, the system can use an efficient sorting algorithm, such as quick sort or merge sort, to sort the similarity scores of all text segments. After calculating the similarity score between each text segment and the difference segment, these similarity scores are used as the basis for sorting.

[0062] Through the quick sort algorithm, the system can recursively divide the text fragments into two groups: high similarity and low similarity, and finally obtain a list arranged by similarity score.

[0063] Merge sort achieves sorting by dividing text fragments into smaller sublists and gradually merging these sublists, ensuring the stability and efficiency of the sorting.

[0064] Using these sorting algorithms, the system can quickly locate the text segment with the highest similarity to the difference segment, providing an accurate starting point for traceability analysis.

[0065] Optionally, the system can utilize a heap data structure, in particular a max heap, to maintain similarity scores for candidate segments. During the process of calculating similarity scores, the system will continuously update the max heap to ensure that the top of the heap is always the segment with the highest current similarity. Since the heap data structure allows for fast access to the largest element, the system can obtain the text segment with the highest similarity in a constant time, greatly improving retrieval efficiency. This approach is particularly suitable for handling a large number of candidate segments, and can ensure that the system finds the most relevant text segment in the shortest time.

[0066] Optionally, the system can maintain a mapping table that associates each text fragment with its coordinates in the original document. This mapping table can be a hash table or dictionary, where the key is the text fragment and the value is the location information of the text fragment in the original document. Once the source fragment is determined, the system can immediately find the specific location of the source fragment in the original document through the mapping table. This method not only speeds up the location search process, but also improves the efficiency of the overall source analysis. In this way, the system can provide accurate original text location information of the text fragment in the original document, allowing users to quickly locate the specific location of the difference fragment.

[0067] Through the above solution, not only can we ensure that the text segment most similar to the difference segment is found, but we can also improve the processing speed and efficiency, and provide users with accurate and efficient tracing analysis results.

[0068] Please refer to Figure 2 The document comparison and tracing method of the second embodiment proposed in this application, after step S20, includes steps S210 to S230: Step S210: creating a PDF parsing instance, and passing the difference segment and the target text as input parameters to the PDF parsing instance.

[0069] In this embodiment, the PDF parsing instance is a tool specifically used to process PDF format documents, which can read and interpret the structure and content of PDF files.

[0070] The system passes the difference segments and target text as input parameters to the PDF parsing instance. The difference segments are the text parts that are identified to be mismatched between the two original documents to be compared, and the target text is the entire text content within the range that includes these difference segments or difference positions.

[0071] The system can use open source PDF processing libraries such as Apache PDFBox (an open source Java library for processing PDF documents), iText (a Java class library for generating PDF documents), or PDFMiner (a Python library for parsing PDF documents).

[0072] These source PDF processing libraries provide rich APIs (Application Programming Interfaces) that allow programs to read the text content, metadata, structural information, etc. of PDF files and operate at the page level. The system can use the API to create PDF parsing instances and prepare for text retrieval and matching.

[0073] Step S220: searching and matching the target text using the PDF parsing instance to determine the location information and the original text segment corresponding to the difference segment.

[0074] In this embodiment, the system uses the functions of the created PDF parsing instance, such as full-text search or text extraction, to search and match the target text to determine the location information of the difference segment in the target text and the corresponding original text segment. In the full-text search or text extraction process, it may involve page-by-page analysis of the target text to ensure that the difference segment can be accurately located.

[0075] The system can use a text positioning algorithm, such as a text content-based search or a layout analysis-based method, to determine the location of the difference segment. For example, the system can determine the coordinates or page number of the difference segment on the target text by comparing the text content of the difference segment with that of the target text, thereby obtaining the original text location information of the difference segment in the original document.

[0076] It is understood that the position information is the position of the difference segment in the target text, which can be a page number, coordinates (for example, the y position on the page), or other forms of identification of the text on the page; the original text position information refers to the corresponding position of the difference segment in the original document. If the positioning identifier in the target text is consistent with the positioning identifier in the original document, such as based on the same page number system, the position information is consistent with the original text position information.

[0077] Step S230: Match each of the difference segments with the corresponding position information and the original segment to generate a tracing result.

[0078] In this embodiment, the system will associate the difference segment with its corresponding position information in the target text and the original segment based on the analysis result of step S220, and then match the difference segment with the position information and the corresponding original segment to generate a tracing result.

[0079] Or based on the position of the original text segment in the original document, for example, mapping the position information of the target text to the original text position information in the original document, generating a tracing result including the difference segment and the corresponding original text position information and the corresponding original text segment, thereby providing the user with the original coordinates of the difference segment.

[0080] Further, step S220 may include steps S221 to S223: Step S221: identifying the layout structure of the target text through the PDF parsing instance, and marking all text units in the target text.

[0081] In this embodiment, the system identifies the layout structure of the target text through a PDF parsing instance and marks all text units. This step is the basis for understanding the document structure of the original document, and involves using PDF parsing tools to analyze and understand the text arrangement and organization in the original document. The system needs to identify different text units in the original document, such as paragraphs, titles, list items, etc., which is usually achieved by analyzing visual features such as font size, style, spacing, and position of the text. For example, the system can use a deep learning model to identify the boundaries of text lines and words, as well as their relative positions on the page, to build a structured document layout representation.

[0082] Step S222: Match the difference segment with each of the text units to determine a matching result between the difference segment and each of the text units.

[0083] In this embodiment, the difference segment is matched with each identified text unit, and the matching degree (i.e., similarity) between the difference segment and each text unit is determined based on a preset threshold. In this process, a PDF parsing tool is used to calculate the matching result between the difference segment and each text unit.

[0084] It should be noted that when using PDF parsing tools to compare each text unit with the difference segment, there are only two matching results: successful match and unsuccessful match. When the content of the difference segment is consistent with the content of the text segment in the original document, the match is successful; if the content of the difference segment is different from the text segment in the original document, the match fails.

[0085] Step S223: Based on the matching result, the successfully matched text unit is used as the original text segment of the difference segment, and the position information of the original text segment in the target text is determined.

[0086] In this embodiment, when there is a successfully matched text unit in the matching results between the difference segment and each text unit, the successfully matched text unit is used as the original text segment of the difference segment, and based on the position information of the original text segment in the target text, the original text position information of the original text segment in the original document is determined, and the specific coordinates of the difference segment in the original document are output based on the original text position information.

[0087] Please refer to Figure 3 In the document comparison and tracing method of the third embodiment proposed in this application, step S30 further includes steps S310 to S340: Step S310: identifying separators in the target text, and using the separators to split the target text into independent text segments.

[0088] It should be noted that the delimiter can be a line break, a paragraph mark (such as a comma, a period), or other logical delimiters used to organize text in a document. The purpose of splitting the target text into independent text fragments is to cut a long text into smaller, more manageable fragments, so that it can be compared with the difference fragments more accurately.

[0089] The system can use regular expression matching, rule-based methods, or sequence labeling techniques trained by machine learning models to identify and extract text content that conforms to specific patterns. Once the delimiters are identified, the system will segment the continuous text stream into multiple independent text segments based on these delimiters, each of which contains one or more sentences, paragraphs, or terms.

[0090] It should be noted that regular expression matching can match strings in text according to predefined patterns. For example, the system can use regular expressions to match common separators such as line breaks, commas, and periods, and use them as the basis for splitting text.

[0091] In addition, the system can use Natural Language Processing (NLP) technology to identify natural delimiters in the text. For example, syntactic analysis technology can help the system understand the structure of sentences and identify the boundaries between sentences. In this way, the system can not only identify delimiters that are clear by punctuation, but also delimiters that are implied by semantics and context, such as the end and beginning of a paragraph.

[0092] After identifying the delimiters, the system will split the target text into a series of independent text segments based on these delimiters. Each text segment contains a complete semantic unit, such as a sentence or a paragraph.

[0093] Step S320: Convert each of the text segments and the difference segments into character sequences respectively, and compare the character sequences of the text segments and the character sequences of the difference segments character by character.

[0094] In this embodiment, the process of converting to a character sequence may include encoding the text segment and the difference segment into a unified character set, such as UTF-8, to ensure consistency of comparison. Character-by-character comparison can be implemented by a simple loop traversal, or by a more efficient algorithm, such as dynamic programming or rolling hashing (such as the Rabin-Karp algorithm), which can ensure that character-level matching operations can be performed efficiently even in large amounts of text data.

[0095] Step S330: Counting the character sequence of the text segment and the character sequence of the difference segment, the number of matching characters at the same position, and the number of mismatching characters.

[0096] In this embodiment, two counters are maintained, one for recording the number of matched characters and the other for recording the number of unmatched characters. During the comparison process, whenever a character match is found at the same position, the match counter increases; otherwise, if there is no match, the unmatch counter increases.

[0097] Step S340: Calculate the similarity between each of the text segments and the difference segment based on the number of character matches and the number of character mismatches.

[0098] In this embodiment, the similarity calculation can adopt various means, such as a simple matching ratio (number of matching characters divided by total number of characters), the inverse of the Levenshtein distance (edit distance) or other algorithms, such as Jaccard similarity or cosine similarity.

[0099] Please refer to Figure 4 In the document comparison and tracing method of the fourth embodiment proposed in the present application, step S40 further includes steps S410 to S420: Step S410: In the target text, the text segments whose similarity reaches or exceeds a first preset threshold are screened out as first candidate segments.

[0100] In this embodiment, the system will traverse the similarity scores of all text fragments and compare them with a preset first threshold. The first threshold is a predefined similarity level that determines whether the text fragments are similar enough to be considered as potential traceability candidates. The screening method can include a simple conditional judgment statement. If the similarity score of the text fragment is greater than or equal to the threshold, it will be included in the first candidate fragment set. In addition, the system can also use a sorting technique to first sort all text fragments in descending order by similarity score, and then select the N fragments with the highest scores as the first candidate fragments, where N can be adjusted according to actual conditions.

[0101] Step S420: Based on the first candidate segment, the text segment whose similarity reaches or exceeds a second preset threshold is used as the second candidate segment, and the text segment with the highest similarity in the second candidate segment is determined as the source segment, and the position coordinates of the source segment in the original document are returned.

[0102] In this embodiment, the second preset threshold is usually higher than the first threshold to ensure that the second candidate segment selected has higher credibility. After determining the second candidate segment, the system will compare the similarity scores of these candidate segments to find the candidate segment with the highest score. This candidate segment with the highest score will be regarded as the source segment because it is most likely to contain the source of the difference segment.

[0103] Finally, the system will return the coordinates of the source fragment in the original document. These coordinates can be page numbers, line numbers, column numbers, or character offsets, etc.

[0104] Further, step S420 may include steps S421 to S423: Step S421: If there is no text segment whose similarity reaches or exceeds the second preset threshold, vector representations of the target text and the difference segment are obtained respectively.

[0105] Step S422: Calculate the semantic similarity between each text segment in the target text and the difference segment.

[0106] Step S423: in the target text, determine the text segment with the highest semantic similarity to the difference segment as the source segment, and return the position coordinates of the source segment in the original document.

[0107] It should be noted that step S421 is a supplementary measure taken when the similarity of no text segment reaches or exceeds the second preset threshold.

[0108] When there is no screening result under the screening of the second preset threshold, the original text position information of the difference segment in the original document and the corresponding original segment can be determined through semantic similarity matching.

[0109] Specifically, the system can use semantic similarity matching based on the BERT (Bidirectional Encoder Representations from Transformers) model. BERT is a pre-trained deep learning model that is commonly used in the field of natural language processing. The semantic similarity matching process based on BE usually involves the following steps: First, the input text fragment and the difference fragment need to be preprocessed, including splitting the text corresponding to the input text fragment and the difference fragment into words or subwords through a tokenizer. These words or subwords are the basic units that the BERT model can understand and process. Next, in order to indicate the beginning and end of the text of the BERT model, special tags such as [CLS] and [SEP] need to be added at the beginning and end of the text content, respectively. The output vector of the [CLS] tag is usually used as a representation of the entire sentence or paragraph. These tags help the BERT model distinguish the boundaries of sentences. After completing the word segmentation and adding special tags, the word segmentation results are converted into indexes in the model vocabulary, so that the text is converted into a sequence of numbers that the BERT model can process.

[0110] The processed text is then fed into the BERT model to obtain a vector representation of each word or subword. The BERT model outputs a deep, bidirectional, contextualized representation of each word or subword.

[0111] Then, the vector output by the BERT model is used to measure the semantic similarity between the text segment and the difference segment. For example, the cosine similarity between two vectors is calculated to evaluate the directional consistency of the two vectors; or the dot product of the two vectors is directly calculated. The larger the dot product result, the higher the similarity between the two text segments.

[0112] Finally, in the similarity scores calculated in step S422, the highest similarity score is found, and the text segment corresponding to the highest similarity score is identified as the source segment. The position coordinates can be determined by tracking the starting position and ending position of the text segment with the highest similarity score in the original document.

[0113] The present application provides a document comparison and tracing device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the document comparison and tracing method in the above-mentioned embodiment one.

[0114] Reference below Figure 5 , which shows a schematic diagram of the structure of a document comparison and tracing device suitable for implementing the embodiment of the present application. The document comparison and tracing device in the embodiment of the present application may include various hardware and software components for implementing the scheduling method of the inspection task. Figure 5 The document comparison and tracing device shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.

[0115] like Figure 5As shown, the document comparison and tracing device may include a processing device 1001 (such as a central processing unit, a graphics processing unit, etc.), which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM: Read Only Memory) 1002 or the program loaded from the storage device 1003 to the random access memory (RAM: Random Access Memory) 1004. In RAM1004, various programs and data required for the operation of the document comparison and tracing device are also stored. The processing device 1001, ROM1002 and RAM1004 are connected to each other through a bus 1005. The input / output (I / O) interface 1006 is also connected to the bus. Generally, the following systems can be connected to the I / O interface 1006: an input device 1007 including, for example, a touch screen, a touchpad, a keyboard, etc.; an output device 1008 including, for example, a liquid crystal display (LCD: Liquid Crystal Display), a speaker, a vibrator, etc.; a storage device 1003 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 1009. The communication device 1009 can allow the document comparison and tracing device to communicate wirelessly or wired with other devices to exchange data. Although the document comparison and tracing device with various systems is shown in the figure, it should be understood that it is not required to implement or have all the systems shown. More or fewer systems can be implemented or have alternatively.

[0116] In particular, according to the embodiments disclosed in the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present application include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device, or installed from a storage device 1003, or installed from a ROM 1002. When the computer program is executed by the processing device 1001, the above-mentioned functions defined in the method of the embodiment disclosed in the present application are executed.

[0117] The document comparison and tracing device provided by the present application adopts the document comparison and tracing device method in the above embodiment, which can solve the technical problem of how to improve the accuracy of document comparison and tracing. Compared with the prior art, the beneficial effects of the document comparison and tracing device provided by the present application are the same as the beneficial effects of the document comparison and tracing method provided by the above embodiment, and the other technical features in the document comparison and tracing device are the same as the features disclosed in the method of the previous embodiment, which will not be repeated here.

[0118] It should be understood that the various parts disclosed in this application can be implemented by hardware, software, firmware or a combination thereof. In the description of the above embodiments, specific features, structures, materials or characteristics can be combined in any one or more embodiments or examples in a suitable manner.

[0119] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

[0120] The present application provides a computer-readable storage medium having computer-readable program instructions (ie, computer programs) stored thereon, and the computer-readable program instructions are used to execute the document comparison and tracing method in the above-mentioned embodiment.

[0121] The computer-readable storage medium provided in the present application may be, for example, a USB flash drive, but is not limited to electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, systems or devices, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM: Random Access Memory), a read-only memory (ROM: Read Only Memory), an erasable programmable read-only memory (EPROM: Erasable Programmable Read Only Memory or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM: CD-Read Only Memory), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with an instruction execution system, system or device. The program code contained on the computer-readable storage medium may be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (Radio Frequency: Radio Frequency), etc., or any suitable combination of the above.

[0122] The computer-readable storage medium may be included in the document comparison and tracing device; or it may exist independently without being assembled into the document comparison and tracing device.

[0123] The computer-readable storage medium carries one or more programs. When the one or more programs are executed by the document comparison and tracing device, the document comparison and tracing device: responds to a tracing request for a difference segment, determines the range of the difference segment in the original document according to the difference segment and the difference position corresponding to the difference segment, and identifies the text within the range as the target text; splits the target text into independent text segments according to delimiters, and compares the text segments with the difference segments to determine the similarity between each of the text segments and the difference segment; uses the text segments whose similarity reaches or exceeds a preset threshold as candidate segments, and determines the text segment with the highest similarity from the candidate segments as the tracing segment, and returns the position coordinates of the tracing segment in the original document.

[0124] Computer program code for performing the operations of the present application may be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages ​​such as Java, Smalltalk, C++, and conventional procedural programming languages ​​such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0125] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present application. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0126] The modules involved in the embodiments described in the present application may be implemented by software or hardware, wherein the name of the module does not constitute a limitation on the unit itself in some cases.

[0127] The readable storage medium provided in this application is a computer-readable storage medium, which stores computer-readable program instructions (i.e., computer programs) for executing the above-mentioned document comparison and tracing method, and can solve the technical problem of how to improve the accuracy of document comparison and tracing. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided in this application are the same as the beneficial effects of the document comparison and tracing method provided in the above-mentioned embodiment, and will not be repeated here.

[0128] An embodiment of the present application provides a computer program product, including a computer program, which implements the steps of the document comparison and tracing method as described above when executed by a processor.

[0129] The computer program product provided in this application can solve the technical problem of how to improve the accuracy of document comparison and tracing. Compared with the prior art, the beneficial effects of the computer program product provided in the embodiment of this application are the same as the beneficial effects of the document comparison and tracing method provided in the above embodiment, which will not be repeated here.

[0130] The above are only preferred embodiments of the present application, and are not intended to limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the present application specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent processing scope of the present application.

[0131] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or system including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or system. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or system including the element.

[0132] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method.

[0133] The above are only preferred embodiments of the present application, and are not intended to limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the present application specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present application.

Claims

1. A document comparison and tracing method, characterized in that: The document comparison and tracing method includes: In response to a tracing request for a difference segment, determining a range of the difference segment in the original document according to the difference segment and a difference position corresponding to the difference segment, and identifying text within the range as a target text; Splitting the target text into independent text segments according to the separators, and comparing the text segments with the difference segments to determine the similarity between each of the text segments and the difference segments; The text segments whose similarity reaches or exceeds a preset threshold are taken as candidate segments, and from the candidate segments, the text segment with the highest similarity is determined as the source segment, and the position coordinates of the source segment in the original document are returned.

2. The document comparison and tracing method according to claim 1, characterized in that: Before the step of responding to the tracing request for the difference segment, determining the range of the difference segment in the original document according to the difference segment and the difference position corresponding to the difference segment, and identifying the text within the range as the target text, the method includes: receiving a comparison instruction, the comparison instruction including comparison parameters and an original document, and identifying differences between the original documents; Extracting continuous text containing the difference points as difference segments, and determining the difference position of each difference segment in the corresponding original document according to the positioning mark of the original document; The difference fragment and the difference position corresponding to the difference fragment are combined to generate a traceability request.

3. The document comparison and tracing method according to claim 1, characterized in that: The step of responding to the tracing request for the difference segment, determining the range of the difference segment in the original document according to the difference segment and the difference position corresponding to the difference segment, and identifying the text within the range as the target text, further includes: According to the difference position, locate the corresponding page or paragraph in the original document; The entire text content including the difference position or the difference segment is extracted from the original document as the target text.

4. The document comparison and tracing method according to claim 1, characterized in that: After the step of responding to the tracing request for the difference segment, determining the range of the difference segment in the original document according to the difference segment and the difference position corresponding to the difference segment, and identifying the text within the range as the target text, the method further includes: Create a PDF parsing instance, and pass the difference segment and the target text as input parameters to the PDF parsing instance; Using the PDF parsing instance to search and match the target text, and determine the location information and the original text segment corresponding to the difference segment; Each of the difference segments is matched with the corresponding location information and the original segment to generate a tracing result.

5. The document comparison and tracing method according to claim 4, characterized in that: The step of determining the location information and the original text segment corresponding to the difference segment comprises: Through the PDF parsing example, the layout structure of the target text is identified, and all text units in the target text are marked; Matching the difference segment with each of the text units to determine a matching result between the difference segment and each of the text units; Based on the matching result, the successfully matched text unit is used as the original text segment of the difference segment, and the position information of the original text segment in the target text is determined.

6. The document comparison and tracing method according to claim 1, characterized in that: The step of splitting the target text into independent text segments according to the delimiters, and comparing the text segments with the difference segments, and determining the similarity between each of the text segments and the difference segments comprises: Identify delimiters in the target text, and use the delimiters to split the target text into independent text segments; Convert each of the text segments and the difference segments into character sequences respectively, and compare the character sequences of the text segments and the character sequences of the difference segments character by character; Counting the number of character matches and the number of character mismatches at the same position in the character sequence of the text segment and the character sequence of the difference segment; Based on the number of character matches and the number of character mismatches, the similarity between each of the text segments and the difference segment is calculated.

7. The document comparison and tracing method according to claim 1, characterized in that: The step of taking the text segments whose similarity reaches or exceeds a preset threshold as candidate segments, determining the text segment with the highest similarity from the candidate segments as the source segment, and returning the position coordinates of the source segment in the original document includes: In the target text, the text segments whose similarity reaches or exceeds a first preset threshold are selected as first candidate segments; Based on the first candidate segment, the text segment whose similarity reaches or exceeds a second preset threshold is used as the second candidate segment, and the text segment with the highest similarity in the second candidate segment is determined as the source segment, and the position coordinates of the source segment in the original document are returned.

8. The document comparison and tracing method according to claim 7, characterized in that: The step of taking the text segment whose similarity reaches or exceeds a second preset threshold as a second candidate segment based on the first candidate segment, determining the text segment with the highest similarity among the second candidate segments as the source segment, and returning the position coordinates of the source segment in the original document, further includes: If there is no text segment whose similarity reaches or exceeds the second preset threshold, respectively obtaining vector representations of the target text and the difference segment; Calculating the semantic similarity between each text segment in the target text and the difference segment; In the target text, a text segment with the highest semantic similarity to the difference segment is determined as the source segment, and the position coordinates of the source segment in the original document are returned.

9. A document comparison and tracing device, characterized in that: The document comparison and tracing device includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the document comparison and tracing method according to any one of claims 1 to 8.

10. A computer storage medium, characterized in that: The computer storage medium is a computer-readable storage medium, and a computer program is stored on the computer storage medium. When the computer program is executed by a processor, the steps of the document comparison and tracing method according to any one of claims 1 to 8 are implemented.

Citation Information

Cited By

  • Differential visualization method and device after content preprocessing based on PDF document and storage medium

    CN120012711A

  • Content tracing method and device based on key information extraction

    CN120197610A

  • Content Traceability Method and Device Based on Key Information Extraction

    CN120197610B

  • Tracing and positioning method and system for cross-format document information, terminal and medium

    CN121210737A