Contract auditing method and device based on text comparison matrix and storage medium
Through the contract audit method based on text comparison matrix, the problems of contract auditing time and manual auditing workload in the existing technology are solved, and the effect of improving the efficiency and accuracy of contract auditing is achieved.
Patent Information
- Application Number
- CN202411824199.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-11
- Publication Date
- 2025-04-04
AI Technical Summary
The existing contract review methods have huge data volumes of grid tables with words as elements, which can take a long time to detect differences and have a large amount of manual review work, which affects efficiency and accuracy.
The contract review method based on the text comparison matrix is adopted. By obtaining the contracts to be reviewed and the template contracts, the content similarity between each contract entries is calculated, the text comparison matrix is constructed, and the step-by-step diagonal detection is carried out to determine the addition, deletion and modification of entries.
It improves the efficiency and accuracy of contract audits, reduces the workload of manual audits, and enables users to quickly and accurately grasp the changes in contracts and maintains the consistency and accuracy of contracts.
Smart Images

Figure CN119761337A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of natural language processing, and in particular to a contract review method, device and storage medium based on a text comparison matrix. Background Art
[0002] The existing contract review scheme is to establish a comparison grid table with words as elements, compare the contracts of Party A and Party B and divide them into two types of differences, namely addition and deletion, and then manually review whether the differences are acceptable. However, due to the huge amount of data in the grid table with words as elements, it takes a long time for the program to automatically detect the differences. After the differences are detected, the difference words and the words around them are combined into a set, and the set is handed over to manual review. If there are multiple difference words in a paragraph of the contract, but they are far apart, it will lead to manual review sentence by sentence, which increases the workload and time of manual review, affecting the efficiency and accuracy of contract review. Summary of the invention
[0003] The purpose of the present invention is to solve one of the technical problems existing in the prior art to at least a certain extent.
[0004] To this end, an object of an embodiment of the present invention is to provide a contract review method based on a text comparison matrix, which improves the efficiency and accuracy of contract review.
[0005] Another object of an embodiment of the present invention is to provide a contract review device based on a text comparison matrix.
[0006] In order to achieve the above technical objectives, the technical solutions adopted by the embodiments of the present invention include:
[0007] On the one hand, an embodiment of the present invention provides a contract review method based on a text comparison matrix, comprising the following steps:
[0008] Acquire the contract to be reviewed and the template contract, and number and sort the contract items of the contract to be reviewed and the template contract respectively to obtain a sequence of items to be reviewed and a sequence of items in the template;
[0009] Traversing the sequence of items to be reviewed and the sequence of template items, and calculating the content similarity between each item to be reviewed and each template item;
[0010] Constructing a text comparison matrix between the to-be-reviewed item sequence and the template item sequence according to the content similarity;
[0011] A step-by-step diagonal detection is performed on the text comparison matrix to obtain an optimal solution path, and then new entries, deleted entries, and modified entries are determined based on the optimal solution path.
[0012] Furthermore, in one embodiment of the present invention, the calculating of the content similarity between each to-be-reviewed item and each template item specifically includes:
[0013] Determine the first text of the item to be reviewed, and determine the second text of the template item;
[0014] Calculating the cosine similarity, Jacard similarity and edit distance similarity between the first text and the second text;
[0015] The content similarity between the to-be-reviewed item and the template item is determined according to an average value of the cosine similarity, the Jacard similarity, and the edit distance similarity.
[0016] Furthermore, in one embodiment of the present invention, the cosine similarity is calculated by the following steps:
[0017] Performing word segmentation processing on the first text and the second text respectively to obtain a first vocabulary and a second vocabulary;
[0018] Merging and removing duplicates from the first vocabulary list and the second vocabulary list to obtain a third vocabulary list;
[0019] Calculate the word frequency of each word in the third word list in the first text to obtain a first word frequency sequence, and calculate the word frequency of each word in the third word list in the second text to obtain a second word frequency sequence;
[0020] Performing vectorization processing on the first word frequency sequence to obtain a first word frequency feature vector of the first text, and performing vectorization processing on the second word frequency sequence to obtain a second word frequency feature vector of the second text;
[0021] The cosine similarity between the first text and the second text is determined according to the cosine values of the first word frequency feature vector and the second word frequency feature vector.
[0022] Furthermore, in one embodiment of the present invention, the Jacard similarity is calculated by the following formula:
[0023]
[0024] Among them, similarity Jacard represents the Jacard similarity between the first text and the second text, A represents the first vocabulary corresponding to the first text, B represents the second vocabulary corresponding to the second text, len represents the vocabulary length, and α represents the preset penalty coefficient.
[0025] Furthermore, in one embodiment of the present invention, the edit distance similarity is calculated by the following formula:
[0026]
[0027] Among them, similarity edit represents the edit distance similarity between the first text and the second text, a represents the first string corresponding to the first text, b represents the second string corresponding to the second text, |a| represents the length of the first string, |b| represents the length of the second string, lev a,b (|a|,|b|) represents the edit distance between the first string and the second string;
[0028] The edit distance is obtained by recursion using the following formula:
[0029]
[0030] Among them, lev a,b (i,j) represents the edit distance between the first i characters of a and the first j characters of b. i represents the i-th character of a, b j represents the jth character of b, is an indicator function, when a i =b j When , its value is 0, otherwise its value is 1, i∈{1,2,…,|a|}, j∈{1,2,…,|b|}.
[0031] Furthermore, in one embodiment of the present invention, the step of constructing a text comparison matrix between the to-be-reviewed item sequence and the template item sequence according to the content similarity specifically includes:
[0032] Determine a first number of rows according to the number of the items to be reviewed, determine a first number of columns according to the number of the template items, and construct an initial matrix according to the first number of rows and the first number of columns;
[0033] When the content similarity between the mth item to be reviewed in the item to be reviewed sequence and the nth template item in the template item sequence is greater than or equal to a preset first threshold value and less than a similarity upper limit value, assigning a preset first value to the element in the mth row and nth column of the initial matrix;
[0034] When the content similarity between the mth item to be reviewed in the sequence of items to be reviewed and the nth template item in the sequence of template items is equal to the similarity upper limit value, assigning the element of the mth row and nth column of the initial matrix a preset second value;
[0035] When the content similarity between the mth to-be-audited entry in the to-be-audited entry sequence and the nth template entry in the template entry sequence is less than the first threshold, the element in the mth row and nth column of the initial matrix is assigned a value of zero.
[0036] Further, in one embodiment of the present invention, the stepwise diagonal detection of the text contrast matrix to obtain the optimal solution path specifically includes:
[0037] Reading the values of matrix elements starting from the upper left corner of the text comparison matrix;
[0038] When the current element is a non-zero value, add the current element to the preset element sequence and jump to the element at the lower right corner of the current element;
[0039] When the current element is zero, mark the current element and traverse the elements to the right. If a non-zero value element is detected, add the non-zero value element to the preset element sequence and jump to the element at the lower right corner of the non-zero value element. If no non-zero value is detected, jump to the element below the marked current element.
[0040] The optimal solution path is determined according to the elements in the element sequence.
[0041] Further, in an embodiment of the present invention, the determining of adding new entries, deleting entries, and modifying entries according to the optimal solution path specifically includes:
[0042] Traversing the row number and column number of each element in the optimal solution path in the text comparison matrix to obtain a row number sequence and a column number sequence;
[0043] Determine the missing row number corresponding to the row number sequence according to the first row number, and determine, according to the missing row number, that the to-be-audited entry with the corresponding serial number in the to-be-audited entry sequence is the newly added entry;
[0044] Determine the missing column number corresponding to the column number sequence according to the first column number, and determine the template entry with the corresponding sequence number in the template entry sequence as a deleted entry according to the missing column number;
[0045] Read the value of each element in the optimal solution path;
[0046] When the element is a first numerical value, the to-be-reviewed entry with the corresponding serial number in the to-be-reviewed entry sequence is determined to be the modified entry according to the row number of the element in the text comparison matrix, and the template entry with the corresponding serial number in the template entry sequence is determined to be the original entry corresponding to the modified entry according to the column number of the element in the text comparison matrix.
[0047] On the other hand, an embodiment of the present invention provides a contract review device based on a text comparison matrix, comprising:
[0048] An item sequence generation module is used to obtain the contract to be reviewed and the template contract, and to number and sort the contract items of the contract to be reviewed and the template contract to obtain an item sequence to be reviewed and a template item sequence;
[0049] A content similarity calculation module, used to traverse the sequence of items to be reviewed and the sequence of template items, and calculate the content similarity between each item to be reviewed and each template item;
[0050] A text comparison matrix construction module, used to construct a text comparison matrix between the to-be-reviewed item sequence and the template item sequence according to the content similarity;
[0051] The matrix detection module is used to perform a step-by-step diagonal detection on the text comparison matrix to obtain an optimal solution path, and then determine to add new entries, delete entries, and modify entries according to the optimal solution path.
[0052] On the other hand, an embodiment of the present invention provides an electronic device, comprising a memory, a processor, a program stored in the memory and executable on the processor, and a data bus for realizing connection and communication between the processor and the memory, wherein the program, when executed by the processor, realizes the contract review method based on the text comparison matrix as described above.
[0053] On the other hand, an embodiment of the present invention further provides a storage medium, which is a computer-readable storage medium used for computer-readable storage, and the storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement the contract review method based on the text comparison matrix as described above.
[0054] The advantages and beneficial effects of the present invention will be partly given in the following description, partly become apparent from the following description, or be understood through the practice of the present invention:
[0055] The embodiment of the present invention obtains a contract to be reviewed and a template contract, and numbers and sorts each contract item of the contract to be reviewed and the template contract respectively, obtains a sequence of items to be reviewed and a sequence of template items, traverses the sequence of items to be reviewed and the sequence of template items, calculates the content similarity between each item to be reviewed and each template item, constructs a text comparison matrix of the sequence of items to be reviewed and the sequence of template items according to the content similarity, performs a step diagonal detection on the text comparison matrix, obtains an optimal solution path, and then determines the newly added items, deleted items, and modified items according to the optimal solution path. The embodiment of the present invention numbers and sorts each contract item of the contract to be reviewed and the template contract, calculates the content similarity between the item to be reviewed and the template item, and constructs a text comparison matrix according to the content similarity, searches for the optimal solution path in the text comparison matrix based on the step diagonal detection, determines the newly added items, deleted items, and modified items according to the obtained optimal solution path, facilitates the subsequent manual review of the newly added items, deleted items, and modified items, reduces the workload of manual review, improves the efficiency and accuracy of contract review, and enables users to more quickly and accurately grasp the changes in the contract, thereby better maintaining the consistency and accuracy of the contract. BRIEF DESCRIPTION OF THE DRAWINGS
[0056] In order to more clearly illustrate the technical solution in the embodiments of the present invention, the following introduction is made to the drawings required for use in the embodiments of the present invention. It should be understood that the drawings introduced below are only for the convenience of clearly describing some embodiments of the technical solution of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.
[0057] Figure 1 A flowchart of the steps of a contract review method based on a text comparison matrix provided by an embodiment of the present invention;
[0058] Figure 2 A step flow chart of step S102 provided in an embodiment of the present invention;
[0059] Figure 3 A flow chart of steps for calculating cosine similarity provided by an embodiment of the present invention;
[0060] Figure 4 A step flow chart of step S103 provided in an embodiment of the present invention;
[0061] Figure 5 A schematic diagram of a text comparison matrix provided by an embodiment of the present invention;
[0062] Figure 6 A step flow chart of step S104 provided in an embodiment of the present invention;
[0063] Figure 7 Another step flow chart of step S104 provided in an embodiment of the present invention;
[0064] Figure 8 A schematic diagram of the structure of a contract review device based on a text comparison matrix provided by an embodiment of the present invention;
[0065] Fig. 9 A schematic diagram of the hardware structure of an electronic device provided by an embodiment of the present invention;
[0066] Fig.10 A schematic diagram of the structure of a storage medium provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0067] Embodiments of the present invention are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present application, and cannot be understood as limitations on the present application. It should be noted that, although the functional module division is performed in the system schematic diagram and the logical order is shown in the flow chart, in some cases, the steps shown or described may be performed in a different order from the module division in the system schematic diagram or the flow chart. For the step numbers in the following embodiments, they are only set for the convenience of explanation, and the order between the steps is not limited in any way. The execution order of each step in the embodiment can be adaptively adjusted according to the understanding of those skilled in the art.
[0068] In the description of the present invention, the meaning of "a plurality" is two or more. If there is a description of the first or the second, it is only for the purpose of distinguishing the technical features, and it cannot be understood as indicating or implying the relative importance or implicitly indicating the number of the indicated technical features or implicitly indicating the order of the indicated technical features. In addition, unless otherwise defined, all technical and scientific terms used in this document have the same meaning as those commonly understood by technicians in the technical field of this application. The terms used in this document are only for the purpose of describing the embodiments of the present application and are not intended to limit the present application.
[0069] The contract review method based on the text comparison matrix provided in the embodiment of the present application can be applied to the terminal, can also be applied to the server side, and can also be software running in the terminal or the server side. In some embodiments, the terminal can be a smart phone, a tablet computer, a laptop computer, a desktop computer, a set-top box, etc.; the server side can be configured as an independent physical server, or a server cluster or distributed system composed of multiple physical servers, and can also be configured as a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms; the software can be an application that implements the contract review method based on the text comparison matrix, etc., but is not limited to the above forms.
[0070] The present application can be used in many general or special computer system environments or configurations. For example: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronic devices, network PCs, minicomputers, mainframe computers, distributed computing environments including any of the above systems or devices, etc. The present application can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The present application can also be practiced in distributed computing environments, in which tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules can be located in local and remote computer storage media including storage devices.
[0071] It should be noted that in each specific implementation of the present application, when it comes to the need to perform relevant processing based on data related to user identity or characteristics such as user information, user behavior data, user historical data, and user location information, the user's permission or consent will be obtained first, and the collection, use, and processing of these data will comply with the relevant laws, regulations, and standards of the relevant countries and regions. In addition, when the embodiment of the present application needs to obtain the user's sensitive personal information, the user's separate permission or consent will be obtained through a pop-up window or by jumping to a confirmation page. After clearly obtaining the user's separate permission or consent, the necessary user-related data for the normal operation of the embodiment of the present application will be obtained.
[0072] like Figure 1 FIG. 1 is a flowchart of a method for contract review based on a text comparison matrix according to an embodiment of the present invention. Figure 1The embodiment of the present invention provides a contract review method based on a text comparison matrix, which specifically includes the following steps:
[0073] S101, obtaining the contract to be reviewed and the template contract, and numbering and sorting the contract items of the contract to be reviewed and the template contract respectively to obtain a sequence of items to be reviewed and a sequence of template items;
[0074] S102, traversing the sequence of items to be reviewed and the sequence of template items, and calculating the content similarity between each item to be reviewed and each template item;
[0075] S103, constructing a text comparison matrix between the to-be-reviewed item sequence and the template item sequence according to the content similarity;
[0076] S104, performing a step-by-step diagonal detection on the text comparison matrix to obtain an optimal solution path, and then determining to add new entries, delete entries, and modify entries according to the optimal solution path.
[0077] The embodiment of the present invention numbers and sorts the various contract items of the contract to be reviewed and the template contract, calculates the content similarity between the items to be reviewed and the template items, and constructs a text comparison matrix based on the content similarity, and searches for the optimal solution path in the text comparison matrix based on the step diagonal detection, and determines the newly added items, deleted items and modified items according to the obtained optimal solution path, so as to facilitate the subsequent manual review of the newly added items, deleted items and modified items, reduce the workload of manual review, improve the efficiency and accuracy of contract review, and enable users to grasp the changes in the contract more quickly and accurately, thereby better maintaining the consistency and accuracy of the contract.
[0078] The specific steps of the embodiment of the present invention are described below.
[0079] First, the contract to be reviewed and the corresponding template contract (i.e., the original contract) are obtained, and the contract items in the contract to be reviewed and the template contract are numbered and sorted, respectively, to obtain the sequence of items to be reviewed and the sequence of template items. Since each part of the contract is composed of multiple items, the present invention reviews the contract items as units, which can avoid multiple reviews of the same sentence, and the amount of data in the matrix formed is also small, and the time for automatic detection of the program is greatly shortened.
[0080] For each to-be-reviewed item in the to-be-reviewed item sequence, the content similarity between the item and each template item in the template item sequence is calculated.
[0081] like Figure 2 FIG. 1 is a flowchart of step S101 provided in an embodiment of the present invention, referring to FIG. Figure 2As an optional implementation, the content similarity between each to-be-reviewed item and each template item is calculated, which specifically includes:
[0082] S1021, determining the first text of the item to be reviewed, and determining the second text of the template item;
[0083] S1022, calculating the cosine similarity, Jacard similarity and edit distance similarity between the first text and the second text;
[0084] S1023. Determine the content similarity between the item to be reviewed and the template item according to the average value of the cosine similarity, the Jacard similarity, and the edit distance similarity.
[0085] Specifically, the first text of the item to be reviewed is determined, and the second text of the template item is determined, and then the cosine similarity, Jacard similarity and edit distance similarity between the first text and the second text are calculated, and the average of the three is the content similarity between the item to be reviewed and the template item.
[0086] like Figure 3 FIG. 1 is a flowchart of a step of calculating cosine similarity provided by an embodiment of the present invention, referring to FIG. Figure 3 , further as an optional implementation, the cosine similarity is calculated by the following steps:
[0087] S201, performing word segmentation processing on a first text and a second text respectively to obtain a first vocabulary and a second vocabulary;
[0088] S202, merging and removing duplicates from the first vocabulary and the second vocabulary to obtain a third vocabulary;
[0089] S203, calculating the word frequency of each word in the third word list in the first text to obtain a first word frequency sequence, and calculating the word frequency of each word in the third word list in the second text to obtain a second word frequency sequence;
[0090] S204, performing vectorization processing on the first word frequency sequence to obtain a first word frequency feature vector of the first text, and performing vectorization processing on the second word frequency sequence to obtain a second word frequency feature vector of the second text;
[0091] S205 . Determine the cosine similarity between the first text and the second text according to the cosine values of the first word frequency feature vector and the second word frequency feature vector.
[0092] Specifically, the cosine value of the angle between two vectors in a vector space can be used as a measure of the difference between two individuals. The closer the cosine value is to 1, the closer the angle is to 0, indicating that the two vectors are more similar. The closer the cosine value is to 0, the closer the angle is to 90 degrees, indicating that the two vectors are less similar. In the embodiment of the present invention, the calculation process of the cosine similarity between the first text and the second text is as follows:
[0093] Segment the first and second texts to be compared respectively to obtain two word lists:
[0094] A=[t1,t2,…,t i ],B=[t1,t2,…,t j ]
[0095] Merge the two word lists and remove duplicates to get a third word list containing all the words in the input sample:
[0096] T(A,B)=T(A)+T(B)=[t1,t2,…,t K ]
[0097] The word frequencies of each word in the third word list in the first text and the second text are selected as feature values to obtain the first word frequency sequence and the second word frequency sequence:
[0098] F(A)=[F A1 ,F A2 ,…,F Ak ]
[0099] F(B)=[F B1 ,F B2 ,…,F Bk ]
[0100] The first word frequency sequence and the second word frequency sequence are vectorized to obtain the first word frequency feature vector and the second word frequency feature vector:
[0101]
[0102] Finally, the cosine value of the first word frequency feature vector and the second word frequency feature vector is calculated as the cosine similarity between the first text and the second text. The closer the cosine similarity is to 1, the more similar the first text and the second text are:
[0103]
[0104] Among them, similarity cos Represents the cosine similarity between the first text and the second text.
[0105] As an optional implementation, the Jacard similarity is calculated by the following formula:
[0106]
[0107] Among them, similarity Jacard represents the Jacard similarity between the first text and the second text, A represents the first vocabulary corresponding to the first text, B represents the second vocabulary corresponding to the second text, len represents the vocabulary length, and α represents the preset penalty coefficient.
[0108] Specifically, the Jacard similarity is used to compare the similarities and differences between finite sample sets, and calculate the ratio of the intersection and union of the sample sets. The larger the ratio, the lower the similarity. However, if there are many repeated words in the set, the accuracy of the calculated similarity will be greatly reduced. Therefore, the embodiment of the invention modifies it and introduces a penalty coefficient related to the text length difference. The penalty coefficient can be adjusted according to the similarity effect. According to the above formula, the closer the Jacard similarity is to 1, the more similar the first text and the second text are.
[0109] As an optional implementation, the edit distance similarity is calculated by the following formula:
[0110]
[0111] Among them, similarity edit represents the edit distance similarity between the first text and the second text, a represents the first string corresponding to the first text, b represents the second string corresponding to the second text, |a| represents the length of the first string, |b| represents the length of the second string, lev a,b (|a|,|b|) represents the edit distance between the first string and the second string;
[0112] The edit distance is obtained by recursion using the following formula:
[0113]
[0114] Among them, lev a,b (i,j) represents the edit distance between the first i characters of a and the first j characters of b. i represents the i-th character of a, b j represents the jth character of b, is an indicator function, when a i =b j When , its value is 0, otherwise its value is 1, i∈{1,2,…,|a|}, j∈{1,2,…,|b|}.
[0115] It should be noted that the first formula in the min operation of the above formula corresponds to deleting characters from the first text to obtain the second text; the second formula corresponds to inserting characters into the first text to obtain the second text; and the third formula corresponds to replacing characters in the first text to obtain the second text.
[0116] Specifically, the edit distance refers to the minimum number of changes required to edit the first text into the second text (only one word can be added, deleted or modified each time). The edit distance is symmetrical, that is, the minimum number of changes to convert the first text into the second text and the minimum number of changes to convert the second text into the first text are equal. The edit distance similarity between the two texts can be calculated by calculating the edit distance. From the above formula, it can be seen that the larger the edit distance, the smaller the edit distance similarity, and the closer the edit distance similarity is to 1, the more similar the first text and the second text are.
[0117] After calculating the cosine similarity, Jacard similarity, and edit distance similarity between the first text and the second text, the content similarity between the item to be reviewed and the template item can be calculated by the following formula:
[0118] similarity=[similarity cos +similarity Jacard +similarity edit ] / 3
[0119] like Figure 4 FIG. 1 is a flow chart of step S103 provided in an embodiment of the present invention, referring to FIG. Figure 4 As an optional implementation, a text comparison matrix between the to-be-reviewed item sequence and the template item sequence is constructed according to the content similarity, which specifically includes:
[0120] S1031, determining the first number of rows according to the number of items to be reviewed, determining the first number of columns according to the number of template items, and constructing an initial matrix according to the first number of rows and the first number of columns;
[0121] S1032: when the content similarity between the mth item to be reviewed in the sequence of items to be reviewed and the nth template item in the sequence of template items is greater than or equal to a preset first threshold value and less than an upper limit value of the similarity, assigning a preset first value to the element in the mth row and nth column of the initial matrix;
[0122] S1033, when the content similarity between the mth item to be reviewed in the item to be reviewed sequence and the nth template item in the template item sequence is equal to the similarity upper limit value, assigning the element of the mth row and nth column of the initial matrix to a preset second value;
[0123] S1034: When the content similarity between the mth item to be reviewed in the item to be reviewed sequence and the nth template item in the template item sequence is less than a first threshold, assigning a value of zero to the element in the mth row and nth column of the initial matrix.
[0124] Specifically, a two-dimensional matrix is defined with the horizontal axis being the template item number axis and the vertical axis being the pending item number axis. The content similarity between the mth pending item in the pending item sequence and the nth template item in the template item sequence is determined. When the content similarity is greater than or equal to 90% (the first threshold value) and less than 100% (the upper limit of similarity), the element in the mth row and nth column is assigned a value of 1 (the first numerical value); when the content similarity is equal to 100%, the element in the mth row and nth column is assigned a value of 2 (the second numerical value); when the content similarity is less than 90%, the element in the mth row and nth column is assigned a value of 0.
[0125] For example, the similarity between the content of the pending item No. 1 and the content of the template item No. 1 is 90.356%, so the matrix element [1,1] is assigned to 1; the similarity between the content of the pending item No. 2 and the content of the template item No. 2 is 92.363%, so the matrix element [2,2] is assigned to 1; the similarity between the content of the pending item No. 3 and the content of the template item No. 3 is 90.153%, so the matrix element [3,3] is assigned to 1; the similarity between the content of the pending item No. 4 and the content of the template item No. 4 is 5.171%, which does not reach 90%, so the matrix element [ 4,4] is assigned to 0; the similarity between the content of the item number 4 to be reviewed and the content of the template item number 5 is 100%, and the matrix element [4,5] is assigned to 2; the similarity between the content of the item number 5 to be reviewed and the content of all template item numbers does not reach 90%, and the elements in the 5th row of the matrix are all assigned to 0; the similarity between the content of the item numbers 6, 7, 8, 9, and 10 to be reviewed and the content of the template item numbers 6, 7, 8, 9, and 10 is 100%, and the matrix elements [6,6], [7,7], [8,8], [9,9], and [10,10] are all assigned to 2. The schematic diagram of the final text comparison matrix is shown below. Figure 5 shown.
[0126] like Figure 6 FIG. 1 is another step flow chart of step S104 provided in an embodiment of the present invention, referring to FIG. Figure 6 As an optional implementation, a step-wise diagonal detection is performed on the text comparison matrix to obtain an optimal solution path, which specifically includes:
[0127] S1041, reading the values of the matrix elements starting from the upper left corner of the text comparison matrix;
[0128] S1042. When the current element is a non-zero value, add the current element to a preset element sequence, and jump to the element at the lower right corner of the current element;
[0129] S1043, when the current element is zero value, mark the current element and traverse the elements to the right, if a non-zero value element is detected, add the non-zero value element to the preset element sequence, and jump to the element at the lower right corner of the non-zero value element, if no non-zero value is detected, jump to the element below the marked current element;
[0130] S1044. Determine an optimal solution path according to the elements in the element sequence.
[0131] Specifically, the staircase diagonal detection is similar to the main diagonal detection. It first detects from the upper left corner of the matrix. When a non-zero value is detected, the next value is detected in the lower right corner. When a zero value is detected, it is marked and detected to the right until a non-zero value is detected. The next value is continued to be detected in the lower right corner. If all the detections to the right are zero, the next value is detected downward from the marked position. The above steps are repeated until the last row or column is reached.
[0132] When performing the detection, start with element [1,1] (first row, first column). If it is not 0, it is considered that the content of the item number 1 to be reviewed corresponds to the content of the template item number 1 (modified or not modified), and the element [1,1] is added to the element sequence, and the row number and column number are both increased by 1 to start the detection of the next matrix element; if the element [4,4] is 0, the column number is increased by 1 to detect to the right, that is, the element [4,5] is detected. If it is not 0, it is considered that the content of the item number 4 to be reviewed corresponds to the content of the template item number 5 (modified or not modified), and the element [4,5] is added to the element sequence. If it is 0, continue to detect to the right; if the detection to the right is all zero, such as Figure 5 The content of the item number 5 in the template entry is not similar to the content of all the numbers in the template entry. The item number 5 in the template entry is new content. The element [6,6] is detected from the marked element [5,6] downward. In addition, if the values of a column of elements are all 0, as shown in the attached Figure 5 If there is no element in the 4th column in the template entry number 4, then none of the items to be reviewed is similar to the content of template item number 4, that is, the content of template item number 4 is deleted.
[0133] like Figure 7 FIG. 1 is another step flow chart of step S104 provided in an embodiment of the present invention, referring to FIG. Figure 7 As an optional implementation, determining to add new entries, delete entries, and modify entries according to the optimal solution path specifically includes:
[0134] S1045, traversing the row number and column number of each element in the optimal solution path in the text comparison matrix to obtain a row number sequence and a column number sequence;
[0135] S1046, determining the missing row number corresponding to the row number sequence according to the first row number, and determining the to-be-audited entry with the corresponding sequence number in the to-be-audited entry sequence as a newly added entry according to the missing row number;
[0136] S1047, determining the missing column number corresponding to the column number sequence according to the first column number, and determining the template entry with the corresponding sequence number in the template entry sequence as a deletion entry according to the missing column number;
[0137] S1048, reading the value of each element in the optimal solution path;
[0138] S1049. When the element is the first numerical value, determine that the to-be-reviewed entry with the corresponding serial number in the to-be-reviewed entry sequence is the modified entry according to the row number of the element in the text comparison matrix, and determine that the template entry with the corresponding serial number in the template entry sequence is the original entry corresponding to the modified entry according to the column number of the element in the text comparison matrix.
[0139] Specifically, Figure 5 For example, the optimal solution path can be expressed as {element [1,1] = 1, element [2,2] = 1, element [3,3] = 1, element [4,5] = 2, element [6,6] = 2, element [7,7] = 2, element [8,8] = 2, element [9,9] = 2, element [10,10] = 2}. According to the optimal solution path, the row number sequence is {1,2,3,4,6,7,8,9,10}, and the column number sequence is {1,2,3,5,6,7,8,9,10}. Correspondingly, the missing rows can be determined. The number is 5, which means the fifth item to be reviewed is a newly added item, and the missing column number is 4, which means the fourth template item is a deleted item. In addition, for elements [1,1], [2,2], and [3,3] whose element values are not 2, the first item to be reviewed is determined to be a modified item, and the first template item is the corresponding original item. The second item to be reviewed is determined to be a modified item, and the second template item is the corresponding original item. The third item to be reviewed is determined to be a modified item, and the third template item is the corresponding original item. It can be judged that the contract to be reviewed has modified Articles 1, 2, and 3 of the template contract, and deleted Article 4 of the template contract. Article 4 of the contract to be reviewed is the same as Article 5 of the template. Article 5 of the contract to be reviewed is a newly added item, and Articles 6, 7, 8, 9, and 10 of the contract to be reviewed are completely consistent with the template contract.
[0140] After determining the new items, deleted items and modified items, the auditor can be reminded to review the new items, deleted items and modified items, thereby greatly improving the efficiency and accuracy of contract review.
[0141] The above is an explanation of the method steps of the embodiment of the present invention. It can be recognized that the embodiment of the present invention numbers and sorts the various contract items of the contract to be reviewed and the template contract, calculates the content similarity between the items to be reviewed and the template items, and constructs a text comparison matrix based on the content similarity, finds the optimal solution path in the text comparison matrix based on the step diagonal detection, determines the new items, delete items and modify items according to the obtained optimal solution path, facilitates the subsequent manual review of the new items, delete items and modify items, reduces the workload of manual review, improves the efficiency and accuracy of contract review, and allows users to grasp the changes in the contract more quickly and accurately, thereby better maintaining the consistency and accuracy of the contract.
[0142] like Figure 8 FIG. 1 is a schematic diagram of a structure of a contract review device based on a text comparison matrix provided by an embodiment of the present invention, referring to FIG. Figure 8 , an embodiment of the present invention provides a contract review device based on a text comparison matrix, comprising:
[0143] An item sequence generation module is used to obtain the contract to be reviewed and the template contract, and to sort the contract items of the contract to be reviewed and the template contract by number, so as to obtain the item sequence to be reviewed and the template item sequence;
[0144] A content similarity calculation module is used to traverse the sequence of items to be reviewed and the sequence of template items, and calculate the content similarity between each item to be reviewed and each template item;
[0145] A text comparison matrix construction module is used to construct a text comparison matrix between the to-be-reviewed item sequence and the template item sequence according to content similarity;
[0146] The matrix detection module is used to perform step-by-step diagonal detection on the text comparison matrix to obtain the optimal solution path, and then determine the addition, deletion and modification of entries based on the optimal solution path.
[0147] The contents of the above method embodiments are all applicable to the present device embodiments. The functions specifically implemented by the present device embodiments are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.
[0148] The embodiment of the present invention further provides an electronic device, the electronic device comprising: a memory, a processor, a program stored in the memory and executable on the processor, and a data bus for realizing connection and communication between the processor and the memory, and the program is executed by the processor to realize the above-mentioned contract review method based on text comparison matrix. The electronic device can be any intelligent terminal including a tablet computer, a vehicle-mounted computer, etc.
[0149] like Fig. 9FIG. 1 is a schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present invention, referring to FIG. Fig. 9 , an embodiment of the present invention provides an electronic device, including:
[0150] The processor 901 may be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of the present invention;
[0151] The memory 902 can be implemented in the form of a read-only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 902 can store an operating system and other application programs. When the technical solution provided in the embodiment of this specification is implemented by software or firmware, the relevant program code is stored in the memory 902, and the processor 901 calls and executes the contract review method based on the text comparison matrix of the embodiment of the present invention;
[0152] Input / output interface 903, used to implement information input and output;
[0153] Communication interface 904, used to realize communication interaction between the device and other devices, which can be realized by wired mode (such as USB, network cable, etc.) or wireless mode (such as mobile network, WIFI, Bluetooth, etc.);
[0154] A bus 905 that transmits information between various components of the device (e.g., the processor 901, the memory 902, the input / output interface 903, and the communication interface 904);
[0155] The processor 901 , the memory 902 , the input / output interface 903 and the communication interface 904 are connected to each other in communication within the device via a bus 905 .
[0156] like Fig.10 FIG. 1 is a schematic diagram of a storage medium according to an embodiment of the present invention. Fig.10 The embodiment of the present invention further provides a storage medium, which is a computer-readable storage medium used for computer-readable storage. The storage medium stores one or more programs 1001, and the one or more programs 1001 can be executed by one or more processors to implement the above-mentioned contract review method based on text comparison matrix.
[0157] The memory, as a non-transient computer-readable storage medium, can be used to store non-transient software programs and non-transient computer executable programs. In addition, the memory may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some embodiments, the memory may optionally include a memory remotely disposed relative to the processor, and these remote memories may be connected to the processor via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0158] The embodiment of the present invention also discloses a computer program product or a computer program, wherein the computer program product or the computer program includes computer instructions, and the computer instructions are stored in a computer-readable storage medium. A processor of a computer device can read the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes Figure 1 The method shown.
[0159] In some selectable embodiments, the function / operation mentioned in the block diagram may not occur in the order mentioned in the operation diagram. For example, depending on the function / operation involved, the two boxes shown in succession can actually be executed substantially simultaneously or the above-mentioned boxes can sometimes be executed in reverse order. In addition, the embodiment presented and described in the flow chart of the present invention is provided by way of example, for the purpose of providing a more comprehensive understanding of technology. The disclosed method is not limited to the operation and logic flow presented herein. Selectable embodiments are expected, wherein the order of various operations is changed and the sub-operation of a part for which is described as a larger operation is performed independently.
[0160] In addition, although the present invention is described in the context of functional modules, it should be understood that, unless otherwise specified to the contrary, one or more of the above-mentioned functions and / or features can be integrated into a single physical device and / or software module, or one or more functions and / or features can be implemented in a separate physical device or software module. It is also understood that a detailed discussion of the actual implementation of each module is unnecessary for understanding the present invention. More specifically, in view of the properties, functions and internal relationships of the various functional modules in the device disclosed herein, the actual implementation of the module will be understood within the conventional skills of the engineer. Therefore, those skilled in the art can implement the present invention set forth in the claims without excessive experimentation using ordinary techniques. It is also understood that the specific concepts disclosed are merely illustrative and are not intended to limit the scope of the present invention, which is determined by the full scope of the appended claims and their equivalents.
[0161] If the above functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the above methods of each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.
[0162] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as an ordered list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by an instruction execution system, device or apparatus (such as a computer-based system, a system including a processor, or other system that can fetch instructions from an instruction execution system, device or apparatus and execute instructions), or in conjunction with such instruction execution systems, devices or apparatuses. For the purposes of this specification, "computer-readable medium" can be any device that can contain, store, communicate, propagate or transmit a program for use by an instruction execution system, device or apparatus, or in conjunction with such instruction execution systems, devices or apparatuses.
[0163] More specific examples of computer-readable media (a non-exhaustive list) include the following: an electrical connection with one or more wires (electronic device), a portable computer disk case (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and editable read-only memory (EPROM or flash memory), an optical fiber device, and a portable compact disk read-only memory (CDROM). In addition, the computer-readable medium may even be a paper or other suitable medium on which the above-mentioned program is printed, since the above-mentioned program can be obtained electronically, for example, by optically scanning the paper or other medium, followed by editing, deciphering or processing in other suitable ways as necessary, and then stored in a computer memory.
[0164] It should be understood that the various parts of the present invention can be implemented by hardware, software, firmware or a combination thereof. In the above-mentioned embodiments, a plurality of steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or their combination: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.
[0165] In the above description of this specification, the description with reference to the terms "one embodiment / example", "another embodiment / example" or "certain embodiments / examples" etc. 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 invention. 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.
[0166] Although embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present invention, and that the scope of the present invention is defined by the claims and their equivalents.
[0167] The above is a specific description of the preferred implementation of the present invention, but the present invention is not limited to the above embodiments. Those skilled in the art may make various equivalent modifications or substitutions without violating the spirit of the present invention. These equivalent modifications or substitutions are all included in the scope defined by the claims of this application.
Claims
1. A contract review method based on text comparison matrix, characterized in that: The following steps are involved: Acquire the contract to be reviewed and the template contract, and number and sort the contract items of the contract to be reviewed and the template contract respectively to obtain a sequence of items to be reviewed and a sequence of items in the template; Traversing the sequence of items to be reviewed and the sequence of template items, and calculating the content similarity between each item to be reviewed and each template item; Constructing a text comparison matrix between the to-be-reviewed item sequence and the template item sequence according to the content similarity; A step-by-step diagonal detection is performed on the text comparison matrix to obtain an optimal solution path, and then new entries, deleted entries, and modified entries are determined based on the optimal solution path.
2. A contract review method based on text comparison matrix according to claim 1, characterized in that: The calculating of the content similarity between each to-be-reviewed item and each template item specifically includes: Determine the first text of the item to be reviewed, and determine the second text of the template item; Calculating the cosine similarity, Jacard similarity and edit distance similarity between the first text and the second text; The content similarity between the to-be-reviewed item and the template item is determined according to an average value of the cosine similarity, the Jacard similarity, and the edit distance similarity.
3. A contract review method based on text comparison matrix according to claim 2, characterized in that: The cosine similarity is calculated by the following steps: Performing word segmentation processing on the first text and the second text respectively to obtain a first vocabulary and a second vocabulary; Merging and removing duplicates from the first vocabulary list and the second vocabulary list to obtain a third vocabulary list; Calculate the word frequency of each word in the third word list in the first text to obtain a first word frequency sequence, and calculate the word frequency of each word in the third word list in the second text to obtain a second word frequency sequence; Performing vectorization processing on the first word frequency sequence to obtain a first word frequency feature vector of the first text, and performing vectorization processing on the second word frequency sequence to obtain a second word frequency feature vector of the second text; The cosine similarity between the first text and the second text is determined according to the cosine values of the first word frequency feature vector and the second word frequency feature vector.
4. A contract review method based on text comparison matrix according to claim 2, characterized in that: The Jacard similarity is calculated by the following formula: Among them, similarity Jacard represents the Jacard similarity between the first text and the second text, A represents the first vocabulary corresponding to the first text, B represents the second vocabulary corresponding to the second text, len represents the vocabulary length, and α represents the preset penalty coefficient.
5. A contract review method based on text comparison matrix according to claim 2, characterized in that: The edit distance similarity is calculated by the following formula: Among them, similarity edit represents the edit distance similarity between the first text and the second text, a represents the first string corresponding to the first text, b represents the second string corresponding to the second text, |a| represents the length of the first string, |b| represents the length of the second string, lev a,b (|a|,|b|) represents the edit distance between the first string and the second string; The edit distance is obtained by recursion using the following formula: Among them, lev a,b (i,j) represents the edit distance between the first i characters of a and the first j characters of b. i represents the i-th character of a, b j represents the jth character of b, is an indicator function, when a i =b j When , its value is 0, otherwise its value is 1, i∈{1,2,…,|a|}, j∈{1,2,…,|b|}.
6. A contract review method based on a text comparison matrix according to any one of claims 1 to 5, characterized in that: The step of constructing a text comparison matrix between the to-be-reviewed item sequence and the template item sequence according to the content similarity specifically includes: Determine a first number of rows according to the number of the items to be reviewed, determine a first number of columns according to the number of the template items, and construct an initial matrix according to the first number of rows and the first number of columns; When the content similarity between the mth item to be reviewed in the sequence of items to be reviewed and the nth template item in the sequence of template items is greater than or equal to a preset first threshold value and less than an upper limit value of the similarity, assigning a preset first value to the element in the mth row and nth column of the initial matrix; When the content similarity between the mth item to be reviewed in the sequence of items to be reviewed and the nth template item in the sequence of template items is equal to the similarity upper limit value, assigning a value of the element in the mth row and nth column of the initial matrix to a preset second value; When the content similarity between the mth to-be-audited entry in the to-be-audited entry sequence and the nth template entry in the template entry sequence is less than the first threshold, the element in the mth row and nth column of the initial matrix is assigned a value of zero.
7. A contract review method based on text comparison matrix according to claim 6, characterized in that: The stepwise diagonal detection of the text comparison matrix is performed to obtain the optimal solution path, which specifically includes: Reading the values of matrix elements starting from the upper left corner of the text comparison matrix; When the current element is a non-zero value, add the current element to the preset element sequence and jump to the element at the lower right corner of the current element; When the current element is zero, mark the current element and traverse the elements to the right. If a non-zero value element is detected, add the non-zero value element to the preset element sequence and jump to the element at the lower right corner of the non-zero value element. If no non-zero value is detected, jump to the element below the marked current element. The optimal solution path is determined according to the elements in the element sequence.
8. A contract review method based on text comparison matrix according to claim 7, characterized in that: The determining of adding new entries, deleting entries, and modifying entries according to the optimal solution path specifically includes: Traversing the row number and column number of each element in the optimal solution path in the text comparison matrix to obtain a row number sequence and a column number sequence; Determine the missing row number corresponding to the row number sequence according to the first row number, and determine, according to the missing row number, that the to-be-audited entry with the corresponding serial number in the to-be-audited entry sequence is the newly added entry; Determine the missing column number corresponding to the column number sequence according to the first column number, and determine the template entry with the corresponding sequence number in the template entry sequence as a deleted entry according to the missing column number; Read the value of each element in the optimal solution path; When the element is a first numerical value, the to-be-reviewed entry with the corresponding serial number in the to-be-reviewed entry sequence is determined to be the modified entry according to the row number of the element in the text comparison matrix, and the template entry with the corresponding serial number in the template entry sequence is determined to be the original entry corresponding to the modified entry according to the column number of the element in the text comparison matrix.
9. A contract review device based on a text comparison matrix, characterized in that: include: An item sequence generation module is used to obtain the contract to be reviewed and the template contract, and to number and sort the contract items of the contract to be reviewed and the template contract to obtain an item sequence to be reviewed and a template item sequence; A content similarity calculation module, used to traverse the sequence of items to be reviewed and the sequence of template items, and calculate the content similarity between each item to be reviewed and each template item; A text comparison matrix construction module, used to construct a text comparison matrix between the to-be-reviewed item sequence and the template item sequence according to the content similarity; The matrix detection module is used to perform a step-by-step diagonal detection on the text comparison matrix to obtain an optimal solution path, and then determine to add new entries, delete entries, and modify entries according to the optimal solution path.
10. A storage medium, the storage medium being a computer-readable storage medium, used for computer-readable storage, characterized in that: The storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement the steps of the contract review method based on the text comparison matrix as described in any one of claims 1 to 8.
Citation Information
Patent Citations
Method and device for searching contract modification part, computer equipment and storage medium
CN109933754A
Text comparison method, contract review method and review system
CN112926299A
Contract auditing method based on text comparison
CN114925672A
Document comparison method and device, equipment and medium
CN116229489A
Fuzzy judgment method and device for contract text error information
CN116702739A