Formula identification method and device, terminal equipment and storage medium

文档序号:49489 发布日期:2021-09-28 浏览:36次 中文

阅读说明:本技术 公式识别方法、装置、终端设备及存储介质 (Formula identification method and device, terminal equipment and storage medium ) 是由 刘涛 于 2021-06-30 设计创作,主要内容包括:本申请适用于人工智能技术领域,提供了一种公式识别方法、装置、终端设备及存储介质,该方法包括:响应于获取到计算公式,检测计算公式中的变量名;按照预设转换规则,将变量名转换成目标字符,以及在计算公式中将变量名替换成转换得到的目标字符;从计算公式中识别出目标函数,以及采用目标函数对应的解析规则对识别得到的目标函数进行解析,得到解析后公式;按照预设排列规则,将解析后公式中的各字符组合成字符序列;将字符序列中的目标字符替换成相应变量名下的取值,执行与计算公式相符的计算,实现对计算公式进行识别。此外,本申请还涉及区块链技术。(The application is applicable to the technical field of artificial intelligence, and provides a formula identification method, a formula identification device, terminal equipment and a storage medium, wherein the method comprises the following steps: detecting a variable name in the calculation formula in response to acquiring the calculation formula; converting the variable name into a target character according to a preset conversion rule, and replacing the variable name with the converted target character in a calculation formula; identifying a target function from the calculation formula, and analyzing the identified target function by adopting an analysis rule corresponding to the target function to obtain an analyzed formula; combining all characters in the analyzed formula into a character sequence according to a preset arrangement rule; and replacing the target character in the character sequence with the value under the corresponding variable name, executing the calculation which is consistent with the calculation formula, and realizing the identification of the calculation formula. In addition, the application also relates to a block chain technology.)

1. A formula identification method, the method comprising:

detecting a variable name in a calculation formula in response to acquiring the calculation formula;

converting the variable name into a target character according to a preset conversion rule, and replacing the variable name with the converted target character in the calculation formula;

identifying a target function from the calculation formula, and analyzing the identified target function by adopting an analysis rule corresponding to the target function to obtain an analyzed formula;

combining all characters in the analyzed formula into a character sequence according to a preset arrangement rule;

and replacing the target character in the character sequence with a value under a corresponding variable name, and executing calculation conforming to the calculation formula to realize the identification of the calculation formula.

2. The formula identification method of claim 1, further comprising:

acquiring a new function input by a user and a function operator of the new function;

generating a newly added analysis rule aiming at the newly added function according to the function operational character and a preset general rule;

and associating the new function with the new analysis rule, and determining the new function associated with the new analysis rule as a target function for storage.

3. The formula identification method of claim 2, wherein the general rule comprises any one or more of:

connecting all characters in the newly added function by adopting a connector and then accessing a function operational character of the newly added function at the tail end;

directly connecting all characters in the newly added function in series and then accessing a function operator of the newly added function at the tail end;

and directly connecting all characters in the newly added function in series and then accessing the function operator of the newly added function at the head.

4. The formula identification method according to claim 3, wherein the generating a new analysis rule for the new function according to the function operator and a preset general rule comprises:

and embedding the function operational characters into the general rule to obtain a newly added analysis rule aiming at the newly added function.

5. The formula identification method according to claim 1, wherein the detecting a variable name in a calculation formula in response to obtaining the calculation formula comprises:

in response to obtaining the calculation formula, determining whether the obtained calculation formula is identified;

if not, executing the detection of the variable name in the calculation formula;

if the character sequences are identified, the character sequences corresponding to the same identified calculation formulas are adopted for calculation, and the obtained calculation formulas are identified.

6. The formula identification method of claim 1, wherein the identifying an objective function from the computational formula comprises:

extracting a function name from the calculation formula and recording the function name as a function name to be identified;

comparing the function name to be identified with a function name of a pre-stored target function;

and if the function name to be identified is consistent with a function name of a pre-stored target function, identifying the function corresponding to the function name to be identified as the target function of which the corresponding function name is consistent with the function name to be identified.

7. The formula identification method according to any of claims 1-6 characterized in that the objective function has function operators; before replacing the target character in the character sequence with the value under the corresponding variable name, executing the calculation conforming to the calculation formula, and realizing the identification of the calculation formula, the method further comprises the following steps:

shifting the function operator and the four operators in the character sequence according to a preset shifting rule; wherein the preset shifting rule comprises any one or more of the following items:

shifting the function operator of the objective function to the tail of all characters corresponding to the objective function;

and shifting the four operators to the ends of two operation objects operated by the four operators.

8. An apparatus for formula recognition, the apparatus comprising:

the formula acquisition unit is used for responding to the acquisition of a calculation formula and detecting a variable name in the calculation formula;

the character replacing unit is used for converting the variable name into a target character according to a preset conversion rule and replacing the variable name into the converted target character in the calculation formula;

the function analysis unit is used for identifying a target function from the calculation formula and analyzing the identified target function by adopting an analysis rule corresponding to the target function to obtain an analyzed formula;

the character combination unit is used for combining all characters in the analyzed formula into a character sequence according to a preset arrangement rule;

and the calculation execution unit is used for replacing the target character in the character sequence with the value under the corresponding variable name, executing the calculation conforming to the calculation formula and realizing the identification of the calculation formula.

9. A terminal device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that the processor implements the steps of the method according to any of claims 1 to 7 when executing the computer program.

10. A computer-readable storage medium, in which a computer program is stored which, when being executed by a processor, carries out the steps of the method according to any one of claims 1 to 7.

Technical Field

The present application relates to the field of artificial intelligence technologies, and in particular, to a formula identification method and apparatus, a terminal device, and a storage medium.

Background

A calculation formula is a general expression method for describing the relationship between objects in nature, which can represent the relationship between the numbers of different objects in nature, and it reflects the relationship between the inside and outside of the objects exactly, and is the basis for we to get from one object to another object, so we can understand the nature and content of the objects better.

Because of continuous acquired training, humans can basically see the inherent logic of a formula at a glance, while computers generally do not have the ability to understand the meaning of a formula at a glance. Therefore, in order to better utilize the advantages of a computer, such as the advantage of high computational efficiency, it is necessary for the computer to identify a calculation formula, so as to provide better calculation services.

Disclosure of Invention

In view of this, embodiments of the present application provide a formula identification method, an apparatus, a terminal device, and a storage medium, so as to solve the problem that a computer cannot effectively identify a calculation formula in the related art.

A first aspect of an embodiment of the present application provides a formula identification method, including:

detecting a variable name in the calculation formula in response to acquiring the calculation formula;

converting the variable name into a target character according to a preset conversion rule, and replacing the variable name with the converted target character in a calculation formula;

identifying a target function from the calculation formula, and analyzing the identified target function by adopting an analysis rule corresponding to the target function to obtain an analyzed formula;

combining all characters in the analyzed formula into a character sequence according to a preset arrangement rule;

and replacing the target character in the character sequence with the value under the corresponding variable name, executing the calculation which is consistent with the calculation formula, and realizing the identification of the calculation formula.

Further, the method further comprises:

acquiring a new function input by a user and a function operator of the new function;

generating a newly added analysis rule aiming at the newly added function according to the function operational character and a preset general rule;

and associating the new function with the new analysis rule, and determining the new function associated with the new analysis rule as a target function for storage.

Further, the generic rules include any one or more of:

connecting all characters in the newly added function by adopting a connector and then accessing a function operator of the newly added function at the tail end;

directly connecting all characters in the newly added function in series and then accessing a function operator of the newly added function at the tail end;

and directly connecting all characters in the newly added function in series and then accessing a function operator of the newly added function at the head.

Further, generating a new analysis rule for the new function according to the function operator and a preset general rule, including:

and embedding the function operational characters into the general rule to obtain a new analysis rule aiming at the new function.

Further, detecting variable names in the calculation formula in response to obtaining the calculation formula includes:

in response to obtaining the calculation formula, determining whether the obtained calculation formula is identified;

if not, executing the detection of the variable name in the calculation formula;

if the character sequences are identified, the character sequences corresponding to the same identified calculation formulas are adopted for calculation, and the obtained calculation formulas are identified.

Further, identifying an objective function from the calculation formula includes:

extracting a function name from the calculation formula and recording the function name as a function name to be identified;

comparing the function name to be identified with a function name of a target function stored in advance;

and if the function name to be identified is consistent with a function name of a pre-stored target function, identifying the function corresponding to the function name to be identified as the target function of which the corresponding function name is consistent with the function name to be identified.

Further, the objective function has function operators; and before replacing the target character in the character sequence with the value under the corresponding variable name, executing the calculation conforming to the calculation formula and realizing the identification of the calculation formula, the method also comprises the following steps:

shifting a function operator and four operators in the character sequence according to a preset shifting rule; wherein the preset shifting rule comprises any one or more of the following items:

shifting the function operational characters of the target function to the tail ends of all characters corresponding to the target function;

and shifting the four operators to the ends of two operation objects operated by the four operators.

A second aspect of an embodiment of the present application provides a formula identifying apparatus, including:

the formula acquisition unit is used for responding to the acquisition of the calculation formula and detecting the variable name in the calculation formula;

the character replacing unit is used for converting the variable name into a target character according to a preset conversion rule and replacing the variable name into the converted target character in a calculation formula;

the function analysis unit is used for identifying a target function from the calculation formula and analyzing the identified target function by adopting an analysis rule corresponding to the target function to obtain an analyzed formula;

the character combination unit is used for combining all characters in the analyzed formula into a character sequence according to a preset arrangement rule;

and the calculation execution unit is used for replacing the target character in the character sequence with the value under the corresponding variable name, executing the calculation conforming to the calculation formula and realizing the identification of the calculation formula.

A third aspect of the embodiments of the present application provides a terminal device, which includes a memory, a processor, and a computer program stored in the memory and executable on the terminal device, where the processor implements the steps of the formula identification method provided in the first aspect when executing the computer program.

A fourth aspect of embodiments of the present application provides a computer-readable storage medium, in which a computer program is stored, and the computer program, when executed by a processor, implements the steps of the formula identification method provided in the first aspect.

The formula identification method, the formula identification device, the terminal equipment and the storage medium have the following beneficial effects that: the variable names in the calculation formula are replaced by the target characters, the calculation formula after the characters are replaced is analyzed into the character sequence, the calculation formula is identified, the calculation complexity of identifying the calculation formula can be reduced due to the fact that the target characters are smaller than the variable name data, the identification efficiency is improved, in addition, the objective functions in various forms in the calculation formula can be analyzed, the calculation formula comprising the objective functions in various forms can be effectively identified, and the practicability is good.

Drawings

In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required to be used in the embodiments or the related technical descriptions will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without inventive exercise.

FIG. 1 is a flowchart illustrating an implementation of a formula identification method according to an embodiment of the present disclosure;

FIG. 2 is a flow chart of another implementation of a formula identification method provided in the embodiments of the present application;

fig. 3 is a block diagram illustrating a formula identifying apparatus according to an embodiment of the present disclosure;

fig. 4 is a block diagram of a terminal device according to an embodiment of the present disclosure.

Detailed Description

In order to make the objects, technical solutions and advantages of the present application more apparent, the present application is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application.

The formula identification method according to the embodiment of the present application may be executed by a control device or a terminal (hereinafter referred to as "terminal device"). When the formula identification method is executed by the terminal equipment, the execution main body is the terminal equipment.

Referring to fig. 1, fig. 1 shows a flowchart of an implementation of a formula identification method provided in an embodiment of the present application, including:

step 101, in response to acquiring a calculation formula, detecting a variable name in the calculation formula.

The above calculation formula may be various calculation formulas. In practice, the calculation formula may include, but is not limited to, at least one of the following operations: addition, subtraction, multiplication, division, averaging, minimum value, etc.

Variable names generally refer to the names of variables. In practice, a calculation formula may have one or more variables, and when the value of a variable changes, the calculation result of the calculation formula usually changes accordingly.

In practice, the variable names in the calculation formula may have a specific format. Taking the formula min [ [ price ], 1000] as an example, "price" is a variable name, "price" is immediately left "[" and immediately right "]", that is, in the formula min [ [ price ], 1000], the format of the variable name is: the left side is immediately adjacent to "[" and the right side is immediately adjacent to "]".

Here, the terminal device may acquire a calculation formula stored in advance, or may acquire a calculation formula currently input by the user. It should be noted that the above calculation formula may be directly stored locally, or may be stored in other electronic devices communicatively connected to the terminal device. When the calculation formula is stored locally, the terminal device may directly extract the locally stored calculation formula for processing. When the calculation formula is stored in other electronic equipment in communication connection with the terminal equipment, the terminal equipment can acquire the calculation formula for processing through a wired connection mode or a wireless connection mode.

After the calculation formula is obtained, the terminal device can obtain the variable name in the calculation formula through the format detection of the variable name.

As an example, if the variable name is in the format: the left side is adjacent to the left side of the variable name, [ "and the right side is adjacent to the left side of the variable name," ] ", and the terminal equipment can detect the variable name in the calculation formula according to the left side adjacent to the left side of the variable name," [ "and the right side adjacent to the right side of the variable name.

As another example, if the variable name is in the format: and the left side is adjacent to the '{' and the right side is adjacent to the '}', the terminal equipment can also detect the left side adjacent to the '{' and the right side adjacent to the '}' of the variable name to obtain the variable name in the calculation formula. The specific format of the variable name is not limited in this embodiment.

And 102, converting the variable name into a target character according to a preset conversion rule, and replacing the variable name with the converted target character in a calculation formula.

The target character is usually a predetermined character. The number of target characters is usually plural. By way of example, there may be 26 target characters, respectively characters A-Z.

The preset conversion rule is a preset rule for converting a variable name into a target character. As an example, the preset conversion rule may be: and sequentially replacing the variable names with target characters according to the appearance sequence of the variable names from first to last. For example, if two variable names, namely "amount" and "period", exist in the calculation formula, the "amount" may be replaced by a, and the "period" may be replaced by B.

For example, if the calculation formula is as follows:

min [ amount ], 10000] if [ period ] > (60, 60, 15 ]/365)

In the calculation formula, the variable with the prior appearance sequence is named as "amount", and the variable with the subsequent appearance sequence is named as "term", and after the variable names are replaced by the target characters in the calculation formula, the obtained calculation formula can be: min [ A, 10000] if [ B > -60, 60, 15 ]/365.

It should be noted that the number of target characters is more than one, for example, 26, so that the complex calculation formula with a plurality of variables can be effectively recognized.

In some alternative implementations, identifying the objective function from the calculation formula may include:

first, a function name is extracted from a calculation formula and recorded as a function name to be recognized.

Here, since the position of the function name generally has a certain format, for example, immediately to the right of the function name "(", the terminal device can extract the function name from the calculation formula based on the position feature of the function name.

Then, the function name to be recognized is compared with the function name of the objective function stored in advance.

Here, there are usually a plurality of objective functions that can be stored in advance, and the terminal device may compare the function name to be recognized with the function name of each stored objective function.

And finally, if the function name to be identified is consistent with the function name of a prestored target function, identifying the function corresponding to the function name to be identified as the target function of which the corresponding function name is consistent with the function name to be identified.

Here, if the function name to be recognized is the same as the function name of a certain stored objective function, the function corresponding to the function name to be recognized is considered to be the stored objective function. The target function in the calculation formula is identified by comparing the function names, so that the target function can be accurately identified.

And 103, identifying a target function from the calculation formula, and analyzing the identified target function by adopting an analysis rule corresponding to the target function to obtain an analyzed formula.

The objective function is usually a preset function, and the objective function usually corresponds to an analysis rule. In practice, the parsing rule of the objective function may be: and connecting characters in the target function by adopting a connector ^ and then accessing a function operator of the target function at the tail end. It is noted that the objective function is typically a function other than the four arithmetic operations. Function operators are typically characters that indicate the type of operation of a function. As an example, the function operator may be "<" to indicate that the operation type of the function is the smallest of a plurality of numbers.

Here, since each objective function has a function name, the terminal device can identify the objective function from the calculation formula by the function name of the objective function. And then, analyzing the target function by adopting an analysis rule corresponding to the target function. And analyzing the target function in the calculation formula to obtain the calculation formula which is the analyzed formula.

As an example, if the objective function is min [ a, b ], the meaning of the objective function is to take the minimum of a, b. If the function operator of the objective function min is "<", then the analyzed objective function may be: a < b >.

As another example, if the objective function is if [ a > ═ b, c, d ], the objective function means that if a > ═ b, then the value is c, otherwise the value is d. If the function operator of the objective function if is greater than or equal to "@", in this case, the analyzed objective function may be: a ^ b ^ c ^ d @.

In practice, the calculation formula may have one objective function or a plurality of different objective functions, and the terminal device may analyze each objective function to obtain an analyzed function of each objective function, and then concatenate the analyzed functions to obtain an analyzed formula.

For example, if the formula to be resolved is as follows:

min[A,10000]*if[B>=60,60,15]/365

the analyzed function obtained by analyzing the target function min may be: a10000 <, the analyzed function obtained by analyzing the target function if can be: b60 ^60^15 @. Finally, the splicing of each analyzed function to obtain an analyzed formula can be as follows: a10000 ^ B60 ^60^15 @/365.

And 104, combining the characters in the analyzed formula into a character sequence according to a preset arrangement rule.

The preset arrangement rule is a rule for arranging characters in a preset formula. In practice, the preset ordering rule may be: the characters are arranged into a character sequence according to the appearance sequence of the characters from first to last.

As an example, if the parsed formula is A10000 ^ B ^60^60^[email protected]/365, the character sequence to combine the characters in the parsed formula can be: [ A, ^10000, <, ^ B, ^60, ^15, @,/, 365 ].

In practical applications, since the connector ^ has no meaning in general, when the connector ^ is included in the formula after the parsing, in order to reduce the data amount needing to be processed, the connector ^ can be deleted directly, and only the character with the calculation meaning in the calculation formula is reserved. For example, if the formula after parsing is: a10000 ^ B60 ^60^[email protected]/365, the obtained character sequence can be: [ A, 10000, <, # B, 60, 60, 15, @,/, 365 ].

And 105, replacing the target character in the character sequence with a value under a corresponding variable name, executing calculation conforming to the calculation formula, and recognizing the calculation formula.

The value under the variable name is generally the value of the variable indicated by the variable name.

Here, the terminal device may directly replace the target character in the character sequence with the value of the corresponding variable, and perform the calculation by using the specific value of the variable, so as to identify the calculation formula.

In the formula identification method provided by the embodiment, the variable name in the calculation formula is replaced by the target character, and the calculation formula after the character replacement is analyzed into the character sequence, so that the calculation formula is identified.

Optionally, the target function has a function operator, and before replacing the target character in the character sequence with a value under a corresponding variable name, performing a calculation corresponding to the calculation formula, and implementing the recognition of the calculation formula, the formula recognition method may further include: and shifting the function operator and the four operators in the character sequence according to a preset shifting rule.

Among them, the four operators are usually symbols indicating to perform one of addition, subtraction, multiplication, and division. In practice, the four operators may include "+", "-", "+", "/".

The predetermined shift rule is generally a predetermined rule for shifting a character. As an example, the preset shift rule may include at least one of the following two items:

firstly, the function operator of the objective function is shifted to the tail of all characters corresponding to the objective function.

And secondly, shifting the four operators to the ends of two operation objects operated by the four operators.

It should be noted that, when a computer performs a calculation, it usually reads data first, and then when a specific operator is read, performs the corresponding operation. For example, when a + b operation is performed by a computer, it is common to read a and b first, then read +, and finally perform an addition operation of a and b. Therefore, function operators and four operators in a character sequence are often required to be moved back before executing a calculation formula that conforms to the calculation formula.

For example, if the character sequence is [ a, 10000, <, B, 60, 60, 15, @,/, 365], the function operator and the four operators in the character sequence are shifted, and the obtained character sequence is: [ A, 10000, <, B, 60, 60, 15, @, 365,/]. At this time, the terminal device may read the characters in the character sequence obtained after the shift in sequence, and perform corresponding calculation by using the value substitution under the variable name corresponding to the target character when reading the target character.

With further reference to fig. 2, fig. 2 is a flowchart illustrating an implementation of another formula identification method according to an embodiment of the present disclosure. As shown in fig. 2, the formula identification method may include the steps of:

step 201, acquiring a new function input by a user and a function operator of the new function.

The user may be a developer or a general user.

The new function may be various functions. As an example, the add function may be max (a, b), which means taking the maximum of a and b. As another example, the newly added function may be ave (a, b), which means taking the average of a and b.

The above function operators are generally characters for indicating the operation type of the function. As an example, the function operator may be "<" to indicate that the operation type of the function is the smallest of a plurality of numbers.

Here, the user may input the new function and a function operator of the new function through the interactive interface. Thus, the terminal device can obtain the new function and the function operator.

Step 202, generating a new analysis rule for the new function according to the function operator and the preset general rule.

The new analysis rule is generally a rule for analyzing a new function.

The general rule is a rule that is set in advance to generate an analysis rule. As an example, the general rules may include: and after all characters in the new function are connected in series, the function operator of the new function is accessed at the tail end.

In practice, the universal rule may include any one or more of the following three items:

firstly, connecting characters in the newly added function by adopting a connector, and then accessing a function operator of the newly added function at the tail end. For example, if the new function is min [ a, b ], the function operator of the new function is "<", and the connector is "<", then the characters may be connected by the connector and then "< -" may be accessed at the tail end, so as to obtain a ^ b <. The connector can be ^ or other symbols.

And secondly, directly connecting all characters in the newly added function in series and then accessing a function operator of the newly added function at the tail end. For example, if the new function is min [ a, b ], and the function operator of the new function is "<", then each character can be directly concatenated and then "<" is connected to the tail end, and ab < ".

And thirdly, directly connecting all characters in the newly added function in series and then accessing a function operator of the newly added function at the head. As an example, if the new function is min [ a, b ], and the function operator of the new function is "<", then the characters may be directly concatenated and then "<" may be accessed to the head, so as to obtain < ab.

Here, the terminal device may generate a new parsing rule for the new function by using the function operator and the common rule

In practical application, if the general rule is that the function operator of the newly added function is accessed at the tail end after characters in the newly added function are connected by adopting a connector, the terminal device may generate a newly added parsing rule for the newly added function in the following manner: and embedding the function operational characters into the general rule to obtain a new analysis rule aiming at the new function. It should be noted that, the direct embedding method is simple and easy to implement, and is helpful to improve the data processing efficiency.

Step 203, associating the new function with the new analysis rule, and determining the new function associated with the new analysis rule as a target function for storage.

Here, the terminal device may associate the new function with the new parsing rule, and then store the new function associated with the new parsing rule as the target function.

And step 204, responding to the acquired calculation formula, and detecting the variable name in the calculation formula.

Step 205, converting the variable name into a target character according to a preset conversion rule, and replacing the variable name with the converted target character in the calculation formula.

And step 206, identifying the target function from the calculation formula, and analyzing the identified target function by adopting an analysis rule corresponding to the target function to obtain an analyzed formula.

And step 207, combining the characters in the analyzed formula into a character sequence according to a preset arrangement rule.

And step 208, replacing the target character in the character sequence with the value under the corresponding variable name, executing the calculation which is consistent with the calculation formula, and realizing the identification of the calculation formula.

In the present embodiment, the specific operations of steps 204-208 are substantially the same as the operations of steps 101-105 in the embodiment shown in fig. 1, and are not repeated herein.

The embodiment can realize the expansion of the target function, is beneficial to realizing the effective identification of more complex calculation formulas, and is beneficial to further improving the practicability of the method.

In an optional implementation manner of each embodiment of the present application, detecting a variable name in a calculation formula in response to acquiring the calculation formula may include the following steps:

step one, responding to the acquisition of the calculation formula, and determining whether the acquired calculation formula is identified.

Here, the terminal device may store the identified calculation formula in advance. When a certain calculation formula is currently acquired, the terminal device may compare the current calculation formula with a stored calculation formula, and if the same calculation formula exists, the currently acquired calculation formula is considered to be identified. Otherwise, the currently obtained calculation formula is considered not to be recognized.

And step two, if the variable name is not identified, executing the detection of the variable name in the calculation formula.

Here, if the currently acquired calculation formula is not recognized, the step of detecting the variable name in the calculation formula is performed. Only the unrecognized calculation formula is recognized, so that the data processing amount can be reduced, and the data processing resources are saved.

Step three: if the character sequences are identified, the character sequences corresponding to the same identified calculation formulas are adopted for calculation, and the obtained calculation formulas are identified.

Here, when the terminal device acquires the identified calculation formula, the terminal device directly adopts the character sequence corresponding to the same previously identified calculation formula to perform calculation, so that the repeated identification process of the same calculation formula can be reduced, and the efficiency of identifying the calculation formula can be improved.

In all embodiments of the present application, the terminal device may detect a variable name in the calculation formula when acquiring the calculation formula. Then, according to a preset conversion rule, converting the variable name into a target character, and replacing the variable name with the converted target character in a calculation formula. And then, identifying the target function from the calculation formula, and analyzing the identified target function by adopting an analysis rule corresponding to the target function to obtain an analyzed formula. And then, according to a preset arrangement rule, combining all characters in the analyzed formula into a character sequence. And finally, replacing the target character in the character sequence with a value under the corresponding variable name, and executing the calculation which is consistent with the calculation formula to realize the identification of the calculation formula. The terminal equipment can upload the calculation formula, the values under each variable name and the calculation result to the block chain, so that the safety and the fair transparency to the user can be ensured. The user equipment may download the data information from the blockchain to verify whether the data information is tampered. The blockchain referred to in this example is a novel application mode of computer technologies such as distributed data storage, point-to-point transmission, consensus mechanism, encryption algorithm, and the like. The block chain (Blockchain), which is essentially a decentralized storage server, is a string of data blocks associated by using a cryptographic method, and each data block contains information of a batch of network transactions, which is used for verifying the validity (anti-counterfeiting) of the information and generating a next block. The blockchain may include a blockchain underlying platform, a platform product service layer, an application service layer, and the like.

Referring to fig. 3, fig. 3 is a block diagram illustrating a formula recognition apparatus 300 according to an embodiment of the present disclosure. The formula identifying apparatus in this embodiment includes units for performing the steps in the corresponding embodiments of fig. 1 to 2. Please refer to fig. 1 to 2 and fig. 1 to 2 for the corresponding embodiments. For convenience of explanation, only the portions related to the present embodiment are shown. Referring to fig. 3, the formula identifying apparatus 300 includes:

a formula obtaining unit 301, configured to, in response to obtaining a calculation formula, detect a variable name in the calculation formula;

a character replacing unit 302, configured to convert the variable name into a target character according to a preset conversion rule, and replace the variable name into the converted target character in a calculation formula;

a function analyzing unit 303, configured to identify a target function from the calculation formula, and analyze the identified target function by using an analysis rule corresponding to the target function to obtain an analyzed formula;

a character combination unit 304, configured to combine characters in the analyzed formula into a character sequence according to a preset arrangement rule;

and the calculation execution unit 305 is configured to replace the target character in the character sequence with a value under a corresponding variable name, execute a calculation corresponding to the calculation formula, and implement identification of the calculation formula.

As an embodiment of the present application, the apparatus may further include an information storage unit (not shown in the figure).

Wherein the information storage unit may be configured to:

acquiring a new function input by a user and a function operator of the new function;

generating a newly added analysis rule aiming at the newly added function according to the function operational character and a preset general rule;

and associating the new function with the new analysis rule, and determining the new function associated with the new analysis rule as a target function for storage.

As an embodiment of the present application, the general rules may include any one or more of the following:

connecting all characters in the newly added function by adopting a connector and then accessing a function operator of the newly added function at the tail end;

directly connecting all characters in the newly added function in series and then accessing a function operator of the newly added function at the tail end;

and directly connecting all characters in the newly added function in series and then accessing a function operator of the newly added function at the head.

As an embodiment of the present application, the generating, in the information storage unit, a new analysis rule for the new function according to the function operator and a preset general rule may include: and embedding the function operational characters into the general rule to obtain a new analysis rule aiming at the new function.

As an embodiment of the present application, the formula obtaining unit 301 is specifically configured to: in response to obtaining the calculation formula, determining whether the obtained calculation formula is identified; if not, executing the detection of the variable name in the calculation formula; if the character sequences are identified, the character sequences corresponding to the same identified calculation formulas are adopted for calculation, and the obtained calculation formulas are identified.

As an embodiment of the present application, the identifying, in the function analyzing unit 303, the target function from the calculation formula may include:

extracting a function name from the calculation formula and recording the function name as a function name to be identified;

comparing the function name to be identified with a function name of a target function stored in advance;

and if the function name to be identified is consistent with a function name of a pre-stored target function, identifying the function corresponding to the function name to be identified as the target function of which the corresponding function name is consistent with the function name to be identified.

As an embodiment of the application, the objective function has a function operator; and the apparatus may further include a character shifting unit (not shown in the drawings). Wherein the character shifting unit is configured to: shifting a function operator and four operators in the character sequence according to a preset shifting rule; wherein the preset shifting rule comprises any one or more of the following items:

shifting the function operational characters of the target function to the tail ends of all characters corresponding to the target function;

and shifting the four operators to the ends of two operation objects operated by the four operators.

The device provided by the embodiment realizes the identification of the calculation formula by replacing the variable name in the calculation formula with the target character and analyzing the calculation formula after the character replacement into the character sequence, and can reduce the calculation complexity of identifying the calculation formula and be beneficial to improving the identification efficiency because the target character is smaller than the data of the variable name.

It should be understood that, in the structural block diagram of the formula identifying apparatus shown in fig. 3, each unit is used to execute each step in the embodiment corresponding to fig. 1 to fig. 2, and each step in the embodiment corresponding to fig. 1 to fig. 2 has been explained in detail in the above embodiment, and specific reference is made to the relevant description in the embodiments corresponding to fig. 1 to fig. 2 and fig. 1 to fig. 2, which is not repeated herein.

Fig. 4 is a block diagram of a terminal device according to another embodiment of the present application. As shown in fig. 4, the terminal device 400 of this embodiment includes: a processor 401, a memory 402 and a computer program 403, such as a program of a formula identification method, stored in the memory 402 and executable on the processor 401. The processor 401, when executing the computer program 403, implements the steps in the embodiments of the equation recognition methods described above, such as the steps 101 to 105 shown in fig. 1, or the steps 201 to 208 shown in fig. 2. Alternatively, when the processor 401 executes the computer program 403, the functions of the units in the embodiment corresponding to fig. 3, for example, the functions of the units 301 to 305 shown in fig. 3, are implemented, for which reference is specifically made to the relevant description in the embodiment corresponding to fig. 3, which is not described herein again.

Illustratively, the computer program 403 may be divided into one or more units, which are stored in the memory 402 and executed by the processor 401 to accomplish the present application. One or more of the units may be a series of computer program instruction segments capable of performing specific functions, which are used to describe the execution of the computer program 403 in the terminal device 400. For example, the computer program 403 may be divided into a formula obtaining unit, a character replacing unit, a function analyzing unit, a character combining unit, and a calculation executing unit, wherein the specific functions of the units are as described above.

The terminal device may include, but is not limited to, a processor 401, a memory 402. Those skilled in the art will appreciate that fig. 4 is merely an example of a terminal device 400 and does not constitute a limitation of terminal device 400 and may include more or fewer components than shown, or combine certain components, or different components, e.g., a turntable device may also include input output devices, network access devices, buses, etc.

The Processor 401 may be a Central Processing Unit (CPU), other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), an off-the-shelf Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic, discrete hardware components, etc. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.

The storage 402 may be an internal storage unit of the terminal device 400, such as a hard disk or a memory of the terminal device 400. The memory 402 may also be an external storage device of the terminal device 400, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), and the like provided on the terminal device 400. Further, the memory 402 may also include both an internal storage unit of the terminal device 400 and an external storage device. The memory 402 is used for storing computer programs and other programs and data required by the turntable device. The memory 402 may also be used to temporarily store data that has been output or is to be output.

In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.

The integrated module, if implemented in the form of a software functional unit and sold or used as a separate product, may be stored in a computer readable storage medium. The computer readable storage medium may be non-volatile or volatile. Based on such understanding, all or part of the flow in the method of the embodiments described above can be realized by a computer program, which can be stored in a computer readable storage medium and can realize the steps of the embodiments of the methods described above when the computer program is executed by a processor. Wherein the computer program comprises computer program code, which may be in the form of source code, object code, an executable file or some intermediate form, etc. The computer-readable storage medium may include: any entity or device capable of carrying computer program code, recording medium, U.S. disk, removable hard disk, magnetic disk, optical disk, computer Memory, Read-Only Memory (ROM), Random Access Memory (RAM), electrical carrier wave signals, telecommunications signals, software distribution media, and the like. It should be noted that the computer readable storage medium may contain content that is subject to appropriate increase or decrease as required by legislation and patent practice in jurisdictions, for example, in some jurisdictions, computer readable storage media that does not include electrical carrier signals and telecommunications signals in accordance with legislation and patent practice.

The above embodiments are only used to illustrate the technical solutions of the present application, and not to limit the same; although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; such modifications and substitutions do not substantially depart from the spirit and scope of the embodiments of the present application and are intended to be included within the scope of the present application.

16页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:唯一标识的生成方法和装置

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!