File comparison method, device, storage medium and equipment

By converting the file into a dictionary form of a hierarchical structure and comparing keywords and values, the problem of insufficient file comparison in the prior art is solved, and a comprehensive comparison of file content is achieved.

CN112487781BActive Publication Date: 2025-05-27CHENGDU HAIGUANG MICROELECTRONICS TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202011435744.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-12-10
Publication Date
2025-05-27
Estimated Expiration
2040-12-10

AI Technical Summary

Technical Problem

The existing file comparison method can only be compared based on the number of lines, and it is impossible to determine whether the actual content of the file is the same, resulting in insufficient comparison of files with complex structures and some content may be missed.

Method used

Convert the file to be compared to data in a hierarchical dictionary form, and compare it according to the values ​​corresponding to the keywords and/or keywords to obtain a more comprehensive comparison result.

Benefits of technology

A full traversal of the file content is realized to avoid missing important content, thereby obtaining more comprehensive comparison results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112487781B_ABST
    Figure CN112487781B_ABST
Patent Text Reader

Abstract

An embodiment of the present invention discloses a file comparison method, device, storage medium and equipment. Among them, the file comparison method includes: obtaining at least two files to be compared; respectively converting the at least two files into at least two pieces of data represented in the form of a hierarchical dictionary; comparing the at least two pieces of data according to keywords and / or values corresponding to the keywords to obtain a comparison result of the at least two files. This method can provide a more comprehensive file comparison result.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular, to a file comparison method, apparatus, storage medium, and device. Background Art

[0002] Currently, when comparing two files, it is usually to compare according to the number of lines of the two files, list the differences between each line of the two files, and display the extra or missing content in the files. However, this method can only compare based on the number of lines and cannot determine whether the actual content of the files is the same. This leads to the problem that when using this method for file comparison, for files with a more complex structure, some content may be omitted, resulting in an incomplete comparison result. Summary of the Invention

[0003] In view of this, one or more embodiments of the present invention provide a file comparison method, apparatus, storage medium, and device, which can provide a more comprehensive comparison result.

[0004] One or more embodiments of the present invention provide a file comparison method, including: obtaining at least two files to be compared; respectively converting the at least two files into at least two pieces of data represented in the form of a hierarchical dictionary; comparing the at least two pieces of data according to keywords and / or values corresponding to the keywords to obtain a comparison result of the at least two files.

[0005] Optionally, comparing the at least two pieces of data according to keywords and / or values corresponding to the keywords to obtain a comparison result of the at least two files includes: in response to finding different keywords in the at least two pieces of data, obtaining a comparison result that there are the different keywords in the at least two pieces of data; in response to obtaining a first comparison instruction, comparing the values corresponding to the different keywords to obtain a comparison result of the values of the different keywords, where the first comparison instruction specifies the different keywords to be compared.

[0006] Optionally, comparing the at least two pieces of data according to keywords and / or values corresponding to the keywords to obtain a comparison result of the at least two files includes: finding the same keywords included in the at least two pieces of data; in response to finding the same pair of keywords in the at least two pieces of data, comparing the values corresponding to the pair of keywords to obtain a comparison result of the values of the pair of keywords.

[0007] Optionally, comparing the at least two pieces of data according to keywords and / or values corresponding to the keywords to obtain a comparison result of the at least two files includes: finding the same keywords included in the at least two pieces of data; in response to finding multiple same keywords in the at least two pieces of data, obtaining a second comparison instruction that specifies a pair of the same keywords to be compared; comparing the values corresponding to the pair of the same keywords to obtain a comparison result of the values corresponding to the pair of the same keywords.

[0008] Optionally, comparing the at least two pieces of data according to keywords and / or values corresponding to the keywords to obtain a comparison result of the at least two files includes: finding the same keywords included in the at least two pieces of data; in response to finding multiple same keywords in the at least two pieces of data, comparing the keywords with consistent corresponding values among the multiple same keywords; in response to there being no keywords with consistent corresponding values among the multiple same keywords, randomly selecting one keyword from each of the multiple same keywords for comparison; in response to the values corresponding to the multiple same keywords including nested dictionaries and the nested dictionaries containing the same values, comparing the keywords among the multiple same keywords for which the nested dictionaries contain the same values.

[0009] Optionally, the method further includes: after comparing the at least two pieces of data according to keywords and values corresponding to the keywords to obtain a comparison result of the at least two files, presenting the comparison results of the at least two files side by side on a user interface, where at least two of the following keywords are presented in different background colors in the comparison result of each file: keywords that are redundant in this file compared with other files among the at least two files, keywords that are missing, keywords with different corresponding values, and keywords with the same corresponding values; in response to an operation of viewing the next-level result, presenting the values corresponding to the keywords in the comparison result.

[0010] One or more embodiments of the present invention provide a file comparison device, including: an acquisition module configured to acquire at least two files to be compared; a conversion module configured to respectively convert the at least two files into at least two pieces of data represented in a hierarchical dictionary form; a comparison module configured to compare the at least two pieces of data according to keywords and / or values corresponding to the keywords to obtain a comparison result of the at least two files.

[0011] Optionally, the comparison module is specifically configured to: in response to finding different keywords in the at least two pieces of data, obtain a comparison result indicating the existence of the different keywords in the at least two pieces of data; in response to a first comparison instruction obtained, compare the values corresponding to the different keywords to obtain a comparison result of the values of the different keywords, where the first comparison instruction specifies the different keywords to be compared.

[0012] Optionally, the comparison module is specifically configured to: find the same keywords included in the at least two pieces of data; in response to finding the same pair of keywords in the at least two pieces of data, compare the values corresponding to the pair of keywords to obtain a comparison result of the values of the pair of keywords.

[0013] Optionally, the comparison module is specifically configured to: find the same keywords included in the at least two pieces of data; in response to finding multiple same keywords in the at least two pieces of data, obtain a second comparison instruction, where the second comparison instruction specifies a pair of the same keywords to be compared; compare the values corresponding to the pair of the same keywords to obtain a comparison result of the values corresponding to the pair of the same keywords.

[0014] Optionally, the comparison module is specifically configured to: find the same keywords included in the at least two pieces of data; in response to finding multiple same keywords in the at least two pieces of data, compare the keywords with consistent corresponding values among the multiple same keywords; in response to there being no keywords with consistent corresponding values among the multiple same keywords, randomly select one keyword from each of the multiple same keywords for comparison; in response to the corresponding values of the multiple same keywords including nested dictionaries and the nested dictionaries containing the same values, compare the keywords among the multiple same keywords for which the nested dictionaries contain the same values.

[0015] Optionally, the apparatus further includes: a first presentation module, configured to, after comparing the at least two pieces of data according to keywords and / or the values corresponding to the keywords to obtain a comparison result of the at least two files, present the comparison result of the at least two files side by side on a user interface, where in the comparison result of each file, at least two of the following keywords are presented in different background colors: keywords that are redundant in this file compared with other files among the at least two files, keywords that are missing, keywords with different corresponding values, and keywords with the same corresponding values; a second presentation module, configured to, in response to an operation of viewing a next-level result, present the values corresponding to the keywords in the comparison result.

[0016] One or more embodiments of the present invention further provide an electronic device, including a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor executes the program, the above-mentioned any file comparison method is implemented.

[0017] One or more embodiments of the present invention further provide a non-transitory computer-readable storage medium storing computer instructions for causing a computer to execute the above-mentioned any file comparison method.

[0018] In the file comparison method of one or more embodiments of the present invention, at least two files to be compared are represented in the form of a hierarchical dictionary, resulting in at least two pieces of data represented in the form of a hierarchical dictionary. By comparing the keywords and / or the values corresponding to the keywords in the at least two pieces of data, a full traversal of the files to be compared can be achieved, avoiding omission of the content to be compared, and thus a more comprehensive comparison result can be obtained. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings required for use in the description of the embodiments or the prior art. Obviously, the drawings in the following description are only some embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other drawings can be obtained based on these drawings.

[0020] Figure 1 is a flowchart of a file comparison method shown according to one or more embodiments of the present invention;

[0021] Figure 2 is a flowchart of a file comparison method shown according to one or more embodiments of the present invention;

[0022] Figure 3 is a schematic structural diagram of a file comparison device shown according to one or more embodiments of the present invention;

[0023] Figure 4 is a schematic structural diagram of an electronic device shown according to one or more embodiments of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0024] The following will describe the embodiments of the present invention in detail with reference to the drawings.

[0025] It should be clear that the described embodiments are only a part of the embodiments of the present invention, rather than all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts belong to the scope of protection of the present invention.

[0026] Figure 1 is a flowchart of a file comparison method shown according to one or more embodiments of the present invention, as Figure 1 shown, the method includes:

[0027] Step 101: Obtain at least two files to be compared;

[0028] In one or more embodiments of the present invention, the files to be compared may be, for example, files with hierarchical file contents, that is, files with contents that can be nested in a hierarchical structure according to a key value key and its corresponding result value value. For example, liberty files and yaml files.

[0029] Step 102: Convert the at least two files into at least two pieces of data represented in the form of a dictionary with a hierarchical structure;

[0030] Taking the liberty file as an example, for example, the structure of the file can be parsed by the siliconsmart tool and stored in the form of a dictionary of hierarchy (hierarchical structure). For example, {aa: bb, cc: {dd: ee}, ff: {gg: {hh: {ii: {jj: kk}}}}...}. Among them, before the colon is the key, and after the colon is the value. The value can also be a nested dictionary. For example, in cc: {dd: ee}, cc is the key and {dd: ee} is the value. In the value {dd: ee}, dd is the key and ee is the value of dd.

[0031] Step 103: Compare the keywords and / or the values corresponding to the keywords in the at least two pieces of data represented in the form of a dictionary with a hierarchical structure to obtain the comparison result of the at least two files.

[0032] The file comparison method according to one or more embodiments of the present invention represents at least two files to be compared in the form of a dictionary with a hierarchical structure, obtains at least two pieces of data represented in the form of a dictionary with a hierarchical structure, and compares the keywords and / or the values corresponding to the keywords in the at least two pieces of data, which can achieve a full traversal of the files to be compared, avoid missing the content to be compared, and thus obtain a more comprehensive comparison result.

[0033] In one or more embodiments of the present invention, comparing the at least two pieces of data represented in the form of a hierarchical dictionary according to keywords and / or values corresponding to the keywords includes: in response to finding different keywords in the at least two pieces of data, obtaining a comparison result indicating the existence of the different keywords in the at least two pieces of data; in response to a first comparison instruction obtained, comparing the values corresponding to the different keywords to obtain a comparison result of the values corresponding to the different keywords. Wherein, the first comparison instruction specifies the different keywords to be compared. Wherein, finding different keywords in the at least two pieces of data may include, for example, for a certain keyword, it only appears in one of the two files to be compared and does not appear in the other file. Further, when different keywords are found in the at least two pieces of data, an error message may be reported, and the error message may, for example, prompt the different keywords existing in the files being compared. For example: Assume that the two files to be compared are respectively represented as file1 and file2, wherein the structure after storage of file1 is: {aa: bb, cc: dd}, and the structure after storage of file2 is: {ee: bb, cc: dd}, then the error message reported may include: error: aa exists in file1 but not in file2; ee exists in file2 but not in file1. At this time, if the user specifies to compare the values of aa and ee, then the values of aa and ee will be compared. Since the values of aa and ee are the same, the information reported may include: the values of aa and ee are equal, both being bb.

[0034] In one or more embodiments of the present invention, obtaining a comparison result of the at least two files by comparing the at least two pieces of data represented in the form of a hierarchical dictionary according to keywords and / or values corresponding to the keywords may include: finding the same keywords included in the at least two pieces of data; in response to finding the same pair of keywords in the at least two pieces of data, comparing the values corresponding to the pair of keywords to obtain a comparison result of the values corresponding to the same pair of keywords. For example, if exactly one same key is found in the above at least two pieces of data, then continue to compare the value pointed to by the key. If the value pointed to by the key is a nested dictionary, then continue to compare the values in the next layer of the nested dictionary until the values in the last layer are compared. For example, assume that the structure after storage of file1 is: {aa: {bb: {cc: dd}}}, and the structure after storage of file2 is: {aa: {bb: {cc: ee}}}, then the error message reported may include: the values of aa->bb->cc in file1 and file2 are different, being dd and ee respectively.

[0035] In one or more embodiments of the present invention, comparing the at least two pieces of data represented in the form of a hierarchical dictionary according to keywords and / or values corresponding to the keywords may include:

[0036] Finding the same keywords included in the at least two pieces of data;

[0037] In response to finding multiple same keywords in the at least two pieces of data, obtaining a second comparison instruction that specifies a pair of the same keywords to be compared;

[0038] Comparing the values corresponding to the pair of the same keywords to obtain a comparison result of the values corresponding to the pair of the same keywords. Taking the liberty file as an example, if multiple same keys are found in the above at least two pieces of data, it can be applied to the comparison of various timing arcs (timing information) in the liberty. For example, the user can specify which two keys' contents are to be compared together. For example, the above second comparison instruction can be defined by the user.

[0039] Still taking the two files to be compared as file1 and file2 respectively as an example. Among them, the structure of file1 after storage is: {aa->1: bb, aa->2: cc, aa->3: dd}, and the structure of file2 after storage is: {aa->1: cc, aa->2: dd, aa->3: bb}. If the user specifies in the second comparison instruction that aa->1 of file1 is to be compared with aa->3 of file2, the obtained comparison result is that the values of both are the same, both being bb.

[0040] It should be noted that since the dictionary structure does not allow the existence of the same key, the ->1, ->2, and ->3 in the above file1 and file2 are numbers assigned to distinguish the three same keys 'aa' in the same file. The same method is also used hereinafter to represent the same keys in the same file.

[0041] In one or more embodiments of the present invention, comparing the at least two pieces of data represented in the form of a hierarchical dictionary according to keywords and / or values corresponding to the keywords to obtain a comparison result of the at least two files may include:

[0042] Finding the same keywords included in the at least two pieces of data;

[0043] In response to finding multiple same keywords in the at least two pieces of data, comparing the keywords with consistent corresponding values among the multiple same keywords;

[0044] In response to the absence of keywords with consistent corresponding values among the multiple identical keywords, one keyword is randomly selected from each of the multiple identical keywords for comparison;

[0045] In response to the values corresponding to the multiple identical keywords including nested dictionaries and the nested dictionaries containing identical values, the keywords among the multiple identical keywords for which the nested dictionaries contain identical values are compared.

[0046] In one example, when multiple pairs of identical keys are found in the at least two pieces of data, it is possible to determine which of these identical keys have equal values, so as to match two keys with equal values together for comparison. Still taking file1 and file2 in the above example as an example, the structure after storage of file1 is: {aa->1: bb, aa->2: cc, aa->3: dd}, and the structure after storage of file2 is: {aa->1: cc, aa->2: dd, aa->3: bb}. It can be seen that the values of the keyword aa->1 in file1 and the keyword aa->3 in file2 are consistent, the value of aa->2 in file1 is consistent with the value of aa->1 in file2, and the value of aa->3 in file1 is consistent with the value of aa->2 in file2. Therefore, in the example, aa->1 in file1 and aa->3 in file2 can be compared, aa->2 in file1 can be compared with aa->1 in file2, and aa->3 in file1 can be compared with aa->2 in file2.

[0047] In another example, there is no case where the values are the same in the two files. For example, the structure after storage of file1 is: {aa->1: bb, aa->2: cc, aa->3: dd}; the structure after storage of file2 is: {aa->1: ee, aa->2: ff, aa->3: gg}. In this case, if the user specifies a comparison between aa->1 of file1 and aa->3 of file2, an error message will be reported, such as the values are different, which are bb and gg respectively. If the user does not specify, the automatic judgment mechanism will be started. Since no key pairs with equal values are found, two keys can be randomly selected from the above multiple pairs of identical keys for comparison. For example, if aa->1 of file1 and aa->2 of file2 are randomly selected for comparison, an error message will be reported, such as the values of aa->1 of file1 and aa->2 of file2 are different, which are bb and ff respectively.

[0048] In another example, among the values corresponding to the keywords in the two pieces of data corresponding to the two files, there are nested dictionaries, and some of the nested dictionaries contain the same values. For example, the structure stored in file1 is: {aa->1: {bb: cc, dd: ee, ff: {gg: hh}}, aa->2: {bb; xx, dd: yy, ff: {zz; jj}}}, and the structure stored in file2 is: {aa->1: {bb: xx, dd: yy, ff: {zz: ii}}, aa->2: {bb: cc, dd: ee, ff: {gg: kk}}}. If the user specifies to compare aa->1 of file1 with aa->2 of file2, the comparison result will be reported. For example, the values of bb in both are the same, both being cc; the values of dd in both are the same, both being ee. At the same time, error messages will also be reported. For example, the values of ff->gg in the two are different, being hh and kk respectively. Another example is that if the user does not specify, the automatic judgment mechanism can be started, which will find the keyword pairs with the most equal values according to the hierarchical structure, and then compare the keywords in these keyword pairs to obtain the comparison result.

[0049] In one or more embodiments of the present invention, the above file comparison method may further include:

[0050] After comparing the at least two pieces of data represented in the form of a hierarchical dictionary according to the keyword and / or the value corresponding to the keyword to obtain the comparison result of the at least two files, the comparison results of the at least two files are presented side by side on the user interface. Among them, in the comparison result of each file, the following at least two keywords are presented in different background colors: the keywords that are redundant in this file compared with the other files among the at least two files, the missing keywords, the keywords with different corresponding values, and the keywords with the same corresponding values; in response to the operation of viewing the next-level result, the values corresponding to the keywords in the comparison result are presented. After the comparison of two files is completed, the comparison result can be displayed scalably on the GUI (Graphical User Interface). For example, in the way of key->value, the comparison result can be nested and displayed. The user can click the + / - buttons presented on the GUI to expand / collapse the next-level information. That is: convert the liberty or yaml file into a form that can be read through GUI operations, and the two files can be presented side by side for the reader to view and compare. At the same time, the same keys can be scaled together to facilitate checking whether the values corresponding to the keys are the same. In an example, if there are redundant keys, they can be represented in purple; if there are missing keys, they can be represented in green; if the values under this key are different, they can be represented in red; if the values from this key to the final value are the same, they can be represented in khaki.

[0051] Figure 2 is a flowchart of a file comparison method shown according to one or more embodiments of the present invention, as Figure 2 shown, the method includes the following processes:

[0052] Input two files;

[0053] Convert the two files into data identified in the form of a hierarchical dictionary;

[0054] Determine whether the user specifies keys to be compared;

[0055] If the user specifies two different keys to be compared, extract the two different keys specified by the user and compare the values corresponding to the two different keys;

[0056] If the user does not specify keys to be compared, compare the keys in the two files;

[0057] Find the same keys in the two files;

[0058] If there are multiple same keys in the two files;

[0059] Determine whether the user specifies keys to be compared among the multiple same keys;

[0060] If the user specifies keys to be compared among the multiple same keys, select the values of the two keys to be compared according to the relationship specified by the user, otherwise, intelligently select the two keys to be compared and compare the values of the selected two keys;

[0061] During the process of comparing the values corresponding to two keys, if the value is a nested dictionary, it can be compared in the way specified by the user, otherwise, compare each level of value under the two keys level by level until the last level of value. If the last level of value is equal, output the comparison result, otherwise output an error message.

[0062] Figure 3 is a schematic structural diagram of a file comparison device shown according to one or more embodiments of the present invention, as Figure 3 shown, the device 30 includes:

[0063] An acquisition module 31, configured to acquire at least two files to be compared;

[0064] A conversion module 32, configured to convert the at least two files into at least two pieces of data represented in the form of a hierarchical dictionary respectively;

[0065] The comparison module 33 is configured to compare the at least two pieces of data according to keywords and / or the values corresponding to the keywords, and obtain the comparison result of the at least two files.

[0066] In one or more embodiments of the present invention, the comparison module may be specifically configured to: in response to finding different keywords in the at least two pieces of data, obtain a comparison result indicating the existence of the different keywords in the at least two pieces of data; in response to a first comparison instruction obtained, compare the values corresponding to the different keywords to obtain a comparison result of the values of the different keywords, wherein the first comparison instruction specifies the different keywords to be compared.

[0067] In one or more embodiments of the present invention, the comparison module may be specifically configured to: find the same keywords included in the at least two pieces of data; in response to finding the same pair of keywords in the at least two pieces of data, compare the values corresponding to the pair of keywords to obtain a comparison result of the values of the pair of keywords.

[0068] In one or more embodiments of the present invention, the comparison module may be specifically configured to: find the same keywords included in the at least two pieces of data; in response to finding multiple same keywords in the at least two pieces of data, obtain a second comparison instruction, wherein the second comparison instruction specifies a pair of the same keywords to be compared; compare the values corresponding to the pair of the same keywords to obtain a comparison result of the values corresponding to the pair of the same keywords.

[0069] In one or more embodiments of the present invention, the comparison module may be specifically configured to: find the same keywords included in the at least two pieces of data; in response to finding multiple same keywords in the at least two pieces of data, compare the keywords with consistent corresponding values among the multiple same keywords; in response to the non-existence of keywords with consistent corresponding values among the multiple same keywords, randomly select one keyword from each of the multiple same keywords for comparison; in response to the values corresponding to the multiple same keywords including nested dictionaries and the nested dictionaries containing the same values, compare the keywords among the multiple same keywords for which the nested dictionaries contain the same values.

[0070] In one or more embodiments of the present invention, the file comparison device may further include: a first presentation module configured to, after comparing the at least two pieces of data according to keywords and the values corresponding to the keywords to obtain the comparison result of the at least two files, present the comparison results of the at least two files side by side on the user interface, wherein, in the comparison result of each file, at least two of the following keywords are presented with different background colors: keywords that are redundant in this file compared with other files among the at least two files, keywords that are missing, keywords with different corresponding values, and keywords with the same corresponding values; a second presentation module configured to, in response to an operation of viewing the next-level result, present the values corresponding to the keywords in the comparison result.

[0071] One or more embodiments of the present invention further provide an electronic device, including a memory, a processor, and a computer program stored on the memory and executable on the processor, where the processor implements any of the above file comparison methods when executing the program.

[0072] One or more embodiments of the present invention further provide a non-transitory computer-readable storage medium storing computer instructions for causing a computer to execute any of the above file comparison methods.

[0073] Figure 4 FIG. shows a more specific schematic diagram of the hardware structure of the electronic device provided in this embodiment. The device may include: a processor 410, a memory 420, an input / output interface 430, a communication interface 440, and a bus 450. Among them, the processor 410, the memory 420, the input / output interface 430, and the communication interface 440 are communicatively connected to each other inside the device through the bus 450.

[0074] The processor 410 may be implemented in a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits, etc., and is used to execute relevant programs to implement the technical solutions provided in the embodiments of this specification.

[0075] The memory 420 can be implemented in the form of ROM (Read Only Memory), RAM (Random Access Memory), static storage devices, dynamic storage devices, etc. The memory 420 can store the operating system and other application programs. When implementing the technical solutions provided in the embodiments of this specification through software or firmware, the relevant program codes are stored in the memory 420 and called and executed by the processor 410.

[0076] The input / output interface 430 is used to connect to the input / output module to achieve information input and output. The input / output module can be configured as a component in the device (not shown in the figure) or externally connected to the device to provide corresponding functions. Among them, the input devices can include keyboards, mice, touchscreens, microphones, various sensors, etc., and the output devices can include displays, speakers, vibrators, indicator lights, etc.

[0077] The communication interface 440 is used to connect to the communication module (not shown in the figure) to achieve communication and interaction between this device and other devices. Among them, the communication module can achieve communication through wired means (such as USB, network cable, etc.) or through wireless means (such as mobile network, WIFI, Bluetooth, etc.).

[0078] The bus 450 includes a path for transmitting information between various components of the device (such as the processor 410, the memory 420, the input / output interface 430, and the communication interface 440).

[0079] It should be noted that although the above device only shows the processor 410, the memory 420, the input / output interface 430, the communication interface 440, and the bus 450, in the specific implementation process, this device may also include other components necessary for normal operation. In addition, those skilled in the art can understand that the above device may also only include the components necessary to implement the solutions of the embodiments of this specification, and do not necessarily include all the components shown in the figure.

[0080] The computer-readable medium of this embodiment includes both permanent and non-permanent, removable and non-removable media, and information storage can be implemented by any method or technology. The information can be computer-readable instructions, data structures, program modules, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassette tapes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information accessible by a computing device.

[0081] It should be noted that in this article, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the term "comprising", "including" or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, article or device comprising a series of elements not only includes those elements, but also includes other elements not expressly listed, or also includes elements inherent to such process, method, article or device. Without further limitation, an element defined by the statement "comprising a..." does not exclude the existence of additional identical elements in the process, method, article or device comprising the element.

[0082] Each embodiment in this specification is described in a related manner. For the same or similar parts among the embodiments, reference can be made to each other. Each embodiment focuses on the differences from other embodiments.

[0083] In particular, for the device embodiments, since they are basically similar to the method embodiments, the description is relatively simple. For the relevant parts, reference can be made to the partial description of the method embodiments.

[0084] For the convenience of description, the above device is described by dividing it into various units / modules according to functions. Of course, when implementing the present invention, the functions of the various units / modules can be implemented in the same or multiple software and / or hardware.

[0085] Those of ordinary skill in the art can understand that all or part of the processes in the methods of the above embodiments can be completed by instructing relevant hardware through a computer program. The program can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above various methods. Among them, the storage medium can be a magnetic disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM), etc.

[0086] As described above, the above are only specific embodiments of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily thought of by those skilled in the art within the technical scope disclosed by the present invention should be covered within the protection scope of the present invention. Therefore, the protection scope of the present invention should be subject to the protection scope of the claims.

Claims

1. A file comparison method, characterized in that, it includes: obtaining at least two files to be compared; respectively converting the at least two files into at least two pieces of data represented in the form of a hierarchical dictionary; comparing the at least two pieces of data according to keywords and / or values corresponding to the keywords to obtain a comparison result of the at least two files; comparing the at least two pieces of data according to keywords and / or values corresponding to the keywords to obtain a comparison result of the at least two files, including: finding the same keywords included in the at least two pieces of data; in response to finding multiple same keywords in the at least two pieces of data, comparing the keywords with consistent corresponding values among the multiple same keywords; in response to there being no keywords with consistent corresponding values among the multiple same keywords, randomly selecting one keyword from each of the multiple same keywords for comparison; in response to the values corresponding to the multiple same keywords including nested dictionaries and the nested dictionaries containing the same values, comparing the keywords among the multiple same keywords for which the nested dictionaries contain the same values; comparing the at least two pieces of data according to keywords and / or values corresponding to the keywords to obtain a comparison result of the at least two files, further including: in response to finding different keywords in the at least two pieces of data, obtaining a comparison result of the existence of the different keywords in the at least two pieces of data; in response to obtaining a first comparison instruction, comparing the values corresponding to the different keywords to obtain a comparison result of the values of the different keywords, wherein the first comparison instruction specifies the different keywords to be compared.

2. The method according to claim 1, characterized in that, comparing the at least two pieces of data according to keywords and / or values corresponding to the keywords to obtain a comparison result of the at least two files, including: finding the same keywords included in the at least two pieces of data; in response to finding the same pair of keywords in the at least two pieces of data, comparing the values corresponding to the pair of keywords to obtain a comparison result of the values of the pair of keywords.

3. The method according to claim 1, characterized in that, comparing the at least two pieces of data according to keywords and / or values corresponding to the keywords to obtain a comparison result of the at least two files, including: finding the same keywords included in the at least two pieces of data; in response to finding multiple same keywords in the at least two pieces of data, obtaining a second comparison instruction, and the second comparison instruction specifies a pair of same keywords to be compared; comparing the values corresponding to the pair of same keywords to obtain a comparison result of the values corresponding to the pair of same keywords.

4. The method according to any one of claims 1 to 3, characterized in that, the method further includes: After comparing the at least two pieces of data according to keywords and / or the values corresponding to the keywords to obtain the comparison results of the at least two files, present the comparison results of the at least two files side by side on the user interface, where at least two of the following keywords are presented in different background colors in the comparison result of each file: Compared with other files among the at least two files, the redundant keywords, missing keywords, keywords with different corresponding values, and keywords with the same corresponding values in this file; In response to an operation to view the next-level result, present the values corresponding to the keywords in the comparison result.

5. A file comparison device, Characterized in that, Comprising: An acquisition module, configured to acquire at least two files to be compared; A conversion module, configured to convert the at least two files into at least two pieces of data represented in the form of a hierarchical dictionary; A comparison module, configured to compare the at least two pieces of data according to keywords and / or the values corresponding to the keywords to obtain the comparison results of the at least two files; The comparison module is specifically configured to: find the same keywords included in the at least two pieces of data; In response to finding multiple same keywords in the at least two pieces of data, compare the keywords with the same corresponding values among the multiple same keywords; In response to there being no keywords with the same corresponding values among the multiple same keywords, randomly select one keyword from each of the multiple same keywords for comparison; In response to the values corresponding to the multiple same keywords including nested dictionaries and the nested dictionaries containing the same values, compare the keywords among the multiple same keywords for which the nested dictionaries contain the same values; The comparison module is specifically configured to: in response to finding different keywords in the at least two pieces of data, obtain the comparison result that there are the different keywords in the at least two pieces of data; in response to obtaining a first comparison instruction, compare the values corresponding to the different keywords to obtain the comparison result of the values of the different keywords, where the first comparison instruction specifies the different keywords to be compared.

6. The device according to claim 5, Characterized in that, The comparison module is specifically configured to: Find the same keywords included in the at least two pieces of data; In response to finding the same pair of keywords in the at least two pieces of data, compare the values corresponding to the pair of keywords to obtain the comparison result of the values of the pair of keywords.

7. The device according to claim 5, Characterized in that, The comparison module is specifically configured to: Find the same keywords included in the at least two pieces of data; In response to finding multiple same keywords in the at least two pieces of data, obtain a second comparison instruction, where the second comparison instruction specifies a pair of the same keywords to be compared; Compare the values corresponding to the pair of the same keywords to obtain the comparison result of the values corresponding to the pair of the same keywords.

8. The device according to any one of claims 5 to 7, Characterized in that, The device further includes: The first presentation module is configured to, after comparing the at least two pieces of data according to keywords and / or values corresponding to the keywords to obtain the comparison result of the at least two files, present the comparison results of the at least two files side by side on the user interface, wherein at least two of the following keywords are presented in different background colors in the comparison result of each file: Compared with other files among the at least two files, the redundant keywords, missing keywords, keywords with different corresponding values, and keywords with the same corresponding values in this file; The second presentation module is configured to present the values corresponding to the keywords in the comparison result in response to an operation of viewing the next-level result.

9. An electronic device, comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, wherein, when the processor executes the program, it implements the file comparison method according to any one of claims 1 to 4.

10. A non-transitory computer-readable storage medium, wherein, the non-transitory computer-readable storage medium stores computer instructions for causing the computer to execute the file comparison method according to any one of claims 1 to 4.

Citation Information

Patent Citations

  • Method for inputting and comparing multi-format documents

    CN103823838A