Natural language processing method, apparatus, device, and medium
By semantically recognizing and parsing users' natural language query requests, structured query statements are generated, solving the problems of semantic alignment deviation and security risks in enterprise-level data scenarios, and realizing efficient and secure generation of data response results.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- SHENZHEN COOCAA NETWORK TECH CO LTD
- Filing Date
- 2026-02-28
- Publication Date
- 2026-06-30
AI Technical Summary
In enterprise-level data scenarios, due to the large volume of data, strong heterogeneity, complex and dynamically evolving business semantics, large language models may experience alignment deviations and security risks in the semantic understanding, query generation and result delivery stages.
By performing semantic recognition on users' natural language query requests, generating indicator query statements, performing syntax and semantic parsing, generating semantic query requests, generating structured query statements based on preset data processing rules, performing matching and data access control, and finally generating response results.
It improves semantic alignment accuracy, reduces the decrease in accuracy caused by semantic ambiguity, and enhances the efficiency and security of response result generation.
Smart Images

Figure CN122309538A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of natural language processing technology, and in particular to a natural language processing method, apparatus, device, and medium. Background Technology
[0002] With the development of large language models, natural language querying has become a crucial demand for enterprise data consumption. Users expect to directly obtain data insights through natural language, replacing the lengthy processes of traditional manual analysis. However, in enterprise-level data scenarios, the large volume, strong heterogeneity, complex and dynamically evolving business semantics of large language models lead to alignment deviations and security risks in semantic understanding, query generation, and result delivery. Therefore, there is an urgent need for a natural language processing method that can improve semantic alignment accuracy. Summary of the Invention
[0003] This invention provides a natural language processing method, apparatus, device, and medium to address alignment discrepancies and security risks in related technologies.
[0004] In a first aspect, the present invention provides a natural language processing method, comprising: In response to the user's natural language query request, generate indicator query statements; The query statement is parsed, and a semantic query request is generated based on the semantic results obtained from the parsing. Based on semantic query requests and preset data processing rules, generate structured query statements; The structured query statement is matched with the preset query results to obtain the data matching results; Based on the data matching results, a response to the natural language query request is generated and sent to the user.
[0005] In some embodiments, in response to a user's natural language query request, a metric query statement is generated, including: Perform semantic recognition on natural language query requests to obtain the semantic features of the requests; Based on the semantic features of the request, determine the corresponding query intent; Based on the query intent, determine the target query metrics; Generate a query statement for the target query metrics.
[0006] In some embodiments, the indicator query statement is parsed, and a semantic query request is generated based on the semantic results obtained from the parsing, including: The semantic features of the indicators are obtained by parsing the syntax of the indicator query statements and extracting elements. Logical inference is performed on the semantic features of indicators based on preset semantic association rules to determine the association between the semantic features of indicators. Generate semantic query requests based on the relationships.
[0007] In some embodiments, a structured query statement is generated based on a semantic query request and preset data processing rules, including: Obtain the user's identity information and determine the user's data permissions based on the identity information; Based on semantic query requests and preset data processing rules, generate target data processing logic; Based on data permissions and target data processing logic, generate structured query statements.
[0008] In some embodiments, target data processing logic is generated based on semantic query requests and preset data processing rules, including: Based on semantic query requests and preset data processing rules, generate initial data processing logic; Based on the initial data processing logic, determine the path characteristics of the corresponding data source; Based on path characteristics, the initial data processing logic is optimized to generate the target data processing logic.
[0009] In some embodiments, a structured query statement is matched with a preset query result to obtain a data matching result, including: Based on structured query statements, determine the corresponding query data characteristics and computational logic characteristics; Based on the characteristics of the query data and the characteristics of the calculation logic, the data is matched with the feature tags in the preset query results to obtain the data matching results.
[0010] In some embodiments, based on the data matching results, a response to the natural language query request is generated, including: When the data matching result is successful, a response result is generated based on the preset query result that is successfully matched; When the data matching result fails, the corresponding data source is queried based on the structured query statement to obtain the original query result, and a response result is generated based on the original query result.
[0011] In a second aspect, the present invention provides a natural language processing apparatus, comprising: The request and response module is used to respond to users' natural language query requests and generate indicator query statements; The indicator parsing module is used to parse indicator query statements and generate semantic query requests based on the semantic results obtained from the parsing. The statement generation module is used to generate structured query statements based on semantic query requests and preset data processing rules; The data matching module is used to match structured query statements with preset query results to obtain data matching results; The results generation module is used to generate a response to a natural language query request based on the data matching results, and then send the response to the user.
[0012] Thirdly, the present invention provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the above-described natural language processing method.
[0013] Fourthly, the present invention provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the above-described natural language processing method.
[0014] The above-mentioned natural language processing methods, devices, equipment, and media implement a scheme in which the method includes: generating an index query statement in response to a user's natural language query request; parsing the index query statement and generating a semantic query request based on the semantic results obtained from the parsing; generating a structured query statement based on the semantic query request and preset data processing rules; matching the structured query statement with preset query results to obtain a data matching result; generating a response result for the natural language query request based on the data matching result, and sending the response result to the user. This method avoids the decrease in accuracy caused by semantic ambiguity when directly generating a structured query statement from natural language by parsing the natural language query request to generate an index query statement, and then generating a structured query statement based on the index query statement. Simultaneously, matching the structured query statement to generate a response result improves the efficiency of response result generation. Attached Figure Description
[0015] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the description of the embodiments of the present invention will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0016] Figure 1 This is a flowchart of a natural language processing method according to an embodiment of the present invention; Figure 2 This is a flowchart of a natural language processing method according to an embodiment of the present invention; Figure 3 This is a flowchart of a natural language processing method according to an embodiment of the present invention; Figure 4 This is a flowchart of a natural language processing method according to an embodiment of the present invention; Figure 5 This is a flowchart of a natural language processing method according to an embodiment of the present invention; Figure 6 This is a flowchart of a natural language processing method according to an embodiment of the present invention; Figure 7 This is a schematic block diagram of a natural language processing device according to an embodiment of the present invention; Figure 8 This is a schematic block diagram of a computer device according to an embodiment of the present invention. Detailed Implementation
[0017] In one embodiment, such as Figure 1 As shown, a natural language processing method is provided, including: S101, in response to the user's natural language query request, generates an indicator query statement; S102, parse the indicator query statement and generate a semantic query request based on the semantic results obtained from the parsing; S103, Generate structured query statements based on semantic query requests and preset data processing rules; S104: Match the structured query statement with the preset query results to obtain the data matching results; S105: Based on the data matching results, generate a response to the natural language query request and send the response to the user.
[0018] As an example, in step S101, when a natural language query request initiated by a user is detected, semantic recognition, query intent judgment, and core indicator extraction can be performed on the natural language query request to transform unstructured natural language content into standardized indicator query statements. The user can initiate the natural language query request through various channels such as the system terminal interactive interface, the enterprise internal office platform, and application programming interfaces. The form of the natural language query request may include text, voice, etc. If it is in the form of voice, it can be converted into text form through voice recognition technology before generating indicator query statements.
[0019] In one embodiment, during the process of generating indicator query statements, the indicator definitions can be matched and verified by combining the enterprise's preset indicator query statement library to ensure that the indicator query statements generated according to the natural language query request are consistent with the indicator definitions of the enterprise's actual business, and to avoid the distortion of subsequent query results due to misunderstanding of indicators.
[0020] The metric query language (MQL) is used to indicate the specific business metric that the natural language query request points to.
[0021] As an example, in step S102, the index query statement can first be parsed and the elements extracted to extract basic information such as atomic indicators, composite indicators, and analysis dimensions from the index query statement. Then, based on the preset semantic association rules, logical inference is performed on the extracted basic information to integrate it into a semantic result. Finally, the semantic result is encapsulated into a structured semantic query request.
[0022] In one embodiment, the query statement can be parsed by performing syntax tree analysis to identify temporal constraints, aggregation logic, and contextual dependencies. Alternatively, the query statement can be directly parsed by extracting features to obtain its semantic vector. However, this invention does not limit the method of parsing the query statement.
[0023] The semantic query request is an intermediate representation that carries the semantic elements and business logic in the index query statement. It is used to drive the generation of subsequent structured query statements and avoids semantic distortion caused by directly generating structured query statements from natural language.
[0024] As an example, in step S103, the semantic query request can be substituted into the preset data processing rules for logical deduction to determine the corresponding data processing logic and the corresponding data source, thereby generating a structured query statement that adapts to the underlying data storage.
[0025] In one embodiment, the corresponding data processing rules can be matched from preset data processing rules based on the indicator type, time range, and dimension combination contained in the semantic query request, thereby determining the corresponding data processing logic and data source, and thus generating the corresponding structured query statement. Since the structured statement is not generated by direct mapping through the semantic query request, but by logical deduction through preset data processing rules, it can effectively avoid mapping deviations caused by semantic ambiguity or grammatical vagueness, and avoid different structured query results when different users or the same user express the same indicator in different contexts.
[0026] Among them, the preset data processing rules are the pre-defined standardized processing rules, which define the standardized data processing logic corresponding to different indicator types, time granularity and dimension combinations, to ensure the consistency of data processing logic under different expressions; among them, the structured query statement is a (Structured Query Language, SQL) statement used to perform data retrieval and calculation.
[0027] As an example, in step S104, the data to be accessed and the corresponding processing methods (such as aggregation, filtering, etc.) can be extracted from the structured query statement, and then the similarity of the data with the corresponding feature identifiers in the preset query results can be matched. The matching results are then judged in combination with the preset matching judgment criteria to obtain the data matching results.
[0028] The feature identifier can be a data table name, field name, or view identifier, which can be used to indicate the data source and calculation logic corresponding to the preset query results; the preset query results are a set of query results pre-calculated and stored for the enterprise's regular data query needs to improve data query efficiency; the data matching results are the matching status determination results between the structured query statement and the preset query results, which are used to determine the method of obtaining query data in the future.
[0029] In one embodiment, various feature matching algorithms can be used to match core feature information with feature identifiers. The preset matching criteria can also be dynamically adjusted according to changes in the business needs of enterprise data query to balance the efficiency and accuracy of data query. However, this invention is not limited to these methods and does not limit the specific algorithm for feature matching.
[0030] As an example, in step S105, depending on the different matching states of the data matching results, the corresponding query results can be obtained by directly retrieving the preset query results or by performing a real-time query on the data source of the underlying stored data. Based on this, a response result for the natural language query request is generated, and then the response result is pushed to the user through the channel through which the user initiates the natural language query request.
[0031] The response result is the final data feedback result generated in response to the natural language query request initiated by the user, which carries the data information corresponding to the user's query requirements.
[0032] In one embodiment, the response result can be formatted according to the terminal type queried by the user, and necessary business description information can be added to the response result to improve the readability and business relevance of the response result. Furthermore, the response result can be semantically refined according to the expression habits in the natural language request, but it is not limited thereto. The present invention does not limit the processing and presentation of the response result.
[0033] In summary, this invention discloses a natural language processing method, comprising: generating an indicator query statement in response to a user's natural language query request; parsing the indicator query statement and generating a semantic query request based on the semantic results obtained from the parsing; generating a structured query statement based on the semantic query request and preset data processing rules; matching the structured query statement with preset query results to obtain a data matching result; generating a response result for the natural language query request based on the data matching result, and sending the response result to the user. This method avoids the decrease in accuracy caused by semantic ambiguity when directly generating structured query statements from natural language by parsing the natural language query request to generate an indicator query statement, and then generating a structured query statement based on the indicator query statement. Simultaneously, matching the structured query statement to generate the response result improves the efficiency of response result generation.
[0034] In one embodiment, such as Figure 2 As shown, step S101, which is to generate an index query statement in response to the user's natural language query request, includes: S201, Perform semantic recognition on the natural language query request to obtain the semantic features of the request; S202, Determine the corresponding query intent based on the semantic features of the request; S203, Based on the query intent, determine the target query metrics; S204, Generate indicator query statements based on target query indicators.
[0035] As an example, in step S201, a natural language processing model can be used to perform word segmentation, part-of-speech tagging, dependency parsing and named entity recognition on the natural language query request, extract relevant semantic elements, and convert them into a request semantic feature vector.
[0036] For example, taking the natural language query request "the top three products in terms of sales revenue and their gross profit margin in the last quarter" as an example, by performing semantic recognition, the time dimension "last quarter", the indicator dimensions "sales revenue" and "gross profit margin", the ranking dimension "top three" and the object dimension "product" can be extracted, and the request semantic features can be generated accordingly.
[0037] Among them, request semantic features are a set of core semantic information extracted from natural language query requests. They include elements such as indicator-related features, dimension-related features, time range features, and computational requirement features related to data queries. They serve as the direct data basis for subsequently determining the user's query intent.
[0038] In one embodiment, the initially extracted request semantic features can be denoised and deredundant, and semantic information irrelevant to the data query can be removed. Incomplete request semantic features can also be supplemented by combining the user's query context to ensure that the extracted request semantic features can fully reflect the user's query needs. However, this invention is not limited to these methods and does not limit the specific model used for semantic recognition or the specific method of feature extraction.
[0039] As an example, in step S202, intent can be classified and matched according to the request semantic features, and the semantic features can be mapped to a predefined query intent template library to identify the corresponding query intent; alternatively, the request semantic features can be directly analyzed to infer the user's query intent. The present invention does not limit the method of query intent identification.
[0040] Among them, query intent is the purpose for which a user initiates a natural language query request. It is used to indicate the type of data, analysis dimensions, and operational behaviors that the user expects to obtain.
[0041] As an example, in step S203, the indicator knowledge graph can be retrieved according to the determined query intent, and the target query indicator that matches the query intent can be matched; or the target query indicator can be derived according to the indicator parameters involved in the query intent and the logical relationship between the indicator parameters.
[0042] Among them, the target query metric is an atomic business metric that matches the user's query intent. It is an element that constitutes the metric query statement. Its metric definition is consistent with the pre-set standard definition to ensure the accuracy of subsequent data queries. In other words, the target query metric is the query metric of the smallest unit.
[0043] For example, if the query intent involves "gross profit margin of a certain product in the previous quarter", the system can automatically match the atomic indicators corresponding to "gross profit margin" in the indicator knowledge graph, such as sales revenue indicators and cost expenditure indicators, and determine them as the target query indicators.
[0044] As an example, in step S204, the determined target query metric can be combined with query constraint elements such as dimensions, time, and filtering conditions extracted from the semantic features of the request, and the metric query statement can be constructed according to the syntax rules of the metric query statement.
[0045] In one embodiment, after generating the indicator query statement, the statement can be checked for syntax compliance and indicator consistency to identify syntax errors and indicator conflicts. If a problem is detected, it can be automatically corrected or the user can be notified of the error.
[0046] It should be understood that the query statement indicates the data content that the user expects to query, but it does not indicate how that data will actually be obtained and presented.
[0047] In one embodiment, such as Figure 3 As shown, step S102, which involves parsing the index query statement and generating a semantic query request based on the semantic results obtained from the parsing, includes: S301, perform syntax parsing and element extraction on the indicator query statement to obtain the indicator semantic features; S302, Based on preset semantic association rules, perform logical inference on the semantic features of the indicators to determine the association between the semantic features of the indicators; S303, Generate a semantic query request based on the relationship.
[0048] In step S301, the indicator query statement can be parsed at multiple levels to identify keywords, operators and logical structures, and extract indicator semantic features including atomic indicators, composite indicators and dimensional information. These indicator semantic features constitute a detailed description of the indicator query statement, providing basic data support for further semantic parsing.
[0049] As an example, in step S302, the extracted semantic features of the indicators can be further analyzed through preset semantic association rules to deduce the logical dependencies between the features.
[0050] For example, if the semantic features of an indicator include the composite indicator "year-on-year growth rate", it can automatically associate the two atomic indicators it depends on, "current period value" and "last year's value", and identify the year-on-year cycle mapping relationship between the two in the time dimension.
[0051] In one embodiment, a knowledge graph can also be used to assist in inferring the association between semantic features of indicators. That is, by mapping the semantic features of indicators to nodes and edges in the knowledge graph, potential semantic associations can be automatically identified and missing contextual information can be supplemented, thereby improving the robustness of semantic parsing.
[0052] As an example, in step S303, the semantic features and logical structure of the indicators can be encapsulated into a semantic query request based on the inferred association. This request carries the user's query intent and related business logic in a standardized form, providing a clear intermediate representation for the subsequent generation of structured query statements.
[0053] In one embodiment, the semantic query request generation process can also incorporate a dynamic adjustment mechanism. For example, when ambiguity is detected in the semantic features of an indicator, a user interaction process can be triggered to request the user to provide further clarification information, thereby ensuring that the final generated semantic query request accurately reflects the user's actual needs.
[0054] In one embodiment, such as Figure 4As shown, step S103, which generates a structured query statement based on the semantic query request and preset data processing rules, includes: S401: Obtain the user's identity information and determine the user's data permissions based on the identity information; S402, Based on semantic query requests and preset data processing rules, generate target data processing logic; S403 generates a structured query statement based on data permissions and target data processing logic.
[0055] In step S401, the user's identity information can be parsed to identify the user group or role to which the user belongs, and the scope of data that the user can access and operation permissions can be determined according to the preset permission management rules, so as to ensure the security and compliance of the data and prevent the user from obtaining data beyond the scope of their permissions.
[0056] As an example, in step S402, key business logic, such as indicator type, time range and dimension combination, can be extracted from the semantic query request. Then, it is matched with the preset data processing rules to derive the target data processing logic that is adapted to the underlying data source. The target data processing logic defines how to extract, aggregate and calculate the required results from the data source to meet the user's query needs.
[0057] In one embodiment, the preset data processing rules can be based on historical query data and user feedback, and the parameters or weights in the rules can be automatically adjusted to improve the adaptability and accuracy of the rules. In addition, the rule optimization process can also incorporate suggestions provided by users to ensure that the generated data processing logic meets the actual business needs.
[0058] In other words, the pre-defined processing logic is used to ensure the uniqueness of the target data processing logic and to avoid different target data processing logics that may arise from different natural language expressions with the same semantics.
[0059] Specifically, initial data processing logic can be generated based on semantic query requests and preset data processing rules; based on the initial data processing logic, the path characteristics of the corresponding data source can be determined; based on the path characteristics, the initial data processing logic can be optimized to generate the target data processing logic.
[0060] In one embodiment, a logical graph of the semantic query request can be constructed based on the semantic query request and the corresponding preset data processing rules. Nodes in the graph represent semantic units such as indicators, dimensions, and time granularity, while edges reflect the constraints and computational dependencies between them, thereby generating initial data processing logic. Then, based on the data source affiliation of each node in the logical graph, the corresponding data source and the query method of the data source are determined, and the query method is identified as a path feature. It should be understood that the query methods of different data sources may be different, and therefore the path features may also be different. Then, based on the path features of different data sources, the initial logical graph is rewritten and merged, redundant computational paths are eliminated, the optimal query path is planned, and the target data processing logic is generated, thereby shielding the path differences of the underlying data storage and the dialect differences of the data sources.
[0061] As an example, in step S403, the target data processing logic can be combined with the user's data permissions to generate the final structured query statement. This statement not only contains the logic of data retrieval and calculation, but also embeds relevant constraints for permission control to ensure that the query results only contain the data that the user is authorized to access.
[0062] In one embodiment, such as Figure 5 As shown, step S104 involves matching the structured query statement with the preset query results to obtain the data matching results, including: S501, based on the structured query statement, determine the corresponding query data characteristics and computational logic characteristics; S502, based on the query data features and calculation logic features, matches them with the feature tags in the preset query results to obtain data matching results.
[0063] As an example, in step S501, key information such as data fields, calculation formulas and logical operators involved in the structured query statement can be extracted by parsing the statement and transformed into query data features and calculation logic features.
[0064] For example, if a structured query contains the calculation logic of "sales amount summaries by month", "sales amount" can be extracted as a data field, "summaries by month" can be extracted as a calculation logic feature, and further refined into aggregation operations on the time dimension. By extracting the above features, the accuracy of the subsequent matching process can be ensured.
[0065] In one embodiment, in step S502, the extracted query data features and computational logic features can be compared with the feature tags in the preset query results. The feature tags in the preset query results are standardized descriptions generated in advance according to regular query requirements, which are used to indicate the data source and computational logic type corresponding to the query results.
[0066] As an example, if the query data features include "sales volume" and "time dimension", and the calculation logic feature is "monthly summary", the system searches for a set of results with the same feature labels in the preset query results. If a completely matching feature label is found, the match is considered successful; if only a partial match or no match is found, the match is considered unsuccessful.
[0067] It should be understood that data matching results include not only the determination of the matching status, but also a quantitative assessment of the degree of matching. For example, a matching score can be calculated based on the proportion of overlapping features, thus providing a basis for subsequent selection of query methods.
[0068] In addition, to improve matching efficiency, a caching mechanism can be introduced to store the features of recent high-frequency queries and their corresponding results in a high-speed cache so that they can respond quickly in subsequent queries.
[0069] In one embodiment, such as Figure 6 As shown, step S105, which is to generate a response to the natural language query request based on the data matching results, includes: S601, When the data matching result is a successful match, generate a response result based on the preset query result that has been successfully matched; S602, when the data matching result is a failure, the corresponding data source is queried based on the structured query statement to obtain the original query result, and a response result is generated based on the original query result.
[0070] In step S601, if the data matching result is successful, data content that is completely consistent with the feature tags can be directly extracted from the preset query results and converted into a natural language form that the user can understand as the response result. This method not only improves query efficiency but also reduces repeated access to the underlying data source, thereby reducing system load. As an example, when generating the response result, the preset query results can be formatted according to the user's query intent. For example, numerical data can be converted into descriptive text with units, or time-dimensional aggregation results can be presented in the form of charts or trend analysis so that users can understand the query results more intuitively.
[0071] In step S602, if the data matching result is a failure, the underlying data source can be directly accessed according to the structured query statement, and the corresponding logical calculations can be performed to obtain the original query result. Based on the original query result, a response result that conforms to the user's semantics is generated. During this process, the user's data permissions will be taken into account to ensure that the query scope is limited to the subset of data that the user is allowed to access.
[0072] In one embodiment, when the data matching result is a partial match, the closest preset query result can be automatically selected based on a quantitative assessment of the matching degree, and the user can be informed of the incompletely matched portion through supplementary explanations. For example, the response result can indicate "No completely matched results were found for some conditions of the current query; the closest data has been shown to you"; alternatively, the preset query results for the matched portion can be retained, while the data source for the unmatched portion can be directly accessed and merged to generate the original query result, which is then output as the response result.
[0073] Furthermore, when generating response results, the display method can be dynamically adjusted based on user preferences. For example, for users who prefer graphical displays, the query results can be presented in the form of bar charts, line charts, or pie charts; while for users who prefer text descriptions, detailed text descriptions can be generated to ensure that the response results can meet the user's actual needs to the greatest extent.
[0074] Optionally, it can also record interaction logs between natural language query requests and response results, which can be used to analyze user query habits, optimize matching strategies, and train more accurate semantic understanding models to achieve closed-loop feedback and provide data support for subsequent iterations and upgrades.
[0075] It should be understood that the sequence number of each step in the above embodiments does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.
[0076] In one embodiment, a natural language processing apparatus is provided, which corresponds one-to-one with the natural language processing methods described in the above embodiments. For example... Figure 7 As shown, the natural language processing device includes a request-response module 701, an indicator parsing module 702, a sentence generation module 703, a data matching module 704, and a result generation module 705. Detailed descriptions of each functional module are as follows: The request and response module 701 is used to respond to the user's natural language query request and generate an indicator query statement; The indicator parsing module 702 is used to parse the indicator query statement and generate a semantic query request based on the semantic results obtained from the parsing. The statement generation module 703 is used to generate structured query statements based on semantic query requests and preset data processing rules; The data matching module 704 is used to match structured query statements with preset query results to obtain data matching results; The result generation module 705 is used to generate a response result for a natural language query request based on the data matching result, and send the response result to the user.
[0077] In one embodiment, the request response module 701 is further configured to perform semantic recognition on the natural language query request to obtain the request semantic features; Based on the semantic features of the request, determine the corresponding query intent; Based on the query intent, determine the target query metrics; Generate a query statement for the target query metrics.
[0078] In one embodiment, the indicator parsing module 702 is further configured to perform syntax parsing and element extraction on the indicator query statement to obtain the indicator semantic features; Logical inference is performed on the semantic features of indicators based on preset semantic association rules to determine the association between the semantic features of indicators. Generate semantic query requests based on the relationships.
[0079] In one embodiment, the statement generation module 703 is further configured to obtain the user's identity information and determine the user's data permissions based on the identity information; Based on semantic query requests and preset data processing rules, generate target data processing logic; Based on data permissions and target data processing logic, generate structured query statements.
[0080] In one embodiment, the statement generation module 703 is further configured to generate initial data processing logic based on the semantic query request and preset data processing rules; Based on the initial data processing logic, determine the path characteristics of the corresponding data source; Based on path characteristics, the initial data processing logic is optimized to generate the target data processing logic.
[0081] In one embodiment, the data matching module 704 is further configured to determine the corresponding query data features and computational logic features based on the structured query statement; Based on the characteristics of the query data and the characteristics of the calculation logic, the data is matched with the feature tags in the preset query results to obtain the data matching results.
[0082] In one embodiment, the result generation module 705 is further configured to generate a response result based on the preset query result that has been successfully matched when the data matching result is a successful match; When the data matching result fails, the corresponding data source is queried based on the structured query statement to obtain the original query result, and a response result is generated based on the original query result.
[0083] This invention provides a natural language processing device, comprising: a request-response module for responding to a user's natural language query request and generating an indicator query statement; an indicator parsing module for parsing the indicator query statement and generating a semantic query request based on the semantic results obtained from the parsing; a statement generation module for generating a structured query statement based on the semantic query request and preset data processing rules; a data matching module for matching the structured query statement with preset query results to obtain a data matching result; and a result generation module for generating a response result for the natural language query request based on the data matching result and sending the response result to the user. This device avoids the decrease in accuracy caused by semantic ambiguity when directly generating structured query statements from natural language by parsing the natural language query request to generate an indicator query statement, and then generating a structured query statement based on the indicator query statement. Simultaneously, it improves the efficiency of response result generation by matching the structured query statement to generate the response result.
[0084] In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 8 As shown, the computer device includes a processor, memory, network interface, and database connected via a system bus. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and database. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The database is used for data employed in natural language processing methods. The network interface is used for communication with external terminals via a network connection. When executed by the processor, the computer program can implement a natural language processing method.
[0085] In one embodiment, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the computer program, implements a natural language processing method.
[0086] In one embodiment, a computer-readable storage medium is provided that stores a computer program, which, when executed by a processor, implements a natural language processing method.
[0087] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. This computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments of the above methods. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), IAMbus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0088] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is used as an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above.
[0089] The above-described embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included within the protection scope of the present invention.
Claims
1. A natural language processing method, characterized in that, include: Responding to the user's natural language query request, generate indicator query statements; The query statement of the indicator is parsed, and a semantic query request is generated based on the semantic results obtained from the parsing. Based on the semantic query request and preset data processing rules, a structured query statement is generated; The structured query statement is matched with the preset query results to obtain the data matching result; Based on the data matching results, a response result for the natural language query request is generated, and the response result is sent to the user.
2. The method according to claim 1, characterized in that, The step of generating an index query statement in response to a user's natural language query request includes: Semantic recognition is performed on the natural language query request to obtain the request semantic features; Based on the semantic features of the request, the corresponding query intent is determined; Based on the query intent, determine the target query metrics; Based on the target query metric, the metric query statement is generated.
3. The method according to claim 1, characterized in that, The step of parsing the indicator query statement and generating a semantic query request based on the semantic results obtained from the parsing includes: The query statement for the indicator is parsed and elements are extracted to obtain the semantic features of the indicator. Logical inference is performed on the semantic features of the indicators based on preset semantic association rules to determine the association relationship between the semantic features of the indicators; Based on the aforementioned relationship, the semantic query request is generated.
4. The method according to claim 1, characterized in that, The step of generating a structured query statement based on the semantic query request and preset data processing rules includes: Obtain the user's identity information, and determine the user's data permissions based on the identity information; Based on the semantic query request and the preset data processing rules, the target data processing logic is generated; Based on the data permissions and the target data processing logic, the structured query statement is generated.
5. The method according to claim 4, characterized in that, The step of generating target data processing logic based on the semantic query request and the preset data processing rules includes: Based on the semantic query request and the preset data processing rules, the initial data processing logic is generated; Based on the initial data processing logic, the path characteristics of the corresponding data source are determined; Based on the path characteristics, the initial data processing logic is optimized to generate the target data processing logic.
6. The method according to claim 1, characterized in that, The step of matching the structured query statement with the preset query results to obtain data matching results includes: Based on the structured query statement, the corresponding query data characteristics and computational logic characteristics are determined; Based on the query data features and the calculation logic features, the data matching results are obtained by matching them with the feature tags in the preset query results.
7. The method according to claim 1, characterized in that, The step of generating a response result for the natural language query request based on the data matching result includes: When the data matching result is a successful match, the response result is generated based on the preset query result that is a successful match; When the data matching result is a failure, the corresponding data source is queried based on the structured query statement to obtain the original query result, and the response result is generated based on the original query result.
8. A natural language processing device, characterized in that, include: The request and response module is used to respond to users' natural language query requests and generate indicator query statements; The indicator parsing module is used to parse the indicator query statement and generate a semantic query request based on the semantic results obtained from the parsing. The statement generation module is used to generate structured query statements based on the semantic query request and preset data processing rules; The data matching module is used to match the structured query statement with the preset query results to obtain the data matching result; The result generation module is used to generate a response result for the natural language query request based on the data matching result, and send the response result to the user.
9. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the natural language processing method as described in any one of claims 1 to 7.
10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the natural language processing method as described in any one of claims 1 to 7.