A method, device, equipment and computer-readable storage medium for removing duplicate expressions

By determining object nodes, analyzing comparable objects and deduplication for Lamda expressions, the problem of intelligent deduplication in the prior art is solved, and the execution efficiency of the decision tree is improved.

CN119512905BActive Publication Date: 2025-05-06ZHEJIANG BANGSUN TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510081331.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-01-20
Publication Date
2025-05-06
Estimated Expiration
2045-01-20

AI Technical Summary

Technical Problem

The prior art cannot intelligently deduplicate Lamda expressions, resulting in inefficient execution of decision trees and wasteful performance.

Method used

By determining the object node corresponding to each target expression, comparable objects are obtained, and these objects are compared, deduplication of the expression is achieved, and the final target expression collection is obtained.

Benefits of technology

It improves the accuracy and efficiency of expression deduplication, reduces the number of repeated predicate nodes in the decision tree, and thus improves the execution efficiency of the decision tree.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119512905B_ABST
    Figure CN119512905B_ABST
Patent Text Reader

Abstract

The present invention discloses an expression deduplication method, device, equipment and computer-readable storage medium, which are applied to the field of data analysis, including: determining the object node corresponding to each target expression; analyzing each object node to obtain the comparable object corresponding to each target expression; comparing the comparable objects corresponding to each target expression, deduplicating all target expressions, and obtaining a final target expression set. Compared with the current manual analysis and deduplication of expressions, the present invention processes all target expressions required for building a decision tree so that the expressions can be converted into comparable objects, thereby comparing each target expression based on the comparable objects, and deduplicating the expressions using the comparison results, thereby improving the accuracy and efficiency of deduplicating the expressions.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of data analysis technology, and in particular to an expression deduplication method, device, equipment and computer-readable storage medium. Background Art

[0002] In current real-time decision-making scenarios, Java (coding software) code is usually used to write and describe rule logic, where the parameters of Java methods are usually described as a Lamda expression (a concise way to represent an instance of a single method interface) logic. Lamda expression input parameters will become Lamda objects in Java, which do not have comparison and judgment methods. In addition, due to complex reference relationships and other situations, there will be a large number of errors in string analysis based on source code. At the same time, the execution efficiency of the decision tree is positively correlated with the number of its nodes. When multiple rules constitute the same decision tree, there will be a large number of repeated predicate nodes, resulting in performance waste.

[0003] It can be seen that how to intelligently deduplicate Lamda expressions is a technical problem that technical personnel in this field urgently need to solve. Summary of the invention

[0004] In view of this, the purpose of the present invention is to provide an expression deduplication method, device, equipment and computer-readable storage medium, which solves the technical problem in the prior art that expressions cannot be deduplicated intelligently.

[0005] In order to solve the above technical problems, the present invention provides an expression deduplication method, comprising:

[0006] Determine the object node corresponding to each target expression;

[0007] Analyze each object node to obtain the comparable object corresponding to each target expression;

[0008] Compare the comparable objects corresponding to each target expression, deduplicate all target expressions, and obtain the final target expression set.

[0009] Optionally, determining the object node corresponding to each target expression includes:

[0010] Reading a bytecode file according to the bytecode object, and parsing the bytecode file to obtain a class node object; wherein the bytecode object is an object determined based on the target expression;

[0011] An initial object node is determined based on the class node object, and the initial object node is matched based on the method name called in the target expression to obtain the object node.

[0012] Optionally, before reading the bytecode file according to the bytecode object and parsing the bytecode file to obtain the class node object, the method further includes:

[0013] Define a target function interface; wherein the target function interface inherits the functional interface and the serialization interface;

[0014] Convert all expressions in the rule into the target function interface form to obtain the target expression;

[0015] Load all compiled code files and obtain the rule objects that need to be loaded in the code files;

[0016] The target expressions in all rule objects are traversed to determine the bytecode objects used by the target expressions and the names of the methods called in the target expressions.

[0017] Optionally, analyze each object node to obtain the comparable object corresponding to each target expression, including:

[0018] Analyze each object node and get the hash value corresponding to each target expression.

[0019] Optionally, analyze each object node to obtain the hash value corresponding to each target expression, including:

[0020] Determine all hash values ​​corresponding to each object node;

[0021] Add all the hash values ​​corresponding to each object node to obtain a comprehensive hash value;

[0022] The comprehensive hash value is used as the hash value corresponding to each target expression.

[0023] Optionally, after comparing the comparable objects corresponding to each target expression and performing deduplication processing on all target expressions to obtain a final target expression set, the following further includes:

[0024] Based on the final target expression set, determining a target decision tree predicate node;

[0025] A decision tree is constructed based on the target decision tree predicate nodes.

[0026] Optionally, the comparable objects corresponding to each target expression are compared, and all target expressions are deduplicated to obtain a final target expression set, including:

[0027] Determine whether the comparable objects corresponding to each target expression are equal;

[0028] When they are equal, keep any one of the repeated target expressions;

[0029] When not equal, keep all target expressions.

[0030] The embodiment of the present invention also provides an expression deduplication device, including:

[0031] An object node determination module, used to determine the object node corresponding to each target expression;

[0032] A comparable object determination module is used to analyze each object node to obtain a comparable object corresponding to each target expression;

[0033] The deduplication module is used to compare the comparable objects corresponding to each target expression, deduplicate all target expressions, and obtain the final target expression set.

[0034] The embodiment of the present invention also provides an expression deduplication device, including:

[0035] Memory for storing computer programs;

[0036] A processor is used to execute the computer program to implement the steps of the above-mentioned expression deduplication method.

[0037] An embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the above-mentioned expression deduplication method are implemented.

[0038] An embodiment of the present invention further provides a computer program product, including a computer program / instruction, which implements the steps of the above-mentioned expression deduplication method when executed by a processor.

[0039] It can be seen that the present invention determines the object node corresponding to each target expression; analyzes each object node to obtain the comparable object corresponding to each target expression; compares the comparable objects corresponding to each target expression, and performs deduplication processing on all target expressions to obtain a final target expression set. Compared with the current method of only manually analyzing and deduplicating expressions, the present invention processes all target expressions required for building a decision tree so that the target expressions can become comparable objects, thereby comparing each expression based on the comparable objects, and using the comparison results to deduplicate the code, thereby improving the accuracy and efficiency of deduplication of target expressions.

[0040] In addition, the present invention also provides an expression deduplication device, equipment and computer-readable storage medium, which also have the above-mentioned beneficial effects. BRIEF DESCRIPTION OF THE DRAWINGS

[0041] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.

[0042] Figure 1 A flowchart of an expression deduplication method provided by an embodiment of the present invention;

[0043] Figure 2 An example flowchart of an expression deduplication method provided in an embodiment of the present invention;

[0044] Figure 3 A structural framework diagram of an expression deduplication method provided by an embodiment of the present invention;

[0045] Figure 4 A schematic diagram of the structure of an expression deduplication device provided by an embodiment of the present invention;

[0046] Figure 5 A schematic diagram of the structure of an expression deduplication device provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0047] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0048] Please refer to Figure 1 , Figure 1 A flowchart of a method for deduplicating expressions provided by an embodiment of the present invention. The method may include:

[0049] S101, determining the object node corresponding to each target expression.

[0050] This embodiment does not limit the specific execution subject. For example, the execution subject in this embodiment can be a computer; or the execution subject in this embodiment can be a tablet, etc. The target expression in this embodiment can be a Lambda expression. Lambda expression is a new feature introduced in Java8. It provides a concise way to represent anonymous functions and a shorthand way to describe the logic of a piece of code. This embodiment does not limit the specific target expression. The object node (node ​​object) corresponding to the target expression in this embodiment refers to the element that constitutes the bytecode instruction stream. This embodiment does not limit the specific node object. For example, the node object in this embodiment can represent a class, method, field or bytecode instruction.

[0051] It should be further explained that, in order to improve the accuracy of determining the object node, the above-mentioned determination of the object node corresponding to each target expression may include:

[0052] S1011, reading a bytecode file according to a bytecode object, and parsing the bytecode file to obtain a class node object; wherein the bytecode object is an object determined based on a target expression.

[0053] S1012, determining an initial object node based on the class node object, and matching the initial object node based on the method name called in the target expression to obtain an object node.

[0054] This embodiment can read the bytecode file according to the Class object (bytecode object) obtained by analysis, parse the bytecode file using ClassReader (a tool for obtaining class information at Java runtime, a class analyzer) of asm (bytecode analysis tool), and obtain the node objects (object nodes) of all methods in the class through ClassNode (ClassNode is a core class in the ASM library, which represents an abstract syntax tree of a Java class. Through ClassNode, you can access and operate the structure and content of a Java class), filter all object nodes, and only filter out node objects that match the method name called by the current target expression.

[0055] It should be further explained that in order to improve the accuracy of determining the method name called in the target expression, before reading the bytecode file according to the bytecode object and parsing the bytecode file to obtain the class node object, it can also include: defining a target function interface; wherein the target function interface inherits the functional interface and the serialization interface; converting all expressions in the rule into the target function interface form to obtain the target expression; loading all compiled code files and obtaining the rule objects to be loaded in the code files; traversing the target expressions in all rule objects, determining the bytecode objects used by the target expression, and the method name called in the target expression. In this embodiment, a functional interface A (target function interface) can be defined that inherits from Java's Predicate (functional interface) and Serializable interface (serialization interface). The interface can be used as a parameter description of the method, and when calling the method described by this type, the input parameter can be a Lamda expression. In interface A, a wrapper method (a tool for building database operation conditions, which provides a flexible and type-safe way to build SQL queries or update statements, a wrapper method) is defined to return the class object through an anonymous inner class. In the implementation class, there are member variables with the input type of the current predicate and the identifier of the current predicate. Define all method parameters in the rule that are Lamda expressions as the interface type. When the corresponding method is used to write the rule source code, the actual type of the Lamda expression is the implementation class of the interface. This embodiment can load all compiled Class files (compiled code files), execute the rule acquisition method, and obtain all rule (Rule) objects that currently need to be loaded. The rule object holds all Lamda expression objects defined in the current rule, and the object type is the A interface. Traverse the Lamda expression objects in all Rule objects. Use reflection to execute the writeReplace method (write replacement method, function, inherit the Serializable interface) on the current object. After execution, the Class object used by the current Lamda object and the method name called in the Lamda expression can be obtained.

[0056] S102, analyzing each object node to obtain a comparable object corresponding to each target expression.

[0057] This embodiment analyzes each object node to obtain the comparable object corresponding to each target expression, which means that the type of the current node is judged and converted down to its subtype, such as (MethodInsnNode, FieldInsnNode), etc. Each type has its corresponding member variables representing the properties of the current node. The variables are converted into comparable objects, and the comparable objects of each node are added to obtain the comparable object corresponding to the target expression. This embodiment does not limit specific comparable objects. For example, the comparable object in this embodiment can be a hash value; or the comparable object in this embodiment can be a feature value.

[0058] It should be further explained that, in order to improve the efficiency of comparison, the above analysis of each object node to obtain the comparable object corresponding to each target expression may include: analyzing each object node to obtain the hash value corresponding to each target expression. The hash value is usually an integer, which makes it very simple and fast to compare two objects, and only needs to compare their hash values.

[0059] It should be further explained that the above analysis of each object node to obtain the hash value corresponding to each target expression may include: determining all hash values ​​corresponding to each object node; adding all hash values ​​corresponding to each object node to obtain a comprehensive hash value; and using the comprehensive hash value as the hash value corresponding to each target expression. In this embodiment, the hash values ​​are added to improve the accuracy of determining the hash value of the target expression.

[0060] S103, comparing the comparable objects corresponding to each target expression, performing deduplication processing on all target expressions, and obtaining a final target expression set.

[0061] This embodiment can retain any one of the repeated target expression sets after comparison.

[0062] It should be further explained that, based on any of the above embodiments, the above-mentioned comparing the comparable objects corresponding to each target expression and filtering all the target expressions to obtain the final target expression set may include: determining whether the comparable objects corresponding to each target expression are equal; when equal, retaining any one of the repeated target expressions; when not equal, retaining all the target expressions.

[0063] It should be further explained that, based on any of the above embodiments, after comparing the comparable objects corresponding to each target expression, deduplicating all target expressions, and obtaining the final target expression set, the method may further include: determining the target decision tree predicate nodes based on the final target expression set; and constructing a decision tree based on the target decision tree predicate nodes. This embodiment can effectively reduce the nodes with the same predicate logic (target expression) in the decision tree, and can greatly improve the decision efficiency.

[0064] The expression deduplication method provided by the embodiment of the present invention may include: S101, determining the object node corresponding to each target expression; S102, analyzing each object node to obtain the comparable object corresponding to each target expression; S103, comparing the comparable objects corresponding to each target expression, deduplicating all target expressions, and obtaining a final target expression set. Compared with the current method of manually analyzing and deduplicating expressions, the present application processes the expressions so that the expressions can become comparable objects, thereby deduplicating the expressions based on the comparison results, thereby improving the accuracy and efficiency of deduplication.

[0065] In current real-time decision-making scenarios, Java code is usually used to describe rule logic, in which the parameters of Java methods are usually described as a Lamda expression logic. Lamda expression input parameters will become Lamda objects in Java, which do not have comparison and judgment methods. In addition, due to complex reference relationships and other situations, string analysis based on source code will have a large number of errors. At the same time, the execution efficiency of the decision tree is positively correlated with the number of its nodes. When multiple rules constitute the same decision tree, there will be a large number of repeated predicate nodes, resulting in performance waste.

[0066] In order to make the present invention easier to understand, please refer to Figure 2 , Figure 2 An example flow chart of an expression deduplication method provided in an embodiment of the present invention may specifically include:

[0067] S201. Define a target function interface; wherein the target function interface inherits Predicate (functional interface) and Serializable interface (serialization interface).

[0068] In this embodiment, the target function interface can be defined as interface A. For ease of understanding, please refer to Figure 3 , Figure 3 A structural framework diagram of an expression deduplication method provided by an embodiment of the present invention, Figure 3The content in the top left box "JavaRuleBuilder.rule("rule8",LoginEvent.Class,Proposal.Class); .when(e->e.getLoginAcct()==null); .whenn(e->e.getip()==null); .when(e->e.getLoginAcct()==null); .then((t,n)->new Proposal("abcd")),buid();" represents the rule object, and e->e.getLoginAcct()==null, e->e.getip()==null, and e->e.getLoginAcct()==null represent Lamda expressions. .when represents a logical judgment predicate, and >new Proposal("abcd") represents the predicate input. The top right represents the Class object used. JavaRuleBuilder is the starting point for building rules and is used to define a rule. In this example, the rule is named "rule", the associated class is LoginEvent, and the Proposal class is used. Rule Object: A rule object contains a condition (when) and an action (then). In this rule, the condition is to check if getLoginAcct() and getDip() are not null. Class and Method Nodes: These nodes represent Java classes and methods. For example, Class:LoginEvent represents the LoginEvent class, and Method:getLoginAcct represents the method for getting a login account. MethodReturnNode: A node that represents the return value of a method. For example, MethodReturnNode:name:getDip represents the return value of the getDip() method. FieldReturnNode: A node that represents the return value of a field. For example, FieldReturnNode:name:dip represents the value of the field dip. PredicateNode: A predicate node that represents a conditional judgment. For example, PredicateNode:desc:String represents a predicate described by a string. Filter Node: A node that represents a filtering operation. PropertyNode: A node that represents a property, for example, PropertyNode:name:dip represents the property dip. ClassReader: represents a class reader, used to read class files. Figure 3The construction process from Java code to decision tree is shown in FIG, including the creation of nodes of classes, methods, and fields, as well as processes such as condition judgment, filtering, and deduplication. Lamda in this embodiment is equivalent to Lamda, and Class is equivalent to class, without any difference.

[0069] S202. Automatically convert all Lamda expressions in the rules into target function interfaces.

[0070] In this embodiment, when the rule source code is written to use the corresponding method, the real type of its Lamda expression is the implementation class of the interface, so that the Lamda expression is automatically converted into interface A.

[0071] S203: Load all compiled Class files and obtain the rule objects that need to be loaded in the Class files.

[0072] This embodiment loads all compiled Class files, executes the rule acquisition method, and acquires all rule objects that need to be loaded. The rule object of this embodiment holds all Lamda expression objects defined in the current rule, and the object type is A interface.

[0073] S204, traverse the Lamda expressions in all rule objects, determine the Class objects used by the Lamda expressions and the names of the methods called in the Lamda expressions.

[0074] This embodiment traverses all Lamda expression objects in Rule objects, and uses reflection to execute the writeReplace method on the current object, after which the Class object used by the current Lamda object and the method name called in the Lamda expression can be obtained.

[0075] S205. Read the bytecode file according to the Class object obtained by analysis, parse the bytecode file using the asm class analyzer, and obtain the class node object.

[0076] S206. Determine a node object based on the class node object, and match the node object based on the method name called in the Lamda expression to obtain a matching node object.

[0077] This embodiment reads the bytecode file according to the Class object obtained by analysis, parses the bytecode file using ClassReader of asm, and obtains the node objects of all methods in the class through ClassNode. All method nodes are filtered to select only the node objects matching the method name called in S204.

[0078] S207. Obtain the properties of the matching node object for analysis to obtain the hash value corresponding to each Lamda expression.

[0079] All the attribute information obtained in this embodiment is the content referenced by the Lamda expression according to the bytecode analysis, and the analysis is not affected by the writing method, line breaks, spaces, etc. At this time, all the method node objects filtered by the predicate Lamda expression are traversed, the InsnList attribute in each node object is obtained for analysis, the type of the current node is judged, and it is converted down to its subtype, such as (MethodInsnNode, FieldInsnNode), etc. Each type has its corresponding member variables representing the attributes of the current node. The variables are converted into hash values, and the hash values ​​of each node are added to obtain the hash value corresponding to the Lamda expression.

[0080] S208. De-duplicate all Lamda expressions according to the hash value to obtain de-duplicate Lamda expressions.

[0081] The implementation class objects that can be analyzed in this embodiment are: MethodInsnNode, FieldInsnNode, IincInsnNode, IntInsnNode, LookupSwitchInsnNode, TypeInsnNode, MultiANewArrayInsnNode, InvokeDynamicInsnNode, TableSwitchInsnNode, LdcInsnNode, VarInsnNode, etc. MethodInsnNode: represents method call instructions, including ordinary method calls, static method calls, and interface method calls. FieldInsnNode: represents field (attribute) access instructions, used to load or store class field values. IincInsnNode: represents local variable increment instructions, used to increase the value of a local variable by a constant. IntInsnNode: represents instructions for operating integers, such as BIPUSH (pushing bytes into the operand stack) and SIPUSH (pushing short integers into the operand stack). LookupSwitchInsnNode: represents a lookup table jump instruction, used to implement multi-branch jumps.

[0082] TypeInsnNode: represents type operation instructions, such as NEW (create a new object), ANEWARRAY (create a new array), CHECKCAST (check type conversion), and INSTANCEOF (check whether an object is an instance of a specific class). MultiANewArrayInsnNode: represents instructions for creating multidimensional arrays. InvokeDynamicInsnNode: represents dynamic method call instructions, used to resolve method calls at runtime. TableSwitchInsnNode: represents table lookup jump instructions, used to implement multi-branch jumps, but unlike LookupSwitchInsnNode, it is an index-based jump. LdcInsnNode: represents instructions for loading constants to the operand stack, which can be any type in the constant pool. VarInsnNode: represents local variable operation instructions, used to load or store values ​​from the local variable table to the operand stack.

[0083] S209, constructing a decision tree based on the Lamda expression after deduplication.

[0084] This embodiment obtains the hash values ​​corresponding to all predicate Lamda expressions (predicates), and removes duplicates according to the hash values ​​to obtain the deduplicated predicate nodes. The deduplicated nodes are then used to construct a decision tree.

[0085] The present invention implements a method for predicate analysis and reorganization of a Lambda code in Java (Lambda expression is a new feature introduced in Java 8, which provides a concise way to represent anonymous functions and a shorthand way to describe the logic of a piece of code) based on asm (bytecode analysis tool) bytecode analysis technology. Its characteristics are that, based on bytecode analysis technology, deduplication is performed when building a decision tree according to the method of predicate logic. Among them, the predicate decision (judgment condition when making a decision) refers to the judgment condition when making a decision. Each judgment condition will form a node of the decision tree, and the description information of the node is called predicate logic. This method can greatly improve the decision-making speed and can provide more reliable and stable analysis results. The present invention aims to use bytecode analysis technology to reliably and stably analyze each predicate node for complex code writing, and build a decision tree based on the analysis results for real-time decision-making.

[0086] The following is an introduction to an expression deduplication device provided in an embodiment of the present invention. The expression deduplication device described below and the expression deduplication method described above can be referenced to each other.

[0087] Please refer to Figure 4 , Figure 4A schematic diagram of a structure of an expression deduplication device provided by an embodiment of the present invention may include:

[0088] An object node determination module 100 is used to determine the object node corresponding to each target expression;

[0089] A comparable object determination module 200 is used to analyze each object node to obtain a comparable object corresponding to each target expression;

[0090] The deduplication module 300 is used to compare the comparable objects corresponding to each target expression, perform deduplication processing on all target expressions, and obtain a final target expression set.

[0091] Further, based on any of the above embodiments, the object node determination module 100 may include:

[0092] A class node object determination unit, configured to read a bytecode file according to a bytecode object, and parse the bytecode file to obtain a class node object; wherein the bytecode object is an object determined based on the target expression;

[0093] The object node determination unit is used to determine an initial object node based on the class node object, and match the initial object node based on the method name called in the target expression to obtain the object node.

[0094] Further, based on the above embodiment, the above expression deduplication device may further include:

[0095] The target function interface determination unit is used to define a target function interface; wherein the target function interface inherits the functional interface and the serialization interface;

[0096] A target expression determination unit, used for converting all expressions in the rule into a target function interface form to obtain the target expression;

[0097] A rule object acquisition unit, used to load all compiled code files and acquire the rule objects to be loaded in the code files;

[0098] The bytecode object and method name acquisition unit is used to traverse the target expressions in all rule objects, determine the bytecode objects used by the target expressions, and the method names called in the target expressions.

[0099] Further, based on any of the above embodiments, the comparable object determination module 200 may include:

[0100] The hash value determination unit is used to analyze each object node to obtain the hash value corresponding to each target expression.

[0101] Further, based on the above embodiment, the above hash value determination unit may include:

[0102] A hash value determination subunit, used to determine all hash values ​​corresponding to each object node;

[0103] A comprehensive hash value determination subunit is used to add all hash values ​​corresponding to each object node to obtain a comprehensive hash value;

[0104] The hash value corresponding to the target expression is determined by a subunit, which is used to use the comprehensive hash value as the hash value corresponding to each target expression.

[0105] Further, based on any of the above embodiments, the above expression deduplication device may further include:

[0106] A target decision tree predicate node determination module, used to determine the target decision tree predicate node based on the final target expression set;

[0107] A decision tree construction module is used to construct a decision tree based on the target decision tree predicate nodes.

[0108] Further, based on any of the above embodiments, the deduplication module 300 may include:

[0109] A judgment unit, used to judge whether the comparable objects corresponding to each target expression are equal;

[0110] The deduplication unit is used to retain any one of the repeated target expressions when they are equal;

[0111] Do not process cells, used to keep all target expressions when they are not equal.

[0112] It should be noted that the order of the modules and units in the above-mentioned expression deduplication device can be changed without affecting the logic.

[0113] An expression deduplication device provided by an embodiment of the present invention may include: an object node determination module 100, for determining the object node corresponding to each target expression; a comparable object determination module 200, for analyzing each object node to obtain a comparable object corresponding to each target expression; a deduplication module 300, for comparing the comparable objects corresponding to each target expression, deduplicating all target expressions, and obtaining a final target expression set. Compared with the current practice of only manually analyzing and deduplicating expressions, the present application processes expressions so that the expressions can become comparable objects, thereby deduplicating expressions based on the comparison results, thereby improving the accuracy and efficiency of deduplication.

[0114] An expression deduplication device provided in an embodiment of the present invention is introduced below. The expression deduplication device described below and the expression deduplication method described above can be referenced to each other.

[0115] Please refer to Figure 5 , Figure 5 A schematic diagram of a structure of an expression deduplication device provided in an embodiment of the present invention may include:

[0116] A memory 10, used for storing computer programs;

[0117] The processor 20 is used to execute a computer program to implement the above-mentioned expression deduplication method.

[0118] The memory 10 , the processor 20 , and the communication interface 30 all communicate with each other via a communication bus 40 .

[0119] In the embodiment of the present invention, the memory 10 is used to store one or more programs, and the program may include program code, and the program code includes computer operation instructions. In the embodiment of the present invention, the memory 10 may store programs for implementing the following functions:

[0120] Determine the object node corresponding to each target expression;

[0121] Analyze each object node to obtain the comparable object corresponding to each target expression;

[0122] Compare the comparable objects corresponding to each target expression, deduplicate all target expressions, and obtain the final target expression set.

[0123] In a possible implementation, the memory 10 may include a program storage area and a data storage area, wherein the program storage area may store an operating system and an application required for at least one function, etc.; the data storage area may store data created during use.

[0124] In addition, the memory 10 may include a read-only memory and a random access memory, and provide instructions and data to the processor. A portion of the memory may also include an NVRAM. The memory stores an operating system and operating instructions, executable modules or data structures, or a subset thereof, or an extended set thereof, wherein the operating instructions may include various operating instructions for implementing various operations. The operating system may include various system programs for implementing various basic tasks and processing hardware-based tasks.

[0125] The processor 20 may be a central processing unit (CPU), an application specific integrated circuit, a digital signal processor, a field programmable gate array or other programmable logic device, a microprocessor or any conventional processor, etc. The processor 20 may call a program stored in the memory 10 .

[0126] The communication interface 30 may be an interface of a communication module, and is used to connect to other devices or systems.

[0127] Of course, it should be noted that Figure 5 The structure shown does not constitute a limitation on the expression deduplication device in the embodiment of the present invention. In actual applications, the expression deduplication device may include Figure 5 More or fewer components than shown, or combinations of certain components.

[0128] The computer-readable storage medium provided in an embodiment of the present invention is introduced below. The computer-readable storage medium described below and the expression deduplication method described above can be referenced to each other.

[0129] The present invention also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the above-mentioned expression deduplication method are implemented.

[0130] The computer-readable storage medium may include: a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and other media that can store program codes.

[0131] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.

[0132] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.

[0133] Finally, it should be noted that, in this article, relationships such as first and second, etc. are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprises" or any other variations are intended to cover non-exclusive inclusion, so that a process, method, article or device that includes a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device.

[0134] The above is a detailed introduction to an expression deduplication method, device, equipment and computer-readable storage medium provided by the present invention. Specific examples are used in this article to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea; at the same time, for general technical personnel in this field, according to the idea of ​​the present invention, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.

Claims

1. A method for removing duplicate expressions, characterized in that: include: Define a target function interface; wherein the target function interface inherits the functional interface and the serialization interface; Convert all expressions in the rule into the target function interface form to obtain the target expression; Load all compiled code files and obtain the rule objects that need to be loaded in the code files; Traversing the target expressions in all rule objects, determining the bytecode objects used by the target expressions, and the names of the methods called in the target expressions; Reading a bytecode file according to the bytecode object, parsing the bytecode file to obtain a class node object; determining an initial object node based on the class node object, and matching the initial object node based on the method name called in the target expression to obtain an object node; the bytecode object is an object determined based on the target expression; Analyze each object node to obtain the comparable object corresponding to each target expression; Compare the comparable objects corresponding to each target expression, deduplicate all target expressions, and obtain the final target expression set.

2. The expression deduplication method according to claim 1, characterized in that: Analyze each object node to obtain the comparable objects corresponding to each target expression, including: Analyze each object node and get the hash value corresponding to each target expression.

3. The expression deduplication method according to claim 2, characterized in that: Analyze each object node to obtain the hash value corresponding to each target expression, including: Determine all hash values ​​corresponding to each object node; Add all the hash values ​​corresponding to each object node to obtain a comprehensive hash value; The comprehensive hash value is used as the hash value corresponding to each target expression.

4. The expression deduplication method according to any one of claims 1 to 3, characterized in that: After comparing the comparable objects corresponding to each target expression and removing duplicates from all target expressions to obtain the final target expression set, it also includes: Based on the final target expression set, determining a target decision tree predicate node; A decision tree is constructed based on the target decision tree predicate nodes.

5. The expression deduplication method according to claim 1, characterized in that: Compare the comparable objects corresponding to each target expression, remove duplicates from all target expressions, and obtain the final target expression set, including: Determine whether the comparable objects corresponding to each target expression are equal; When they are equal, keep any one of the repeated target expressions; When not equal, keep all target expressions.

6. An expression deduplication device, characterized in that: include: The target function interface determination module is used to define a target function interface; wherein the target function interface inherits the functional interface and the serialization interface; The target expression determination module is used to convert all expressions in the rule into the target function interface form to obtain the target expression; A rule object acquisition module is used to load all compiled code files and obtain the rule objects that need to be loaded in the code files; A bytecode object and method name acquisition module, used to traverse the target expressions in all rule objects, determine the bytecode objects used by the target expressions, and the method names called in the target expressions; An object node determination module is used to read a bytecode file according to the bytecode object, and parse the bytecode file to obtain a class node object; determine an initial object node based on the class node object, and match the initial object node based on the method name called in the target expression to obtain an object node; the bytecode object is an object determined based on the target expression; A comparable object determination module is used to analyze each object node to obtain a comparable object corresponding to each target expression; The deduplication module is used to compare the comparable objects corresponding to each target expression, deduplicate all target expressions, and obtain the final target expression set.

7. An expression deduplication device, characterized in that: include: Memory for storing computer programs; A processor, used to execute the computer program to implement the steps of the expression deduplication method as described in any one of claims 1 to 5.

8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps of the expression deduplication method as described in any one of claims 1 to 5.

Citation Information

Patent Citations

  • Privacy leakage vulnerability detection confirming method based on static stain data analysis

    CN106940773A

  • Regular expression matching method and device for network security

    CN111181980A