CN105630761B - Formula processing method and device - Google Patents
Formula processing method and device Download PDFInfo
- Publication number
- CN105630761B CN105630761B CN201610124782.9A CN201610124782A CN105630761B CN 105630761 B CN105630761 B CN 105630761B CN 201610124782 A CN201610124782 A CN 201610124782A CN 105630761 B CN105630761 B CN 105630761B
- Authority
- CN
- China
- Prior art keywords
- formula
- text
- user
- grammar
- calculation
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
- 238000003672 processing method Methods 0.000 title abstract description 11
- 238000004364 calculation method Methods 0.000 claims description 80
- 238000000034 method Methods 0.000 claims description 28
- 238000007781 pre-processing Methods 0.000 claims description 16
- 238000012545 processing Methods 0.000 claims description 14
- 238000006243 chemical reaction Methods 0.000 claims description 8
- 238000004458 analytical method Methods 0.000 claims description 3
- 230000006870 function Effects 0.000 description 53
- 238000010586 diagram Methods 0.000 description 8
- 230000008569 process Effects 0.000 description 6
- 230000008878 coupling Effects 0.000 description 3
- 238000010168 coupling process Methods 0.000 description 3
- 238000005859 coupling reaction Methods 0.000 description 3
- 238000012986 modification Methods 0.000 description 3
- 230000004048 modification Effects 0.000 description 3
- 238000004891 communication Methods 0.000 description 2
- 230000002452 interceptive effect Effects 0.000 description 2
- 238000007620 mathematical function Methods 0.000 description 2
- 239000003607 modifier Substances 0.000 description 2
- 238000004422 calculation algorithm Methods 0.000 description 1
- 238000013461 design Methods 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 238000012216 screening Methods 0.000 description 1
- 230000001960 triggered effect Effects 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F40/00—Handling natural language data
- G06F40/10—Text processing
- G06F40/166—Editing, e.g. inserting or deleting
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Health & Medical Sciences (AREA)
- Artificial Intelligence (AREA)
- Audiology, Speech & Language Pathology (AREA)
- Computational Linguistics (AREA)
- General Health & Medical Sciences (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Machine Translation (AREA)
Abstract
The embodiment of the invention discloses a kind of formula processing method and devices, after user's input meets the formula text of user's grammer, when the formula text of user's input meets user's grammer, automatically the precompile text for meeting default expression syntax is converted the formula to, and save formula info, to when editing formula, as long as input meets the formula text of user's grammer, formula text can be converted to the text for meeting bottom grammar request by system automatically, to simplify user's operation, facilitate user to edit formula, reduces error rate.
Description
Technical Field
The present invention relates to the field of formula processing technologies, and in particular, to a formula processing method and apparatus.
Background
In banking systems, computing is an essential task for business personnel. At present, a common practice of a salesman is to edit a formula by using an expression language, that is, the salesman edits a calculation logic into an expression according to the syntax of a target expression language (such as OGNL, SPEL, and the like), and after the editing is completed, the target expression language is triggered to complete the calculation. The inventor finds that the existing formula processing method requires a salesman to be familiar with the knowledge of the underlying grammar, and is inconvenient to use and easy to make mistakes.
Disclosure of Invention
The invention aims to provide a formula processing method and a formula processing device, which are convenient for a user to edit a formula and reduce the error rate.
In order to achieve the purpose, the invention provides the following technical scheme:
a formula processing method, comprising:
receiving a formula text input by a user;
judging whether the formula text conforms to user grammar;
if the formula text conforms to the user grammar, converting the formula text into a precompiled text conforming to a preset expression grammar;
generating and storing formula information, wherein the formula information comprises: formula ID, calculation mode, the precompiled text and calculation accuracy.
In the above method, preferably, the determining whether the formula text conforms to the user grammar includes:
preprocessing the formula text, and converting Chinese punctuation characters in the formula text into English punctuation characters;
reading the character string obtained after preprocessing word by word, judging whether the read word is a keyword or a self-defined variable or not when reading one word, and if so, determining that the read word is in accordance with user grammar; otherwise, determining that the formula text does not conform to the user grammar.
In the above method, preferably, if the formula text conforms to a user grammar, the converting the formula text into a precompiled text conforming to a preset expression grammar includes:
if the read word is a keyword, acquiring configuration information corresponding to the read word;
and analyzing the read words based on an analyzer defined in the configuration information so as to convert the formula text into a precompiled text conforming to the preset expression grammar.
The above method, preferably, further comprises:
and saving formula text which is input by a user and conforms to the grammar of the user.
The above method, preferably, further comprises:
receiving a formula ID and calculation parameters input by a user;
obtaining formula information based on the formula ID;
if the calculation mode is formula calculation, calling a calculator which accords with the preset expression grammar, and transmitting the precompiled text and calculation parameters to the calculator;
if the calculation mode is function calculation, determining a reflection calling function according to the name of the function, the name of the class to which the function belongs and the calculation parameters, and reflecting and calling the determined reflection calling function.
An equation processing apparatus comprising:
the first receiving module is used for receiving a formula text input by a user;
the judging module is used for judging whether the formula text conforms to the user grammar;
the conversion module is used for converting the formula text into a precompiled text which accords with the grammar of a preset expression if the formula text accords with the grammar of a user;
an information generating module, configured to generate formula information, where the formula information includes: formula ID, calculation mode, the precompiled text and calculation accuracy.
Preferably, the above apparatus, wherein the judging module includes:
the preprocessing unit is used for preprocessing the formula text and converting Chinese punctuation characters in the formula text into English punctuation characters;
the judging unit is used for reading the character strings obtained after the preprocessing word by word, judging whether the read words are keywords or custom variables or not when one word is read, and determining that the read words conform to the user grammar if the read words are the keywords or the custom variables; otherwise, determining that the formula text does not conform to the user grammar.
The above apparatus, preferably, the conversion module includes:
an acquisition unit configured to acquire configuration information corresponding to the read word if the read word is a keyword;
and the analysis unit is used for analyzing the read words based on an analyzer defined in the configuration information so as to convert the formula text into a precompiled text which accords with a preset expression grammar.
The above apparatus, preferably, further comprises:
and the storage module is used for storing the formula text which is input by the user and accords with the grammar of the user.
The above apparatus, preferably, further comprises:
the second receiving module is used for receiving the formula ID and the calculation parameters input by the user;
the acquisition module is used for acquiring formula information based on the formula ID;
the first calculation module is used for calling a calculator which accords with the grammar of the preset expression if the calculation mode is formula calculation, and transmitting the precompiled text and the calculation parameters to the calculator;
and the second calculation module is used for determining a reflection calling function according to the function name, the class name of the function and the calculation parameter if the calculation mode is function calculation, and reflecting and calling the determined reflection calling function.
According to the scheme, after the formula text which accords with the user grammar is input by the user, the formula is automatically converted into the precompiled text which accords with the preset expression grammar when the formula text which is input by the user accords with the user grammar, and the formula information is stored, so that when the formula is edited, the system can automatically convert the formula text into the text which accords with the requirement of the bottom grammar as long as the formula text which accords with the user grammar is input, the user operation is simplified, the formula is conveniently edited by the user, and the error rate is reduced.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
FIG. 1 is a flowchart of an implementation of a formula processing method according to an embodiment of the present disclosure;
FIG. 2 is a flowchart illustrating an implementation of determining whether a received formula text conforms to a user grammar according to an embodiment of the present disclosure;
fig. 3 is a flowchart illustrating an implementation of converting a formula text into a precompiled text conforming to a preset expression grammar if the formula text conforms to a user grammar according to an embodiment of the present application;
FIG. 4 is an exemplary diagram of a formula editing window provided in an embodiment of the present application;
FIG. 5 is a schematic structural diagram of a formula processing apparatus according to an embodiment of the present disclosure;
fig. 6 is a schematic structural diagram of a determining module according to an embodiment of the present disclosure;
fig. 7 is a schematic structural diagram of a conversion module according to an embodiment of the present application.
The terms "first," "second," "third," "fourth," and the like in the description and in the claims, as well as in the drawings described above, if any, are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It should be understood that the data so used may be interchanged under appropriate circumstances such that embodiments of the application described herein may be practiced otherwise than as specifically illustrated.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be obtained by a person skilled in the art without inventive effort based on the embodiments of the present invention, are within the scope of the present invention.
Referring to fig. 1, fig. 1 is a flowchart illustrating an implementation of a formula processing method according to an embodiment of the present disclosure, where the method includes:
step S11: receiving a formula text input by a user;
in the embodiment of the invention, when the user edits the formula text, the formula text needs to be input according to the user grammar. The user grammar is a grammar which is easy for a user to understand and memorize and is irrelevant to the bottom-layer grammar.
Step S12: judging whether the received formula text conforms to user grammar;
in the embodiment of the invention, the formula text can be converted into the pre-compiled text only by inputting the formula text according to the user grammar.
Step S13: if the received formula text conforms to the user grammar, converting the formula text into a precompiled text conforming to a preset expression grammar;
the precompiled text contains the function name and the name of the class to which the function belongs.
And if the received formula text does not accord with the grammar of the user, outputting prompt information to prompt the error position, the error reason and the like. The precompiled text obtained by conversion is a formula which accords with the grammar of the preset expression.
For example, when the add (1,2) is input by the user, the system converts the add (1,2) into a format conforming to the OGNL grammar, such as: @ com. ljy. op @ add (new bigddemimal ("1"), new bigddemimal ("2")).
Step S14: generating and storing formula information, wherein the formula information comprises: formula ID, calculation mode, precompiled text, calculation accuracy and other main information. The formula information can also comprise auxiliary information such as last modifier information, last modification time and the like.
Generally, the calculation mode includes a formula calculation mode and a function calculation mode. In the embodiment of the invention, the formula calculation mode defined by the user through the interactive interface is the formula calculation mode.
After the precompiled text is obtained, formula information may be generated and saved to facilitate invoking the formula.
According to the formula processing method provided by the embodiment of the invention, after the formula text conforming to the grammar of the user is input by the user, the formula is automatically converted into the precompiled text conforming to the grammar of the preset expression, and the formula information is stored. When a user edits a formula, the system can automatically convert the formula text into the text meeting the requirement of the bottom grammar as long as the formula text meeting the grammar of the user is input, so that the user operation is simplified, the user can edit the formula conveniently, and the error rate is reduced.
Optionally, an implementation flowchart for determining whether the received formula text conforms to the user grammar, provided by the embodiment of the present invention, is shown in fig. 2, and may include:
step S21: preprocessing a formula text, and converting Chinese punctuation characters in the formula text into English punctuation characters;
in the embodiment of the invention, the user is allowed to input Chinese punctuation characters, namely the user is allowed to input punctuation characters and the like in a full-angle state, which is convenient for the user to operate. That is to say, in the embodiment of the present invention, the user does not need to pay attention to whether the current input state is the half-angle input state or the full-angle input state, and the user may input punctuation characters in the full-angle state or in the half-angle state. Further simplifying user operation.
Specifically, the chinese punctuation characters can be converted into english punctuation characters according to a preset correspondence between the chinese punctuation characters and the english punctuation characters. For example, if a user inputs a comma of a chinese punctuation in a formula text, ", the comma of the chinese punctuation in the formula text is" replaced with a comma of an english punctuation "", according to a correspondence between a preset chinese punctuation character and an english punctuation character; similarly, if the user inputs the brackets "()" of the Chinese punctuation in the formula text, the brackets "()" of the Chinese punctuation in the formula text are replaced by the brackets "()" of the English punctuation according to the corresponding relationship between the preset Chinese punctuation character and the English punctuation character.
Step S22: reading the character string obtained after preprocessing word by word, judging whether the read word is a keyword or a self-defined variable or not when reading one word, and if so, determining that the read word is in accordance with user grammar; otherwise, determining that the formula text does not conform to the user grammar.
Specifically, in the embodiment of the present invention, the keywords may be divided into two categories, where one category of keywords starts with letters and consists of letters, or consists of letters and numbers, such as function names; the other class begins with non-letters, such as numbers, operators, brackets, and the like. The user-defined variable is named by a user, the system cannot be defined, and the naming rule is consistent with the first type of keywords.
Based on the above definition of the keywords, in the embodiment of the present invention, in the process of identifying the keywords, it may be determined according to whether the initial is a letter:
if the read word is started with a letter, reading a complete word, judging whether the word is a system-defined keyword (mainly a system-defined function) or not, if so, determining that the word meets the grammar requirement of the user, and otherwise, processing the read word as a self-defined variable. In embodiments of the present invention, the user-defined variables are also started with letters.
If the read word is not started by letters, judging whether the character is a system-defined keyword (mainly including numbers, operators, brackets and the like), if so, determining that the word meets the grammatical requirement of the user, otherwise, determining that the preprocessed character string does not meet the grammatical requirement of the user.
After the read word is determined to meet the user grammar requirement, the next word can be continuously read, whether the read word is the keyword or not is judged according to the method, and the character string obtained after preprocessing is read completely.
Of course, if it is determined that the preprocessed character string does not meet the user grammar requirement and the preprocessed character string has not been read, the next word may not be read.
That is, if the read word is neither a keyword nor a custom variable, the word does not comply with the user grammar requirement, and as long as one word in the preprocessed character string does not comply with the user grammar requirement, the preprocessed character string does not comply with the user grammar requirement.
Optionally, an implementation flowchart for converting the formula text into a pre-compiled text conforming to the preset expression syntax if the formula text conforms to the user syntax provided in the embodiment of the present invention is shown in fig. 3, and may include:
step S31: if the read word is a keyword, acquiring configuration information corresponding to the read keyword;
the configuration information corresponding to the read keyword may be acquired when it is determined that the read word is the keyword. Or reading the configuration information matched with each keyword in the preprocessed character string when the preprocessed character string is determined to meet the grammar requirement of the user.
The configuration information records user syntax and underlying syntax (i.e. preset expression syntax, such as the syntax of OGNL or SPEL expression language).
For example, to define a mathematical function such as bigdecimalAdd, 2 parameters are introduced, and all are BigDecimal type, and implemented by add method of com.
keyword.bigdecimalAdd=functionParser
sysfunc.bigdecimalAdd=@com.ljy.BigDecimalOpUtil@add
funcParmCount.bigdecimalAdd=2
Through these several lines of configuration information, it can be known that:
first row: bigdemelmalad, which is specified as a keyword by keyword, is specified on the left of the equal sign; to the right of the equal sign, a parser which is required to parse the function is specified, and the functionParser is the name of the parser.
A second row: left of the equal sign, sysfunc, bigdimelmalad, which is specified by sysfunc to be a system function; on the right of the equal sign, the @ class full qualified name @ method name is the syntactic format of the OGNL calling method, so that the corresponding class full qualified name com.
Third row: left of the equal sign, funcpammcount, bigdeminiaadd, the number of parameters of bigdeminiaadd is specified through funcpammcount; to the right of the equal sign, 2 parameters are specified for bigdecimalAdd.
With the configuration information, the parser defined in the configuration information can be called to parse the read words. When the parser encounters bigdecimalAdd character string during parsing, it can correctly recognize that the character string is a keyword and is a system function, the number of parameters must be 2, otherwise, the user is prompted to configure a mistake. And (4) successfully analyzing, and calling a specific java method (namely which method of which class) by using the class full qualified name of the second row to obtain a return result of the function.
Step S32: and analyzing the read words based on an analyzer defined in the configuration information so as to convert the formula text into a precompiled text conforming to the preset expression grammar.
Furthermore, after the pre-compiled text is obtained, the original formula text (i.e., the formula text input by the user and conforming to the user grammar) can be saved.
In the embodiment of the invention, the original formula text is saved, which has the following advantages: firstly, because the original formula text is the calculation process set by the service personnel, the specific calculation idea, such as what the formula for looking up a certain fee is specific, can be known by looking up the original formula text. Second, the original formula text can also be used when modifying the formula. Third, the formula is used when it is copied. For example, when a formula is added, it may only need to slightly modify the existing formula, and after the formula is queried through the formula ID or name, etc. in the system, the formula text is confirmed, and then it can be copied and pasted for use. The user operation is simplified.
Optionally, the formula processing method provided in the embodiment of the present invention may further include:
receiving a formula ID and calculation parameters input by a user;
obtaining formula information based on the formula ID, wherein the formula information comprises: formula ID, calculation mode, the precompiled text and calculation accuracy;
if the calculation mode is formula calculation, calling a calculator which accords with the grammar of a preset expression, and transmitting the precompiled text and the calculation parameters to the called calculator;
if the calculation mode is function calculation, determining a reflection calling function according to the function name, the class name of the function and the calculation parameter, and reflecting and calling the determined reflection calling function.
In the embodiment of the invention, in order to facilitate user operation, a formula editing window can be displayed, and the interface of the formula editing window comprises a formula editing frame and a function frame, wherein the function frame is divided into a system function frame, an atomic function frame (namely, a user-defined function frame related to business) and a business variable frame. Fig. 4 is a diagram illustrating an example of a formula editing window according to an embodiment of the present invention.
In the example of FIG. 4, the user double clicks on a function or variable, the function or pass amount will be displayed in the formula edit box, and a single click on the function or variable, the written description of the function or variable will be displayed at the bottom.
The system function, the atomic function and the variable all support the screening function.
Most of the parameters of the function are displayed in Chinese, so that the function is convenient for a user to understand and use, and the user needs to remove Chinese and replace the Chinese with a corresponding value. For the currency and the business variable in the trading place, one item is selected when the business variable is displayed at the first level, the specific value is displayed at the second level of the business variable, and the selected text in the edit box is replaced by double clicking one item.
The variable is supported, the value of the variable can be determined only when in operation, the variable is composed of letters or numbers, and date is a date variable in fig. 4.
The formulas which are already edited and saved can be inquired, and after one of the formulas is selected in the new interface, the formulas are displayed in the edit box in a reverse mode.
Corresponding to the method embodiment, an embodiment of the present invention further provides a formula processing apparatus, and a schematic structural diagram of the formula processing apparatus provided in the embodiment of the present invention is shown in fig. 5, and may include:
a first receiving module 51, a judging module 52, a converting module 53 and an information generating module 54; wherein,
the first receiving module 51 is used for receiving a formula text input by a user;
in the embodiment of the invention, when the user edits the formula text, the formula text needs to be input according to the user grammar. The user grammar is a grammar which is easy for a user to understand and memorize and is irrelevant to the bottom-layer grammar.
The judging module 52 is configured to judge whether the formula text input by the user conforms to the user grammar;
in the embodiment of the invention, the formula text can be converted into the pre-compiled text only by inputting the formula text according to the user grammar.
The conversion module 53 is configured to convert the formula text into a precompiled text that conforms to a preset expression grammar if the formula text conforms to the user grammar;
the precompiled text contains the function name and the name of the class to which the function belongs.
And if the received formula text does not accord with the grammar of the user, outputting prompt information to prompt the error position, the error reason and the like. The precompiled text obtained by conversion is a formula which accords with the grammar of the preset expression.
For example, when the add (1,2) is input by the user, the system converts the add (1,2) into a format conforming to the OGNL grammar, such as: @ com. ljy. op @ add (new bigddemimal ("1"), new bigddemimal ("2")).
The information generating module 54 is configured to generate formula information, which includes: formula ID, calculation mode, generated precompiled text and calculation accuracy.
The formula information can also comprise auxiliary information such as last modifier information, last modification time and the like.
Generally, the calculation mode includes a formula calculation mode and a function calculation mode. In the embodiment of the invention, the formula calculation mode defined by the user through the interactive interface is the formula calculation mode.
After the precompiled text is obtained, formula information may be generated and saved to facilitate invoking the formula.
The formula processing device provided by the embodiment of the invention automatically converts the formula into the precompiled text which accords with the preset expression grammar and stores the formula information when the formula text input by the user accords with the user grammar after the user inputs the formula text which accords with the user grammar. When a user edits a formula, the system can automatically convert the formula text into the text meeting the requirement of the bottom grammar as long as the formula text meeting the grammar of the user is input, so that the user operation is simplified, the user can edit the formula conveniently, and the error rate is reduced.
Optionally, a schematic structural diagram of the determining module 52 provided in the embodiment of the present invention is shown in fig. 6, and may include:
a preprocessing unit 61 and a judgment unit 62; wherein,
the preprocessing unit 61 is configured to preprocess a formula text input by a user, and convert a chinese punctuation character in the formula text into an english punctuation character;
in the embodiment of the invention, the user is allowed to input Chinese punctuation characters, namely the user is allowed to input punctuation characters and the like in a full-angle state, which is convenient for the user to operate. That is to say, in the embodiment of the present invention, the user does not need to pay attention to whether the current input state is the half-angle input state or the full-angle input state, and the user may input punctuation characters in the full-angle state or in the half-angle state. Further simplifying user operation.
Specifically, the chinese punctuation characters can be converted into english punctuation characters according to a preset correspondence between the chinese punctuation characters and the english punctuation characters. For example, if a user inputs a comma of a chinese punctuation in a formula text, ", the comma of the chinese punctuation in the formula text is" replaced with a comma of an english punctuation "", according to a correspondence between a preset chinese punctuation character and an english punctuation character; similarly, if the user inputs the brackets "()" of the Chinese punctuation in the formula text, the brackets "()" of the Chinese punctuation in the formula text are replaced by the brackets "()" of the English punctuation according to the corresponding relationship between the preset Chinese punctuation character and the English punctuation character.
The judging unit 62 is configured to perform word-by-word reading on the preprocessed character string, judge whether the read word is a keyword or a custom variable every time a word is read, and determine that the read word conforms to user grammar if the read word is the keyword or the custom variable; otherwise, determining that the formula text does not conform to the user grammar.
Specifically, in the embodiment of the present invention, the keywords may be divided into two categories, where one category of keywords starts with letters and consists of letters, or consists of letters and numbers, such as function names; the other class begins with non-letters, such as numbers, operators, brackets, and the like. The user-defined variable is named by a user, the system cannot be defined, and the naming rule is consistent with the first type of keywords.
Based on the above definition of the keywords, in the embodiment of the present invention, in the process of identifying the keywords, it may be determined according to whether the initial is a letter:
if the read word is started with a letter, reading a complete word, judging whether the word is a system-defined keyword (mainly a system-defined function) or not, if so, determining that the word meets the grammar requirement of the user, and otherwise, processing the read word as a self-defined variable. In embodiments of the present invention, the user-defined variables are also started with letters.
If the read word is not started by letters, judging whether the character is a system-defined keyword (mainly including numbers, operators, brackets and the like), if so, determining that the word meets the grammatical requirement of the user, otherwise, determining that the preprocessed character string does not meet the grammatical requirement of the user.
After the read word is determined to meet the user grammar requirement, the next word can be continuously read, whether the read word is the keyword or not is judged according to the method, and the character string obtained after preprocessing is read completely.
Of course, if it is determined that the preprocessed character string does not meet the user grammar requirement and the preprocessed character string has not been read, the next word may not be read.
That is, if the read word is neither a keyword nor a custom variable, the word does not comply with the user grammar requirement, and as long as one word in the preprocessed character string does not comply with the user grammar requirement, the preprocessed character string does not comply with the user grammar requirement.
Optionally, a schematic structural diagram of the conversion module 53 provided in the embodiment of the present invention is shown in fig. 7, and may include:
an acquisition unit 71 and an analysis unit 72; wherein,
the obtaining unit 71 is configured to obtain configuration information corresponding to the read word if the read word is a keyword;
the configuration information corresponding to the read keyword may be acquired when it is determined that the read word is the keyword. Or reading the configuration information matched with each keyword in the preprocessed character string when the preprocessed character string is determined to meet the grammar requirement of the user.
The configuration information records user syntax and underlying syntax (i.e. preset expression syntax, such as the syntax of OGNL or SPEL expression language).
For example, to define a mathematical function such as bigdecimalAdd, 2 parameters are introduced, and all are BigDecimal type, and implemented by add method of com.
keyword.bigdecimalAdd=functionParser
sysfunc.bigdecimalAdd=@com.ljy.BigDecimalOpUtil@add
funcParmCount.bigdecimalAdd=2
Through these several lines of configuration information, it can be known that:
first row: bigdemelmalad, which is specified as a keyword by keyword, is specified on the left of the equal sign; to the right of the equal sign, a parser which is required to parse the function is specified, and the functionParser is the name of the parser.
A second row: left of the equal sign, sysfunc, bigdimelmalad, which is specified by sysfunc to be a system function; on the right of the equal sign, the @ class full qualified name @ method name is the syntactic format of the OGNL calling method, so that the corresponding class full qualified name com.
Third row: left of the equal sign, funcpammcount, bigdeminiaadd, the number of parameters of bigdeminiaadd is specified through funcpammcount; to the right of the equal sign, 2 parameters are specified for bigdecimalAdd.
With the configuration information, the parser defined in the configuration information can be called to parse the read words. When the parser encounters bigdecimalAdd character string during parsing, it can correctly recognize that the character string is a keyword and is a system function, the number of parameters must be 2, otherwise, the user is prompted to configure a mistake. And (4) successfully analyzing, and calling a specific java method (namely which method of which class) by using the class full qualified name of the second row to obtain a return result of the function.
The parsing unit 72 is configured to parse the read word based on a parser defined in the obtained configuration information to convert the formula text into a precompiled text conforming to a preset expression syntax.
Optionally, the formula processing apparatus provided in the embodiment of the present invention may further include:
and the storage module is used for storing the original formula text (namely the formula text which is input by the user and accords with the grammar of the user) and the like.
In the embodiment of the invention, the original formula text is saved, which has the following advantages: firstly, because the original formula text is the calculation process set by the service personnel, the specific calculation idea, such as what the formula for looking up a certain fee is specific, can be known by looking up the original formula text. Second, the original formula text can also be used when modifying the formula. Third, the formula is used when it is copied. For example, when a formula is added, it may only need to slightly modify the existing formula, and after the formula is queried through the formula ID or name, etc. in the system, the formula text is confirmed, and then it can be copied and pasted for use. The user operation is simplified.
Optionally, the formula processing apparatus provided in the embodiment of the present invention may further include:
the second receiving module is used for receiving the formula ID and the calculation parameters input by the user;
an obtaining module, configured to obtain formula information based on the formula ID, where the formula information includes: formula ID, calculation mode, the precompiled text and calculation accuracy;
the first calculation module is used for calling a calculator which accords with the grammar of a preset expression if the calculation mode is formula calculation, and transmitting a precompiled text and calculation parameters to the calculator;
and the second calculation module is used for determining a reflection calling function according to the name of the function, the name of the class to which the function belongs and the calculation parameters and reflecting and calling the determined reflection calling function if the calculation mode is function calculation.
Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention.
It is clear to those skilled in the art that, for convenience and brevity of description, the specific working processes of the above-described systems (if any), apparatuses and units may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In the several embodiments provided in the present application, it should be understood that the disclosed system (if present), apparatus, and method may be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the units is only one logical division, and other divisions may be realized in practice, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present invention 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 functions, if implemented in the form of software functional units and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
The previous description of the disclosed embodiments is provided to enable any person skilled in the art to make or use the present invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the invention. Thus, the present invention is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims (6)
1. A method of formula processing, comprising:
receiving a formula text input by a user, wherein the formula text comprises a preset system function and/or an atomic function;
judging whether the formula text conforms to the user grammar, including: preprocessing the formula text, and converting Chinese punctuation characters in the formula text into English punctuation characters; reading the character string obtained after preprocessing word by word, judging whether the read word is a keyword or a self-defined variable or not when reading one word, and if so, determining that the read word is in accordance with user grammar; otherwise, determining that the formula text does not conform to the user grammar;
if the formula text conforms to the user grammar, converting the formula text into a precompiled text conforming to a preset expression grammar, including: if the read word is a keyword, acquiring configuration information corresponding to the read word; analyzing the read words based on an analyzer defined in the configuration information so as to convert the formula text into a precompiled text conforming to a preset expression grammar;
generating and storing formula information, wherein the formula information comprises: formula ID, calculation mode, the precompiled text and calculation accuracy.
2. The method of claim 1, further comprising:
and saving formula text which is input by a user and conforms to the grammar of the user.
3. The method of claim 1, further comprising:
receiving a formula ID and calculation parameters input by a user;
obtaining formula information based on the formula ID;
if the calculation mode is formula calculation, calling a calculator which accords with the preset expression grammar, and transmitting the precompiled text and calculation parameters to the calculator;
if the calculation mode is function calculation, determining a reflection calling function according to the name of the function, the name of the class to which the function belongs and the calculation parameters, and reflecting and calling the determined reflection calling function.
4. An equation processing apparatus, comprising:
the first receiving module is used for receiving a formula text input by a user, wherein the formula text comprises a preset system function and/or an atom function;
the judging module is used for judging whether the formula text conforms to the grammar of the user, and comprises the following steps: the preprocessing unit is used for preprocessing the formula text and converting Chinese punctuation characters in the formula text into English punctuation characters; the judging unit is used for reading the character strings obtained after the preprocessing word by word, judging whether the read words are keywords or custom variables or not when one word is read, and determining that the read words conform to the user grammar if the read words are the keywords or the custom variables; otherwise, determining that the formula text does not conform to the user grammar;
a conversion module, configured to convert the formula text into a precompiled text that conforms to a preset expression grammar if the formula text conforms to a user grammar, including: an acquisition unit configured to acquire configuration information corresponding to the read word if the read word is a keyword; the analysis unit is used for analyzing the read words based on an analyzer defined in the configuration information so as to convert the formula text into a precompiled text conforming to the grammar of a preset expression;
an information generating module, configured to generate formula information, where the formula information includes: formula ID, calculation mode, the precompiled text and calculation accuracy.
5. The apparatus of claim 4, further comprising:
and the storage module is used for storing the formula text which is input by the user and accords with the grammar of the user.
6. The apparatus of claim 4, further comprising:
the second receiving module is used for receiving the formula ID and the calculation parameters input by the user;
the acquisition module is used for acquiring formula information based on the formula ID;
the first calculation module is used for calling a calculator which accords with the grammar of the preset expression if the calculation mode is formula calculation, and transmitting the precompiled text and the calculation parameters to the calculator;
and the second calculation module is used for determining a reflection calling function according to the function name, the class name of the function and the calculation parameter if the calculation mode is function calculation, and reflecting and calling the determined reflection calling function.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201610124782.9A CN105630761B (en) | 2016-03-04 | 2016-03-04 | Formula processing method and device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201610124782.9A CN105630761B (en) | 2016-03-04 | 2016-03-04 | Formula processing method and device |
Publications (2)
Publication Number | Publication Date |
---|---|
CN105630761A CN105630761A (en) | 2016-06-01 |
CN105630761B true CN105630761B (en) | 2019-03-12 |
Family
ID=56045720
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201610124782.9A Active CN105630761B (en) | 2016-03-04 | 2016-03-04 | Formula processing method and device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN105630761B (en) |
Families Citing this family (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN108304383B (en) * | 2018-01-29 | 2019-06-25 | 北京神州泰岳软件股份有限公司 | The formula info extracting method and device of service profile |
CN112347144B (en) * | 2021-01-04 | 2021-05-07 | 树根互联技术有限公司 | Service index query method and device and server |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101187929A (en) * | 2007-12-05 | 2008-05-28 | 浪潮集团山东通用软件有限公司 | Formula definition assembly for flexible mathematical aiming at large data of database table |
CN101329731A (en) * | 2008-06-06 | 2008-12-24 | 南开大学 | Automatic recognition method pf mathematical formula in image |
CN102663138A (en) * | 2012-05-03 | 2012-09-12 | 北京大学 | Method and device for inputting formula query terms |
CN102693303A (en) * | 2012-05-18 | 2012-09-26 | 上海极值信息技术有限公司 | Method and device for searching formulation data |
CN102789486A (en) * | 2012-06-28 | 2012-11-21 | 用友软件股份有限公司 | Formula manipulation device and formula manipulation method for data analysis system |
CN103677852A (en) * | 2013-12-30 | 2014-03-26 | 山东舜德数据管理软件工程有限公司 | Design method of extensible class natural language formula editor |
-
2016
- 2016-03-04 CN CN201610124782.9A patent/CN105630761B/en active Active
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101187929A (en) * | 2007-12-05 | 2008-05-28 | 浪潮集团山东通用软件有限公司 | Formula definition assembly for flexible mathematical aiming at large data of database table |
CN101329731A (en) * | 2008-06-06 | 2008-12-24 | 南开大学 | Automatic recognition method pf mathematical formula in image |
CN102663138A (en) * | 2012-05-03 | 2012-09-12 | 北京大学 | Method and device for inputting formula query terms |
CN102693303A (en) * | 2012-05-18 | 2012-09-26 | 上海极值信息技术有限公司 | Method and device for searching formulation data |
CN102789486A (en) * | 2012-06-28 | 2012-11-21 | 用友软件股份有限公司 | Formula manipulation device and formula manipulation method for data analysis system |
CN103677852A (en) * | 2013-12-30 | 2014-03-26 | 山东舜德数据管理软件工程有限公司 | Design method of extensible class natural language formula editor |
Also Published As
Publication number | Publication date |
---|---|
CN105630761A (en) | 2016-06-01 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US11520975B2 (en) | Lean parsing: a natural language processing system and method for parsing domain-specific languages | |
CN108027833B (en) | Method for creating structured data language query | |
CA3033859C (en) | Method and system for automatically extracting relevant tax terms from forms and instructions | |
US8543913B2 (en) | Identifying and using textual widgets | |
US9047346B2 (en) | Reporting language filtering and mapping to dimensional concepts | |
CA2680306C (en) | Identification of concepts in software | |
AU2019203697A1 (en) | Intelligent data extraction | |
US20180018322A1 (en) | System and method for automatically understanding lines of compliance forms through natural language patterns | |
EP2296094A1 (en) | Document analysis, commenting, and reporting system | |
US20170083615A1 (en) | Robust and Readily Domain-Adaptable Natural Language Interface to Databases | |
TWI661349B (en) | Method and system for generating conversational user interface | |
US11188193B2 (en) | Method and system for generating a prioritized list | |
CN112434501B (en) | Method, device, electronic equipment and medium for intelligent generation of worksheet | |
CN111813680B (en) | Method and device for generating test script, computer equipment and storage medium | |
CN107992523A (en) | The function choosing-item lookup method and terminal device of mobile application | |
CN112420145A (en) | Electronic medical record document data processing method and device and computer readable storage medium | |
CN110837545A (en) | Interactive data analysis method, device, medium and electronic equipment | |
CN105630761B (en) | Formula processing method and device | |
CN113741864B (en) | Automatic semantic service interface design method and system based on natural language processing | |
CN118502857A (en) | Interactive processing method, device, equipment, medium and program product of user interface | |
US20230359827A1 (en) | Representing Confidence in Natural Language Processing | |
CN111767703B (en) | Form data acquisition method, device and system | |
CN114391151A (en) | Enhanced natural language generation platform | |
CN111368522A (en) | Information generation method and device, computer equipment and computer readable storage medium | |
AU2018337034B2 (en) | Lean parsing: a natural language processing system and method for parsing domain-specific languages |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |