Data matching method, device, equipment, storage medium and program product
By calculating the cost of node matching and structure editing distance during the data matching process, the problem of low data matching accuracy in the prior art is solved, and higher data matching accuracy is achieved.
Patent Information
- Application Number
- CN202211318045.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-10-26
- Publication Date
- 2025-08-22
- Estimated Expiration
- 2042-10-26
AI Technical Summary
In the existing data matching methods, the calculation accuracy of the structure editing distance is low, resulting in low accuracy of the data matching results.
By obtaining the target data set and the data structure of the data set to be matched, node matching is performed, matching costs are calculated, predictive structure editing distance is determined, and operands are determined based on this, and the real structure editing distance is finally calculated, thereby filtering out the data set to be matched that matches the target data set.
Improve the accuracy of data matching and ensure that it is more accurate to filter out data sets that match the target data set from multiple data sets to be matched based on the real structure edit distance.
Smart Images

Figure CN117033759B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a data matching method, apparatus, device, storage medium, and program product. Background Art
[0002] With the rapid development of the internet, more and more interconnected data is available online. To facilitate management and query, data structures are used to represent interconnected data. A data structure is a data structure composed of nodes and edges, which can express the relationships between data.
[0003] When performing data similarity matching, the structural edit distance between the corresponding data structures can be used for matching. The smaller the structural edit distance between two data structures, the more similar they are. However, current methods for calculating the structural edit distance have low accuracy, resulting in low accuracy in data matching results. Summary of the Invention
[0004] The embodiments of the present application provide a data matching method, apparatus, device, storage medium, and program product, which can solve the technical problem of low accuracy of data matching results.
[0005] This embodiment of the present application provides a data matching method, including:
[0006] Obtaining a target data structure corresponding to a target data set and to-be-matched data structures corresponding to at least two to-be-matched data sets, wherein the target data structure includes at least two target nodes, each of which corresponds to data in the target data set, and the to-be-matched data structure includes at least two to-be-matched nodes, each of which represents data in the to-be-matched data set;
[0007] Perform node matching on the target data structure and the to-be-matched data structure to obtain a matching cost between the target node and the to-be-matched node, where the matching cost represents the similarity between the target node and the to-be-matched node;
[0008] determining, based on the matching cost, at least two predicted structure edit distances between the target data structure and the data structure to be matched, wherein the predicted structure edit distances represent predicted similarities between the target data structure and the data structure to be matched;
[0009] Determining the number of operations required to modify the target data structure into the to-be-matched data structure based on the predicted structure edit distance;
[0010] determining, based on the operands, at least two true structure edit distances between the target data structure and the data structure to be matched, wherein the true structure edit distances represent true similarities between the target data structure and the data structure to be matched;
[0011] According to the at least two true structure edit distances, a to-be-matched data set that matches the target data set is screened out from the at least two to-be-matched data sets.
[0012] Accordingly, an embodiment of the present application provides a data matching device, comprising:
[0013] a structure acquisition module, configured to acquire a target data structure corresponding to a target data set and data structures to be matched corresponding to at least two data sets to be matched, wherein the target data structure includes at least two target nodes, each of which corresponds to data in the target data set, and the data structures to be matched include at least two nodes to be matched, each of which represents data in the data sets to be matched;
[0014] A node matching module is used to perform node matching on the target data structure and the to-be-matched data structure to obtain a matching cost between the target node and the to-be-matched node, wherein the matching cost represents the similarity between the target node and the to-be-matched node;
[0015] a first determining module, configured to determine, based on the matching cost, at least two predicted structure edit distances between the target data structure and the data structure to be matched, wherein the predicted structure edit distances represent predicted similarities between the target data structure and the data structure to be matched;
[0016] A second determining module is configured to determine the number of operations required to modify the target data structure into the to-be-matched data structure based on the predicted structure edit distance;
[0017] a third determining module, configured to determine, based on the operands, at least two real structure edit distances between the target data structure and the data structure to be matched, wherein the real structure edit distances represent real similarities between the target data structure and the data structure to be matched;
[0018] A set screening module is used to screen out a set of data to be matched that matches the target data set from the at least two sets of data to be matched based on the at least two real structure edit distances.
[0019] Optionally, the first determining module is specifically configured to execute:
[0020] Determine a combination method of a node matching group, wherein the node matching group includes the target node and the node to be matched;
[0021] According to the above matching cost, the predicted structural edit distance of the above combination is determined;
[0022] At least two predicted structure edit distances between the target data structure and the to-be-matched data structure are screened out from the predicted structure edit distances of the combination.
[0023] Optionally, the first determining module is specifically configured to execute:
[0024] Get iteration constraints;
[0025] According to the matching cost and the iteration constraint, distance iteration is performed on the target data structure and the to-be-matched data structure to obtain at least two predicted structure edit distances.
[0026] Optionally, the first determining module is specifically configured to execute:
[0027] According to the matching cost and the iteration constraint, performing distance iteration on the combination of the node matching group to obtain at least two target combination methods, the node matching group including the target node and the node to be matched;
[0028] At least two predicted structure edit distances between the target data structure and the to-be-matched data structure are determined according to the matching costs of the node matching groups in the at least two target combination modes.
[0029] Optionally, the first determining module is specifically configured to execute:
[0030] Obtaining the number of iterations between the target data structure and the to-be-matched data structure;
[0031] Determine the iteration constraint conditions corresponding to the above number of iterations;
[0032] At least two predicted structure edit distances between the target data structure and the to-be-matched data structure are determined according to the number of iterations, the iteration constraint corresponding to the number of iterations, and the matching cost.
[0033] Optionally, the first determining module is specifically configured to execute:
[0034] Get the current iteration number;
[0035] Determine the historical combination method corresponding to the historical iteration number before the current iteration number;
[0036] According to the historical combination mode, the iteration constraint corresponding to the current iteration number, and the matching cost, a predicted structural edit distance between the target data structure and the to-be-matched data structure for the current iteration number is determined.
[0037] Optionally, the first determining module is specifically configured to execute:
[0038] Determine, based on the historical combination modes, the iteration constraint corresponding to the current iteration number, and the matching cost, an initial predicted structural edit distance for each of the historical combination modes at the current iteration number;
[0039] From the initial predicted structure edit distance, the predicted structure edit distance between the target data structure and the to-be-matched data structure for the current number of iterations is screened out.
[0040] Optionally, the first determining module is specifically configured to execute:
[0041] Select a historical node matching group from each of the above historical combination methods;
[0042] According to each of the above historical node matching groups, the solution space where each node matching group is located is divided to obtain a sub-solution space for each of the above historical combination modes;
[0043] According to the iteration constraint corresponding to the current iteration number and the matching cost of the node matching group in the sub-solution space, the initial predicted structural edit distance of the current iteration number for each of the historical combination modes is determined.
[0044] Optionally, the above historical combination mode includes a combination mode corresponding to adjacent historical iteration numbers, and the solution space where each node matching group is located includes an adjacent solution space where the historical combination mode of the adjacent historical iteration numbers is located.
[0045] Accordingly, the first determining module is specifically configured to execute:
[0046] According to each of the above historical node matching groups, the above adjacent solution space is divided to obtain an initial sub-solution space that does not contain the above historical node matching group;
[0047] Based on the initial sub-solution space, a sub-solution space for each of the above historical combinations is determined.
[0048] Optionally, the second determining module is specifically configured to execute:
[0049] Determine a matching relationship between the target node and the node to be matched based on the predicted structural edit distance;
[0050] According to the matching relationship, the number of operations required to modify the target data structure into the to-be-matched data structure is determined.
[0051] Optionally, the second determining module is specifically configured to execute:
[0052] Determining a first node attribute of the target node and a second node attribute of the node to be matched based on the predicted structural edit distance;
[0053] The number of operations required to modify the target data structure into the to-be-matched data structure is determined according to the first node attribute and the second node attribute.
[0054] Optionally, the second determining module is specifically configured to execute:
[0055] Determining a first edge attribute of the target node based on the predicted structural edit distance, and determining a second edge attribute of the node to be matched;
[0056] The number of operations required to modify the target data structure into the to-be-matched data structure is determined according to the first edge attribute and the second edge attribute.
[0057] Optionally, the second determining module is specifically configured to execute:
[0058] Based on the predicted structural edit distance, selecting a first node pair from the target data structure, where the first node pair includes the target node;
[0059] Filtering out a second node pair that matches the first node pair from the to-be-matched data structure, wherein the second node pair includes the to-be-matched node;
[0060] A first node attribute of the first node pair is determined, and a second node attribute of the second node pair is determined.
[0061] Optionally, the second determining module is specifically configured to execute:
[0062] If the first edge attribute indicates that a connected edge exists, and the second edge attribute indicates that a connected edge does not exist, then the connected edge in the first node pair is deleted to obtain an edge operand;
[0063] According to the edge operands, the operands required to modify the target data structure into the to-be-matched data structure are determined.
[0064] Optionally, the second determining module is specifically configured to execute:
[0065] If the first edge attribute indicates that there is no connected edge, and the second edge attribute indicates that there is a connected edge, then adding the connected edge to the first node pair to obtain an edge operand;
[0066] According to the edge operands, the operands required to modify the target data structure into the to-be-matched data structure are determined.
[0067] In addition, an embodiment of the present application also provides an electronic device, including a processor and a memory, wherein the memory stores a computer program, and the processor is used to run the computer program in the memory to implement the data matching method provided in the embodiment of the present application.
[0068] In addition, an embodiment of the present application further provides a computer-readable storage medium, which stores a computer program. The computer program is suitable for loading by a processor to execute any data matching method provided in the embodiment of the present application.
[0069] In addition, an embodiment of the present application also provides a computer program product, including a computer program, which implements any data matching method provided in the embodiment of the present application when executed by a processor.
[0070] In an embodiment of the present application, a target data structure corresponding to a target data set and data structures to be matched corresponding to at least two data sets to be matched are obtained, the target data structure includes at least two target nodes, each target node corresponds to data in the target data set, and the data structure to be matched includes at least two nodes to be matched, each node to be matched represents data in the data set to be matched; node matching is performed on the target data structure and the data structure to be matched to obtain a matching cost between the target node and the node to be matched, and the matching cost represents the similarity between the target node and the node to be matched; based on the matching cost, at least two predicted structure edit distances between the target data structure and the data structure to be matched are determined, and the predicted structure edit distance represents the predicted similarity between the target data structure and the data structure to be matched; based on the predicted structure edit distance, at least two operands required to modify the target data structure to the data structure to be matched are determined; based on the operands, at least two real structure edit distances between the target data structure and the data structure to be matched are determined, and the real structure edit distance represents the real similarity between the target data structure and the data structure to be matched; based on the at least two real structure edit distances, a data set to be matched that matches the target data set is screened out from the at least two data sets to be matched.
[0071] That is, in an embodiment of the present application, since multiple predicted similarities between the target data structure and the data structure to be matched are first determined, multiple operands can be obtained through multiple predicted similarities, that is, multiple real structure edit distances can be obtained through multiple predicted similarities, so that the real structure edit distance that meets the real distance condition can be screened out from the multiple real structure edit distances, so that the real structure edit distance finally obtained is more accurate, thereby making it more accurate to screen out the data set to be matched that matches the target data set from multiple data sets to be matched based on the real structure edit distance. BRIEF DESCRIPTION OF THE DRAWINGS
[0072] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.
[0073] Figure 1 Schematic diagram of the data matching process provided in the embodiment of the present application;
[0074] Figure 2 Schematic diagram of the data matching method provided in the embodiment of the present application;
[0075] Figure 3 Schematic diagram of a method for calculating a predicted structural edit distance provided in an embodiment of the present application;
[0076] Figure 4 This is a schematic diagram of a node matching group provided in an embodiment of the present application;
[0077] Figure 5 Schematic diagram of the division of the solution space provided in an embodiment of the present application;
[0078] Figure 6 This is a schematic diagram of another way of dividing the solution space provided in an embodiment of the present application;
[0079] Figure 7 is a schematic diagram of the target data structure and the data structure to be matched provided in an embodiment of the present application;
[0080] Figure 8 This is a flow chart of another data matching method provided in an embodiment of the present application;
[0081] Figure 9 is a schematic diagram of a target data structure modification method provided by an embodiment of the present application;
[0082] Figure 10 This is a flow chart of another data matching method provided in an embodiment of the present application;
[0083] Figure 11 Schematic diagram of the structure of the data matching device provided in an embodiment of the present application;
[0084] Figure 12 It is a structural diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0085] The following will be combined with the drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without making creative efforts are within the scope of protection of this application.
[0086] Embodiments of the present application provide a data matching method, apparatus, device, storage medium, and program product. The apparatus may be an electronic device, the storage medium may be a computer storage medium, and the program product may be a computer program product. The data matching apparatus may be integrated into an electronic device, which may be a server, a terminal, or other device.
[0087] Among them, the server can be an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, network acceleration services (Content Delivery Network, CDN), as well as big data and artificial intelligence platforms.
[0088] Furthermore, multiple servers can form a blockchain, and the servers are nodes on the blockchain.
[0089] The terminal may be a smartphone, tablet computer, laptop computer, desktop computer, smart speaker, smart watch, etc., but is not limited thereto. The terminal and the server may be connected directly or indirectly via wired or wireless communication, and this application does not impose any restrictions thereon.
[0090] For example, Figure 1 As shown, the terminal obtains the target data set and sends the target data set to the server. The server then determines the target data structure corresponding to the target data set and obtains the to-be-matched data structures corresponding to at least two to-be-matched data sets. The target data structure includes at least two target nodes, each target node corresponds to the data in the target data set, and the to-be-matched data structure includes at least two to-be-matched nodes, each to-be-matched node represents the data in the to-be-matched data set.
[0091] The server then performs node matching on the target data structure and the data structure to be matched, and obtains the matching cost between the target node and the node to be matched. The matching cost represents the similarity between the target node and the node to be matched, and determines at least two predicted structure editing distances between the target data structure and the data structure to be matched based on the matching cost. The predicted structure editing distance represents the predicted similarity between the target data structure and the data structure to be matched.
[0092] Next, the server determines the number of operations required to modify the target data structure to the to-be-matched data structure based on the predicted structural edit distance. Based on the number of operations, the server determines at least two true structural edit distances between the target data structure and the to-be-matched data structure. The true structural edit distances represent the true similarity between the target and to-be-matched data structures. Finally, based on the at least two true structural edit distances, the server selects a to-be-matched data set that matches the target data set from the at least two to-be-matched data sets and returns the matching to the terminal, thereby obtaining the matching data set that matches the target data set.
[0093] In the specific implementation of this application, related data such as user information is involved. When the above embodiments of this application are applied to specific products or technologies, user permission or consent is required, and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards of relevant countries and regions.
[0094] In addition, the term "a plurality of" in the embodiments of the present application refers to two or more than two. The terms "first" and "second" in the embodiments of the present application are used to distinguish descriptions and should not be understood to imply relative importance.
[0095] It should be noted that the order of description of the following embodiments is not intended to limit the preferred order of the embodiments.
[0096] In this embodiment, the data matching device will be described from the perspective of the data matching method. In order to facilitate the description of the data matching method of the present application, the data matching device will be integrated into the terminal for detailed description, that is, the terminal will be used as the execution subject for detailed description.
[0097] See also Figure 2 , Figure 2 : is a flow chart of a data matching method provided in one embodiment of the present application. The data matching method may include:
[0098] S201. Obtain a target data structure corresponding to a target data set and data structures to be matched corresponding to at least two data sets to be matched, wherein the target data structure includes at least two target nodes, each target node corresponds to data in the target data set, and the data structure to be matched includes at least two nodes to be matched, each node to be matched represents data in the data set to be matched.
[0099] A data set refers to a set of data with associated relationships. The target data set may be the data set to be matched. The target data structure may be a data structure constructed based on the associated relationships between data in the target data set. A data structure may be composed of nodes, or alternatively, nodes and edges between nodes.
[0100] The definition of the to-be-matched data set and the to-be-matched data structure may refer to the description of the target data set and the target data structure, which will not be repeated in this embodiment.
[0101] After obtaining the target data set, the terminal can construct a target data structure corresponding to the target data set and obtain a to-be-matched data structure corresponding to the to-be-matched data set. Alternatively, the terminal can directly obtain the target data structure corresponding to the target data set and obtain a to-be-matched data structure corresponding to the to-be-matched data set. This example is not limited here.
[0102] S202 : Perform node matching on the target data structure and the data structure to be matched to obtain a matching cost between the target node and the node to be matched, where the matching cost represents the similarity between the target node and the node to be matched.
[0103] The method for determining the matching cost between the target node and the node to be matched can be selected according to the actual situation. For example, the matching cost can be determined based on whether there is a connecting edge between the target node and the node to be matched, or the matching cost can be determined based on the connection weight between the target node and the node to be matched. This embodiment does not limit this.
[0104] The method of determining the connection edge between the target node and the node to be matched and the method of determining the connection weight between the target node and the node to be matched can be selected according to actual conditions and are not limited in this example.
[0105] Performing node matching on the target data structure and the to-be-matched data structure may refer to pairwise matching of target nodes in the target data structure with to-be-matched nodes in the to-be-matched data structure, thereby obtaining matching costs between the target nodes and the to-be-matched nodes.
[0106] For example, target node n11 is matched with to-be-matched node n21 in pairs, and target node n11 is matched with to-be-matched node n22 in pairs.
[0107] When the similarity between the target node and the node to be matched is higher, the matching cost between the target node and the node to be matched is lower; when the similarity between the target node and the node to be matched is lower, the matching cost between the target node and the node to be matched is higher.
[0108] S203 : Determine at least two predicted structure edit distances between the target data structure and the data structure to be matched based on the matching cost, where the predicted structure edit distances represent predicted similarities between the target data structure and the data structure to be matched.
[0109] When the true structure edit distance between two data structures is smaller, the two data structures are more similar. In related technologies, the true structure edit distance can be calculated using a greedy algorithm.
[0110] The greedy algorithm refers to defining a local greedy function f(u,v), where u represents a node in the data structure G1, v represents a node in the data structure G2, and f(u,v) represents the cost of node u corresponding to node v. The predicted structure edit distance between the two data structures is calculated using the local greedy function, and then a minimum predicted structure edit distance is obtained through the optimal matching algorithm. Finally, the minimum predicted structure edit distance is used as a greedy approximation of the true structure edit distance.
[0111] Assuming that both data structures contain n nodes, the sum of the costs of n groups of correspondences between the two data structures is:
[0112] F=f(u1,v1)+f(u2,v2)+...+f(u n ,v n )
[0113] The above cost sum is also the predicted structural edit distance in the embodiment of the present application. The minimum cost sum Dis(f) is used as a greedy approximate solution of the true structural edit distance. That is, the true structural edit distance and the minimum cost sum satisfy the following relationship:
[0114] GED(G1,G2)=argmin{Dis(f)|f:vu}
[0115] GED(G1,G2) represents the true structural edit distance between data structure G1 and data structure G2.
[0116] That is, the calculated predicted structure edit distance is an upper bound of the true structure edit distance:
[0117] Dis(f)>=GED(G1,G2)
[0118] In practical applications, in order to ensure the overall polynomial complexity of the algorithm, a function that is easy to calculate is usually selected as a greedy function, which leads to an unstable correlation between the predicted structure edit distance and the true structure edit distance. As a result, there is no theoretical guarantee for the gap between the minimum predicted structure edit distance and the minimum true structure edit distance. As a result, the true structure edit distance obtained based on the minimum predicted structure edit distance cannot be guaranteed to be the minimum, which in turn leads to inaccurate true structure edit distance, reducing the accuracy of the matched data set.
[0119] For example, the greedy function is set to the degree difference between two nodes. The degree difference refers to the difference between the number of edges of node u and the number of edges of node v. For example, if node u has three edges and node v has four edges, then f(u,v) = |3-4| = 1. In this case, the greedy function can be as follows:
[0120] f(u,v)=|d(u)-d(v)|
[0121] d(u) represents the number of edges of node u, and d(v) represents the number of edges of node v. The total cost can be shown as follows:
[0122] F=Dis(f)=Sum{f(u,v)|u∈G1}
[0123] Compared with the definition of the true structural edit distance, the above cost sum calculation method ignores the matching relationship between the adjacent nodes of node u and the adjacent nodes of node v. Although it simplifies the algorithm complexity, the true structural edit distance obtained according to the minimum predicted structural edit distance cannot be guaranteed to be the minimum.
[0124] Therefore, in this embodiment, at least two predicted structure edit distances between the target data structure and the data structure to be matched are determined based on the matching cost, and it is not just about calculating the minimum predicted structure edit distance between the target data structure and the data structure to be matched, so that at least two real structure edit distances can be obtained based on the at least two predicted structure edit distances, thereby improving the accuracy of the data set to be matched matched based on the real structure edit distances.
[0125] The number of predicted structural edit distances may be k, where k is an integer and is equal to or greater than 2. k may be set according to actual conditions and is not limited in this embodiment.
[0126] Optionally, at least two predicted structure edit distances can be predicted structure edit distances between the target data structure and the data structure to be matched that satisfy a preset distance condition. The preset distance condition can be set according to actual conditions. For example, the preset distance condition can be a minimum distance. That is, at this time, at least two predicted structure edit distances can be at least two minimum predicted structure edit distances between the target data structure and the data structure to be matched.
[0127] For example, the predicted structural edit distances between the target data structure and the data structure to be matched include 5, namely 100, 150, 40, 80 and 120, then at least two predicted structural edit distances between the target data structure and the data structure to be matched may be 40 and 80.
[0128] In some embodiments, the terminal can determine all combinations of node matching groups, that is, obtain all matching methods between the target data structure and the data structure to be matched, and then determine the predicted structural editing distance of each combination based on the matching cost, and then screen out at least two predicted structural editing distances from the predicted structural editing distances of each combination.
[0129] For example, when the at least two predicted structure edit distances are k minimum predicted structure edit distances, the terminal can obtain all combinations of node matching groups, and then determine the predicted structure edit distances of each combination based on the matching cost, and select the k minimum predicted structure edit distances from each predicted structure edit distance.
[0130] However, when the number of target nodes and nodes to be matched is large, determining all combinations of node matching groups and then determining the predicted structural edit distance of each combination based on the matching cost requires enumerating all matching methods between the target data structure and the data structure to be matched, resulting in a large amount of calculation.
[0131] Therefore, in some other embodiments, determining at least two predicted structural edit distances between the target data structure and the data structure to be matched based on the matching cost includes:
[0132] Get iteration constraints;
[0133] According to the matching cost and iteration constraints, the target data structure and the data structure to be matched are iterated to obtain at least two predicted structure edit distances.
[0134] The iterative constraint condition can be set according to the preset distance condition. For example, if the preset distance condition is the minimum distance, the iterative constraint condition can be iteratively searching for at least two minimum predicted structure edit distances. In this case, the predicted structure edit distance can be positively correlated with the true structure edit distance. For another example, if the preset distance condition is the maximum distance, the iterative constraint condition can be iteratively searching for at least two maximum predicted structure edit distances. In this case, the predicted structure edit distance can be negatively correlated with the true structure edit distance.
[0135] In this embodiment, by iterating the constraints, distance iteration is performed on the target data structure and the data structure to be matched so that at least two predicted structure edit distances can be obtained, which eliminates the need to enumerate all matching methods between the target data structure and the data structure to be matched, thereby reducing the amount of calculation.
[0136] Among them, according to the matching cost and iteration constraints, the method of distance iteration on the target data structure and the data structure to be matched can be selected according to actual conditions. For example, the Hungarian algorithm or the km (Kuhn-Munkres) algorithm can be selected, which is not limited in this embodiment.
[0137] Refer to the following Figure 3 , with the iterative constraint condition of finding the matching method with the maximum matching cost (that is, obtaining the minimum predicted structure editing distance), the process of using the km (Kuhn-Munkres) algorithm to iterate the distance between the target data structure and the data structure to be matched according to the matching cost and iterative constraint condition is explained.
[0138] The maximum matching cost between the target node and each node to be matched is assigned as the vertex value of the target node, and the vertex value of the node to be matched is assigned as 0. For example, Figure 3 As shown in 301 , the matching cost between the target node n11 and the to-be-matched node n21 is 0.8, and the matching cost between the target node n11 and the to-be-matched node n22 is 0.6. Then, the matching cost 0.8 is assigned as the vertex value of the target node n11.
[0139] After obtaining the vertex assignment of each target node, the to-be-matched node corresponding to the matching cost equal to or greater than the vertex assignment is used as the to-be-matched node to be matched with the target node. Optionally, the to-be-matched node with the same matching cost as the vertex assignment is first used as the to-be-matched node to be matched with the target node. If the to-be-matched node with the same matching cost as the vertex assignment has been matched, the vertex assignment of the target node and the vertex assignment of the target node that has been matched with the to-be-matched node are subtracted by a preset value, and the vertex assignment of the to-be-matched node is increased by a preset value. Then, the step of using the to-be-matched node with the same matching cost as the vertex assignment as the to-be-matched node to be matched with the target node is returned to be executed until all target nodes in the target data structure are matched, and the matching method with the maximum matching cost is obtained, thereby obtaining the minimum predicted structure editing distance.
[0140] For example, Figure 3 As shown in 301, the preset value is set to 0.1, the vertex value of the target node n11 is assigned to 0.8, the matching cost between the target node n11 and the node to be matched n21 is 0.8, and the node to be matched n21 has not been matched before, then the node to be matched n21 is used as the node to be matched with the target node n11, then the vertex value of the target node n12 is assigned to 0.9, the matching cost between the target node n12 and the node to be matched n23 is 0.9, and the node to be matched n23 has not been matched before, then the node to be matched n23 is used as the node to be matched with the target node n12. Matching nodes, the vertex value of target node n13 is 0.9, and the matching cost between target node n13 and the node to be matched n21 is 0.9. However, since the node to be matched n21 has been matched, the vertex value of target node n11 is subtracted by 0.1, and the vertex value of target node n11 is 0.7. The vertex value of target node n13 is subtracted by 0.1, and the vertex value of target node n13 is 0.8. The vertex value of the node to be matched n21 is increased by 0.1, and the vertex value of the node to be matched n21 is 0.1. At this time, it can be as follows Figure 3 As shown in 302.
[0141] At this time, the matching cost between the target node n11 and the to-be-matched node n21 is 0.8 (0.7+0.1=0.8), which is greater than the vertex assignment 0.7 of the target node n11. The to-be-matched node matched by the target node n11 is still the to-be-matched node n21. Although the matching cost 0.9 between the target node n13 and the to-be-matched node n21 is greater than the vertex assignment 0.8 of the target node n13, the to-be-matched node n21 has been matched and the matching cost 0.8 between the target node n13 and the to-be-matched node n22 is equal to the vertex assignment 0.8 of the target node n13. Therefore, the to-be-matched node n22 can be used as the to-be-matched node matched with the target node n13.
[0142] If at this time, the target node n13 has not found a matching node to be matched, the vertex assignment of the target node n13 and the vertex assignment of the target node n11 are subtracted by 0.1, and the vertex assignment of the matching node n21 is increased by 0.1 until a matching node to be matched with the target node n13 is found.
[0143] The km (Kuhn-Munkres) algorithm is used to perform distance iteration on the target data structure and the data structure to be matched according to the matching cost and iteration constraints, and the matching method with the second largest matching cost (the second smallest predicted structure editing distance) is found. For details, please refer to the process of determining the matching method with the largest matching cost, which will not be repeated in this embodiment.
[0144] In some other embodiments, distance iteration is performed on the target data structure and the data structure to be matched based on the matching cost and the iteration constraint to obtain at least two predicted structure edit distances, including:
[0145] According to the matching cost and the iteration constraint, the node matching group combination method is iterated to obtain at least two target combination methods, and the node matching group includes the target node and the node to be matched;
[0146] At least two predicted structural edit distances between the target data structure and the to-be-matched data structure are determined according to the matching costs of the node matching groups in the at least two target combination modes.
[0147] The target combination method refers to the matching method between the target data structure and the data structure to be matched. When the combination method of the node matching group is different, the matching method between the target data structure and the data structure to be matched is also different.
[0148] For example, Figure 4 As shown, there are node matching groups g1, g2, g3 and g4, the node matching group g1 includes the target node n11 and the node to be matched n21, the node matching group g2 includes the target node n11 and the node to be matched n22, the node matching group g3 includes the target node n12 and the node to be matched n21, and the node matching group g4 includes the target node n12 and the node to be matched n22. The combination method of the node matching groups can be to combine the node matching group g1 and the node matching group g4 to obtain a matching method of the target data structure and the data structure to be matched, and to combine the node matching group g2 and the node matching group g3 to obtain another matching method of the target data structure and the data structure to be matched.
[0149] It should be understood that when the terminal performs distance iteration on the combination method of the node matching group to obtain the target combination method, it can obtain the predicted structure editing distance corresponding to the target combination method. Alternatively, the terminal can also perform distance iteration on the combination method of the node matching group to obtain the target combination method, and then determine at least two predicted structure editing distances between the target data structure and the data structure to be matched based on the matching costs of the node matching groups in at least two target combination methods.
[0150] In some other embodiments, determining at least two predicted structural edit distances between the target data structure and the data structure to be matched based on the matching cost includes:
[0151] Get the number of iterations between the target data structure and the data structure to be matched;
[0152] Determine the iteration constraints corresponding to the number of iterations;
[0153] At least two predicted structure edit distances between the target data structure and the to-be-matched data structure are determined according to the number of iterations, the iteration constraint corresponding to the number of iterations, and the matching cost.
[0154] It should be noted that the corresponding iteration constraints for each iteration can be different. For example, when at least two predicted structure edit distances are the two smallest predicted structure edit distances, the iteration constraint for the first iteration can be to find the smallest predicted structure edit distance, and the iteration constraint for the second iteration can be to find the second smallest predicted structure edit distance.
[0155] Alternatively, the iteration constraints corresponding to each iteration may be the same, and the minimum predicted structure edit distance is found, but the corresponding node matching groups are different in each iteration, so that the predicted structure edit distances of different iteration times are different according to the same iteration constraints.
[0156] For example, in the first iteration, all node matching groups between the target data structure and the data structure to be matched are iterated. The target combination of the first iteration includes node matching group g1, node matching group g2, and node matching group g3. Then, in the second iteration, the combination of node matching groups between the target data structure and the data structure to be matched, except for node matching group g1, can be iterated.
[0157] In this embodiment, the iteration constraint can be associated with the number of iterations. Then, when the iteration reaches the current number of iterations, the predicted structure editing distance of the current number of iterations is obtained based on the iteration constraint and matching cost corresponding to the current number of iterations, thereby obtaining at least two predicted structure editing distances.
[0158] In some other embodiments, determining at least two predicted structural edit distances between the target data structure and the data structure to be matched based on the number of iterations, the iteration constraint corresponding to the number of iterations, and the matching cost includes:
[0159] Get the current iteration number;
[0160] Determine the historical combination method corresponding to the historical iteration number before the current iteration number;
[0161] According to the historical combination mode, the iteration constraint corresponding to the current iteration number, and the matching cost, the predicted structural editing distance between the target data structure and the data structure to be matched for the current iteration number is determined.
[0162] The current iteration count refers to the number of iterations currently in progress, while the past iteration count refers to the number of iterations that have already been completed. For example, if the current iteration count is the fifth iteration, the past iteration count could be the first iteration, the second iteration, the third iteration, or the fourth iteration.
[0163] If the current iteration number is the first iteration, the predicted structural edit distance between the target data structure and the data structure to be matched can be determined directly based on the iteration constraint corresponding to the current iteration number and the matching cost.
[0164] Optionally, at least two predicted structural edit distances between the target data structure and the data structure to be matched may be determined based on a historical combination method corresponding to at least one historical iteration number before the current iteration number, an iteration constraint corresponding to the current iteration number, and a matching cost.
[0165] The at least one historical iteration number may be two historical iteration numbers adjacent to the current iteration number. For example, if the current iteration number is the fifth iteration, the historical iteration numbers may be the third iteration and the fourth iteration.
[0166] In some other embodiments, determining the predicted structural edit distance between the target data structure and the data structure to be matched for the current number of iterations based on the historical combination mode, the iteration constraint corresponding to the current number of iterations, and the matching cost includes:
[0167] Determine the initial predicted structural edit distance for each historical combination at the current iteration based on the historical combination, the iteration constraints corresponding to the current iteration, and the matching cost;
[0168] From the initial predicted structure edit distance, the predicted structure edit distance between the target data structure and the data structure to be matched for the current number of iterations is filtered out.
[0169] In this implementation, for each historical combination, there is an initial predicted structural edit distance, and then the predicted structural edit distance between the target data structure and the data structure to be matched for the current number of iterations is screened out from the multiple initial predicted structural edit distances.
[0170] Among them, according to the historical combination mode, the iteration constraint corresponding to the current iteration number, and the matching cost, the process of determining the initial predicted structural edit distance for each historical combination mode at the current iteration number can be:
[0171] According to the matching cost, determine the initial combination method of the node matching group. If the initial combination method is not a historical combination method, check whether the initial combination method meets the iteration constraint conditions corresponding to the current number of iterations. If so, use the initial combination method as the target combination method for each historical combination method for the current number of iterations. If not, return to the step of determining the initial combination method of the node matching group according to the matching cost.
[0172] Alternatively, in some other embodiments, based on the historical combination modes, the iteration constraints corresponding to the current iteration number, and the matching cost, the process of determining the initial predicted structural edit distance for each historical combination mode at the current iteration number is also as follows:
[0173] Select a historical node matching group from each historical combination;
[0174] According to each historical node matching group, the solution space of each node matching group is divided to obtain a sub-solution space for each historical combination;
[0175] According to the iteration constraints corresponding to the current iteration number and the matching cost of the node matching group in the sub-solution space, the initial predicted structural edit distance for each historical combination method at the current iteration number is determined.
[0176] It should be understood that when distance iteration is performed on the combination of node matching groups according to the matching cost and the iteration constraint to obtain at least two target combination methods, the process of determining the initial predicted structural edit distance for each historical combination method at the current iteration number according to the iteration constraint corresponding to the current iteration number and the matching cost of the node matching group in the sub-solution space can be:
[0177] According to the iteration constraints corresponding to the current iteration number and the matching cost of the node matching group in the sub-solution space, the distance iteration is performed on the combination of the node matching group to obtain the target combination for each historical combination at the current iteration number;
[0178] According to the matching cost of the node matching group in the target combination mode for each historical combination mode, the initial predicted structural edit distance for each historical combination mode at the current iteration number is determined.
[0179] A historical node matching group can be any node matching group in the historical combinations. The solution space of a node matching group can refer to the set of all node matching group combinations. Alternatively, the solution space of a node matching group can refer to the set of all perfect matching methods between the target data structure and the data structure to be matched, that is, the set of perfect combinations of node matching groups. A perfect matching method refers to a matching method in which every target node in the target data structure has a matching node in the data structure to be matched. When both data structures contain n nodes, there are a total of n! perfect matching methods.
[0180] For example, the target data structure and the data structure to be matched can be as follows Figure 4 If in combination mode 1 of the node matching group, that is, in matching mode 1, the target node n11 matches the to-be-matched node n21, and the target node n12 matches the to-be-matched node n22, then matching mode 1 is a perfect matching mode.
[0181] When the solution space where the node matching group is located is a set of perfect matching methods between the target data structure and the data structure to be matched, the combination methods of the node matching group are distance iterated according to the iteration constraints corresponding to the current number of iterations and the matching costs of the node matching groups in the sub-solution space to obtain the target combination method for each historical combination method at the current number of iterations. This can be understood as finding a perfect matching method that meets the iteration constraints from the perfect matching methods between the target data structure and the data structure to be matched.
[0182] It should be noted that if the current iteration number is the second iteration, the historical iteration number of the current iteration number may be the first iteration, that is, at this time, the historical combination mode includes only one.
[0183] Although the solution space where the node matching group is located is a set of perfect matching methods between the target data structure and the data structure to be matched, in this embodiment, since the target combination method is obtained through iteration, the solution space where the node matching group is located can be a blank solution space, and then the target combination method is found through iteration. There is no need to enumerate the perfect matching methods between the target data structure and the data structure to be matched, thereby reducing the amount of calculation.
[0184] In this embodiment, the iteration constraints for each iteration number can be the same. Then, according to each historical node matching group, the solution space where each node matching group is located is divided to obtain a sub-solution space for each historical combination method. Based on the iteration constraints corresponding to the current iteration number and the matching cost of the node matching group in the sub-solution space, the initial predicted structural editing distance for each historical combination method at the current iteration number is determined.
[0185] Among them, according to each historical node matching group, the solution space where each node matching group is located is divided, and the process of obtaining the sub-solution space for each historical combination can be:
[0186] According to the historical node matching groups of all historical iterations before the current iteration, the solution space where each node matching group is located is divided to obtain the initial sub-solution space that does not contain the historical node matching group;
[0187] According to the initial sub-solution space, a sub-solution space for each historical combination is determined.
[0188] For example, Figure 5 As shown, the solution space where each node matching group is located is M, that is, the solution space of the target data structure and the data structure to be matched is M, and the current number of iterations is the third iteration. The node matching group g1 and the node matching group g2 are screened out from the historical combination method of the first iteration, and the node matching group g3 is screened out from the historical combination method of the second iteration. Then, the solution space M is divided to obtain a first initial sub-solution space M1 that does not contain the node matching group g2 and a second initial sub-solution space M2 that does not contain the node matching group g1 and the node matching group g3. Then, the second initial sub-solution space is used as the sub-solution space for the historical combination method of the second iteration, and the first initial sub-solution space is used as the sub-solution space for the historical combination method of the first iteration.
[0189] Alternatively, the historical combination mode includes the combination mode corresponding to the adjacent historical iteration number, and the solution space where each node matching group is located includes the adjacent solution space where the historical combination mode of the adjacent historical iteration number is located. In this case, according to each historical node matching group, the solution space where each node matching group is located is divided, and the process of obtaining the sub-solution space for each historical combination mode can also be:
[0190] According to each historical node matching group, the adjacent solution space is divided to obtain the initial sub-solution space that does not contain the historical node matching group;
[0191] According to the initial sub-solution space, the sub-solution space for each historical combination is determined.
[0192] The adjacent solution space where the historical combination of adjacent historical iteration numbers is located may refer to a solution space that includes the historical combination of adjacent historical iteration numbers.
[0193] The initial sub-solution space that does not include the historical node matching group can be understood as the initial sub-solution space composed of the combination of edges that do not include the historical node matching group. For example, Figure 4 As shown, the historical combination method includes the node matching group g1 and the node matching group g4. The node matching group g1 is a historical matching node, and the initial sub-solution space that does not include the node matching group g1 can be an initial sub-solution space composed of a combination method that does not include the edge between the target node n11 and the node to be matched n21.
[0194] Different historical combinations of adjacent historical iterations can exist in different solution spaces. For example, when the adjacent historical iteration number is one historical iteration number, the adjacent solution space may include the solution space containing the historical combination of the previous historical iteration number after the current iteration number (if it is the first iteration, it can be directly iterated according to the solution space where the node matching group is located). When the adjacent historical iteration number is two adjacent historical iteration numbers, the adjacent solution space may include the solution space containing the historical combination of the previous historical iteration number adjacent to the current iteration number and the solution space containing the historical combination of the next historical iteration number adjacent to the current iteration number.
[0195] The previous historical iteration number refers to the iteration number with the larger difference between the two previous iteration numbers and the current iteration number. The next historical iteration number refers to the iteration number with the smaller difference between the two previous iteration numbers and the current iteration number. For example, if the current iteration number is the third, the previous historical iteration number refers to the first iteration, and the next historical iteration number refers to the second iteration.
[0196] For example, Figure 6 As shown, the solution space where each node matching group is located is M. When the current iteration number is the first iteration, the node matching group in the solution space M is iterated to obtain the target combination method of the first iteration and the solution space M1 where the target combination method of the first iteration is located. At this time, the solution space M1 can be the same as the solution space M.
[0197] When the current iteration number is the second iteration, and the adjacent historical iteration number of the current iteration number is the first iteration, the adjacent solution space can be the solution space M1 where the historical combination method of the first iteration is located (when the first iteration is the current iteration number, the combination method of the first iteration is called the target combination method, and when the first iteration is the historical iteration number, the combination method of the first iteration is called the historical combination method). From the historical combination methods of the first iteration, the historical node matching group g1 is selected, and the solution space M1 is divided according to the historical node matching group g1 to obtain an initial sub-solution space M2 that does not include the historical node matching group g1, and M1' that includes the historical node matching group g1. The initial sub-solution space M2 is used as the sub-solution space of the historical combination method of the first iteration for the current iteration number.
[0198] When the current iteration number is the third iteration, the previous historical iteration number adjacent to the current iteration number is the first iteration, and the next historical iteration number is the second iteration. The adjacent solution spaces may be solution space M1' containing the historical combination scheme of the first iteration and solution space M2 containing the historical combination scheme of the second iteration. A historical node matching group g2 is selected from the historical combination schemes of the second iteration, and solution space M2 is partitioned based on historical node matching group g2 to obtain an initial sub-solution space M3a that does not contain historical node matching group g2, and a solution space M2' that contains historical node matching group g2. The initial sub-solution space M3a is used as the sub-solution space for the historical combination scheme of the second iteration for the current iteration number.
[0199] Filter out the historical node matching group g3 from the historical combination method of the first iteration, divide the solution space M1' according to the historical node matching group g3, and obtain the initial sub-solution space M3b that does not contain the historical node matching group g3, and the solution space M1'' that contains the historical node matching group g3. The initial sub-solution space M3b is used as the sub-solution space for the historical combination method of the first iteration for the current iteration number.
[0200] It should be noted that the solution space containing the historical combination schemes of the previous historical iteration number adjacent to the current iteration number may include a first solution space and a second solution space. When dividing the solution space containing the historical combination schemes of the previous historical iteration number adjacent to the current iteration number, the division may be performed on the second solution space containing the historical combination schemes of the previous historical iteration number or on the first solution space containing the historical combination schemes of the previous historical iteration number. The second solution space containing the historical combination schemes of the previous historical iteration number refers to the solution space containing the combination schemes composed of the historical node matching groups in the historical combination schemes, and the first solution space containing the historical combination schemes of the previous historical iteration number refers to the solution space containing the combination schemes composed of the historical node matching groups in the historical combination schemes and the solution space containing the combination schemes that do not consist of the historical node matching groups in the historical combination schemes. That is, after dividing the first solution space containing the historical combination schemes of the previous historical iteration number, a second solution space containing the historical node matching groups and an initial sub-solution space that does not contain the historical node matching groups can be obtained.
[0201] For example, Figure 6 As shown, the current iteration number is the fourth iteration, then the first solution space where the historical combination method of the previous historical iteration number is located is the solution space M2, and the second solution space where the historical combination method of the previous historical iteration number is located is the solution space M2', and the solution space M2' contains the combination method composed of the historical node matching group g1.
[0202] In this embodiment, by dividing the solution space between the target data structure and the data structure to be matched, the target combination method for each historical combination method at the current iteration number is obtained, thereby obtaining the initial predicted structural editing distance for each historical combination method at the current iteration number.
[0203] After obtaining the target combination for each historical combination, the terminal can determine the initial predicted structural edit distance for each historical combination at the current iteration number based on the matching cost of the node matching group in the target combination for each historical combination.
[0204] For example, Figure 6As shown, after performing distance iteration on the combination mode of the node matching groups according to the iterative constraints of the third iteration and the matching costs of the node matching groups in the initial sub-solution space M3b, a first target combination mode for the historical combination mode of the first iteration is obtained for the third iteration, and after performing distance iteration on the combination mode of the node matching groups according to the iterative constraints of the third iteration and the matching costs of the node matching groups in the initial sub-solution space M3a, a second target combination mode for the historical combination mode of the second iteration is obtained for the third iteration, the initial predicted structural editing distance for the historical combination mode of the first iteration is determined according to the matching costs of the node matching groups in the first target combination mode, and the initial predicted structural editing distance for the historical combination mode of the second iteration is determined according to the matching costs of the node matching groups in the second target combination mode.
[0205] Then, the predicted structure editing distance for the current number of iterations is screened out from the initial predicted structure editing distance for the historical combination method for the first iteration and the initial predicted structure editing distance for the historical combination method for the second iteration, until the iteration number is completed, and at least two predicted structure editing distances between the target data structure and the data structure to be matched are obtained.
[0206] If the preset distance condition is a minimum distance, the minimum initial predicted structure edit distance among the initial predicted structure edit distances may be used as the predicted structure edit distance between the target data structure and the data structure to be matched for the current number of iterations.
[0207] It should be noted that after obtaining the predicted structural editing distance of the current iteration number, the terminal can filter out the solution space where the historical combination method of the current iteration number is located from the sub-solution space for each historical combination method of the current iteration number based on the predicted structural editing distance of the current iteration number, so that the solution space where the historical combination method of the current iteration number is located can be used in the next iteration.
[0208] Optionally, the terminal may use the sub-solution space of the historical combination method corresponding to the predicted structural edit distance as the solution space of the historical combination method of the current iteration number.
[0209] For example, Figure 6 As shown, the sub-solution space of the historical combination method of the first iteration in the third iteration is the initial sub-solution space M3b, and the sub-solution space of the historical combination method of the second iteration in the third iteration is the initial sub-solution space M3a. If the predicted structural edit distance of the third iteration is the initial predicted structural edit distance corresponding to the target combination method obtained according to the initial sub-solution space M3b, then the initial sub-solution space M3b is used as the solution space where the historical combination method of the third iteration is located.
[0210] If the third predicted structural edit distance is the initial predicted structural edit distance corresponding to the target combination method obtained according to the initial sub-solution space M3a, the initial sub-solution space M3a is used as the solution space where the historical combination method of the third iteration is located.
[0211] Then, in the fourth iteration, the solution space is divided according to the historical combination mode of the second iteration and the solution space of the historical combination mode of the third iteration.
[0212] Since the solution space of the historical combination schemes of the previous historical iteration number includes the first solution space and the second solution space, if the solution space of the historical combination schemes of the subsequent historical iteration number adjacent to the current iteration number is obtained by partitioning from the first solution space of the historical combination schemes of the previous historical iteration number adjacent to the current iteration number, then at the current iteration number, the second solution space of the historical combination schemes of the previous historical iteration number is partitioned. If the solution space of the historical combination schemes of the subsequent historical iteration number adjacent to the current iteration number is obtained by partitioning from the second solution space of the historical combination schemes of the previous historical iteration number, then at the current iteration number, the first solution space of the previous historical iteration number is partitioned.
[0213] For example, Figure 6 As shown, the fourth iteration is the current iteration number, the next historical iteration number adjacent to the current iteration number is the third iteration number, the previous historical iteration number adjacent to the current iteration number is the second iteration number, and the previous iteration number before the previous historical iteration number is the first iteration number.
[0214] If the solution space where the historical combination of the third iteration number is located is the initial sub-solution space M3a, then in the fourth iteration, the second solution space M2' where the historical combination of the second iteration number is located is divided. If the solution space where the historical combination of the third iteration number is located is the initial sub-solution space M3b, then in the fourth iteration, the first solution space M2 where the historical combination of the second iteration number is located is divided.
[0215] When the sub-solution space of the historical combination method of the current iteration number for the previous historical iteration number is used as the solution space where the historical combination method of the current iteration number is located, there is no need to divide the solution space where the historical combination method of the subsequent historical iteration number for the current iteration number is located in the next iteration. The target combination method of the historical combination method for the subsequent historical iteration number obtained in the current iteration number can be directly used as the target combination method for the historical combination method in the next iteration.
[0216] For example, Figure 6As shown, in the third iteration, the initial sub-solution space M3b of the historical combination method of the third iteration for the previous historical iteration number (the first iteration) is used as the solution space where the historical combination method of the third iteration is located. Then, in the fourth iteration, the solution space M2 is divided. However, since the solution space M2 has been divided in the third iteration, the target combination method in the initial sub-solution space M3a can be directly used without dividing the solution space M2 again.
[0217] In this embodiment, the target combination of the current number of iterations can be obtained based on the historical combination of adjacent historical numbers of iterations of the current number of iterations and the solution space where the historical combination of adjacent historical numbers of iterations are located. There is no need to calculate based on the historical combination of all historical numbers of iterations of the current number of iterations and the solution space where each node matching group is located, thereby reducing the amount of calculation.
[0218] S204: Determine the number of operations required to modify the target data structure into the to-be-matched data structure based on the predicted structure edit distance.
[0219] The number of operations required to modify the target data structure to the to-be-matched data structure refers to the number of operations required to modify the target data structure to the to-be-matched data structure. The operations required to modify the target data structure to the to-be-matched data structure can be at least one of deleting edges, adding edges, adding nodes, deleting nodes, and modifying node attributes. One operation count is obtained for each predicted structural edit distance.
[0220] In some embodiments, determining the number of operations required to modify the target data structure to the to-be-matched data structure based on the predicted structural edit distance includes:
[0221] Determine the matching relationship between the target node and the node to be matched based on the predicted structural edit distance;
[0222] According to the matching relationship, the number of operations required to modify the target data structure into the data structure to be matched is determined.
[0223] For example, the target data structure and the data structure to be matched can be as follows Figure 7 As shown, black and white represent different attributes. In the predicted structural edit distance f1, the matching relationship between the target node and the to-be-matched node is: target node n11 matches to-be-matched node n21, target node n12 matches to-be-matched node n22, target node n13 matches to-be-matched node n23, target node n14 matches to-be-matched node n24, and target node n15 matches to-be-matched node n25.
[0224] In some embodiments, determining the number of operations required to modify the target data structure to the to-be-matched data structure based on the predicted structural edit distance includes:
[0225] Determining a first node attribute of a target node based on the predicted structural edit distance, and determining a second node attribute of a node to be matched;
[0226] An operation number required to modify the target data structure into a to-be-matched data structure is determined according to the first node attribute and the second node attribute.
[0227] For example, Figure 7 As shown, target node n12 matches to-be-matched node n22, and the first node attribute of target node n12 is different from the second node attribute of to-be-matched node n22. In this case, the first attribute of the target node is changed to the second node attribute, that is, target node n12 is changed to black. In this case, the number of operations required to modify the target data structure to the to-be-matched data structure is 1. In addition, there is no target node that matches to-be-matched node n26 in the to-be-matched data structure, and the first node attribute is 0. In this case, a target node that matches to-be-matched node n26 in the to-be-matched data structure can be added to the target data structure. In this case, the number of operations required to modify the target data structure to the to-be-matched data structure is 2.
[0228] Alternatively, based on the predicted structural edit distance, the process of determining the number of operations required to modify the target data structure to the to-be-matched data structure may be:
[0229] Determine the first edge attribute of the target node based on the predicted structural edit distance, and determine the second edge attribute of the node to be matched;
[0230] An operation number required to modify the target data structure into the to-be-matched data structure is determined according to the first edge attribute and the second edge attribute.
[0231] For example, Figure 7 As shown, the target node n11 matches the node to be matched n21. The first edge attribute of the target node n11 is that there is one connecting edge, while the second edge attribute of the node to be matched n21 is that there are two connecting edges. It is necessary to add an edge to the target node n11, and the number of operations required to modify the target data structure to the data structure to be matched is 1.
[0232] In order to more quickly and accurately determine the number of operations required to modify the target data structure into the to-be-matched data structure based on the first edge attribute and the second edge attribute, in other embodiments, determining the first node attribute of the target node and determining the second node attribute of the to-be-matched node based on the predicted structure edit distance include:
[0233] Based on the predicted structural edit distance, selecting a first node pair from the target data structure, the first node pair including the target node;
[0234] Filtering out a second node pair that matches the first node pair from the to-be-matched data structure, where the second node pair includes the to-be-matched node;
[0235] A first node property of the first node pair is determined, and a second node property of the second node pair is determined.
[0236] The second node pair that matches the first node pair refers to a node pair consisting of nodes to be matched that match the target node in the first node pair. For example, Figure 7 As shown, the target node n11 matches the to-be-matched node n21, and the target node n12 matches the to-be-matched node n22. The first node pair includes the target node n11 and the target node n12, and the second node pair matching the first node pair includes the to-be-matched node n21 and the to-be-matched node n22.
[0237] When the first edge attribute is the first edge attribute of the first node pair and the second edge attribute is the second edge attribute of the second node pair, determining the number of operations required to modify the target data structure to the to-be-matched data structure according to the first edge attribute and the second edge attribute includes:
[0238] If the first edge attribute indicates that a connected edge exists, and the second edge attribute indicates that a connected edge does not exist, then the connected edge in the first node pair is deleted to obtain the edge operand;
[0239] According to the edge operands, the number of operations required to modify the target data structure into the to-be-matched data structure is determined.
[0240] For example, Figure 7 As shown, the first node pair includes the target node n11 and the target node n12, the second node pair includes the to-be-matched node n21 and the to-be-matched node n22, the first edge attribute of the first node pair is that a connecting edge exists, and the second edge attribute of the second node pair is that there is no connecting edge, then the connecting edge in the first node pair is deleted, and the edge operation number is 1, that is, at this time, the operation number required to modify the target data structure to the to-be-matched data structure is 1.
[0241] Alternatively, determining the number of operations required to modify the target data structure to the to-be-matched data structure according to the first edge attribute and the second edge attribute may also include:
[0242] If the first edge attribute indicates that there is no connected edge, and the second edge attribute indicates that there is a connected edge, then add the connected edge to the first node pair to obtain the edge operand;
[0243] According to the edge operands, the number of operations required to modify the target data structure into the to-be-matched data structure is determined.
[0244] For example, Figure 7 As shown, the first node pair includes target node n15 and target node n16 (additional target nodes, not in Figure 7 As shown in the figure), the second node pair includes the node to be matched n25 and the node to be matched n26. The first edge attribute of the first node pair is that there is no connecting edge, and the second edge attribute of the second node pair is that there is a connecting edge. Then, a connecting edge is added to the first node pair, and the edge operand is 1. That is, at this time, the number of operations required to modify the target data structure to the data structure to be matched is 1.
[0245] It should be understood that if the first edge attribute is that there is no connected edge and the second edge attribute is also that there is no connected edge, then there is no need to modify the target data structure; or, if the first edge attribute is that there is a connected edge and the second edge attribute is also that there is a connected edge, there is no need to modify the target data structure.
[0246] S205 : Determine at least two real structure edit distances between the target data structure and the data structure to be matched according to the operands, where the real structure edit distances represent real similarities between the target data structure and the data structure to be matched.
[0247] The true structure edit distance, also known as the graph edit distance (GED), refers to the number of operations required to modify one data structure into another. The smaller the true structure edit distance, the greater the true similarity between the two data structures. A true structure edit distance is obtained based on a number of operations.
[0248] After obtaining the operands required to modify the target data structure into the data structure to be matched, the terminal uses the operands as the real structure edit distance between the target data structure and the data structure to be matched.
[0249] S206 : Filtering out a to-be-matched data set that matches the target data set from the at least two to-be-matched data sets based on the at least two true structure edit distances.
[0250] There are at least two real structure edit distances between the target data structure and a data structure to be matched. After obtaining the at least two real structure edit distances, the terminal can use the real structure edit distance that meets the real distance condition among the at least two real structure edit distances as the target real structure edit distance between the target data structure and the data structure to be matched, and then use the to-be-matched data set corresponding to the target real structure edit distance that meets the target distance condition as the to-be-matched data set that matches the target data set.
[0251] Alternatively, after obtaining the real structure edit distance of the current iteration, the terminal can compare the real structure edit distance of the current iteration with the real structure edit distance of the previous iteration. If the real structure edit distance of the current iteration better meets the real distance condition than the real structure edit distance of the previous iteration, the real structure edit distance of the current iteration will be used as the target real structure edit distance between the target data structure and the data structure to be matched. If the real structure edit distance of the previous iteration better meets the real distance condition than the real structure edit distance of the current iteration, there is no need to modify the target real structure edit distance between the target data structure and the data structure to be matched until the iteration is completed.
[0252] The real distance condition and the target distance condition can be set according to actual conditions. For example, if both the real distance condition and the target distance condition can be set as the minimum distance, the minimum real structure edit distance of the at least two real structure edit distances is used as the target real structure edit distance between the target data structure and the data structure to be matched, and the to-be-matched data set corresponding to the minimum target real structure edit distance is used as the to-be-matched data set that matches the target data set. This embodiment does not limit this step.
[0253] In this embodiment, obtaining at least two predicted structure edit distances between the target data structure and the data structure to be matched does not simply calculate the minimum predicted structure edit distance between the target data structure and the data structure to be matched, so that at least two real structure edit distances can be obtained based on the at least two predicted structure edit distances, and then the target real structure edit distance between the target data structure and the data structure to be matched is filtered out from the at least two real structure edit distances, thereby improving the accuracy of the target real structure edit distance, thereby improving the accuracy of the data set to be matched that is filtered according to the target real structure edit distance and matches the target data set.
[0254] As can be seen from the above, in an embodiment of the present application, a target data structure corresponding to a target data set and data structures to be matched corresponding to at least two data sets to be matched are obtained, the target data structure includes at least two target nodes, each target node corresponds to data in the target data set, and the data structure to be matched includes at least two nodes to be matched, each node to be matched represents data in the data set to be matched; the target data structure and the data structure to be matched are node-matched to obtain a matching cost between the target node and the node to be matched, and the matching cost represents the similarity between the target node and the node to be matched; based on the matching cost, at least two predicted structure edit distances between the target data structure and the data structure to be matched are determined, and the predicted structure edit distance represents the predicted similarity between the target data structure and the data structure to be matched; based on the predicted structure edit distance, at least two operands required to modify the target data structure to the data structure to be matched are determined; based on the operands, at least two real structure edit distances between the target data structure and the data structure to be matched are determined, and the real structure edit distance represents the real similarity between the target data structure and the data structure to be matched; based on the at least two real structure edit distances, a data set to be matched that matches the target data set is screened out from the at least two data sets to be matched.
[0255] That is, in an embodiment of the present application, since multiple predicted similarities between the target data structure and the data structure to be matched are first determined, multiple operands can be obtained through multiple predicted similarities, that is, multiple real structure edit distances can be obtained through multiple predicted similarities, so that the real structure edit distance that meets the real distance condition can be screened out from the multiple real structure edit distances, so that the real structure edit distance finally obtained is more accurate, thereby making it more accurate to screen out the data set to be matched that matches the target data set from multiple data sets to be matched based on the real structure edit distance.
[0256] The method described in the above embodiment is further described in detail below with examples.
[0257] The data matching methods in the embodiments of this application can be applied to various data search scenarios, such as matching with compounds, matching with social network graphs, or matching with knowledge graphs. The following describes the data matching methods in the embodiments of this application by applying them to compound matching and social network graph matching.
[0258] When the data matching method in the embodiment of the present application is applied to the matching of social network graphs, the first social network graph in the first social system can be used as the target data structure, and the target nodes in the first social network graph represent the users in the first social system. The second social network graph in the second social system can be used as the data structure to be matched, and the nodes to be matched in the second social network graph represent the users in the second social system. Searching for the second social network graph that matches the first social network graph can be understood as searching for a second social network graph that is similar to the first social network graph.
[0259] See also Figure 8 , Figure 8 This is a flow chart of the data matching method provided in an embodiment of the present application when applied to a social network graph. The data matching method flow may include:
[0260] S801. The terminal obtains a first social network graph corresponding to a set of users in a first social system and a second social network graph corresponding to at least two sets of users in a second social system. The first social network graph includes at least two target nodes, each target node corresponding to a user in the first social system. The second social network graph includes at least two to-be-matched nodes, each to-be-matched node representing a user in the second social system.
[0261] S802: The terminal performs node matching on the first social network graph and the second social network graph to obtain a matching cost between the target node and the node to be matched, where the matching cost represents the similarity between the target node and the node to be matched.
[0262] S803: The terminal obtains the number of iterations between the first social network graph and the second social network graph, and determines an iteration constraint corresponding to the number of iterations, where the iteration constraint is to find a combination with the minimum total matching cost between the first social network graph and the second social network graph.
[0263] The total matching cost is the sum of the matching costs between the target node and the node to be matched.
[0264] S804: The terminal obtains the current iteration number in the iteration number, and determines the historical combination mode corresponding to the adjacent historical iteration numbers of the current iteration number.
[0265] S805. The terminal selects a historical node matching group from each historical combination mode, and divides the adjacent solution space of the historical combination modes with adjacent historical iteration times according to the historical node matching group to obtain an initial sub-solution space that does not include the historical node matching group.
[0266] S806: The terminal determines a sub-solution space for each historical combination based on the initial sub-solution space.
[0267] S807: The terminal performs distance iteration on the combination of node matching groups according to the iteration constraint corresponding to the current iteration number and the matching cost of the node matching group in the sub-solution space, and obtains the target combination for each historical combination at the current iteration number.
[0268] S808: The terminal determines the minimum initial predicted structural edit distance for each historical combination according to the matching cost of the node matching group in the target combination of each historical combination according to the current number of iterations.
[0269] In this embodiment, when the current number of iterations is the first iteration, the km (Kuhn-Munkres) algorithm can be used to perform distance iteration on the combination of the node matching group according to the connection weight between the target node and the node to be matched, and obtain the combination with the largest total connection weight, that is, the combination with the largest total connection weight, that is, the combination with the smallest total matching cost, and use the combination with the largest total connection weight as the target combination for each historical combination for the current number of iterations.
[0270] The larger the total connection weight, the smaller the total matching cost, and the smaller the total connection weight, the larger the total matching cost.
[0271] When obtaining the combination with the largest total connection weight, the terminal can determine the initial predicted structural edit distance of each historical combination at the current iteration number according to the total connection weight.
[0272] When the current iteration number is not the first iteration, the distance iteration of the node matching group combination mode may be performed by the km (Kuhn-Munkres) algorithm, or the distance iteration of the node matching group combination mode may be performed by the minimum circle algorithm or the shortest path algorithm.
[0273] S809: The terminal uses the smallest initial predicted structural edit distance among the initial predicted structural edit distances as the predicted structural edit distance between the first social network graph and the second social network graph for the current number of iterations.
[0274] S8010: The terminal determines a matching relationship between the target node and the node to be matched based on the predicted structural edit distance for the current number of iterations.
[0275] S8011. The terminal determines a first node attribute of the target node and a second node attribute of the node to be matched based on the matching relationship, and determines the number of node operations required to modify the first social network graph into the second social network graph based on the first node attribute and the second node attribute.
[0276] S8012. The terminal selects a first node pair from the first social network graph based on the matching relationship, where the first node pair includes the target node, and selects a second node pair that matches the first node pair from the second social network graph, where the second node pair includes the node to be matched.
[0277] S8013: The terminal determines a first node attribute of the first node pair, and determines a second node attribute of the second node pair.
[0278] S8014. If the first edge attribute indicates that a connecting edge exists and the second edge attribute indicates that a connecting edge does not exist, the terminal deletes the connecting edge in the first node pair to obtain an edge operand.
[0279] S8015. If the first edge attribute indicates that there is no connecting edge, and the second edge attribute indicates that there is a connecting edge, the terminal adds a connecting edge to the first node pair to obtain an edge operand.
[0280] If the first edge attribute indicates that a connected edge exists and the second edge attribute indicates that a connected edge exists, or if the first edge attribute indicates that a connected edge does not exist and the second edge attribute indicates that a connected edge does not exist, then the first node pair does not need to be modified.
[0281] That is, in this application, the process of obtaining the edge operation according to the first edge attribute and the second edge attribute can be shown in the following table:
[0282]
[0283] S8016. The terminal determines the number of operations required to modify the first social network graph into the second social network graph based on the number of edge operations and the number of node operations, and uses the number of operations as the true structural edit distance between the first social network graph and the second social network graph for the current number of iterations. The true structural edit distance represents the true similarity between the first social network graph and the second social network graph.
[0284] For example, when the first social network graph and the second social network graph are as follows Figure 7 In the figure, black and white represent different attributes. The matching relationship between the target node and the to-be-matched node is: target node n11 matches to-be-matched node n21, target node n12 matches to-be-matched node n22, target node n13 matches to-be-matched node n23, target node n14 matches to-be-matched node n24, and target node n15 matches to-be-matched node n25.
[0285] Since there is no target node in the first social network graph that matches the node n26 to be matched in the second social network graph, the first node attribute is 0. At this time, a target node n16 that matches the node n26 to be matched in the second social network graph can be added to the first social network graph, such as Figure 9As shown, if the first node attribute of the target node n12 is different from the second node attribute of the node to be matched n22, the first attribute of the target node is changed to the second node attribute, that is, the target node n12 is changed to black, and the number of node operations required to modify the first social network graph to the second social network graph is 2.
[0286] The first node pair includes the target node n11 and the target node n12, and the second node pair includes the to-be-matched node n21 and the to-be-matched node n22. The first edge attribute of the first node pair is that a connecting edge exists, and the second edge attribute of the second node pair is that a connecting edge does not exist. Then, the connecting edge in the first node pair is deleted, such as Figure 9 shown.
[0287] The first node pair includes target node n15 and target node n16, and the second node pair includes to-be-matched node n25 and to-be-matched node n26. The first edge attribute of the first node pair is that there is no connecting edge, and the second edge attribute of the second node pair is that there is a connecting edge. Then, a connecting edge is added to the first node pair, such as Figure 9 shown.
[0288] The first node pair includes the target node n14 and the target node n16, and the second node pair includes the to-be-matched node n24 and the to-be-matched node n26. The first edge attribute of the first node pair is that there is no connecting edge, and the second edge attribute of the second node pair is that there is a connecting edge. Then, a connecting edge is added to the first node pair, such as Figure 9 shown.
[0289] The above operations on the edges of the first social network graph are performed a total of 3 times, so the number of edge operations is 3. The number of edge operations 3 plus the number of node operations 2, the number of operations required to modify the first social network graph into the second social network graph is 5. In other words, the true structural edit distance between the first social network graph and the second social network graph for the current number of iterations is 5.
[0290] S8017: If the real structural edit distance of the current iteration is less than the real structural edit distance of the previous iteration, the terminal updates the target real structural edit distance between the first social network graph and the second social network graph to the real structural edit distance of the current iteration, and returns to execute S804.
[0291] If the true structural edit distance of the current iteration is greater than the true structural edit distance of the previous iteration, there is no need to modify the target true structural edit distance between the first social network graph and the second social network graph and the process returns to S804 .
[0292] The terminal can set the number of iterations, that is, set a specific number of iterations, and stop iterating when the number of iterations meets the number of iterations.
[0293] Alternatively, the terminal may not set a specific number of iterations, and stop iterating when the difference between the true structure edit distance of the current iteration number and the true structure edit distance of the previous iteration is within a preset range.
[0294] S8018. After obtaining the target true structure edit distances between the first social network graph and each second social network graph, the terminal uses the second social network graph corresponding to the smallest target true structure edit distance as the social network graph that matches the first social network graph.
[0295] In this example, not only the true structure edit distance corresponding to the minimum predicted structure edit distance is considered, but also the true structure edit distances corresponding to the first k (when the number of iterations is k) predicted structure edit distances are calculated. Then, the minimum true structure edit distance is screened out from the k true structure edit distances, that is, the optimal combination is screened out from the k target combinations, thereby improving the accuracy of the target true structure edit distance.
[0296] Moreover, the complexity of the present application is also controllable. When both the first social network graph and the second social network graph include n nodes, the complexity of one iteration is O(n 3 ), when k iterations are performed, the total complexity is O(kn 3 ). When the number of iterations is larger, the accuracy of the target true structure edit distance is also higher, and the accuracy of the target true structure edit distance is improved under controllable complexity.
[0297] Furthermore, by partitioning the solution space, the kth smallest predicted structural edit distance is obtained, without enumerating all combinations of node matching groups between the first social network graph and the second social network graph, thus reducing the amount of calculation.
[0298] The specific implementation and corresponding beneficial effects of this embodiment can be specifically referred to the above-mentioned data matching method embodiment, and this embodiment will not be repeated here.
[0299] When the data matching method in the embodiment of the present application is applied to the matching of compounds, the structure of the first compound can be used as the target data structure, and the target node in the structure of the first compound represents the element of the first compound. The structure of the second compound can be used as the data structure to be matched, and the node to be matched in the structure of the second compound represents the element of the second compound. Searching for a second compound that matches the first compound can be understood as searching for a second compound that is similar to the first compound.
[0300] See also Figure 10 , Figure 10 This is a flow chart of the data matching method provided in the embodiment of the present application when applied to compound matching. The data matching method process may include:
[0301] S1001. The terminal obtains the structure of a first compound and the structures of at least two second compounds, where the structure of the first compound includes at least two target nodes, each target node corresponds to an element of the first compound, and the structure of the second compound includes at least two nodes to be matched, each node to be matched represents an element of the second compound.
[0302] S1002: The terminal performs node matching on the structure of the first compound and the structure of the second compound to obtain a matching cost between the target node and the node to be matched, where the matching cost represents the similarity between the target node and the node to be matched.
[0303] S1003. The terminal obtains the number of iterations between the structure of the first compound and the structure of the second compound, and determines an iteration constraint corresponding to the number of iterations. The iteration constraint is to find a combination with the minimum total matching cost between the structure of the first compound and the structure of the second compound.
[0304] The total matching cost is the sum of the matching costs between the target node and the node to be matched.
[0305] S1004: The terminal obtains the current iteration number in the iteration number, and determines the historical combination method corresponding to the adjacent historical iteration numbers of the current iteration number.
[0306] S1005. The terminal selects a historical node matching group from each historical combination mode, and divides the adjacent solution space of the historical combination modes with adjacent historical iteration times according to the historical node matching group to obtain an initial sub-solution space that does not include the historical node matching group.
[0307] S1006: The terminal determines a sub-solution space for each historical combination based on the initial sub-solution space.
[0308] S1007. The terminal performs distance iteration on the combination of node matching groups according to the iteration constraint corresponding to the current iteration number and the matching cost of the node matching group in the sub-solution space, and obtains the target combination for each historical combination at the current iteration number.
[0309] S1008: The terminal determines the minimum initial predicted structural edit distance for each historical combination according to the matching cost of the node matching group in the target combination of each historical combination according to the current number of iterations.
[0310] S1009 . The terminal uses the smallest initial predicted structure edit distance among the initial predicted structure edit distances as the predicted structure edit distance between the structure of the first compound and the structure of the second compound for the current number of iterations.
[0311] S10010: The terminal determines a matching relationship between the target node and the node to be matched based on the predicted structural edit distance for the current number of iterations.
[0312] S10011. The terminal determines a first node attribute of the target node and a second node attribute of the node to be matched based on the matching relationship, and determines the number of node operations required to modify the structure of the first compound to the structure of the second compound based on the first node attribute and the second node attribute.
[0313] S10012. The terminal selects a first node pair from the structure of the first compound based on the matching relationship, the first node pair including the target node, and selects a second node pair matching the first node pair from the structure of the second compound, the second node pair including the node to be matched.
[0314] S10013. The terminal determines a first node attribute of the first node pair, and determines a second node attribute of the second node pair.
[0315] The first node attribute may be the type of the element of the first compound. For example, if the first compound is composed of oxygen and carbon, the first node attribute may be oxygen.
[0316] S10014. If the first edge attribute indicates that a connecting edge exists and the second edge attribute indicates that a connecting edge does not exist, the terminal deletes the connecting edge in the first node pair to obtain an edge operand.
[0317] S10015. If the first edge attribute indicates that there is no connecting edge, and the second edge attribute indicates that there is a connecting edge, the terminal adds a connecting edge to the first node pair to obtain an edge operand.
[0318] If the first edge attribute indicates that a connected edge exists and the second edge attribute indicates that a connected edge exists, or if the first edge attribute indicates that a connected edge does not exist and the second edge attribute indicates that a connected edge does not exist, then the first node pair does not need to be modified.
[0319] S10016. The terminal determines the number of operations required to modify the structure of the first compound into the structure of the second compound based on the edge operands and the node operands, and uses the operands as the true structure edit distance between the structures of the first compound and the second compound for the current number of iterations. The true structure edit distance represents the true similarity between the structures of the first compound and the second compound.
[0320] S10017. If the real structure edit distance of the current iteration is less than the real structure edit distance of the previous iteration, the terminal updates the target real structure edit distance between the structure of the first compound and the structure of the second compound to the real structure edit distance of the current iteration, and returns to execute S1004.
[0321] If the real structure edit distance of the current iteration is greater than the real structure edit distance of the previous iteration, there is no need to modify the target real structure edit distance between the structures of the first compound and the second compound, and the process returns to S1004 .
[0322] The terminal can set the number of iterations, that is, set a specific number of iterations, and stop iterating when the number of iterations meets the number of iterations.
[0323] Alternatively, the terminal may not set a specific number of iterations, and stop iterating when the difference between the true structure edit distance of the current iteration number and the true structure edit distance of the previous iteration is within a preset range.
[0324] S10018. After obtaining the target true structure edit distances between the structure of the first compound and the structures of each second compound, the terminal takes the second compound corresponding to the smallest target true structure edit distance as a compound matching the first compound.
[0325] The specific implementation and corresponding beneficial effects of this embodiment can be specifically referred to the above-mentioned data matching method embodiment, and this embodiment will not be repeated here.
[0326] To facilitate better implementation of the data matching method provided in the embodiment of the present application, the embodiment of the present application also provides a device based on the above data matching method. The meanings of the terms are the same as those in the above data matching method, and the specific implementation details can be referred to the description in the method embodiment.
[0327] For example, Figure 11 As shown, the data matching device may include:
[0328] The structure acquisition module 1101 is used to acquire a target data structure corresponding to the target data set and to-be-matched data structures corresponding to at least two to-be-matched data sets, wherein the target data structure includes at least two target nodes, each target node corresponding to data in the target data set, and the to-be-matched data structure includes at least two to-be-matched nodes, each to-be-matched node representing data in the to-be-matched data set;
[0329] A node matching module 1102 is configured to perform node matching on the target data structure and the to-be-matched data structure to obtain a matching cost between the target node and the to-be-matched node, where the matching cost represents the similarity between the target node and the to-be-matched node.
[0330] A first determining module 1103 is configured to determine at least two predicted structure edit distances between the target data structure and the data structure to be matched based on the matching cost, where the predicted structure edit distance represents a predicted similarity between the target data structure and the data structure to be matched;
[0331] A second determining module 1104 is configured to determine the number of operations required to modify the target data structure into the to-be-matched data structure based on the predicted structure edit distance;
[0332] A third determining module 1105 is configured to determine, based on the operands, at least two real structure edit distances between the target data structure and the data structure to be matched, where the real structure edit distances represent real similarities between the target data structure and the data structure to be matched;
[0333] The set screening module 1106 is configured to screen out a to-be-matched data set that matches the target data set from at least two to-be-matched data sets based on at least two true structure edit distances.
[0334] Optionally, the first determining module 1103 is specifically configured to execute:
[0335] Determine various combinations of node matching groups, where the node matching group includes the target node and the node to be matched;
[0336] According to the matching cost, the predicted structural edit distance of the combination is determined;
[0337] At least two predicted structure edit distances between the target data structure and the data structure to be matched are screened out from the predicted structure edit distances in the combined manner.
[0338] Optionally, the first determining module 1103 is specifically configured to execute:
[0339] Get iteration constraints;
[0340] According to the matching cost and iteration constraints, the target data structure and the data structure to be matched are iterated to obtain at least two predicted structure edit distances.
[0341] Optionally, the first determining module 1103 is specifically configured to execute:
[0342] According to the matching cost and the iteration constraint, the node matching group combination method is iterated to obtain at least two target combination methods, and the node matching group includes the target node and the node to be matched;
[0343] At least two predicted structural edit distances between the target data structure and the to-be-matched data structure are determined according to the matching costs of the node matching groups in the at least two target combination modes.
[0344] Optionally, the first determining module 1103 is specifically configured to execute:
[0345] Get the number of iterations between the target data structure and the data structure to be matched;
[0346] Determine the iteration constraints corresponding to the number of iterations;
[0347] At least two predicted structure edit distances between the target data structure and the to-be-matched data structure are determined according to the number of iterations, the iteration constraint corresponding to the number of iterations, and the matching cost.
[0348] Optionally, the first determining module 1103 is specifically configured to execute:
[0349] Get the current iteration number;
[0350] Determine the historical combination method corresponding to the historical iteration number before the current iteration number;
[0351] According to the historical combination mode, the iteration constraint corresponding to the current iteration number, and the matching cost, the predicted structural editing distance between the target data structure and the data structure to be matched for the current iteration number is determined.
[0352] Optionally, the first determining module 1103 is specifically configured to execute:
[0353] Determine the initial predicted structural edit distance for each historical combination at the current iteration based on the historical combination, the iteration constraints corresponding to the current iteration, and the matching cost;
[0354] From the initial predicted structure edit distance, the predicted structure edit distance between the target data structure and the data structure to be matched for the current number of iterations is filtered out.
[0355] Optionally, the first determining module 1103 is specifically configured to execute:
[0356] Select a historical node matching group from each historical combination;
[0357] According to each historical node matching group, the solution space of each node matching group is divided to obtain a sub-solution space for each historical combination;
[0358] At least two predicted structural edit distances between the target data structure and the data structure to be matched are determined according to the iteration constraint corresponding to the current iteration number and the matching cost of the node matching group in the sub-solution space.
[0359] Optionally, the historical combination mode includes a combination mode corresponding to adjacent historical iteration numbers, and the solution space where each node matching group is located includes an adjacent solution space where the historical combination mode of adjacent historical iteration numbers is located.
[0360] Accordingly, the first determining module 1103 is specifically configured to execute:
[0361] According to each historical node matching group, the adjacent solution space is divided to obtain the initial sub-solution space that does not contain the historical node matching group;
[0362] According to the initial sub-solution space, the sub-solution space for each historical combination is determined.
[0363] Optionally, the second determining module 1104 is specifically configured to execute:
[0364] Determine the matching relationship between the target node and the node to be matched based on the predicted structural edit distance;
[0365] According to the matching relationship, the number of operations required to modify the target data structure into the to-be-matched data structure is determined.
[0366] Optionally, the second determining module 1104 is specifically configured to execute:
[0367] Determining a first node attribute of a target node based on the predicted structural edit distance, and determining a second node attribute of a node to be matched;
[0368] An operation number required to modify the target data structure into a to-be-matched data structure is determined according to the first node attribute and the second node attribute.
[0369] Optionally, the second determining module 1104 is specifically configured to execute:
[0370] Determine the first edge attribute of the target node based on the predicted structural edit distance, and determine the second edge attribute of the node to be matched;
[0371] An operation number required to modify the target data structure into the to-be-matched data structure is determined according to the first edge attribute and the second edge attribute.
[0372] Optionally, the second determining module 1104 is specifically configured to execute:
[0373] Based on the predicted structural edit distance, selecting a first node pair from the target data structure, the first node pair including the target node;
[0374] Filtering out a second node pair that matches the first node pair from the to-be-matched data structure, where the second node pair includes the to-be-matched node;
[0375] A first node property of the first node pair is determined, and a second node property of the second node pair is determined.
[0376] Optionally, the second determining module 1104 is specifically configured to execute:
[0377] If the first edge attribute indicates that a connected edge exists, and the second edge attribute indicates that a connected edge does not exist, then the connected edge in the first node pair is deleted to obtain the edge operand;
[0378] According to the edge operands, the number of operations required to modify the target data structure into the to-be-matched data structure is determined.
[0379] Optionally, the second determining module 1104 is specifically configured to execute:
[0380] If the first edge attribute indicates that there is no connected edge, and the second edge attribute indicates that there is a connected edge, then add the connected edge to the first node pair to obtain the edge operand;
[0381] According to the edge operands, the number of operations required to modify the target data structure into the to-be-matched data structure is determined.
[0382] During specific implementation, the above modules can be implemented as independent entities, or they can be arbitrarily combined and implemented as the same or several entities. The specific implementation methods and corresponding beneficial effects of the above modules can be found in the previous method embodiments and will not be repeated here.
[0383] The embodiment of the present application also provides an electronic device, which may be a server or a terminal, etc. Figure 12 , which shows a schematic diagram of the structure of the electronic device involved in the embodiment of the present application, specifically:
[0384] The electronic device may include one or more processors 1201 of processing cores, one or more computer-readable storage media memories 1202, a power supply 1203, an input unit 1204 and other components. Those skilled in the art will appreciate that Figure 12 The electronic device structure shown in the figure does not constitute a limitation of the electronic device, and may include more or fewer components than shown in the figure, or combine certain components, or arrange components differently.
[0385] Processor 1201 is the control center of the electronic device. It connects all parts of the electronic device using various interfaces and circuits. It executes computer programs and / or modules stored in memory 1202 and accesses data stored in memory 1202 to perform various functions of the electronic device and process data. Optionally, processor 1201 may include one or more processing cores. Preferably, processor 1201 may integrate an application processor and a modem processor. The application processor primarily handles the operating system, user interface, and application programs, while the modem processor primarily handles wireless communications. It is understood that the modem processor may not be integrated into processor 1201.
[0386] The memory 1202 can be used to store computer programs and modules. The processor 1201 executes various functional applications and data processing by running the computer programs and modules stored in the memory 1202. The memory 1202 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, a computer program required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area may store data created according to the use of the electronic device, etc. In addition, the memory 1202 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage device. Accordingly, the memory 1202 may also include a memory controller to provide the processor 1201 with access to the memory 1202.
[0387] The electronic device also includes a power supply 1203 for supplying power to various components. Preferably, the power supply 1203 can be logically connected to the processor 1201 via a power management system, thereby enabling the power management system to manage charging, discharging, and power consumption. The power supply 1203 can also include one or more DC or AC power supplies, a recharging system, a power failure detection circuit, a power converter or inverter, a power status indicator, and other arbitrary components.
[0388] The electronic device may further include an input unit 1204, which may be configured to receive input digital or character information and generate keyboard, mouse, joystick, optical or trackball signal input related to user settings and function control.
[0389] Although not shown, the electronic device may further include a display unit, etc., which will not be described in detail here. Specifically, in this embodiment, the processor 1201 in the electronic device will load the executable files corresponding to one or more computer program processes into the memory 1202 according to the following instructions, and the processor 1201 will run the computer programs stored in the memory 1202 to implement various functions, such as:
[0390] Obtaining a target data structure corresponding to the target data set and to-be-matched data structures corresponding to at least two to-be-matched data sets, wherein the target data structure includes at least two target nodes, each target node corresponds to data in the target data set, and the to-be-matched data structure includes at least two to-be-matched nodes, each to-be-matched node represents data in the to-be-matched data set;
[0391] Perform node matching on the target data structure and the data structure to be matched to obtain the matching cost between the target node and the node to be matched. The matching cost represents the similarity between the target node and the node to be matched.
[0392] determining at least two predicted structure edit distances between the target data structure and the data structure to be matched based on the matching cost, wherein the predicted structure edit distances represent predicted similarities between the target data structure and the data structure to be matched;
[0393] Determining the number of operations required to modify the target data structure to the to-be-matched data structure based on the predicted structure edit distance;
[0394] determining, based on the operands, at least two true structure edit distances between the target data structure and the data structure to be matched, the true structure edit distances representing true similarities between the target data structure and the data structure to be matched;
[0395] A data set to be matched that matches the target data set is screened out from at least two data sets to be matched according to the at least two true structure edit distances.
[0396] The specific implementation methods and corresponding beneficial effects of the above operations can be found in the detailed description of the data matching method above, which will not be repeated here.
[0397] Those skilled in the art will appreciate that all or part of the steps in the various methods of the above embodiments may be accomplished by a computer program, or by controlling related hardware through a computer program. The computer program may be stored in a computer-readable storage medium and loaded and executed by a processor.
[0398] To this end, an embodiment of the present application provides a computer-readable storage medium storing a computer program that can be loaded by a processor to execute the steps of any of the data matching methods provided in the embodiments of the present application. For example, the computer program can execute the following steps:
[0399] Obtaining a target data structure corresponding to the target data set and to-be-matched data structures corresponding to at least two to-be-matched data sets, wherein the target data structure includes at least two target nodes, each target node corresponds to data in the target data set, and the to-be-matched data structure includes at least two to-be-matched nodes, each to-be-matched node represents data in the to-be-matched data set;
[0400] Perform node matching on the target data structure and the data structure to be matched to obtain the matching cost between the target node and the node to be matched. The matching cost represents the similarity between the target node and the node to be matched.
[0401] determining at least two predicted structure edit distances between the target data structure and the data structure to be matched based on the matching cost, wherein the predicted structure edit distances represent predicted similarities between the target data structure and the data structure to be matched;
[0402] Determining the number of operations required to modify the target data structure to the to-be-matched data structure based on the predicted structure edit distance;
[0403] determining, based on the operands, at least two true structure edit distances between the target data structure and the data structure to be matched, the true structure edit distances representing true similarities between the target data structure and the data structure to be matched;
[0404] A to-be-matched data set that matches the target data set is screened out from the at least two to-be-matched data sets according to the at least two true structure edit distances.
[0405] The specific implementation methods and corresponding beneficial effects of the above operations can be found in the previous embodiments and will not be described in detail here.
[0406] The computer-readable storage medium may include a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0407] Since the computer program stored in the computer-readable storage medium can execute the steps in any data matching method provided in the embodiments of the present application, the beneficial effects that can be achieved by any data matching method provided in the embodiments of the present application can be achieved. Please refer to the previous embodiments for details and will not be repeated here.
[0408] According to one aspect of the present application, a computer program product or computer program is provided, the computer program product or computer program including computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the above-described data matching method.
[0409] The above is a detailed introduction to a data matching method, device, equipment, storage medium and program product provided in the embodiments of the present application. Specific examples are used herein to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea; at the same time, for technical personnel in this field, based on the ideas of the present application, 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 application.
Claims
1. A data matching method, characterized in that: include: Obtaining a target data structure corresponding to a target data set and to-be-matched data structures corresponding to at least two to-be-matched data sets, wherein the target data structure includes at least two target nodes, each of which corresponds to data in the target data set, and the to-be-matched data structure includes at least two to-be-matched nodes, each of which represents data in the to-be-matched data set; Perform node matching on the target data structure and the to-be-matched data structure to obtain a matching cost between the target node and the to-be-matched node, wherein the matching cost represents a similarity between the target node and the to-be-matched node; Determining at least two predicted structural edit distances between the target data structure and the data structure to be matched based on the matching cost, including: obtaining an iteration constraint; performing distance iteration on a combination of node matching groups based on the matching cost and the iteration constraint to obtain at least two target combination methods, wherein the node matching group includes the target node and the node to be matched; determining at least two predicted structural edit distances between the target data structure and the data structure to be matched based on the matching costs of the node matching groups in the at least two target combination methods; wherein the predicted structural edit distance represents a predicted similarity between the target data structure and the data structure to be matched; determining, based on the predicted structure edit distance, the number of operations required to modify the target data structure into the to-be-matched data structure; determining, based on the operands, at least two real structure edit distances between the target data structure and the data structure to be matched, the real structure edit distances representing real similarities between the target data structure and the data structure to be matched; According to the at least two true structure edit distances, a to-be-matched data set that matches the target data set is screened out from the at least two to-be-matched data sets.
2. The data matching method according to claim 1, characterized in that: Determining at least two predicted structure edit distances between the target data structure and the to-be-matched data structure according to the matching cost includes: Determine various combinations of node matching groups, where the node matching group includes the target node and the node to be matched; Determining a predicted structural edit distance of the combination according to the matching cost; At least two predicted structure edit distances between the target data structure and the to-be-matched data structure are screened out from the predicted structure edit distances of the combination.
3. The data matching method according to claim 1, characterized in that: Determining at least two predicted structure edit distances between the target data structure and the to-be-matched data structure according to the matching cost includes: Obtaining the number of iterations between the target data structure and the data structure to be matched; Determining an iteration constraint condition corresponding to the number of iterations; At least two predicted structure edit distances between the target data structure and the to-be-matched data structure are determined according to the number of iterations, an iteration constraint corresponding to the number of iterations, and the matching cost.
4. The data matching method according to claim 3, characterized in that: The determining, according to the number of iterations, the iteration constraint corresponding to the number of iterations, and the matching cost, at least two predicted structure edit distances between the target data structure and the to-be-matched data structure includes: Get the current iteration number; Determine a historical combination method corresponding to the historical number of iterations before the current number of iterations; Determine a predicted structural edit distance between the target data structure and the to-be-matched data structure for the current number of iterations according to the historical combination mode, the iteration constraint corresponding to the current number of iterations, and the matching cost.
5. The data matching method according to claim 4, characterized in that: The determining, based on the historical combination mode, the iteration constraint corresponding to the current iteration number, and the matching cost, a predicted structural edit distance between the target data structure and the to-be-matched data structure for the current iteration number, includes: Determining an initial predicted structural edit distance of each of the historical combination modes at the current iteration number according to the historical combination modes, the iteration constraint corresponding to the current iteration number, and the matching cost; The predicted structure edit distance between the target data structure and the to-be-matched data structure for the current number of iterations is filtered out from the initial predicted structure edit distance.
6. The data matching method according to claim 5, characterized in that: The determining, based on the historical combination modes, the iteration constraint corresponding to the current iteration number, and the matching cost, an initial predicted structural edit distance of the current iteration number for each of the historical combination modes includes: Selecting a historical node matching group from each of the historical combination methods; According to each of the historical node matching groups, the solution space where each node matching group is located is divided to obtain a sub-solution space for each of the historical combination modes; According to the iteration constraint corresponding to the current iteration number and the matching cost of the node matching group in the sub-solution space, the initial predicted structural edit distance of the current iteration number for each of the historical combination modes is determined.
7. The data matching method according to claim 6, characterized in that: The historical combination mode includes the combination mode corresponding to adjacent historical iteration times, and the solution space where each node matching group is located includes the adjacent solution space where the historical combination mode of adjacent historical iteration times is located; The solution space where each node matching group is located is divided according to each of the historical node matching groups to obtain a sub-solution space for each of the historical combination modes, including: Dividing the adjacent solution space according to each of the historical node matching groups to obtain an initial sub-solution space that does not include the historical node matching group; According to the initial sub-solution space, a sub-solution space for each of the historical combination modes is determined.
8. The data matching method according to any one of claims 1 to 7, characterized in that: The determining, based on the predicted structure edit distance, the number of operations required to modify the target data structure to the to-be-matched data structure includes: Determining a matching relationship between the target node and the node to be matched based on the predicted structural edit distance; According to the matching relationship, the number of operations required to modify the target data structure into the to-be-matched data structure is determined.
9. The data matching method according to any one of claims 1 to 7, characterized in that: The determining, based on the predicted structure edit distance, the number of operations required to modify the target data structure to the to-be-matched data structure includes: Determining a first node attribute of the target node based on the predicted structural edit distance, and determining a second node attribute of the node to be matched; The number of operations required to modify the target data structure into the to-be-matched data structure is determined according to the first node attribute and the second node attribute.
10. The data matching method according to any one of claims 1 to 7, characterized in that: The determining, based on the predicted structure edit distance, the number of operations required to modify the target data structure to the to-be-matched data structure includes: Determining a first edge attribute of the target node based on the predicted structural edit distance, and determining a second edge attribute of the node to be matched; The number of operations required to modify the target data structure into the to-be-matched data structure is determined according to the first edge attribute and the second edge attribute.
11. The data matching method according to claim 10, characterized in that: The determining the first edge attribute of the target node based on the predicted structural edit distance, and determining the second edge attribute of the to-be-matched node, includes: Based on the predicted structural edit distance, screening out a first node pair from the target data structure, where the first node pair includes the target node; Filtering out a second node pair that matches the first node pair from the to-be-matched data structure, where the second node pair includes the to-be-matched node; A first node attribute of the first node pair is determined, and a second node attribute of the second node pair is determined.
12. The data matching method according to claim 11, characterized in that: The determining, based on the first edge attribute and the second edge attribute, the number of operations required to modify the target data structure to the to-be-matched data structure includes: If the first edge attribute indicates that a connected edge exists, and the second edge attribute indicates that a connected edge does not exist, deleting the connected edge in the first node pair to obtain an edge operand; The number of operations required to modify the target data structure into the to-be-matched data structure is determined according to the edge operands.
13. The data matching method according to claim 11, characterized in that: The determining, based on the first edge attribute and the second edge attribute, the number of operations required to modify the target data structure to the to-be-matched data structure includes: If the first edge attribute indicates that there is no connected edge, and the second edge attribute indicates that there is a connected edge, then adding the connected edge to the first node pair to obtain an edge operand; The number of operations required to modify the target data structure into the to-be-matched data structure is determined according to the edge operands.
14. A data matching device, characterized in that: include: a structure acquisition module, configured to acquire a target data structure corresponding to a target data set and data structures to be matched corresponding to at least two data sets to be matched, wherein the target data structure includes at least two target nodes, each of which corresponds to data in the target data set; and the data structure to be matched includes at least two nodes to be matched, each of which represents data in the data sets to be matched; a node matching module, configured to perform node matching on the target data structure and the to-be-matched data structure to obtain a matching cost between the target node and the to-be-matched node, wherein the matching cost represents a similarity between the target node and the to-be-matched node; A first determination module is configured to determine, based on the matching cost, at least two predicted structural edit distances between the target data structure and the data structure to be matched, comprising: obtaining an iteration constraint; performing distance iteration on a combination of node matching groups based on the matching cost and the iteration constraint to obtain at least two target combination methods, wherein the node matching group includes the target node and the node to be matched; and determining, based on the matching costs of the node matching groups in the at least two target combination methods, at least two predicted structural edit distances between the target data structure and the data structure to be matched; wherein the predicted structural edit distance represents a predicted similarity between the target data structure and the data structure to be matched; A second determining module is configured to determine the number of operations required to modify the target data structure into the to-be-matched data structure based on the predicted structure edit distance; a third determining module, configured to determine, based on the operand, at least two real structure edit distances between the target data structure and the data structure to be matched, the real structure edit distances representing real similarities between the target data structure and the data structure to be matched; A set screening module is used to screen out a to-be-matched data set that matches the target data set from the at least two to-be-matched data sets according to the at least two real structure edit distances.
15. An electronic device, characterized in that: The method comprises a processor and a memory, wherein the memory stores a computer program, and the processor is used to run the computer program in the memory to execute the data matching method according to any one of claims 1 to 13.
16. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, and the computer program is suitable for being loaded by a processor to execute the data matching method according to any one of claims 1 to 13.
17. A computer program product, characterized in that The computer program product stores a computer program, and the computer program is suitable for being loaded by a processor to execute the data matching method according to any one of claims 1 to 13.
Citation Information
Patent Citations
Database-based data matching method and device and computer readable medium
CN114385683A
Heterogeneous gate address matching method and device, computer equipment and storage medium
CN114741621A