A text comparison method, device, computer equipment and readable storage medium

By dividing legal documents into subtexts and using word vector calculation methods, automatic comparison of legal documents is realized, time-consuming and error-prone problems in the existing technology are solved, and comparison efficiency and accuracy are improved.

CN112395851BActive Publication Date: 2024-12-06CHINALAWINFO CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202011292846.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-11-18
Publication Date
2024-12-06
Estimated Expiration
2040-11-18

AI Technical Summary

Technical Problem

The prior art has the problem of time-consuming and error-prone in legal documents comparison, and common text processing software is difficult to meet the actual comparison needs of structured documents, and requires a lot of manual time and energy to adapt.

Method used

By dividing the overall legal document into several subtexts, and narrowing the comparison range based on the similarity values ​​between the subtexts, word vector calculations are used to obtain similarity values ​​and distinctive features, automatic comparison is achieved, and manual participation and error rates are reduced.

Benefits of technology

It greatly improves the efficiency of legal documents comparison, reduces the rate of manual errors, and can quickly locate and modify content to meet the comparison needs of structured documents.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112395851B_ABST
    Figure CN112395851B_ABST
Patent Text Reader

Abstract

The present invention provides a text comparison method, device, computer equipment and readable storage medium, the method comprising: obtaining a plurality of first subtexts from a first text and obtaining a plurality of second subtexts from a second text; obtaining a plurality of similarity values ​​according to the first subtext and the second subtext; the similarity value is the degree of similarity between a first subtext and a second subtext; obtaining a similar text pair according to the similarity value, the similar text pair comprising a first subtext and a second subtext with the largest similarity value to the first subtext; obtaining at least one distinguishing feature of the first subtext and the second subtext in the similar text pair. Through the above method, the whole process does not require manual participation, reduces the error rate of manual text comparison, and greatly improves the text comparison efficiency, so it has high practical value.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of data comparison, and in particular to a text comparison method, device, computer equipment and readable storage medium. Background Art

[0002] In the legal field, before a new law or regulation is promulgated, there is often a draft and one or more corresponding draft revisions. For legal practitioners, understanding the changes from the draft to the draft revision can bring them great convenience.

[0003] At present, a common way for legal professionals to compare legal documents is to use manual comparison. Manual comparison of legal documents is divided into the following four steps. The first step is to manually organize two legal documents and manually split each legal document into legal article levels; the second step is to manually sort out similar legal article pairs of the two legal documents; the third step is to manually find the similarities and differences between similar legal articles, or use comparison tools to compare the similarities and differences of each similar legal article pair; the fourth step is to manually design the display output method and output the comparison results. The above solution requires professionals to invest a lot of time and energy in manual processing to adapt to existing technologies. There are still problems of time-consuming and error-prone, and there are high requirements for the professional background of the comparison personnel. This comparison method has a lot of room for improvement.

[0004] In order to solve the problem that manual comparison is time-consuming and error-prone, some text processing software is used in the prior art to optimize the manual processing method. Common text processing software on the market, such as Word and Adobe software, has a comparison function, but the document comparison function contained in software such as Word and Adobe is for universal considerations. It compares word by word and paragraph by paragraph, and does not consider the need for fixed structure or logical unit comparison in the comparison of relatively fixed structure documents. This requires comparison personnel to do a lot of preparatory work, such as legal document legal document legal provisions sorting, similar legal provisions sorting, etc., in order to meet the document comparison function contained in software such as Word and Adobe. It cannot fully meet the actual needs of legal document comparison, and still requires professionals to invest a lot of time and energy in manual processing to adapt to the existing technology. Therefore, the common software comparison function is basically difficult to meet the actual comparison needs of structured documents such as laws and contracts. Summary of the invention

[0005] In view of the problem that the comparison method of the above-mentioned existing structured documents is time-consuming and cannot be separated from manual operation, the present invention is proposed to provide a text comparison method, apparatus, computer equipment and readable storage medium that overcome the above-mentioned problem or at least partially solve the above-mentioned problem.

[0006] According to one aspect of the present invention, a text comparison method is provided for comparing a first text with a second text, the method comprising:

[0007] Acquire a plurality of first subtexts from the first text and acquire a plurality of second subtexts from the second text;

[0008] Acquire a plurality of similarity values ​​according to the first subtext and the second subtext; the similarity values ​​are the degree of similarity between a first subtext and a second subtext;

[0009] Acquire a similar text pair according to the similarity value, wherein the similar text pair includes a first subtext and a second subtext having the greatest similarity value to the first subtext;

[0010] At least one distinguishing feature of a first subtext and a second subtext in the similar text pair is obtained.

[0011] Preferably, obtaining a plurality of similarity values ​​according to the first subtext and the second subtext specifically includes:

[0012] Obtaining a first word vector for the first subtext and a second word vector for the second subtext respectively;

[0013] The first word vector includes the number of occurrences of each character unit in the first subtext, the second word vector includes the number of occurrences of each character unit in the second subtext, and a character unit includes at least one character;

[0014] A similarity value between the first subtext and the second subtext is obtained according to the first word vector and the second word vector.

[0015] Preferably, obtaining similar text pairs according to the similarity values ​​specifically includes:

[0016] Comparing N similarity values ​​between a first subtext and N second subtexts;

[0017] A second subtext corresponding to the maximum value among the N similarity values ​​is selected, and the second subtext and the first subtext are used as a similar text pair.

[0018] Preferably, obtaining at least one distinguishing feature between the first subtext and the second subtext in the similar text pair specifically includes:

[0019] Acquire at least one common string in the similar text pair; the common string is a string that is the same between the first subtext and the second subtext; the string includes at least one character unit;

[0020] Confirming a first interval and / or a second interval in a first subtext and a second subtext in the similar text pair; the first interval is an interval before the common string, and the second interval is an interval after the common string;

[0021] Comparing contents of a first character unit in the first subtext and located within the first interval and / or the second interval with contents of a second character unit in the second subtext and located within the first interval and / or the second interval;

[0022] A distinguishing feature is determined based on the content, where the distinguishing feature includes but is not limited to one of the following: missing character units, added character units, and different character units.

[0023] Preferably, obtaining a plurality of first subtexts from the first text specifically includes:

[0024] Traversing the starting characters of subtext tags in the first text, the subtext tags being tags representing the first subtext;

[0025] A first subtext is confirmed according to two adjacent starting characters.

[0026] Preferably, the method further comprises:

[0027] Traversing the starting character and the ending character of the subtext mark in the first text, the subtext mark being a mark representing the first subtext;

[0028] Confirm the subtext mark according to the starting character and the ending character;

[0029] A first subtext is confirmed according to two adjacent subtext marks.

[0030] According to another aspect of the present invention, there is provided a text comparison device for comparing a first text with a second text, the device comprising:

[0031] A first acquisition unit, used for acquiring a plurality of first subtexts from the first text and acquiring a plurality of second subtexts from the second text;

[0032] A second acquisition unit is used to acquire a plurality of similarity values ​​according to the first subtext and the second subtext; the similarity value is the degree of similarity between a first subtext and a second subtext;

[0033] A third acquisition unit, configured to acquire a similar text pair according to the similarity value, wherein the similar text pair includes a first subtext and a second subtext having the greatest similarity value to the first subtext;

[0034] The fourth acquisition unit is used to acquire at least one distinguishing feature between the first subtext and the second subtext in the similar text pair.

[0035] Preferably, the device further comprises:

[0036] a fifth acquisition unit, configured to traverse the starting characters of a subtext mark in the first text, wherein the subtext mark is a mark representing the first subtext;

[0037] The sixth acquiring unit is used to confirm the first subtext according to two adjacent starting characters.

[0038] According to another aspect of the present invention, a computer device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the text comparison method as described in any one of the above items when executing the computer program.

[0039] According to another aspect of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores an executable computer program, and when the computer program is executed by a processor, the text comparison method as described in any one of the above items is implemented.

[0040] Through the above scheme, the overall legal document is first divided into several sub-texts and a method based on the several sub-texts is developed, and the scope of the text to be compared is further narrowed according to the similarity value to quickly perform the subsequent distinguishing feature search. The whole process does not require human participation, which reduces the error rate of manual comparison of legal documents and greatly improves the comparison efficiency of legal documents, so it has high practical value.

[0041] The above description is only an overview of the technical solution of the present invention. In order to more clearly understand the technical means of the present invention, it can be implemented according to the contents of the specification. In order to make the above and other purposes, features and advantages of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are listed below. BRIEF DESCRIPTION OF THE DRAWINGS

[0042] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0043] Figure 1 A flow chart of a text comparison method in an embodiment of the present invention;

[0044] Figure 2 A schematic diagram of the structure of a text comparison device in an embodiment of the present invention;

[0045] Figure 3 4 is a structural diagram of a computer device in an embodiment of the present invention. DETAILED DESCRIPTION

[0046] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0047] The embodiment of the present invention provides a text comparison method for comparing two similar texts. Specifically, the text to be compared is a legal document with a certain format or document structure, such as a first edition book and a second edition book, or a law, regulation, ordinance, implementation rules, judicial interpretation, etc. Among them, for the sake of clarity, the two texts to be compared are respectively referred to as the first text and the second text in the following embodiment. The comparison between the first text and the second text usually involves the comparison between different versions of the book, or the comparison between the draft and the draft revision in the process of lawmaking, or the comparison between the draft and the draft for review or any two versions of the legal text to be implemented, so as to sort out similar legal provisions and clearly understand the modification process and content. Among them, the content of the comparison includes addition, deletion and modification. Taking legal documents as an example, in the actual processing process, since the legal documents are relatively uniform in format and there is a special document structure of "editing chapter and clause items", the comparison scheme described in the embodiment of the present invention comes into being.

[0048] In the specific text comparison method, the difference between the first text and the second text is compared as an example. Figure 1 As shown, the method includes:

[0049] Step 101, obtaining a plurality of first subtexts from a first text and obtaining a plurality of second subtexts from a second text;

[0050] Step 102, obtaining a plurality of similarity values ​​according to the first subtext and the second subtext; the similarity value is the degree of similarity between a first subtext and a second subtext;

[0051] Step 103, obtaining a similar text pair according to the similarity value, wherein the similar text pair includes a first subtext and a second subtext having the greatest similarity value to the first subtext;

[0052] Step 104: Obtain at least one distinguishing feature of the first subtext and the second subtext in the similar text pair.

[0053] The text comparison method described in the above embodiment divides the entire first text and the second text into several first sub-texts and several second sub-texts respectively, and further narrows the scope of the text to be compared according to the similarity values ​​between the sub-texts to quickly perform subsequent distinguishing feature searches. The entire process does not require human participation, reduces the error rate of manual text comparison, and greatly improves the comparison efficiency of the two texts, so it has high practical value.

[0054] Specifically, in step 101, the first text and the second text are two independent texts with comparability. Among them, comparability means that the main content of the first text and the second text is similar to a large extent, for example, the first text and the second text are in the relationship between the original manuscript and the revised manuscript, or the first text and the second text are in the relationship between the first version and the second version of a certain file, or the first text and the second text are in the relationship between the replacement text and the replaced text, that is, the two texts have a certain degree of identical content, which is used to establish a comparative relationship between the two texts. Obtaining a number of first subtexts from the first text and obtaining a number of second subtexts from the second text is to perform document splitting on the first text and the second text, so as to split the first text and the second text into a number of subtexts. Document splitting refers to splitting the text into multiple paragraphs according to its original document structure with a certain logical relationship, and each paragraph or a combination of multiple paragraphs can be called a subtext, so as to facilitate subsequent individual comparison and quickly locate the modified place. In the specific splitting process, the splitting method and rules for the first text are the same as those for the second text, so that the structures of the split sub-texts are comparable, that is, the first sub-text will appear in its entirety or not in the second sub-text, and part of the content will not appear in one sub-text and the other part in the second sub-text, so as to avoid affecting the accuracy of the subsequent comparison process, but the number of the first sub-texts and the number of the second sub-texts may be the same or different.

[0055] In step 102 after the first text and the second text are split into a plurality of first subtexts and a plurality of second subtexts, all the first subtexts and the second subtexts are respectively combined, each group contains a first subtext and a second subtext, and the similarity value between the first subtext and the second subtext in each group is determined. In a specific scheme, for example, the first text is split into ten first subtexts, and the second text is split into ten second subtexts. The ten first subtexts are respectively arranged and combined with the ten second subtexts, and the similarity value of each combination is calculated, that is, there are 10 2Similarity values. The similarity value is between [0-1], 1 represents exact similarity, and the closer the value is to 1, the higher the similarity. For example, first select a first subtext, and calculate the similarity values ​​between the first subtext and ten second subtexts, then select another first subtext, and calculate the similarity values ​​between the first subtext and ten second subtexts, and so on, to obtain a total of 100 similarity values ​​between each first subtext and each second subtext.

[0056] In another preferred embodiment, a similarity threshold is also provided, and the similarity threshold represents the minimum similarity value between the first subtext and the second subtext. When the similarity between the first subtext and the second subtext is less than the similarity threshold, it can be directly determined that the first subtext and the second subtext are not similar. Next, taking multiple similarity values ​​between a certain first subtext and all second subtexts as an example, if the similarity values ​​obtained between a certain first subtext and all second subtexts are all less than the similarity threshold, it can be considered that the first subtext and all second subtexts are not comparable, that is, the first subtext is not similar to any second subtext. At this time, the first subtext is directly regarded as a non-similar text, and the subsequent process of obtaining similar text pairs and obtaining distinguishing features is no longer performed.

[0057] In step 103, after obtaining a number of similarity values, a similar text pair is obtained according to the similarity values, wherein the similar text pair includes a first subtext and a second subtext having the largest similarity value with the first subtext. In a preferred embodiment, obtaining a similar text pair according to the similarity values ​​specifically includes: comparing the N similarity values ​​of a first subtext and N second subtexts; selecting a second subtext corresponding to the maximum value among the N similarity values, and using the second subtext and the first subtext as a similar text pair. Wherein, N is the number of second subtexts.

[0058] Still taking the above embodiment as an example, that is, after obtaining ten similarity values ​​between a certain first subtext and ten second subtexts, in one implementation method, the ten similarity values ​​are compared in turn, and the first subtext and the second subtext corresponding to the largest similarity value are selected as a group of similar text pairs. In another implementation, the combination of the first subtext and the second subtext whose similarity value is less than the similarity threshold is first excluded, and only the combination of the first subtext and the second subtext whose similarity value is greater than the similarity threshold is retained. When the combination of the first subtext and the second subtext whose similarity value is greater than the similarity threshold has only a unique combination, the first subtext and the second subtext in the group can be directly used as a similar text pair; when the combination of the first subtext and the second subtext whose similarity value is greater than the similarity threshold is greater than one group, the combination of the first subtext and the second subtext corresponding to the largest similarity value is obtained in a one-by-one comparison as a similar text pair.

[0059] After obtaining several similar text pairs, it means that the first subtext and the second subtext in the similar text pair are related subtexts, and the similarity between them is relatively large. Therefore, step 104 is used to specifically compare the similar text pairs and obtain at least one distinguishing feature of the first subtext and the second subtext in the similar text pair, and the distinguishing feature is the difference between the two texts. Specifically, in order to locate the distinguishing features of the two texts and determine the distinguishing feature types, it is necessary to use one of the texts as the reference text, that is, use the first text as the reference or the second text as the reference text. In a preferred embodiment, when the first text and the second text are the difference between the first draft text and the revised draft text, using the revised draft as the reference can more clearly reflect the modification changes. In other words, step 104 mainly performs the text comparison process, and obtains the difference between the two texts through algorithm calculation to identify the addition, deletion, and modification operations from the reference text to the revised text.

[0060] Step 104 is specifically described by taking the first text as the first draft text and the second text as the revised draft text as an example. When the content of the first subtext is ABC and the content of the second subtext is AB, it means that the first subtext has been deleted, wherein the content C is the deleted part, that is, the distinguishing feature is the deletion of C; when the content of the first subtext is ABC and the content of the second subtext is ABCD, it means that the first subtext has been added, wherein the content D is the added part, that is, the distinguishing feature is the addition of D; when the content of the first subtext is still ABC and the content of the second subtext is ABD, it means that the first subtext has been modified, wherein C is modified to D, that is, the distinguishing feature is the change from C to D. So far, the above embodiment of the present invention can be used to divide the entire legal document into several subtexts and develop a text based on several subtexts, and further narrow the scope of the text to be compared according to the similarity value, and finally obtain the distinguishing feature by constructing similar text pairs and comparing the differences between the similar text pairs.

[0061] The text comparison method described in the specific embodiment of the present invention preferably obtains a plurality of similarity values ​​according to the first subtext and the second subtext, specifically comprising:

[0062] Obtaining a first word vector for the first subtext and a second word vector for the second subtext respectively;

[0063] Among them, the first word vector contains the number of occurrences of each character unit in the first subtext, and the second word vector contains the number of occurrences of each character unit in the second subtext, and a character unit contains at least one character; specifically, for the consideration of computing performance and algorithm complexity, a similarity algorithm is used here. First, all character units appearing in the subtext are counted. The character unit can be a Chinese character or a word. Each Chinese character or word is used as a dimension, and the number of occurrences of each Chinese character or unit is counted for each subtext. The statistical result of the number of occurrences of all Chinese characters or words in the subtext can form the word statistics of the subtext, that is, the word vector of the subtext.

[0064] The similarity value between the first subtext and the second subtext is obtained according to the first word vector and the second word vector. After the word vector representation of each subtext is obtained, the similarity between any two subtexts is calculated by cosine similarity based on the word vector representation of the subtext.

[0065] In the text comparison method described in the embodiment of the present invention, preferably, obtaining at least one distinguishing feature between the first subtext and the second subtext in the similar text pair specifically includes:

[0066] At least one common string in the similar text pair is obtained; the common string is the same string between the first subtext and the second subtext; the common string includes at least one character unit. In a specific embodiment, by locating the common string in a subtext, it is possible to confirm the completely identical parts of the two subtexts, that is, the parts that have not changed. The identical string can be a phrase / word, or a sentence, or a paragraph. The character unit is the smallest unit in a subtext, which can usually be a phrase or a word. As long as it appears in both subtexts at the same time and is exactly the same, it can be identified as belonging to the common string.

[0067] Confirm the first interval and / or second interval in the first subtext and the second subtext of the similar text pair; the first interval is the interval before the common string, and the second interval is the interval after the common string. The first interval and the second interval are the parts where changes occur in the two subtexts, and are also the contents that need to be compared. In a preferred embodiment, the first interval and the second interval do not contain any common string, that is, the first interval and the second interval only contain the different parts of the two subtexts.

[0068] Compare the contents of the first character unit located in the first interval and / or the second interval in the first subtext and the second character unit located in the first interval and / or the second interval in the second subtext. In a specific embodiment, the contents of the first interval and the second interval may include one or more first character units and second character units. During the comparison, one character unit or multiple character units may be compared as a whole, or divided into several smaller units for comparison according to certain rules. When selecting the content for comparison, it is necessary to compare in the order of the subtexts, that is, compare the first interval or the second interval at the same time. For example, the first character unit of the first interval of the first subtext and the second character unit of the first interval of the second subtext are selected at the same time for comparison, or the first character unit of the second interval of the first subtext and the second character unit of the second interval of the second subtext are selected for comparison.

[0069] A distinguishing feature is determined based on the content, where the distinguishing feature includes but is not limited to one of the following: missing character units, added character units, and different character units.

[0070] In a specific embodiment, the above comparison process is exemplified as follows. Refer to Table 1: Assume that there is a first sub-text A including multiple first character units "abcdefghijklmn", and there is a second sub-text B containing multiple second character units "abcefdhzijk". Through the search algorithm for common strings, it can be confirmed that "abc", "ef", "h", and "ijk" are common strings. If the second sub-text B is used as the reference, then the "d" in the first sub-text A after "abc" is an operation of deletion, so the distinguishing feature is the lack of character units; the "g" after "ef" in the first sub-text A corresponds to the "d" after "ef" in the second sub-text B, so this is an operation of modification here, that is, the distinguishing feature is different character units; the "h" and "ijk" in the second sub-text B correspond to the "h" and "ijk" in the first sub-text A. Since there are no character units between "hijk" in A, the "z" between "h" and "ijk" in the second sub-text B is an operation of addition, and the corresponding distinguishing feature is the addition of character units; after "ijk" in the first sub-text A is "lmn", which does not exist in the second sub-text B, that is, the distinguishing feature is the lack of character units, so it is an operation of deletion.

[0071] Table 1 Comparison Table of the First Sub-text and the Second Sub-text

[0072]

[0073] Preferably, for the text comparison method described in the embodiment of the present invention, obtaining several first sub-texts from the first text specifically includes:

[0074] Traverse the starting characters of the sub-text markers in the first text, where the sub-text marker is a marker representing the first sub-text. In a specific embodiment, since the text compared in the embodiment of the present invention is a text with a certain format or document structure, such as a legal document, this type of document usually forms several sub-texts according to a certain format or structure. That is to say, a certain format or structure divides the text through special markers, and this marker can be called a sub-text marker. For example, a whole text is divided into several sub-texts by using "article, chapter, section, clause, paragraph, item, sub-item" as the sub-text markers for separation. In a more specific embodiment, each sub-text marker has a starting character. When the sub-text marker only contains one character unit, the starting character is this character unit; when the sub-text marker contains several character units, the starting character is the first character unit, and the character unit can be one of numbers, letters, Chinese characters, symbols, or spaces. For example, the character unit "Article" is used as the starting character of the sub-text markers "Chapter 1" and "Chapter 2".

[0075] Identify one of the first sub-texts based on two adjacent starting characters. Specifically, each starting character is the beginning part of a sub-text marker, that is, the starting position. Therefore, the content between two starting characters is used as the first sub-text, which is convenient for quickly splitting a complex text into simple parts. Taking the above embodiment as an example, the content from the starting character "第" of the sub-text marker "第一章" to the character before the starting character "第" of the sub-text marker "第二章" can be identified as the first sub-text.

[0076] In another specific embodiment, the specific method of obtaining several second sub-texts from the second text is the same as above and will not be elaborated here.

[0077] In the text comparison method described in the embodiments of the present invention, preferably, the method further includes:

[0078] Traverse the starting characters and ending characters of the sub-text markers in the first text. The meaning of the starting characters is the same as above, and the ending character is the ending part of a sub-text marker, that is, the ending position. When a sub-text marker contains several character units, a complete sub-text marker can be represented by distinguishing the starting character and the ending character of the sub-text. Taking the above embodiment as an example, the character unit "章" is used as the ending character of the sub-text markers "第一章" and "第二章".

[0079] Identify the sub-text marker according to the starting character and the ending character; identify one of the first sub-texts according to two adjacent sub-text markers. Specifically, by traversing the starting characters and ending characters of the sub-text markers, and a complete sub-text marker can be located through an adjacent starting character and ending character. Traversing the ending characters of the sub-text markers is by using the character unit used at the end of the sub-text marker as the ending character.

[0080] Taking the regulations in legal documents as a specific example, the method for obtaining sub-texts is as follows: For regulations, the most core text markers include character units of "chapter, section, article", so the recognition of "chapter, section, article" text markers is the first step of the comparison method. Therefore, after reading in the regulations, traverse the regulations to find the markers containing the content of "chapter, section, article", and then use the markers found containing the content of "chapter, section, article" as delimiters to complete the splitting of the regulations. In the specific method, in order to quickly locate text markers, in the method described in the embodiments of the present invention, first locate the first line break character that appears in the regulations, that is, the approximate position where text markers may appear, and record the number of spaces that appear after the line break character, that is, the interference item of the marker start position, and then search for the start character of the text marker. If the character unit after the space belongs to any character unit in the text marker start character set, then continue to search backward to see if the next character unit is a number, a space, or a Chinese or English punctuation mark. The text marker start character set at least includes the following character units: '第', '(', '(', '零', '一', '二', '三', '四', '五', '六', '七', '八', '九', '十', '百', '千', '万', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'; The Chinese and English punctuation marks at least include the following character units: '、', '.', ', '. Further, continue to search backward to see if the next character unit matches any one in the marker end character set. For example, the end characters containing '章', '节', '条', ')', ')', '、', or a general Chinese character unit, that is, stop searching when there is no clear belonging to the above end characters. Through the above steps, it can be determined that if a character unit is located after a line break character and one or more spaces and belongs to any one in the text marker start character set, it is the start position of the text marker. If a character unit is after the start position of the marked text and before the marker end character set or a general Chinese character unit, it is the end position of the text marker. Based on the obtained marker start position and marker end position, the "chapter, section, article" text markers can be extracted. Next, continue to identify the next text marker according to the above search logic until all text markers in the regulations are identified. Then, the content between the start character of a text marker and the start character of the next text marker is determined as the specific content of a legal article. Traversing all text markers can obtain the specific content of all legal articles.

[0081] The embodiments of the present invention also provide a text comparison device for comparing a first text with a second text, as Figure 2 shown, the device includes:

[0082] A first acquisition unit 201 is used to acquire a plurality of first subtexts from a first text and acquire a plurality of second subtexts from a second text;

[0083] A second acquisition unit 202 is used to acquire a plurality of similarity values ​​according to the first subtext and the second subtext; the similarity value is the degree of similarity between a first subtext and a second subtext;

[0084] A third acquisition unit 203 is used to acquire a similar text pair according to the similarity value, wherein the similar text pair includes a first subtext and a second subtext having the greatest similarity value to the first subtext;

[0085] The fourth acquiring unit 204 is configured to acquire at least one distinguishing feature between the first subtext and the second subtext in the similar text pair.

[0086] The text comparison device described in the embodiment of the present invention preferably further includes:

[0087] a fifth acquisition unit, configured to traverse the starting characters of a subtext mark in the first text, wherein the subtext mark is a mark representing the first subtext;

[0088] The sixth acquiring unit is used to confirm the first subtext according to two adjacent starting characters.

[0089] The following uses the comparison of the legal documents "Resident Identity Card Law of the People's Republic of China" and "Resident Identity Card Law of the People's Republic of China (2011 Amendment)" as an example to explain the text comparison method described in the specific embodiment of the present invention. However, it should be clear that this is only a specific embodiment of the present invention and does not mean that the present invention is the only embodiment. Any method based on the concept of the present invention is within the protection scope of the present invention.

[0090] In step 101, several articles are obtained from the "Resident Identity Card Law of the People's Republic of China" as the first subtext, and several articles are obtained from the "Resident Identity Card Law of the People's Republic of China (2011 Amendment)" as the second subtext.

[0091] In step 102, several similarity values ​​are obtained according to the first subtext and the second subtext, for example: [(0,0,0.9449), (1,1,1.0000), (2,2,1.0000), (3,3,0.9554), (4,4,0.9999), (5,5,1.0000), (6,6,0.9999), (7,7,0.9999), (8,8,1.0000), (9,9,1.0000), (10,10,0.9999), (11,11,0.9999), (12,12,0.9902), (13,13, 0.9999),(14,14,0.9999),(15,15,0.9025),(16,16,0.9999),(17,17,0.9731),(18,18,1.0000),(19,19,0.9999),(20,20,1.0000),(21,21,0.9999),(22,-1,0.0),(23,22,0.9999),(24,23,0.9449),(25,24,0.9999),(26,25,0.9999),(27,26,0.8301)]. Among them, (0, 0, 0.9449) means that the similarity value between the first subtext 0 and the first second subtext 0 is 0.9449, (22, -1, 0.0). The similarity value is between [0-1], 1 means they are exactly the same, and the closer the value is to 1, the higher the similarity.

[0092] Step 103, obtaining a similar text pair according to the similarity value, wherein the similar text pair includes a first subtext and a second subtext with the largest similarity value to the first subtext. As shown in the above similarity value example, the similar text pair has been screened, for example, (0, 0, 0.9449) means that the first first subtext 0 and the first second subtext 0 are a similar text pair. And (22, -1, 0.0) means that the first subtext 22 has no corresponding second subtext, so it does not have a similar text pair.

[0093] Step 104: Obtain at least one distinguishing feature of the first subtext and the second subtext in the similar text pair. In a specific embodiment, the distinguishing feature between the two subtexts is represented by a replace mark, an equal mark, a delete mark, and an insert mark.

[0094] 26 27[('equal',0,4,'This Law shall come into force as of',0,4,'本法自'),('replace',4,8,'January 1, 2004',4,8,'2 0 0 4'),('equal',8,9,'. The Regulations of the People\'s Republic of China on Resident Identity Cards shall be repealed simultaneously.',8,9,'年'),('replace',9,10,'1',9,10,'1'),('equal',10,11,'. The resident identity cards obtained in accordance with the Regulations of the People\'s Republic of China on Resident Identity Cards',10,11,'月'),('replace',11,12,'1',11,12,'1'),('equal',12,66,'shall cease to be valid as of January 1, 2013. The resident identity cards obtained in accordance with this Law',12,66,'日起施行,《中华人民共和国居民身份证条例》同时废止。\n依照《中华人民共和国居民身份证条例》领取的居民身份证,'),('replace',66,67,'before January 1, 2012',66,82,'在'),('equal',67,71,'shall continue to be valid within their valid term.',82,86,'自2013年1月1日起停止使用。'),('equal',67,71,'依照本法',82,86,'依照本法'),('replace',71,72,'be replaced',86,98,'在2012年1月1日以前'),('equal',72,73,'and',98,99,'领'),('insert',73,73,'obtained',99,101,'取的'),('equal',73,78,'resident identity cards',101,106,'居民身份证'),('delete',78,79,'before',106,106,”),('equal',79,92,'shall continue to be valid within their valid term.',106,119,',在其有效期内,继续有效。'),('insert',92,92,”,119,124,'\nThe State Council shall'),('equal',92,93,'be replaced',124,125,'换'),('replace',93,94,'and',125,137,'发新一代居民身份证后,原'),('equal',94,100,'the specific measures for the',137,143,'居民身份证的'),('replace',100,105,'resident identity cards to cease to be valid',143,149,'停止使用日期'),('equal',105,109,'shall be decided by the State Council.',149,153,'由国务院'),('replace',109,110,'ulate',153,154,'决'),('equal',110,113,'. \n',154,157,'定。\n')]。

[0095] Among them, the first sub-text 26 and the first sub-text 27 represent the comparison results of the 26th paragraph in the first piece of legislation and the 27th paragraph in the second piece of legislation. "equal", "replace", "delete", and "insert" represent the corresponding operation marks. The following takes ('equal', 0, 4, 'This Law shall come into force as of', 0, 4, 'This Law shall come into force as of') and ('replace', 4, 8, '2004', 4, 8, '2004') as examples. The content at the 0th to 4th character positions of the 26th paragraph in the first piece of legislation is the same as that at the 0th to 4th character positions of the 27th paragraph in the second piece of legislation, both being "This Law shall come into force as of". Therefore, the above operation example obtains the 0th, 1st, 2nd, and 3rd characters, excluding the 4th character. The next "replace" mark starts from the 4th character position, including the 4th character and excluding the 8th character. The results of the remaining operation examples are the same as the operation explanation of the "equal" mark.

[0096] Finally, the corresponding comparison results can be given through the display output. For example, the comparison results of different laws are given in the form of Table 2, and the display of the comparison results can be customized in various different styles. Through the comparison of the tables, the change results of similar law pairs can be seen in detail, and the change results of the entire legislation can also be seen as a whole. Among them, the underlined mark represents the replacement of characters, the bold mark represents the addition of characters, and the strikethrough mark represents the deletion of characters.

[0097] Example of the comparison result between the first sub-text and the second sub-text in Table 2

[0098]

[0099]

[0100] Based on the text comparison method and device described in the above embodiments of the present invention, it can be seen that the present invention has the following beneficial effects:

[0101] 1. The splitting of the text is realized.

[0102] 2. The similarity calculation of sub-texts is realized, and the best similar text pairs are selected.

[0103] 3. The comparison calculation of similar text pairs is realized.

[0104] 4. The display output result of the comparison of two texts is realized.

[0105] 5. The automatic comparison according to the text structure is realized, filling the gap in automatic comparison.

[0106] 6. The text comparison efficiency is improved.

[0107] In one embodiment of this article, such as Figure 3As shown, a computer device is also provided, and the computer device 302 may include one or more processors 304, such as one or more central processing units (CPUs), and each processing unit may implement one or more hardware threads. The computer device 302 may also include any memory 306, which is used to store any kind of information such as code, settings, data, etc. Non-limitingly, for example, the memory 306 may include any one or more combinations of the following: any type of RAM, any type of ROM, flash memory device, hard disk, optical disk, etc. More generally, any memory may use any technology to store information. Further, any memory may provide volatile or non-volatile retention of information, and a computer program that can be run on the processor 304 is stored on the memory 306, and the processor 304 implements a text comparison method described in any of the aforementioned embodiments when executing the computer program. Further, any memory may represent a fixed or removable component of the computer device 302. In one case, when the processor 304 executes an associated instruction stored in any memory or a combination of memories, the computer device 302 may perform any operation of the associated instruction. The computer device 302 also includes one or more drive mechanisms 308 for interacting with any memory, such as a hard disk drive mechanism, an optical disk drive mechanism, and the like.

[0108] The computer device 302 may also include an input / output module 310 (I / O) for receiving various inputs (via input devices 312) and for providing various outputs (via output devices 314). A specific output mechanism may include a presentation device 316 and an associated graphical user interface (GUI) 318. In other embodiments, the input / output module 310 (I / O), the input device 312, and the output device 314 may not be included, and the computer device 302 may be used as a computer device in a network. The computer device 302 may also include one or more network interfaces 320 for exchanging data with other devices via one or more communication links 322. One or more communication buses 324 couple the components described above together.

[0109] The communication link 322 may be implemented in any manner, for example, through a local area network, a wide area network (e.g., the Internet), a point-to-point connection, etc., or any combination thereof. The communication link 322 may include any combination of hardwired links, wireless links, routers, gateway functions, name servers, etc., governed by any protocol or combination of protocols.

[0110] The embodiments of the present invention further provide a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the text comparison method described in any of the above embodiments is executed.

[0111] The embodiments of this document also provide a computer-readable instruction, wherein when a processor executes the instruction, the program therein causes the processor to execute the text comparison method described in any of the above examples.

[0112] It should be understood that in various embodiments of the present invention, the size of the serial numbers of the above-mentioned processes does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.

[0113] It should also be understood that in the embodiments of the present invention, the term "and / or" is only a description of the association relationship of the associated objects, indicating that three relationships may exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the associated objects before and after are in an "or" relationship.

[0114] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in terms of function in the above description. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.

[0115] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0116] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, or it can be an electrical, mechanical or other form of connection.

[0117] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the embodiments of the present invention.

[0118] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0119] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of 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 method described in 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.

[0120] The present invention uses specific embodiments to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. At the same time, for those skilled in the art, according to the idea of ​​the present invention, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.

Claims

1. A text comparison method for comparing a first text with a second text, characterized in that: The method comprises: Acquire a plurality of first subtexts from the first text and acquire a plurality of second subtexts from the second text; Acquire a plurality of similarity values ​​according to the first subtext and the second subtext; the similarity values ​​are the degree of similarity between a first subtext and a second subtext; Acquire a similar text pair according to the similarity value, wherein the similar text pair includes a first subtext and a second subtext having the greatest similarity value to the first subtext; Acquire at least one distinguishing feature of a first subtext and a second subtext in the similar text pair; The method further comprises: Traversing the starting character and the ending character of a subtext tag in the first text, the subtext tag being a tag representing the first subtext; The sub-text mark is confirmed according to the starting character and the ending character; if a character unit is located after a line break and one or more spaces and belongs to any one of the text mark starting character set, it is the starting position of the text mark; if a character unit is after the starting position of the marked text and belongs to the mark ending character set or before a common Chinese character unit, it is the ending position of the text mark; A first subtext is confirmed according to two adjacent subtext marks.

2. The text comparison method according to claim 1, characterized in that: Acquiring a number of similarity values ​​according to the first subtext and the second subtext specifically includes: Obtaining a first word vector for the first subtext and a second word vector for the second subtext respectively; The first word vector includes the number of occurrences of each character unit in the first subtext, the second word vector includes the number of occurrences of each character unit in the second subtext, and a character unit includes at least one character; A similarity value between the first subtext and the second subtext is obtained according to the first word vector and the second word vector.

3. The text comparison method according to claim 1, characterized in that: Acquiring similar text pairs according to the similarity values ​​specifically includes: Comparing N similarity values ​​between a first subtext and N second subtexts; A second subtext corresponding to the maximum value among the N similarity values ​​is selected, and the second subtext and the first subtext are used as a similar text pair.

4. The text comparison method according to claim 1, characterized in that: Acquiring at least one distinguishing feature between the first subtext and the second subtext in the similar text pair specifically includes: Acquire at least one common string in the similar text pair; the common string is a string that is the same between the first subtext and the second subtext; the string includes at least one character unit; Confirming a first interval and / or a second interval in a first subtext and a second subtext in the similar text pair; the first interval is an interval before the common string, and the second interval is an interval after the common string; Comparing the contents of a first character unit in the first subtext and located in the first interval and / or the second interval with the contents of a second character unit in the second subtext and located in the first interval and / or the second interval; A distinguishing feature is determined according to the content, wherein the distinguishing feature includes one of the following: missing character units, added character units, and different character units.

5. The text comparison method according to claim 1, characterized in that: Acquiring a plurality of first subtexts from the first text specifically includes: Traversing the starting characters of subtext tags in the first text, the subtext tags being tags representing the first subtext; A first subtext is confirmed according to two adjacent starting characters.

6. A text comparison device for comparing a first text with a second text, characterized in that: The device comprises: A first acquisition unit, used for acquiring a plurality of first subtexts from the first text and acquiring a plurality of second subtexts from the second text; A second acquisition unit is used to acquire a plurality of similarity values ​​according to the first subtext and the second subtext; the similarity value is the degree of similarity between a first subtext and a second subtext; A third acquisition unit, configured to acquire a similar text pair according to the similarity value, wherein the similar text pair includes a first subtext and a second subtext having the greatest similarity value to the first subtext; a fourth acquisition unit, configured to acquire at least one distinguishing feature between the first subtext and the second subtext in the similar text pair; The first acquisition unit is further used to: traverse the starting character and the ending character of a subtext mark in the first text, the subtext mark being a mark representing the first subtext; The sub-text mark is confirmed according to the starting character and the ending character; if a character unit is located after a line break and one or more spaces and belongs to any one of the text mark starting character set, it is the starting position of the text mark; if a character unit is after the starting position of the marked text and belongs to the mark ending character set or before a common Chinese character unit, it is the ending position of the text mark; A first subtext is confirmed according to two adjacent subtext marks.

7. A text comparison device according to claim 6, characterized in that: include: a fifth acquisition unit, configured to traverse the starting characters of a subtext mark in the first text, wherein the subtext mark is a mark representing the first subtext; The sixth acquiring unit is used to confirm the first subtext according to two adjacent starting characters.

8. A computer 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 computer program, the text comparison method according to any one of claims 1 to 5 is implemented.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores an executable computer program, and when the computer program is executed by a processor, the text comparison method according to any one of claims 1 to 5 is implemented.