Query method, device and electronic equipment

By adding new columns to the table and using expression analysis, the limitation of the table-based question-and-answer system in accurately answering questions has been overcome, enabling real-time and accurate table-based question-and-answer applications and enhancing query efficiency and scope.

CN116628287BActive Publication Date: 2026-05-08ALIBABA (CHINA) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
ALIBABA (CHINA) CO LTD
Filing Date
2023-05-24
Publication Date
2026-05-08

AI Technical Summary

Technical Problem

Existing form-based question-and-answer systems cannot accurately answer users' questions because the forms lack the data that users need to be directly stored, which limits their application scope.

Method used

By adding new columns to the table and using expressions to summarize and analyze multiple lines of text, a first table is generated. The target text is then queried in the first table based on the selected text and conditional text, and the target value is determined as the result text.

Benefits of technology

It expands the application scope of table-based question and answer systems, enabling real-time and accurate responses to various types of user questions, reducing maintenance costs and improving query efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116628287B_ABST
    Figure CN116628287B_ABST
Patent Text Reader

Abstract

The application provides a query method, device and electronic equipment. The method comprises the following steps: in response to obtaining a query text facing a first table, obtaining the first table, the query text comprising a selection text and a condition text, the first table adding a new column on the basis of a second table, the new column corresponding to a first expression, the first expression being used for inductive analysis of multiple lines of text in the second table; querying at least one line of target text in the first table that meets the condition text; determining a target column in the first table according to the selection text, the column name of the target column and the selection text belonging to the same semantics; and determining that the target value corresponding to the target column in the at least one line of target text is the result text corresponding to the query text, wherein the target value is determined according to the expression. Based on various types of query texts of the user, the application can obtain the corresponding result text, thereby improving the application range of table question and answer.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and in particular to query methods, devices and electronic devices. Background Technology

[0002] Table-based question answering is a question-answering engine that uses natural language processing to provide answers based on the content of a table. For example, based on a user's query text, the engine queries the table for the answer text to reply to the user.

[0003] Currently, the method of retrieving answer text in a table is based on the user's query text, searching for the existing answer text within the table. However, in some cases, the table does not directly store the data the user wants, making it impossible to accurately answer the user's question and thus limiting the application of table-based question answering. Summary of the Invention

[0004] This application provides various methods, devices, and electronic devices for querying information to broaden the application scope of form-based question and answer systems.

[0005] The first aspect of this application provides a query method, comprising: responding to obtaining query text directed to a first table; obtaining the first table, the query text including selection text and condition text, the first table having added new columns based on a second table, the new columns corresponding to a first expression, the first expression being used for summarizing and analyzing multiple lines of text in the second table; querying at least one line of target text in the first table that matches the condition text; determining a target column in the first table based on the selection text, the column name of the target column having the same semantic meaning as the selection text; determining that in at least one line of target text, the target value corresponding to the target column is the result text corresponding to the query text, wherein the target value is determined based on the expression.

[0006] A second aspect of this application provides a query method applied to a terminal device, comprising: acquiring query text; sending query text to a cloud server, the query text being used to instruct the cloud server to rewrite the query text into query text; and receiving result text sent by the cloud server, the result text being determined by the cloud server according to the query method of the first aspect.

[0007] A third aspect of this application provides a query device applied to a cloud server, comprising:

[0008] The acquisition module is used to respond to the query text of the first table. The first table is acquired, and the query text includes selection text and conditional text. The first table has new columns added on the basis of the second table. The new columns correspond to the first expression. The first expression is used to summarize and analyze the multiple lines of text in the second table.

[0009] The query module is used to retrieve at least one row of target text that matches the specified conditions from the first table.

[0010] The first determination module is used to determine the target column in the first table based on the selected text. The column name of the target column has the same semantic meaning as the selected text.

[0011] The second determining module is used to determine that in at least one row of target text, the target value corresponding to the target column is the result text corresponding to the query text, wherein the target value is determined according to an expression.

[0012] A fourth aspect of this application provides an electronic device, including: a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the query method as described in the first aspect and / or the second aspect.

[0013] The fifth aspect of this application provides a computer-readable storage medium storing a computer program that, when executed by a processor, causes the processor to implement the query method as described in the first and / or second aspects.

[0014] This application embodiment is applied to a table-based question-and-answer scenario. It obtains query text for a first table through a response. The first table includes selection text and conditional text. A new column is added to the first table based on a second table, and each new column corresponds to a first expression. The first expression is used to summarize and analyze multiple rows of text in the second table. At least one row of target text matching the conditional text is retrieved from the first table. Based on the selection text, a target column is determined in the first table, and the column name of the target column has the same semantic meaning as the selection text. In the determined target text, the target value corresponding to the target column is the result text corresponding to the query text. The target value is determined based on the expression, and corresponding result text can be obtained based on various types of user query text, thus improving the application scope of table-based question-and-answer. Attached Figure Description

[0015] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings:

[0016] Figure 1 An application scenario diagram provided for an exemplary embodiment of this application;

[0017] Figure 2 A flowchart illustrating the steps of a query method provided in an exemplary embodiment of this application;

[0018] Figure 3A flowchart illustrating the steps of another query method provided in an exemplary embodiment of this application;

[0019] Figure 4 A structural block diagram of a query device provided for an exemplary embodiment of this application;

[0020] Figure 5 This is a schematic diagram of the structure of an electronic device provided as an exemplary embodiment of this application. Detailed Implementation

[0021] To make the objectives, technical solutions, and advantages of this application clearer, the technical solutions of this application will be clearly and completely described below in conjunction with specific embodiments and corresponding drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of them. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0022] Currently, the method of querying answer text in a table is based on the user's query text, and then searching for the existing answer text in a second table. For example, referring to Table 1, which is a second table, users can only query the alarm time, case status, and alarm location. Other query content cannot be directly determined from this second table. For example, if the user's query text is "How many valid alarms are there today?", then this query text is rewritten as SQL (Structured Query Language), i.e., the query text in this application, which is "Select (quantity) from Table 1, with the condition that case status = valid, date = today". Here, "Select (quantity) from Table 1" is the selection text, and "the condition that case status = valid" and "date = today" are both condition texts. Since Table 1 does not have a "quantity" column, the result text cannot be directly determined from Table 1, thus making it impossible to reply to the user's query.

[0023] Table 1

[0024] Alarm time Case Status Police location 2022-07-01 efficient Area A 2022-07-09 invalid Area A 2022-07-10 efficient Area B 2022-07-11 invalid Area C 2022-07-28 efficient Area A 2022-07-28 efficient Area A 2022-07-28 efficient Area B

[0025] Based on the above problems, one solution is to pre-calculate the results offline for each possible data point, add a new column to the second table, and then determine the values ​​of the new column to fill the corresponding cells. However, in practical applications, the values ​​in the cells of the second table change frequently, especially for numeric columns. If the values ​​are recalculated every time there is a change, it will not guarantee real-time performance and will waste a significant amount of repetitive work. For example, referring to Table 2, if the second table only has three columns (product name, quantity, and unit price), adding a "total price" column to the second table requires calculating the total price for each row in the second table. If the quantity or unit price in one row changes, the corresponding total price needs to be recalculated and then filled into the corresponding total price column, resulting in a large workload.

[0026] Table 2

[0027]

[0028]

[0029] Furthermore, referring to Table 3, for tables similar to Table 1, if a new column is added as "Quantity," the value of this column can only indicate whether the corresponding row is a valid alarm, and cannot directly answer the user's question such as "How many valid alarms are there today?" Therefore, this method cannot answer the user's question and limits the application of table-based question answering.

[0030] Table 3

[0031] Alarm time Case Status Police location quantity 2022-07-01 efficient Area A 1 2022-07-09 invalid Area A 0 2022-07-10 efficient Area B 1 2022-07-11 invalid Area C 0 2022-07-28 efficient Area A 1 2022-07-28 efficient Area A 1 2022-07-28 efficient Area B 1

[0032] To address the aforementioned issues, this application provides a query method that obtains query text for a first table through a response. The first table includes selection text and conditional text. A new column is added to the first table based on a second table, and each new column corresponds to a first expression used for summarizing and analyzing multiple lines of text in the second table. At least one line of target text matching the conditional text is queried in the first table. Based on the selection text, a target column is determined in the first table, with the column name sharing the same semantic meaning as the selection text. In the at least one line of target text, the target value corresponding to the target column is the result text corresponding to the query text. The target value is determined based on the expression, allowing for the retrieval of corresponding result text based on various types of user query text, thus expanding the application scope of table-based question answering.

[0033] In this embodiment, the execution device of the training query method is not limited. Optionally, the training query method can be applied to a terminal, or the overall training query method can be implemented with the help of a cloud computing system. For example, the training query method can be applied to a cloud server to take advantage of the resources on the cloud to run various models; instead of applying it to the cloud, the training query method can also be applied to server-side devices such as conventional servers, cloud servers, or server arrays.

[0034] In addition, refer to Figure 1 This is an application scenario diagram of this application. Terminal device 11 sends a query text to server 12. Server 12 rewrites the query text to obtain a structured query text, and then queries the result text in the first table based on the query text, and sends the result text to terminal device 11 to answer the query text.

[0035] In text classification tasks, such as user reviews, text classification models can be used to determine whether a user review is positive or negative. Another example is product descriptions; these can be input into the model to determine the corresponding product category.

[0036] Figure 1 This is merely one example of an application scenario exemplified by this application. This application can also be applied to other related scenarios, which are not limited here.

[0037] The technical solutions provided by the various embodiments of this application are described in detail below with reference to the accompanying drawings.

[0038] Figure 2 A flowchart illustrating the steps of a query method provided for an exemplary embodiment of this application. Figure 2 As shown, this query method specifically includes the following steps:

[0039] S201, Response: Received query text for the first table, retrieved the first table.

[0040] The query text includes selection text and conditional text. The first table is based on the second table and has added columns. The added columns correspond to the first expression, which is used to summarize and analyze the multiple lines of text in the second table.

[0041] In this embodiment, the query text is generated based on the user-input query text. The query text is natural language, while the query text is structured, including selection text and condition text. In this embodiment, the technique used to rewrite the query text into query text is NLTSQL (Natural Language to SQL), which converts the user-input natural language text into structured language query text.

[0042] For example, if a user's query text is "What is the total price of product A?", the corresponding query text would be "Select (total price), condition (product name = A)", where the selection text is "Select (total price)" and the condition text is "Condition (product name = A)". If a user's query text is "What is the daily interest rate for low-risk products?", the corresponding query text would be "Select (daily interest rate), condition (risk level = low)".

[0043] In this application, the query text is used to make it easier to find the corresponding result text in the first table. The condition text can be used to find the text in each row of text that meets the condition text in the first table, and the selection text can be used to determine the result text in each row of text.

[0044] In this embodiment of the application, the first table may be generated in advance based on the second table for users to query, or it may be generated in real time based on the query text.

[0045] S202, query at least one row of target text that meets the conditions in the first table.

[0046] In this embodiment of the application, the conditional text in the query text can be used to determine at least one line of target text that meets the conditional text.

[0047] Optionally, if the condition text contains a new column name, the new column name corresponding to the condition text is removed, and a new condition text is used. The first table is then used to query at least one row of target text that matches the new condition text.

[0048] S203, Based on the selected text, determine the target column in the first table.

[0049] In this context, the column name of the target column and the selection text share the same semantic meaning.

[0050] In this embodiment of the application, the data range is first narrowed down by conditional text, and then the result text that satisfies the query text is found by selecting text.

[0051] S204, determine that in at least one row of target text, the target value corresponding to the target column is the result text corresponding to the query text.

[0052] The target value is determined by the expression.

[0053] The first table has a new column based on the second table. The new column has a corresponding first expression, and the result text is determined based on the first expression and the text of the second table.

[0054] For example, refer to Table 1 as the second table and Table 4 as the first table. The newly added column in Table 4 is the column named "Quantity," which could also be named "Number of Valid Alarms." All values ​​in this new column are empty, and it has a corresponding first expression. For example, this first expression could be "Count (Case Status == Valid? and Alarm Time == Today? 1:0)", which means "Count when the case status is valid and the alarm time is today."

[0055] Table 4

[0056] Alarm time Case Status Police location quantity 2022-07-01 efficient Area A 2022-07-09 invalid Area A 2022-07-10 efficient Area B 2022-07-11 invalid Area C 2022-07-28 efficient Area A 1 2022-07-28 efficient Area A 2 2022-07-28 efficient Area B 3

[0057] Based on Table 4, if the query text is "Select (quantity) from Table 1, with the condition that case status = valid and date = today", and today is 2022-07-28, then the result text can be determined to be 3 based on the first expression "count (case status == valid? and alarm time == today? 1:0)" and the second table.

[0058] In this embodiment, the result text can be determined based on the text in the first expression and the second table, wherein the first expression and the newly added column have a corresponding relationship. In this embodiment, the first table may have one or more newly added columns relative to the second table.

[0059] Furthermore, since the newly added column only has a name and no corresponding values, any changes to the text in the second table also require updating the values ​​in the newly added column without affecting the use of the first expression. Therefore, configuring the first expression for the newly added column ensures the real-time performance of the table, avoids wasting significant repetitive work, and can accurately and promptly answer various types of user questions, thus expanding the application scope of the table-based Q&A system.

[0060] This application embodiment is applied to a table-based question-and-answer scenario. It obtains query text and retrieves result text in a first table based on the query text. The first table has a new column based on the second table, and the new column has a corresponding first expression. The result text is determined based on the first expression and the text of the corresponding row in the second table. It can obtain the corresponding result text based on various types of query text from users, thus improving the application scope of table-based question-and-answer.

[0061] Reference Figure 3 The flowchart illustrates another query method provided as an exemplary embodiment of this application. Figure 3 The query method shown includes the following steps:

[0062] S301, retrieve the query text.

[0063] The specific implementation process of this step is described in S201 and will not be repeated here.

[0064] S302, based on the query text and the second table, determine the name of the new column and the first expression.

[0065] In this embodiment of the application, the new column name is determined based on the selection text and condition text in the query text and the column names in the second table. The new column name has a different meaning from the column names in the second table, and the new column name has the same meaning as part of the text in the query text.

[0066] For example, if the query text is "Select (Quantity) from Table 1, with the condition that Case Status = Valid and Date = Today", then the new column name is "Quantity", which does not exist in the second table. As another example, if the query text is "Select (Total Price), with the condition 'Product A'", referring to Table 2, the second table only has columns named "Product Name, Quantity, and Unit Price", then the new column name could be "Total Price".

[0067] In addition, the first expression is generated as follows: the second expression is generated based on the query text and the name of the new column; the second expression is validated, and if the second expression passes the validation, the second expression is determined to be the first expression.

[0068] In this embodiment, a second expression is generated based on the selected text and conditional text according to preset rules. Furthermore, the second expression needs to be validated to verify its usability.

[0069] Furthermore, a second expression is generated based on the query text and the name of the new column, including: determining the second expression based on the semantics of the query text and the semantics of the name of the new column.

[0070] In this context, the query text is "Select (Quantity) from Table 1, with the condition that case status = valid and date = today," and the newly added column name is "Quantity." The second expression can be "Count (Case status == valid? and alarm time == today? 1:0)." The second expression can also be "Count," "Count (Case status == valid? 1:0)," or "1:0 Count (Alarm time == today? 1:0)." If the second expression is "Count," then based on Table 4, if the query text is "Select (Quantity) from Table 1, with the condition that case status = valid and date = today," and today is 2022-07-28, then first, based on the condition text "Case status = valid and date = today," we can determine that the last three rows of text in Table 4 meet the condition text. Then, based on the selection text "Select (Quantity)," we determine that "Quantity" in the second table is the column corresponding to the result text. Using this first expression to count the last three rows of text in Table 4 yields the result text 3.

[0071] The second expression can be determined based on various types of computed elements or combinations thereof. Computational elements include: aggregate functions, column values ​​and / or column names in the second table, constants, ternary operators, arithmetic operators, and built-in functions. Specifically, aggregate functions include determining maximum, minimum, average, and summation. Constants include constant characters or data. Ternary operators include not greater than, not less than, greater than, and less than. Arithmetic operators include basic operations such as addition, subtraction, multiplication, and division. Built-in functions include modulo and integer operations.

[0072] In this embodiment of the application, elements can be selected from the above multiple calculated elements based on the semantics of the query text and the name of the new column to form a second expression.

[0073] Optionally, generating a second expression based on the query text and the name of the new column includes: inputting the query text and the name of the new column into a pre-trained generative model for processing to obtain the second expression.

[0074] In this embodiment of the application, a generation model can be pre-trained, and the generation module can generate a second expression based on the query text and the name of the new column.

[0075] The second expression validation includes: validating whether the second expression conforms to the preset expression rules; if it does, validating whether the data type of the data determined by the second expression is consistent with the data type of the newly added column; if they are consistent, the second expression validation is deemed successful.

[0076] Specifically, the expression rules include: nested aggregate functions are not allowed (for example, an expression that calculates the maximum value and then sums is nested); newly added columns cannot reference each other. For instance, when calculating the value of newly added column 1, the value of newly added column 2 cannot be used. If the second expression does not conform to these preset expression rules, the second expression fails validation. Otherwise, subsequent validations are performed.

[0077] Furthermore, if the data type of the newly added column should be numeric, but the data type determined by the second expression is character, then the data types are inconsistent, and the second expression will fail the validation.

[0078] In the embodiments of this application, the generated second expression can be in code format, and an easily understandable expression can be obtained by translating the second expression.

[0079] In this embodiment of the application, the value of the newly added column refers to the value corresponding to the name of the newly added column. This value is calculated by using the first expression on multiple lines of text in the second table, which can realize the corresponding value in real time and does not need to be stored in advance for users to query.

[0080] S302, add a new column to the second table and establish the correspondence between the new column and the first expression to obtain the first table.

[0081] The newly added column has its name in the first table.

[0082] In this embodiment of the application, after determining the name of the new column and the first expression, the new column can be added to the second table. For example, the first table is shown in Table 4.

[0083] Furthermore, if the condition text contains new column names, the query text is rewritten according to the semantics of the query text to obtain a new query text.

[0084] The condition text containing the name of the new column includes text that is synonymous with the name of the new column. For example, if the name of the new column is "Number of Alarms" and the condition text is "Number of Cases Reported," the two are synonymous.

[0085] For example, if the query text is "Select (quantity) from Table 1, with the condition that case status = valid and date = today", then the condition text in this query text does not contain the name of the new column, so there is no need to rewrite the query text. If the query text is "Which places have a valid alarm count greater than 1 in July 2022?", the corresponding query text is "Select (alarm location), with the condition that (alarm time ≥ 2022-07-01 and alarm time ≤ 2022-07-31, quantity > 1)", and the condition text contains the name of the new column "quantity", then rewriting this query text will result in "Select 'alarm location', with the condition (alarm time ≥ 2022-07-01 and alarm time ≤ 2022-07-31, quantity > 1), from grouped alarm locations".

[0086] In this embodiment, the query text can be rewritten as needed, and the rewritten query text has the same semantics as the original query text. The rewritten query text can more quickly and accurately retrieve the result text in the first table.

[0087] S304, Query at least one row of target text that matches the conditions in the first table.

[0088] The specific implementation process of this step is described in S202 and will not be repeated here.

[0089] S305, Based on the selected text, determine the target column in the first table.

[0090] The specific implementation process of this step is described in S203 and will not be repeated here.

[0091] S306, determine that in at least one row of target text, the target value corresponding to the target column is the result text corresponding to the query text.

[0092] For example, if the query text is "Which places have a valid alarm count greater than 1 in July 2022?", it is converted to the query text "Select (alarm location), with the conditions (alarm time ≥ 2022-07-01 and alarm time ≤ 2022-07-31, quantity > 1)". Then, based on the query text and the second table (as shown in Table 1), the first table (as shown in Table 2) is generated. Then, the query text is rewritten to obtain the new query text "Select 'Alarm Location', Conditions (Alarm Time ≥ 2022-07-01 and Alarm Time ≤ 2022-07-31, Quantity > 1, Group Alarm Locations)". Then, the partial condition text ((Alarm Time ≥ 2022-07-01 and Alarm Time ≤ 2022-07-31, Group Alarm Locations)) is executed. At least one target text (X) that meets the condition text is found in the first table. Then, in the at least one target text (X), at least one target text (Y) with a valid alarm quantity greater than 1 is selected. Then, the alarm location is determined in the at least one target text (Y).

[0093] In this embodiment of the application, by introducing a new column into the second table to obtain the first table, the problem of not being able to query data that is not in the table in the current table question and answer scenario is solved, the table question and answer capability is enhanced, the maintenance cost of data that is related between different columns in the table and the data changes frequently is greatly reduced, and the query efficiency of the result text is improved.

[0094] In addition, this application also provides a query method applied to a terminal device. The query method includes: obtaining query text; sending query text to a cloud server, the query text being used to instruct the cloud server to rewrite the query text into query text; and receiving result text sent by the cloud server, the result text being determined by the cloud server according to any of the above query methods.

[0095] The specific implementation process of this embodiment is the same as that of the above embodiment, and will not be repeated here.

[0096] In this application embodiment, in addition to providing a query method, a query device is also provided, such as... Figure 4 As shown, the query device 40 includes:

[0097] The acquisition module 41 is used to respond to the acquisition of query text for the first table. The first table is acquired, and the query text includes selection text and condition text. The first table has added columns based on the second table. The added columns correspond to the first expression. The first expression is used to summarize and analyze the multiple lines of text in the second table.

[0098] Query module 42 is used to query at least one row of target text that meets the conditions in the first table;

[0099] The first determining module 43 is used to determine the target column in the first table based on the selected text, wherein the column name of the target column has the same semantic meaning as the selected text;

[0100] The second determining module 44 is used to determine that in at least one row of target text, the target value corresponding to the target column is the result text corresponding to the query text, wherein the target value is determined according to an expression.

[0101] In an optional embodiment, the acquisition module 41 is specifically used to determine the new column name and the first expression of the new column based on the query text and the second table before querying at least one row of target text that meets the conditions in the first table; add the new column to the second table and establish the correspondence between the new column and the first expression to obtain the first table, wherein the new column has a new column name in the first table.

[0102] In an optional embodiment, the acquisition module 41 is configured to generate the first expression in the following manner:

[0103] Generate a second expression based on the query text and the name of the new column; validate the second expression, and if the second expression passes the validation, determine that the second expression is the first expression.

[0104] In an optional embodiment, when the acquisition module 41 generates the second expression based on the query text and the name of the new column, it is specifically used to: determine the second expression based on the semantics of the query text and the semantics of the name of the new column.

[0105] In an optional embodiment, when the acquisition module 41 generates the second expression based on the query text and the name of the new column, it is specifically used to: input the query text and the name of the new column into a pre-trained generative model for processing to obtain the second expression.

[0106] In an optional embodiment, when the acquisition module 4 verifies the second expression, it is specifically used to verify the second expression, and before determining the second expression as the first expression if the second expression passes the verification, it verifies whether the second expression conforms to the preset expression rules; if it does, it verifies whether the data type of the data determined according to the second expression is consistent with the data type of the newly added column; if they are consistent, it determines that the second expression has passed the verification.

[0107] In an optional embodiment, the newly added column has a corresponding newly added column name, and further includes: a rewriting module (not shown), used to rewrite the query text according to the semantics of the query text before the query result text in the first table if the condition text contains the newly added column name, to obtain a new query text.

[0108] In addition, this application also provides another query device (not shown), including:

[0109] The acquisition module is used to acquire query text;

[0110] The sending module is used to send query text to the cloud server. The query text is used to instruct the cloud server to rewrite the query text into a query text.

[0111] The receiving module is used to receive the result text sent by the cloud server. The result text is determined by the cloud server according to any of the query methods mentioned above.

[0112] The specific implementation process is the same as described in the above embodiments, and will not be repeated here.

[0113] Furthermore, in some of the processes described in the above embodiments and accompanying drawings, multiple operations appear in a specific order. However, it should be clearly understood that these operations may not be executed in the order they appear herein, or may be executed in parallel. The sequence numbers are merely used to distinguish different operations, and the sequence numbers themselves do not represent any execution order. Additionally, these processes may include more or fewer operations, and these operations may be executed sequentially or in parallel. It should be noted that the descriptions such as "first," "second," etc., in this document are used to distinguish different messages, devices, modules, etc., and do not represent a sequential order, nor do they limit "first" and "second" to different types.

[0114] Figure 5 This is a schematic diagram of an electronic device provided as an exemplary embodiment of this application. The electronic device is used to run the above-described query method. Figure 5 As shown, the electronic device includes a memory 54 and a processor 55.

[0115] Memory 54 is used to store computer programs and can be configured to store various other data to support operation on electronic devices. Memory 54 may be object storage (OSS).

[0116] The memory 54 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk or optical disk.

[0117] Processor 55, coupled to memory 54, is used to execute a computer program in memory 54 for: responding to the acquisition of query text directed to a first table; acquiring the first table, the query text including selection text and condition text, the first table having added columns based on a second table, the added columns corresponding to a first expression, the first expression being used for inductive analysis of multiple lines of text in the second table; querying at least one line of target text in the first table that matches the condition text; determining a target column in the first table based on the selection text, the column name of the target column having the same semantic meaning as the selection text; determining that in at least one line of target text, the target value corresponding to the target column is the result text corresponding to the query text, wherein the target value is determined according to the expression.

[0118] Further optionally, when the processor 55 obtains the first table, it specifically performs the following: determines the new column name and the first expression of the new column based on the query text and the second table; adds the new column to the second table and establishes a correspondence between the new column and the first expression to obtain the first table, wherein the new column has a new column name in the first table.

[0119] Alternatively, the processor 55 is configured to generate the first expression by: generating a second expression based on the query text and the name of the new column; validating the second expression; and, if the second expression passes the validation, determining the second expression as the first expression.

[0120] In an optional embodiment, when the processor 55 generates the second expression based on the query text and the name of the new column, it is specifically used to: determine the second expression based on the semantics of the query text and the semantics of the name of the new column.

[0121] In an optional embodiment, when the processor 55 generates the second expression based on the query text and the name of the new column, it specifically performs the following: inputs the query text and the name of the new column into a pre-trained generative model for processing to obtain the second expression.

[0122] In an optional embodiment, when the processor 55 verifies the second expression, it specifically performs the following steps: verifies whether the second expression conforms to a preset expression rule; if it does, it verifies whether the data type of the data determined according to the second expression is consistent with the data type of the newly added column; if they are consistent, it determines that the second expression has passed the verification.

[0123] In an optional embodiment, the newly added column has a corresponding newly added column name. Before querying the result text in the first table based on the query text, the processor 55 is further configured to: if the condition text contains the newly added column name, rewrite the query text according to the semantics of the query text to obtain a new query text.

[0124] In one alternative embodiment, the processor 55, coupled to the memory 54, is configured to execute a computer program in the memory 54, and is further configured to: acquire query text; send query text to a cloud server, the query text being used to instruct the cloud server to rewrite the query text into query text; and receive result text sent by the cloud server, the result text being determined by the cloud server according to the query method described above.

[0125] Furthermore, such as Figure 5 As shown, the electronic device also includes other components such as a firewall 51, a load balancer 52, a communication component 56, and a power supply component 53. Figure 5 The diagram only shows some components and does not mean that the electronic device includes only these components. Figure 5 The components shown.

[0126] Accordingly, embodiments of this application also provide a computer-readable storage medium storing a computer program, which, when executed by a processor, causes the processor to implement the steps in the method described above.

[0127] Accordingly, embodiments of this application also provide a computer program product, including a computer program / instructions, which, when executed by a processor, cause the processor to implement the steps in the method described above.

[0128] The above Figure 5 The communication component is configured to facilitate wired or wireless communication between the device containing the communication component and other devices. The device containing the communication component can access wireless networks based on communication standards, such as WiFi, 2G, 3G, 4G / LTE, 5G, or combinations thereof. In one exemplary embodiment, the communication component receives broadcast signals or broadcast-related text from an external broadcast management system via a broadcast channel. In one exemplary embodiment, the communication component also includes a Near Field Communication (NFC) module to facilitate short-range communication. For example, the NFC module may be implemented based on Radio Frequency Identification (RFID), Infrared Data Association (IrDA) technology, Ultra-Wideband (UWB) technology, Bluetooth (BT) technology, and other technologies.

[0129] The above Figure 5 The power supply component provides power to the various components of the device in which it resides. The power supply component may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to the device in which it resides.

[0130] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, systems, or computer program products. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0131] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable text processing device to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable text processing device, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0132] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable text processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0133] These computer program instructions can also be loaded onto a computer or other programmable text processing device to cause a series of operational steps to be performed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable device for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0134] In a typical configuration, a computing device includes one or more processors (CPU and / or GPU), input / output interfaces, network interfaces, and memory.

[0135] Memory may include non-persistent storage in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.

[0136] Computer-readable media, including both permanent and non-permanent, removable and non-removable media, can be used to store text by any method or technology. Text can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic magnetic disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store text accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.

[0137] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.

[0138] The above are merely embodiments of this application and are not intended to limit the scope of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of the claims of this application.

Claims

1. A query method, characterized in that, include: The response obtains the query text for the first table, retrieves the first table, the query text includes selection text and condition text, the first table has a new column added on the basis of the second table, the new column corresponds to a first expression, the first expression is used to summarize and analyze multiple lines of text in the second table; In the first table, query at least one row of target text that matches the stated conditions; Based on the selected text, a target column is determined in the first table, wherein the column name of the target column has the same semantic meaning as the selected text; In the at least one row of target text, the target value corresponding to the target column is determined to be the result text corresponding to the query text, wherein the target value is determined according to the expression.

2. The query method according to claim 1, characterized in that, Obtaining the first table includes: Based on the query text and the second table, determine the new column name and the first expression for the new column; Add a new column to the second table and establish a correspondence between the new column and the first expression to obtain the first table, wherein the new column has the name of the new column in the first table.

3. The query method according to claim 2, characterized in that, The first expression is generated in the following manner: A second expression is generated based on the query text and the name of the newly added column; The second expression is validated, and if the second expression passes the validation, the second expression is determined to be the first expression.

4. The query method according to claim 3, characterized in that, The step of generating a second expression based on the query text and the newly added column name includes: The second expression is determined based on the semantics of the query text and the semantics of the newly added column name.

5. The query method according to claim 3, characterized in that, The step of generating a second expression based on the query text and the newly added column name includes: The query text and the name of the newly added column are input into a pre-trained generative model for processing to obtain the second expression.

6. The query method according to any one of claims 3 to 5, characterized in that, The verification of the second expression includes: Verify whether the second expression conforms to the preset expression rules; If the conditions are met, then verify whether the data type of the data determined by the second expression is consistent with the data type of the newly added column; If they match, the second expression has passed the validation.

7. The query method according to any one of claims 1 to 5, characterized in that, The newly added column has a corresponding new column name, and the step of querying the result text in the first table based on the query text further includes: If the condition text contains the name of the newly added column, then the query text is rewritten according to the semantics of the query text to obtain a new query text.

8. A query method, characterized in that, Applied to terminal devices, the query method includes: Obtain the query text; Send the query text to the cloud server, the query text being used to instruct the cloud server to rewrite the query text into a query text; Receive result text sent by a cloud server, wherein the result text is determined by the query method according to any one of claims 1 to 7.

9. A query device, characterized in that, include: The acquisition module is used to respond to the acquisition of query text for the first table, acquire the first table, the query text includes selection text and condition text, the first table has a new column added on the basis of the second table, the new column corresponds to a first expression, the first expression is used to summarize and analyze multiple lines of text in the second table; The query module is used to query at least one row of target text in the first table that matches the conditions. The first determining module is used to determine a target column in the first table based on the selected text, wherein the column name of the target column has the same semantic meaning as the selected text; The second determining module is used to determine that in the at least one row of target text, the target value corresponding to the target column is the result text corresponding to the query text, wherein the target value is determined according to the expression.

10. An electronic device, characterized in that, include: A processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the computer program, implements the query method as described in any one of claims 1 to 8.

Citation Information

Patent Citations

  • Offline verification method and device for structured query language grammars

    CN111367936A

  • Natural language data query method and device, electronic equipment and storage medium

    CN114281957A