Data processing method and device, computer device and storage medium
By searching and matching the parameters and keywords of user-defined formulas in the registry and embedding business logic, the problem of the inability to parse user-defined formulas in existing technologies is solved, and efficient business data processing and formula reuse are achieved.
Patent Information
- Application Number
- CN202110297853.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-03-19
- Publication Date
- 2025-11-11
- Estimated Expiration
- 2041-03-19
AI Technical Summary
Existing technology cannot effectively parse user-defined formulas, making it impossible to implement business processing procedures.
By obtaining the registry and the formula to be parsed, the system searches for the target preset formula in the registry based on the function name, matches the parameters and keywords, assigns values to the placeholder keywords, and embeds business logic to form a business formula.
It enables semantic parsing of user-defined formulas, which can efficiently process business data and improve formula parsing speed and reusability.
Smart Images

Figure CN113704561B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a data processing method, apparatus, computer equipment, and storage medium. Background Technology
[0002] A formula is a general format, usually represented by symbols, that expresses a certain relationship (such as a law or theorem) between various quantities, and can be universally applied to similar things. Formulas can be used to implement some reusable business processes. If you want to use a computer to implement business processes based on formulas, you must first use the computer to parse the semantics of the formulas.
[0003] In related technologies, formula parsing involves storing formulas in multiple stacks, analyzing the positions of parentheses, storing the smallest unit, and then parsing and restoring the semantics of the formula based on the order of the parentheses. During formula parsing, each smallest unit is judged separately. However, this method cannot parse user-defined formulas because the stored formulas are predefined. Summary of the Invention
[0004] Therefore, it is necessary to provide a data processing method, apparatus, computer equipment, and storage medium capable of parsing user-defined formulas to address the aforementioned technical problems.
[0005] A data processing method, the method comprising:
[0006] Retrieve registry entries and formulas to be parsed;
[0007] The function name of the formula to be parsed is searched in the registry to determine the target preset formula corresponding to the formula to be parsed in the registry;
[0008] The formula to be parsed is matched with the target preset formula to determine the keywords corresponding to each parameter in the formula to be parsed in the registry.
[0009] Based on the keywords corresponding to each parameter, assign each parameter in the formula to be parsed to the corresponding placeholder keyword;
[0010] Obtain the business logic of the formula to be parsed, and embed the business logic into the business formula composed of the placeholder keywords.
[0011] A data processing apparatus, the apparatus comprising:
[0012] The acquisition module is used to retrieve the registry and the formula to be parsed.
[0013] The search module is used to search the registry based on the function name of the formula to be parsed, and determine the target preset formula corresponding to the formula to be parsed in the registry;
[0014] The matching module is used to match the formula to be parsed with the target preset formula to determine the keywords corresponding to each parameter in the formula to be parsed in the registry.
[0015] The assignment module is used to assign values to the corresponding placeholder keywords of the formula to be parsed based on the keywords corresponding to each parameter.
[0016] The business logic embedding module is used to obtain the business logic of the formula to be parsed and embed the business logic into the business formula composed of the placeholder keywords.
[0017] A computer device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program performing the following steps:
[0018] Retrieve registry entries and formulas to be parsed;
[0019] The function name of the formula to be parsed is searched in the registry to determine the target preset formula corresponding to the formula to be parsed in the registry;
[0020] The formula to be parsed is matched with the target preset formula to determine the keywords corresponding to each parameter in the formula to be parsed in the registry.
[0021] Based on the keywords corresponding to each parameter, assign each parameter in the formula to be parsed to the corresponding placeholder keyword;
[0022] Obtain the business logic of the formula to be parsed, and embed the business logic into the business formula composed of the placeholder keywords.
[0023] A computer-readable storage medium having a computer program stored thereon, the computer program performing the following steps when executed by a processor:
[0024] Retrieve registry entries and formulas to be parsed;
[0025] The function name of the formula to be parsed is searched in the registry to determine the target preset formula corresponding to the formula to be parsed in the registry;
[0026] The formula to be parsed is matched with the target preset formula to determine the keywords corresponding to each parameter in the formula to be parsed in the registry.
[0027] Based on the keywords corresponding to each parameter, assign each parameter in the formula to be parsed to the corresponding placeholder keyword;
[0028] Obtain the business logic of the formula to be parsed, and embed the business logic into the business formula composed of the placeholder keywords.
[0029] The aforementioned data processing method, apparatus, computer equipment, and storage medium, after obtaining the registry and the formula to be parsed, search for the corresponding target preset formula in the registry based on the function name of the formula to be parsed, and match the formula to be parsed with the target preset formula to determine the keywords corresponding to each parameter in the formula in the registry. Then, based on the correspondence between parameters and keywords, each parameter in the formula to be parsed is assigned to the corresponding placeholder keyword. Finally, the business logic of the formula to be parsed is obtained and embedded into the business formula composed of placeholder keywords, resulting in a business formula with defined business logic. The registry and the formula to be parsed can be defined by the user. After obtaining the registry and the formula to be parsed, the method parses the formula to be parsed to determine the keywords corresponding to each parameter in the registry, assigns each parameter in the formula to the corresponding placeholder keyword, and then embeds the corresponding business logic into the business formula composed of the assigned placeholder keywords. Semantic parsing can also be achieved for user-defined formulas, which can then be used for business processing of relevant business data. Attached Figure Description
[0030] Figure 1 This is a flowchart illustrating a data processing method in one embodiment;
[0031] Figure 2 This is a schematic diagram of the registry in a specific embodiment;
[0032] Figure 3 This is a flowchart illustrating the data processing method in another embodiment;
[0033] Figure 4 This is a flowchart illustrating the process of determining the corresponding keywords in the registry for each parameter in the formula to be parsed, based on the registry, in one embodiment.
[0034] Figure 5 This is a schematic diagram of the segmentation result obtained by segmenting the formula to be analyzed in a specific embodiment;
[0035] Figure 6 This is a flowchart illustrating a data processing method in a specific embodiment;
[0036] Figure 7 This is a structural block diagram of a data processing device in one embodiment;
[0037] Figure 8 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation
[0038] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0039] In one embodiment, such as Figure 1 As shown, a data processing method is provided. This embodiment illustrates the application of this method to a terminal. It is understood that this method can also be applied to a server, and can also be applied to a system including a terminal and a server, and can be implemented through the interaction between the terminal and the server.
[0040] Natural Language Processing (NLP) is an important field within computer science and artificial intelligence. It studies the theories and methods for enabling effective communication between humans and computers using natural language. NLP is a science that integrates linguistics, computer science, and mathematics. Therefore, research in this field involves natural language, that is, the language people use in daily life, and thus it has a close relationship with linguistic research. NLP techniques typically include text processing, semantic understanding, machine translation, question answering, and knowledge graphs. In the embodiments of this application, the parsing of formulas by a program falls under the field of natural language processing.
[0041] In this embodiment, the method includes steps S110 to S150.
[0042] Step S110: Obtain the registry and the formula to be parsed.
[0043] The registry is typically used to store system and application settings; in one embodiment, it refers to the storage relationships and related information of data and formats. Users can define keywords, keyword types, and preset formula formats through the registry; preset formulas include information such as function names, start and end symbols, delimiters, and keywords. In a specific embodiment, such as... Figure 2 The diagram shown illustrates a registry in a specific embodiment. Here, `item`: a string object defined within a formula; `date`: an integer object defined within a formula; `sample`: a string object defined within a formula; `order`: a string object defined within a formula; `item`, `date`, `sample`, and `order` represent keywords defined in the registry. `rank_s(item,sample,order)`, `zsroce_s(item,sample)`, and `sum_t(item,date,date,sample)` represent the formats of three specific preset formulas.
[0044] The formula to be parsed represents a formula that needs to be parsed by the system, and the formula to be parsed contains parameters; wherein, the parameters in the formula to be parsed can be user-defined. Further, in one embodiment, both the registry and the formula to be parsed can be input by the user.
[0045] Step S120: Search the registry for the function name of the formula to be parsed to determine the target preset formula corresponding to the formula to be parsed in the registry.
[0046] A function is a piece of program or code that can be directly referenced by another piece of program or code. In one specific embodiment, the formula to be parsed is represented as: rank_s(closePrice,AShare,ASC), where "rank_s" is the function name of the formula to be parsed. In another embodiment, the formula to be parsed is represented as: zsroce_s(closePrice,AShare), where "zsroce_s" is the function name of the formula to be parsed.
[0047] In one embodiment, the registry defines the format of each preset formula. Understandably, a preset formula includes a function name, start and end symbols, separators, and keywords. Further, based on the function name of the formula to be parsed, a search is performed in the preset formulas defined in the registry. The preset formula with the same function name as the formula to be parsed is the target preset formula corresponding to the formula to be parsed in the registry. The search for the corresponding target preset formula in the registry based on the function name can be implemented in any way.
[0048] In one embodiment, if a preset formula with the same function name as the formula to be parsed is found in the registry, that preset formula is the target preset formula. In another embodiment, if two or more preset formulas with the same function name are found in the registry based on the function name of the formula to be parsed, the target preset formula can be determined by comparing the number of parameters in the formula to be parsed with the number of keywords in the found preset formulas with the same function name; alternatively, the target preset formula can be determined by comparing the types of parameters in the formula to be parsed with the types of keywords in the preset formulas; or in other embodiments, the target preset formula can be determined from the found preset formulas with the same function name through other methods. In this embodiment, considering that multiple preset formulas with different functions may be named with the same function name in the registry, the target preset formula corresponding to the formula to be parsed can also be determined based on the number and type of parameters / keywords.
[0049] Step S130: Match the formula to be parsed with the target preset formula to determine the keywords corresponding to each parameter in the formula to be parsed in the registry.
[0050] In one embodiment, keywords are also defined in the registry. In this embodiment, after finding the target preset formula corresponding to the formula to be parsed in the registry, the formula to be parsed is matched with the target preset formula to determine the keywords corresponding to each parameter in the formula to be parsed in the target preset formula, that is, the keywords corresponding to each parameter in the formula to be parsed in the registry. Further, the specific process of determining the keywords corresponding to each parameter in the formula to be parsed will be described in detail in later embodiments and will not be repeated here.
[0051] In one specific embodiment, the formula to be parsed is represented as: rank_s(closePrice,AShare,ASC), where "closePrice", "AShare", and "ASC" are the parameters in the formula to be parsed. The target preset formula is rank_s(item,sample,order), where "item", "sample", and "order" are the keywords in the target preset formula. In one embodiment, the keywords corresponding to each parameter in the formula to be parsed are determined based on the position information of each parameter in the formula to be parsed and the position information of each keyword in the target preset formula.
[0052] Step S140: Based on the keywords corresponding to each parameter, assign values to the corresponding placeholder keywords for each parameter in the formula to be parsed.
[0053] After determining the keywords corresponding to each parameter in the formula to be parsed, the parameters in the formula are represented by placeholders using these keywords, that is, the parameters are assigned to the corresponding keywords; in this embodiment, the placeholder keywords are denoted as placeholder keywords. In this step, after representing each parameter in the formula with its corresponding keyword, the program carries the correspondence between the parameters in the formula and the placeholder keywords during subsequent runtime. In one embodiment, after assigning each parameter in the formula to its corresponding placeholder keyword, the program generates key-value pairs between the placeholder keywords and the parameters, using the placeholder keywords as keys and the parameters as the corresponding values. The key-value pairs store data, and each key corresponds to a unique value.
[0054] Step S150: Obtain the business logic of the formula to be parsed, and embed the business logic into the business formula composed of placeholder keywords.
[0055] The business logic of the formula to be parsed refers to the function that the user expects to achieve through the formula; in one embodiment, the business logic of the formula to be parsed is the user input. In the steps described above, the system has already completed the parsing of the formula to be parsed based on the registry. At this point, the system has determined the keywords corresponding to each parameter in the formula. It still needs to parse the actual meaning of these keywords in the application, that is, the function to be performed using the formula. Therefore, when the business logic of the formula to be parsed is obtained, it is embedded into the formula composed of placeholder keywords to complete the semantic parsing of the formula and determine the function corresponding to it. In a specific embodiment, the business logic of the formula to be parsed is to sort specified sample data; or the business logic of the formula to be parsed is to sum specified sample data, etc. The specified sample data can be determined by the parameters in the formula to be parsed. In subsequent use, the user only needs to input the corresponding business data to use the business formula to complete the corresponding business logic and obtain the business processing result.
[0056] Furthermore, in this embodiment, the formula that embeds business logic is denoted as the business formula, and the corresponding business logic can be executed on the relevant data obtained thereafter using the business formula.
[0057] The above data processing method, after obtaining the registry and the formula to be parsed, searches for the corresponding target preset formula in the registry based on the function name of the formula to be parsed, and matches the formula to be parsed with the target preset formula to determine the keywords corresponding to each parameter in the formula in the registry. Then, based on the correspondence between parameters and keywords, each parameter in the formula to be parsed is assigned to the corresponding placeholder keyword. Finally, the business logic of the formula to be parsed is obtained and embedded into the business formula composed of placeholder keywords, resulting in a business formula with defined business logic. The registry and the formula to be parsed can be defined by the user. After obtaining the registry and the formula to be parsed, the method parses the formula to determine the keywords corresponding to each parameter in the registry, assigns each parameter in the formula to the corresponding placeholder keyword, and then embeds the corresponding business logic into the business formula composed of the assigned placeholder keywords. Semantic parsing can also be achieved for user-defined formulas, which can then be used for business processing of relevant business data.
[0058] In one embodiment, such as Figure 3 As shown, after obtaining the business logic of the formula to be parsed and embedding the business logic into the business formula composed of placeholder keywords, the method further includes steps S310 and S320.
[0059] Step S310: Obtain the business data to be processed corresponding to the business formula.
[0060] The business data to be processed refers to the data corresponding to the business formula. In one embodiment, the business data to be processed can be obtained from a database, or it can be obtained from a specified path, such as from a fixed website, etc. Further, in one embodiment, the business data to be processed can be set to be obtained at a specified time, for example, the system is set to obtain the business data to be processed at 5 pm every day; or the system is set to obtain the business data to be processed at preset time intervals, etc.
[0061] In one embodiment, the business data to be processed includes data corresponding to the parameters representing the data name and data sample range in the formula to be parsed. In one specific embodiment, the parameters included in the formula to be parsed include: data named as the closing price of the day, and the data range including all A-shares. In this embodiment, the business data to be processed includes the closing price data of all A-shares for the day. In another specific embodiment, the parameters included in the formula to be parsed include data named as the highest temperature of the day, and the data range including a specified location. In this embodiment, the business data to be processed obtained by the system includes the highest temperature of the day at the specified location. In other embodiments, the business data to be processed can also be other types of data.
[0062] Step S320: Based on the business formula, perform the corresponding business processing on the business data to be processed to obtain the business processing result.
[0063] The system executes corresponding business logic on the business data to be processed based on the specified sample data in the business formula to obtain the processing result. In one specific embodiment, the business logic corresponding to the business formula is to sort the specified sample data. In this embodiment, after obtaining the business data to be processed, the business data to be processed is sorted, and the sorting result is the business processing result in this embodiment.
[0064] In this embodiment, for the input business data, the parsed business formula is used to execute business logic on the data to obtain the business processing result. The same formula can be reused when performing the same business operation on different data. For the user, after the system parses the formula, they only need to transmit different business data to the system to obtain the corresponding business processing result.
[0065] In one embodiment, such as Figure 4 As shown, the formula to be parsed is matched with the target preset formula to determine the keywords corresponding to each parameter in the formula to be parsed in the registry, including steps S410 to S430.
[0066] Step S410: Read the start and end symbols, delimiters, and positional relationships of each keyword in the target preset formula.
[0067] Start and end symbols are symbols used for positioning in a preset formula, including start and end symbols. In one specific embodiment, start and end symbols are parentheses "()", "{}", or "[]". Separator symbols are symbols used to separate different parameters in a preset formula. In one specific embodiment, separator symbols are commas ",", "、", or " / ". The positional relationship of keywords indicates the positional relationship between keywords in the preset formula. In one embodiment, the positional relationship of keywords includes the order of the keywords.
[0068] Step S420: The formula to be parsed is split into strings according to the start and end symbols and the delimiter to obtain the splitting result.
[0069] In one embodiment, the preset formula defines the formula format. If the formula to be parsed has the same function name as the preset formula, then the format of the parameters in the formula to be parsed should be the same as the format of the preset formula. Similarly, the start and end symbols and delimiters in the formula to be parsed should also be in the same positions as the start and end symbols and delimiters in the preset formula. The formula to be parsed is then divided into multiple strings based on the start and end symbols and delimiters, including the function name, start and end symbols, delimiters, and parameters. For example... Figure 5 The diagram shown is a schematic representation of the segmentation result obtained by segmenting the formula to be analyzed in a specific embodiment.
[0070] Step S430: Based on the positional relationship of each keyword in the target preset formula, determine the keywords corresponding to each parameter in the segmentation result.
[0071] As can be seen from the above steps, the target preset formula corresponds to the formula to be parsed, and the start and end symbols and delimiters contained therein are the same. The keywords in the target preset formula and the parameters in the formula to be parsed should also correspond one-to-one. Therefore, in this embodiment, the correspondence between keywords and parameters is determined based on the positional relationship of each keyword in the target preset formula and the positional relationship of the parameters in the segmentation result obtained by segmenting the formula to be parsed. In one embodiment, determining the keywords corresponding to each parameter in the segmentation result based on the positional relationship of each keyword in the target preset formula includes: scanning and matching each keyword of the target preset formula and each parameter in the segmentation result in the same direction to determine the correspondence between parameters and keywords in the same position.
[0072] In one specific embodiment, taking the formula to be parsed as rank_s(closePrice,AShare,ASC) as an example, the corresponding target preset formula rank_s(item,sample,order) is found in the registry, and the formula to be parsed is divided into the following parts: Figure 5The segmentation results shown, based on the positional relationship of the keywords "item, sample, order" in the target preset formula, determine the correspondence between the keywords and parameters as "item-closePrice", "sample-AShare", and "order-ASC".
[0073] In this embodiment, the target preset formula corresponding to the formula to be parsed is searched in the registry, and the start and end symbols and delimiters are read from the target preset formula. Based on the start and end symbols and delimiters in the target preset formula, the formula to be parsed is segmented into multiple strings. Finally, based on the positional relationship of each keyword in the target preset formula, the parameters corresponding to each keyword are determined from the segmentation results of the formula to be parsed, thus obtaining the correspondence between the keywords in the target preset formula and the parameters of the formula to be parsed. Using start and end symbols and delimiters to segment the formula to be parsed into strings can improve the formula parsing speed and speed up the formula restoration process.
[0074] Furthermore, in one embodiment, before determining the keyword corresponding to each parameter in the segmentation result based on the positional relationship of each keyword in the target preset formula, the method further includes: determining whether each parameter in the segmentation result conforms to the type of the keyword at the corresponding position; in this embodiment, if the parameter in the segmentation result conforms to the type of the keyword at the corresponding position, the keyword at the corresponding position is determined as the keyword corresponding to the parameter.
[0075] The types of each keyword in the target preset formula can be obtained from the registry. After splitting the formula to be parsed into strings based on start and end symbols and delimiters, the positional relationship of the keywords in the target preset formula can be compared to determine the correspondence between keywords and parameters. At this point, the corresponding parameters are judged according to the type of the keyword to determine whether the parameter matches the keyword type. If the parameter matches the keyword type, the keyword is determined as the keyword corresponding to the parameter.
[0076] In one embodiment, the keyword types in the target preset formula include: string type and integer type. In a specific embodiment, the target preset formula contains three keywords: item, sample, and order. The types of item, sample, and order are all string types. In this embodiment, it is determined whether the parameters in the formula to be parsed are string types. For example, if the parameters in the formula to be parsed include closePrice, AShare, and ASC, all of which are string types, it means that the parameters match the corresponding keyword types. Therefore, it is determined that the keyword corresponding to the parameter "item" is "closePrice", the keyword corresponding to the parameter "sample" is "AShare", and the keyword corresponding to the parameter "order" is "ASC".
[0077] In this embodiment, when determining the keyword corresponding to a parameter in the formula to be parsed, the type of keyword in the target preset formula is considered when judging the parameter in the formula to be parsed. Only when the parameter matches the type of the corresponding keyword can the keyword corresponding to the parameter be determined. By checking whether the parameter matches the keyword type, the accuracy of matching parameters and keywords can be ensured.
[0078] Furthermore, in one embodiment, the method further includes: generating an alarm message if the parameters in the segmentation result do not conform to the type of the keyword at the corresponding position.
[0079] In one specific embodiment, taking the target preset formula containing three keywords: item, sample, and order, where item, sample, and order are all of string type as an example, and assuming that the formula to be parsed contains a parameter "1", since "1" is of integer type and does not conform to the keyword type, an alarm message is generated to prompt the user.
[0080] In one embodiment, after obtaining the business logic of the formula to be parsed, and before embedding the business logic into the business formula composed of placeholder keywords, the method further includes: verifying the parameters corresponding to each placeholder keyword according to the business logic; if the parameters corresponding to the placeholder keywords all meet the constraints of the business logic, proceeding to the step of embedding the business logic into the business formula composed of placeholder keywords.
[0081] After obtaining the business logic of the formula to be parsed, the business logic imposes certain constraints on the data, so the parameters of the formula to be parsed need to be validated. In one embodiment, the validation of parameters includes the existence validation of parameters representing the data range and the data, and the value validation of parameters representing the function.
[0082] In one specific embodiment, the formula to be parsed is "rank_s(closePrice,AShare,ASC)", and the business logic of the formula is "to sort the closing prices of all A-shares on the current day". Here, "all A-shares" is the sample data range, represented by "AShare", the closing price is the sample data, represented by "closePrice", and the sorting function is represented by "ASC". In this embodiment, "closePrice" and "AShare" are validated to determine if data containing "closePrice" exists in the database or program cache, and if data within the sample data range containing "AShare" exists. "ASC" is validated to determine if it represents the sorting function. If the parameters corresponding to each placeholder key in the business formula meet the corresponding constraints, the step of embedding the business logic into the business formula can proceed.
[0083] In another embodiment, if any parameter fails to meet the constraints of the business logic, an alarm message is generated and sent to the user. In a specific embodiment, if it is determined that a parameter representing a function does not meet the constraints of the business logic, a confirmation message is sent to the user. If the user's feedback indicates that there is no error, the process proceeds to the step of embedding the business logic into the business formula. For example, if the placeholder keyword corresponds to a parameter representing a function with the custom name "AA", when the system verifies the value of "AA", since it cannot determine that the function represented by "AA" is sorting, it needs to send a confirmation message to the user. If the user's feedback confirms that the meaning of the parameter "AA" is indeed sorting, the process can also proceed to the step of embedding the business logic into the business formula.
[0084] In this embodiment, when embedding business logic into a business formula, each parameter is verified according to the constraints of the business logic to confirm whether it meets the constraints of the business logic. If it does, the step of embedding business logic into the formula is executed, which can further ensure the accuracy of formula parsing and reduce the possibility of formula parsing errors.
[0085] This application also provides an application scenario in which the above-described data processing method is applied. In this embodiment, the above-described data processing method is applied in a formula parser. Specifically, as... Figure 6 As shown, the application of this data processing method in this scenario is as follows: During the process of the formula parser parsing the formula to be parsed, all data defined in the lexical analysis will be used to construct custom keywords in the form of a registry. The syntax parser will then parse the correct input formula parameters. The parsing process is as follows:
[0086] Obtain the registry and load it into the formula parser. The registry is... Figure 2 For example, as shown below, `item`: a string object defined within the formula, representing the unique identifier of the data. `date`: an integer object defined within the formula, representing the time period of the data. `sample`: a string object defined within the formula, representing the sample range of the data. `order`: a string object defined within the formula, representing the sorting direction of the data. The formula parser reads the keywords defined in the registry and generates the corresponding keywords.
[0087] Get the formula to be parsed by the user input. Take the formula to be parsed as rank_s(closePrice,AShare,ASC) as an example.
[0088] The function name of the formula to be parsed is searched in the registry to determine the target preset formula corresponding to the formula to be parsed. In this embodiment, based on the function name of the formula to be parsed, "rank_s", and the definition of func in the registry, the corresponding target preset formula is determined to be: rank_s(item,sample,order).
[0089] Based on rank_s(item,sample,order), the target preset formula is divided using "()" as the start and end symbols and "," as the delimiter, to obtain the keywords contained in the target preset formula.
[0090] The formula to be parsed is divided into function name, start and end symbols, delimiter, and parameters. For example... Figure 2 The parse tree shown performs a left-to-right scan and matching of formulas. The matching results are then assigned placeholder values based on keywords in the target formula. The placeholder keyword "item" is assigned the value of the parameter "closePrice" in the formula to be parsed; the placeholder keyword "sample" is assigned the value of "AShare"; and the placeholder keyword "order" is assigned the value of "ASC". At this point, all placeholder keywords in the formulas have been assigned the user-input values. These strings are actually semantically meaningless to the program; they are simply strings obtained through placeholder and type matching. During the scanning and assignment process, no overly complex validation is performed; only type checking is needed. For example, if any parameter in the formula to be parsed is 1, since the keywords "item", "sample", and "order" in the target formula are all string types (defined in the registry), the system will report an error indicating that the parameter "1" in the formula to be parsed does not conform to the keyword type of rank_s.
[0091] After the above steps, the code context during system program execution will carry the following fields: the value of func is rank_s, the value of item is closePrice, the value of sample is AShare, and the value of order is ASC. In one embodiment, the above correspondence can be represented in the code as key-value pairs.
[0092] Furthermore, the business logic corresponding to the formula to be parsed is obtained, and the business logic is embedded into the target preset formula to obtain the business formula. In this embodiment, taking the business logic defined as a data sorting function as an example, the runtime date is used as the value retrieval date. It is necessary to perform existence checks on closePrice and AShare respectively, and search for data with the code closePrice through the database or program cache. To find the sample data range of AShare, it is necessary to perform value checks on ASC and DESC. If the value corresponding to order is not one of these two, the business layer handles this exception.
[0093] At this point, the semantics of `rank_s(closePrice, AShare, ASC)` are fully clear. The semantics are actually derived from embedding business logic within the predefined formula for the system's target. The sample range is all A-share listed stocks up to the specified runtime date, and the corresponding closing prices are used to sort the data in ascending order.
[0094] In other embodiments, the formula to be parsed can be defined with other parameters. For example, the data code `closePrice` (closing price) can be replaced with definitions such as opening price or temperature. `AShare` can be replaced with other custom sample ranges, such as the ChiNext board or temperatures in various countries. The function name `rank_s` can be replaced with something like `zsroce_s`, representing the standardization of the sample data; or it can be replaced with `sum_t`, representing the sum of sample data over a period of time. The semantics of the formulas are all implemented in the logic of the business layer developer code.
[0095] The above embodiments can improve the parsing speed of formula parsing, accelerate semantic restoration, enable high formula reusability, and allow non-developers to customize their own data using existing formula parsers. Developers only need to design the business logic corresponding to `func` in the formula; all keywords used in the formula can be obtained through the runtime context of the program, reducing the workload of developers in writing formula parsers.
[0096] It should be understood that although the steps in the flowcharts involved in the above embodiments are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts involved in the above embodiments may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages in other steps.
[0097] In one embodiment, such as Figure 7 As shown, a data processing apparatus is provided. This apparatus can be a software module, a hardware module, or a combination of both, integrated into a computer device. Specifically, the apparatus includes: an acquisition module 710, a search module 720, a matching module 730, an assignment module 740, and a business logic embedding module 750, wherein:
[0098] Module 710 is used to obtain the registry and the formula to be parsed.
[0099] The lookup module 720 is used to search the registry based on the function name of the formula to be parsed, and to determine the target preset formula corresponding to the formula to be parsed in the registry.
[0100] The matching module 730 is used to match the formula to be parsed with the target preset formula to determine the keywords corresponding to each parameter in the formula to be parsed in the registry.
[0101] The assignment module 740 is used to assign values of each parameter in the formula to be parsed to the corresponding placeholder keywords based on the keywords corresponding to each parameter.
[0102] The business logic embedding module 750 is used to obtain the business logic of the formula to be parsed and embed the business logic into the business formula composed of placeholder keywords.
[0103] The aforementioned data processing device, after acquiring the registry and the formula to be parsed, searches for the corresponding target preset formula in the registry based on the function name of the formula to be parsed, and matches the formula to be parsed with the target preset formula to determine the keywords corresponding to each parameter in the formula in the registry. Then, based on the correspondence between parameters and keywords, it assigns each parameter in the formula to the corresponding placeholder keyword. Finally, it acquires the business logic of the formula to be parsed and embeds the business logic into the business formula composed of placeholder keywords, thus obtaining a business formula with defined business logic. The registry and the formula to be parsed can be defined by the user. After acquiring the registry and the formula to be parsed, the device parses the formula to determine the keywords corresponding to each parameter in the registry, assigns each parameter in the formula to the corresponding placeholder keyword, and then embeds the corresponding business logic into the business formula composed of the assigned placeholder keywords. Semantic parsing can also be achieved for user-defined formulas, which can then be used for business processing of relevant business data.
[0104] In one embodiment, the acquisition module 710 of the above-mentioned device is further configured to: acquire the business data to be processed corresponding to the business formula; in this embodiment, the above-mentioned device further includes: a business processing module, configured to perform corresponding business processing on the business data to be processed based on the business formula, and obtain the business processing result.
[0105] In one embodiment, the matching module 730 of the above-mentioned device includes: a reading unit, used to read the start and end symbols, delimiters, and positional relationships of each keyword in the target preset formula; a segmentation unit, used to segment the formula to be parsed into a string according to the start and end symbols and delimiters to obtain the segmentation result; and a keyword determination unit, used to determine the keyword corresponding to each parameter in the segmentation result based on the positional relationship of each keyword in the target preset formula.
[0106] In one embodiment, the above apparatus further includes: a type determination module, used to determine whether each parameter in the segmentation result conforms to the type of the keyword at the corresponding position; the keyword determination unit is further used to: if the parameter in the segmentation result conforms to the type of the keyword at the corresponding position, determine the keyword at the corresponding position as the keyword corresponding to the parameter.
[0107] In one embodiment, the above apparatus further includes an alarm module, used to generate alarm information if the parameters in the segmentation result do not conform to the type of the keyword at the corresponding position.
[0108] In one embodiment, the above apparatus further includes: a verification module, configured to verify the parameters corresponding to each placeholder keyword according to the business logic; the above business logic embedding module 750 is further configured to, if the parameters corresponding to the placeholder keywords all meet the constraints of the business logic, proceed to the step of embedding the business logic into the business formula composed of the placeholder keywords.
[0109] For specific embodiments of the data processing device, please refer to the embodiments of the data processing method described above, which will not be repeated here. Each module in the above-described data processing device can be implemented entirely or partially through software, hardware, or a combination thereof. Each module can be embedded in or independent of the processor in a computer device in hardware form, or stored in the memory of a computer device in software form, so that the processor can call and execute the operations corresponding to each module.
[0110] In one embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as follows: Figure 8As shown, the computer device includes a processor, memory, communication interface, display screen, and input devices connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, carrier networks, NFC (Near Field Communication), or other technologies. When the computer program is executed by the processor, it implements a data processing method. The display screen can be an LCD screen or an e-ink screen. The input devices can be a touch layer covering the display screen, buttons, a trackball, or a touchpad mounted on the computer device casing, or an external keyboard, touchpad, or mouse.
[0111] Those skilled in the art will understand that Figure 8 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0112] In one embodiment, a computer device is also provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the above method embodiments.
[0113] In one embodiment, a computer-readable storage medium is provided storing a computer program that, when executed by a processor, implements the steps in the above method embodiments.
[0114] In one embodiment, a computer program product or computer program is provided, the computer program product or computer program including computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and executes the computer instructions, causing the computer device to perform the steps in the above method embodiments.
[0115] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments of the methods described above. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, or optical storage, etc. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM), etc.
[0116] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0117] The above embodiments merely illustrate several implementation methods of this application, and while the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the invention patent. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this patent application should be determined by the appended claims.
Claims
1. A data processing method, characterized in that, The method includes: Retrieve the registry and the formula to be parsed; the formula to be parsed refers to the formula that needs to be parsed by the system; the formula to be parsed includes user-defined parameters; The function name of the formula to be parsed is searched in the registry to determine the target preset formula corresponding to the formula to be parsed in the registry; The formula to be parsed is matched with the target preset formula to determine the keywords corresponding to each parameter in the formula to be parsed in the registry. Based on the keywords corresponding to each parameter, assign each parameter in the formula to be parsed to the corresponding placeholder keyword; The business logic of the formula to be parsed is obtained, and the business logic is embedded into the business formula composed of placeholder keywords. The actual meaning of the placeholder keywords in the application is determined. The business logic is the function that the user expects to achieve through the formula to be parsed, and it is characterized by data name, data sample range and business processing method. Obtain the business data to be processed corresponding to the business formula; the business data to be processed matches the data name and the data sample range. Based on the business formula, the corresponding business processing is performed on the business data to be processed to obtain the business processing result.
2. The data processing method according to claim 1, characterized in that, The formula to be parsed is matched with the target preset formula to determine the keywords corresponding to each parameter in the formula to be parsed in the registry, including: Read the start and end symbols, delimiters, and positional relationships of keywords in the target preset formula; The formula to be parsed is segmented into a string based on the start and end symbols and the delimiter to obtain the segmentation result; Based on the positional relationship of each keyword in the target preset formula, the keyword corresponding to each parameter in the segmentation result is determined.
3. The data processing method according to claim 2, characterized in that, Before determining the keywords corresponding to each parameter in the segmentation result based on the positional relationship of each keyword in the target preset formula, the method further includes: Determine whether each parameter in the segmentation result matches the type of the keyword at the corresponding position; If the parameter in the segmentation result matches the type of the keyword at the corresponding position, the keyword at the corresponding position is determined as the keyword corresponding to the parameter.
4. The data processing method according to claim 3, characterized in that, The method further includes: If the parameters in the segmentation result do not match the type of the keyword at the corresponding position, an alarm message is generated.
5. The data processing method according to any one of claims 1 to 4, characterized in that, After obtaining the business logic of the formula to be parsed and before embedding the business logic into the business formula composed of placeholder keywords, the method further includes: Based on the business logic, the parameters corresponding to each placeholder keyword are validated. If the parameters corresponding to the placeholder keywords all meet the constraints of the business logic, proceed to the step of embedding the business logic into the business formula composed of the placeholder keywords.
6. A data processing apparatus, characterized in that, The device includes: The acquisition module is used to acquire the registry and the formula to be parsed; the formula to be parsed represents the formula that needs to be parsed by the system; the formula to be parsed includes user-defined parameters; The search module is used to search the registry based on the function name of the formula to be parsed, and determine the target preset formula corresponding to the formula to be parsed in the registry; The matching module is used to match the formula to be parsed with the target preset formula to determine the keywords corresponding to each parameter in the formula to be parsed in the registry. The assignment module is used to assign values to the corresponding placeholder keywords of the formula to be parsed based on the keywords corresponding to each parameter. The business logic embedding module is used to obtain the business logic of the formula to be parsed, embed the business logic into the business formula composed of placeholder keywords, and determine the actual meaning of the placeholder keywords in the application; the business logic is the function that the user expects to achieve through the formula to be parsed, and is characterized by data name, data sample range, and business processing method. The acquisition module is further configured to: acquire the business data to be processed corresponding to the business formula; the business data to be processed matches the data name and the data sample range; The device further includes a business processing module, used to perform corresponding business processing on the business data to be processed based on the business formula, and obtain a business processing result.
7. The data processing apparatus according to claim 6, characterized in that, The matching module includes: The reading unit is used to read the start and end symbols, delimiters, and positional relationships of each keyword in the target preset formula; A segmentation unit is used to segment the formula to be parsed into a string based on the start and end symbols and the segmentation symbol, so as to obtain the segmentation result. The keyword determination unit is used to determine the keyword corresponding to each parameter in the segmentation result based on the positional relationship of each keyword in the target preset formula.
8. The data processing apparatus according to claim 7, characterized in that, The device further includes: The type determination module is used to determine whether each parameter in the segmentation result conforms to the type of the keyword at the corresponding position; The keyword determination unit is further configured to: if the parameter in the segmentation result matches the type of the keyword at the corresponding position, determine the keyword at the corresponding position as the keyword corresponding to the parameter.
9. The data processing apparatus according to claim 8, characterized in that, The device further includes: The alarm module is used to generate alarm information if the parameters in the segmentation result do not match the type of the keyword at the corresponding position.
10. The data processing apparatus according to any one of claims 6 to 9, characterized in that, The device further includes: The verification module is used to verify the parameters corresponding to each placeholder keyword according to the business logic. The business logic embedding module is further configured to: if the parameters corresponding to the placeholder keywords all meet the constraints of the business logic, proceed to the step of embedding the business logic into the business formula composed of the placeholder keywords.
11. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 5.
12. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Character string based formula manipulation method and device
CN106874243A
An inter-process communication method and related equipment
CN109710426A