Information acquisition method, device and electronic device based on natural language input
By processing and semantic conversion of query statements input in natural language, a structured query language is generated and executed in the data warehouse, the problem of low query efficiency in business intelligence systems is solved, and fast and convenient information acquisition is achieved.
Patent Information
- Application Number
- CN202411882102.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-19
- Publication Date
- 2025-04-01
AI Technical Summary
In the existing business intelligence system, business users have low query efficiency and need to find the report you want to see from a large number of preset reports, and each query requires setting query parameters.
By performing natural language processing on query statements input by natural language, query intent and keywords are extracted, semantic transformation is performed, structured query language for business scenarios is generated, and executed in the data warehouse to obtain query results.
It improves the query efficiency of business users, reduces the complexity of query parameter setting, reduces the cost of use, and realizes the ability to quickly obtain the required information.
Smart Images

Figure CN119739733A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of business intelligence technology, and in particular to an information acquisition method, device and electronic device based on natural language input. Background Art
[0002] Business Intelligence (BI) refers to the use of modern data warehouse technology, online analysis and processing technology, data mining and data presentation technology to effectively obtain information from data, provide support for decision-making, and realize business value.
[0003] The development of business intelligence has entered the era of cloud computing. The general logic is to establish a data warehouse, embed data points on the business side, collect behavioral data and finally save it in the database. At the same time, establish relevant business dimension tables, use report design software to develop multiple data reports, and then provide them to the business through a portal website.
[0004] Current business intelligence has met the needs of enterprises for obtaining information to a certain extent, but its use cost is relatively high. Generally, the business intelligence system of a large enterprise has at least hundreds of reports. After entering the business intelligence system, the business must find the reports they want to see, and each time they need to set their own query parameters, which greatly reduces the efficiency of business users. Summary of the invention
[0005] In view of the above problems, the present invention provides an information acquisition method, device, electronic device and storage medium based on natural language input to solve the problem of low query efficiency of business users.
[0006] According to one aspect of the present invention, there is provided an information acquisition method based on natural language input, comprising: performing natural language processing on an input natural language information query statement to obtain query intent and query keywords; performing semantic conversion on the query intent and query keywords to obtain query variables and corresponding query parameters; generating a business scenario structured query language based on the query variables and corresponding query parameters; executing the business scenario structured query language in a data warehouse to obtain a query result corresponding to the natural language query statement.
[0007] In an optional manner, generating a business scenario structured query language based on the query variables and corresponding query parameters includes: searching a predefined business scenario structured query language library based on the query variables and corresponding query parameters, and generating a business scenario structured query language based on the search results.
[0008] In an optional manner, a search is performed in a predefined business scenario structured query language library according to the query variables and the corresponding query parameters, and a business scenario structured query language is generated according to the search results, including: passing the query variables and the corresponding query parameters to a query statement generation interface, searching in a predefined business scenario structured query language library through the query statement generation interface, and generating a business scenario structured query language according to the search results.
[0009] In an optional manner, the query statement generation interface is used to search in a predefined business scenario structured query language library, and a business scenario structured query language is generated based on the search results, including: searching in a predefined business scenario structured query language library through the query statement generation interface to obtain a first business scenario structured query language whose matching degree meets a preset threshold; embedding the query variables and corresponding query parameters into a dynamic execution statement in the first business scenario structured query language in the form of EL expressions to obtain a second business scenario structured query language; and using the second business scenario structured query language as the final business scenario structured query language.
[0010] In an optional manner, generating a business scenario structured query language according to the query variables and corresponding query parameters includes: inputting the query variables and corresponding query parameters into a business scenario model, and predicting the business scenario structured query language.
[0011] In an optional manner, the input natural language query statement is subjected to natural language processing to obtain query intent and query keywords, including: converting the natural language query statement into a feature vector, inputting the feature vector into a trained intent recognition model to obtain the query intent; inputting the natural language query statement into a trained named entity recognition model to obtain query keywords including time period, business scenario, measurement dimension and operation indicator.
[0012] In an optional manner, the query intent and query keywords are semantically converted to obtain query variables and corresponding query parameters, including: converting the keywords of the time period into the corresponding determined date according to the semantic conversion rules, converting the keywords of the business scenario into the corresponding determined business, converting the keywords of the operating indicators into the corresponding active users, usage time, number of uses, number of clicks, page views, number of lines of code or number of documents, and converting the keywords of the measurement dimension into the corresponding user, department, gender or age; using the keywords as query parameters and the semantic conversion results corresponding to the keywords as query variables.
[0013] An embodiment of the present invention also provides an information acquisition device based on natural language input, including: an intention recognition module, used to perform natural language processing on an input natural language query statement to obtain query intention and query keywords; a semantic conversion module, used to perform semantic conversion on the query intention and query keywords to obtain query variables and corresponding query parameters; a query language generation module, used to generate a business scenario structured query language based on the query variables and corresponding query parameters; a data warehouse execution module, used to execute the business scenario structured query language in a data warehouse to obtain a query result corresponding to the natural language query statement.
[0014] In an optional manner, the query language generation module is specifically used to: search in a predefined business scenario structured query language library according to the query variable and the corresponding query parameter, and generate a business scenario structured query language according to the search result.
[0015] In an optional manner, the query language generation module includes: a query statement generation interface, which is used to search in a predefined business scenario structured query language library according to the query variables and corresponding query parameters, and generate a business scenario structured query language according to the search results.
[0016] In an optional manner, the query statement generation interface is specifically used to: search in a predefined business scenario structured query language library according to the query variables and the corresponding query parameters to obtain a first business scenario structured query language whose matching degree meets a preset threshold; embed the query variables and the corresponding query parameters into a dynamic execution statement in the first business scenario structured query language in the form of EL expressions to obtain a second business scenario structured query language; and use the second business scenario structured query language as the final business scenario structured query language.
[0017] In an optional manner, the query language generation module is specifically used to: input query variables and corresponding query parameters into the business scenario model, and predict the business scenario structured query language.
[0018] In an optional manner, the intent recognition module is specifically used to: convert the natural language query statement into a feature vector, input the feature vector into a trained intent recognition model to obtain the query intent; input the natural language query statement into a trained named entity recognition model to obtain query keywords including time period, business scenario, measurement dimension and operation indicator.
[0019] In an optional manner, the semantic conversion module is specifically used to: convert the keywords of the time period into the corresponding specific date according to the semantic conversion rules, convert the keywords of the business scenario into the corresponding specific business, convert the keywords of the operation indicator into the corresponding active users, usage time, number of uses, number of clicks, page views, number of lines of code or number of documents, and convert the keywords of the measurement dimension into the corresponding user, department, gender or age; use the keywords as query parameters and the semantic conversion results corresponding to the keywords as query variables.
[0020] An embodiment of the present invention also provides an electronic device, comprising: a shell, a processor, a memory, a circuit board and a power supply circuit, wherein the circuit board is placed inside the space enclosed by the shell, and the processor and the memory are arranged on the circuit board; the power supply circuit is used to supply power to various circuits or devices of the above-mentioned electronic device; the memory is used to store executable program code; the processor runs a program corresponding to the executable program code by reading the executable program code stored in the memory, so as to execute the information acquisition method based on natural language input described in any of the preceding items.
[0021] An embodiment of the present invention also provides a computer-readable storage medium, including: the computer-readable storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement any of the aforementioned information acquisition methods based on natural language input.
[0022] According to the information acquisition method, device, electronic device and storage medium based on natural language input provided by the present invention, compared with the prior art that finds the report you want to see from a large number of preset reports and needs to set your own query parameters every time, the embodiment of the present invention only needs to perform natural language processing on the input natural language query statement to obtain the query intent and query keywords; perform semantic conversion on the query intent and query keywords to obtain query variables and corresponding query parameters; generate a business scenario structured query language based on the query variables and corresponding query parameters; execute the business scenario structured query language in the data warehouse to obtain the query result corresponding to the natural language query statement. The embodiment of the present invention only needs to perform intent recognition and keyword extraction on the natural language query statement to obtain the business scenario structured query language, and can use the business scenario structured query language to conveniently and quickly perform information query from the data warehouse and obtain query results, with high query efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] By reading the detailed description of the preferred embodiment below, various other advantages and benefits will become clear to those of ordinary skill in the art. The accompanying drawings are only used for the purpose of illustrating the preferred embodiment and are not considered to be limitations of the present invention. In addition, the same reference symbols are used to represent the same components throughout the accompanying drawings.
[0024] Figure 1 A schematic diagram showing a flow chart of a method for obtaining information based on natural language input according to an embodiment of the present invention; Figure 2 A schematic diagram showing the composition of data query requirements in an embodiment of the present invention is shown; Figure 3 A schematic diagram showing a flow chart of an information acquisition method based on natural language input according to another embodiment of the present invention; Figure 4 A schematic diagram showing a framework of an information acquisition device based on natural language input according to an embodiment of the present invention; Figure 5 A schematic structural diagram of an electronic device according to an embodiment of the present invention is shown. DETAILED DESCRIPTION
[0025] The exemplary embodiments of the present invention will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present invention are shown in the accompanying drawings, it should be understood that the present invention can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided in order to enable a more thorough understanding of the present invention and to enable the scope of the present invention to be fully communicated to those skilled in the art.
[0026] Figure 1 The schematic diagram shows the process of the information acquisition method based on natural language input according to the embodiment of the present invention. Figure 1 Specifically, Figure 1 As shown, the information acquisition method based on natural language input includes the following steps: Step S101, performing natural language processing on the input natural language query sentence to obtain the query intent and query keywords; In this embodiment, the natural language query statement input by the user can be processed by natural language processing technology to obtain the query intent and query keywords.
[0027] The query intent may be a certain business analysis intent; the query keywords may include time period, business scenario, operation indicator, and / or measurement dimension. The measurement dimension may be referred to as dimension hereinafter.
[0028] See also Figure 2For example, the natural language query statement (also called data analysis demand) entered by the user is: "I want to check the active users of DingChat of the digital operation & ecological preparation team in the past seven days". By performing intent recognition on the natural language query statement, it is determined that the current user's intention is business analysis. Keywords such as "recent seven days", "digital operation & ecological preparation", "DingChat", and "active users" are identified through keywords.
[0029] Among them, the query keywords are as follows Figure 2 As shown, it includes time period, business scenarios, operational indicators and dimensions.
[0030] The time period determines the time range of the query, such as today, yesterday, the past week, the past seven days, and last month; the business scenario determines the business of the query, which is generally a service or product module, such as operating system (OS), DingChat, DingTao, desktop, and Native Services; the operational indicator determines the statistical target, that is, determines the specific indicators of the query, such as active users, number of uses, clicks, page views, number of lines of code, number of documents, usage time, etc.; the dimension includes more fine-grained measurement dimensions for different business scenarios, such as users, departments, gender, age, business dimensions, etc.
[0031] Step S102: semantically convert the query intent and query keywords to obtain query variables and corresponding query parameters.
[0032] In some embodiments, the keywords of the time period are converted into corresponding determined dates according to the semantic conversion rules, the keywords of the business scenarios are converted into corresponding determined businesses, the keywords of the operation indicators are converted into corresponding active users, usage time, usage times, clicks, page views, number of lines of code or number of documents, etc., and the keywords of the measurement dimensions are converted into corresponding users, departments, genders or ages. The keywords are used as query parameters, and the semantic conversion results corresponding to the keywords are used as query variables.
[0033] For example, the natural language query entered by the user is: "I want to check the [active users] of [DingChat] of the [Digital Operation & Ecosystem Preparation] team in the [last seven days]". The current user's intention is business analysis, and the identified keywords are "last seven days", "digital operation & ecosystem preparation", "DingChat", and "active users".
[0034] After semantic conversion: "Recent seven days" corresponds to the query parameters STARTDATE and ENDDATE. Assuming today is 2024-08-15, then STARTDATE='2024-08-08', ENDDATE='2024-08-15'.
[0035] "Digital Operation & Ecosystem Preparation Year" indicates the query department, which is converted to DEPARTMENT = 'Digital Operation & Ecosystem Preparation'.
[0036] "DingChat" means querying products, so it is converted to SERVICENAME='DingChat'; "Active Users" is a specific operational indicator, which is converted to code='DAU'.
[0037] Step S103, generating a business scenario structured query language according to the query variables and corresponding query parameters; wherein the business scenario structured query language includes embedded static business statements and dynamic execution statements.
[0038] In this embodiment, the dynamic execution statement in the business scenario structured query language includes a time period, a business scenario, an operating indicator, and / or a measurement dimension; wherein the time period includes at least one of the following periods: today, yesterday, a week, a month, last week, and last month; the business scenario includes, but is not limited to, various business dimensions of services and products; the operating indicator includes at least one of the following indicators: active users, usage time, number of uses, number of clicks, page views, number of lines of code, number of documents; the measurement dimension includes, but is not limited to, users, departments, gender, and age. Embedded static business statements are used to build a basic framework for queries, including connection relationships between multiple predefined data tables, aggregate functions, and filtering conditions. Dynamic execution statements are dynamically generated based on the query variables and parameters entered by the user, and are used to replace placeholders or parameter variables in predefined queries.
[0039] Step S104: execute the business scenario structured query language in the data warehouse to obtain a query result corresponding to the natural language query statement.
[0040] The information acquisition method based on natural language input provided by the embodiment of the present invention obtains query intent and query keywords by performing natural language processing on the input natural language query statement; performs semantic conversion on the query intent and query keywords to obtain query variables and corresponding query parameters; generates a business scenario structured query language according to the query variables and corresponding query parameters; executes the business scenario structured query language in the data warehouse to obtain the query result corresponding to the natural language query statement. In this way, in the embodiment of the present invention, it is only necessary to perform intent recognition and keyword extraction on the natural language query statement to obtain the business scenario structured query language, and the query result can be obtained through the preset structured query language library, which is low in cost and high in query efficiency.
[0041] In some embodiments, generating a business scenario structured query language according to the query variables and corresponding query parameters (step S103) includes: According to the query variables and corresponding query parameters, a search is performed in a predefined business scenario structured query language library, and according to the search results, a business scenario structured query language is generated.
[0042] Specifically, according to the query variables and the corresponding query parameters, a search is performed in a predefined business scenario structured query language library to obtain a business scenario structured query language whose matching degree meets a preset threshold.
[0043] Among them, the business scenario structured query language library contains all the current operational indicator query SQLs of the target enterprise. Each SQL corresponds to a specific business scenario, and the query dimensions are preset in advance through EL expressions and other methods.
[0044] According to the query variables and parameters, multiple SQL statements in the business scenario structured query language library are matched, and the matching degree of each SQL statement with the current query is calculated, wherein the matching degree can be calculated according to the matching number, matching order, semantic similarity, etc. of the variables and parameters. When the matching degree of the SQL statement reaches or exceeds the preset threshold, the SQL statement is used as the first business scenario structured query language. The preset threshold can be adjusted according to the actual needs of the enterprise and the complexity of the database to ensure the accuracy and practicality of the retrieval results.
[0045] For example, determine all business scenarios of an enterprise, including operational indicators and query dimensions of each business scenario, define the query SQL of each operational indicator in advance, including all query dimensions involved, and dimension it into SQL through EL expression. Taking DAU as an example, its SQL statement is: select dim.day_name dt, case when a.u is not null then a.u else 0 end as num from bi_dim_date dim left join( select `date` as dt, count(distinct uuid) as u from devsecops_service_active_user_details where <#if STARTDATE !="">date>=date_format( STARTDATE ,'%Y-%m-%d')< / #if> <#if ENDDATE !="">and date<=date_format( ENDDATE ,'%Y-%m-%d')< / #if> <#if SERVICENAME !="">and service_name= SERVICENAME < / #if> <#if DEPARTMENT !="全部"> and department= DEPARTMENT
[0046] <#else> < / #if> group by date )a on dim.day_name=a.dt where <#if STARTDATE !="">dim.day_name>=date_format( STARTDATE ,'%Y-%m-%d')< / #if> <#if ENDDATE !="">and dim.day_name<=date_format( ENDDATE ,'%Y-%m-%d')< / #if> <#if IS_WORKDAY !="all"> and dim.is_workday= IS_WORKDAY
[0047] <#else> < / #if> order by dim.day_name Preset the possible query dimensions through EL expressions, such as STARTDATE : Start time ENDDATE : End time SERVICENAME : Service Name DEPARTMENT :department IS_WORKDAY : Is it a working day? In order to facilitate rapid retrieval in a predefined business scenario structured query language library and generate a business scenario structured query language, an embodiment of the present invention also provides a query statement generation interface, through which a business scenario structured query language can be generated. Specifically, in some embodiments, according to the query variable and the corresponding query parameter, a search is performed in a predefined business scenario structured query language library, and according to the search result, a business scenario structured query language is generated, including: passing the query variable and the corresponding query parameter to the query statement generation interface, searching in a predefined business scenario structured query language library through the query statement generation interface, and generating a business scenario structured query language according to the search result.
[0048] In some embodiments, keywords and corresponding query variables may be associated to obtain a structured JSON object, and a query statement generation interface may be obtained, for example: JSON { "code":"DAU", / / Operational indicators "params":{ "STARTDATE":"2024-08-01", / / Start time "ENDDATE":"2024-08-15", / / End date "DEPARTMENT":"Digital Operation & Ecosystem Preparation", / / Department "SERVICENAME":"DingChat" "IS_WORKDAY":"1" / / Is it a working day? } } Through this query statement generation interface, the parameters passed in by the user can replace the corresponding parameters in the DAU query SQL to obtain the final business scenario structured query language (SQL statement).
[0049] For example, the final business scenario structured query language (SQL statement) is: JSON select dim.day_name dt, case when au is not null then au else 0 end as num from bi_dim_date dim left join( select `date` as dt, count(distinct uuid) as u from devsecops_service_active_user_details where date>=date_format('2024-08-01','%Y-%m-%d') and date<=date_format('2024-08-15','%Y-%m-%d') and service_name='DingChat' and department = 'Digital Operation & Ecosystem Preparation' group by date )a on dim.day_name=a.dt where dim.day_name>=date_format('2024-08-01','%Y-%m-%d') and dim.day_name<=date_format('2024-08-15','%Y-%m-%d') and dim.is_workday=1 order by dim.day_name In some embodiments, searching in a predefined business scenario structured query language library through the query statement generation interface and generating a business scenario structured query language based on the search results may include: searching in a predefined business scenario structured query language library through the query statement generation interface to obtain a first business scenario structured query language whose matching degree meets a preset threshold; embedding the query variables and corresponding query parameters into the dynamic execution statements in the first business scenario structured query language in the form of EL expressions to obtain a second business scenario structured query language; and using the second business scenario structured query language as the final business scenario structured query language.
[0050] In an optional manner, generating a business scenario structured query language according to the query variables and corresponding query parameters (step S103) may also include: inputting the query variables and corresponding query parameters into a business scenario model to predict the business scenario structured query language.
[0051] The business scenario model can be obtained by training a structured query language containing query variables and corresponding business scenarios as business scenario samples.
[0052] In this embodiment, the business scenario model is trained through historical query records to learn and understand the mapping relationship between query variables and business scenario structured query language, which can further improve the automation level of query processing and reduce the workload of pre-setting SQL statement libraries. The business scenario model can adopt a model such as a decision tree, which is not limited in this article.
[0053] In an optional manner, the input natural language query statement is subjected to natural language processing to obtain query intent and query keywords, including: converting the natural language query statement into a feature vector, inputting the feature vector into a trained intent recognition model to obtain the query intent; wherein the intent recognition model is a ChatGPT-PLUS model, a ChatMASTER model or a QAnything model; inputting the natural language query statement into a trained named entity recognition model to obtain query keywords including time period, business scenario, measurement dimension and operation indicator; wherein the named entity recognition model is a NER model or a spaCy model.
[0054] In this embodiment, the input natural language query statement is converted into a feature vector by using methods such as TF-IDF, and the feature vector is input into the trained intent recognition model to identify the query intent. Among them, the intent recognition model is the ChatGPT-PLUS model, the ChatMASTER model or the QAnything model, and the above models are all open source models (the open source website of the ChatGPT-PLUS model is: https: / / gitee.com / blackfox / chatgpt-plus; the open source website of the ChatMASTER model is: https: / / gitee.com / panday94 / chat-master; the open source website of the QAnything model is: https: / / gitee.com / netease-youdao / QAnything). Based on the above open source models, the mapping relationship between the query and the query intent can be learned through training samples. Other deep learning models can also be used to train the mapping relationship between the query and the query intent, which is not limited in this article.
[0055] The input natural language query statement is preprocessed by word segmentation, stop word removal, stem extraction, etc., and the preprocessed word segmentation is input into the NER model or spaCy model for named entity recognition to obtain named entities as query keywords, wherein the named entities include time periods, business scenarios, dimensions, and operational indicators. Among them, the NER model and the spaCy model are both named entity recognition models, which can recognize names of people, places, and organizational names. In this embodiment, the NER model or spaCy model is used to train and recognize named entities including time periods (such as "last month", "this week"), business scenarios (such as "OS", "desktop", "Native Services", etc.), dimensions (such as "users", "departments", "business dimensions", etc.) and operational indicators (such as "active users", "number of lines of code", etc.) as key query words.
[0056] In some embodiments, a query call interface can be generated based on dynamic execution statements in a predefined business scenario structured query language library; query variables and corresponding query parameters are passed to the query call interface, and the corresponding business scenario structured query language is generated and executed through the query call interface.
[0057] Figure 3 FIG. 1 is a flow chart of an embodiment of the present invention. Figure 3 The information acquisition method based on natural language input in this embodiment includes the following steps: S31, the user raises a natural language query requirement; S32, semantically analyzing the natural language query requirements to obtain the query intent; S33, extracting keywords for natural language query requirements; S34, based on the semantic analysis and keyword extraction of natural language query requirements, generate business scenario structured query language SQL; The process of generating a business scenario structured query language SQL includes semantically converting the query intent and query keywords to obtain query variables and corresponding query parameters; generating a business scenario structured query language according to the query variables and corresponding query parameters; S35, executing business scenario structured query language SQL; S36, data processing; S37. Result visualization.
[0058] Semantic parsing and keyword extraction of natural language query requirements are performed by artificial intelligence.
[0059] The generation and execution of the business scenario structured query language SQL is carried out in the data warehouse.
[0060] After executing the final business scenario structured query language SQL in the data warehouse, the corresponding result data is obtained, and the result data can be processed to generate corresponding line charts, pie charts, bar charts, etc. to meet the different needs of users. Finally, the results are presented to the user. Optionally, artificial intelligence can summarize the results of data processing (step S38) and present the result summary to the user.
[0061] In the above embodiments of the present invention, data developers do not need to develop reports one by one according to business analysis requirements. They only need to sort out all the current operating indicators of the enterprise, convert them into specific query SQLs, and preset the query dimensions in advance through EL expressions.
[0062] Users no longer need to look at dozens or hundreds of reports. They only need to enter their own query and analysis requirements to return specific results and related charts.
[0063] At present, natural language queries in the industry are basically implemented through the TexttoSql model. Simple table queries can ensure accuracy, but in the scenario of enterprise big data platforms, there are hundreds of tables in the data warehouse and thousands of fields. The query of a single operating indicator involves more than a dozen tables or even more. Therefore, the efficiency and accuracy of TextToSql will be greatly reduced. The technical solution provided by the present invention pre-sets all the enterprise's operating indicator query SQL (including query dimensions) in advance, and only needs to identify the user's intention to obtain four entities [time period] [business] [query dimension] and [operation indicator]. In this embodiment, on the basis of ensuring the accuracy of intent recognition and keyword extraction, the query efficiency is greatly improved. In addition, since there is no need to train a large number of tables and fields in the data warehouse, only intent recognition and keyword extraction are required, which greatly reduces the consumption of computing power.
[0064] Figure 4 The schematic diagram of the framework of the information acquisition device based on natural language input according to an embodiment of the present invention is shown. The information acquisition device based on natural language input comprises: The intention recognition module 410 is used to perform natural language processing on the input natural language query statement to obtain the query intention and query keywords; wherein the query keywords include time period, business scenario, operation indicator and measurement dimension; Semantic conversion module 420, used to perform semantic conversion on the query intent and query keywords to obtain query variables and corresponding query parameters; A query language generation module 430, for generating a business scenario structured query language according to the query variables and corresponding query parameters; wherein the business scenario structured query language includes embedded static business statements and dynamic execution statements; The data warehouse execution module 440 is used to execute the business scenario structured query language in the data warehouse to obtain the query result corresponding to the natural language query statement.
[0065] The device of this embodiment can execute the information acquisition method based on natural language input described in the previous embodiment. Its implementation process and technical effects are basically the same and will not be repeated here.
[0066] In some embodiments, the query language generation module is specifically used to: search in a predefined business scenario structured query language library according to the query variables and corresponding query parameters, and generate a business scenario structured query language according to the search results.
[0067] In some embodiments, the query language generation module includes: a query statement generation interface, which is used to search in a predefined business scenario structured query language library according to the query variables and corresponding query parameters, and generate a business scenario structured query language according to the search results.
[0068] In some embodiments, the query statement generation interface is specifically used to: search in a predefined business scenario structured query language library according to the query variables and the corresponding query parameters to obtain a first business scenario structured query language whose matching degree meets a preset threshold; embed the query variables and the corresponding query parameters into the dynamic execution statement in the first business scenario structured query language in the form of EL expressions to obtain a second business scenario structured query language; and use the second business scenario structured query language as the final business scenario structured query language.
[0069] In some embodiments, the query language generation module is specifically used to: input query variables and corresponding query parameters into the business scenario model, and predict the business scenario structured query language.
[0070] In some embodiments, the intent recognition module 410 is specifically used to: convert the natural language query statement into a feature vector, input the feature vector into a trained intent recognition model to obtain the query intent; input the natural language query statement into a trained named entity recognition model to obtain query keywords including time period, business scenario, measurement dimension and operation indicator.
[0071] In some embodiments, the semantic conversion module is specifically used to: convert the keywords of the time period into the corresponding specific date according to the semantic conversion rules, convert the keywords of the business scenario into the corresponding specific business, convert the keywords of the operation indicator into the corresponding active users, usage time, number of uses, number of clicks, page views, number of lines of code or number of documents, and convert the keywords of the measurement dimension into the corresponding user, department, gender or age; use the keywords as query parameters and the semantic conversion results corresponding to the keywords as query variables.
[0072] Each device of this embodiment can execute the information acquisition method based on natural language input described in the previous embodiment. Its implementation process and technical effects are basically the same and will not be repeated here.
[0073] The embodiment of the present invention further provides an electronic device, such as Figure 5As shown, the electronic device provided in the embodiment of the present application includes: a shell 51, a processor 52, a memory 53, a circuit board 54 and a power circuit 55, wherein the circuit board 54 is arranged inside the space enclosed by the shell 51, and the processor 52 and the memory 53 are arranged on the circuit board 54; the power circuit 55 is used to supply power to various circuits or devices of the above-mentioned electronic device; the memory 53 is used to store executable program codes; the processor 52 runs the program corresponding to the executable program code by reading the executable program code stored in the memory 53, so as to execute the information acquisition based on natural language input provided in any embodiment of the present invention.
[0074] The specific execution process of the above steps by the processor 52 and the steps further executed by the processor 52 by running the executable program code can be found in the description of the previous embodiment, which will not be repeated here.
[0075] The above-mentioned electronic devices exist in various forms, including but not limited to: (1) Mobile communication devices: These devices are characterized by having mobile communication functions and their main goal is to provide voice and data communications. Such terminals include: smart phones (such as iPhones), multimedia phones, functional phones, and low-end phones. (2) Ultra-mobile personal computer devices: These devices belong to the category of personal computers, have computing and processing functions, and generally also have mobile Internet access features. Such terminals include: PDAs, MIDs and UMPC devices, such as iPads. (3) Servers: Devices that provide computing services. The server's composition includes processors, hard disks, memory, system buses, etc. The server is similar to the general computer architecture, but because it needs to provide highly reliable services, it has higher requirements in terms of processing power, stability, reliability, security, scalability, manageability, etc. (4) Other electronic devices with data interaction functions.
[0076] An embodiment of the present application also provides a computer-readable storage medium, which stores one or more programs. The one or more programs can be executed by one or more processors to implement the information acquisition based on natural language input provided by any embodiment of the present invention, and can also achieve the corresponding technical effects, which have been described in detail above and will not be repeated here.
[0077] According to the solution provided by the present invention, natural language processing is performed on the input natural language query statement to obtain query intent and query keywords; wherein the query keywords include time period, business scenario, operation indicator and measurement dimension; semantic conversion is performed on the query intent and query keywords to obtain query variables and corresponding query parameters; according to the query variables and corresponding query parameters, a business scenario structured query language is generated; wherein the business scenario structured query language includes embedded static business statements and dynamic execution statements; the business scenario structured query language is executed in the data warehouse to obtain the query result corresponding to the natural language query statement. The present invention only needs to perform intent recognition and keyword extraction on the natural language query statement to obtain the operation indicator structured query language, and the query result can be obtained through the preset structured query language library, which has low cost and high query efficiency.
[0078] Those skilled in the art will appreciate that the modules in the devices in the embodiments may be adaptively changed and arranged in one or more devices different from the embodiments. The modules or units or components in the embodiments may be combined into one module or unit or component, and further may be divided into multiple submodules or subunits or subcomponents. All features disclosed in this specification (including the accompanying claims, abstracts and drawings) and all processes or units of any method or device disclosed in this manner may be combined in any combination, except that at least some of such features and / or processes or units are mutually exclusive. Unless otherwise expressly stated, each feature disclosed in this specification (including the accompanying claims, abstracts and drawings) may be replaced by an alternative feature that provides the same, equivalent or similar purpose. In addition, those skilled in the art will appreciate that, although some embodiments herein include certain features included in other embodiments but not other features, the combination of features of different embodiments is meant to be within the scope of the present invention and to form different embodiments. For example, in the following claims, any one of the claimed embodiments may be used in any combination. The present invention may be implemented by means of hardware including several different elements and by means of a suitably programmed computer. In a unit claim that lists several means, several of these means may be embodied by the same hardware item. The steps in the above embodiments should not be understood as limiting the execution order unless otherwise specified.
Claims
1. A method for obtaining information based on natural language input, characterized in that: include: Perform natural language processing on the input natural language information query sentence to obtain the query intent and query keywords; Performing semantic conversion on the query intent and query keywords to obtain query variables and corresponding query parameters; Generate a business scenario structured query language according to the query variables and corresponding query parameters; The business scenario structured query language is executed in the data warehouse to obtain a query result corresponding to the natural language query statement.
2. The information acquisition method based on natural language input according to claim 1, characterized in that: Generating a business scenario structured query language according to the query variables and corresponding query parameters includes: According to the query variables and corresponding query parameters, a search is performed in a predefined business scenario structured query language library, and according to the search results, a business scenario structured query language is generated.
3. The information acquisition method based on natural language input according to claim 2, characterized in that: According to the query variable and the corresponding query parameter, a search is performed in a predefined business scenario structured query language library, and according to the search result, a business scenario structured query language is generated, including: The query variables and corresponding query parameters are passed into a query statement generation interface, a search is performed in a predefined business scenario structured query language library through the query statement generation interface, and a business scenario structured query language is generated according to the search results.
4. The method for obtaining information based on natural language input according to claim 3, characterized in that: The query statement generation interface is used to search in a predefined business scenario structured query language library, and the business scenario structured query language is generated according to the search results, including: Through the query statement generation interface, a search is performed in a predefined business scenario structured query language library to obtain a first business scenario structured query language whose matching degree meets a preset threshold; Embed the query variable and the corresponding query parameter into the dynamic execution statement in the first business scenario structured query language in the form of EL expression to obtain a second business scenario structured query language; The second business scenario structured query language is used as the final business scenario structured query language.
5. The method for obtaining information based on natural language input according to claim 2, characterized in that: Generating a business scenario structured query language according to the query variables and corresponding query parameters includes: The query variables and corresponding query parameters are input into the business scenario model to predict the business scenario structured query language.
6. The method for obtaining information based on natural language input according to claim 1, characterized in that: The step of performing natural language processing on the input natural language query statement to obtain the query intent and query keywords includes: Convert the natural language query statement into a feature vector, and input the feature vector into a trained intent recognition model to obtain the query intent; The natural language query statement is input into a trained named entity recognition model to obtain query keywords including time period, business scenario, measurement dimension and operation indicator.
7. The method for obtaining information based on natural language input according to claim 6, characterized in that: The semantic conversion of the query intent and the query keywords to obtain query variables and corresponding query parameters includes: According to the semantic conversion rules, the keywords of the time period are converted into the corresponding determined dates, the keywords of the business scenarios are converted into the corresponding determined businesses, the keywords of the operation indicators are converted into the corresponding active users, usage time, number of usages, number of clicks, page views, number of lines of code or number of documents, and the keywords of the measurement dimensions are converted into the corresponding users, departments, genders or ages; The keyword is used as a query parameter, and the semantic conversion result corresponding to the keyword is used as a query variable.
8. An information acquisition device based on natural language input, characterized in that: include: The intent recognition module is used to perform natural language processing on the input natural language query sentence to obtain the query intent and query keywords; A semantic conversion module, used to perform semantic conversion on the query intent and query keywords to obtain query variables and corresponding query parameters; A query language generation module, used to generate a business scenario structured query language according to the query variables and corresponding query parameters; The data warehouse execution module is used to execute the business scenario structured query language in the data warehouse to obtain the query result corresponding to the natural language query statement.
9. An electronic device, comprising: The electronic device comprises: a shell, a processor, a memory, a circuit board and a power supply circuit, wherein the circuit board is placed inside the space enclosed by the shell, and the processor and the memory are arranged on the circuit board; the power supply circuit is used to supply power to various circuits or devices of the above-mentioned electronic device; the memory is used to store executable program code; the processor runs the program corresponding to the executable program code by reading the executable program code stored in the memory, so as to execute the information acquisition method based on natural language input described in any one of the preceding claims 1-7.
10. A computer-readable storage medium, characterized in that: include: The computer-readable storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement the information acquisition method based on natural language input as described in any one of claims 1 to 7.
Citation Information
Cited By
Data extraction method and device based on natural language and electronic equipment
CN121301368A