A data query and analysis method
By using logical model operations and numerical operations in massive time series data processing, formula expressions are converted into numerical expressions, which solves the problem of complexity in storage and maintenance of indicator relationships, and achieves more efficient data processing and disk space utilization.
Patent Information
- Application Number
- CN202310443285.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-04-24
- Publication Date
- 2024-09-06
- Estimated Expiration
- 2043-04-24
AI Technical Summary
When the existing technology processes massive time series data, the logical sub-storage of indicator relationships occupies a large amount of disk space, resulting in a reduction in database disk occupancy and computing power used in CPU processor calculations, and it is difficult to customize and maintain indicator relationships.
Use if and withoutif logical model operations, Boolean logical model operations, comparison logical model operations and suffix sum function expression logical model operations, convert formula expressions into numerical expressions through regular matching and hash mapping, and use logical operations and comparison operations Process the symbols and verify whether the expression is compliant to reduce the complexity of the indicator relationship.
It effectively reduces the disk space occupation and CPU computing power consumption of indicator relationships, simplifies indicator relationship maintenance, and improves operability and user experience.
Smart Images

Figure CN116483334B
Abstract
Description
Technical Field
[0001] The present invention relates to the application field of software data calculation and verification, and in particular to a data query and analysis method. Background Art
[0002] As technology continues to advance, there are more and more ways to obtain news streams, and the amount of information users obtain has increased dramatically. Massive amounts of time series data are overwhelming, and very valuable information is hidden in them.
[0003] For example, the application number CN200610000534.X discloses a method for converting a ladder logic routine into Boolean logic. The Boolean representation of the ladder logic element is collected in the corresponding logic expression of each ladder rung in the plurality of ladder rungs defining the ladder logic routine. The Boolean logic element is then parsed out from the logic expression. The Boolean logic elements are then stored in a memory in the order in which the Boolean logic elements are parsed, thereby representing the ladder logic routine in the order in which the ladder logic routine is executed.
[0004] Existing technical cases are usually designed to set the relationship between indicator data in advance, without customizing the restrictive relationship between various indicators, resulting in the storage of a large number of indicator relationship logic formulas, which not only increases the disk data occupancy rate of indicator relationship data storage, but also complicates the maintenance of indicator relationships. This makes it inconvenient to expand and maintain the software's customized indicator relationships, and reduces the database disk occupancy rate and CPU processor computing power used for data relationship maintenance. Summary of the invention
[0005] The present invention aims to solve the above technical problems and provides a data query and analysis method.
[0006] In order to solve the above technical problems, the technical solution provided by the present invention is:
[0007] A data query and analysis method includes if logic model operation, withoutif logic model operation, Boolean logic model operation, comparison logic model operation and suffix and function expression logic model operation, and converts a formula expression F into a numerical expression D through a numerical operation mode dop such as regular matching and hash mapping, the numerical expression is composed of a Boolean function expression B and a logic function expression L through a logic operation lop, and the Boolean values returned by each function expression are obtained by calculating the value of each function expression, and then the Boolean logic model operation is performed to obtain the final Boolean value of the input expression;
[0008] The relationship is as follows:
[0009] D = dop(F);
[0010] dop(F)=(B|L)log(B|L);
[0011] B = BF(opD,opD);
[0012] L=(DF|opD)rop(DF|opD).
[0013] Preferably, the dop is a numerical operation, the rop is a relational operator, and the lop is a logical operator.
[0014] Preferably, the if logic model operation steps are as follows:
[0015] Step 1: Convert the formula expression to a numerical expression;
[0016] Step 2: Process the Boolean function module in the numerical expression and replace the corresponding formula with the Boolean function result;
[0017] Step 3: Use the if / elseif / else keywords to extract the string sequence of the judgment logic from the string sequence in the numerical expression.
[0018] Step 4: Extract different branch contents according to whether the if / elseif adjustment is true;
[0019] Step 5: Process the branch content, perform Boolean model processing on the branch content, and perform verification and judgment processing on the Boolean result of the branch content.
[0020] Preferably, the withoutif logic model operation steps are as follows:
[0021] Step 1: Convert the formula expression to a numerical expression
[0022] Step 2: Process the Boolean function module in the numerical expression and replace the corresponding formula with the Boolean function result
[0023] Step 3: Perform Boolean model processing on the numerical expression and perform verification and judgment processing on the Boolean result of the branch content.
[0024] Preferably, the step 1 is to first perform regular matching on the formula expression, then transform each variable name, map the transformed variable name and the input hash storage data, and generate a numerical logic expression.
[0025] Preferably, the step 2 is to determine whether there is a Boolean function in the formula, intercept the Boolean function expression string, and perform Boolean function matching processing on the string sequence to obtain the Boolean function expression function operation result, and then replace the numerical expression.
[0026] Preferably, the Boolean logic model operation steps are as follows:
[0027] Step 1: Split the operation sequence according to the Boolean operation separator and extract the logical operator sequence;
[0028] Step 2: Traverse each splitting logical operator, if it is || or &&, push it into the storage stack, if not, determine whether it contains a comparison operator symbol, if so, perform a comparison logic model operation, and push the returned Boolean result into the storage core, if not, perform a Boolean value type conversion, and push the calculated Boolean result into the stack;
[0029] Step 3: Perform a combined Boolean calculation on the elements in the stack and return the final Boolean result.
[0030] Preferably, the comparative logic model operation steps are as follows:
[0031] Step 1: Use comparison operators to split and initialize arrays of the same length to cache the results of each expression of the corresponding split comparison operator;
[0032] Step 2: For each split comparison operator expression, use the suffix and function expression logic model to calculate and process to return the corresponding expression result, and then replace the elements in the intermediate result array;
[0033] Step 3: Perform comparison operations on the elements in the intermediate results and return the Boolean result after calculation.
[0034] Preferably, the suffix and function expression logic model operation steps are as follows:
[0035] Step 1: Use regular expressions to determine whether the logical string sequence is a numeric sequence. If so, return the result directly.
[0036] Step 2: Add spaces around all operators to facilitate string segmentation;
[0037] Step 3: Convert the string sequence into an intermediate expression for subsequent processing;
[0038] Step 4: Convert the converted infix expression into a postfix expression for subsequent calculations;
[0039] Step 5: Operate the suffix expression sequence array and return the logical operation result.
[0040] After adopting the above method, the present invention has the following advantages:
[0041] The present invention adopts if and withoutif model operations, and can perform model operation processing according to the input formula expression and the corresponding mapping content, and verify whether the content rules are compliant and whether they are within the specified thresholds and limits; thereby better maintaining the indicator relationship and reducing the complexity of the indicator variable relationship, while reducing the disk space occupied by the maintenance content and the CPU computing power brought by the verification, and at the same time can bring better operability to users, reduce user operations and more convenient guidance.
[0042] The above summary is for illustrative purposes only and is not intended to be limiting in any way. In addition to the illustrative aspects, embodiments and features described above, further aspects, embodiments and features of the present invention will be readily apparent by reference to the accompanying drawings and the following detailed description. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or technical descriptions will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0044] Figure 1 It is a flow chart of the if logic model operation of the present invention.
[0045] Figure 2 It is a flowchart of the withoutif logic model operation of the present invention.
[0046] Figure 3 It is a flow chart of the Boolean logic model operation of the present invention.
[0047] Figure 4 It is a flow chart of the comparative logic model operation of the present invention.
[0048] Figure 5 It is a flow chart of the suffix and function expression logic model operation of the present invention. DETAILED DESCRIPTION
[0049] Specific embodiments of the present invention will now be mentioned in detail. Although the present invention is described in conjunction with these specific embodiments, it should be appreciated that it is not intended to limit the present invention to these specific embodiments. On the contrary, these embodiments are intended to cover substitutions, changes or equivalent embodiments that may be included in the spirit and scope of the invention defined by the claims. In the following description, a large number of specific details are set forth in order to provide a comprehensive understanding of the present invention. The present invention can be implemented without some or all of these specific details. In other cases, in order not to make the present invention unnecessarily obscure, well-known process operations are not described in detail.
[0050] When used in conjunction with "including," "methods comprising," or similar language in this specification and the appended claims, the singular forms "a," "an," and "the" include plural references unless the context clearly dictates otherwise. Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs.
[0051] The present invention is further described in detail below in conjunction with the full text.
[0052] Combined with Figure 1-5 , a data query and analysis method, including if logic model operation, withoutif logic model operation, Boolean logic model operation, comparison logic model operation and suffix and function expression logic model operation, and through the numerical operation mode dop such as regular matching and hash mapping, the formula expression F is converted into a numerical expression D, the numerical expression is composed of a Boolean function expression B and a logic function expression L through the logic operation lop, and the Boolean value returned by each function expression is obtained by calculating the value of each function expression, and then the Boolean logic model operation is performed to obtain the final Boolean value of the input expression;
[0053] The relationship is as follows:
[0054] D = dop(F);
[0055] dop(F)=(B|L)lop(B|L);
[0056] B = BF(opD,opD);
[0057] L=(DF|opD)rop(DF|opD).
[0058] The dop is a numerical operation, the rop is a relational operator, and the lop is a logical operator.
[0059] The meanings of each operator and identifier are explained as follows:
[0060] (1).dop is a numerical operation, including regular matching, hash mapping, etc.
[0061] (2).rop is a relational operator (<,>,=,<=,>=, etc.).
[0062] (3).lop is a logical operator (||, &&, etc.).
[0063] (4) Boolean function (BF): A function whose return value is a Boolean type, such as range(), equal(), etc.
[0064] (5) Numerical function (DF): a function whose return value is a numeric type, such as max(), min(), etc.
[0065] (6) The operand (opD) can be a specific number or a numerical function, such as max(1,3), 3, etc.
[0066] (7) Boolean function expression (B): It consists of a Boolean function and an operand, such as equal(1, 2)
[0067] (8) Logical function expression (L): It is a set of operands combined through relational operations (rop), such as max(-1,1)>0.
[0068] (9). Content expression: The data format used to process input data. The format is as follows: r(tableName) <indexname>[contentIndex]. For example, r(a) <count>[0] indicates the "0th" (note: software fields generally start numbering from 0) value of the "count" field in form "a".
[0069] (10) Formula expression (F): An expression obtained by performing function operations (BF, DF) and logical operations (lop) on the content expression, such as:
[0070] equal(r(a) <name> [0],r(a) <alia>[0])||max(r(a) <index1> [0],r(a) <index2>[0])>0)
[0071] (11) Numerical expression (D): The dop operation can be used to convert a formula expression into a numerical expression, such as:
[0072] equal(r(a) <name> [0],r(a) <alia>[0])||max(r(a) <index1> [0],r(a) <index2>[0])>0)
[0073] becomes
[0074] equal(string1,string1)||max(-1,1)>0
[0075] The if logic model operation steps are as follows:
[0076] Step 1: Convert the formula expression to a numerical expression;
[0077] Step 2: Process the Boolean function module in the numerical expression and replace the corresponding formula with the Boolean function result;
[0078] Step 3: Use the if / elseif / else keywords to extract the string sequence of the judgment logic from the string sequence in the numerical expression.
[0079] Step 4: Extract different branch contents according to whether the if / elseif adjustment is true;
[0080] Step 5: Process the branch content, perform Boolean model processing on the branch content, and perform verification and judgment processing on the Boolean result of the branch content.
[0081] The withoutif logic model operation steps are as follows:
[0082] Step 1: Convert the formula expression to a numerical expression
[0083] Step 2: Process the Boolean function module in the numerical expression and replace the corresponding formula with the Boolean function result
[0084] Step 3: Perform Boolean model processing on the numerical expression and perform verification and judgment processing on the Boolean result of the branch content.
[0085] The step 1 is to first perform regular matching on the formula expression, then transform each variable name, map the transformed variable name and the input hash storage data, and generate a numerical logic expression.
[0086] The step 2 is to determine whether there is a Boolean function in the formula, intercept the Boolean function expression string, and perform Boolean function matching processing on the string sequence to obtain the function operation result of the Boolean function expression, and then replace the numerical expression.
[0087] The Boolean logic model operation steps are as follows:
[0088] Step 1: Split the operation sequence according to the Boolean operation separator and extract the logical operator sequence;
[0089] Step 2: Traverse each splitting logical operator, if it is || or &&, push it into the storage stack, if not, determine whether it contains a comparison operator symbol, if so, perform a comparison logic model operation, and push the returned Boolean result into the storage core, if not, perform a Boolean value type conversion, and push the calculated Boolean result into the stack;
[0090] Step 3: Perform a combined Boolean calculation on the elements in the stack and return the final Boolean result.
[0091] The comparative logic model operation steps are as follows:
[0092] Step 1: Use comparison operators to split and initialize arrays of the same length to cache the results of each expression of the corresponding split comparison operator;
[0093] Step 2: For each split comparison operator expression, use the suffix and function expression logic model to calculate and process to return the corresponding expression result, and then replace the elements in the intermediate result array;
[0094] Step 3: Perform comparison operations on the elements in the intermediate results and return the Boolean result after calculation.
[0095] The operation steps of the suffix and function expression logic model are as follows:
[0096] Step 1: Use regular expressions to determine whether the logical string sequence is a numeric sequence. If so, return the result directly.
[0097] Step 2: Add spaces around all operators to facilitate string segmentation;
[0098] Step 3: Convert the string sequence into an intermediate expression for subsequent processing;
[0099] Step 4: Convert the converted infix expression into a postfix expression for subsequent calculations;
[0100] Step 5: Operate the suffix expression sequence array and return the logical operation result.
[0101] Embodiment 1:
[0102] like Figure 1 As shown, the operation steps of the if logic model are as follows:
[0103] Step 1: Convert the formula expression to a numerical expression;
[0104] In this embodiment, the input formula expression and the corresponding expression variables are converted into specific corresponding numerical logic expression formulas;
[0105] The specific steps are:
[0106] ①First, perform regular matching on the formula expression, and then transform each variable name.
[0107] ② Map the transformed variable names and the input hash storage data to generate a numerical logic expression.
[0108] For example,
[0109] Data Entry
[0110] Formula expression:
[0111] if(range(r(a) <count>[0],13|14|15)||equal(r(a) <name> [0],r(a) <alia>[0])
[0112] ||max(r(a) <maxcount> [0],r(a) <randomcount>[0])>0)){
[0113] }
[0114] Hash storage data:
[0115] {a_count_0:13,
[0116] a_name_0:luobing,
[0117] a_alia_0:luobing,
[0118] a_maxCount_0:-1,
[0119] a_randomCount_0:1
[0120] }
[0121] ①First, perform regular matching on the formula expression, and then perform transformation processing
[0122] For example, the transformation is as follows: r(a) <count>[0]->a_count_0
[0123] if(range(r(a) <count>[0],13|14|15)||equal(r(a) <name> [0],r(a) <alia>[0])
[0124] ||max(r(a) <maxcount> [0],r(a) <randomcount>[0])>0)){
[0125] }
[0126] ->
[0127] if(range(a_count_0,13|14|15)||equal(a_name_0,a_alia_0)
[0128] ||max(a_maxCount_0,a_randomCount_0)>0)){
[0129] }
[0130] ② Generate a numerical logic expression after mapping
[0131] Mapping processing such as: a_count_0->13
[0132] if(range(a_count_0,13|14|15)||equal(a_name_0,a_alia_0)
[0133] ||max(a_maxCount_0,a_randomCount_0)>0)){
[0134] }
[0135] ->
[0136] if(range(13,13|14|15)||equal(luobing,luobing)
[0137] ||max(-1,1)>0)){
[0138] }
[0139] Step 2: Process the Boolean function module in the numerical expression and replace the corresponding formula with the Boolean function result;
[0140] The Boolean function in the processing expression is a function that returns a Boolean value result. In this embodiment, the Boolean function in the input numerical expression is processed into a Boolean result value.
[0141] The specific steps are:
[0142] ① Determine whether there is a Boolean function in the formula and intercept the Boolean function expression string.
[0143] ② Perform Boolean function matching on the string sequence, obtain the Boolean function expression function operation result (true|false), and then replace the numerical expression.
[0144] For example,
[0145] Data Entry
[0146] if(range(13,13|14|15)||equal(luobing,luobing)
[0147] ||max(-1,1)>0)){
[0148] }
[0149] The corresponding function name is located by searching the string index through the function name keyword. Then the content in the expression is intercepted.
[0150] Then the intercepted Boolean function expression string list is as follows:
[0151] ①range(13,13|14|15)②equal(luobing,luobing)
[0152] Perform Boolean function matching on the string sequence, obtain the result of the Boolean function expression, and then replace the corresponding function formula with the result.
[0153] The processing of the range function is as follows:
[0154] Match the function name range, and then split it into two elements. The first element is the sub-item 13, and the second element is 13|14|15. Then perform a split operation on the sub-item 13|14|15, split it into a numeric array with |, and then determine whether the numeric array contains the value of the first sub-item 13. If it does, the Boolean result value is true, otherwise it is false.
[0155] The same Boolean function equal compares whether the contents of two sub-items are the same.
[0156] if(range(13,13|14|15)||equal(luobing,luobing)
[0157] ||max(-1,1)>0)){
[0158] }
[0159] ->
[0160] if(true||true||max(-1,1)>0)){
[0161] }
[0162] Step 3: The string sequence in the numerical expression is intercepted by the if / elseif / else keywords to determine the string sequence of the logic. In this embodiment, the string sequence after the if / elseif keywords in the input numerical expression is converted into a Boolean result.
[0163] The specific steps are:
[0164] ① Use the if / elseif keywords to intercept the string sequence of judgment logic in the numerical expression.
[0165] ②Perform Boolean operation on the string sequence and replace the numerical expression with the returned Boolean operation result.
[0166] For example,
[0167] Data Entry
[0168] if(true||true||max(-1,1)>0)){
[0169] }
[0170] ①Intercept the string sequence after the keyword
[0171] true||true||max(-1,1)>0
[0172] ②Perform Boolean logic model operations and then replace the numerical expression
[0173] true||true||max(-1,1)>0
[0174] Returns true after a Boolean operation
[0175] if(true||true||max(-1,1)>0)){
[0176] }
[0177] ->
[0178] if(true){
[0179] }
[0180] Step 4: Extract different branch contents based on if / elseif adjustments are true.
[0181] In this embodiment, different branch contents are extracted according to the Boolean operation results of different branches of the keyword if / elseif.
[0182] The specific steps are:
[0183] Make branch judgments based on the results of Boolean operations. If the value in if is true, then intercept the branch content in if, such as
[0184] If it is false, then determine whether there is an elseif, and then obtain the string sequence of the elseif judgment logic, and then perform the same logical operation as the string sequence of the if judgment logic. If the logic judgment in elseif is true, then obtain the branch content in elseif. If there is no elseif branch, determine whether there is an else branch, and then obtain the else branch content.
[0185] For example,
[0186] The input is as follows:
[0187] if(condition1){
[0188] max(3,5)+(6,7)>=min(5,3)+9
[0189] }elseif(condition2){
[0190] 3+5-2==min(5,3)+9
[0191] }else{
[0192] max(3,5)>=min(6,2)
[0193] }
[0194] If condition1 is true, then the branch content is max(3,5)+(6,7)>=min(5,3)+9. If it is not true, then determine whether condition2 is true. If so, the branch content is 3+5-2==min(5,3)+9. If not, the branch content is max(3,5)>=min(6,2).
[0195] Step 5: Process the branch content, perform Boolean model processing on the branch content, and perform verification and judgment processing on the Boolean result of the branch content. In this embodiment, a comparison operation is performed according to the comparison operator of the extracted branch content, and then it is verified whether the Boolean result is true.
[0196] The specific steps are:
[0197] Input Data
[0198] max(3,5)>=min(6,2)
[0199] Perform Boolean logic model operations on the formula, then return the Boolean result to verify whether the Boolean result is true.
[0200] Embodiment 2:
[0201] like Figure 2 As shown, the withoutif logic model operation steps are as follows:
[0202] The specific steps of this method, step 1 and step 2 are the same as steps 1 and 2 of the if logic model operation.
[0203] Step 3: Perform Boolean model processing on the numerical expression and perform verification and judgment processing on the Boolean result of the branch content.
[0204] The specific steps are:
[0205] Input Data
[0206] max(3,5)>=min(6,2)
[0207] Perform Boolean logic model operations on the formula, then return the Boolean result to verify whether the Boolean result is true.
[0208] Embodiment three:
[0209] like Figure 3 As shown, the Boolean logic model operation steps are as follows:
[0210] Step 1: Split the operation sequence according to the Boolean operation separator and extract the logical operator sequence;
[0211] In this embodiment, the input numerical expression is segmented, and then each segmented character sequence is extracted to facilitate subsequent processing.
[0212] The specific steps are:
[0213] ① Determine whether the logical string sequence contains the logical operator || or &&.
[0214] ② If it contains, add the logical operator || or && to split the empty string, and then perform the empty string split logical operator sequence.
[0215] For example,
[0216] Enter the numeric expression true||true||max(5,3)>0||6>=2||1<=min(5,3)-2
[0217] The formula contains || or &&.
[0218] Add empty strings to the || and && parts of the formula.
[0219] true||true||max(5,3)>0||6>=2||1<=min(5,3)-2
[0220] ->
[0221] true||true||max(5,3)>0||6>=2||1<=min(5,3)-2
[0222] Then extract the logical operator sequence by splitting on the empty string.
[0223] true||true||max(5,3)>0||6>=2||1<=min(5,3)-2
[0224] Perform the split extraction operation, and the split operator after extraction is as follows:
[0225] ①true②||③true④||⑤max(5,3)>0⑥||⑦6>=2⑧||
[0226] ⑨1<=min(5,3)-2
[0227] Step 2: Traverse each splitting logical operator, if it is || or &&, push it into the storage stack, if not, determine whether it contains comparison operators >=, <=, >, <, etc. If it does, perform a comparison logic model operation, and push the returned Boolean result into the storage stack. If it does not exist, perform a Boolean value type conversion, and push the calculated Boolean result into the stack.
[0228] In this embodiment, the segmented logical operator sequence is traversed, and then different logical operations are performed according to the keywords, and finally the Boolean result of the operation is pushed into the stack to facilitate subsequent processing.
[0229] The specific steps are:
[0230] For example,
[0231] Initialize the storage stack data structure stack.
[0232] The split string sequence is as follows:
[0233] ①max(5,3)>0②||③true
[0234] The first expression max(5,3)>0 does not belong to || or &&, and the expression contains the comparison operator >, so the comparison logic model operation is performed and the returned Boolean result true is pushed into the stack.
[0235] The second formula belongs to || and &&, so it is directly pushed into the storage stack.
[0236] The third expression true does not belong to ||, &&, and the expression does not contain comparison operators. Remember to convert the Boolean type true->true, and then push the Boolean result into the storage stack.
[0237] Step 3: Perform a combined Boolean calculation on the elements in the stack and return the final Boolean result.
[0238] In this embodiment, there are only four elements in the stack, namely ||, &&, true, and false. They are popped out of the stack in sequence to perform || and && logical operations, and then the final Boolean result is returned.
[0239] The specific steps are:
[0240] For example,
[0241] The elements in the stack are as follows:
[0242] true, ||, false, ||, true, &&, false
[0243] Because && has a higher priority, the && operation should be performed first, and then the Boolean result of the operation should replace the corresponding && operation.
[0244] Use 1 queue to store intermediate results.
[0245] The steps are as follows:
[0246] Set the initial value flag = false, false represents the logical || operation, true represents the && operation.
[0247] Loop through the elements in the stack and perform logical || and && operations.
[0248] First pop the element from the stack and determine whether it is a logical operator ||, && or a Boolean value true, false.
[0249] If it is a Boolean value, continue to take elements from the stack.
[0250] Determine whether the element taken out is || or &&. If it is &&, temporarily store the flag flag = true.
[0251] Then take out the element in the stack. If flag == true at this time, then directly perform the logical && operation and store the intermediate result.
[0252] If flag == false at this time, then take out the element in the stack again, and judge whether the element taken out is || or &&. If it is &&, then take out the element in the stack again. Then perform && operation on the middle Boolean values, and then store the starting element and the result of && operation as the intermediate result. If the element taken out is ||, then perform || operation on the element taken out before, and then store the element taken out this time and the result of || operation as the intermediate result.
[0253] Then keep looping and taking out, and perform Boolean operation according to the above steps.
[0254] Returns the result of a Boolean operation.
[0255] Embodiment 4:
[0256] like Figure 4 As shown, the operation steps of the comparative logic model are as follows:
[0257] Step 1: Use comparison operators to split and initialize arrays of the same length to cache the results of each expression of the corresponding split comparison operator;
[0258] In this embodiment, the logical string sequence is first segmented according to the operator, and then the segmented strings are stored in a temporary result array to facilitate subsequent comparison operation processing.
[0259] The specific steps are:
[0260] ① Determine whether it contains comparison operators >=, <=, >, <, etc., and then initialize a temporary intermediate result array with an array length of 3.
[0261] ②Then split the numerical expression according to the operator.
[0262] For example,
[0263] Formula (max(5,3)+2)-1<=(min(5,3)-2*3)+8
[0264] The formula contains the comparison operator <=, and then fills in an empty string.
[0265] (max(5,3)+2)-1<=(min(5,3)-2*3)+8
[0266] ->
[0267] (max(5,3)+2)-1<=(min(5,3)-2*3)+8
[0268] Then the segmentation is performed according to the empty string, and the logical sequence after segmentation is as follows:
[0269] ①(max(5,3)+2)-1②<=③(min(5,3)-2*3)+8
[0270] Store these three formulas in the intermediate result array respectively.
[0271] Step 2: For each split comparison operator expression, use the suffix and function expression logic model to calculate and process to return the corresponding expression result, and then replace the elements in the intermediate result array;
[0272] In this embodiment, each element is traversed to determine whether it is a comparison operator. If not, the corresponding logical operation is performed, the result is returned, and then the element with the corresponding index is replaced.
[0273] The specific steps are:
[0274] ① Determine whether the element is a comparison operator. If yes, skip it. If not, perform logical operation.
[0275] ②The result of the logical operation replaces the array element at the index position.
[0276] For example,
[0277] Array elements
[0278] ①(max(5,3)+2)-1②<=③(min(5,3)-2*3)+8
[0279] The result of the logical operation of the formula (max(5,3)+2)-1 is 6
[0280] The result of the logical operation of the formula (min(5,3)-2*3)+8 is 5
[0281] So the elements in the final intermediate result array are stored as follows:
[0282] ①6②<=③5
[0283] In this embodiment, each element is traversed to determine whether it is a comparison operator. If not, the corresponding logical operation is performed, the result is returned, and then the element with the corresponding index is replaced.
[0284] The specific steps are:
[0285] ① Determine whether the element is a comparison operator. If yes, skip it. If not, perform logical operation.
[0286] ②The result of the logical operation replaces the array element at the index position.
[0287] For example,
[0288] Array elements
[0289] ①(max(5,3)+2)-1②<=③(min(5,3)-2*3)+8
[0290] The result of the logical operation of the formula (max(5,3)+2)-1 is 6
[0291] The result of the logical operation of the formula (min(5,3)-2*3)+8 is 5
[0292] So the elements in the final intermediate result array are stored as follows:
[0293] ①6②<=③5
[0294] Step 3: Perform comparison operations on the elements in the intermediate results and return the Boolean result after calculation.
[0295] In this embodiment, all elements are first taken out, and then the corresponding comparison operation is performed according to the comparison operator with index position 2, and the result is returned.
[0296] The specific steps are:
[0297] ① Perform corresponding comparison operations according to the comparison operator.
[0298] ②Return the Boolean result of the operation.
[0299] For example,
[0300] If the comparison operation is >=, then the comparison operation temp[0]>=temp[1] is performed
[0301] If the comparison operation is >, then the comparison operation temp[0]>temp[1] is performed
[0302] If the comparison operation is <=, then the comparison operation temp[0]<=temp[1] is performed.
[0303] If the comparison operation is <, then the comparison operation temp[0] is performed. <temp[1]
[0304] Returns the result of a comparison Boolean operation.
[0305] Embodiment five:
[0306] like Figure 5 As shown, the operation steps of the suffix and function expression logic model are as follows:
[0307] Step 1: Use regular expressions to determine whether the logical string sequence is a numeric sequence. If so, return the result directly.
[0308] The specific steps are:
[0309] Determine whether it is a digital sequence
[0310] For example,
[0311] ①3->3
[0312] ②(max(5,3)+2)-1
[0313] ③9-8*min(5,6)+max(3,6)+min(5,7)+(3*4-1)
[0314] If the first formula is a numeric sequence, the result 3 is returned directly. If the other two formulas are not numeric sequences, subsequent processing is required.
[0315] Step 2: Add spaces around all operators to facilitate string segmentation;
[0316] In this embodiment, a separation space string is first added to the left and right of the operator, such as + / *%, () and the like.
[0317] The specific steps are:
[0318] For example,
[0319] ①(max(5,3)+2)-1
[0320] ->
[0321] (max(5,3)+2)-1
[0322] ②9-8*min(5,6)+max(3,6)+min(5,7)+(3*4-1)
[0323] ->
[0324] 9-8*min(5,6)+max(3,6)+min(5,7)+(3*4-1)
[0325] Step 3: Convert the string sequence into an intermediate expression for subsequent processing;
[0326] In this embodiment, the sequence of numerical function character strings in the numerical expression is converted to facilitate subsequent operations.
[0327] The specific steps are:
[0328] ① Initialize the arithmetic operator stack and the string array where the infix expression is finally stored.
[0329] ② Split the string by spaces, and then traverse the split string sequence.
[0330] ③If the split string is `,`, it means it is `,` in the digital function, get the last element of the arithmetic operator stack, and then store the element in the string array.
[0331] ④ If the split string is `(`, determine whether the string array contains at least one element, then push the last element in the string array into the operator stack. If the string array has at least one element and the element is a numeric function, remove the last element of the string array and then save `(` to the string array.
[0332] ⑤ If the split string is `)`, if at least one of the elements of the string array and the stack and the last element in the stack is a numeric function, pop the element in the stack, then save the element in the string array, and then save `)` in the string array. If the above conditions are not met, determine whether the stack element size is greater than 0. If it is greater than 0, pop the element and then save `)` in the string array.
[0333] ⑥If the string does not belong to the above situation, save the split string into a string array.
[0334] ⑦ Use space strings to merge and concatenate string arrays and remove trailing spaces to return an infix expression string sequence.
[0335] For example,
[0336] ①(max(5,3)+2)-1
[0337] ->
[0338] ((5max3)+2)-1
[0339] ②9-8*min(5,6)+max(3,6)+min(5,7)+(3*4-1)
[0340] ->
[0341] 9-8*(5min6)+(3max6)+(5min7)+(3*4-1)
[0342] Step 4: Convert the converted infix expression into a postfix expression for subsequent calculations;
[0343] In this embodiment, the infix expression is converted into a postfix expression to facilitate subsequent operations.
[0344] The specific steps are:
[0345] ①Initialize the suffix expression array and operator stack.
[0346] ② Split the infix expression string sequence by space string, and then traverse it.
[0347] ③ First push the slowest operator of the fixed constant into the operator stack.
[0348] ③If the split string sequence is a digital sequence, save the element sequence to the suffix expression array.
[0349] ④If the split string sequence is `(`, push `(` into the operator stack.
[0350] ⑤If the split string sequence is `)`, loop through the operator stack, pop the top element of the operator stack first, if the element is equal to `(`, exit the loop, if it is not equal to `(`, save the element to the suffix expression array.
[0351] ⑥ If the split string is not the above situation, if the priority of the split string sequence (the string sequence may be +- / % or a numeric function, `(`, etc.) is less than the priority of the top element of the stack, push the split string sequence into the operator stack.
[0352] ⑦ If the priority is greater than or equal to the priority, loop through the operator stack and determine whether the priority of the top element of the operator stack is less than the priority of the split string. If it is, pop the element and save it in the suffix expression array. Loop until the priority of the top element of the stack is greater than the priority of the split string. Then push the split string into the operator stack.
[0353] ⑧After traversing the infix string sequence, loop through the operator stack, with the cutoff condition that the element of the operator stack is equal to the constant slowest operator. Pop each element in the operator and save it to the postfix expression array.
[0354] ⑨Return the suffix expression sequence array.
[0355] For example,
[0356] ①((5max3)+2)-1
[0357] ->
[0358] (5->3->max->2->+->1->-)
[0359] ②9-8*(5min6)+(3max6)+(5min7)+(3*4-1)
[0360] ->
[0361] >8->5->6->min->*->-->3->6->max->+->5->7->min->+->3->4->*->1->-->+)
[0362] Step 5: Operate the suffix expression sequence array and return the logical operation result.
[0363] In this embodiment, the infix expression sequence array is operated and the operation result is returned.
[0364] The specific steps are:
[0365] ① Initialize the operator stack and start traversing the suffix expression sequence array.
[0366] ② Determine whether the string element is a digital sequence. If so, push it into the operator stack.
[0367] ③If not, determine whether the string element is a numeric function (there are two cases, the number of function parameters is 1 or 2). If the number of parameters is only 1, pop the top element of the operator stack, perform numeric operations through the string element (numeric function) and the top element of the stack, and then push the operation result into the operator stack.
[0368] ④ If there are two parameters, pop the top two elements of the operator stack, perform digital operations on the string element (numeric function) and the top two elements, and then push the operation result into the operator stack.
[0369] ⑤After the traversal is completed, the result of the element at the top of the operator stack is returned.
[0370] For example,
[0371] ①(5->3->max->2->+->1->-)
[0372] ->6
[0373] ②(9->8->5->6->min->*->-->3->6->max->+->5->7->min->+->3->4->*->1->-->+)
[0374] ->-9
[0375] The main purpose is to determine whether the value of a field in a form meets specific conditions, so as to determine whether the filled content meets expectations, or to find qualified units (such as enterprises, individuals, organizations, etc.). This method encodes forms, fields, and field contents to record their corresponding information. According to the incoming formula expressions and the corresponding mapping content, regular expressions, stacks, string matching and segmentation, suffix expressions and other algorithms and data structures are used to perform model operations and verify whether the content rules are compliant and within the specified thresholds and limits. It can better maintain indicator relationships, reduce the complexity of indicator variable relationships, reduce the disk space occupied by maintenance content, reduce the CPU computing power brought by verification, reduce user operations, and make the guidance method clearer, thereby bringing users a better operation method and experience.
[0376] The present invention and its embodiments are described above, and such description is not restrictive. What is shown in the full text is only one of the embodiments of the present invention, and the actual structure is not limited thereto. In short, if ordinary technicians in the field are inspired by it, without departing from the purpose of the invention, they can design a structure and embodiment similar to the technical solution without creativity, which should belong to the protection scope of the present invention.< / randomcount> < / maxcount> < / alia> < / name> < / count> < / count> < / randomcount> < / maxcount> < / alia> < / name> < / count> < / index1> < / alia> < / name> < / index1> < / alia> < / name> < / count> < / indexname>
Claims
1. A data query and analysis method, characterized in that: It includes if logic model operation, withoutif logic model operation, Boolean logic model operation, comparison logic model operation and suffix and function expression logic model operation, and transforms the formula expression F into a numerical expression D through regular matching and hash mapping numerical operation mode dop. The numerical expression is composed of a Boolean function expression B and a logic function expression L through the logic operation lop. The Boolean values returned by each function expression are obtained by calculating the value of each function expression, and then the Boolean logic model operation is performed to obtain the final Boolean value of the input expression. The relationship is as follows: D = dop(F); dop(F)=(B|L)lop(B|L); B=BF(opD,opD); L = (DF|opD)rop(DF|opD); The rop is a relational operator, the BF is a Boolean function, the DF is a digital function, and the opD is a specific number or numerical function; The if logic model operation steps are as follows: Step 1: Convert the formula expression to a numerical expression; Step 2: Process the Boolean function module in the numerical expression and replace the corresponding formula with the Boolean function result; Step 3: Use the if / elseif / else keywords to extract the string sequence of the judgment logic from the string sequence in the numerical expression. Step 4: Extract different branch contents according to whether the if / elseif adjustment is true; Step 5: Process the branch content, perform Boolean model processing on the branch content, and perform verification and judgment processing on the Boolean result of the branch content; The withoutif logic model operation steps are as follows: Step 1: Convert the formula expression to a numerical expression Step 2: Process the Boolean function module in the numerical expression and replace the corresponding formula with the Boolean function result Step 3: Perform Boolean model processing on the numerical expression and perform truth verification on the Boolean result of the branch content; The Boolean logic model operation steps are as follows: Step 1: Split the operation sequence according to the Boolean operation separator and extract the logical operator sequence; Step 2: Traverse each splitting logical operator, if it is || or &&, push it into the storage stack, if not, determine whether it contains a comparison operator symbol, if so, perform a comparison logic model operation, and push the returned Boolean result into the storage core, if not, perform a Boolean value type conversion, and push the calculated Boolean result into the stack; Step 3: Perform a combined Boolean calculation on the elements in the stack and return the final Boolean result; The comparative logic model operation steps are as follows: Step 1: Use comparison operators to split and initialize arrays of the same length to cache the results of each expression of the corresponding split comparison operator; Step 2: For each split comparison operator expression, use the suffix and function expression logic model to calculate and process to return the corresponding expression result, and then replace the elements in the intermediate result array; Step 3: Perform comparison operations on the elements in the intermediate results and return the Boolean result after calculation; The operation steps of the suffix and function expression logic model are as follows: Step 1: Use regular expressions to determine whether the logical string sequence is a numeric sequence. If so, return the result directly. Step 2: Add spaces around all operators to facilitate string segmentation; Step 3: Convert the string sequence into an intermediate expression for subsequent processing; Step 4: Convert the converted infix expression into a postfix expression for subsequent calculations; Step 5: Operate the suffix expression sequence array and return the logical operation result.
2. A data query and analysis method according to claim 1, characterized in that: The dop is a numerical operation, and the lop is a logical operator.
3. A data query and analysis method according to claim 1, characterized in that: The step 1 is to first perform regular matching on the formula expression, then transform each variable name, map the transformed variable name and the input hash storage data, and generate a numerical logic expression.
4. A data query and analysis method according to claim 1, characterized in that: The step 2 is to determine whether there is a Boolean function in the formula, intercept the Boolean function expression string, and perform Boolean function matching processing on the string sequence to obtain the function operation result of the Boolean function expression, and then replace the numerical expression.
