Document comparison method and device and electronic equipment
By constructing a document diagram structure and combining text features, the problem of difficulty in accurately evaluating the similarity of complex documents in the prior art is solved, and the deep fusion evaluation of document structure and text is achieved, which improves the accuracy and comprehensiveness of similarity evaluation.
Patent Information
- Application Number
- CN202411661901.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-20
- Publication Date
- 2025-04-29
AI Technical Summary
The prior art is difficult to accurately evaluate the similarity between document elements in complex document files, and calculating the similarity between pictures and text alone is not enough to comprehensively evaluate the similarity between two documents.
By constructing the graph structure of a document, characterize the element position characteristics, element hierarchy relationships and position similarity differences of document elements. Combining text features, a neural network model is used to extract graph features and text features, and fuse structural features and text features to evaluate document similarity.
It realizes a more accurate and comprehensive evaluation of the similarity between two documents, enriches the dimensions of similarity evaluation, and can deeply explore the structural and textual characteristics of the document.
Smart Images

Figure CN119903351A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of electronic document processing, and in particular to a document comparison method, device and electronic equipment. Background Art
[0002] Calculating similarity between documents is an important means of document analysis.
[0003] Related technologies determine the similarity between two documents by separately calculating the similarity between images and the similarity between texts in the two documents. However, the document elements in a document (document title, paragraph text, table, table title, image, image title, etc.) are diverse. For complex document files, there is also a complex hierarchical structure relationship between document elements. Only calculating the similarity between images and texts in two documents cannot accurately evaluate the similarity between the two documents. Summary of the invention
[0004] The present application aims to solve at least one of the technical problems existing in the related art. To this end, the present application proposes a document comparison method, device and electronic device, which can more accurately evaluate the similarity between two documents.
[0005] In a first aspect, the present application provides a document comparison method, the method comprising:
[0006] A first graph structure corresponding to the first document and a second graph structure corresponding to the second document are respectively constructed; the first graph structure and the second graph structure are used to respectively characterize element position features, element hierarchical relationships, and position similarity differences of document elements in the corresponding first document and the second document;
[0007] Determine a first graph feature of the first graph structure and a second graph feature of the second graph structure;
[0008] Acquire a first text feature corresponding to the first document and a second text feature corresponding to the second document;
[0009] The similarity between the first document and the second document is obtained according to the first graph feature, the second graph feature, the first text feature and the second text feature.
[0010] According to the document comparison method of the present application, a first graph structure corresponding to the first document and a second graph structure corresponding to the second document are respectively constructed; the first graph structure and the second graph structure are respectively used to characterize the element position characteristics, element hierarchical relationships and position similarity differences of the document elements in the corresponding first document and the second document; the first graph features of the first graph structure and the second graph features of the second graph structure are determined to achieve deep mining of the structural features of the two documents.
[0011] By obtaining the first text feature corresponding to the first document and the second text feature corresponding to the second document; obtaining the similarity between the first document and the second document according to the first graph feature, the second graph feature, the first text feature and the second text feature, the text features and structural features of the document elements themselves are integrated to determine the similarity between the two documents, enriching the dimension of similarity evaluation, and achieving more accurate and comprehensive determination of the similarity between the two documents.
[0012] According to an embodiment of the present application, respectively constructing a first graph structure corresponding to a first document and a second graph structure corresponding to a second document includes:
[0013] Determine the position similarity difference between any two adjacent document elements in the first graph structure and the second graph structure based on the following method, where the two adjacent document elements include the first element and the second element:
[0014] Obtaining a distance difference between document elements represented by the first element and the second element, respectively, according to the page number of the first target page to which the first element belongs, the page number of the second target page to which the second element belongs, the height of the first element on the first target page, and the height of the second element on the second target page;
[0015] Obtaining a level difference between the first element and the second element according to the title level of the most recent document title to which the first element belongs and the title level of the most recent document title to which the second element belongs;
[0016] According to the distance difference and the level difference, the position similarity difference between the first element and the second element is obtained.
[0017] According to an embodiment of the present application, determining a first graph feature of a first graph structure and a second graph feature of a second graph structure includes:
[0018] Inputting a first expression of the first graph structure and a second expression of the second graph structure into a trained first neural network model, obtaining a first graph feature corresponding to the first graph structure and a second graph feature corresponding to the second graph structure output by the first neural network model;
[0019] The first neural network model uses graph structure expressions as training samples and graph features of the graph structure as training labels.
[0020] According to an embodiment of the present application, obtaining a first text feature corresponding to a first document and a second text feature corresponding to a second document includes:
[0021] Extracting text contents corresponding to each document element in the first document and the second document respectively;
[0022] According to the text content of each document element in the first document and the text content of each document element in the second document, a first text feature corresponding to the first document and a second text feature corresponding to the second document are obtained respectively.
[0023] According to an embodiment of the present application, extracting text content corresponding to each document element in the first document and the second document includes:
[0024] When the document element is a picture, identify the high-level features of the picture, perform natural language conversion processing on the high-level features, and obtain the text content corresponding to the picture;
[0025] When the document element is a table, the text content of each unit in the table is extracted according to the type and target order of each unit in the table, and the extracted text content of each unit is spliced to obtain the text content corresponding to the table.
[0026] According to an embodiment of the present application, obtaining a first text feature corresponding to the first document and a second text feature corresponding to the second document respectively according to the text content of each document element in the first document and the text content of each document element in the second document includes:
[0027] Splicing the text contents of each document element in the first document to obtain first spliced text content;
[0028] splicing the text contents of each document element in the second document to obtain second spliced text contents;
[0029] Inputting the first concatenated text content and the second concatenated text content into a trained second neural network model, obtaining a first text feature corresponding to the first document and a second text feature corresponding to the second document output by the second neural network model;
[0030] The second neural network model uses text content as training samples and text features of the text content as training labels.
[0031] According to an embodiment of the present application, before respectively constructing a first graph structure corresponding to the first document and a second graph structure corresponding to the second document, the method further includes:
[0032] Converting the first document and the second document into a first picture and a second picture respectively;
[0033] The first image and the second image are identified to obtain a plurality of document elements corresponding to the first document and the second document, respectively, and element position features corresponding to each document element.
[0034] According to an embodiment of the present application, obtaining the similarity between the first document and the second document according to the first graph feature, the second graph feature, the first text feature, and the second text feature includes:
[0035] Determining a first similarity between the first image feature and the second image feature, and a second similarity between the first text feature and the second text feature;
[0036] The similarity between the first document and the second document is obtained according to the first similarity and the second similarity.
[0037] In a second aspect, the present application provides a document comparison device, the document comparison device comprising:
[0038] A construction module, used to construct a first graph structure corresponding to the first document and a second graph structure corresponding to the second document respectively; the first graph structure and the second graph structure are used to represent element position features, element hierarchical relationships and position similarity differences of document elements in the corresponding first document and the second document respectively;
[0039] A first determining module, used to determine a first graph feature of a first graph structure and a second graph feature of a second graph structure;
[0040] A first acquisition module, used to acquire a first text feature corresponding to the first document and a second text feature corresponding to the second document;
[0041] The second acquisition module is used to obtain the similarity between the first document and the second document according to the first image feature, the second image feature, the first text feature and the second text feature.
[0042] According to the document comparison device of the present application, a first graph structure corresponding to the first document and a second graph structure corresponding to the second document are respectively constructed; the first graph structure and the second graph structure are respectively used to characterize the element position characteristics, element hierarchical relationships and position similarity differences of the document elements in the corresponding first document and the second document; the first graph features of the first graph structure and the second graph features of the second graph structure are determined to achieve deep mining of the structural features of the two documents.
[0043] By obtaining the first text feature corresponding to the first document and the second text feature corresponding to the second document; obtaining the similarity between the first document and the second document according to the first graph feature, the second graph feature, the first text feature and the second text feature, the text features and structural features of the document elements themselves are integrated to determine the similarity between the two documents, enriching the dimension of similarity evaluation, and achieving more accurate and comprehensive determination of the similarity between the two documents.
[0044] In a third aspect, the present application provides an electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the document comparison method provided in the first aspect described above is implemented.
[0045] In a fourth aspect, the present application provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the document comparison method provided in the first aspect above.
[0046] In a fifth aspect, the present application provides a chip, the chip comprising a processor and a communication interface, the communication interface and the processor are coupled, and the processor is used to run a program or instruction to implement the document comparison method provided in the first aspect.
[0047] In a sixth aspect, the present application provides a computer program product, including a computer program, which, when executed by a processor, implements the document comparison method provided in the first aspect above.
[0048] The above one or more technical solutions in the embodiments of the present application have at least one of the following technical effects:
[0049] The embodiments of the present application respectively construct a first graph structure corresponding to the first document and a second graph structure corresponding to the second document; the first graph structure and the second graph structure are respectively used to characterize the element position characteristics, element hierarchical relationships and position similarity differences of the document elements in the corresponding first document and the second document; determine the first graph features of the first graph structure and the second graph features of the second graph structure to achieve deep mining of the structural features of the two documents.
[0050] By obtaining the first text feature corresponding to the first document and the second text feature corresponding to the second document; obtaining the similarity between the first document and the second document according to the first graph feature, the second graph feature, the first text feature and the second text feature, the text features and structural features of the document elements themselves are integrated to determine the similarity between the two documents, enriching the dimension of similarity evaluation, and achieving more accurate and comprehensive determination of the similarity between the two documents.
[0051] Additional aspects and advantages of the present application will be given in part in the description below, and in part will become apparent from the description below, or will be learned through the practice of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0052] The above and / or additional aspects and advantages of the present application will become apparent and easily understood from the description of the embodiments in conjunction with the following drawings, in which:
[0053] Figure 1 This is one of the flowcharts of the document comparison method provided in the embodiment of the present application;
[0054] Figure 2 is a structural schematic diagram of a first graph structure corresponding to a first document provided in an embodiment of the present application;
[0055] Figure 3This is the second flow chart of the document comparison method provided in the embodiment of the present application;
[0056] Figure 4 is a schematic diagram of the structure of a document comparison device provided in an embodiment of the present application;
[0057] Figure 5 It is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0058] The following will be combined with the drawings in the embodiments of the present application to clearly describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments in the present application belong to the scope of protection of this application.
[0059] The terms "first", "second", etc. in the specification and claims of the present application are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable under appropriate circumstances, so that the embodiments of the present application can be implemented in an order other than those illustrated or described here, and the objects distinguished by "first", "second", etc. are generally of one type, and the number of objects is not limited. For example, the first object can be one or more. In addition, "and / or" in the specification and claims represents at least one of the connected objects, and the character " / " generally indicates that the objects associated with each other are in an "or" relationship.
[0060] The document comparison method, document comparison device, electronic device and readable storage medium provided in the embodiments of the present application are described in detail below with reference to the accompanying drawings through specific embodiments and their application scenarios.
[0061] The document comparison method may be applied to a terminal, and may be specifically executed by hardware or software in the terminal.
[0062] The document comparison method provided in the embodiment of the present application may be executed by an electronic device or a functional module or functional entity in the electronic device that can implement the document comparison method. The electronic devices mentioned in the embodiment of the present application include but are not limited to mobile phones, tablet computers, computers, cameras, and wearable devices. The document comparison method provided in the embodiment of the present application is described below using an electronic device as an example of the execution subject.
[0063] like Figure 1 As shown, the document comparison method includes: step 110, step 120, step 130 and step 140.
[0064] Step 110, construct a first graph structure corresponding to the first document and a second graph structure corresponding to the second document respectively; the first graph structure and the second graph structure are used to represent element position features, element hierarchical relationships and position similarity differences of document elements in the corresponding first document and second document respectively.
[0065] The first document and the second document in the embodiment of the present application can be in any document format, including but not limited to text format (txt, rtf), document processing format (doc, docx, odt), portable format (pdf), markup language format (xml, html), presentation format (ppt), table format (xls) and image format (jpeg, png).
[0066] The document formats of the first document and the second document may be the same or different, and there is no limitation on this.
[0067] To eliminate the differences in document formats, documents can be converted into pictures. Specifically, the first document can be converted into a first picture, and the second document can be converted into a second picture. The number of first pictures and second pictures can be multiple (one page of the document corresponds to one picture). When the sizes of the first picture and the second picture are different, at least one of the first picture and the second picture can be scaled so that the first picture and the second picture are the same size, for example, both are 640*640 pixels.
[0068] The first document and the second document may be obtained by crawling, or by other methods, which are not limited.
[0069] In the embodiment of the present application, the first document and the second document both include at least one document element, and the document elements include but are not limited to document titles (which may include multi-level titles), paragraph text, table titles, tables, picture titles, and pictures.
[0070] The embodiment of the present application can identify the first image and the second image through the aggregation-segmentation structure PP-Structure technology, and obtain multiple document elements corresponding to the first document and the second document respectively, as well as element position features corresponding to each document element.
[0071] Element position features refer to the position features of document elements in a document, which can be represented in the form of a vector. Element position features include but are not limited to the position height of the element in the document (including the page number of the target page where the document element is located and the height in the target page), area, indentation and other parameters.
[0072] In addition, there are some relationships between document elements, including but not limited to element hierarchical relationships and position similarity differences. Among them, element hierarchical relationships include but are not limited to subordinate relationships, inclusion relationships and parallel relationships. For example, under the same level of title, the title and the picture below the title are in an inclusion relationship; for example, the second-level title and the second-level title are in a parallel relationship; for example, the second-level title and the third-level title under the second-level title are in a subordinate relationship. The subordinate relationship between titles can be determined based on the detection box height, font size, etc. of the title.
[0073] Position similarity difference refers to the difference between the positions of document elements, which can be determined based on the distance difference and level difference between the document elements. The distance difference represents the difference in distance between two document elements, and the level difference represents the difference between the levels of two document elements.
[0074] The embodiments of the present application can construct a first graph structure based on the element position characteristics, element hierarchical relationships and position similarity differences of the first document, wherein the nodes in the first graph structure represent document elements in the first document, the attributes of the nodes represent the element position characteristics of the corresponding document elements, the edges between two adjacent nodes represent the element hierarchical relationship between the document elements represented by the two nodes respectively, and the weights of the edges represent the position similarity differences between the document elements represented by the two nodes respectively.
[0075] Similarly, a second graph structure can be constructed based on the element position characteristics, element hierarchical relationships and position similarity differences of the second document, wherein the nodes in the second graph structure represent document elements in the second document, the attributes of the nodes represent the element position characteristics of the corresponding document elements, the edges between two adjacent nodes represent the element hierarchical relationships between the document elements represented by the two nodes respectively, and the weights of the edges represent the position similarity differences between the document elements represented by the two nodes respectively.
[0076] like Figure 2 As shown, the present application implements a structural schematic diagram of a first graph structure corresponding to a first document, wherein the first graph structure includes a plurality of nodes, namely, nodes 1 to 10, each node representing a corresponding document element, and each document element having a corresponding element position feature, wherein:
[0077] The document element represented by node 1 is a level 1 title, the document element represented by node 2 is a paragraph; the document element represented by node 3 is a level 2 title; the document element represented by node 4 is a level 2 title, the document element represented by node 5 is a level 3 title, the document element represented by node 6 is a paragraph, the document element represented by node 7 is a paragraph, the document element represented by node 8 is a picture, the document element represented by node 9 is a paragraph, the document element represented by node 10 is a table, the document element represented by node 11 is a picture title, and the document element represented by node 12 is a table title.
[0078] Each node has a corresponding element position feature V. The element position features of each node are V1, V2, V3, V4, V5, V6, V7, V8, V9, V10, V11, and V12 respectively. The hierarchical relationship between two adjacent nodes can be a subordinate relationship S1 or an inclusion relationship S2. The child nodes of the same parent node are in a parallel relationship. The edge weight W represents the position similarity difference between two nodes.
[0079] Among them, the child nodes of node 1 include node 2, node 3 and node 4. The element hierarchical relationship between the document elements represented by node 1 and node 2 is an inclusion relationship S2, and the weight between the two is w1; the element hierarchical relationship between the document elements represented by node 1 and node 3 is a subordinate relationship S1, and the weight between the two is w2; the element hierarchical relationship between the document elements represented by node 1 and node 4 is a subordinate relationship S1, and the weight between the two is w3.
[0080] The child nodes 5, 7, 8 and 11 of node 2, the element hierarchical relationship between the document elements represented by node 2 and node 5 respectively is a subordination relationship S1, and the weight between the two is w4; the element hierarchical relationship between the document elements represented by node 2 and node 7 respectively is an inclusion relationship S2, and the weight between the two is w6; the element hierarchical relationship between the document elements represented by node 2 and node 8 respectively is an inclusion relationship S2, and the weight between the two is w7; the element hierarchical relationship between the document elements represented by node 2 and node 11 respectively is an inclusion relationship S2, and the weight between the two is w10.
[0081] The child nodes 9, 10 and 12 of node 4, the element hierarchical relationship between the document elements represented by node 4 and node 9 respectively is the inclusion relationship S2, and the weight between the two is w8; the element hierarchical relationship between the document elements represented by node 4 and node 10 respectively is the inclusion relationship S2, and the weight between the two is w9; the element hierarchical relationship between the document elements represented by node 4 and node 12 respectively is the inclusion relationship S2, and the weight between the two is w12.
[0082] Child node 6 of node 5; the element hierarchical relationship between the document elements represented by nodes 5 and 6 is a containment relationship S2, and the weight between the two is w5.
[0083] The second graph structure may be created for the second document in the same manner, which will not be described in detail herein.
[0084] Step 120: Determine a first graph feature of the first graph structure and a second graph feature of the second graph structure.
[0085] After obtaining the first graph structure of the first document and the second graph structure of the second document, the embodiment of the present application inputs the first expression of the first graph structure and the second expression of the second graph structure into the trained first neural network model to obtain the first graph feature corresponding to the first graph structure and the second graph feature corresponding to the second graph structure output by the first neural network model. The first neural network model uses the expression of the graph structure as a training sample and the graph feature of the graph structure as a training label.
[0086] The first graph feature and the second graph feature can be represented in the form of feature vectors, the first graph feature is a first feature vector, and the second graph feature is a second feature vector. More specifically, they can be represented in the form of embedding vectors, the first graph feature is a first embedding vector, and the second graph feature is a second embedding vector.
[0087] Step 130: Obtain a first text feature corresponding to the first document and a second text feature corresponding to the second document.
[0088] For a document, the text feature of the document is very important for calculating the text similarity. Therefore, it is also necessary to determine a first text feature corresponding to the first text and a second text feature corresponding to the second document.
[0089] Specifically, the text content corresponding to each document element in the first document and the second document can be extracted. Document elements such as document paragraphs, document titles, table titles, and picture titles are all text-formatted data. Therefore, the text content of these document elements can be directly extracted; for document elements of the picture type, the high-level features of the picture can be identified, and the high-level features can be converted into natural language to obtain the text content corresponding to the picture; for document elements of the table type, the text content of each unit in the table can be extracted according to the type and target order of each unit in the table (for example, from top to bottom, from left to right), and the text content of each extracted unit can be spliced to obtain the text content corresponding to the table.
[0090] For the first document, the text contents of each document element in the first document may be spliced to obtain first spliced text contents; for the second document, the text contents of each document element in the second document may be spliced to obtain second spliced text contents.
[0091] The first text feature corresponding to the first document can be obtained based on the first concatenated text content; the second text feature corresponding to the second document can be obtained based on the second concatenated text content. Both the first text feature and the second text feature can be represented by feature vectors, specifically, they can be represented by embedded vectors, without limitation.
[0092] Step 140: Obtain the similarity between the first document and the second document according to the first graph feature, the second graph feature, the first text feature, and the second text feature.
[0093] In the embodiment of the present application, the first graph feature and the second graph feature respectively represent the structural features of the first document and the structural features of the second document, and the first similarity between the first graph feature and the second graph feature represents the similarity between the structures of the two documents.
[0094] In the embodiment of the present application, the first text feature and the second text feature respectively represent features of the text content of the first document and the text content of the second document, and the second similarity between the first text feature and the second text feature represents the similarity between the text contents of the two documents.
[0095] The similarity between the first document and the second document can be obtained based on the first similarity and the second similarity. Specifically, it can be assumed that the influencing factor of the structural similarity is k1, the influencing factor of the document content is k2, the first similarity is cosθ1, and the second similarity is cosθ2, then the similarity between the text contents of the two documents can be k1cosθ1+k2cosθ2.
[0096] The embodiments of the present application respectively construct a first graph structure corresponding to the first document and a second graph structure corresponding to the second document; the first graph structure and the second graph structure are respectively used to characterize the element position characteristics, element hierarchical relationships and position similarity differences of the document elements in the corresponding first document and the second document; determine the first graph features of the first graph structure and the second graph features of the second graph structure to achieve deep mining of the structural features of the two documents.
[0097] The embodiment of the present application obtains a first text feature corresponding to a first document and a second text feature corresponding to a second document; obtains the similarity between the first document and the second document based on the first graph feature, the second graph feature, the first text feature and the second text feature, and cleverly integrates the text features and structural features of the document elements themselves to determine the similarity between the two documents, enriches the dimensions of similarity evaluation, and achieves more accurate and comprehensive determination of the similarity between the two documents.
[0098] In some embodiments, respectively constructing a first graph structure corresponding to the first document and a second graph structure corresponding to the second document includes:
[0099] Determine the position similarity difference between any two adjacent document elements in the first graph structure and the second graph structure based on the following method, where the two adjacent document elements include the first element and the second element:
[0100] Obtaining a distance difference between document elements represented by the first element and the second element, respectively, according to the page number of the first target page to which the first element belongs, the page number of the second target page to which the second element belongs, the height of the first element on the first target page, and the height of the second element on the second target page;
[0101] Obtaining a level difference between the first element and the second element according to the title level of the most recent document title to which the first element belongs and the title level of the most recent document title to which the second element belongs;
[0102] According to the distance difference and the level difference, the position similarity difference between the first element and the second element is obtained.
[0103] The above-mentioned embodiments have illustrated that the weight of the edge in the graph structure represents the position similarity between the document elements represented by the two nodes connected. The position similarity difference is affected by the distance difference and the level difference between the document elements. The position similarity difference is negatively correlated with the distance difference. The greater the distance, the smaller the position similarity difference (weight); the position similarity difference is also negatively correlated with the level difference. The greater the level difference, the smaller the position similarity difference (weight).
[0104] Assuming that two adjacent document elements include a first element and a second element, the height of the page is l, the page number of the first target page to which the first element belongs is n1, the pixel coordinates of the first element on the first target page are (x1, y1, x2, y2), (x1, y1) represents the pixel coordinates of the lower left corner of the first element, and (x2, y2) represents the pixel coordinates of the upper right corner of the first element, then the height h1 of the first element in the entire first document can be determined, and h1 can be determined based on the following formula (1):
[0105] h1=l*(n1-1)+(y2-y1) (1).
[0106] Similarly, assuming that the page number of the second target page to which the second element belongs is n2, and the pixel coordinates of the second element on the second target page are (x1', y1', x2', y2'), (x1', y1') represents the pixel coordinates of the lower left corner of the second element, and (x2', y2') represents the pixel coordinates of the upper right corner of the second element, then the height h2 of the second element in the entire first document can be determined, and h2 can be determined based on the following formula (2):
[0107] h2=l*(n2-1)+(y2'-y1') (2).
[0108] Then, the distance difference △h between the document elements represented by the first element and the second element can be determined. △h can be determined based on the following formula (3):
[0109] △h=|h2-h2| (3),
[0110] “||” represents an absolute value.
[0111] In addition, since the first image and the second image may be scaled or cropped, when calculating h1 and h2, it is necessary to restore the heights in the original first image (not scaled or cropped) and the original second image according to the scaling ratio and / or cropping ratio.
[0112] For the title level, the nearest document title refers to the nearest title to which the document element belongs. Assuming that the title level of the nearest document title to which the first element belongs is t1, and the title level of the nearest document title to which the second element belongs is t2, then the level difference △t between the first element and the second element can be determined. △t can be determined based on the following formula (4):
[0113] △t=|t2-t1| (4).
[0114] Because the exponential decay function can simulate the phenomenon that the position similarity difference (weight) decreases rapidly but smoothly as the distance difference (or level difference) increases, the parameters α and β can be adjusted according to specific needs. For example, if the position difference is more important than the level difference, α can be set larger than β. The mathematical constant e represents the base of the logarithm, and the position similarity difference w (weight) is calculated as formula (5):
[0115] w=e -αΔh-βΔt (5).
[0116] Based on the above method, the positional relationship between two adjacent document elements in a complex document can be effectively, accurately and comprehensively mined.
[0117] In some embodiments, determining a first graph feature of a first graph structure and a second graph feature of a second graph structure includes:
[0118] Inputting a first expression of the first graph structure and a second expression of the second graph structure into a trained first neural network model, obtaining a first graph feature corresponding to the first graph structure and a second graph feature corresponding to the second graph structure output by the first neural network model;
[0119] The first neural network model uses graph structure expressions as training samples and graph features of the graph structure as training labels.
[0120] Specifically, assuming that the element position feature of a node is represented by Vi, the element position features of all document elements contained in any document can be represented by V = {v1, v2, ..., v i} represents that V is a node set, representing all document elements in the document.
[0121] Each edge in the graph structure of the document can be represented as E = {(vi ,v j ,w ij )|v i ,v j ∈V}, i and j represent two adjacent nodes, wij represents the weights of two adjacent nodes, and E is an edge set, which represents the element hierarchical relationship between the document elements represented by the nodes.
[0122] Then, the expression of the graph structure of the document can be expressed as G = (V, E).
[0123] Based on the above method, the first expression G1=(V1, E1) of the first graph structure can be obtained, where E1 represents the edge set in the first graph structure, and V1 represents the element position feature set of each node in the first graph structure; the second expression G2=(V2, E2) of the second graph structure can be obtained, where E2 represents the edge set in the second graph structure, and V2 represents the element position feature set of each node in the second graph structure.
[0124] The first expression of the first graph structure and the second expression of the second graph structure can be input into a trained first neural network model to obtain a first graph feature corresponding to the first graph structure output by the first neural network model and a second graph feature corresponding to the second graph structure; the first neural network model uses the expression of the graph structure as a training sample and the graph features of the graph structure as training labels.
[0125] In practical applications, the open source python library networkx can be used to construct the graph structure of the document, and the python open source LINE library algorithm can be used to construct the first neural network model, which can be a GNNS model. During the training process, sample data can be input into the first neural network model to be trained, and the Alias sampling algorithm can be used to set parameters such as the negative sampling index and number of iterations, learning rate and embedding dimension, so as to train the first neural network.
[0126] Through the graph learning training process constructed by the LINE algorithm, each node will obtain a low-dimensional graph embedding vector. This graph embedding vector not only contains the information of the node itself, but also incorporates the information of its neighboring nodes, so that it can more comprehensively reflect the characteristics of the document elements represented by the node in the document. The graph embedding vectors of all graph nodes can be normalized and added to obtain the graph features corresponding to the graph structure. This graph feature represents the structural characteristics of the document.
[0127] In some embodiments, obtaining a first text feature corresponding to a first document and a second text feature corresponding to a second document includes:
[0128] Extracting text contents corresponding to each document element in the first document and the second document respectively;
[0129] According to the text content of each document element in the first document and the text content of each document element in the second document, respectively obtain a first text feature corresponding to the first document and a second text feature corresponding to the second document;
[0130] In the embodiment of the present application, each document element has corresponding text content, and the text content corresponding to each document element in the first document and the second document can be extracted respectively.
[0131] Specifically, extracting text contents corresponding to each document element in the first document and the second document includes:
[0132] When the document element is a picture, identify the high-level features of the picture, perform natural language conversion processing on the high-level features, and obtain the text content corresponding to the picture;
[0133] When the document element is a table, the text content of each unit in the table is extracted according to the type and target order of each unit in the table, and the extracted text content of each unit is spliced to obtain the text content corresponding to the table.
[0134] It can be understood that, when the document element is any one of a document paragraph, a document title, a table title, and a picture title, since these document elements are data in text format, the text content of these document elements can be directly extracted.
[0135] When the document element is a picture, the high-level features of the picture can be identified. The high-level features of the picture usually refer to the more abstract features extracted when analyzing and processing the image. These features can usually convey the overall content, semantics or theme of the image, rather than just the underlying pixel information.
[0136] High-level features include the following categories: object recognition (people, animals, buildings, etc.), scene understanding (understanding the scene type presented in the image, such as cities, natural scenery, indoor environments, etc.), emotions and emotions (analyzing the emotions conveyed by the image, such as happiness, sadness, tension, etc.), color and texture (summarizing the overall tone and texture characteristics of the image, such as warm tones, cold tones, rough or smooth surfaces), composition and layout (analyzing image composition techniques, such as symmetry, focus, balance, etc.) and semantic segmentation (classifying different areas in the image, such as separating foreground and background), etc.
[0137] Furthermore, the high-level features are processed through natural language conversion to obtain the text content corresponding to the image.
[0138] In practical applications, we can use image caption technology and the open source nlpconnect / vit-gpt2-image-captioning model in huggingface to identify the high-level features of images, perform natural language conversion on the high-level features, and obtain the text content corresponding to the image.
[0139] When the document element is a table, the text content of each cell in the table is extracted according to the type of each cell in the table (such as whether it has a border or is merged) and the target order (from left to right, from top to bottom), and the text content of each extracted cell is spliced to obtain the text content corresponding to the table.
[0140] A first text feature corresponding to the first document may be obtained according to the text content of each document element in the first document, and a second text feature corresponding to the second document may be obtained according to the text content of each document element in the second document.
[0141] In some embodiments, obtaining a first text feature corresponding to the first document and a second text feature corresponding to the second document respectively according to the text content of each document element in the first document and the text content of each document element in the second document includes:
[0142] Splicing the text contents of each document element in the first document to obtain first spliced text content;
[0143] splicing the text contents of each document element in the second document to obtain second spliced text contents;
[0144] Inputting the first concatenated text content and the second concatenated text content into a trained second neural network model, obtaining a first text feature corresponding to the first document and a second text feature corresponding to the second document output by the second neural network model;
[0145] The second neural network model uses text content as training samples and text features of the text content as training labels.
[0146] After obtaining the text content of each document element in the first document, the embodiment of the present application can splice the text content of each document element in the first document to obtain a first spliced text content, for example, the first spliced text content is: level 1 title: text content; paragraph: text content; level 2 title: text content; picture: text content; table: text content.
[0147] Similarly, after the text content of each document element in the second document, the text content of each document element in the second document can be spliced to obtain second spliced text content.
[0148] The first concatenated text content and the second concatenated text content can be input into a trained second neural network model to obtain the first text features corresponding to the first document and the second text features corresponding to the second document output by the second neural network model; the second neural network model uses the text content as a training sample and the text features of the text content as training labels.
[0149] In practical applications, the second neural network model can be a BERT-WWM-Chinese model. The text content of each document element will be converted into the text content of the node. Through the BERT-WWM-Chinese model, the text content is converted into text features. The text features can specifically be feature vectors. Each text feature will be normalized and added together to express the feature vector of the concatenated text content.
[0150] In some embodiments, before respectively constructing a first graph structure corresponding to the first document and a second graph structure corresponding to the second document, the method further includes:
[0151] Converting the first document and the second document into a first picture and a second picture respectively;
[0152] The first image and the second image are identified to obtain a plurality of document elements corresponding to the first document and the second document, respectively, and element position features corresponding to each document element.
[0153] The above-mentioned embodiments have explained that in order to eliminate the differences in document formats and break the cross-format document similarity evaluation, the documents can be converted into pictures. Specifically, the first document is converted into a first picture, and the second document is converted into a second picture. The number of first pictures and second pictures can be multiple (one page of the document corresponds to one picture). When the sizes of the first picture and the second picture are different, at least one of the first picture and the second picture can be scaled so that the first picture and the second picture are the same size, for example, both are 640*640 pixels.
[0154] The embodiment of the present application can identify the first image and the second image through the aggregation-segmentation structure PP-Structure technology, and obtain multiple document elements corresponding to the first document and the second document respectively, as well as element position features corresponding to each document element.
[0155] Element position features refer to the position features of document elements in a document, which can be represented in the form of a vector. Element position features include but are not limited to the position height of the element in the document (including the page number of the target page where the document element is located and the height in the target page), area, indentation and other parameters.
[0156] In some embodiments, obtaining the similarity between the first document and the second document according to the first graph feature, the second graph feature, the first text feature, and the second text feature includes:
[0157] Determining a first similarity between the first image feature and the second image feature, and a second similarity between the first text feature and the second text feature;
[0158] The similarity between the first document and the second document is obtained according to the first similarity and the second similarity.
[0159] Specifically, the first similarity and the second similarity may both be cosine similarity, and the calculation formula of cosine similarity is the following formula (6):
[0160]
[0161] When calculating the first similarity, cosθ represents the first similarity, Characterize the first image features, Characterize the second graph features.
[0162] When calculating the second similarity, cosθ represents the second similarity, Characterize the first text feature, Characterize the second text feature.
[0163] The similarity between the first document and the second document can be obtained based on the first similarity and the second similarity. Specifically, it can be assumed that the influencing factor of the structural similarity is k1, the influencing factor of the document content is k2, the first similarity is cosθ1, and the second similarity is cosθ2, then the similarity between the text contents of the two documents can be k1cosθ1+k2cosθ2.
[0164] like Figure 3 As shown, the present embodiment provides a flowchart of a document comparison method, comprising the following steps:
[0165] Step 301: Convert the first document and the second document into the first picture and the second picture respectively; and execute step 302.
[0166] Step 302: Identify the first image and the second image, obtain multiple document elements corresponding to the first document and the second document, and element position features corresponding to each document element; execute steps 303, 304 and 308;
[0167] Step 303, respectively determine the element hierarchical relationship between any two adjacent document elements in the first document and the second document; jump to step 305;
[0168] Step 304: respectively determine the distance difference and the level difference between any two adjacent document elements in the first document and the second document, and determine the position similarity difference between the two adjacent document elements according to the distance difference and the level difference between the two adjacent document elements; jump to step 305;
[0169] Step 305: construct a first graph structure corresponding to the first document and a second graph structure corresponding to the second document respectively; the first graph structure and the second graph structure are used to represent element position features, element hierarchical relationships and position similarity differences of document elements in the corresponding first document and second document respectively; execute step 306;
[0170] Step 306: Input the first expression of the first graph structure and the second expression of the second graph structure into the trained first neural network model to obtain the first graph feature corresponding to the first graph structure and the second graph feature corresponding to the second graph structure output by the first neural network model; execute step 307;
[0171] Step 307, determine the first similarity between the first image feature and the second image feature; jump to step 312;
[0172] Step 308, extract the text content corresponding to each document element in the first document and the second document respectively; execute step 309;
[0173] Step 309, splicing the text contents of each document element in the first document to obtain first spliced text content; splicing the text contents of each document element in the second document to obtain second spliced text content; executing step 310;
[0174] Step 310: input the first concatenated text content and the second concatenated text content into the trained second neural network model to obtain the first text feature corresponding to the first document and the second text feature corresponding to the second document output by the second neural network model; and execute step 311;
[0175] Step 311, determining a second similarity between the first text feature and the second text feature; executing step 312;
[0176] Step 312: Obtain the similarity between the first document and the second document according to the first similarity and the second similarity.
[0177] The detailed implementation process of the above steps 301 to 312 is shown in the above embodiments and will not be described again here.
[0178] The document comparison method provided in the embodiment of the present application can be executed by a document comparison device. In the embodiment of the present application, the document comparison device provided in the embodiment of the present application is described by taking the document comparison method executed by the document comparison device as an example.
[0179] The embodiment of the present application also provides a document comparison device.
[0180] like Figure 4 As shown, the document comparison device includes: a construction module 410, a first determination module 420, a first acquisition module 430 and a second acquisition module 440.
[0181] A construction module 410 is used to construct a first graph structure corresponding to the first document and a second graph structure corresponding to the second document, respectively; the first graph structure and the second graph structure are used to represent element position features, element hierarchical relationships, and position similarity differences of document elements in the corresponding first document and the second document, respectively;
[0182] A first determining module 420, configured to determine a first graph feature of a first graph structure and a second graph feature of a second graph structure;
[0183] A first acquisition module 430, configured to acquire a first text feature corresponding to a first document and a second text feature corresponding to a second document;
[0184] The second acquisition module 440 is used to obtain the similarity between the first document and the second document according to the first image feature, the second image feature, the first text feature and the second text feature.
[0185] According to the document comparison device provided in the embodiment of the present application, a first graph structure corresponding to the first document and a second graph structure corresponding to the second document are respectively constructed; the first graph structure and the second graph structure are respectively used to characterize the element position characteristics, element hierarchical relationships and position similarity differences of the document elements in the corresponding first document and the second document; the first graph features of the first graph structure and the second graph features of the second graph structure are determined to achieve deep mining of the structural features of the two documents.
[0186] By obtaining the first text feature corresponding to the first document and the second text feature corresponding to the second document; obtaining the similarity between the first document and the second document according to the first graph feature, the second graph feature, the first text feature and the second text feature, the text features and structural features of the document elements themselves are integrated to determine the similarity between the two documents, enriching the dimension of similarity evaluation, and achieving more accurate and comprehensive determination of the similarity between the two documents.
[0187] In some embodiments, the construction module 410 is specifically used to:
[0188] Determine the position similarity difference between any two adjacent document elements in the first graph structure and the second graph structure based on the following method, where the two adjacent document elements include the first element and the second element:
[0189] Obtaining a distance difference between document elements represented by the first element and the second element, respectively, according to the page number of the first target page to which the first element belongs, the page number of the second target page to which the second element belongs, the height of the first element on the first target page, and the height of the second element on the second target page;
[0190] Obtaining a level difference between the first element and the second element according to the title level of the most recent document title to which the first element belongs and the title level of the most recent document title to which the second element belongs;
[0191] According to the distance difference and the level difference, the position similarity difference between the first element and the second element is obtained.
[0192] In some embodiments, the first determining module 420 is specifically configured to:
[0193] Inputting a first expression of the first graph structure and a second expression of the second graph structure into a trained first neural network model, obtaining a first graph feature corresponding to the first graph structure and a second graph feature corresponding to the second graph structure output by the first neural network model;
[0194] The first neural network model uses graph structure expressions as training samples and graph features of the graph structure as training labels.
[0195] In some embodiments, the first acquisition module 430 includes:
[0196] An extraction submodule, used to extract text contents corresponding to each document element in the first document and the second document respectively;
[0197] The first acquisition submodule is used to obtain first text features corresponding to the first document and second text features corresponding to the second document according to text contents of each document element in the first document and text contents of each document element in the second document.
[0198] In some embodiments, the extraction submodule is specifically used to:
[0199] When the document element is a picture, identify the high-level features of the picture, perform natural language conversion processing on the high-level features, and obtain the text content corresponding to the picture;
[0200] When the document element is a table, the text content of each unit in the table is extracted according to the type and target order of each unit in the table, and the extracted text content of each unit is spliced to obtain the text content corresponding to the table.
[0201] In some embodiments, the first acquisition submodule is used to
[0202] A first splicing unit, used to splice the text contents of each document element in the first document to obtain first spliced text content;
[0203] A second splicing unit, used to splice the text contents of each document element in the second document to obtain second spliced text contents;
[0204] An obtaining unit, used for inputting the first concatenated text content and the second concatenated text content into a trained second neural network model, and obtaining a first text feature corresponding to the first document and a second text feature corresponding to the second document output by the second neural network model;
[0205] The second neural network model uses text content as training samples and text features of the text content as training labels.
[0206] In some embodiments, the document comparison device further includes:
[0207] A conversion module, used to convert the first document and the second document into a first picture and a second picture respectively;
[0208] The recognition module is used to recognize the first image and the second image, and obtain a plurality of document elements corresponding to the first document and the second document respectively, and element position features corresponding to each document element.
[0209] In some embodiments, the second acquisition module 440 is specifically used to:
[0210] Determining a first similarity between the first image feature and the second image feature, and a second similarity between the first text feature and the second text feature;
[0211] The similarity between the first document and the second document is obtained according to the first similarity and the second similarity.
[0212] The document comparison device in the embodiment of the present application can be an electronic device, or a component in the electronic device, such as an integrated circuit or a chip. The electronic device can be a terminal, or other devices other than a terminal. Exemplarily, the electronic device can be a mobile phone, a tablet computer, a laptop computer, a PDA, a vehicle-mounted electronic device, a mobile Internet device (Mobile Internet Device, MID), an augmented reality (augmented reality, AR) / virtual reality (virtual reality, VR) device, a robot, a wearable device, an ultra-mobile personal computer (ultra-mobile personal computer, UMPC), a netbook or a personal digital assistant (personal digital assistant, PDA), etc., and can also be a server, a network attached storage (Network Attached Storage, NAS), a personal computer (personal computer, PC), a television (television, TV), a teller machine or a self-service machine, etc., which is not specifically limited in the embodiment of the present application.
[0213] The document comparison device in the embodiment of the present application may be a device having an operating system. The operating system may be a Microsoft (Windows) operating system, an Android (Android) operating system, an IOS operating system, or other possible operating systems, which are not specifically limited in the embodiment of the present application.
[0214] The document comparison device provided in the embodiment of the present application can achieve Figures 1 to 3 To avoid repetition, the various processes implemented by the method embodiment are not described here.
[0215] In some embodiments, Figure 5 As shown, an embodiment of the present application also provides an electronic device 500, including a processor 501, a memory 502, and a computer program stored in the memory 502 and executable on the processor 501. When the program is executed by the processor 501, each process of the above-mentioned document comparison method embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it will not be described here.
[0216] It should be noted that the electronic devices in the embodiments of the present application include the mobile electronic devices and non-mobile electronic devices mentioned above.
[0217] The electronic device package may include but is not limited to mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 5 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0218] The memory 502 may be a ROM (Read Only Memory) or other types of static storage devices that can store static information and instructions, a RAM (Random Access Memory) or other types of dynamic storage devices that can store information and instructions, or an EEPROM (Electrically Erasable Programmable Read Only Memory), a CD-ROM (Compact Disc Read Only Memory) or other optical disk storage, optical disk storage (including compressed optical disk, laser disk, optical disk, digital versatile disk, Blu-ray disk, etc.), magnetic disk storage media, other magnetic storage devices, or any other medium that can be used to carry or store computer programs and can be read by a computer, without limitation herein.
[0219] The memory 502 is used to store the computer program for executing the embodiment of the present application, and the execution is controlled by the memory 602. The memory 502 is used to execute the computer program stored in the memory 502 to implement the steps shown in the above method embodiment.
[0220] An embodiment of the present application also provides a non-transitory computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the various processes of the above-mentioned document comparison method embodiment are implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.
[0221] The processor is the processor in the electronic device described in the above embodiment. The readable storage medium includes a computer readable storage medium, such as a computer read-only memory ROM, a random access memory RAM, a magnetic disk or an optical disk.
[0222] It should be noted that the computer-readable medium mentioned above in the present disclosure may be a computer-readable signal medium or a computer-readable medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared or semiconductor system, device or device, 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), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. The computer readable signal medium may also be any computer readable medium other than a computer readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer readable medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.
[0223] An embodiment of the present application also provides a computer program product, including a computer program, which implements the above-mentioned document comparison method when executed by a processor.
[0224] The processor is the processor in the electronic device described in the above embodiment. The readable storage medium includes a computer readable storage medium, such as a computer read-only memory ROM, a random access memory RAM, a magnetic disk or an optical disk.
[0225] An embodiment of the present application further provides a chip, which includes a processor and a communication interface, wherein the communication interface is coupled to the processor, and the processor is used to run programs or instructions to implement the various processes of the above-mentioned document comparison method embodiment, and can achieve the same technical effect. To avoid repetition, it will not be repeated here.
[0226] It should be understood that the chip mentioned in the embodiments of the present application can also be called a system-level chip, a system chip, a chip system or a system-on-chip chip, etc.
[0227] It should be noted that, in this article, the terms "comprise", "include" or any other variant thereof are intended to cover non-exclusive inclusion, so that the process, method, article or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise one..." do not exclude the presence of other identical elements in the process, method, article or device including the element. In addition, it should be pointed out that the scope of the methods and devices in the embodiments of the present application is not limited to performing functions in the order shown or discussed, and may also include performing functions in a substantially simultaneous manner or in reverse order according to the functions involved, for example, the described method may be performed in an order different from that described, and various steps may also be added, omitted, or combined. In addition, the features described with reference to certain examples may be combined in other examples.
[0228] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned 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. Based on such an understanding, the technical solution of the present application, or the part that contributes to the relevant technology, can be embodied in the form of a computer software product, which is stored in a storage medium (such as ROM / RAM, a disk, or an optical disk), and includes a number of instructions for a terminal (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present application.
[0229] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present application, ordinary technicians in this field can also make many forms without departing from the purpose of the present application and the scope of protection of the claims, all of which are within the protection of the present application.
[0230] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "illustrative embodiments", "examples", "specific examples", or "some examples" means that the specific features, structures, materials, or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present application. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials, or characteristics described may be combined in any one or more embodiments or examples in a suitable manner.
[0231] Although the embodiments of the present application have been shown and described, those skilled in the art will appreciate that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present application, and that the scope of the present application is defined by the claims and their equivalents.
Claims
1. A document comparison method, characterized in that: include: A first graph structure corresponding to the first document and a second graph structure corresponding to the second document are respectively constructed; the first graph structure and the second graph structure are respectively used to characterize element position features, element hierarchical relationships, and position similarity differences of document elements in the corresponding first document and the second document; determining a first graph feature of the first graph structure and a second graph feature of the second graph structure; Acquire a first text feature corresponding to the first document and a second text feature corresponding to the second document; The similarity between the first document and the second document is obtained according to the first graph feature, the second graph feature, the first text feature, and the second text feature.
2. The document comparison method according to claim 1, characterized in that: The step of respectively constructing a first graph structure corresponding to the first document and a second graph structure corresponding to the second document includes: Determine the position similarity difference between any two adjacent document elements in the first graph structure and the second graph structure based on the following method, where the two adjacent document elements include the first element and the second element: Obtaining a distance difference between document elements represented by the first element and the second element, respectively, according to the page number of the first target page to which the first element belongs, the page number of the second target page to which the second element belongs, the height of the first element on the first target page, and the height of the second element on the second target page; Obtaining a level difference between the first element and the second element according to a title level of a recent document title to which the first element belongs and a title level of a recent document title to which the second element belongs; A position similarity difference between the first element and the second element is obtained according to the distance difference and the level difference.
3. The document comparison method according to claim 1, characterized in that: The determining of the first graph feature of the first graph structure and the second graph feature of the second graph structure includes: Inputting a first expression of the first graph structure and a second expression of the second graph structure into a trained first neural network model to obtain a first graph feature corresponding to the first graph structure output by the first neural network model and a second graph feature corresponding to the second graph structure; The first neural network model uses expressions of graph structure as training samples and graph features of graph structure as training labels.
4. The document comparison method according to claim 1, characterized in that: The acquiring a first text feature corresponding to the first document and a second text feature corresponding to the second document includes: Extracting text contents corresponding to each document element in the first document and the second document; According to the text content of each document element in the first document and the text content of each document element in the second document, a first text feature corresponding to the first document and a second text feature corresponding to the second document are obtained respectively.
5. The document comparison method according to claim 4, characterized in that: The extracting text contents corresponding to the document elements in the first document and the second document respectively includes: When the document element is a picture, identifying high-level features of the picture, performing natural language conversion processing on the high-level features, and obtaining text content corresponding to the picture; In the case where the document element is a table, the text content of each unit in the table is extracted according to the type and target order of each unit in the table, and the extracted text content of each unit is spliced to obtain the text content corresponding to the table.
6. The document comparison method according to claim 4, characterized in that: The obtaining, according to the text content of each document element in the first document and the text content of each document element in the second document, a first text feature corresponding to the first document and a second text feature corresponding to the second document respectively includes: splicing the text contents of each document element in the first document to obtain first spliced text content; splicing the text contents of each document element in the second document to obtain second spliced text contents; Inputting the first concatenated text content and the second concatenated text content into a trained second neural network model, and obtaining a first text feature corresponding to the first document and a second text feature corresponding to the second document output by the second neural network model; The second neural network model uses text content as training samples and text features of the text content as training labels.
7. The document comparison method according to claim 1, characterized in that: Before respectively constructing the first graph structure corresponding to the first document and the second graph structure corresponding to the second document, the method further includes: Converting the first document and the second document into a first picture and a second picture respectively; The first image and the second image are identified, and a plurality of document elements corresponding to the first document and the second document are obtained, as well as element position features corresponding to each document element.
8. The document comparison method according to any one of claims 1 to 7, characterized in that: The obtaining the similarity between the first document and the second document according to the first graph feature, the second graph feature, the first text feature, and the second text feature includes: Determining a first similarity between the first graph feature and the second graph feature, and a second similarity between the first text feature and the second text feature; The similarity between the first document and the second document is obtained according to the first similarity and the second similarity.
9. A document comparison device, characterized in that: include: A construction module, used to construct a first graph structure corresponding to the first document and a second graph structure corresponding to the second document, respectively; the first graph structure and the second graph structure are used to represent element position features, element hierarchical relationships and position similarity differences of document elements in the corresponding first document and second document, respectively; A first determining module, configured to determine a first graph feature of the first graph structure and a second graph feature of the second graph structure; A first acquisition module, used to acquire a first text feature corresponding to the first document and a second text feature corresponding to the second document; The second acquisition module is used to obtain the similarity between the first document and the second document according to the first graph feature, the second graph feature, the first text feature and the second text feature.
10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the document comparison method according to any one of claims 1 to 8 is implemented.
Citation Information
Cited By
File circulation tracing method and device, equipment and storage medium
CN120896769A