CN116050351A - Structure comparison method, device and equipment of logic expression and storage medium - Google Patents

Structure comparison method, device and equipment of logic expression and storage medium Download PDF

Info

Publication number
CN116050351A
CN116050351A CN202211711444.7A CN202211711444A CN116050351A CN 116050351 A CN116050351 A CN 116050351A CN 202211711444 A CN202211711444 A CN 202211711444A CN 116050351 A CN116050351 A CN 116050351A
Authority
CN
China
Prior art keywords
tree
logic
expression
logic expression
way
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202211711444.7A
Other languages
Chinese (zh)
Inventor
董儒汲
郭焕阳
彭锃
丁波
刘超
纪传俊
纪达麒
陈运文
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Daguan Intelligent Shenzhen Co ltd
Original Assignee
Daguan Intelligent Shenzhen Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Daguan Intelligent Shenzhen Co ltd filed Critical Daguan Intelligent Shenzhen Co ltd
Priority to CN202211711444.7A priority Critical patent/CN116050351A/en
Publication of CN116050351A publication Critical patent/CN116050351A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/12Use of codes for handling textual entities
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/12Use of codes for handling textual entities
    • G06F40/151Transformation

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Health & Medical Sciences (AREA)
  • Artificial Intelligence (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Computational Linguistics (AREA)
  • General Health & Medical Sciences (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Document Processing Apparatus (AREA)

Abstract

The invention discloses a structure comparison method, device and equipment of logic expressions and a storage medium. The method comprises the following steps: respectively analyzing the first logic expression and the second logic expression to generate a basic element group respectively matched with the first logic expression and the second logic expression; if the basic elements included in each basic element group are the same, generating a simplified multi-way tree respectively matched with the first logic expression and the second logic expression; generating node codes of tree nodes in each simplified multi-tree according to the hierarchical layout relation of each simplified multi-tree and the total number of tree nodes; according to the logic relation between different tree nodes in each simplified multi-way tree and the node codes of each tree node, generating the logic value of each simplified multi-way tree, and according to each logic value, generating the comparison result of the first logic expression and the second logic expression. By adopting the technical scheme, the complex logic expression can be quickly compared instead of the traditional manual comparison method.

Description

Structure comparison method, device and equipment of logic expression and storage medium
Technical Field
The present invention relates to the field of computer data processing technologies, and in particular, to a method, an apparatus, a device, and a storage medium for comparing structures of logic expressions.
Background
The meaningful expression obtained by splicing the relational expression or the logical quantity by using the logical operator is the logical expression.
The traditional logic expression comparison method can only acquire character differences between two logic expressions, and cannot accurately acquire comparison results for scenes with different characters and identical logic structures. If the logic structures of the logic expressions are to be compared, a manual comparison mode is needed, but for the logic expressions with complex logic structures, the manual comparison is time-consuming and the accuracy of the comparison result cannot be ensured.
Disclosure of Invention
The invention provides a structure comparison method, device and equipment of logic expressions and a storage medium, which can replace the traditional manual comparison method to carry out quick comparison on complex logic expressions.
According to an aspect of the present invention, there is provided a structure comparison method of logic expressions, including:
respectively analyzing the first logic expression and the second logic expression to generate a basic element group respectively matched with the first logic expression and the second logic expression;
If the basic elements included in each basic element group are the same, generating a simplified multi-way tree respectively matched with the first logic expression and the second logic expression;
generating node codes of tree nodes in each simplified multi-tree according to the hierarchical layout relation of each simplified multi-tree and the total number of tree nodes;
according to the logic relation between different tree nodes in each simplified multi-way tree and the node codes of each tree node, generating the logic value of each simplified multi-way tree, and according to each logic value, generating the comparison result of the first logic expression and the second logic expression.
According to another aspect of the present invention, there is provided a structure alignment apparatus of a logic expression, comprising:
the basic element group generation module is used for respectively analyzing the first logic expression and the second logic expression to generate basic element groups respectively matched with the first logic expression and the second logic expression;
a simplified multi-way tree generating module for generating a simplified multi-way tree respectively matched with the first logic expression and the second logic expression if the basic elements included in each basic element group are the same;
the node code generating module is used for generating node codes of all tree nodes in all the simplified multi-tree according to the hierarchical layout relation of all the simplified multi-tree and the total number of the tree nodes;
The comparison result generation module is used for generating logic values of each simplified multi-way tree according to the logic relation among different tree nodes in each simplified multi-way tree and the node codes of each tree node, and generating comparison results of the first logic expression and the second logic expression according to each logic value.
According to another aspect of the present invention, there is provided an electronic apparatus including:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein,
the memory stores a computer program executable by the at least one processor to enable the at least one processor to perform a structural alignment method of a logic expression as described in any of the embodiments of the present invention.
According to another aspect of the present invention, there is provided a computer readable storage medium storing computer instructions for causing a processor to implement a structural alignment method of a logic expression according to any of the embodiments of the present invention when executed.
According to the technical scheme, the basic element group of the logic expression is obtained, the simplified multi-way tree and node codes of all tree nodes in the simplified multi-way tree are generated for the logic expression with the same basic element group, so that the logic value of the simplified multi-way tree is generated, the logic value of the simplified multi-way tree is compared, the comparison result of the logic expression is obtained, the complex logic expression can be compared quickly, the accuracy of the comparison result is high, the manual comparison can be reduced, and the labor cost and the time cost are reduced.
It should be understood that the description in this section is not intended to identify key or critical features of the embodiments of the invention or to delineate the scope of the invention. Other features of the present invention will become apparent from the description that follows.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for the description of the embodiments will be briefly described below, and it is apparent that the drawings in the following description are only some embodiments of the present invention, and other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a flow chart of a method for structure alignment of a logic expression according to a first embodiment of the present invention;
FIG. 2 is a flow chart of a method of structure alignment of another logic expression provided in accordance with a second embodiment of the present invention;
FIG. 3 is a schematic diagram of a structure alignment device of a logic expression according to a third embodiment of the present invention;
fig. 4 is a schematic structural diagram of an electronic device implementing a structural comparison method of a logic expression of an embodiment of the present invention.
Detailed Description
In order that those skilled in the art will better understand the present invention, a technical solution in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in which it is apparent that the described embodiments are only some embodiments of the present invention, not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the present invention without making any inventive effort, shall fall within the scope of the present invention.
It should be noted that the terms "first," "second," and the like in the description and the claims of the present invention and the above figures are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used may be interchanged where appropriate such that the embodiments of the invention described herein may be implemented in sequences other than those illustrated or otherwise described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
The invention is applicable to any type of logic expression, and in order to better explain the technical scheme of the invention, an investment supervision expression is selected for illustration in the embodiment of the invention.
Example 1
Fig. 1 is a flowchart of a structure comparison method of a logic expression provided in a first embodiment of the present invention, where the method may be implemented by a structure comparison device of a logic expression, and the structure comparison device of a logic expression may be implemented in hardware and/or software, and may be generally configured in a computer or a processor with a data processing function. As shown in fig. 1, the method includes:
s110, respectively analyzing the first logic expression and the second logic expression to generate a basic element group respectively matched with the first logic expression and the second logic expression.
The meaningful expression obtained by splicing the relational expression or the logical quantity by using the logical operator is a logical expression, and the logical operator can comprise logical AND, logical OR, logical NOT and other operators, and the relational expression and the logical quantity are other elements except the logical operator in the logical expression.
In one specific example, when the investment supervision expression is "[ securities category in { stock certificate } ] and [ market code in { Shanghai securities exchange, shenzhen securities exchange, beijing securities exchange } ]", and is a logical operator, [ securities category in { stock certificate } ], and [ market code in { Shanghai securities exchange, shenzhen securities exchange, beijing securities exchange } ], are two different logical quantities.
Wherein the first logic expression and the second logic expression are two expressions for comparison, and the "first" and the "second" are only used for distinguishing the two logic expressions and do not limit the sequence thereof. In the example of the investment supervision expression used in the embodiment, the first logic expression may refer to a logic expression manually spelled after the business personnel interprets the investment supervision rule text, the second logic expression may refer to a logic expression automatically generated by using a template library, and the template library is a template library obtained by the business personnel according to the previous experience summary, and the template library can provide a comparison verification function when writing a new expression. Errors may exist in either the manually spelled logic expression or the logic expression generated by the template library, so that when two logic expressions are different, different parts can be quickly obtained for targeted inspection by service personnel, and the accuracy of the logic expression is improved, and meanwhile, the generation efficiency of the logic expression is also improved.
The basic element group is an element set disassembled according to a logic expression, and in the previous example, [ market code in { Shanghai securities exchange, shenzhen securities exchange } ] can be disassembled into three elements, including: market code in Shanghai securities exchange, market code in Shenzhen securities exchange so and market code in Beijing securities exchange.
S120, if the basic elements included in each basic element group are the same, generating a simplified multi-way tree which is matched with the first logic expression and the second logic expression respectively.
In a specific example, when the first logic expression is [ securities category in { holding certificate } ] and ([ market code in { Shanghai securities exchange, shenzhen securities exchange, beijing securities exchange } ] or [ securities category in { holding certificate } ]), the basic element group that can be parsed by the first logic expression includes the following basic elements:
a. securities category in stock certificate
b. Market code in Shanghai securities exchange
c. Market code in Shenzhen securities exchange
d. Market code in Beijing securities exchange
When the second logic expression is [ securities category in { deposit certificate } ] and [ market code in { Shanghai securities exchange, shenzhen securities exchange } ], the basic element group which can be resolved by the second logic expression comprises the following basic elements:
a. Securities category in stock certificate
b. Market code in Shanghai securities exchange
c. Market code in Shenzhen securities exchange
d. Market code in Beijing securities exchange
It can be seen that, although the first logic expression is different from the second logic expression, all the basic elements in the two parsed basic element groups are the same, but the logic structures of the two logic expressions cannot be determined to be the same at this time, and it can be understood that although the basic element groups from which the two logic expressions are split are the same, the meanings expressed by the two logic expressions may be different. According to the invention, the simplified multi-way tree is generated according to the logic expression, and the comparison result between the two logic expressions is further obtained through the analysis of the simplified multi-way tree.
Optionally, a binary tree matched with the two logic expressions can be generated according to the first logic expression and the second logic expression, the binary tree is converted into a multi-way tree through a preset conversion rule, and the multi-way tree is simplified, so that a simplified multi-way tree matched with the two logic expressions is finally obtained.
In the previous example, when the second logical expression is [ securities category in { stock certificate } ] and [ market code in { Shanghai securities exchange, shenzhen securities exchange } ], it simplifies the multi-way tree as follows:
Figure BDA0004026319850000071
It is easy to see that in the reduced multi-way tree of the second logical expression, the element securities category in stock certificates are missing, one possible reason is that the multi-way tree of the first logical expression has the same element as the element logic, and the elements in the two logical expression multi-way trees are eliminated simultaneously by the reduction process, so that the reduced multi-way tree is finally obtained as described above.
S130, generating node codes of tree nodes in each simplified multi-tree according to the hierarchical layout relation of each simplified multi-tree and the total number of tree nodes.
It will be appreciated that in practice of the present invention, a reduced multi-way tree of a logical expression may generally have a plurality of tree nodes, and that the present invention encodes each tree node in the reduced multi-way tree such that the logical value of the reduced multi-way tree can be further calculated by encoding the respective tree node.
Alternatively, the coding of the tree nodes may be determined based on the total number of tree nodes in the reduced multi-tree, e.g., for a reduced multi-tree having three tree nodes, the coding of the three tree nodes may be: 1110100, 1101010 and 1011001. The code is a continuous number, and the grouping is used to explain the method of constructing the code. In particular, for a simplified multi-way tree of three tree nodes, the encoding of each tree node may be divided into
Figure BDA0004026319850000072
and />
Figure BDA0004026319850000073
Three collections, for tree nodes encoded as 1110100, it +.>
Figure BDA0004026319850000074
1 @>
Figure BDA0004026319850000075
110 @, @>
Figure BDA0004026319850000076
100, it can be seen that three encoded +.>
Figure BDA0004026319850000077
All the same, fixed to 1, three encoded +.>
Figure BDA0004026319850000078
And->
Figure BDA0004026319850000079
All different.
S140, generating logic values of each simplified multi-way tree according to the logic relation among different tree nodes in each simplified multi-way tree and the node codes of each tree node, and generating a comparison result of the first logic expression and the second logic expression according to each logic value.
It will be appreciated that when each tree node is encoded, the reduced multi-way tree may be equivalent to a tree formed by an encoding and a logical operator, where the encoding is calculated according to the operation logic of the logical operator, and finally the logical value of the reduced multi-way tree may be obtained.
In a specific example, in the previous example, if three tree nodes with codes 1110100, 1101010 and 1011001 are tree nodes under the same and logic, the logic value calculated by the three tree nodes is 1000000, so that the logic value of the simplified multi-tree can be calculated layer by layer.
It will be appreciated that if the logical values of the reduced multi-way tree of two logical expressions are the same and the elements in the base element group are the same, then the meaning represented by the two logical expressions is the same; if the elements in the basic element groups of the two logic expressions are the same, but the logic values of the simplified multi-way tree are different, tree nodes with different meanings can be found out according to the codes of the tree nodes in the simplified multi-way tree.
The method of obtaining the tree nodes with different meanings may be to compare two simplified multi-tree layers by layers, determine the logic value under each layer, if the logic values are the same, temporarily strip the currently determined layer, so as to determine the logic value of the next layer, until two layers with different logic values are obtained, and when at least one of the two layers cannot strip out a new layer, output the two layers as the part with difference between the two logic expressions.
Alternatively, the comparison result of the first logic expression and the second logic expression may be the same as the two logic expressions, or may be different from each other, and the part having the difference in the logic expressions is obtained.
According to the technical scheme, the basic element group of the logic expression is obtained, the simplified multi-way tree and node codes of all tree nodes in the simplified multi-way tree are generated for the logic expression with the same basic element group, so that the logic value of the simplified multi-way tree is generated, the logic value of the simplified multi-way tree is compared, the comparison result of the logic expression is obtained, the complex logic expression can be compared quickly, the accuracy of the comparison result is high, the manual comparison can be reduced, and the labor cost and the time cost are reduced.
Example two
Fig. 2 is a flowchart of another method for comparing structures of logic expressions according to the second embodiment of the present invention, and the method for comparing structures of logic expressions is specifically described based on the above embodiment. As shown in fig. 2, the method includes:
s210, acquiring logical operation characters and element characters in the logical expression.
Alternatively, the logical operation characters may be and, any, or characters for representing logical relationships, and the element characters may be market codes, shenzhen securities exchange, and other text elements.
S220, splitting the element characters with the merging relation in the logic expression according to the logic operation characters and the element characters, and generating a plurality of basic elements according to the splitting result.
In a specific example, [ market code in { Shanghai securities exchange, shenzhen securities exchange, beijing securities exchange } ] can be split into three basic elements of market code in Shanghai securities exchange, market code in Shenzhen securities exchange and market code in Beijing securities exchange.
The specific manner of splitting depends on the meaning of the logical operation characters and is only illustrated here as an example.
S230, utilizing the basic element combination to form a basic element group matched with the logic expression.
S240, if the basic elements included in each basic element group are the same, generating a simplified multi-way tree which is matched with the first logic expression and the second logic expression respectively.
Wherein generating a reduced multi-way tree that matches the first logical expression and the second logical expression, respectively, may specifically include:
generating a binary tree which is matched with the first logic expression and the second logic expression respectively according to a preset binary tree generation rule;
and converting the binary tree into a multi-tree according to a preset multi-tree conversion rule, and simplifying the converted multi-tree to obtain a simplified multi-tree.
In the previous example, when the logical expression is [ securities category in { stock certificate } ] and [ market code in { Shanghai securities exchange, shenzhen securities exchange } ], the binary tree form matched therewith is as follows:
Figure BDA0004026319850000101
further, after converting the binary tree into the multi-tree, the multi-tree form is as follows:
Figure BDA0004026319850000102
the binary tree and the multi-tree are different in form, but all the meanings are the same.
The simplifying process of the converted multi-way tree can include at least one of the following:
if the same first tree node exists under the first operation logic in the multi-way tree, one first tree node is reserved, and the rest first tree nodes are deleted;
Deleting the second tree node in each multi-way tree if the same second tree node exists under the second operation logic of each multi-way tree;
if a plurality of third tree nodes meeting the merging condition exist under the third operation logic of each multi-way tree, and each third tree node among the multi-way trees is the same, merging the plurality of third tree nodes in each multi-way tree, and generating a fourth tree node with the same logic meaning as the plurality of third tree nodes.
The simplifying process of the multi-way tree can comprise the simplifying process of the multi-way tree and the simplifying process of the multi-way tree, in a simple way, the redundant elements in the multi-way tree can be simplified firstly, after the redundant elements in the multi-way tree are not existed, the multi-way tree with the two logic expressions being subjected to redundancy elimination is compared, the tree nodes with the same logic and elements in the two multi-way tree are deleted, finally, the plurality of tree nodes which can be combined and represented in the multi-way tree are combined into one tree node to be represented, and the simplifying process of the multi-way tree is completed.
In one specific example, the multi-way tree if matched to the first logical expression is as follows:
Figure BDA0004026319850000111
the multi-way tree matching the second logical expression is as follows:
Figure BDA0004026319850000112
at this time, one security category in stock certificate in the second logical expression may be deleted to complete in-tree reduction of the second logical expression; because the all logic of the two multi-way trees is provided with the element of the securities category in stock certificate, the securities category in stock certificate element of the two multi-way trees can be deleted at the same time; it can be seen that the market code in Shanghai securities exchange under the any logic, the market code in Shenzhen securities exchange and the market code in Beijing securities exchange can be logically combined, so that the three elements can be replaced by the elements ([ market code in Shenzhen securities exchange ] - [ market code in Beijing securities exchange ] - [ market code in Shanghai securities exchange ]). The reduced multi-way tree of the first logical expression may be represented as:
Figure BDA0004026319850000121
The reduced multi-way tree of the second logical expression may be represented as:
Figure BDA0004026319850000122
optionally, if different basic elements exist between the basic element groups respectively matched with the first logic expression and the second logic expression, a structure comparison result of the logic expression is generated according to the different basic elements.
In a specific example, if the basic element group of the first logic expression is a. Stock certificate of securities type in b. Market code in Shanghai securities exchange c. Market code in Shenzhen securities exchange d. Market code in Beijing securities exchange, the basic element group of the second logic expression is a. Stock certificate of securities type in b. Market code in Shanghai securities exchange c. Market code in Shenzhen securities exchange d. Market code in New York securities exchange, at this time, d items of the two basic element groups are two different basic elements, and the market code in Beijing securities exchange and the market code in New York securities exchange can be output as a structure comparison result.
S250, according to the hierarchical layout relation of the current processing simplified multi-way tree, ordering all tree nodes in the current processing simplified multi-way tree.
S260, determining a coding template with a matched set coding length in the current processing simplified multi-way tree according to the total number of tree nodes of the current processing simplified multi-way tree, wherein the coding template comprises at least one fixed coding region and at least one variable coding region.
In the previous example, for a simplified multi-way tree of three tree nodes, the encoding of each tree node may be divided into
Figure BDA0004026319850000131
and />
Figure BDA0004026319850000132
Three sets, each set having a code length of a predetermined length, e.g., +.>
Figure BDA0004026319850000133
Only one bit of the code, ">
Figure BDA0004026319850000134
And->
Figure BDA0004026319850000135
Has three-bit code, can be used for treating +.>
Figure BDA0004026319850000136
Set to a fixed coding region, +.>
Figure BDA0004026319850000137
All are 1, and can be added with->
Figure BDA0004026319850000138
and />
Figure BDA0004026319850000139
The variable coding regions are set as long as the codes in the variable coding regions of each tree node are ensured to be different from each other.
S270, filling fixed coding values in the fixed coding region according to a preset coding rule, and respectively filling variable coding values in the variable coding region according to the sequencing result of all tree nodes in the current processing simplified multi-tree to form node codes respectively corresponding to each tree node in the current processing simplified multi-tree.
S280, generating logic values of each simplified multi-way tree according to the logic relation among different tree nodes in each simplified multi-way tree and the node codes of each tree node, and generating a comparison result of the first logic expression and the second logic expression according to each logic value.
The generating a comparison result of the first logic expression and the second logic expression according to each logic value may specifically include:
Detecting whether first logic values and second logic values respectively corresponding to the first logic expression and the second logic expression are consistent;
if not, analyzing a first logic sub-value and a second logic sub-value respectively corresponding to the current comparison level of each simplified multi-way tree in the first logic expression and the second logic expression, wherein the current comparison level is initialized to be the last level of the simplified multi-way tree;
comparing whether the first logic sub-value is consistent with the second logic sub-value;
if yes, after subtracting one process from the current comparison level, returning to execute the operation of analyzing the first logic sub-value and the second logic sub-value respectively corresponding to the current comparison level of each simplified multi-way tree until the process of all levels in the simplified multi-way tree is completed;
if not, respectively analyzing the first logic sub-value and the second logic sub-value into last logic sub-values respectively corresponding to each tree node when the total number of the tree nodes included in the current comparison hierarchy is not unique;
identifying target tree nodes with different last logic sub-values as comparison results of the first logic expression and the second logic expression;
when the total number of the tree nodes included in the current comparison level is unique, the unique tree nodes in the current comparison level are used as comparison results of the first logic expression and the second logic expression.
According to the technical scheme, the subsequent calculation amount can be effectively reduced and the calculation speed can be improved by simplifying the multi-way tree converted by the logic expression, and the difference part of the logic expression can be rapidly positioned by generating the comparison result of the logic expression according to the logic value of the simplified multi-way tree, so that the comparison efficiency of the logic expression is improved.
Example III
Fig. 3 is a schematic structural diagram of a structural comparison device of a logic expression according to a third embodiment of the present invention. As shown in fig. 3, the apparatus includes: a base element group generation module 310, a simplified multi-way tree generation module 320, a node code generation module 330, and a comparison result generation module 340.
The basic element group generating module 310 is configured to parse the first logic expression and the second logic expression, respectively, and generate basic element groups that are matched with the first logic expression and the second logic expression, respectively.
A simplified multi-way tree generating module 320, configured to generate a simplified multi-way tree that matches the first logical expression and the second logical expression, respectively, if the base elements included in each base element group are the same.
The node code generating module 330 is configured to generate node codes of tree nodes in each simplified multi-tree according to the hierarchical layout relationship of each simplified multi-tree and the total number of tree nodes.
The comparison result generating module 340 is configured to generate a logic value of each simplified multi-way tree according to the logic relationship between different tree nodes in each simplified multi-way tree and the node code of each tree node, and generate a comparison result of the first logic expression and the second logic expression according to each logic value.
According to the technical scheme, the basic element group of the logic expression is obtained, the simplified multi-way tree and node codes of all tree nodes in the simplified multi-way tree are generated for the logic expression with the same basic element group, so that the logic value of the simplified multi-way tree is generated, the logic value of the simplified multi-way tree is compared, the comparison result of the logic expression is obtained, the complex logic expression can be compared quickly, the accuracy of the comparison result is high, the manual comparison can be reduced, and the labor cost and the time cost are reduced.
Based on the above embodiments, the basic element group generating module 310 may specifically be configured to:
acquiring a logical operation character and an element character in a logical expression;
splitting element characters with merging relations in a logic expression according to the logic operation characters and the element characters, and generating a plurality of basic elements according to splitting results;
The basic element group matched with the logic expression is formed by basic element combination.
On the basis of the above embodiments, the method may further include a basic element result generation module, specifically configured to:
if different basic elements exist between basic element groups respectively matched with the first logic expression and the second logic expression, a structure comparison result of the logic expression is generated according to the different basic elements.
Based on the above embodiments, the simplified multi-tree generation module 320 may include:
the binary tree generation unit is used for generating a binary tree which is matched with the first logic expression and the second logic expression respectively according to a preset binary tree generation rule;
and the multi-tree simplifying unit is used for converting the binary tree into the multi-tree according to a preset multi-tree conversion rule, and simplifying the converted multi-tree to obtain a simplified multi-tree.
On the basis of the above embodiments, the multi-way tree simplifying unit may be specifically configured to:
if the same first tree node exists under the first operation logic in the multi-way tree, one first tree node is reserved, and the rest first tree nodes are deleted;
deleting the second tree node in each multi-way tree if the same second tree node exists under the second operation logic of each multi-way tree;
If a plurality of third tree nodes meeting the merging condition exist under the third operation logic of each multi-way tree, and each third tree node among the multi-way trees is the same, merging the plurality of third tree nodes in each multi-way tree, and generating a fourth tree node with the same logic meaning as the plurality of third tree nodes.
Based on the above embodiments, the node code generating module 330 may be specifically configured to:
according to the hierarchical layout relation of the current processing simplified multi-way tree, ordering all tree nodes in the current processing simplified multi-way tree;
determining a coding template with a set coding length matched in the current processing simplified multi-way tree according to the total number of tree nodes of the current processing simplified multi-way tree, wherein the coding template comprises at least one fixed coding region and at least one variable coding region;
and filling fixed coding values in the fixed coding region according to a preset coding rule, and respectively filling variable coding values in the variable coding region according to the ordering result of each tree node in the current processing simplified multi-tree to form node codes respectively corresponding to each tree node in the current processing simplified multi-tree.
Based on the above embodiments, the comparison result generating module 340 may be specifically configured to:
Detecting whether first logic values and second logic values respectively corresponding to the first logic expression and the second logic expression are consistent;
if not, analyzing a first logic sub-value and a second logic sub-value respectively corresponding to the current comparison level of each simplified multi-way tree in the first logic expression and the second logic expression, wherein the current comparison level is initialized to be the last level of the simplified multi-way tree;
comparing whether the first logic sub-value is consistent with the second logic sub-value;
if yes, after subtracting one process from the current comparison level, returning to execute the operation of analyzing the first logic sub-value and the second logic sub-value respectively corresponding to the current comparison level of each simplified multi-way tree until the process of all levels in the simplified multi-way tree is completed;
if not, respectively analyzing the first logic sub-value and the second logic sub-value into last logic sub-values respectively corresponding to each tree node when the total number of the tree nodes included in the current comparison hierarchy is not unique;
identifying target tree nodes with different last logic sub-values as comparison results of the first logic expression and the second logic expression;
when the total number of the tree nodes included in the current comparison level is unique, the unique tree nodes in the current comparison level are used as comparison results of the first logic expression and the second logic expression.
The structure comparison device of the logic expression provided by the embodiment of the invention can execute the structure comparison method of the logic expression provided by any embodiment of the invention, and has the corresponding functional modules and beneficial effects of the execution method.
Example IV
Fig. 4 shows a schematic diagram of the structure of an electronic device 10 that may be used to implement an embodiment of the invention. Electronic devices are intended to represent various forms of digital computers, such as laptops, desktops, workstations, personal digital assistants, servers, blade servers, mainframes, and other appropriate computers. Electronic equipment may also represent various forms of mobile devices, such as personal digital processing, cellular telephones, smartphones, wearable devices (e.g., helmets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions, are meant to be exemplary only, and are not meant to limit implementations of the inventions described and/or claimed herein.
As shown in fig. 4, the electronic device 10 includes at least one processor 11, and a memory, such as a Read Only Memory (ROM) 12, a Random Access Memory (RAM) 13, etc., communicatively connected to the at least one processor 11, in which the memory stores a computer program executable by the at least one processor, and the processor 11 may perform various appropriate actions and processes according to the computer program stored in the Read Only Memory (ROM) 12 or the computer program loaded from the storage unit 18 into the Random Access Memory (RAM) 13. In the RAM13, various programs and data required for the operation of the electronic device 10 may also be stored. The processor 11, the ROM12 and the RAM13 are connected to each other via a bus 14. An input/output (I/O) interface 15 is also connected to bus 14.
Various components in the electronic device 10 are connected to the I/O interface 15, including: an input unit 16 such as a keyboard, a mouse, etc.; an output unit 17 such as various types of displays, speakers, and the like; a storage unit 18 such as a magnetic disk, an optical disk, or the like; and a communication unit 19 such as a network card, modem, wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information/data with other devices via a computer network, such as the internet, and/or various telecommunication networks.
The processor 11 may be a variety of general and/or special purpose processing components having processing and computing capabilities. Some examples of processor 11 include, but are not limited to, a Central Processing Unit (CPU), a Graphics Processing Unit (GPU), various specialized Artificial Intelligence (AI) computing chips, various processors running machine learning model algorithms, digital Signal Processors (DSPs), and any suitable processor, controller, microcontroller, etc. The processor 11 performs the various methods and processes described above, such as the structural alignment of logical expressions as described in embodiments of the invention. Namely:
respectively analyzing the first logic expression and the second logic expression to generate a basic element group respectively matched with the first logic expression and the second logic expression;
If the basic elements included in each basic element group are the same, generating a simplified multi-way tree respectively matched with the first logic expression and the second logic expression;
generating node codes of tree nodes in each simplified multi-tree according to the hierarchical layout relation of each simplified multi-tree and the total number of tree nodes;
according to the logic relation between different tree nodes in each simplified multi-way tree and the node codes of each tree node, generating the logic value of each simplified multi-way tree, and according to each logic value, generating the comparison result of the first logic expression and the second logic expression.
In some embodiments, the structural alignment method of the logic expressions may be implemented as a computer program tangibly embodied on a computer-readable storage medium, such as storage unit 18. In some embodiments, part or all of the computer program may be loaded and/or installed onto the electronic device 10 via the ROM12 and/or the communication unit 19. When the computer program is loaded into the RAM13 and executed by the processor 11, one or more steps of the structural alignment method of the logical expressions described above may be performed. Alternatively, in other embodiments, the processor 11 may be configured to perform the structural alignment method of the logical expression in any other suitable manner (e.g., by means of firmware).
Various implementations of the systems and techniques described here above may be implemented in digital electronic circuitry, integrated circuit systems, field Programmable Gate Arrays (FPGAs), application Specific Integrated Circuits (ASICs), application Specific Standard Products (ASSPs), systems On Chip (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and/or combinations thereof. These various embodiments may include: implemented in one or more computer programs, the one or more computer programs may be executed and/or interpreted on a programmable system including at least one programmable processor, which may be a special purpose or general-purpose programmable processor, that may receive data and instructions from, and transmit data and instructions to, a storage system, at least one input device, and at least one output device.
A computer program for carrying out methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus, such that the computer programs, when executed by the processor, cause the functions/acts specified in the flowchart and/or block diagram block or blocks to be implemented. The computer program may execute entirely on the machine, partly on the machine, as a stand-alone software package, partly on the machine and partly on a remote machine or entirely on the remote machine or server.
In the context of the present invention, a computer-readable storage medium may be a tangible medium that can contain, or store a computer program for use by or in connection with an instruction execution system, apparatus, or device. The computer readable storage medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. Alternatively, the computer readable storage medium may be a machine readable signal medium. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
To provide for interaction with a user, the systems and techniques described here can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to a user; and a keyboard and a pointing device (e.g., a mouse or a trackball) through which a user can provide input to the electronic device. Other kinds of devices may also be used to provide for interaction with a user; for example, feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form, including acoustic input, speech input, or tactile input.
The systems and techniques described here can be implemented in a computing system that includes a background component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front-end component (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such background, middleware, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: local Area Networks (LANs), wide Area Networks (WANs), blockchain networks, and the internet.
The computing system may include clients and servers. The client and server are typically remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other. The server can be a cloud server, also called a cloud computing server or a cloud host, and is a host product in a cloud computing service system, so that the defects of high management difficulty and weak service expansibility in the traditional physical hosts and VPS service are overcome.
It should be appreciated that various forms of the flows shown above may be used to reorder, add, or delete steps. For example, the steps described in the present invention may be performed in parallel, sequentially, or in a different order, so long as the desired results of the technical solution of the present invention are achieved, and the present invention is not limited herein.
The above embodiments do not limit the scope of the present invention. It will be apparent to those skilled in the art that various modifications, combinations, sub-combinations and alternatives are possible, depending on design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the scope of the present invention.

Claims (10)

1. A method of structure alignment of logical expressions, comprising:
respectively analyzing the first logic expression and the second logic expression to generate a basic element group respectively matched with the first logic expression and the second logic expression;
if the basic elements included in each basic element group are the same, generating a simplified multi-way tree matched with the first logic expression and the second logic expression respectively;
Generating node codes of tree nodes in each simplified multi-tree according to the hierarchical layout relation of each simplified multi-tree and the total number of tree nodes;
according to the logic relation between different tree nodes in each simplified multi-way tree and the node codes of each tree node, generating the logic value of each simplified multi-way tree, and according to each logic value, generating the comparison result of the first logic expression and the second logic expression.
2. The method of claim 1, wherein parsing the first logical expression and the second logical expression, respectively, generates a set of base elements that match the first logical expression and the second logical expression, respectively, comprising:
acquiring a logical operation character and an element character in a logical expression;
splitting the element characters with the merging relation in the logic expression according to the logic operation characters and the element characters, and generating a plurality of basic elements according to the splitting result;
and constructing a basic element group matched with the logic expression by utilizing the basic element combination.
3. The method of claim 2, further comprising, after generating the base element group that matches the first logical expression and the second logical expression, respectively:
If different basic elements exist between basic element groups respectively matched with the first logic expression and the second logic expression, generating a structure comparison result of the logic expression according to the different basic elements.
4. The method of claim 2, wherein generating a reduced multi-way tree that matches the first logical expression and the second logical expression, respectively, comprises:
generating a binary tree which is matched with the first logic expression and the second logic expression respectively according to a preset binary tree generation rule;
and converting the binary tree into a multi-tree according to a preset multi-tree conversion rule, and simplifying the converted multi-tree to obtain a simplified multi-tree.
5. The method of claim 4, wherein simplifying the converted multi-way tree comprises at least one of:
if the same first tree node exists under the first operation logic in the multi-way tree, one first tree node is reserved, and the rest first tree nodes are deleted;
deleting the second tree node in each multi-way tree if the same second tree node exists under the second operation logic of each multi-way tree;
if a plurality of third tree nodes meeting the merging condition exist under the third operation logic of each multi-way tree, and each third tree node among the multi-way trees is the same, merging the plurality of third tree nodes in each multi-way tree, and generating a fourth tree node with the same logic meaning as the plurality of third tree nodes.
6. The method of claim 5, wherein generating node codes for each tree node in each reduced multi-drop tree based on the hierarchical layout relationship of each reduced multi-drop tree and the total number of tree nodes comprises:
ordering all tree nodes in the current processing simplified multi-tree according to the hierarchical layout relation of the current processing simplified multi-tree;
determining a coding template with a set coding length matched in the current processing simplified multi-way tree according to the total number of tree nodes of the current processing simplified multi-way tree, wherein the coding template comprises at least one fixed coding region and at least one variable coding region;
and filling fixed coding values in the fixed coding region according to a preset coding rule, and respectively filling variable coding values in the variable coding region according to the sequencing result of each tree node in the current processing simplified multi-tree to form node codes respectively corresponding to each tree node in the current processing simplified multi-tree.
7. The method of claim 6, wherein generating a comparison of the first logical expression and the second logical expression based on each logical value comprises:
detecting whether first logic values and second logic values respectively corresponding to the first logic expression and the second logic expression are consistent;
If not, analyzing a first logic sub-value and a second logic sub-value respectively corresponding to the current comparison level of each simplified multi-way tree in the first logic expression and the second logic expression, wherein the current comparison level is initialized to be the last level of the simplified multi-way tree;
comparing whether the first logic sub-value is consistent with the second logic sub-value;
if yes, after subtracting one process from the current comparison level, returning to execute the operation of analyzing the first logic sub-value and the second logic sub-value respectively corresponding to the current comparison level of each simplified multi-way tree until the process of all levels in the simplified multi-way tree is completed;
if not, respectively analyzing the first logic sub-value and the second logic sub-value into last logic sub-values respectively corresponding to each tree node when the total number of the tree nodes included in the current comparison hierarchy is not unique;
identifying target tree nodes with different last logic sub-values as comparison results of the first logic expression and the second logic expression;
when the total number of the tree nodes included in the current comparison level is unique, the unique tree nodes in the current comparison level are used as comparison results of the first logic expression and the second logic expression.
8. A structural alignment device for a logic expression, comprising:
the basic element group generation module is used for respectively analyzing the first logic expression and the second logic expression to generate basic element groups respectively matched with the first logic expression and the second logic expression;
a simplified multi-way tree generating module, configured to generate a simplified multi-way tree that matches the first logical expression and the second logical expression, respectively, if the base elements included in each of the base element groups are the same;
the node code generating module is used for generating node codes of all tree nodes in all the simplified multi-tree according to the hierarchical layout relation of all the simplified multi-tree and the total number of the tree nodes;
the comparison result generation module is used for generating logic values of each simplified multi-way tree according to the logic relation among different tree nodes in each simplified multi-way tree and the node codes of each tree node, and generating comparison results of the first logic expression and the second logic expression according to each logic value.
9. An electronic device, the electronic device comprising:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein,
The memory stores a computer program executable by the at least one processor to enable the at least one processor to perform the structural alignment method of the logical expression of any of claims 1-7.
10. A computer readable storage medium storing computer instructions for causing a processor to implement the structural alignment method of the logical expression of any of claims 1-7 when executed.
CN202211711444.7A 2022-12-29 2022-12-29 Structure comparison method, device and equipment of logic expression and storage medium Pending CN116050351A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211711444.7A CN116050351A (en) 2022-12-29 2022-12-29 Structure comparison method, device and equipment of logic expression and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211711444.7A CN116050351A (en) 2022-12-29 2022-12-29 Structure comparison method, device and equipment of logic expression and storage medium

Publications (1)

Publication Number Publication Date
CN116050351A true CN116050351A (en) 2023-05-02

Family

ID=86115814

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211711444.7A Pending CN116050351A (en) 2022-12-29 2022-12-29 Structure comparison method, device and equipment of logic expression and storage medium

Country Status (1)

Country Link
CN (1) CN116050351A (en)

Similar Documents

Publication Publication Date Title
CN113722493B (en) Text classification data processing method, apparatus and storage medium
CN111339743B (en) Account number generation method and device
CN114722048B (en) Data processing method and device, electronic equipment and storage medium
CN116303013A (en) Source code analysis method, device, electronic equipment and storage medium
CN115186738A (en) Model training method, device and storage medium
CN116050351A (en) Structure comparison method, device and equipment of logic expression and storage medium
CN114443493A (en) Test case generation method and device, electronic equipment and storage medium
CN114611155B (en) Data management node verification method, device, equipment and medium
CN117272970B (en) Document generation method, device, equipment and storage medium
CN115511014B (en) Information matching method, device, equipment and storage medium
CN118051670A (en) Service recommendation method, device, equipment and medium
CN115130603A (en) BIM classification coding method and device for transformer substation, electronic equipment and storage medium
CN116303369A (en) Automatic coding method and device based on database, electronic equipment and medium
CN118012936A (en) Data extraction method, device, equipment and storage medium
CN115934101A (en) Interface document generation method, device, medium and electronic equipment
CN116796859A (en) Training method and device for sequence-to-sequence model, electronic equipment and medium
CN117472912A (en) Data coding and warehousing method and device, electronic equipment and storage medium
CN116662563A (en) Skill culture knowledge graph generation method, device, equipment and medium
CN115525774A (en) Map generation method and device, electronic equipment and storage medium
CN117667693A (en) Automatic message testing method, device, equipment and storage medium
CN117851599A (en) Method, device, equipment and medium for extracting text of other elements of investment supervision
CN115567624A (en) Message processing method and device, electronic equipment and medium
CN117609234A (en) Data processing method and device
CN116186411A (en) Method and device for constructing user behavior prediction model based on depth recommendation model
CN117371058A (en) Data processing method and device, electronic equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination