Document information comparison method and device, equipment and medium
By using semantic difference model for semantic difference detection in Word document comparison, the problem that traditional methods are difficult to deal with complex document formats and semantic differences is solved, and efficient and accurate document comparison and intuitive difference display are achieved.
Patent Information
- Application Number
- CN202411492751.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-24
- Publication Date
- 2025-02-18
AI Technical Summary
Traditional Word document comparison methods are difficult to deal with complex document formats, structures, and semantic differences, and are inefficient, which has significant shortcomings in the comparison of multilingual and semantic levels.
By obtaining Word document sets, extracting paragraph text content, using character comparison algorithm for literal difference detection, identifying the difference parts, and using semantic difference models, including pre-trained language models for semantic understanding and similarity algorithms, to perform semantic difference detection. Identify the type of difference in the difference section.
It improves the accuracy and efficiency of document comparison, can quickly process large-scale documents, supports multiple document formats and structures, and provides intuitive difference reports and visual presentation, with a good user experience.
Smart Images

Figure CN119476251A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of document comparison, and in particular to a method, device, equipment and medium for comparing document information. Background Art
[0002] With the rapid development of electronic documents, more and more work scenarios need to be applied to electronic documents, especially those that require text work. Among them, scenarios such as policy revision and contract review also require the comparison of electronic documents, especially Word documents, so there are certain requirements for the accuracy of electronic document comparison.
[0003] Traditional Word document comparison methods mainly rely on string matching and simple difference calculations. This method is difficult to handle complex document formats, structures, and semantic differences, and is inefficient. It has significant deficiencies in multi-language and semantic comparisons. Therefore, this application needs to propose a document comparison method with high accuracy and efficiency. Summary of the invention
[0004] The present application provides a method, apparatus, device and medium for comparing document information, which performs semantic difference detection on the identified difference parts through a semantic difference model to identify the difference type of the difference parts, thereby improving the efficiency and accuracy of accurately identifying the semantic differences of texts.
[0005] In a first aspect, the present application provides a method for comparing document information, the method comprising:
[0006] Obtain a word document set, wherein the word document set includes a plurality of word documents to be compared;
[0007] Extract the text content of paragraphs in multiple word documents to be compared;
[0008] Using a character comparison algorithm, the text contents of paragraphs in the standard word document in the word document to be compared and the comparison word document other than the standard word document are detected to identify the difference parts in each paragraph;
[0009] A semantic difference model is used to perform semantic difference detection on text content corresponding to the difference part to identify the difference type of the difference part. The semantic difference model includes a pre-trained language model for semantic understanding and a similarity algorithm.
[0010] Optionally, extract the text contents of paragraphs in multiple word documents to be compared, including:
[0011] Split the paragraphs in the word document to be compared;
[0012] The text contents in the split paragraphs are stored after being standardized, wherein the standardization includes unified character encoding, special character processing, normalization of blank characters and word segmentation processing.
[0013] Optionally, before extracting the text contents of the paragraphs in the multiple word documents to be compared, the method further includes:
[0014] By processing the fonts, paragraphs, tables and pictures in multiple word documents to be compared, multiple word documents to be compared are converted into a standardized text format.
[0015] Optionally, a semantic difference model is used to perform semantic difference detection on the text content corresponding to the difference part to identify the difference type of the difference part, including:
[0016] Use the pre-trained language model to encode the text content and generate the semantic vector corresponding to the text content;
[0017] According to the semantic vectors and similarity algorithm, the similarity between the semantic vectors is calculated to obtain the semantic similarity score of the text content;
[0018] According to the relationship between the semantic similarity score and the threshold, the difference type of the difference part is obtained.
[0019] Optionally, according to the relationship between the semantic similarity score and the threshold, the difference type of the difference part is obtained, including:
[0020] When the semantic similarity score is greater than or equal to the threshold, the difference type of the difference part is determined to be modification;
[0021] When the semantic similarity score is less than the threshold, and the difference part is a part of the standard word document, the difference type of the difference part is determined to be deletion;
[0022] When the semantic similarity score is less than the threshold value, and the difference part is a part of the compared word document, the difference type of the difference part is determined to be increase.
[0023] Optionally, the method further comprises:
[0024] Generate a text difference report based on the location of the different parts, difference type, text content and similarity score.
[0025] Optionally, the method further comprises:
[0026] Display the standard word document and the comparison word document side by side in the view;
[0027] Mark the difference parts and the difference types of the difference parts by color and style;
[0028] Special marks or pop-up annotations are used at the difference parts to display the semantic content of the difference parts, and the semantic content of the difference parts is obtained through a pre-trained language model.
[0029] In a second aspect, the present application provides a device for comparing document information, the device comprising:
[0030] An acquisition unit, used for acquiring a word document set, wherein the word document set includes a plurality of word documents to be compared;
[0031] An extraction unit, used for extracting text contents of paragraphs in a plurality of word documents to be compared;
[0032] A detection unit, used to detect literal differences between the text contents of paragraphs in the standard word document in the word document to be compared and the comparison word document other than the standard word document, using a character comparison algorithm, and identify the difference parts in each paragraph;
[0033] The recognition unit is used to perform semantic difference detection on the text content corresponding to the difference part using a semantic difference model to identify the difference type of the difference part. The semantic difference model includes a pre-trained language model and a similarity algorithm for semantic understanding.
[0034] Optionally, the extraction unit is specifically used for:
[0035] Split the paragraphs in the word document to be compared;
[0036] The text contents in the split paragraphs are stored after being standardized, wherein the standardization includes unified character encoding, special character processing, normalization of blank characters and word segmentation processing.
[0037] Optionally, the device further comprises:
[0038] The processing unit is used to convert the multiple word documents to be compared into a standardized text format by processing the fonts, paragraphs, tables and pictures in the multiple word documents to be compared.
[0039] Optionally, the identification unit includes:
[0040] The encoding subunit is used to encode the text content using the pre-trained language model to generate a semantic vector corresponding to the text content;
[0041] A calculation subunit, used to calculate the similarity between the semantic vectors according to the semantic vectors and the similarity algorithm, and obtain the semantic similarity score of the text content;
[0042] A subunit is obtained, which is used to obtain the difference type of the difference part according to the relationship between the semantic similarity score and the threshold.
[0043] Optionally, the obtaining subunit is specifically used for:
[0044] When the semantic similarity score is greater than or equal to the threshold, the difference type of the difference part is determined to be modification;
[0045] When the semantic similarity score is less than the threshold, and the difference part is a part of the standard word document, the difference type of the difference part is determined to be deletion;
[0046] When the semantic similarity score is less than the threshold value, and the difference part is a part of the compared word document, the difference type of the difference part is determined to be increase.
[0047] Optionally, the device further comprises:
[0048] The generating unit is used for generating a text difference report according to the position of the difference part, the difference type, the text content and the similarity score.
[0049] Optionally, the device further includes a display unit specifically configured to:
[0050] Display the standard word document and the comparison word document side by side in the view;
[0051] Mark the difference parts and the difference types of the difference parts by color and style;
[0052] Special marks or pop-up annotations are used at the difference parts to display the semantic content of the difference parts, and the semantic content of the difference parts is obtained through a pre-trained language model.
[0053] In a third aspect, the present application provides an electronic device, the electronic device comprising a memory and a processor:
[0054] The memory is used to store computer programs;
[0055] The processor is used to execute the method provided by the first aspect according to the computer program.
[0056] In a fourth aspect, the present application further provides a computer-readable storage medium, which is used to store a computer program, and the computer program is used to execute the method provided in the first aspect above.
[0057] It can be seen that this application has the following beneficial effects:
[0058] The present application provides a method for document information comparison. First, after obtaining a word document set with multiple word documents to be compared, the text content of paragraphs in the multiple word documents to be compared is extracted; then, a character comparison algorithm is used to perform literal difference detection on the text content of paragraphs in the standard word document to be compared and the comparison word document other than the standard word document, and the difference part in each paragraph is identified; finally, a semantic difference model is used to perform semantic difference detection on the text content corresponding to the difference part, and the difference type of the difference part is identified, and the semantic difference model includes a pre-trained language model and a similarity algorithm for semantic understanding. In this process, not only literal difference detection is performed to identify the difference part, but also the model is used to perform semantic difference detection on the difference part, so that the difference type of the specific difference part can be detected. Because the semantic understanding ability of the large model is utilized, the semantic difference of the text can be accurately identified, and the entire difference detection process is efficient, and large-scale documents can be processed quickly. In addition, the present application can also support a variety of document formats and structures, has strong adaptability, and also provides intuitive difference reports and visual displays, and provides a good user experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0059] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the present application. For ordinary technicians in this field, other drawings can also be obtained based on these drawings.
[0060] Figure 1 A flowchart of an embodiment of a method for comparing document information in an embodiment of the present application;
[0061] Figure 2 A flowchart of another embodiment of a method for comparing document information in an embodiment of the present application;
[0062] Figure 3 A schematic diagram of the architecture of a method for comparing document information in an embodiment of the present application;
[0063] Figure 4 A schematic diagram of the structure of a device for comparing document information in an embodiment of the present application;
[0064] Figure 5 It is a schematic diagram of the structure of an electronic device in an embodiment of the present application. DETAILED DESCRIPTION
[0065] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0066] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards of relevant countries and regions.
[0067] At present, traditional word document comparison methods mainly rely on string matching and simple difference calculations, which are difficult to handle complex document formats, structures, and semantic differences, and are inefficient, and have significant deficiencies in multilingual and semantic comparisons. With the development of natural language processing (NLP) technology, especially the application of large-scale pre-trained models (such as BERT, GPT, etc.), a method has been provided to improve the accuracy and efficiency of document comparison.
[0068] In an embodiment of the present application, by using a pre-trained model to perform semantic analysis on the difference parts of the word documents to be compared, thereby obtaining the difference types of the difference parts, the literal and semantic differences of the text can be accurately identified, thereby improving the accuracy and efficiency of document comparison.
[0069] In specific implementation, the method may include, for example: obtaining a word document set, the word document set including multiple word documents to be compared; extracting the text contents of paragraphs in the multiple word documents to be compared; then using a character comparison algorithm to perform literal difference detection on the text contents of paragraphs in a standard word document in the word documents to be compared and a comparison word document other than the standard word document, and identifying the difference parts in each paragraph; finally, using a semantic difference model to perform semantic difference detection on the text contents corresponding to the difference parts, and identifying the difference types of the difference parts, the semantic difference model including a pre-trained language model for semantic understanding and a similarity algorithm.
[0070] It can be seen that the method provided by the implementation of this application can identify the difference type of the difference part by using the semantic difference model, accurately evaluate the semantic similarity of the document, accurately identify the literal and semantic differences of the text, and improve the accuracy and efficiency of document information comparison.
[0071] To facilitate understanding of the specific implementation of the document information comparison method provided in the embodiment of the present application, it will be described below with reference to the accompanying drawings.
[0072] It should be noted that the subject implementing the document information comparison method may be a document information comparison device provided in the embodiment of the present application, and the document information comparison device may be carried in an electronic device or a functional module of an electronic device. The electronic device in the embodiment of the present application may be any device capable of implementing the document information comparison method in the embodiment of the present application, for example, an Internet of Things (IoT) device.
[0073] Figure 1 A flowchart of a method for comparing document information provided in an embodiment of the present application is provided. The method can also be applied to a device for comparing document information, which can be, for example, Figure 4 The document information comparison device 400 shown in FIG. 1 may also be integrated in the document information comparison device 400. Figure 5 Functional modules in the electronic device 500 are shown.
[0074] like Figure 1 As shown, the method includes the following S101 to S104:
[0075] S101: Obtain a word document set, where the word document set includes a plurality of word documents to be compared.
[0076] In order to identify the difference part type of the word documents to be compared according to semantics, firstly, a word document set can be obtained, wherein the word document set includes multiple word documents to be compared; after extracting the text content of paragraphs in the multiple word documents to be compared, a character comparison algorithm is used to perform literal difference detection on the text content of the paragraphs in the standard word document to be compared and the comparison word document other than the standard word document, and the difference part in each paragraph is identified; finally, a semantic difference model is used to perform semantic difference detection on the text content corresponding to the difference part, and the difference type of the difference part is identified, wherein the semantic difference model includes a pre-trained language model and a similarity algorithm for semantic understanding. Therefore, the embodiment of the present application first obtains the word document set through S101, and makes preliminary preparations for the subsequent extraction of text content.
[0077] In this process, firstly, the word documents to be compared can be collected into a word document set, wherein the word document set includes a standard word document and a comparison word document to be compared with the standard word document, wherein there can be multiple comparison word documents.
[0078] S102: Extracting text contents of paragraphs in multiple word documents to be compared.
[0079] As an example, before executing S102, the word document set needs to be preprocessed, that is, the word document is converted into a standardized text format to ensure the consistency and accuracy of subsequent processing. Specifically, the multiple word documents to be compared are converted into a standardized text format by processing the fonts, paragraphs, tables and pictures in the multiple word documents to be compared.
[0080] In order to consider the complex structure of the word document in the subsequent text content extraction process, the complex structure to be considered includes various elements such as titles, paragraphs, lists, footnotes, etc., to ensure that they are not lost or misplaced during the extraction process. For format information, such as fonts, colors, alignments, etc., an effective encoding method needs to be designed to ensure that the format information of the word document set is consistent. For tables, the structural information of the table needs to be retained. Possible methods include converting all tables in the word document to a specific text format or using a special data structure to represent it. For pictures and other embedded objects, they need to be processed separately as metadata (such as size, location, file name, etc.) to ensure the consistency and accuracy of subsequent processing. In addition, the table structure and image metadata can be stored so that in addition to comparing the text content, non-text elements such as tables and pictures can also be compared.
[0081] As an example, S102 may include: splitting paragraphs in the word document to be compared; and storing the text contents in the split paragraphs after standardization, wherein the standardization includes unified character encoding, processing special characters, normalizing blank characters, and word segmentation.
[0082] That is, in terms of text content, standardization is required, including unified character encoding, processing of special characters, normalization of blank characters, etc. At the same time, for multilingual documents, language identification and corresponding preprocessing steps need to be considered, such as Chinese word segmentation, right-to-left processing of Arabic, etc. In order to improve the efficiency of subsequent processing, some optimization operations are also required, such as removing stop words, stemming, generating inverted indexes, etc.
[0083] In this process, it is necessary to combine multiple technologies, including natural language processing, image processing, data structure optimization, etc., to ensure that all relevant information of the word document can be fully and accurately captured, and the word document can be converted into a standardized text format, laying a solid foundation for subsequent efficient comparison.
[0084] S103: Using a character comparison algorithm, the text contents of paragraphs in the standard word document in the word document to be compared and the comparison word document other than the standard word document are detected to identify the difference parts in each paragraph.
[0085] When performing difference detection, you first need to perform literal difference detection, that is, you can use character and word level comparison algorithms (such as Levenshtein distance) to perform preliminary literal difference detection, and identify the parts of the paragraphs in the standard word document and the comparison word document that are different, which may include new additions, deletions, and modifications. And you can also use sequence alignment algorithms (such as the longest common subsequence, Diff algorithm, etc.) to accurately locate the added, deleted, and modified content.
[0086] In this process, only the parts with textual differences are simply identified, so it is necessary to subsequently perform semantic understanding and comparison on the different parts to further understand the difference type to which the different parts belong.
[0087] S104: Using a semantic difference model to perform semantic difference detection on text content corresponding to the difference part, and identifying the difference type of the difference part, the semantic difference model includes a pre-trained language model for semantic understanding and a similarity algorithm.
[0088] As an example, S104 may include: S1041, using the pre-trained language model to encode the text content to generate a semantic vector corresponding to the text content; S1042, based on the semantic vectors and the similarity algorithm, calculating the similarity between the semantic vectors to obtain the semantic similarity score of the text content; S1043, based on the relationship between the semantic similarity score and the threshold, obtaining the difference type of the difference part.
[0089] The pre-trained language model used in the above S1041 can be based on models such as Bidirectional Encoder Representations from Transformers (BERT) and Generative Pre-Trained Transformer-3 (GPT-3). In the embodiment of the present application, the appropriate pre-trained language model size and configuration can be selected according to task requirements and computing resources. In S1041, for the case of long texts, a segmented encoding method can be used to encode each paragraph of text separately and then merge them.
[0090] It should be noted that text semantic similarity analysis is a technique for measuring the degree of matching between two or more documents. This technique can not only compare the surface similarity of texts, but also deeply understand the intrinsic meaning of texts, and plays an important role in multiple fields such as information retrieval, machine translation, and automatic question answering. Compared with traditional text similarity calculation methods, semantic similarity analysis can more accurately capture the semantic information of texts, thereby providing higher quality comparison results. Therefore, in the above S1042, by calculating the semantic similarity of each part of the document, the potential changes of the text are further confirmed, and by calculating the similarity between the semantic vectors, the semantic similarity of each part of the document is evaluated. The similarity algorithms in this application, such as cosine similarity, Euclidean distance, etc. For high-dimensional semantic vectors, cosine similarity is usually a better choice. The specific similarity calculation includes: calculating the similarity between the semantic vectors of the corresponding parts in the document. For the comparison of multiple paragraphs or sentences, weighted average or other aggregation methods can be used to comprehensively calculate the overall similarity and obtain a semantic similarity score.
[0091] In the above S1043, the difference type of the difference part can be obtained by using the relationship between the semantic similarity score and the threshold. The specific process may include: (1) when the semantic similarity score is greater than or equal to the threshold, the difference type of the difference part is determined to be modification; (2) when the semantic similarity score is less than the threshold, and the difference part is part of the standard word document, the difference type of the difference part is determined to be deletion; (3) when the semantic similarity score is less than the threshold, and the difference part is part of the comparison word document, the difference type of the difference part is determined to be addition. In the embodiment of the present application, a dynamic threshold setting method is adopted to adjust the threshold according to factors such as text length and complexity.
[0092] In addition to the above-mentioned difference types for obtaining the difference parts, special algorithms can also be designed to detect and track changes in document structure, such as the movement, segmentation or merging of paragraphs. When dealing with format changes, it is necessary to consider multiple attributes such as fonts, colors, alignment, and evaluate the impact of these changes on the overall style and readability of the document. For non-text elements such as tables and pictures, special comparison methods need to be developed, such as table structure comparison, image similarity calculation, etc. Contextual information can also be considered during the analysis process, because some seemingly minor modifications may have a significant impact on the meaning of the entire document.
[0093] In this process, the semantic difference model is used to detect the semantic difference of the text content corresponding to the difference part. Identifying the difference type of the difference part can not only compare the surface similarity of the text, but also deeply understand the intrinsic meaning of the text, playing an important role in information retrieval, machine translation, automatic question answering and other fields. Compared with the traditional text similarity calculation method, the semantic similarity analysis used in this application can more accurately capture the semantic information of the text, thereby providing a higher quality comparison result.
[0094] In addition to obtaining the difference type of the difference part of the word text, the embodiment of the present application can also generate a text difference report based on the position, difference type, text content and similarity score of the difference part, so that the difference information of the difference part can be organized and displayed according to the hierarchical structure of the document so that the user can view the difference.
[0095] It should be noted that the embodiments of the present application also include visual display. The specific visual display may include: displaying the standard word document and the comparison word document side by side in the view, and marking the difference parts and the difference types of the difference parts by color and style; and using special marks or pop-up annotations at the difference parts to display the semantic content of the difference parts, and the semantic content of the difference parts is obtained through a pre-trained language model.
[0096] That is, design a side-by-side view to display the original document and the modified document side by side, using different colors and styles to mark additions, deletions, and modifications. For the movement of large sections of text, use connecting lines or arrows to indicate their new positions to help users understand the changes in the document structure. To handle long documents, implement thumbnail navigation and quick jump functions so that users can easily switch between different parts of the document. For changes at the semantic level, you can use a pre-trained language model to obtain the semantic content of the difference part, and use special tags or pop-up comments to explain the semantic content of the difference part.
[0097] There is also a change summary view that shows the overall changes in the document, such as the main chapters that have been modified, the parts with the biggest changes, etc., to help users quickly get an overview of document changes. For changes in tables and images, special visualization methods are designed, such as cell-level comparison of tables, highlighting of differences in images, etc. In order to improve the user experience, interactive filtering and search functions are implemented, allowing users to filter the displayed differences based on conditions such as change type and importance. Taking into account the needs of different users, multiple view modes are provided, such as side-by-side view, merged view, difference list view, etc., so that users can choose the most suitable display method according to their preferences. Finally, in order to support team collaboration and realize real-time sharing and collaborative editing functions, multiple users can also view and discuss document changes at the same time.
[0098] It can be seen that the embodiment of the present application detects literal differences through a character comparison algorithm, identifies the difference part, and also uses a model to detect semantic differences in the difference part, so that the difference type of the specific difference part can be detected. Since the semantic understanding ability of the large model is utilized, the semantic differences of the text can be accurately identified, and the entire difference detection process is efficient, and large-scale documents can be processed quickly.
[0099] In order to make the method provided in the embodiment of the present application clearer and easier to understand, Figure 2 This method is applied to Figure 3 A specific example of the architecture diagram of document information comparison is shown.
[0100] like Figure 2 As shown, the implementation may include:
[0101] S201: Obtain a word document set, where the word document set includes a plurality of word documents to be compared.
[0102] like Figure 3 As shown, the user first uploads the word document to the word document collection for subsequent document comparison operations.
[0103] S202: Preprocessing a plurality of word documents to be compared.
[0104] like Figure 3 As shown, after obtaining the word document set, the user needs to preprocess the multiple word documents to be compared. The specific method is to process the fonts, paragraphs, tables and pictures in the multiple word documents to be compared, so that the multiple word documents to be compared are converted into a standardized text format.
[0105] S203: Extracting text contents of paragraphs in multiple word documents to be compared.
[0106] like Figure 3 As shown, the operations of text extraction and word segmentation are specifically: splitting the paragraphs in the word document to be compared, and storing the text content in the split paragraphs after standardization, wherein the standardization includes unified character encoding, processing special characters, normalizing blank characters and word segmentation. Among them, the text extraction is performed by an external service, specifically, the external service performs it after document image recognition.
[0107] S204: Using a character comparison algorithm, the text contents of paragraphs in the standard word document in the word document to be compared and the comparison word document other than the standard word document are detected to identify the difference parts in each paragraph.
[0108] like Figure 3 As shown, text preprocessing is performed, that is, preliminary literal difference detection is performed in advance through a comparison algorithm based on character and word levels to obtain the difference part in each paragraph.
[0109] S205: Encode the text content corresponding to the difference part using the pre-trained language model to generate a semantic vector corresponding to the text content.
[0110] like Figure 3 As shown, the text content corresponding to the difference part in the word document to be compared is subjected to a large model text comparison operation. First, the text content corresponding to the difference part is input into the pre-trained language model, the text content is encoded, and a semantic vector corresponding to the text content is generated.
[0111] S206: Calculate the similarity between the semantic vectors based on the semantic vectors and the similarity algorithm to obtain the semantic similarity score of the text content.
[0112] After obtaining the semantic vector, the similarity between the semantic vectors is calculated according to the similarity algorithm to obtain the semantic similarity score of the text content, that is, the semantic similarity score is finally obtained according to the large model text comparison operation.
[0113] S207: Obtain the difference type of the difference part according to the relationship between the semantic similarity score and the threshold.
[0114] like Figure 3 As shown, a difference identification operation can be performed based on the semantic similarity score. The specific difference identification operation includes: obtaining the difference type of the difference part based on the relationship between the semantic similarity score and the threshold, for example, when the semantic similarity score is greater than or equal to the threshold, the difference type of the difference part is determined to be modification; when the semantic similarity score is less than the threshold, and the difference part is a part of the standard word document, the difference type of the difference part is determined to be deletion; and when the semantic similarity score is less than the threshold, and the difference part is a part of the comparison word document, the difference type of the difference part is determined to be addition.
[0115] S208: Generate a text difference report according to the location of the difference part, the difference type, the text content and the similarity score.
[0116] like Figure 3 As shown, after the difference recognition is performed, a result can be generated, specifically including generating a text difference report according to the location of the difference part, the difference type, the text content and the similarity score.
[0117] S209: Displaying the difference between the standard word document and the comparison word document through a view.
[0118] The specific process may be to display the standard word document and the comparison word document side by side in the view, and mark the difference parts and the difference types of the difference parts by color and style; and use special marks or pop-up annotations at the difference parts to display the semantic content of the difference parts, and the semantic content of the difference parts is obtained by a pre-trained language model.
[0119] This embodiment provides a method for document information comparison, which not only uses a character comparison algorithm to detect literal differences and identify the difference parts, but also uses a model to detect semantic differences in the difference parts, so that the difference type of the specific difference parts can be detected. Because the semantic understanding ability of the large model is utilized, the semantic differences of the text can be accurately identified, and the entire difference detection process is efficient and can quickly process large-scale documents. In addition, this application can also support a variety of document formats and structures, has strong adaptability, and also provides intuitive difference reports and visual displays, providing a good user experience.
[0120] See also Figure 4 , the embodiment of the present application provides a device 400 for comparing document information, the device comprising:
[0121] An acquisition unit 401 is used to acquire a word document set, where the word document set includes a plurality of word documents to be compared;
[0122] An extraction unit 402 is used to extract text contents of paragraphs in a plurality of word documents to be compared;
[0123] The detection unit 403 is used to detect the text difference between the paragraphs in the standard word document and the comparison word document other than the standard word document in the word document to be compared by using a character comparison algorithm, and identify the difference part in each paragraph;
[0124] The identification unit 404 is used to perform semantic difference detection on the text content corresponding to the difference part using a semantic difference model to identify the difference type of the difference part. The semantic difference model includes a pre-trained language model and a similarity algorithm for semantic understanding.
[0125] Optionally, the extraction unit 402 is specifically configured to:
[0126] Split the paragraphs in the word document to be compared;
[0127] The text contents in the split paragraphs are stored after being standardized, wherein the standardization includes unified character encoding, special character processing, normalization of blank characters and word segmentation processing.
[0128] Optionally, the device 400 further includes:
[0129] The processing unit is used to convert the multiple word documents to be compared into a standardized text format by processing the fonts, paragraphs, tables and pictures in the multiple word documents to be compared.
[0130] Optionally, the identification unit 404 includes:
[0131] The encoding subunit is used to encode the text content using the pre-trained language model to generate a semantic vector corresponding to the text content;
[0132] A calculation subunit, used to calculate the similarity between the semantic vectors according to the semantic vectors and the similarity algorithm, and obtain the semantic similarity score of the text content;
[0133] A subunit is obtained, which is used to obtain the difference type of the difference part according to the relationship between the semantic similarity score and the threshold.
[0134] Optionally, the obtaining subunit is specifically used for:
[0135] When the semantic similarity score is greater than or equal to the threshold, the difference type of the difference part is determined to be modification;
[0136] When the semantic similarity score is less than the threshold, and the difference part is a part of the standard word document, the difference type of the difference part is determined to be deletion;
[0137] When the semantic similarity score is less than the threshold value, and the difference part is a part of the compared word document, the difference type of the difference part is determined to be increase.
[0138] Optionally, the device 400 further includes:
[0139] The generating unit is used for generating a text difference report according to the position of the difference part, the difference type, the text content and the similarity score.
[0140] Optionally, the device 400 further includes a display unit specifically configured to:
[0141] Display the standard word document and the comparison word document side by side in the view;
[0142] Mark the difference parts and the difference types of the difference parts by color and style;
[0143] Special marks or pop-up annotations are used at the difference parts to display the semantic content of the difference parts, and the semantic content of the difference parts is obtained through a pre-trained language model.
[0144] It should be noted that the specific implementation method and effect of the document information comparison device 400 can be found in the above Figure 1 or Figure 2 The relevant descriptions in the provided methods will not be repeated here.
[0145] The present application embodiment also provides an electronic device 500, such as Figure 5 As shown, the device 500 includes a memory 501 and a processor 502:
[0146] The memory 501 is used to store computer programs;
[0147] The processor 502 is used to execute the above Figure 1 or Figure 2 The method provided.
[0148] In addition, the present application also provides a computer-readable storage medium, the computer-readable storage medium is used to store a computer program, and the computer program is used to execute Figure 1 or Figure 2 The method provided.
[0149] Through the description of the above implementation methods, it can be known that those skilled in the art can clearly understand that all or part of the steps in the above-mentioned embodiment method can be implemented by means of software plus a general hardware platform. Based on such an understanding, the technical solution of the present application can be embodied in the form of a software product, which can be stored in a storage medium, such as a read-only memory (ROM) / RAM, a magnetic disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network communication device such as a router) to execute the methods described in each embodiment of the present application or some parts of the embodiments.
[0150] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment. The device embodiment described above is only schematic, in which the modules described as separate components may or may not be physically separated, and the components displayed as modules may or may not be physical modules, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules can be selected according to actual needs to achieve the goals of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative work.
[0151] The above description is merely an exemplary embodiment of the present application and is not intended to limit the protection scope of the present application.
Claims
1. A method for comparing document information, characterized in that: The method comprises: Obtain a word document set, wherein the word document set includes a plurality of word documents to be compared; Extracting text contents of paragraphs in the multiple word documents to be compared; Using a character comparison algorithm, the text contents of paragraphs in the standard word document in the word document to be compared and the comparison word document other than the standard word document are detected to identify the difference parts in each paragraph; A semantic difference model is used to perform semantic difference detection on text content corresponding to the difference part to identify the difference type of the difference part. The semantic difference model includes a pre-trained language model and a similarity algorithm for semantic understanding.
2. The method according to claim 1, characterized in that The extracting text contents of paragraphs in the multiple word documents to be compared includes: Splitting the paragraphs in the word document to be compared; The text contents in the split paragraphs are stored after being standardized, wherein the standardization includes unified character encoding, special character processing, normalization of blank characters and word segmentation processing.
3. The method according to claim 2, characterized in that Before extracting the text contents of the paragraphs in the multiple word documents to be compared, the method further includes: The multiple word documents to be compared are converted into a standardized text format by processing the fonts, paragraphs, tables and pictures in the multiple word documents to be compared.
4. The method according to claim 1, characterized in that: The using of the semantic difference model to perform semantic difference detection on the text content corresponding to the difference part to identify the difference type of the difference part includes: Encoding the text content using the pre-trained language model to generate a semantic vector corresponding to the text content; Calculating the similarity between the semantic vectors based on the semantic vectors and the similarity algorithm to obtain a semantic similarity score of the text content; According to the relationship between the semantic similarity score and the threshold, the difference type of the difference part is obtained.
5. The method according to claim 1, characterized in that The step of obtaining the difference type of the difference part according to the relationship between the semantic similarity score and the threshold value includes: When the semantic similarity score is greater than or equal to the threshold, determining that the difference type of the difference part is modification; When the semantic similarity score is less than the threshold value, and the difference part is a part of the standard word document, determining that the difference type of the difference part is deletion; When the semantic similarity score is less than the threshold value, and the difference portion is a portion of the compared word document, the difference type of the difference portion is determined to be an increase.
6. The method according to claim 1, characterized in that The method further comprises: A text difference report is generated according to the location, difference type, text content and similarity score of the difference part.
7. The method according to claim 1, characterized in that The method further comprises: Displaying the standard word document and the comparison word document side by side in a view; Mark the difference parts and the difference types of the difference parts by color and style; A special mark or a pop-up annotation is used at the difference part to display the semantic content of the difference part, and the semantic content of the difference part is obtained through the pre-trained language model.
8. A device for comparing document information, characterized in that: The device comprises: An acquisition unit, used for acquiring a word document set, wherein the word document set includes a plurality of word documents to be compared; An extraction unit, used for extracting text contents of paragraphs in the multiple word documents to be compared; A detection unit, used for using a character comparison algorithm to perform literal difference detection on the text contents of paragraphs in the standard word document in the word document to be compared and the comparison word document other than the standard word document, and identifying the difference parts in each paragraph; The recognition unit is used to perform semantic difference detection on the text content corresponding to the difference part using a semantic difference model to identify the difference type of the difference part, wherein the semantic difference model includes a pre-trained language model and a similarity algorithm for semantic understanding.
9. An electronic device, characterized in that: The device comprises a memory and a processor, and the electronic device is used to execute a program stored in the memory to run the method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium is used to store a computer program, and the computer program is used to execute the method according to any one of claims 1 to 7.
Citation Information
Cited By
Electronic document difference analysis method, system and equipment and storage medium
CN120087354A
Asset warehousing method, device and equipment, readable storage medium and program product
CN121658548A