String comparison method and apparatus, electronic device, and storage medium

By generating an edit distance matrix and determining the target business path, the problem of inflexible and inaccurate string comparison in existing technologies is solved, achieving flexible and accurate string comparison and intuitively displaying the differences.

CN115238141BActive Publication Date: 2026-03-20DATAGRAND TECH INC
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-07-19
Publication Date
2026-03-20

AI Technical Summary

Technical Problem

Existing technologies struggle to compare strings flexibly and accurately, and cannot visually observe the differences between strings.

Method used

Generate an edit distance matrix between the target string and the reference string, determine the target business path based on the edit distance matrix, and combine each character in the target string and the reference string to obtain the target combination display result and the reference combination display result, and finally determine the string comparison result.

Benefits of technology

It achieves flexible and accurate string comparison and can intuitively display the differences between strings.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115238141B_ABST
    Figure CN115238141B_ABST
Patent Text Reader

Abstract

Embodiments of the present application disclose a string comparison method and device, electronic equipment and a storage medium. The method comprises: generating an edit distance matrix between a target string and a reference string; determining a target service path according to the edit distance matrix, and combining each character in the target string and the reference string according to the target service path to obtain a target combined display result and a reference combined display result; and determining a string comparison result of the target string and the reference string according to the target combined display result and the reference combined display result. The embodiments of the present application can flexibly and accurately compare strings, and the difference between the two can be observed intuitively.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] Embodiments of the present application relate to the technical field of computer, and particularly relate to a string comparison method and device, electronic equipment and storage medium. BACKGROUND

[0002] At present, in scenarios such as spelling detection, it is usually necessary to compare two strings to find the difference between the two strings.

[0003] How to flexibly and accurately compare strings and intuitively observe the difference between them is an important problem in the industry. SUMMARY

[0004] Embodiments of the present application provide a string comparison method and device, electronic equipment and storage medium to flexibly and accurately compare strings and intuitively observe the difference between them.

[0005] According to an aspect of embodiments of the present application, a string comparison method is provided, comprising:

[0006] generating an edit distance matrix between a target string and a reference string;

[0007] determining a target business path according to the edit distance matrix, and combining each character in the target string and the reference string according to the target business path to obtain a target combined display result and a reference combined display result;

[0008] determining a string comparison result of the target string and the reference string according to the target combined display result and the reference combined display result.

[0009] According to another aspect of embodiments of the present application, a string comparison device is provided, comprising:

[0010] an edit distance matrix generation module configured to generate an edit distance matrix between a target string and a reference string;

[0011] a display result determination module configured to determine a target business path according to the edit distance matrix, and combine each character in the target string and the reference string according to the target business path to obtain a target combined display result and a reference combined display result;

[0012] a string comparison result determination module configured to determine a string comparison result of the target string and the reference string according to the target combined display result and the reference combined display result.

[0013] According to another aspect of the present invention, an electronic device is provided, the electronic device comprising:

[0014] At least one processor; and

[0015] A memory communicatively connected to the at least one processor; wherein,

[0016] The memory stores a computer program that can be executed by the at least one processor, the computer program being executed by the at least one processor to enable the at least one processor to perform the string comparison method according to any embodiment of the present invention.

[0017] According to another aspect of the present invention, a computer-readable storage medium is provided, the computer-readable storage medium storing computer instructions, the computer instructions being configured to cause a processor to execute and implement the string comparison method described in any embodiment of the present invention.

[0018] The technical solution of this invention generates an edit distance matrix between a target string and a reference string; determines a target business path based on the edit distance matrix; and combines each character in the target string and the reference string according to the target business path to obtain a target combination display result and a reference combination display result; and determines a string comparison result between the target string and the reference string based on the target combination display result and the reference combination display result. This allows for flexible and accurate string comparison and enables intuitive observation of the differences between the two.

[0019] It should be understood that the description in this section is not intended to identify key or important features of the embodiments of the present invention, nor is it intended to limit the scope of the embodiments of the present invention. Other features of the embodiments of the present invention will become readily apparent from the following description. Attached Figure Description

[0020] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0021] Figure 1 This is a flowchart of a string comparison method provided in Embodiment 1 of the present invention;

[0022] Figure 2 This is a flowchart of a string comparison method provided in Embodiment 1 of the present invention;

[0023] Figure 3 is a structural schematic diagram of a string comparison device according to Embodiment Two of the present application;

[0024] Figure 4 is a structural schematic diagram of an electronic device implementing a string comparison method according to Embodiment One of the present application. DETAILED DESCRIPTION

[0025] In order to enable those skilled in the art to better understand the embodiments of the present application, the technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only some of the embodiments of the present application, but not all the embodiments. Based on the embodiments in the embodiments of the present application, all other embodiments obtained by those skilled in the art without creative labor should fall within the scope of protection of the present application.

[0026] It should be noted that the terms "first", "second", and the like in the specification and claims of the embodiments of the present application and the above-described drawings are used to distinguish similar objects, and do not necessarily indicate a specific order or a chronological sequence. It should be understood that the data thus used can be interchanged under appropriate circumstances, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein. In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusion, for example, a process, method, system, product, or device that includes a series of steps or units does not necessarily have to be limited to only those steps or units clearly listed, but can include other steps or units that are not clearly listed or inherent to the process, method, product, or device.

[0027] Embodiment One

[0028] Figure 1 A flowchart of a string comparison method according to Embodiment One of the present application is provided. The present embodiment can be applied to comparing the contents of two strings and displaying the comparison results in one string. The method can be executed by a string comparison device, which can be implemented in the form of hardware and / or software. The string comparison device can be configured in an electronic device, which in the present embodiment can be a computer, a server, or a tablet computer, etc. The present embodiment does not limit the electronic device. Specifically, referring to Figure 1 , the method specifically includes the following steps:

[0029] Step 110, generating an edit distance matrix between the target string and the reference string.

[0030] In the embodiment, the target string and the reference string can be any string, which is not limited in the embodiment. The length of the target string and the reference string can be the same or different, which is not limited in the embodiment. For example, in the embodiment, the target string can be "I spent 100 yuan today", and the reference string can be "I spent 254 yuan today".

[0031] In the field, the edit distance is a quantitative measure of the difference between two strings (e.g. English words), which measures how many operations are needed to change one string into another. The edit distance can be used in natural language processing, for example, spelling checking can determine which (or which) is more likely to be the correct word according to the edit distance of a misspelled word and other correct words.

[0032] In the embodiment, the edit distance refers to deleting, adding or replacing any character in the string, and the calculation formula is:

[0033]

[0034] In an optional implementation of the embodiment, generating the edit distance matrix between the target string and the reference string can include: calculating the edit distance between each character in the target string and the reference string respectively; and generating the edit distance matrix according to each edit distance.

[0035] For example, in the above example, the edit distance between "I" and "I", the edit distance between "today" and "today", the edit distance between "buy" and "consume", the edit distance between "yuan" and "yuan", the edit distance between "I" and "I today", and the edit distance between "I spent today" and "I bought things today" can be calculated respectively, which is not described in the embodiment.

[0036] For example, in the above example, the obtained edit distance matrix can be as follows:

[0037] I Today went shopping spent yuan I bought 1 0 0 something 0 1 2 3 4 5 6 7 8 9 10 11 12 spent 1 0 1 2 3 4 5 6 7 8 9 10 11 yuan 2 1 0 1 2 3 4 5 6 7 8 9 10 Figure 2 3 2 1 0 1 2 3 4 5 6 7 8 9 Figure 2 4 3 2 1 1 2 3 4 5 6 7 8 9 Figure 3 5 4 3 2 2 2 3 4 5 6 7 8 9 Figure 3 6 5 4 3 3 3 3 4 5 6 7 8 9 Figure 4 7 6 5 4 4 4 4 4 5 6 7 8 9 Figure 4 8 7 6 5 5 5 5 5 4 5 6 7 8 2 9 8 7 6 6 6 6 6 5 5 6 7 8 5 10 9 8 7 7 7 7 7 6 6 6 7 8 4 11 10 9 8 8 8 8 8 7 7 7 7 8 ​ 12 11 10 9 9 9 9 9 8 8 8 8 7

[0038] Step 120, determining the target business path according to the edit distance matrix, and combining each character in the target string and the reference string according to the target business path to obtain the target combined display result and the reference combined display result.

[0039] In an optional implementation of the embodiment, after generating the edit distance matrix between the target string and the reference string, the target business path can be further determined according to the generated edit distance matrix.

[0040] Optionally, determining the target service path according to the edit distance matrix can include: sequentially selecting the minimum target element in each row and each column of the edit distance matrix; and sequentially connecting each target element starting from the top-left corner of the edit distance matrix to form the target service path. In the above example, the minimum target elements obtained by traversal are (0, 0, 0, 0, 1, 2, 3, 4, 4, 5, 6, 7, 7) respectively. Further, each target element can be sequentially connected starting from the top-left corner of the edit distance matrix to form the target service path. In this embodiment, the target service path formed is: 0→0→0→0→1→2→3→4→4→5→6→7→7.

[0041] It can be understood that the target service path in this embodiment is an edit distance increasing path, which represents the process in which the target string and the reference string gradually become dissimilar, and reflects the difference between the target string and the reference string.

[0042] Further, each character in the target string and the reference string can be combined according to the generated target service path to obtain the target combined display result and the reference combined display result.

[0043] In an optional implementation of this embodiment, combining each character in the target string and the reference string according to the target service path to obtain the target combined display result and the reference combined display result can include: determining the difference type between each target character in the target string and each reference character in the reference string according to the target service path; and combining each target character and each reference character according to the difference type to obtain the target combined display result and the reference combined display result.

[0044] The difference type includes at least one of the following: consistent, modified, added, and deleted, which are not limited in this embodiment.

[0045] For example, in the above example, determining the difference type between each target character in the target string and each reference character in the reference string according to the target service path can include: determining the edit distance between the target character and the reference character according to the edit distance between the target character and the reference character; for example, the edit distance between the target character "I" and the reference character "I" is 0, and the difference type between the two is "consistent"; the edit distance between the target character "buy" and the reference character "walk" is 1, and the difference type between the two is "modified"; in the above example, the difference types between each target character and reference character are "consistent, consistent, consistent, modified, modified, modified, modified, consistent, modified, modified, modified, consistent" in turn.

[0046] Further, the target characters and the reference characters of the same difference type can be combined to obtain the target combination display result "I spent 254 yuan today to buy things", and the reference combination display result "I spent 100 yuan today to go shopping".

[0047] Step 130, determining the string comparison result of the target string and the reference string according to the target combination display result and the reference combination display result.

[0048] In an optional implementation of the embodiment, after obtaining the target combination display result and the reference combination display result, the string comparison result of the target string and the reference string can be further determined according to the target combination display result and the reference combination display result.

[0049] In an optional implementation of the embodiment, determining the string comparison result of the target string and the reference string according to the target combination display result and the reference combination display result can include: merging the target combination display result and the reference combination display result to obtain the string comparison result of the target string and the reference string.

[0050] In an optional implementation of the embodiment, after obtaining the target combination display result "I spent 254 yuan today to buy things" and the reference combination display result "I spent 100 yuan today to go shopping", the target combination display result "I spent 254 yuan today to buy things" and the reference combination display result "I spent 100 yuan today to go shopping" can be further combined to obtain the string comparison result "I spent 100 (254) yuan today to go shopping (buy things)".

[0051] In an alternative implementation of this embodiment, before determining the string comparison result between the target string and the reference string based on the target combined display result and the reference combined display result, it further includes: determining whether there are ignorable items in the target combined display result and the reference combined display result; if there are ignorable items, filtering out the ignorable items and merging the two combined results before and after the ignorable items; wherein, the difference types of the two combined results before and after the ignorable item are the same.

[0052] Exemplarily, in the above example, the difference types of the two combined results before and after the character '了' are the same, both being'modification', so the character '了' is an ignorable item. Further, the two combined results before and after '了' are merged, and the obtained string comparison result is 'I spent 100 yuan shopping today (spent 254 yuan on buying things)'.

[0053] It should be noted that in this embodiment, the differences between the two strings can be displayed. For example, in this example, 'I spent 100 yuan shopping' can be displayed in red, and 'Spent 254 yuan on buying things' can be displayed in green, etc. This embodiment does not limit it.

[0054] The technical solution of the embodiment of the present invention generates an edit distance matrix between the target string and the reference string; determines the target business path according to the edit distance matrix, and combines each character in the target string and the reference string respectively according to the target business path to obtain the target combined display result and the reference combined display result; determines the string comparison result between the target string and the reference string according to the target combined display result and the reference combined display result, which can flexibly and accurately compare strings and can visually observe the differences between the two.

[0055] To better understand the embodiment of the present invention, ​ is a flowchart of a string comparison method provided according to Embodiment 1 of the present invention. Refer to ​ and this method includes the following steps:

[0056] Step 210, initial setting.

[0057] In this embodiment, the edit step length can be set. For example, the 'insertion' step length, the 'deletion' step length, and the'modification' step length can be set.

[0058] Step 220, edit distance calculation.

[0059] In this embodiment, the calculation result of the edit distance can be output in the form of a matrix, and the difference type can be saved.

[0060] Step 230, calculating a target path.

[0061] Step 240, calculating a target path difference point.

[0062] Step 250, merging adjacent difference points.

[0063] Step 260, integrating difference point services.

[0064] In this embodiment, integrating difference point services can include: same type merging, adjacent designated interval ignoring, and non-same type merging.

[0065] Step 270, filtering difference point services.

[0066] In this embodiment, filtering difference point services can include: difference type filtering, target character type filtering, and service logic filtering.

[0067] Step 280, outputting a string comparison result.

[0068] The scheme of the embodiment of the application can display the difference between two strings while realizing difference comparison between strings, and can optionally ignore difference points, facilitating user viewing and improving the intelligent level of string comparison.

[0069] Embodiment Two

[0070] ​ A structural schematic diagram of a string comparison device provided for the second embodiment of the application, which can execute the string comparison method described in any of the above embodiments; as shown in the figure, the device includes: an edit distance matrix generation module 310, a display result determination module 320, and a string comparison result determination module 330. ​ The edit distance matrix generation module 310 is used to generate an edit distance matrix between a target string and a reference string.

[0071] The edit distance matrix generation module 310 is used to generate an edit distance matrix between a target string and a reference string.

[0072] The display result determination module 320 is used to determine a target service path according to the edit distance matrix, and combine each character in the target string and the reference string according to the target service path, to obtain a target combined display result and a reference combined display result.

[0073] The string comparison result determination module 330 is used to determine a string comparison result of the target string and the reference string according to the target combined display result and the reference combined display result.

[0074] The scheme of the embodiment generates an edit distance matrix between a target string and a reference string through an edit distance matrix generation module; determines a target service path according to the edit distance matrix through a display result determination module, and combines each character in the target string and the reference string according to the target service path to obtain a target combined display result and a reference combined display result; and determines a string comparison result of the target string and the reference string according to the target combined display result and the reference combined display result through a string comparison result determination module, so that the string comparison can be flexibly and accurately performed, and the difference between the two can be intuitively observed.

[0075] In an optional implementation of the embodiment, the edit distance matrix generation module 310 is specifically configured to calculate the edit distance between each character in the target string and the reference string.

[0076] The edit distance matrix is generated according to each edit distance.

[0077] In an optional implementation of the embodiment, the display result determination module 320 is specifically configured to sequentially select the smallest target element in each row and each column of the edit distance matrix.

[0078] The target service path is formed by sequentially connecting each target element from the top-left corner of the edit distance matrix.

[0079] In an optional implementation of the embodiment, the display result determination module 320 is further specifically configured to determine the difference type between each target character in the target string and each reference character in the reference string according to the target service path.

[0080] Each target character and each reference character is combined according to the difference type to obtain the target combined display result and the reference combined display result.

[0081] In an optional implementation of the embodiment, the string comparison device further includes an ignorable item determination module configured to

[0082] determine whether there is an ignorable item in the target combined display result and the reference combined display result.

[0083] If there is an ignorable item, the ignorable item is filtered out, and the combined results before and after the ignorable item are merged.

[0084] The difference types of the combined results before and after the ignorable item are the same.

[0085] In an optional implementation of the embodiment, the string comparison result determination module 330 is specifically configured to combine the target combination display result and the reference combination display result to obtain the string comparison result of the target string and the reference string.

[0086] In an optional implementation of the embodiment, the difference type includes at least one of the following:

[0087] addition, and deletion.

[0088] The string comparison device provided in the embodiment has the functions and advantages of the string comparison method provided in any of the embodiments.

[0089] Embodiment three

[0090] ​ A structural schematic diagram of an electronic device 10 that can be used to implement embodiments of the present application is shown. The electronic device is intended to represent various forms of digital computers, such as laptops, desktops, tablets, personal digital assistants, servers, blade servers, mainframes, and other appropriate computers. The electronic device can also represent various forms of mobile devices, such as personal digital processors, cellular telephones, smart phones, wearable devices (e.g., headsets, glasses, watches, etc.), and other similar computing devices. The components shown here, their connections and relationships, and their functions, are meant to be examples only, and are not intended to limit implementations of the present application described and / or claimed in this document.

[0091] As shown in ​ The electronic device 10 includes at least one processor 11, and a memory, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., which is in communication with the at least one processor 11, wherein the memory stores a computer program that can be executed by the at least one processor. The processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 into the random access memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.

[0092] A plurality of components in the electronic device 10 are connected to the I / O interface 15, including: an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a magnetic disk, an optical disk, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices through a computer network, such as the Internet, and / or various telecommunication networks.

[0093] The processor 11 can be various general and / or special purpose processing components with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processor 11 performs various methods and processes described above, such as the string comparison method.

[0094] In some embodiments, the string comparison method can be implemented as a computer program tangibly embodied in a computer readable storage medium, such as the storage unit 18. In some embodiments, part or all of the computer program can be loaded and / or installed onto the electronic device 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded onto the RAM 13 and executed by the processor 11, one or more steps of the string comparison method described above can be performed. Alternatively, in other embodiments, the processor 11 can be configured to perform the string comparison method by any other appropriate means, such as by means of firmware.

[0095] The various implementations of the systems and techniques described above can be realized in digital electronic circuitry, integrated circuitry, a field programmable gate array (FPGA), an application specific integrated circuit (ASIC), a system on a chip (SOC), a programmable logic device (PLD), a computer hardware, firmware, software, and / or combinations thereof. These various implementations can include implementation in one or more computer programs that are executable and / or interpretable on a programmable system including at least one programmable processor, which can be special or general purpose, coupled to receive data and instructions from, and to transmit data and instructions to, a storage system, at least one input device, and at least one output device.

[0096] A computer program for implementing the methods of embodiments of the application can be written in any combination of one or more programming languages. The computer program can be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus to produce a machine, such that the computer program, when executed by the processor, produces a means for implementing the functions / acts specified in the flowcharts and / or block diagrams. The computer program can be executed entirely on a machine, partially on a machine, partially on a machine as part of a standalone software package, and partially on a remote machine or entirely on a remote machine or server.

[0097] In the context of embodiments of the application, a computer-readable storage medium can be a tangible medium that can contain or store a computer program for use by or in connection with an instruction execution system, apparatus, or device. A computer-readable storage medium can include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium can be a machine-readable signal medium. More specific examples of a machine-readable storage medium will include one or more lines of a program of instructions in a transitory signal, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0098] To provide for interaction with a user, the systems and techniques described here can be implemented on an electronic device having a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user and a keyboard and a pointing device (e.g., a mouse or a trackball) by which the user can provide input to the electronic device. Other kinds of devices can be used to provide for interaction with a user as well; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form, including acoustic, speech, or tactile input.

[0099] The systems and techniques described herein can be implemented in a computing system that includes a back end component, e.g., as a data server, or that includes a middleware component, e.g., an application server, or that includes a front end component, e.g., a user computer having a graphical user interface or a Web browser through which a user can interact with an implementation of the systems and techniques described herein, or any combination of such back end, middleware, or front end components. The components of the system can be interconnected by any form or medium of digital data communication, e.g., a communication network. Examples of communication networks include a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.

[0100] The computing system can include clients and servers. A client and server are generally remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other. A server can be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system, to solve the defects of large management difficulty and weak business scalability in traditional physical host and VPS service.

[0101] It should be understood that the various forms of flow shown above can be re-ordered, added to, or deleted from without departing from the scope of the present embodiments. For example, the steps recited in the present embodiments can be executed in parallel, in series, or in a different order, and the present embodiments are not limited herein as to the order in which the steps are executed, as long as the desired results of the present embodiments are achieved.

[0102] The above detailed description does not constitute a limitation on the protection scope of the present embodiments. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent replacements, and improvements made within the spirit and principles of the present embodiments shall be included in the protection scope of the present embodiments.

Claims

1. A string comparison method, characterized in that, include: Generate the edit distance matrix between the target string and the reference string; The target service path is determined based on the edit distance matrix, and the characters in the target string and the reference string are combined according to the target service path to obtain the target combination display result and the reference combination display result. The string comparison result between the target string and the reference string is determined based on the target combination display result and the reference combination display result; The step of determining the target business path based on the edit distance matrix includes: The smallest target element in each row and column of the edit distance matrix is ​​selected sequentially; Starting from the top left corner of the edit distance matrix, each target element is connected sequentially to form the target business path; the target business path reflects the differences between the target string and the reference string. The step of combining characters in the target string and the reference string according to the target business path to obtain the target combination display result and the reference combination display result includes: Determine the difference type between each target character in the target string and each reference character in the reference string based on the target business path; Based on the difference type, each target character and each reference character are combined to obtain the target combination display result and the reference combination display result.

2. The method according to claim 1, characterized in that, The generated edit distance matrix between the target string and the reference string includes: Calculate the edit distance between each character in the target string and the reference string; The edit distance matrix is ​​generated based on each of the edit distances.

3. The method according to claim 1, characterized in that, Before determining the string comparison result between the target string and the reference string based on the target combination display result and the reference combination display result, the method further includes: Determine whether there are any ignorable items in the target combination display result and the reference combination display result; If there are ignorable items, then filter out the ignorable items and merge the two combination results before and after the ignorable items; The difference between the two combined results before and after the ignorable term is of the same type.

4. The method according to claim 3, characterized in that, The step of determining the string comparison result between the target string and the reference string based on the target combination display result and the reference combination display result includes: The target combination display result and the reference combination display result are combined to obtain the string comparison result between the target string and the reference string.

5. The method according to any one of claims 1-4, characterized in that, The difference types include at least one of the following: Consistency, modification, addition, and deletion.

6. A string comparison device, characterized in that, include: The edit distance matrix generation module is used to generate the edit distance matrix between the target string and the reference string; The display result determination module is used to determine the target business path based on the edit distance matrix, and to combine each character in the target string and the reference string according to the target business path to obtain the target combination display result and the reference combination display result. The string comparison result determination module is used to determine the string comparison result between the target string and the reference string based on the target combination display result and the reference combination display result; The display result determination module is specifically used for: The smallest target element in each row and column of the edit distance matrix is ​​selected sequentially; Starting from the top left corner of the edit distance matrix, each target element is connected sequentially to form the target business path; the target business path reflects the differences between the target string and the reference string. The result determination module is also specifically used to determine the difference type between each target character in the target string and each reference character in the reference string based on the target business path; Based on the difference type, each target character and each reference character are combined to obtain the target combination display result and the reference combination display result.

7. An electronic device, characterized in that, The electronic device includes: At least one processor; and A memory communicatively connected to the at least one processor; wherein, The memory stores a computer program that can be executed by the at least one processor, the computer program being executed by the at least one processor to enable the at least one processor to perform the string comparison method according to any one of claims 1-5.

8. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions that cause a processor to execute the string comparison method according to any one of claims 1-5.

Citation Information

Patent Citations

  • Method and device for searching contract modification part, computer equipment and storage medium

    CN109933754A