Differential processing method and device of mind map file
By converting mind map files into a list of nodes and utilizing node identifiers and content similarity methods, the problem of low accuracy and efficiency in calculating differences in mind map files is solved, achieving more accurate and efficient difference identification.
Patent Information
- Application Number
- CN202111296614.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-03
- Publication Date
- 2025-10-28
- Estimated Expiration
- 2041-11-03
AI Technical Summary
In existing technologies, the accuracy and efficiency of difference calculation for mind map files are low, especially when self-similar nodes exist in XMind documents. The matching method and similarity calculation of XML content difference algorithms result in very low accuracy of text content difference calculation.
By converting mind map files into a list of nodes, and utilizing node identifiers and content similarity, the differences between mind map files are determined, including the addition, deletion, modification, and movement of nodes. A method combining node identifier comparison and similarity calculation is adopted to improve the accuracy and efficiency of difference calculation.
This makes the results of mind map file difference calculation more reasonable and accurate, improves the efficiency of content difference calculation, and can effectively identify the types of node changes.
Smart Images

Figure CN113987276B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present invention relate to the field of network technology, and in particular to a method for processing differences in mind map files, a device for processing differences in mind map files, an electronic device, and a storage medium. Background Technology
[0002] XMind is currently the most popular mind mapping tool. XMind documents, with their tree-like structure, effectively represent the hierarchy and branches of a document, making them widely used in development. However, during the iteration of XMind, developers need to pay attention to the content changes between versions. Visually comparing version content diffs is inefficient and prone to omissions.
[0003] Existing text content-based difference calculation methods are basically based on line-by-line and column-by-column comparisons to determine whether an entire line or column in the document is newly added or deleted. However, algorithms for calculating tree-structured text content differences are not widely used. The XML content difference algorithm is one of the few tree-structured text content difference algorithms that can calculate changes in node content and attributes of XML documents. However, when the XML content difference algorithm is directly used to calculate the content differences of XMind, the matching method and similarity calculation defects of the XML content difference algorithm lead to a very low accuracy in text content difference calculation when self-similar nodes exist in the XMind document. Summary of the Invention
[0004] This invention provides a method for handling differences in mind map files, in order to solve the problems of low accuracy and efficiency in calculating differences in mind map files in the prior art.
[0005] Accordingly, embodiments of the present invention also provide a mind map file difference processing device to ensure the implementation and application of the above method.
[0006] To address the aforementioned problems, this invention discloses a method for handling differences in mind map files, the method comprising:
[0007] Obtain a mind map file; the mind map file includes a first mind map file and a second mind map file, wherein the version of the second mind map file is higher than that of the first mind map file;
[0008] The first mind map file is converted into a first node list, and the second mind map file is converted into a second node list; the first node list includes a first node identifier and a first node content corresponding to the first node, and the second node list includes a second node identifier and a second node content corresponding to the second node;
[0009] The nodes that indicate differences between the mind map files can be determined based on the first node identifier, the second node identifier, the first node content, and the second node content, or based on the similarity between the first node content and the second node content.
[0010] Preferably, the first node content includes first text content, and the second node content includes second text content. The step of determining the nodes that differ between the mind map files based on the first node identifier, the second node identifier, the first node content, and the second node content, or determining the nodes that differ between the mind map files based on the similarity between the first node identifier, the second node identifier, the first node content, and the second node content, includes:
[0011] Count the total number of the first node and the second node, and the same number of nodes with the same first node identifier and the same second node identifier;
[0012] Calculate the ratio of the identical quantity to the difference between the total quantity and the identical quantity;
[0013] When the ratio is greater than or equal to a preset threshold, the nodes that represent the differences between the mind map files are determined based on the first node identifier, the second node identifier, the first text content, and the second text content.
[0014] When the ratio is less than a preset threshold, the nodes that are different between the mind map files are determined based on the similarity between the content of the first node and the content of the second node.
[0015] Preferably, determining the nodes that represent differences between the mind map files based on the first node identifier, the second node identifier, the first text content, and the second text content includes:
[0016] Obtain the same first node and the same second node whose first node identifier is the same as the second node identifier;
[0017] When the parent node identifier of the same first node is different from the parent node identifier of the same second node, the same first node and the same second node are identified as moving nodes.
[0018] When the parent node identifier of the same first node is the same as the parent node identifier of the same second node, and the first text content corresponding to the same first node is different from the second text content corresponding to the same second node, the same first node and the same second node are identified as modified nodes.
[0019] When the parent node identifier of the same first node is the same as the parent node identifier of the same second node, and the first text content corresponding to the same first node is the same as the second text content corresponding to the same second node, the same first node and the same second node are determined as unchanged nodes.
[0020] Preferably, the step of determining the nodes that represent the differences between the mind map files based on the first node identifier, the second node identifier, the first text content, and the second text content further includes:
[0021] By comparing the first node list and the second node list, different node identifiers are obtained;
[0022] When the different node identifiers belong to the first node list, the first node corresponding to the different node identifiers is determined as the node to be deleted;
[0023] When the different node identifiers belong to the second node list, the second node corresponding to the different node identifiers is determined as a newly added node.
[0024] Preferably, the first node list includes the first node path and the first direct child node corresponding to the first node, and the second node list includes the second node path and the second direct child node corresponding to the second node; the step of determining the nodes that differ between the mind map files based on the similarity between the content of the first node and the content of the second node includes:
[0025] The first and second nodes in the first and second node lists that have the same first text content and second text content, and whose first node path and second node path are the same, are taken as a matching set and removed from the first and second node lists. The first and second nodes in the removed first and second node lists are added as retained first nodes to the first retained set and as retained second nodes to the second retained set.
[0026] Calculate the text similarity between the first text content of the first retained first node and the second text content of the second retained second node in the first retained set, the path similarity between the first node path and the second node path, and the direct child node similarity between the first direct child node and the second direct child node to obtain a similarity matrix;
[0027] Based on the similarity matrix, the nodes that indicate differences between the mind map files are determined.
[0028] Preferably, the text similarity is calculated in the following manner:
[0029] Determine the length of the first string of the first text content of the first node to be retained, and the length of the second string of the second text content of the second node to be retained;
[0030] Calculate the sum of the lengths of the first string and the second string;
[0031] Obtain the longest common substring between the first text content and the second text content, and calculate the length and value of the longest common substring.
[0032] Remove the longest common substring from the first text content and the second text content;
[0033] Text similarity is calculated based on the string length and value and the length and value of the longest common substring.
[0034] Preferably, the path similarity is calculated in the following manner:
[0035] Determine the length of the first string of the first node path of the retained first node, and the length of the second string of the second node path of the retained second node;
[0036] Calculate the sum of the lengths of the first string and the second string;
[0037] Obtain the longest common substring between the first node path and the second node path, and calculate the length and value of the longest common substring.
[0038] Remove the longest common substring in the first node path and the second node path;
[0039] Path similarity is calculated based on the string length and value and the length and value of the longest common substring.
[0040] Preferably, the similarity of the direct child nodes is calculated in the following manner:
[0041] Determine the number of identical direct child nodes of the first node to be retained and the second node to be retained;
[0042] Determine the maximum number of direct child nodes of the first node to be retained and the second node to be retained;
[0043] The ratio of the number of identical direct child nodes to the maximum number of direct child nodes is used as the similarity of the direct child nodes.
[0044] Preferably, determining the nodes of difference between the mind map files based on the similarity matrix includes:
[0045] When there is a row or column with all values of 0 in the similarity matrix, the corresponding first node to be retained is determined as a node to be deleted and removed from the first retention set to obtain the third retention set;
[0046] When there is a row or column with all values of 0 in the similarity matrix, the corresponding second node is determined as a newly added node and removed from the second retention set to obtain the fourth retention set.
[0047] Preferably, it also includes:
[0048] Obtain the similarity between the first node retained in the third retention set and the second node retained in the fourth retention set; the similarity includes text similarity, path similarity, and direct child node similarity;
[0049] The KM algorithm is used to calculate the sum of weights with the similarity as the weight, and the target retain first node and target retain second node corresponding to the maximum sum of weights are determined.
[0050] When the similarity between the target retained first node and the target retained second node is less than a preset threshold, the target retained first node is deleted and removed from the third retained set to obtain the fifth retained set, and the target retained second node is added and removed from the fourth retained set to obtain the sixth retained set.
[0051] Add the first reserved node and the second reserved node from the fifth reserved set and the sixth reserved set to the matching set;
[0052] If the parent node of the first node in the fifth retention set and the parent node of the second node in the sixth retention set do not exist in the matching set, the second node is determined to be a moved node.
[0053] If the matching set contains the parent node of the first node to be retained in the fifth retention set and the parent node of the second node to be retained in the sixth retention set, and the first text content of the first node to be retained is different from the second text content of the second node to be retained, then the second node to be retained is determined to be the modified node.
[0054] This invention also discloses a mind map file difference processing device, the device comprising:
[0055] Mind map file acquisition module; acquires mind map files; the mind map files include a first mind map file and a second mind map file, wherein the version of the second mind map file is higher than that of the first mind map file;
[0056] The mind map file conversion module is used to convert the first mind map file into a first node list and to convert the second mind map file into a second node list; the first node list includes a first node identifier and first node content corresponding to the first node, and the second node list includes a second node identifier and second node content corresponding to the second node.
[0057] The difference node determination module is used to determine the difference nodes between the mind map files based on the first node identifier, the second node identifier, the first node content, and the second node content, or to determine the difference nodes between the mind map files based on the similarity between the first node content and the second node content.
[0058] This invention discloses an electronic device, including a processor, a memory, and a computer program stored in the memory and capable of running on the processor. When the computer program is executed by the processor, it implements the steps of the mind map file difference processing method as described above.
[0059] This invention discloses a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps of the mind map file difference processing method described above.
[0060] The embodiments of the present invention have the following advantages:
[0061] In this embodiment of the invention, mind map files are obtained; the mind map files include a first mind map file and a second mind map file, with the second mind map file having a higher version than the first mind map file; the first mind map file is converted into a first node list, and the second mind map file is converted into a second node list; the first node list includes a first node identifier and first node content corresponding to the first node, and the second node list includes a second node identifier and second node content corresponding to the second node; nodes that differ between the mind map files are determined based on the first node identifier, the second node identifier, the first node content, and the second node content, or nodes that differ between the mind map files are determined based on the similarity between the first node content and the second node content. By using a difference processing method based on node identifiers or node content, difference calculation of the mind map tree structure is achieved, making the results of content difference calculation more reasonable and accurate, and improving the efficiency of content difference calculation. Attached Figure Description
[0062] Figure 1 It is a text-based chart that displays the differences between rows and columns.
[0063] Figure 2 This is a flowchart illustrating the steps of an embodiment of a method for handling differences in mind map files according to the present invention.
[0064] Figure 3 This is a flowchart of a method for determining the differences between two mind map files according to the present invention;
[0065] Figure 4 This is a flowchart of the present invention based on node identification and text content difference calculation;
[0066] Figure 5 This is a flowchart of a node content-based difference calculation method according to the present invention;
[0067] Figure 6 This is a structural block diagram of a mind map file difference processing device according to the present invention. Detailed Implementation
[0068] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0069] In existing technologies, text content-based difference calculation methods are basically based on a line-by-line comparison of text, and column-by-column comparison, to determine whether an entire line or column in the document is a newly added or deleted line or column; for example... Figure 1 This is used to calculate Git and SVN content differences in committed code; however, algorithms for calculating tree-structured text content differences are not widely used. The XML content difference algorithm is one of the few tree-structured text content difference algorithms that can calculate changes in the node content and attributes of XML documents. It determines the content difference results by comparing the similarity of nodes and filtering for the maximum matching similarity. Currently, there is no algorithm specifically for calculating XMind content differences, and determining XMind content differences previously required manual identification.
[0070] However, the autonomous identification of XMind content differences has certain omission issues, and it cannot intuitively display the differences. Review fatigue can also lead to inefficiency, especially when the XMind document is large and has many nodes. If the XML content difference algorithm is directly used to calculate XMind content differences, although the document formats have a certain similarity (the XMind document is a compressed file, and the node content is organized through XML), the matching method and similarity calculation defects of XML content differences result in very low accuracy when nodes in the XMind document have similar structures to their descendant nodes. This can lead to significant misleading results. Directly using the XML content difference algorithm to calculate XMind content differences results in many self-similar nodes. When one or several nodes are mismatched, it can easily lead to a chain reaction, resulting in a high error rate in the overall content difference calculation.
[0071] To address the aforementioned problems, this invention provides a method for handling differences in mind map files, thereby resolving the issues of low accuracy and efficiency in calculating differences in mind map files.
[0072] Reference Figure 2 The diagram illustrates a flowchart of an embodiment of a mind map file difference processing method according to the present invention. The embodiment of the present invention may include the following steps:
[0073] Step 201: Obtain mind map files; the mind map files include a first mind map file and a second mind map file, wherein the version of the second mind map file is higher than that of the first mind map file;
[0074] Mind maps are an effective graphical thinking tool for expressing divergent thinking; their tree structure effectively represents the hierarchy and branches of a document. In version iterations, it's often necessary to compare old and new versions to identify differences. In this embodiment of the invention, a first mind map file represents the old version, and a second mind map file represents the new version, with the second mind map file having a higher version number than the first. Specifically, version comparison primarily involves identifying the added, deleted, modified, and moved nodes in both versions of the mind map files.
[0075] Step 202: Convert the first mind map file into a first node list, and convert the second mind map file into a second node list; the first node list includes the first node identifier and the first node content corresponding to the first node, and the second node list includes the second node identifier and the second node content corresponding to the second node;
[0076] The node list can be tree structure data corresponding to the tree structure of the mind map. The node list can include multiple nodes, and each node can have a corresponding node identifier, text content, parent node, child node, etc.
[0077] In practice, the nodes in the canvases of the two mind map files (old and new) that need to have their differences calculated can be converted into node lists. Starting from the root node of the canvas, a reverse post-order traversal is used to traverse the text node trees corresponding to the old and new canvases. The resulting node lists are the node lists of the old and new trees. In addition to node identifiers and text content, each node in the node list contains a text string describing the path from the root node to the current node, a parent node, and a set of direct child nodes. Direct child nodes are the next-level child nodes of a given node, i.e., the child nodes directly connected to that node.
[0078] Step 203: Determine the nodes that differ between the mind map files based on the first node identifier, the second node identifier, the first node content, and the second node content; or, determine the nodes that differ between the mind map files based on the similarity between the first node content and the second node content.
[0079] In this embodiment of the invention, the nodes that differ between the two versions of the mind map can be determined based on the node identifiers and text content of the node lists converted from the old and new mind map files; alternatively, the nodes that differ between the two versions of the mind map can be determined based on the similarity of the text content corresponding to the two mind map files; wherein, the similarity may include text content similarity, node path similarity, and direct child node similarity.
[0080] In the specific implementation, the nodes in the canvas of the two mind map files (old and new) that need to have their differences calculated are converted into a first node list and a second node list, respectively. Then, all node identifiers in the two node lists are traversed. Since node identifiers are unique, a threshold can be preset to determine the ratio of the same node identifiers in the two node lists to the difference between the total number of node identifiers and the number of the same node identifiers. When the ratio is greater than the preset threshold, the method of calculating content differences using node identifiers can be used; otherwise, the method of calculating content differences using node similarity can be used.
[0081] If a method for calculating content differences based on node identifiers is used, it may specifically include the following steps:
[0082] 1. By using two nested loops, the traversal of the second node list is used as the outer loop, and the node identifiers are compared one by one.
[0083] 2. If the node is a node with the same node identifier in the first node list, and the node's parent node identifier is different from the parent node identifier of the corresponding node in the first node list, then the node can be determined to be a node that has been moved.
[0084] 3. When the parent node identifier of a node is the same as the parent node identifier of a node in the corresponding first node list, but the corresponding text content is different, then the node can be determined to be a modified node.
[0085] 4. If the parent node identifier of a node is the same as the parent node identifier of the corresponding node in the first node list, and the corresponding text content is also the same, then it can be determined that the node is an unchanged node.
[0086] If a method for calculating content differences based on node similarity is used, it may specifically include the following steps:
[0087] 1. Remove identical nodes from the first and second node lists. Identical nodes are those whose text content and path to the root node have not changed, meaning they are completely unaffected during version iterations. Add identical nodes to the matching node set.
[0088] 2. Calculate the similarity between each pair of nodes in the two removed node lists. If the similarity does not exceed the similarity threshold, mark the similarity as 0. When the similarity between a node and all the nodes it is compared with does not exceed the similarity threshold, if the node is in the second node list, it is a newly added node; if it is in the first node list, it is a deleted node. At the same time, remove these nodes from both node lists.
[0089] 3. Then, using the similarity of nodes as weights, the maximum weight matching algorithm is used to obtain the globally optimal match. Unmatched nodes are determined as newly added or deleted nodes based on their first or second node list. If the similarity between two matched nodes is 0, then these two nodes are also newly added or deleted nodes and are removed from the optimal matching result. The remaining node pairs are nodes that may have been moved or modified. The remaining matched nodes are added to the set of matched nodes.
[0090] 4. If the matching node set contains a parent node of a node in the first node list and the second node list, then the node can be determined to be a moved node, that is, a node that has been moved in the new version of the mind map file; if the matching node set does not contain a parent node of a node in the first node list and the second node list, and the text content of the nodes in the first node list and the second node list is different, then the node can be determined to be a modified node.
[0091] In this embodiment of the invention, mind map files are obtained; the mind map files include a first mind map file and a second mind map file, with the second mind map file having a higher version than the first mind map file; the first mind map file is converted into a first node list, and the second mind map file is converted into a second node list; the first node list includes a first node identifier and first node content corresponding to the first node, and the second node list includes a second node identifier and second node content corresponding to the second node; nodes that differ between the mind map files are determined based on the first node identifier, the second node identifier, the first node content, and the second node content, or nodes that differ between the mind map files are determined based on the similarity between the first node content and the second node content. By using a difference processing method based on node identifiers or node content, difference calculation of the mind map tree structure is achieved, making the results of content difference calculation more reasonable and accurate, and improving the efficiency of content difference calculation.
[0092] In an exemplary embodiment, the first node content includes first text content, and the second node content includes second text content. Step 203, determining the nodes that differ between the mind map files based on the first node identifier, the second node identifier, the first node content, and the second node content, or determining the nodes that differ between the mind map files based on the similarity between the first node identifier, the second node identifier, the first node content, and the second node content, includes:
[0093] Count the total number of the first node and the second node, and the same number of nodes with the same first node identifier and the same second node identifier;
[0094] Calculate the ratio of the identical quantity to the difference between the total quantity and the identical quantity;
[0095] When the ratio is greater than or equal to a preset threshold, the nodes that represent the differences between the mind map files are determined based on the first node identifier, the second node identifier, the first text content, and the second text content.
[0096] When the ratio is less than a preset threshold, the similarity between the content of the first node and the content of the second node determines the nodes that are different between the mind map files.
[0097] Here, the first node refers to all nodes in the first node list, the second node refers to all nodes in the second node list, the first text content refers to the text content corresponding to all nodes in the first node list, and the second text content refers to the text content corresponding to all nodes in the second node list.
[0098] After obtaining the second and first nodes corresponding to the old and new mind map files, it is necessary to determine whether to use a method based on node identifiers and text content to determine node differences, or a method based on node content. In this embodiment of the invention, a threshold can be preset. If the ratio of identical node identifiers in the first and second nodes exceeds the preset threshold, the method based on node identifiers and text content is used; otherwise, the method based on node content is used. One method for calculating the ratio of identical node identifiers is as follows:
[0099]
[0100] Where R represents the ratio of identical node identifiers, l s The number of nodes with the same identifier, l o and l n The sub-tables represent the number of nodes in the first node and the second node; the threshold can be set as needed. The calculation method for the ratio of identical node identifiers can also be the ratio of the number of identical nodes with the same identifier in both the first and second nodes to the total number of the first and second nodes, or other calculation methods; this invention does not limit this.
[0101] The following combination Figure 3 The above processing methods will be further described in detail, please refer to... Figure 3 The flowchart illustrates a process for determining the differences between two mind map files, which may include the following steps:
[0102] Step 301: Convert the nodes in the canvas of the two mind map files (old and new) that require the difference to be calculated into two tree-like data structures respectively;
[0103] In this example, the old mind map file corresponds to the old tree, and the new mind map file corresponds to the new tree. The old tree and the new tree can correspond to the first node list and the second node list, respectively. The first node list and the second node list have first nodes and second nodes, respectively. Nodes have corresponding identifiers and text content. In this example, the node identifier is represented in the form of id.
[0104] Step 302: Calculate the proportion of nodes with the same node ID in the first node list and the second node list;
[0105] Specifically, you can first calculate the total number of the first and second nodes, and the number of nodes with the same id in the first and second node lists; then calculate the difference between the total number of nodes and the number of nodes with the same id, and then calculate the ratio of the number of nodes with the same id to the difference, which is the proportion of nodes with the same id.
[0106] Step 303: Determine whether the above ratio exceeds the preset threshold; if yes, proceed to step 304; otherwise, proceed to step 305.
[0107] Step 304: Calculate node differences based on node ID;
[0108] Specifically, the nodes that differ between mind map files can be determined based on the first node ID, the second node ID, the first text content, and the second text content;
[0109] Step 305: Calculate node differences based on text content;
[0110] Specifically, the nodes that indicate differences between the mind map files can be determined based on the similarity between the first and second text contents.
[0111] In this exemplary embodiment, by counting the total number of the first node and the second node, and the same number of nodes with the same first node identifier and the same second node identifier, the ratio of the same number to the difference between the total number and the same number is calculated. Through the difference processing method based on node identifier or node content, the difference calculation method of mind map tree structure is made more diverse, and the efficiency of content difference calculation is improved.
[0112] In an exemplary embodiment, determining the nodes representing differences between the mind map files based on the first node identifier, the second node identifier, the first text content, and the second text content includes:
[0113] Obtain the same first node and the same second node whose first node identifier is the same as the second node identifier;
[0114] When the parent node identifier of the same first node is different from the parent node identifier of the same second node, the same first node and the same second node are identified as moving nodes.
[0115] When the parent node identifier of the same first node is the same as the parent node identifier of the same second node, and the first text content corresponding to the same first node is different from the second text content corresponding to the same second node, the same first node and the same second node are identified as modified nodes.
[0116] When the parent node identifier of the same first node is the same as the parent node identifier of the same second node, and the first text content corresponding to the same first node is the same as the second text content corresponding to the same second node, the same first node and the same second node are determined as unchanged nodes.
[0117] After determining the method for calculating differences based on node identifiers and text content, it was found that in a tree structure, the parent-child relationship of nodes represents their structure and location, while the text content is the actual displayed content. Therefore, the differences between nodes can be determined by their parent node identifiers and text content. Specifically, the first node mentioned above represents all nodes in the old version of the mind map file, and the second node represents all nodes in the new version of the mind map file.
[0118] In this exemplary embodiment, the nodes corresponding to the same node identifier in the first and second nodes are first obtained, and then it is determined whether the difference between the node and the old version is that it has not changed, has been modified, or has been moved. Specifically, there are three cases:
[0119] 1. When the parent node identifier in the first node is different from the parent node identifier in the second node, it indicates that the position of the node has changed compared to the old version, and therefore it is identified as a moved node;
[0120] 2. When the parent node identifier in the first node is the same as the parent node identifier in the second node, and the text content corresponding to the first node is different from the text content corresponding to the second node, it means that the position of the node has not changed compared to the old version, but the corresponding text content has changed. Therefore, it is identified as a modified node.
[0121] 3. When the parent node identifier in the first node is the same as the parent node identifier in the second node, and the text content corresponding to the first node is also the same as the text content corresponding to the second node, then the node is an unchanged node.
[0122] In this exemplary embodiment, by obtaining the same first node and the same second node with the same first node identifier and the same second node identifier, and determining the difference type of the node based on the parent node identifier and text content of the same node, the content difference calculation of the mind map tree structure can be realized, and the moved or modified nodes can be calculated, thereby improving the accuracy and efficiency of the content difference calculation.
[0123] In an exemplary embodiment, the step of determining the nodes that represent differences between the mind map files based on the first node identifier, the second node identifier, the first text content, and the second text content further includes:
[0124] By comparing the first node list and the second node list, different node identifiers are obtained;
[0125] When the different node identifiers belong to the first node list, the first node corresponding to the different node identifiers is determined as the node to be deleted;
[0126] When the different node identifiers belong to the second node list, the second node corresponding to the different node identifiers is determined as a newly added node.
[0127] The following combination Figure 4 The process of calculating differences based on node identifiers and text content is further described below, referring to... Figure 4 The flowchart illustrates the difference calculation based on node identifiers and text content, which may include the following steps:
[0128] Step 401: Convert the mind map files to be compared into two trees;
[0129] In the specific implementation, the nodes in the canvas of the two mind map files (old and new) that need to have their differences calculated can be converted into two tree-like data structures. The old mind map file corresponds to the old tree, and the new mind map file corresponds to the new tree. The old tree and the new tree correspond to the first node list and the second node list, respectively. The first node list and the second node list have the first node and the second node, respectively. The node includes the corresponding identifier, text content, and parent node. The node identifier is represented in the form of id.
[0130] Step 402: Compare the node IDs of the two trees pairwise;
[0131] In practice, the nodes in the first node list can be compared sequentially with each node in the second node list. For example, if the first node list contains two nodes, A1 and A2, and the second node list contains three nodes, B1, B2, and B3, then the nodes in the two lists can be compared pairwise. This means comparing A1 with B1, B2, and B3 respectively, and comparing A2 with B1, B2, and B3 respectively.
[0132] Step 403: Determine if the node IDs are the same;
[0133] If the node IDs are the same, proceed to step 404; otherwise, proceed to step 406.
[0134] Step 404: Compare whether the parent node IDs of the nodes are the same;
[0135] When two nodes have the same ID, further compare whether their parent node IDs are the same; where a node's parent node is the node directly above it. If the parent node IDs are the same, proceed to step 405; however, since the parent-child node structure of a tree data structure is relatively fixed, if the parent node IDs of the nodes are different, it means that the parent-child (upper-lower) structure of the node has changed, that is, the position of the node has changed, and it can be determined that the node has been moved.
[0136] Step 405: Compare whether the text content of the nodes is the same;
[0137] After the judgment in step 404, it can be determined that the node has not been moved. If the text content of the node is the same, it can be determined that the node is completely unmodified; otherwise, it can be determined that the node has modified the text content.
[0138] Step 406: Determine whether the node belongs to the new tree;
[0139] After the judgment in step 403, it can be determined that the node IDs are different. That is to say, the node belongs to only one of the old tree or the new tree, and the old tree corresponds to the first node list and the second node list, respectively. By determining which node list it belongs to, it can be determined whether the node is deleted or added. If the node is in the first node list, that is, the node exists in the old tree but not in the new tree, it can be determined that the node is deleted; otherwise, it can be determined that the node is added.
[0140] In this exemplary embodiment, by obtaining the same first node and the same second node with the same first node identifier and the same second node identifier, and determining the difference type of the node based on the parent node identifier and text content of the same node, the content difference calculation of the mind map tree structure can be realized, and nodes that have been moved, modified, added or deleted can be calculated, thereby improving the accuracy and efficiency of content difference calculation.
[0141] In an exemplary embodiment, the first node list includes a first node path and a first direct child node corresponding to the first node, and the second node list includes a second node path and a second direct child node corresponding to the second node; step 203, determining the nodes with differences between the mind map files based on the similarity between the content of the first node and the content of the second node, includes:
[0142] The first and second nodes in the first and second node lists that have the same first text content and second text content, and whose first node path and second node path are the same, are taken as a matching set and removed from the first and second node lists. The first and second nodes in the removed first and second node lists are added as retained first nodes to the first retained set and as retained second nodes to the second retained set.
[0143] Calculate the text similarity between the first text content of the first retained first node and the second text content of the second retained second node in the first retained set, the path similarity between the first node path and the second node path, and the direct child node similarity between the first direct child node and the second direct child node to obtain a similarity matrix;
[0144] Based on the similarity matrix, the nodes that indicate differences between the mind map files are determined.
[0145] In the node content similarity calculation method, the set of nodes to be calculated needs to be determined first. Then, the first and second node lists are traversed, and each pair of the first and second nodes is compared. Nodes whose content and path remain unchanged are added to the matching set, and these unchanged nodes are removed from both the first and second node lists. The first and second nodes of the removed first and second node lists are then added to the first and second retention sets, respectively. The first and second retention sets are the sets of nodes with differences that need to be calculated, denoted as S. n and S o .
[0146] Calculate the text similarity, path similarity, and direct child node similarity of the first text content of the first node and the second text content of the second node in the first retention set for each pair of nodes. The path similarity and direct child node similarity directly reflect the structural similarity of the nodes. Therefore, the similarity between two nodes is actually a weighted sum of the three dimensions of similarity: text similarity, path similarity, and direct child node similarity. One way to calculate the similarity is as follows:
[0147]
[0148] Where ij represents S n and S o The label of the middle node, Represents text similarity, direct child node similarity, and path similarity, w t ,w c ,w p This represents the weight assigned to the corresponding similarity; two calculation methods are listed above; when both nodes have direct child nodes, the calculation method in the first row is used, and when one of the nodes does not have a direct child node, the calculation method in the second row is used.
[0149] When calculating pairwise similarity between nodes, a corresponding similarity matrix is generated. Suppose there are two node sets A and B. Set A has 3 nodes, A1, A2, and A3, and set B has 4 nodes, B1, B2, B3, and B4. Calculating pairwise similarity between nodes in sets A and B results in a 3×4 matrix, with dimensions equal to the product of the number of nodes in set A and the number of nodes in set B, as shown below:
[0150] A1B1, A1B2, A1B3, A1B4
[0151] A2B1, A2B2, A3B3, A4B4
[0152] A3B1, A3B2, A3B3, A3B4
[0153] The step of determining the nodes of difference between the mind map files based on the similarity matrix includes:
[0154] When there is a row or column with all values of 0 in the similarity matrix, the corresponding first node to be retained is determined as a node to be deleted and removed from the first retention set to obtain the third retention set;
[0155] When there is a row or column with all values of 0 in the similarity matrix, the corresponding second node is determined as a newly added node and removed from the second retention set to obtain the fourth retention set.
[0156] In this matrix, each element represents the similarity between two nodes in sets A and B. Each row or column in the matrix corresponds to the similarity between a node and all nodes in another set. For example, the first row of the matrix is calculated pairwise between node A1 in set A and all nodes in set B, and the first column is calculated pairwise between node B1 in set B and all nodes in set A.
[0157] Therefore, when the similarity of a row or column in the matrix is 0, it means that the node corresponding to that row or column is dissimilar to all nodes in the other set. Since the first node to be retained corresponds to the old version of the mind map file, and the second node to be retained corresponds to the new version of the mind map file, when all similarities of nodes in the first node to be retained are 0 in the matrix, it means that the node has no similarity to any node in the second node to be retained, i.e., the node does not exist in the new version of the mind map, and thus the node is determined to be deleted. Similarly, when the similarity of nodes in the second node to be retained is 0, the node is determined to be a newly added node.
[0158] In this embodiment of the invention, first nodes and second nodes in the first node list and second node list whose first and second text contents are the same, and whose first and second node paths are the same, are treated as a matching set and removed from the first and second node lists. The removed first nodes and second nodes from the first and second node lists are then added as retained first nodes to a first retained set and as retained second nodes to a second retained set. The text similarity, path similarity, and direct child node similarity of the retained first nodes and retained second nodes in the first retained set are calculated pairwise. A similarity matrix is obtained, and the difference nodes in the mind map file are determined based on the similarity matrix. This allows for difference calculation based on the content similarity of mind map nodes, making the calculation methods more diverse, the results more accurate, reducing computational load, and improving the efficiency of difference calculation.
[0159] In an exemplary embodiment, the text similarity is calculated as follows:
[0160] Determine the length of the first string of the first text content of the first node to be retained, and the length of the second string of the second text content of the second node to be retained;
[0161] Calculate the sum of the lengths of the first string and the second string;
[0162] Obtain the longest common substring between the first text content and the second text content, and calculate the length and value of the longest common substring.
[0163] Remove the longest common substring from the first text content and the second text content;
[0164] Text similarity is calculated based on the string length and value and the length and value of the longest common substring.
[0165] The longest common substring is the substring with the longest character length that is present in both strings. The specific method for calculating text similarity is as follows:
[0166]
[0167] Here, s1 and s2 are two text contents whose similarity needs to be calculated, and m is the sum of the lengths of the longest common substrings found in each iteration. That is, by repeatedly calculating the longest common substring, deleting the found longest common substring, and continuing the search until none remain, the sum of the lengths of all longest common substrings is m. len(·) is a function used to calculate the length of a string. For example, consider two strings to be compared: "This is a string to be compared" and "This is another string." They go through three processes of finding the longest common substring: the first time, "string" is found, deleted from the original text, and the search continues; the second time, "This is" is found; the third time, "A" is found; in the fourth search, since there are no longer any longest common substrings (or the longest common substring is empty), m is the sum of the lengths of these three substrings, i.e., m = 7; the final text similarity is 0.7.
[0168] Similarly, the path similarity is calculated as follows:
[0169] Determine the length of the first string of the first node path of the retained first node, and the length of the second string of the second node path of the retained second node;
[0170] Calculate the sum of the lengths of the first string and the second string;
[0171] Obtain the longest common substring between the first node path and the second node path, and calculate the length and value of the longest common substring.
[0172] Remove the longest common substring in the first node path and the second node path;
[0173] Path similarity is calculated based on the string length and value and the length and value of the longest common substring.
[0174] The calculation of path similarity is the same as the calculation of text similarity. A specific character, such as ' / ', can be added as a separator at each level of the path. In the specific implementation, assuming path A is "node1 / node2 / node3" and path B is "node1 / node4 / node3", similar to the method of calculating text content similarity, the similarity between path A and B can be calculated to be 0.8.
[0175] In this embodiment of the invention, the similarity is calculated by summing the lengths of the first and second strings; obtaining the longest common substring between the first and second text content; and calculating the sum of the lengths of the longest common substrings. This allows for the calculation of the similarity between the node content and node paths of a mind map, improving the accuracy and efficiency of content difference calculation.
[0176] In an exemplary embodiment, the direct child node similarity is calculated as follows:
[0177] Determine the number of identical direct child nodes of the first node to be retained and the second node to be retained;
[0178] Determine the maximum number of direct child nodes of the first node to be retained and the second node to be retained;
[0179] The ratio of the number of identical direct child nodes to the maximum number of direct child nodes is used as the similarity of the direct child nodes.
[0180] The similarity of direct child nodes is calculated based on the proportion of matching nodes to the total number of child nodes. The calculation method for child node similarity is as follows:
[0181]
[0182] Where m is the number of matching nodes among the direct children of the two nodes, and nc i and nc j The value of m represents the number of direct child nodes; max() is a function that gets the maximum of the two numbers. It should be noted that the value of m can only be found by directly searching the above set of matching nodes, because when the similarity is calculated, all of its direct child nodes may not have been matched yet. Therefore, the similarity of the other part of the child nodes needs to be calculated pairwise.
[0183] In the specific implementation, assuming there are nodes A and B, node A has 3 direct child nodes, node B has 4 direct child nodes, and the number of matching direct child nodes in nodes A and B is 2, then through the above method, it can be seen that the similarity between the direct child nodes of nodes A and B is 2 divided by 4, which is 0.5.
[0184] In this exemplary embodiment, by calculating the similarity of the direct child nodes of the nodes in the mind map file, a reference dimension can be added when calculating content differences. The similarity of direct child nodes can reflect the similarity of node structures and improve the accuracy of content difference calculation.
[0185] In one exemplary embodiment, it further includes:
[0186] Obtain the similarity between the first node retained in the third retention set and the second node retained in the fourth retention set; the similarity includes text similarity, path similarity, and direct child node similarity;
[0187] The KM algorithm is used to calculate the sum of weights with the similarity as the weight, and the target retain first node and target retain second node corresponding to the maximum sum of weights are determined.
[0188] When the similarity between the target retained first node and the target retained second node is less than a preset threshold, the target retained first node is deleted and removed from the third retained set to obtain the fifth retained set, and the target retained second node is added and removed from the fourth retained set to obtain the sixth retained set.
[0189] Add the first reserved node and the second reserved node from the fifth reserved set and the sixth reserved set to the matching set;
[0190] If the parent node of the first node in the fifth retention set and the parent node of the second node in the sixth retention set do not exist in the matching set, the second node is determined to be a moved node.
[0191] If the matching set contains the parent node of the first node to be retained in the fifth retention set and the parent node of the second node to be retained in the sixth retention set, and the first text content of the first node to be retained is different from the second text content of the second node to be retained, then the second node to be retained is determined to be the modified node.
[0192] The KM algorithm is a classic matching algorithm used to find the global optimum. Optimal matching means maximizing the sum of the weights of all matching results. The sum of weights refers to the sum of the weights corresponding to the matching results. In this embodiment of the invention, the similarity of nodes is used as the weights of the KM algorithm. For example, applying the KM algorithm to the similarity matrix composed of the similarity of the first node retained in the third retention set and the second node retained in the fourth retention set will yield all matching results for the first and second nodes retained. The KM algorithm guarantees that the sum of the similarities corresponding to these matching results is the largest among all possible matching results, that is, obtaining the result with the largest sum of weights among all matching results, and thus determining the target first node and target second node retained corresponding to the result with the largest sum of weights.
[0193] When calculating the pairwise similarity of nodes, a corresponding similarity matrix is generated. After obtaining the similarity matrix, each element value in the matrix is compared with a similarity threshold F (the threshold is generally set as F = w).t +w p The comparison can be performed using a pre-set similarity threshold, w. t and w p These represent the weights for text similarity and path similarity, respectively. In actual calculations, it is very rare for two nodes to have a similarity of 0. Therefore, for ease of calculation, when the similarity does not exceed the threshold, the element value at the corresponding position is directly set to 0.
[0194] The following combination Figure 5 A detailed explanation of the node-based content difference calculation process is provided, please refer to [link / reference]. Figure 5 The flowchart illustrates a node content-based difference calculation method provided by an embodiment of the present invention, which may specifically include the following steps:
[0195] Step 501: Convert the mind map files to be compared into two trees;
[0196] This step is similar to the step described above for converting mind map files into a tree data structure, and will not be repeated here.
[0197] Step 502: Produce a list of nodes for subsequent traversal of the tree;
[0198] In practice, the corresponding node list can be generated by traversing the tree converted from the mind map file. Of course, other traversal methods can also be used for tree traversal, and this invention does not limit this. Similarly, the old mind map file corresponds to the old tree, and the new mind map file corresponds to the new tree; wherein, the old tree and the new tree correspond to the first node list and the second node list, respectively; the first node list and the second node list each have a first node and a second node, respectively.
[0199] Step 503: Compare the nodes of the two trees pairwise;
[0200] The process of comparing nodes in two trees can involve comparing the text content and paths of nodes in the old and new trees. First, it's necessary to determine the set of nodes whose differences need to be calculated, thus eliminating interference from unchanged nodes. Two nested loops can be used to determine whether a node has changed before and after the mind map iteration; only unchanged nodes need to be filtered out. Two nodes considered unchanged between the two versions are defined as follows: the node's text content remains unchanged, and the path from the root node to the current node is exactly the same. The root node is the highest-level node that a given node can trace back to.
[0201] Step 504: Determine if there are any node pairs whose text content and path are exactly the same;
[0202] In practice, nodes with identical text content and paths can be considered as a node pair, which is generally two nodes.
[0203] Step 505: Add the node pair to the set of matching node pairs and remove it from the node list;
[0204] Since nodes with identical text content and paths are considered matching nodes, and these nodes have remained completely unaffected during version iterations, these node pairs are added to the set S of matching node pairs. M From the matching set, remove these nodes from the first node list and the second node list corresponding to the old tree and the new tree, respectively; the filtered second node list and first node list (i.e., the old and new node lists) are the sets of nodes for which the node differences need to be calculated, denoted as S. n (Fourth Reserve Set) and S o (Third Reserved Set);
[0205] Step 506: Calculate the similarity matrix between any two nodes in the node list;
[0206] This step is similar to the method described above for calculating the similarity matrix, and will not be repeated here.
[0207] Step 507: Set the similarity of elements in the similarity matrix that do not exceed the similarity threshold to 0;
[0208] The filtered two node sets S n and S o Calculate the text similarity between pairs of texts. If the similarity does not exceed the similarity threshold, set the similarity to 0 directly to facilitate subsequent calculations.
[0209] Step 508: Determine if there are any cases in the similarity matrix where all rows or all columns are 0;
[0210] Since the similarity matrix is calculated pairwise between two node sets, each row or column corresponds to the similarity between a node and all nodes in the other node set. Therefore, in the similarity matrix, if an entire row or column has a value of zero, it means that the node corresponding to that row or column has no similar nodes in the other node set. If there is a case where the similarity of all rows or columns is 0, proceed to step 509; otherwise, proceed to step 511.
[0211] Step 509: Find the node corresponding to the row or column, and delete the row or column from the similarity matrix;
[0212] Step 510: Determine whether the node is a node in the new tree;
[0213] After finding the corresponding node, match that node with the previously selected node set S. n and S o Perform a judgment. If this node is S n If a node is found in the set of nodes, then that node is a newly added node and is added to the set of newly added nodes S.a In the middle, if this node is S o The node in the set of nodes to be deleted is added to the set of deleted nodes S. d In the middle; at the same time, remove these nodes from S n and S o Remove from the similarity matrix; remove the corresponding row or column from the similarity matrix; at this point, S n S is the sixth reserved set. o For the fifth reserved set;
[0214] Step 511: Calculate the optimal match using the similarity matrix to obtain the set of optimal matching node pairs;
[0215] In practical implementation, the KM algorithm (maximum weight matching algorithm) can be used on the similarity matrix, using similarity as weights to calculate S. n and S o The optimal matching result of the middle node is obtained as S. n and S o The set S of optimal matching node pairs of the middle node km ;
[0216] Step 512: Determine whether the similarity between the matched nodes is 0;
[0217] Because of the characteristics of the maximum weight matching algorithm, it always aims to match as many nodes as possible. This may result in nodes with a similarity of 0 being matched. Therefore, based on the obtained optimal match, it is necessary to verify whether the node similarity is 0. If it is 0, proceed to step 513; otherwise, proceed to step 514.
[0218] Step 513: Remove the node pairs from the set of optimal matching node pairs S km Remove from the list, and determine the two nodes in each node pair;
[0219] In removing node pairs from the set of optimal matching node pairs S km After removal from the middle, proceed to step 510;
[0220] Step 514; Add the node to the set of matching node pairs;
[0221] At this point, the set of optimal matching node pairs S km Only the nodes that have been modified or moved remain in the S list. km Node pairs in S are copied to S M middle;
[0222] Step 515: Determine whether the parent node of the node pair is in the set of matching node pairs;
[0223] When S n and S oThe parent node of each node pair in the set S is in the matching node pair set. M When the node pair is identified as a node whose text content has been modified, it is added to the set S of modified node pairs. c Otherwise, it can be determined that the node pair has been moved and added to the set S of moved node pairs. m In the middle. The final set of node pairs S is obtained. a ,S d ,S c ,S m This is the result of the difference calculation based on the node content.
[0224] In this exemplary embodiment, by calculating the similarity of nodes and using the KM algorithm to further filter nodes, unaffected nodes are filtered out, narrowing the scope of content difference calculation, eliminating and reducing misjudgments, and enabling the calculation of modified, moved, added and deleted nodes. The content difference calculation results are more accurate and more efficient.
[0225] It should be noted that, for the sake of simplicity, the method embodiments are all described as a series of actions. However, those skilled in the art should understand that the embodiments of the present invention are not limited to the described order of actions, because according to the embodiments of the present invention, some steps can be performed in other orders or simultaneously. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are preferred embodiments, and the actions involved are not necessarily essential to the embodiments of the present invention.
[0226] Reference Figure 6 The diagram shows a structural block diagram of an embodiment of a mind map file difference processing device according to the present invention. Specifically, the embodiment of the present invention may include the following modules:
[0227] Mind map file acquisition module 601; acquires mind map files; the mind map files include a first mind map file and a second mind map file, wherein the version of the second mind map file is higher than that of the first mind map file;
[0228] The mind map file conversion module 602 is used to convert the first mind map file into a first node list and to convert the second mind map file into a second node list; the first node list includes a first node identifier and a first node content corresponding to the first node, and the second node list includes a second node identifier and a second node content corresponding to the second node.
[0229] The difference node determination module 603 is used to determine the difference nodes between the mind map files based on the first node identifier, the second node identifier, the first node content, and the second node content, or to determine the difference nodes between the mind map files based on the similarity between the first node content and the second node content.
[0230] In an exemplary embodiment, the difference node determination module 603 is configured to: count the total number of the first node and the second node, and the same number of nodes with the same first node identifier and the same second node identifier; calculate the ratio of the same number to the difference between the total number and the same number; when the ratio is greater than or equal to a preset threshold, determine the difference nodes between the mind map files based on the first node identifier, the second node identifier, the first text content, and the second text content; when the ratio is less than the preset threshold, determine the difference nodes between the mind map files based on the similarity between the first node content and the second node content.
[0231] In an exemplary embodiment, the difference node determination module 603 is configured to acquire identical first nodes and identical second nodes whose first node identifier and second node identifier are the same; when the parent node identifier of the identical first node is different from the parent node identifier of the identical second node, the identical first node and the identical second node are determined as moved nodes; when the parent node identifier of the identical first node is the same as the parent node identifier of the identical second node, and the first text content corresponding to the identical first node is different from the second text content corresponding to the identical second node, the identical first node and the identical second node are determined as modified nodes; when the parent node identifier of the identical first node is the same as the parent node identifier of the identical second node, and the first text content corresponding to the identical first node is the same as the second text content corresponding to the identical second node, the identical first node and the identical second node are determined as unchanged nodes.
[0232] In an exemplary embodiment, the difference node determination module 603 is used to compare the first node list and the second node list to obtain different node identifiers; when the different node identifier belongs to the first node list, the first node corresponding to the different node identifier is determined as a deleted node; when the different node identifier belongs to the second node list, the second node corresponding to the different node identifier is determined as a newly added node.
[0233] In an exemplary embodiment, the first node list includes a first node path and a first direct child node corresponding to a first node, and the second node list includes a second node path and a second direct child node corresponding to a second node. The difference node determination module 603 is used to take the first nodes and the second nodes in the first node list and the second node list where the first text content is the same as the second text content and the first node path is the same as the second node path as a matching set, and remove them from the first node list and the second node list. The first nodes and the second nodes in the removed first node list and the second node list are added as retained first nodes to a first retained set and as retained second nodes to a second retained set. The text similarity between the first text content of the retained first node and the second text content of the retained second node in the first retained set, the path similarity between the first node path and the second node path, and the direct child node similarity between the first direct child node and the second direct child node in the first retained set are calculated pairwise to obtain a similarity matrix. Based on the similarity matrix, the difference nodes between the mind map files are determined.
[0234] In an exemplary embodiment, the difference node determination module 603 is configured to: determine the first string length of the first text content of the retained first node and the second string length of the second text content of the retained second node; calculate the string length sum of the first string length and the second string length; obtain the longest common substring in the first text content and the second text content, and calculate the longest common substring length sum of the longest common substring; remove the longest common substring in the first text content and the second text content; and calculate the text similarity based on the string length sum and the longest common substring length sum.
[0235] In an exemplary embodiment, the difference node determination module 603 is configured to: determine the first string length of the first node path for retaining the first node and the second string length of the second node path for retaining the second node; calculate the sum of the string lengths of the first and second strings; obtain the longest common substring in the first and second node paths and calculate the sum of the lengths of the longest common substrings; remove the longest common substring in the first and second node paths; and calculate the path similarity based on the sum of the string lengths and the sum of the lengths of the longest common substrings.
[0236] In an exemplary embodiment, the difference node determination module 603 is configured to determine the number of identical direct child nodes of the retained first node and the retained second node; determine the maximum number of direct child nodes of the retained first node and the retained second node; and use the ratio of the number of identical direct child nodes to the maximum number of direct child nodes as the similarity of the direct child nodes.
[0237] In an exemplary embodiment, the difference node determination module 603 is configured to determine the corresponding first retention node as a node to be deleted when there is a row or column with all values of 0 in the similarity matrix, and remove it from the first retention set to obtain a third retention set; and to determine the corresponding second retention node as a newly added node when there is a row or column with all values of 0 in the similarity matrix, and remove it from the second retention set to obtain a fourth retention set.
[0238] In an exemplary embodiment, the difference node determination module 603 is configured to obtain the similarity between the first retained node in the third retention set and the second retained node in the fourth retention set; the similarity includes text similarity, path similarity, and direct child node similarity; the KM algorithm is used to calculate a weight sum with the similarity as weights to determine the target first retained node and the target second retained node corresponding to the maximum weight sum; when the similarity between the target first retained node and the target second retained node is less than a preset threshold, the target first retained node is deleted and removed from the third retention set to obtain a fifth retention set, and the target second retained node is added as a new node and removed from the fourth retention set. The sixth retention set is obtained by removing nodes from the fifth and sixth retention sets; the first and second nodes of the retention set are added to the matching set; if the parent node of the first node of the retention set in the fifth retention set and the parent node of the second node of the retention set in the sixth retention set do not exist in the matching set, the second node of the retention set is determined to be a moved node; if the parent node of the first node of the retention set in the fifth retention set and the parent node of the second node of the retention set in the sixth retention set exist in the matching set, and the first text content of the first node of the retention set is different from the second text content of the second node of the retention set, the second node of the retention set is determined to be a modified node.
[0239] As the device embodiment is basically similar to the method embodiment, the description is relatively simple, and relevant parts can be found in the description of the method embodiment.
[0240] This invention discloses an electronic device, including a processor, a memory, and a computer program stored in the memory and capable of running on the processor. When the computer program is executed by the processor, it implements the steps described in the above embodiment of the mind map file difference processing method.
[0241] This invention discloses a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps described in the above embodiment of the mind map file difference processing method.
[0242] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. The same or similar parts between the various embodiments can be referred to each other.
[0243] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, apparatus, or computer program products. Therefore, embodiments of the present invention can take the form of entirely hardware embodiments, entirely software embodiments, or embodiments combining software and hardware aspects. Furthermore, embodiments of the present invention can take the form of computer program products implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0244] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, terminal devices (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing terminal device to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing terminal device, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0245] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing terminal device to operate in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.
[0246] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal equipment, causing a series of operational steps to be performed on the computer or other programmable terminal equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable terminal equipment for implementing the process. Figure 1 a process or multiple processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0247] Although preferred embodiments of the present invention have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of the embodiments of the present invention.
[0248] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or terminal device that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or terminal device. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or terminal device that includes said element.
[0249] The foregoing has provided a detailed description of a method for processing differences in mind map files, a device for processing differences in mind map files, an electronic device, and a storage medium provided by the present invention. Specific examples have been used to illustrate the principles and implementation methods of the present invention. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of the present invention. At the same time, for those skilled in the art, there will be changes in specific implementation methods and application scope based on the ideas of the present invention. Therefore, the content of this specification should not be construed as a limitation of the present invention.
Claims
1. A method for handling differences in mind map files, characterized in that, The method includes: Obtain a mind map file; the mind map file includes a first mind map file and a second mind map file, wherein the version of the second mind map file is higher than that of the first mind map file; The first mind map file is converted into a first node list, and the second mind map file is converted into a second node list; the first node list includes a first node identifier and a first node content corresponding to the first node, the second node list includes a second node identifier and a second node content corresponding to the second node, the first node content includes first text content, and the second node content includes second text content; Count the total number of the first node and the second node, and the same number of nodes with the same first node identifier and the same second node identifier; Calculate the difference between the total quantity and the same quantity, and calculate the ratio of the same quantity to the difference; When the ratio is greater than or equal to a preset threshold, the nodes that represent the differences between the mind map files are determined based on the first node identifier, the second node identifier, the first text content, and the second text content. When the ratio is less than a preset threshold, the nodes that are different between the mind map files are determined based on the similarity between the content of the first node and the content of the second node.
2. The method according to claim 1, characterized in that, The step of determining the nodes that represent the differences between the mind map files based on the first node identifier, the second node identifier, the first text content, and the second text content includes: Obtain the same first node and the same second node whose first node identifier is the same as the second node identifier; When the parent node identifier of the same first node is different from the parent node identifier of the same second node, the same first node and the same second node are identified as moving nodes. When the parent node identifier of the same first node is the same as the parent node identifier of the same second node, and the first text content corresponding to the same first node is different from the second text content corresponding to the same second node, the same first node and the same second node are identified as modified nodes. When the parent node identifier of the same first node is the same as the parent node identifier of the same second node, and the first text content corresponding to the same first node is the same as the second text content corresponding to the same second node, the same first node and the same second node are determined as unchanged nodes.
3. The method according to claim 2, characterized in that, The step of determining the nodes that represent the differences between the mind map files based on the first node identifier, the second node identifier, the first text content, and the second text content further includes: By comparing the first node list and the second node list, different node identifiers are obtained; When the different node identifiers belong to the first node list, the first node corresponding to the different node identifiers is determined as the node to be deleted; When the different node identifiers belong to the second node list, the second node corresponding to the different node identifiers is determined as a newly added node.
4. The method according to claim 1, characterized in that, The first node list includes the first node path and the first direct child node corresponding to the first node; the second node list includes the second node path and the second direct child node corresponding to the second node. The node for determining the differences between the mind map files based on the similarity between the content of the first node and the content of the second node includes: The first and second nodes in the first and second node lists that have the same first text content and second text content, and whose first node path and second node path are the same, are taken as a matching set and removed from the first and second node lists. The first and second nodes in the removed first and second node lists are added as retained first nodes to the first retained set and as retained second nodes to the second retained set. Calculate the text similarity between the first text content of the first retained first node and the second text content of the second retained second node in the first retained set, the path similarity between the first node path and the second node path, and the direct child node similarity between the first direct child node and the second direct child node to obtain a similarity matrix; Based on the similarity matrix, the nodes that indicate differences between the mind map files are determined.
5. The method according to claim 4, characterized in that, The text similarity is calculated in the following way: Determine the length of the first string of the first text content of the first node to be retained, and the length of the second string of the second text content of the second node to be retained; Calculate the sum of the lengths of the first string and the second string; Obtain the longest common substring between the first text content and the second text content, and calculate the length and value of the longest common substring. Remove the longest common substring from the first text content and the second text content; Text similarity is calculated based on the string length and value and the length and value of the longest common substring.
6. The method according to claim 4, characterized in that, The path similarity is calculated in the following way: Determine the length of the first string of the first node path of the retained first node, and the length of the second string of the second node path of the retained second node; Calculate the sum of the lengths of the first string and the second string; Obtain the longest common substring between the first node path and the second node path, and calculate the length and value of the longest common substring. Remove the longest common substring in the first node path and the second node path; Path similarity is calculated based on the string length and value and the length and value of the longest common substring.
7. The method according to claim 4, characterized in that, The similarity of direct child nodes is calculated in the following way: Determine the number of identical direct child nodes of the first node to be retained and the second node to be retained; Determine the maximum number of direct child nodes of the first node to be retained and the second node to be retained; The ratio of the number of identical direct child nodes to the maximum number of direct child nodes is used as the similarity of the direct child nodes.
8. The method according to claim 4, characterized in that, The step of determining the nodes of difference between the mind map files based on the similarity matrix includes: When there is a row or column with all values of 0 in the similarity matrix, the corresponding first node to be retained is determined as a node to be deleted and removed from the first retention set to obtain the third retention set; When there is a row or column with all values of 0 in the similarity matrix, the corresponding second node is determined as a newly added node and removed from the second retention set to obtain the fourth retention set.
9. The method according to claim 8, characterized in that, Also includes: Obtain the similarity between the first node retained in the third retention set and the second node retained in the fourth retention set; the similarity includes text similarity, path similarity, and direct child node similarity; The KM algorithm is used to calculate the sum of weights with the similarity as the weight, and the target retain first node and target retain second node corresponding to the maximum sum of weights are determined. When the similarity between the target retained first node and the target retained second node is less than a preset threshold, the target retained first node is deleted and removed from the third retained set to obtain the fifth retained set, and the target retained second node is added and removed from the fourth retained set to obtain the sixth retained set. Add the first reserved node and the second reserved node from the fifth reserved set and the sixth reserved set to the matching set; If the parent node of the first node in the fifth retention set and the parent node of the second node in the sixth retention set do not exist in the matching set, the second node is determined to be a moved node. If the matching set contains the parent node of the first node to be retained in the fifth retention set and the parent node of the second node to be retained in the sixth retention set, and the first text content of the first node to be retained is different from the second text content of the second node to be retained, then the second node to be retained is determined to be the modified node.
10. A device for processing differences in mind map files, characterized in that, The device includes: Mind map file acquisition module; acquires mind map files; the mind map files include a first mind map file and a second mind map file, wherein the version of the second mind map file is higher than that of the first mind map file; The mind map file conversion module is used to convert the first mind map file into a first node list and to convert the second mind map file into a second node list; the first node list includes a first node identifier and a first node content corresponding to the first node, the second node list includes a second node identifier and a second node content corresponding to the second node, the first node content includes first text content, and the second node content includes second text content. The difference node determination module is used to count the total number of the first node and the second node, and the number of nodes with the same first node identifier and the same second node identifier; calculate the difference between the total number and the number of nodes with the same identifier, and calculate the ratio of the number of nodes with the same identifier to the difference; when the ratio is greater than or equal to a preset threshold, determine the difference nodes between the mind map files based on the first node identifier, the second node identifier, the first text content, and the second text content; when the ratio is less than the preset threshold, determine the difference nodes between the mind map files based on the similarity between the content of the first node and the content of the second node.
11. An electronic device, characterized in that, The method includes a processor, a memory, and a computer program stored in the memory and capable of running on the processor, wherein the computer program, when executed by the processor, implements the steps of the mind map file difference processing method as described in any one of claims 1 to 9.
12. A computer-readable storage medium, characterized in that, A computer program is stored on the computer-readable storage medium, which, when executed by a processor, implements the steps of the mind map file difference processing method as described in any one of claims 1 to 9.
Citation Information
Patent Citations
Difference visualization processing method and device for behavior tree
CN110008304A
Method and device for displaying different version information of product, computer equipment and medium
CN112632249A