CN114428788B - Natural language processing method, device, equipment and storage medium - Google Patents
Natural language processing method, device, equipment and storage medium Download PDFInfo
- Publication number
- CN114428788B CN114428788B CN202210106438.2A CN202210106438A CN114428788B CN 114428788 B CN114428788 B CN 114428788B CN 202210106438 A CN202210106438 A CN 202210106438A CN 114428788 B CN114428788 B CN 114428788B
- Authority
- CN
- China
- Prior art keywords
- entity
- aggregation
- character string
- natural language
- sequence
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
- 238000003058 natural language processing Methods 0.000 title claims abstract description 159
- 238000000034 method Methods 0.000 title claims abstract description 103
- 238000004220 aggregation Methods 0.000 claims abstract description 311
- 230000002776 aggregation Effects 0.000 claims abstract description 296
- 230000004931 aggregating effect Effects 0.000 claims abstract description 18
- 238000012545 processing Methods 0.000 claims description 42
- 230000008569 process Effects 0.000 claims description 41
- 230000015654 memory Effects 0.000 claims description 23
- 238000004458 analytical method Methods 0.000 claims description 18
- 230000011218 segmentation Effects 0.000 claims description 16
- 238000004590 computer program Methods 0.000 claims description 12
- 238000013507 mapping Methods 0.000 claims description 11
- 238000003062 neural network model Methods 0.000 claims description 5
- 238000006116 polymerization reaction Methods 0.000 claims description 5
- 238000013473 artificial intelligence Methods 0.000 abstract description 9
- 238000005516 engineering process Methods 0.000 abstract description 3
- 238000010586 diagram Methods 0.000 description 21
- 238000000605 extraction Methods 0.000 description 17
- 230000006870 function Effects 0.000 description 15
- 238000013528 artificial neural network Methods 0.000 description 10
- 230000003993 interaction Effects 0.000 description 10
- 238000006243 chemical reaction Methods 0.000 description 7
- 238000004422 calculation algorithm Methods 0.000 description 6
- 238000004891 communication Methods 0.000 description 5
- 238000010801 machine learning Methods 0.000 description 4
- 238000013527 convolutional neural network Methods 0.000 description 3
- 235000019800 disodium phosphate Nutrition 0.000 description 2
- 239000000284 extract Substances 0.000 description 2
- 238000002372 labelling Methods 0.000 description 2
- 239000000203 mixture Substances 0.000 description 2
- 238000012986 modification Methods 0.000 description 2
- 230000004048 modification Effects 0.000 description 2
- 230000001537 neural effect Effects 0.000 description 2
- 230000003287 optical effect Effects 0.000 description 2
- 230000000306 recurrent effect Effects 0.000 description 2
- 238000011160 research Methods 0.000 description 2
- 238000013515 script Methods 0.000 description 2
- BSFODEXXVBBYOC-UHFFFAOYSA-N 8-[4-(dimethylamino)butan-2-ylamino]quinolin-6-ol Chemical compound C1=CN=C2C(NC(CCN(C)C)C)=CC(O)=CC2=C1 BSFODEXXVBBYOC-UHFFFAOYSA-N 0.000 description 1
- 241000282412 Homo Species 0.000 description 1
- 101100237842 Xenopus laevis mmp18 gene Proteins 0.000 description 1
- 238000013459 approach Methods 0.000 description 1
- 238000003491 array Methods 0.000 description 1
- 230000006399 behavior Effects 0.000 description 1
- 230000009286 beneficial effect Effects 0.000 description 1
- 238000013529 biological neural network Methods 0.000 description 1
- 230000005540 biological transmission Effects 0.000 description 1
- 238000012937 correction Methods 0.000 description 1
- 238000012217 deletion Methods 0.000 description 1
- 230000037430 deletion Effects 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 230000018109 developmental process Effects 0.000 description 1
- 230000006872 improvement Effects 0.000 description 1
- 230000006698 induction Effects 0.000 description 1
- 238000013178 mathematical model Methods 0.000 description 1
- 230000002093 peripheral effect Effects 0.000 description 1
- 238000004549 pulsed laser deposition Methods 0.000 description 1
- 230000002787 reinforcement Effects 0.000 description 1
- 239000007787 solid Substances 0.000 description 1
- 238000012549 training Methods 0.000 description 1
- 238000013526 transfer learning Methods 0.000 description 1
- 230000001960 triggered effect Effects 0.000 description 1
- 230000000007 visual effect Effects 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/24—Querying
- G06F16/242—Query formulation
- G06F16/243—Natural language query formulation
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/24—Querying
- G06F16/242—Query formulation
- G06F16/2433—Query languages
- G06F16/244—Grouping and aggregation
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F40/00—Handling natural language data
- G06F40/20—Natural language analysis
- G06F40/279—Recognition of textual entities
- G06F40/289—Phrasal analysis, e.g. finite state techniques or chunking
- G06F40/295—Named entity recognition
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F40/00—Handling natural language data
- G06F40/30—Semantic analysis
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- Computational Linguistics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Artificial Intelligence (AREA)
- Mathematical Physics (AREA)
- Audiology, Speech & Language Pathology (AREA)
- General Health & Medical Sciences (AREA)
- Health & Medical Sciences (AREA)
- Data Mining & Analysis (AREA)
- Databases & Information Systems (AREA)
- Machine Translation (AREA)
Abstract
The application provides a natural language processing method, a device, equipment, a storage medium and a program product, which are applied to various scenes such as cloud technology, artificial intelligence, intelligent transportation, vehicle-mounted and the like; the natural language processing method comprises the following steps: performing entity recognition on the natural language description to obtain an entity character string sequence, wherein each entity character string in the entity character string sequence is a label of an entity in the natural language description in a target language; aggregating the entity character string sequences based on a target grammar, and aggregating and returning the entity character string sequences with failed aggregation, wherein the target grammar is the grammar of a target language; re-aggregating based on the aggregation rollback result to obtain semantic information to be analyzed, wherein the semantic information to be analyzed is an aggregation relation among entity character strings in the entity character sequence; and analyzing the semantic information to be analyzed to obtain the target language description. The application can improve the accuracy of natural language processing.
Description
Technical Field
The present application relates to a natural language processing technology in the field of artificial intelligence, and in particular, to a natural language processing method, apparatus, device, storage medium, and program product.
Background
With the rapid development of artificial intelligence, natural language processing is applied to every corner in life. In natural language processing, a process of converting a natural language description into a structured query language description is often involved to interact with a database based on structured query language text, thereby enabling processing of the database based on the natural language description.
Generally, in order to convert a natural language description into a structured query language description, entity tags (such as column names, table names, etc.) are generally extracted from the natural language description, adjacent entity tags are aggregated, and finally the aggregated local aggregation results are spliced to obtain the structured query language description. However, in the process of converting the natural language description into the structured query language description, adjacent entity tags determine an aggregation result, which may cause the finally obtained structured query language description to be erroneous; therefore, the accuracy of natural language processing is low.
Disclosure of Invention
The embodiment of the application provides a natural language processing method, a device, equipment, a computer readable storage medium and a computer program product, which can improve the accuracy of natural language processing.
The technical scheme of the embodiment of the application is realized as follows:
The embodiment of the application provides a natural language processing method, which comprises the following steps:
Performing entity recognition on natural language description to obtain an entity character string sequence, wherein the natural language description is information for interacting with a database by adopting natural language description, and each entity character string in the entity character string sequence is a label of an entity in the natural language description in a target language;
Aggregating the entity character string sequences based on target grammar, and aggregating and returning the entity character string sequences with failed aggregation, wherein the target grammar is the grammar of target language;
Re-aggregating based on an aggregation rollback result to obtain semantic information to be analyzed, wherein the semantic information to be analyzed is an aggregation relation between the entity character strings in the entity character sequence;
Analyzing the semantic information to be analyzed to obtain target language description, wherein the target language description is information which adopts the target language description and is used for interacting with the database.
The embodiment of the application provides a natural language processing device, which comprises:
The entity recognition module is used for carrying out entity recognition on the natural language description to obtain an entity character string sequence, wherein the natural language description is information for interacting with a database by adopting the natural language description, and each entity character string in the entity character string sequence is a label of an entity in the natural language description in a target language;
the sequence aggregation module is used for aggregating the entity character string sequences based on target grammar, and aggregating and returning the entity character string sequences which are failed to aggregate, wherein the target grammar is the grammar of a target language;
the sequence aggregation module is further configured to perform re-aggregation based on an aggregation rollback result to obtain semantic information to be resolved, where the semantic information to be resolved is an aggregation relationship between the entity character strings in the entity character sequence;
The information analysis module is used for analyzing the semantic information to be analyzed to obtain target language description, wherein the target language description is information which adopts the target language description and is used for interacting with the database.
In the embodiment of the present application, the aggregate backoff includes at least one of entity string backoff and sequence backoff, where the entity string backoff refers to a backoff process for performing re-aggregation on the entity string, and the entity string backoff refers to a backoff process for performing re-aggregation on the next entity string sequence of the entity string sequence.
In the embodiment of the present application, when the aggregation fallback includes entity string fallback, the aggregation fallback result is the consecutive entity strings in the entity string sequence that fail aggregation.
In the embodiment of the present application, the sequence aggregation module is further configured to aggregate, for the consecutive entity strings that fail aggregation in the entity string sequence, the entity strings that are adjacent and do not belong to an aggregation manner corresponding to the target grammar into a specified aggregation result; and aggregating the appointed aggregation result to obtain the semantic information to be analyzed.
In the embodiment of the present application, the information parsing module is further configured to obtain, in the semantic information to be parsed, a target entity string that is in a sibling relationship with the entity string in the specified aggregation result; and resolving the entity character string and the target entity character string in the appointed aggregation result to obtain the target language description.
In the embodiment of the present application, when the aggregation fallback includes sequence fallback, the aggregation fallback result is the next entity string sequence of the entity string sequence that fails to aggregate, where the entity string sequence that fails to aggregate and the next entity string sequence belong to at least two entity string sequences corresponding to the natural language description, and each entity string sequence corresponds to an entity segmentation manner of the natural language description.
In the embodiment of the present application, the sequence aggregation module is further configured to re-aggregate the next entity string sequence to obtain the semantic information to be parsed.
In the embodiment of the present application, when the aggregation and backoff includes entity string backoff and sequence backoff, the sequence aggregation module is further configured to perform the entity string backoff on the entity string sequence that fails to aggregate, so as to obtain an entity string backoff result; re-aggregating the entity character string rollback results; and carrying out sequence backspacing on the entity character string backspacing result with aggregation failure, wherein the sequence backspacing result is the aggregation backspacing result.
In an embodiment of the present application, the natural language processing device further includes a resource obtaining module, configured to obtain a domain resource of the natural language description, where the domain resource includes at least one of an entity string library and an entity recognition model, and the entity recognition model is a neural network model for recognizing an entity.
In the embodiment of the present application, the entity recognition module is further configured to perform entity recognition on the natural language description based on the domain resource, so as to obtain the entity string sequence.
In the embodiment of the application, the entity recognition module is further used for extracting the entity from the natural language description to obtain an initial entity character string sequence; and mapping the initial entity character string in the initial entity character string sequence into the entity character string based on the corresponding relation between the database attribute and the entity to obtain the entity character string sequence corresponding to the initial entity character string, wherein the corresponding relation between the database attribute and the entity is the corresponding relation between the attribute in the database and the entity described by the natural language.
In the embodiment of the present application, the sequence aggregation module is further configured to map each of the entity strings in the entity string sequence to a syntax element of the target syntax, so as to obtain a syntax element sequence corresponding to the entity string sequence; and carrying out layer-by-layer aggregation on the grammar element sequence based on an aggregation rule corresponding to the target grammar until the aggregation is finished when the aggregation is a single aggregation result, wherein the semantic information to be analyzed comprises the single aggregation result.
In the embodiment of the present application, the sequence aggregation module is further configured to determine that the aggregation is successful when the entity string corresponding to the single aggregation result includes the entity string sequence; and when the entity character string corresponding to the single aggregation result comprises part of the entity character strings in the entity character string sequence, determining that aggregation fails.
In the embodiment of the application, the information analysis module is used for analyzing the semantic information to be analyzed layer by layer to obtain sub-descriptions to be spliced; and splicing the sub-descriptions to be spliced to obtain the target language description.
In the embodiment of the application, the natural language processing device further comprises a database interaction module, which is used for processing the database based on the target language description to obtain a database processing result, wherein the database processing result comprises at least one of inquired target data, a deleting result, a modifying result and an adding result; and presenting the database processing result.
The embodiment of the application provides natural language processing equipment, which comprises the following components:
a memory for storing executable instructions;
and the processor is used for realizing the natural language processing method provided by the embodiment of the application when executing the executable instructions stored in the memory.
The embodiment of the application provides a computer readable storage medium which stores executable instructions for realizing the natural language processing method provided by the embodiment of the application when being executed by a processor.
The embodiment of the application provides a computer program product, which comprises a computer program or instructions, wherein the computer program or instructions realize the natural language processing method provided by the embodiment of the application when being executed by a processor.
The embodiment of the application has at least the following beneficial effects: in the process of processing the natural language description, when the aggregation of the entity character string sequence corresponding to the natural language description fails, the aggregation can be carried out again through aggregation rollback, so that the correct semantic information to be analyzed can be obtained; therefore, when the semantic information to be analyzed is analyzed, the correct target language text can be obtained; therefore, the accuracy of natural language processing can be improved.
Drawings
FIG. 1 is a schematic diagram of an exemplary natural language processing;
FIG. 2 is a schematic diagram of another exemplary natural language processing;
FIG. 3 is a schematic diagram of a natural language processing system according to an embodiment of the present application;
fig. 4 is a schematic diagram of a composition structure of the server in fig. 3 according to an embodiment of the present application;
FIG. 5 is a flowchart illustrating a natural language processing method according to an embodiment of the present application;
FIG. 6 is a second flow chart of a natural language processing method according to an embodiment of the present application;
FIG. 7 is a flowchart illustrating a natural language processing method according to an embodiment of the present application;
FIG. 8 is a schematic diagram of an exemplary application flow provided by an embodiment of the present application;
FIG. 9 is a schematic diagram of an exemplary database provided by an embodiment of the present application;
FIG. 10 is a schematic diagram of an exemplary data query provided by an embodiment of the present application;
FIG. 11 is a schematic illustration of an exemplary natural language processing flow provided by an embodiment of the present application;
FIG. 12 is a schematic diagram of another exemplary natural language processing flow provided by an embodiment of the present application;
FIG. 13 is a schematic diagram of an exemplary aggregate rollback procedure provided by an embodiment of the present application;
fig. 14 is a schematic diagram of another exemplary aggregate rollback procedure provided in an embodiment of the present application.
Detailed Description
The present application will be further described in detail with reference to the accompanying drawings, for the purpose of making the objects, technical solutions and advantages of the present application more apparent, and the described embodiments should not be construed as limiting the present application, and all other embodiments obtained by those skilled in the art without making any inventive effort are within the scope of the present application.
In the following description, reference is made to "some embodiments" which describe a subset of all possible embodiments, but it is to be understood that "some embodiments" can be the same subset or different subsets of all possible embodiments and can be combined with one another without conflict.
Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used in the embodiments of the application is for the purpose of describing embodiments of the application only and is not intended to be limiting of the application.
Before describing embodiments of the present application in further detail, the terms and terminology involved in the embodiments of the present application will be described, and the terms and terminology involved in the embodiments of the present application will be used in the following explanation.
1) Artificial intelligence (ARTIFICIAL INTELLIGENCE, AI) is a theory, method, technique, and application system that uses a digital computer or a machine controlled by a digital computer to simulate, extend, and expand human intelligence, sense the environment, acquire knowledge, and use knowledge to obtain optimal results.
2) Machine learning (MACHINE LEARNING, ML) is a multi-domain interdisciplinary, involving multiple disciplines such as probability theory, statistics, approximation theory, convex analysis, algorithm complexity theory, and the like. Specially researching how a computer simulates or implements learning behavior of a human to acquire new knowledge or skill; reorganizing the existing knowledge structure to continuously improve the performance of the knowledge structure. Machine learning is the core of artificial intelligence, a fundamental approach to letting computers have intelligence, which is applied throughout various areas of artificial intelligence. Machine learning typically includes techniques such as artificial neural networks, belief networks, reinforcement learning, transfer learning, and induction learning.
3) An artificial neural network is a mathematical model that mimics the structure and function of a biological neural network, and exemplary structures of the artificial neural network in embodiments of the present application include deep neural networks (Deep Neural Networks, DNN), convolutional neural networks (Convolutional Neural Network, CNN) and recurrent neural networks (Recurrent Neural Network, RNN), neural state machines (Neural STATE MACHINE, NSM), and Phase-function neural networks (Phase-Functioned Neural Network, PFNN), among others. The entity recognition model related in the embodiment of the application is a model of an artificial neural network.
4) Natural language processing (Nature Language Processing, NLP), an important direction in the fields of computer science and artificial intelligence, is used to study various theories and methods that enable efficient communication between humans and computers in natural language. The natural language processing is a science integrating linguistics, computer science and mathematics, so the research in the field of natural language processing relates to natural language, namely the language used by people in daily life, and the research of natural language and linguistics has close relation.
5) The natural language to structured query language (Nature Language to Structured Query Language, NL2 SQL) refers to converting the natural language into a normalized semantic representation (Formal Meaning Represention) that can be understood by the electronic device. The NL2SQL task is a type of semantic parsing task, and is used for converting a natural language problem input by a user into an SQL query statement that can operate with a database, so as to complete interaction with the database and obtain information in the database through the natural language.
6) A context-free decision algorithm (Cocke Younger Kasami Algorithm, CYK algorithm) for determining whether a string conforms to the context-free grammar algorithm; where Context free grammar (Context FREE GRAMMAR, CFG) refers to the fact that character V always can be replaced by string w, regardless of the Context in which character V appears. In the embodiment of the application, the aggregation is performed by a CYK algorithm.
7) Grammar aggregation refers to the process of aggregating character strings corresponding to natural language from bottom to top into hierarchical semantic information based on grammar of a structured query language; in the embodiment of the application, the polymerization is simply called.
8) Hierarchical parsing refers to a process of parsing hierarchical semantic information layer by adopting top-down to obtain a structured query language; in the embodiment of the application, the analysis is called simply.
9) Domain applicability refers to the ability of a neural network model to be applied to different domains (e.g., financial domain, educational domain, etc.).
10 Natural language parsing robustness, which refers to the generalization ability when processing diverse natural language descriptions; the stronger the natural language parsing robustness is, the less affected the parsing result is by the description sequence of the natural language and whether there is ambiguity.
Generally, in order to convert a natural language description into a structured query language description, entity tag extraction is usually performed on the natural language description, adjacent entity tags are aggregated, and finally, the aggregated local aggregation results are spliced to obtain the structured query language description.
Referring to FIG. 1, FIG. 1 is a schematic diagram of an exemplary natural language processing; as shown in fig. 1, a user question 1-11 (called natural language description) is subjected to component mapping by using database information 1-12, synonym information 1-131 in the general field and a question template 1-132 to obtain an entity component 1-2; obtaining entity tags (such as column names, table names, etc.) of the entity components 1-2 by using the tag identification model 1-3; querying adjacent entity labels in the SQL grammar library 1-4 based on the problem template 1-132, and aggregating the queried adjacent entity labels into a new grammar unit 1-5 (called a local aggregation result); in the polymerization process, scoring is carried out based on the similarity of the polymerized grammar units and the problems by using scoring models 1-6, so that the grammar unit with the highest score is selected as a new grammar unit; the concatenation of the new grammar elements results in SQL statements 1-7 (referred to as structured query language descriptions).
Referring to fig. 2 with reference to fig. 1, fig. 2 is a schematic diagram of another exemplary natural language processing; as shown in fig. 2, a process of performing natural language processing using the processing flow shown in fig. 1 is described; as shown in fig. 2, for the user problem 2-1 (greening not less than 30% of cities and giving their occupation area) and the database 2-2 (namely, city tables including names (abbreviated as Col 0), provinces (abbreviated as Col 1), population (ten thousands) (abbreviated as Col 2), area (abbreviated as Col 3) and greening rate (abbreviated as Col 4), synonym information 1-13, tag recognition model 1-3, SQL grammar library 1-4 of the general field in fig. 1 are adopted for aggregation to obtain individual new grammar units 2-3 ("condition: col4> =num", "select: tab.col0", "select: col3", "select: col0, col3" and "sele ct: col0, col3 wmer Col 4") and finally, based on individual new grammar units 2-3, concatenation is called SQL sentence 2-4 (referred to as structured query language). Where "condition", "Num", "T ab" and "select" are information in the SQL grammar library.
Based on fig. 1 and fig. 2, it can be determined that in the process of obtaining the SQL statement based on the aggregation of the user problem, since in the process of detecting whether the adjacent entity tags can be aggregated, at least one entity tag capable of being aggregated is directly aggregated into a grammar unit, and since the grammar unit is an SQL clause, each aggregation in the aggregation process can obtain a local aggregation result; in addition, in the aggregation process, the adjacent entity tags can aggregate a local aggregation result, the aggregation is performed based on the adjacent entity tags, and the natural language description modes are various, for example, long-distance semantic relations exist in some natural language description texts, namely other entity tags are included between two contextually relevant entity tags, at this time, the aggregation is performed based on the adjacent entity tags, so that the finally obtained structured query language description is wrong; therefore, the accuracy and robustness of natural language processing is low.
Illustratively, the user question "what is the average teacher wage for each county? When the processing is performed, the obtained local aggregation result which can be aggregated by the label average (function) and the label teacher wage (column name) is SELECT AVG (teacher wage), and a correct SQL sentence can be obtained. In contrast, when the natural language processing procedure shown in fig. 1 is used to process the user question "what the average wages of the teacher wages are in each county", since the label "county" (column name) is included between the label "teacher wages" (column names) and the label "average" (functions), the result of aggregation is an erroneous SQL statement including "select teacher wages, county" or "SELECT AVG (county)". That is, for a varied natural language description, the natural language processing method shown in fig. 1 is poor in accuracy and robustness.
In addition, it should be noted that, in the above natural language processing, the correctness of the obtained structured query language description also depends on the recognition result of the entity component. Since natural language is diverse in description order and often includes cases where ambiguity exists, the accuracy of the obtained physical components is low; when the obtained entity components are erroneous due to recognition errors, the structured query language description aggregated based on the entity components is also erroneous.
Illustratively, the user question "distribution of the number of stem teachers of each county under query" may be divided into a recognition result 1 "distribution of the number of stem teachers (column values) of each county |county under query (erroneous recognition result) and a recognition result 2" distribution of the number of stem teachers (column values) of each county|county (column names) |stem teacher (function) | (correct recognition result) "; since "county backbone teacher" is a column value, the request of "each" such traversal cannot be used, so that the recognition result 1 is a wrong recognition result, resulting in that the obtained SQL statement is also wrong. This is because the field adaptability of natural language processing is low, and thus, the method is applied to fields such as financial fields and educational fields.
In addition, in the process of component mapping and grammar unit aggregation in FIGS. 1 and 2, problem templates 1-132 are used; the problem templates 1-132 are utilized to perform conversion on the description of the user problem, and grammar unit aggregation is performed by combining the problem templates 1-132 with the SQL grammar library 1-4; thus, the dependency on the problem templates 1-132 in the natural language processing process results in a higher complexity of the aggregation process, resulting in a lower efficiency of the natural language processing.
Based on the above, embodiments of the present application provide a method, an apparatus, a device, a computer readable storage medium, and a computer program product for processing natural language, which can improve efficiency, accuracy, and robustness of natural language processing, and can also improve field applicability of natural language processing. The following describes an exemplary application of the natural language processing device provided by the embodiment of the present application, where the natural language processing device provided by the embodiment of the present application may be implemented as various types of terminals, such as a smart phone, a smart watch, a notebook computer, a tablet computer, a desktop computer, an intelligent home appliance, a set-top box, an intelligent vehicle-mounted device, a portable music player, a personal digital assistant, a dedicated messaging device, an intelligent voice interaction device, a portable game device, and an intelligent sound box, and may also be implemented as a server. In the following, an exemplary application when the natural language processing device is implemented as a server will be described.
Referring to fig. 3, fig. 3 is a schematic architecture diagram of a natural language processing system according to an embodiment of the present application; as shown in fig. 3, to support a natural language processing application, in the natural language processing system 100, a terminal 200 (the terminal 200-1 and the terminal 200-2 are exemplarily shown) is connected to a server 400 (referred to as a natural language processing device) through a network 300, and the network 300 may be a wide area network or a local area network, or a combination of both. In addition, the natural language processing system 100 further includes a database 500 for providing data support to the server 400; also, the database 500 shown in fig. 1 is a case independent of the server 400, and furthermore, the database 500 may be integrated in the server 400, which is not limited by the embodiment of the present application.
The terminal 200 is configured to send a natural language description to a server through the network 300, receive a database processing result corresponding to the natural language description sent by the server through the network 300, and display the database processing result in a graphical interface.
The server 400 is configured to receive, through the network 300, a natural language description sent by the terminal 200, and perform entity recognition on the natural language description to obtain an entity string sequence, where the natural language description is information for interacting with a database by using the natural language description, and each entity string in the entity string sequence is a tag of an entity in the natural language description in a target language; aggregating the entity character string sequences based on a target grammar, and aggregating and returning the entity character string sequences with failed aggregation, wherein the target grammar is the grammar of a target language; re-aggregating based on the aggregation rollback result to obtain semantic information to be analyzed, wherein the semantic information to be analyzed is an aggregation relation among entity character strings in the entity character sequence; analyzing semantic information to be analyzed to obtain target language description, wherein the target language description is information which adopts the target language description and is used for interacting with a database; processing the database based on the target language description to obtain a database processing result; the database processing result corresponding to the natural language description is transmitted to the terminal 200 through the network 300.
Referring to fig. 4, fig. 4 is a schematic diagram of a composition structure of the server in fig. 3 according to an embodiment of the present application; the server 400 shown in fig. 4 includes: at least one processor 410, a memory 450, at least one network interface 420, and a user interface 430. The various components in server 400 are coupled together by bus system 440. It is understood that the bus system 440 is used to enable connected communication between these components. The bus system 440 includes a power bus, a control bus, and a status signal bus in addition to the data bus. But for clarity of illustration the various buses are labeled in fig. 4 as bus system 440.
The Processor 410 may be an integrated circuit chip having signal processing capabilities such as a general purpose Processor, such as a microprocessor or any conventional Processor, a digital signal Processor (DSP, digital Signal Processor), or other programmable logic device, discrete gate or transistor logic device, discrete hardware components, or the like.
The user interface 430 includes one or more output devices 431, including one or more speakers and/or one or more visual displays, that enable presentation of the media content. The user interface 430 also includes one or more input devices 432, including user interface components that facilitate user input, such as a keyboard, mouse, microphone, touch screen display, camera, other input buttons and controls.
Memory 450 may be removable, non-removable, or a combination thereof. Exemplary hardware devices include solid state memory, hard drives, optical drives, and the like. Memory 450 optionally includes one or more storage devices physically remote from processor 410.
Memory 450 includes volatile memory or nonvolatile memory, and may also include both volatile and nonvolatile memory. The non-volatile Memory may be a Read Only Memory (ROM) and the volatile Memory may be a random access Memory (RAM, random Access Memory). The memory 450 described in embodiments of the present application is intended to comprise any suitable type of memory.
In some embodiments, memory 450 is capable of storing data to support various operations, examples of which include programs, modules and data structures, or subsets or supersets thereof, as exemplified below.
An operating system 451 including system programs, e.g., framework layer, core library layer, driver layer, etc., for handling various basic system services and performing hardware-related tasks, for implementing various basic services and handling hardware-based tasks;
Network communication module 452 for reaching other computer devices via one or more (wired or wireless) network interfaces 420, exemplary network interfaces 420 include: bluetooth, wireless compatibility authentication (Wi-Fi), universal serial bus (USB, universal Serial Bus), etc.;
a presentation module 453 for enabling presentation of information (e.g., a user interface for operating peripheral devices and displaying content and information) via one or more output devices 431 (e.g., a display screen, speakers, etc.) associated with the user interface 430;
An input processing module 454 for detecting one or more user inputs or interactions from one of the one or more input devices 432 and translating the detected inputs or interactions.
In some embodiments, the natural language processing device provided in the embodiments of the present application may be implemented in software, and fig. 4 shows a natural language processing device 455 stored in a memory 450, which may be software in the form of a program and a plug-in, and includes the following software modules: the entity identification module 4551, the sequence aggregation module 4552, the information resolution module 4553, the resource acquisition module 4554 and the database interaction module 4555 are logical, and thus may be arbitrarily combined or further split according to the implemented functions. The functions of the respective modules will be described hereinafter.
In some embodiments, the natural language processing apparatus provided by the embodiments of the present application may be implemented in hardware, and as an example, the natural language processing apparatus provided by the embodiments of the present application may be a processor in the form of a hardware decoding processor that is programmed to perform the natural language processing method provided by the embodiments of the present application, for example, the processor in the form of a hardware decoding processor may employ one or more Application specific integrated circuits (ASICs, applications SPECIFIC INTEGRATED circuits), DSPs, programmable logic devices (PLDs, programmable Logic Device), complex Programmable logic devices (CPLDs, complex Programmable Logic Device), field-Programmable gate arrays (FPGAs), field-Programmable GATE ARRAY), or other electronic components.
In some embodiments, the terminal or the server may implement the natural language processing method provided by the embodiment of the present application by running a computer program. For example, the computer program may be a native program or a software module in an operating system; the method can be a local (Native) Application program (APP), namely a program which can be run only by being installed in an operating system, such as a question-answer APP, a dialogue APP or an intelligent customer service APP; the method can also be an applet, namely a program which can be run only by being downloaded into a browser environment; but also an applet that can be embedded in any APP. In general, the computer programs described above may be any form of application, module or plug-in.
In the following, the natural language processing method provided by the embodiment of the present application will be described in connection with exemplary applications and implementations of the natural language processing device provided by the embodiment of the present application. In addition, the natural language processing method provided by the embodiment of the application is applied to various scenes such as cloud technology, artificial intelligence, intelligent transportation, vehicle-mounted and the like.
Referring to fig. 5, fig. 5 is a schematic flow chart of a natural language processing method according to an embodiment of the present application, and the steps shown in fig. 5 will be described.
S501, carrying out entity recognition on the natural language description to obtain an entity character string sequence.
In the embodiment of the application, the natural language processing equipment acquires the information which adopts natural language description and is used for interacting with the database, and thus, the natural language description is acquired; then, the natural language processing device extracts and converts the entity of the natural language description, namely the entity recognition of the natural language description is completed, and the obtained entity recognition result is the entity character string sequence. The entity character string sequence comprises at least one entity character string, a description sequence is included among the entity character strings in the entity character string sequence, and the description sequence corresponds to the sequence of each entity corresponding to the entity character string in the natural language description.
It should be noted that, the natural language processing device may obtain the natural language description by responding to the user operation, may obtain the natural language description by receiving information sent by other devices responding to the user operation, may obtain the natural language description by executing the received acquisition instruction, and the like, which is not limited by the embodiment of the present application. The natural language description is information for interacting with the database by adopting the natural language description, wherein the information for interacting with the database can be information for acquiring data to be queried, for example, data acquisition description such as a question asked by a user and a request of the user by adopting the natural language description, information in an audio form, information in a video form, information in a text form, information in a picture form and the like; when the natural language description is information in a non-text form, the natural language processing device needs to perform entity recognition after converting the natural language description into the description in a text form; in addition, the information interacted with the database may be information of adding data to be added, information of deleting data to be deleted, information of modifying data to be modified, and the like, which is not limited by the embodiment of the present application.
It should be further noted that, the entity identification is a process of identifying a character string corresponding to the database from the natural language description, and includes extracting an entity in the natural language description and converting the extracted entity into the character string in the database, so that each entity character string in the entity character string sequence is a tag of the entity in the natural language description in the target language, for example, a column name (teacher wage, county code, teacher identifier, etc.), a count (count), an average value (avg), etc. The database is used for storing data to be interacted.
S502, aggregating entity character string sequences based on target grammar, and aggregating and backing-off entity character string sequences with failed aggregation.
In an embodiment of the present application, the natural language processing device is configured to convert a natural language description into a data query description capable of interacting with a database, for example, a SQL statement or the like. Here, the natural language processing device can obtain a grammar of a target language (e.g., a language such as SQL language that interacts with the database) for interacting with the database, referred to herein as a target grammar; that is, the target grammar is the grammar of the target language.
It should be noted that, the natural language processing device aggregates at least one entity string in the entity string sequence by using the target grammar to obtain an aggregate relationship between entity strings in the entity string sequence, where the aggregate relationship between entity strings in the entity string sequence is referred to as semantic information to be parsed. In the process that the natural language processing device aggregates the entity character string sequence based on the target grammar, if the aggregation fails, aggregation rollback processing is performed.
It should be further noted that, since natural language descriptions are various in terms of description sequence, description term, and the like, when description is performed on information of the same semantics by using natural language, various description results can be obtained; the description mode of interacting with the database is fixed, so that when the natural language description is converted into the description capable of interacting with the database, the natural language processing device needs to aggregate the entity character string sequence corresponding to the natural language description according to the grammar of the target language so as to obtain the description capable of interacting with the database based on the aggregation result; wherein aggregation refers to a process of determining an aggregate relationship between entity strings in an entity character sequence. In addition, the aggregation failure refers to a situation that the final aggregation result does not match the target grammar, or the final aggregation result does not match the entity string sequence, and the interaction result corresponding to the natural language description cannot be obtained. The aggregation backspacing refers to a process of backspacing an aggregation to re-aggregate, and includes at least one of entity character string backspacing and sequence backspacing, wherein entity character string backspacing refers to a backspacing process of re-aggregating entity character strings, and entity character string backspacing refers to a backspacing process of re-aggregating a next entity character string sequence of the entity character string sequence.
And S503, performing secondary aggregation based on the aggregation rollback result to obtain semantic information to be analyzed.
In the embodiment of the application, the natural language processing equipment obtains the aggregation rollback result by performing aggregation rollback on the entity character string sequence; then, the natural language processing equipment carries out secondary aggregation on the aggregation rollback result, so that semantic information to be analyzed is obtained; the semantic information to be analyzed is an aggregation relation among entity character strings in the entity character sequence, and the semantic information to be analyzed is a successful aggregation result of the entity character string sequence; here, when the natural language processing device re-aggregates the aggregation fallback result, if the aggregation fails, the natural language processing device may perform re-aggregation fallback and re-aggregation by adopting the processing manner of aggregation fallback described in S502, that is, iteratively performing the processing of aggregation fallback and re-aggregation until the semantic information to be parsed is obtained.
It should be noted that, after the natural language processing device performs aggregation and fallback on the entity string sequence, the obtained aggregation and fallback result refers to information to be aggregated again, and may be any one of the entity string and the next entity string sequence; when the aggregate rollback result includes the next entity string sequence, the natural language description corresponds to a plurality of entity string sequences, and each entity string sequence corresponds to an entity segmentation mode of the natural language description.
S504, analyzing the semantic information to be analyzed to obtain the target language description.
In the embodiment of the application, after the natural language processing equipment obtains the semantic information to be analyzed, the semantic information to be analyzed is analyzed, and the information which is described by adopting the target language and is used for interacting with the database is obtained; the target language description is information for interacting with the database by adopting the target language description.
It should be noted that, because the semantic information to be parsed includes the aggregate relationships between the entity strings of the entity string sequence, the natural language processing device adopts the target language to describe the aggregate relationships between the entity strings of the entity string sequence, and thus the target language description is obtained.
It can be understood that, in the process of processing the natural language description, when the aggregation of the entity character string sequence corresponding to the natural language description fails, the aggregation can be performed again through the aggregation rollback, so that the correct semantic information to be analyzed can be obtained; therefore, when the semantic information to be analyzed is analyzed, the correct target language text can be obtained; therefore, the accuracy of natural language processing and the robustness of natural language analysis can be improved.
In the embodiment of the application, when the aggregation and backspacing includes entity character string backspacing, the aggregation and backspacing result is a continuous entity character string failing to aggregate in the entity character string sequence; at this time, S503 may be realized by S5031 and S5032 (not shown in the figure); that is, the natural language processing device performs the aggregation again based on the aggregation rollback result to obtain the semantic information to be parsed, including S5031 and S5032, and each step is described below.
S5031, for the continuous entity character strings which fail to be aggregated in the entity character string sequence, the entity character strings which are adjacent and do not belong to the aggregation mode corresponding to the target grammar are aggregated into the appointed aggregation result.
In the embodiment of the application, natural language processing equipment determines continuous entity character strings which fail to be aggregated in an entity character string sequence, and aggregates adjacent entity character strings which do not belong to an aggregation mode corresponding to a target grammar into a designated aggregation result in the continuous entity character strings which fail to be aggregated; wherein, the consecutive entity character strings failing to be aggregated refer to at least two consecutive entity character strings failing to be aggregated; and designating the entity character strings in the aggregation result for aggregation with any other entity character strings in the entity character string sequence.
S5032, aggregating the appointed aggregation result to obtain semantic information to be analyzed.
In the embodiment of the application, the natural language processing device continues to aggregate the entity character string sequence based on the appointed aggregation result, so that semantic information to be analyzed comprising the appointed aggregation result is obtained. In addition, the natural language processing device may aggregate the specified aggregation result with any entity character string when aggregating the specified aggregation result.
Accordingly, in the embodiment of the present application, S504 may be implemented through S5041 and S5042 (not shown in the drawings); that is, the natural language processing apparatus parses the semantic information to be parsed to obtain the target language description, including S5041 and S5042, and each step is described below.
S5041, obtaining a target entity character string which is in brother relation with the entity character string in the appointed aggregation result in the semantic information to be analyzed.
In the embodiment of the application, natural language processing equipment acquires an aggregation result which is the same as a designated aggregation result as a father node when the analysis is carried out to the designated aggregation result in the process of analyzing semantic information to be analyzed; here, the entity character string in the aggregation result with the appointed aggregation result being the same father node is the target entity character string with the entity character string in the appointed aggregation result being the brother relation; wherein, the father node is an aggregation result of the designated aggregation result and the target entity character string, that is, the sibling relationship refers to a relationship capable of being aggregated into one aggregation result.
S5042, resolving the entity character strings in the appointed aggregation result and the target entity character strings to obtain target language description.
In the embodiment of the application, the natural language processing device analyzes the entity character string and the target entity character string in the appointed aggregation result to obtain the sub-description of the target language which corresponds to the entity character string and the target entity character string in the appointed aggregation result together.
It can be appreciated that, because of the variety of natural language description modes, for example, long-distance semantic relationships exist in some natural language description texts, that is, other entity strings are included between two entity strings related to context; at this time, aggregation modes which are adjacent but not corresponding to the target grammar are aggregated into a designated aggregation result through aggregation rollback of the entity strings, and any entity string in the designated aggregation result is aggregated with the target entity string, so that discontinuous aggregation is realized, and therefore, correct aggregation can be realized, and further, correct target language description can be obtained.
In the embodiment of the application, when the aggregation rollback includes sequence rollback, the aggregation rollback result is the next entity string sequence of the entity string sequence failed in aggregation; the entity character string sequence and the next entity character string sequence which fail to aggregate belong to at least two entity character string sequences corresponding to natural language description, and each entity character string sequence corresponds to an entity segmentation mode of the natural language description; at this time, S503 may also be realized by S5033 (not shown in the figure); that is, the natural language processing device performs the aggregation again based on the aggregation rollback result to obtain the semantic information to be parsed, including S5033, and each step is described below.
S5033, the next entity character string sequence is aggregated again, and semantic information to be analyzed is obtained.
It should be noted that, when the natural language processing device returns the aggregation of the entity string sequence to the next entity string sequence, the next entity string sequence is aggregated again based on the target grammar to obtain the semantic information to be parsed. Here, because the same description sometimes corresponds to at least one entity segmentation mode in the natural language, when the natural language processing device adopts different entity segmentation modes to perform entity segmentation on the natural language description, a plurality of entity character string sequences corresponding to the natural language description are obtained. In addition, when the natural language processing equipment carries out the polymerization again on the next entity character string sequence, semantic information to be analyzed is obtained after the polymerization is successful; if the next entity string sequence fails to be aggregated again, the natural language processing equipment aggregates and rolls back the next entity string sequence which fails to be aggregated again, and re-aggregates the next entity string sequence as a further aggregation and roll-back result, so that the aggregation and roll-back are iteratively performed until semantic information to be analyzed is successfully aggregated; in the iterative aggregation rollback process, the method is realized by traversing at least two entity character string sequences corresponding to natural language descriptions.
It can be understood that, because the same description corresponds to at least one semantic meaning in the natural language description, the natural language processing device obtains at least two entity character string sequences corresponding to the natural language description by performing entity segmentation on the natural language description by adopting different entity switching modes; when the aggregation of the current entity character string sequence fails, determining that the entity segmentation mode corresponding to the current entity character string sequence is wrong; thus, through aggregation rollback, the entity character string sequence corresponding to the correct entity segmentation mode can be determined, and further the correct target language description can be obtained.
In the embodiment of the present application, when the aggregation fallback includes entity string fallback and sequence fallback, the natural language processing device performs the aggregation fallback on the entity string sequence with failed aggregation in S502, including S5021 to S5023 (not shown in the figure), and each step is described below.
S5021, carrying out entity character string rollback on the entity character string sequence with failed aggregation to obtain an entity character string rollback result.
When the natural language description includes at least two entity character string sequences, the natural language processing device performs entity character string rollback on the entity character string sequences failed to be aggregated, and the obtained result is an entity character string rollback result; the entity character string rollback result is continuous entity character strings which fail to be aggregated in the entity character string sequence.
S5022, performing re-aggregation on the entity character string rollback result.
In the embodiment of the application, after the natural language processing equipment obtains the entity character string rollback result, the entity character string rollback knot is aggregated again; if the re-aggregation of the entity character string rollback result is successful, the current entity character string sequence is divided by adopting a correct entity division mode, and semantic information to be analyzed corresponding to the natural language description is obtained.
S5023, carrying out sequence rollback on the entity character string rollback result of the aggregation failure.
In the embodiment of the application, when the natural language processing equipment carries out the re-aggregation of the entity character string rollback results, if the aggregation fails, the current entity character string sequence is indicated to be divided by adopting an incorrect entity division mode, and the sequence rollback is carried out on the entity character string rollback results which fail to be aggregated; here, the sequence backoff result is an aggregate backoff result.
Referring to fig. 6, fig. 6 is a second flowchart of a natural language processing method according to an embodiment of the present application; as shown in fig. 6, in the embodiment of the present application, S506 is further included before S501; that is, the natural language processing apparatus performs entity recognition on the natural language description, and before obtaining the entity string sequence, the natural language processing method further includes S506, which is described below.
S506, acquiring domain resources of the natural language description.
It should be noted that, the database operated by the natural language description corresponds to a domain, such as an education domain, a financial domain, etc.; the corresponding domain comprises domain resources for extracting the entities in the domain, and the domain resources comprise at least one of an entity character string library and an entity identification model; the entity character string library can comprise each entity character string in the field corresponding to the database of the natural language description operation, and can also comprise at least one character string corresponding to each semantic; the entity recognition model is a neural network model for recognizing an entity in the field corresponding to the database operated by the natural language description, and is obtained by training a natural language description sample and an entity labeling sample, and the natural language description sample and the entity labeling sample also belong to the field corresponding to the database operated by the natural language description.
With continued reference to fig. 6, accordingly, S501 may be implemented by S5011; that is, the natural language processing apparatus performs entity recognition on the natural language description to obtain an entity character string sequence, including S5011, which is described below.
S5011, carrying out entity recognition on the natural language description based on the domain resource to obtain an entity character string sequence.
It should be noted that, after the natural language processing device obtains the domain resource, the domain resource is adopted to perform entity recognition on the natural language description; here, when the domain resource includes an entity string library, entity strings in the entity string sequence are obtained by entity extraction of the natural language description by the entity string library; when the domain resource comprises an entity recognition model, entity character strings in the entity character string sequence are obtained by extracting the entity from the natural language description through the entity recognition model; when the domain resource comprises an entity character string library and an entity recognition model, the entity character string in the entity character string sequence is obtained by combining two entity extraction results which are obtained by respectively carrying out entity extraction on natural language description by utilizing the entity character string library and the entity recognition model. The method comprises the steps of extracting a natural language description by using an entity character string library, wherein the extraction of the entity is a character string matching mode, and the extraction of the entity is a character string semantic feature analysis mode by using an entity recognition model.
It can be understood that, because the domain resource has higher precision than the universal resource, the accuracy of the obtained entity character string sequence can be improved by obtaining the entity character string sequence through the domain resource in the embodiment of the application; in addition, when the natural language processing equipment acquires the entity character string sequence by utilizing the entity character string library and the entity recognition model, entity extraction is carried out in a matching mode and a character string semantic feature analysis mode, so that the recall rate of the entity character string can be improved. In addition, the embodiment of the application performs entity extraction based on the domain resources in the field, can be suitable for various application fields, and improves the domain adaptability.
In the embodiment of the present application, S501 may also be implemented through S5012 and S5013 (not shown in the drawings); that is, the natural language processing device performs entity recognition on the natural language description to obtain an entity character string sequence, including S5012 and S5013, and each step is described below separately.
S5012, extracting the entity from the natural language description to obtain an initial entity character string sequence.
In the embodiment of the application, the natural language processing equipment firstly extracts the entity in the natural language description, and an initial entity character string sequence is obtained, namely the entity extraction result is obtained; the initial entity character string sequence comprises at least one initial entity character string, each initial entity character string is an entity in the natural language description, and a combination sequence is included between the at least one initial entity character string, and the combination sequence refers to the sequence of each initial entity character string in the natural language description.
S5013, mapping the initial entity character string in the initial entity character string sequence into an entity character string based on the corresponding relation between the database attribute and the entity, and obtaining the entity character string sequence corresponding to the initial entity character string.
In the embodiment of the present application, the natural language processing device is further configured to convert an initial entity string into an attribute in the database, that is, convert an entity extracted from the natural description language into a string in the database. Here, the natural language processing device can obtain a correspondence between the database attribute and the entity, where the correspondence between the database attribute and the entity is a correspondence between the attribute in the database and the entity described by the natural language, for example, the entity described by the natural language is "a university in the attached middle", and the attribute in the database is "a university in the attached middle"; the natural language processing device performs conversion processing based on correspondence between database attributes and entities.
It can be understood that the entity (i.e. the initial entity character string) extracted from the natural language description is converted to be converted into the attribute of the database (i.e. the entity character string), so that the aggregation mode of each entity character string can be accurately determined in the aggregation process, and the accuracy of natural language processing is improved.
In the embodiment of the present application, the natural language processing device aggregates the entity string sequence based on the target grammar in S502, including S5024 and S5025 (not shown in the figure), and each step is described below.
S5024, mapping each entity character string in the entity character string sequence into a grammar element of the target grammar to obtain a grammar element sequence corresponding to the entity character string sequence.
It should be noted that the target syntax includes a syntax element; the syntax elements are syntax elements in the target speech, such as column names, functions (AGG), intents (INT), ranks (SORT), values (VAL), and so on. Here, the natural language processing device can obtain the correspondence between the database attribute and the syntax element, map each entity string in the entity string sequence to the syntax element of the target syntax based on the correspondence between the database attribute and the syntax element, and obtain the syntax element sequence corresponding to the entity string sequence. Wherein each syntax element in the sequence of syntax elements corresponds to an entity string.
S5025, based on the aggregation rule corresponding to the target grammar, conducting layer-by-layer aggregation on the grammar element sequence until the aggregation is finished when the aggregation is a single aggregation result.
It should be noted that the target grammar also includes an aggregation rule; the aggregation rule refers to an aggregation manner of each syntax element, for example, aggregation of functions and column names, aggregation result and ordering aggregation of functions and column names, and the like. Here, the natural language processing device performs layer-by-layer aggregation of at least one syntax element in the sequence of syntax elements based on the aggregation rule until the aggregation is ended when the final single aggregation result is aggregated. The single aggregation result comprises an aggregation relation corresponding to the entity character strings in the entity character string sequence, namely the semantic information to be analyzed.
It can be understood that, in the embodiment of the application, the language element sequence is aggregated into a single aggregation result from bottom to top and then parsed into the target language description, so that aggregation rollback can be performed in the aggregation process, and correction of error aggregation and error segmentation is realized, thereby improving the accuracy of natural language processing.
In the embodiment of the present application, S507 and S508 (not shown in the figure) are further included after S502; that is, after the natural language processing apparatus aggregates the entity string sequence based on the target grammar, the natural language processing method further includes S507 and S508, each of which is described below.
S507, when the entity character string corresponding to the single aggregation result comprises an entity character string sequence, determining that the aggregation is successful.
In the embodiment of the application, after the natural language processing equipment obtains a single aggregation result, judging an entity character string corresponding to the single aggregation result; when the entity character strings corresponding to the single aggregation result are determined to comprise the entity character string sequence, the fact that aggregation is completed on all entity character strings in the entity character string sequence is indicated, and therefore success in aggregation is determined.
S508, when the entity character string corresponding to the single aggregation result comprises part of entity character strings in the entity character string sequence, determining that aggregation fails.
In the embodiment of the application, when the natural language processing device determines that the entity character string corresponding to the single aggregation result comprises part of entity character strings in the entity character string sequence, the aggregation of the part of entity character strings in the entity character string sequence is completed, so that the aggregation failure is determined.
It should be noted that S507 and S508 are two independent steps, and are not sequential in execution order.
In the embodiment of the present application, S504 may be implemented through S5043 and S5044 (not shown in the drawings); that is, the natural language processing apparatus parses the semantic information to be parsed to obtain the target language description, including S5043 and S5044, and each step is described below.
S5043, analyzing semantic information to be analyzed layer by layer to obtain sub-descriptions to be spliced.
In the embodiment of the application, because the semantic information to be analyzed is obtained by the natural language processing equipment through bottom-up aggregation of the entity character string sequence, the natural language processing equipment analyzes the semantic information to be analyzed from top to bottom so as to obtain each sub-description described by the target language, and determines each word description as the sub-description to be spliced.
It should be noted that, because the semantic information to be analyzed includes a single aggregation result, the natural language processing device starts from the single aggregation result, analyzes the aggregation result included in the single aggregation result layer by layer until the analysis is completed until the aggregation result obtained first is analyzed, and the analysis is finished, so as to obtain the sub-description to be spliced.
S5044, splicing the sub-descriptions to be spliced to obtain the target language description.
In the embodiment of the application, after the natural language processing device obtains the sub-description to be spliced, at least one sub-description in the sub-description to be spliced is spliced, and the obtained splicing result is the target language description.
It can be understood that, because the natural language processing device aggregates the entity string sequence in a bottom-up aggregation manner, the aggregated semantic information to be analyzed is analyzed in a top-down analysis manner, so as to correspond to the aggregation process, so that the correct target language description is analyzed, and the accuracy of natural language processing is improved.
Referring to fig. 7, fig. 7 is a flowchart illustrating a natural language processing method according to an embodiment of the present application; as shown in fig. 7, in the embodiment of the present application, S509 and S510 are further included after S504; that is, the natural language processing apparatus parses the semantic information to be parsed, and after obtaining the target language description, the natural language processing method further includes S509 and S510, and each step is described below.
S509, processing the database based on the target language description to obtain a database processing result.
It should be noted that, after the natural language processing device obtains the target language description, the natural language processing device can interact with the database based on the target language description to control the database; here, when the natural language processing device interacts with the database based on the target language description, that is, the database is processed based on the target language description to control the database, the obtained processing result is the processing result of the database. The database processing results comprise at least one of queried target data, deleting results, modifying results and adding results.
S510, presenting a database processing result.
In the embodiment of the present application, the natural language processing device may present the database processing result in itself, or may send the numerical control processing result to the presenting end device, so that the presenting end device presents the database processing result, etc., which is not limited in the embodiment of the present application.
It can be understood that, in the embodiment of the application, the correct target language description can be obtained by performing aggregation rollback on the entity character string sequence with failed aggregation; furthermore, when the database is processed based on the target language description, a correct database processing result can be obtained, and the accuracy of interaction between the database and the natural language is improved.
In the following, an exemplary application of the embodiment of the present application in a practical application scenario will be described. This exemplary application describes a process of extracting corresponding content (an interaction with a database) from a data table based on a question or query description (referred to as a natural language description) described in natural language when constructing a data table (referred to as a database) based dialog system for a specified domain. Here, since the SQL language (referred to as a target language) is an effective method for extracting contents of a data table, a problem or a query description of a natural language description is first converted into an SQL statement (referred to as a target language description), and then the corresponding contents are extracted from the data table by using the SQL statement, so that a process of extracting the corresponding contents from the data table according to the problem or the query description of the natural language description can be realized.
Referring to fig. 8, fig. 8 is a schematic diagram of an exemplary application flow provided by an embodiment of the present application; as shown in FIG. 8, page 8-1 is presented by invoking an applet of the dialog system, showing data query flow 8-11 (first speech recognition, then natural language processing, then intelligent analysis, and finally data conclusion). And when the acquired user question is in a text form, directly performing natural language processing.
When intelligent conversations are conducted based on the conversational system using the exemplary application flow shown in fig. 8, referring to fig. 9, fig. 9 is a schematic diagram of an exemplary database provided by an embodiment of the application; as shown in FIG. 9, data table 9-1 is a financial table (financial) including 7 column names (called database attributes) of name, redemption fee (shfy), purchase limit, risk level (fxdj), time of sale, age of purchase, and revenue of purchase; when the user problem 'maximum value of average redemption costs of different risk levels' input by the user is obtained, the SQL sentence 'SELECT AVG (shfy), fxdj from finace group by fxdj order by avg (shfy) DESC LIMIT 1' can be obtained by adopting the natural language processing method provided by the embodiment of the application; the SQL statement is then executed against data table 9-1, resulting in a query result (referred to as target data in the database processing result). Referring to fig. 10, fig. 10 is a schematic diagram of an exemplary data query provided in an embodiment of the present application; as shown in FIG. 10, in the Smart dialog page 10-1, query results 10-12, and additional information 10-13 are displayed for user questions 10-11.
An exemplary process flow of the natural language processing method provided by the embodiment of the present application is described below.
Referring to fig. 11, fig. 11 is a schematic diagram of an exemplary natural language processing flow provided in an embodiment of the present application; as shown in fig. 11, for the data table 11-1 and the default configuration table 11-2 corresponding to the data table 11-1, determining an entity key string identification module 11-3 corresponding to the domain of the dialogue system; when obtaining the user question 11-4 (what is the sum of the achievement total (Gross Merchandise Volume, GMV) of company a, the entity key string recognition module 11-3 is used to perform entity recognition on the user question 11-4, and perform bottom-up rollback SQL grammar aggregation 11-5 on the entity recognition result (called entity string sequence), and then perform top-down hierarchical SQL parsing 11-6 on the aggregation result, to obtain the SQL statement 11-7 (select sum (achievement GMV) from property sample table where brand=company Aand statistical time=202108).
It should be noted that, the entity key character string recognition module 11-3 is constructed by at least one of an entity character string library and an entity recognition model in the domain corresponding to the dialogue system; here, when the entity key string recognition module 11-3 is constructed through the entity string library and the entity recognition model to perform entity extraction, the entity may be obtained by combining the two extraction results to increase the recall rate of the entity key string recognition module 11-3. In addition, the entity key string recognition module 11-3 includes, in addition to an entity extraction function, an entity conversion function, that is, converting an entity extracted from a user problem or query description into an attribute (for example, a column name) corresponding to a data table, so as to solve the problem caused by an alias, thus improving the accuracy of aggregation; for example, the entity "university of a" in the user question is converted into the attribute "university of a" in the data table.
It should be further noted that, the entity key string recognition module 11-3 is further configured to obtain at least one entity segmentation result, so that a user problem corresponds to the at least one entity segmentation result; for example, a prefecture backbone teacher corresponds to two entity segmentation results of { "prefecture", "backbone teacher" }, and { "prefecture backbone teacher" }.
The entity recognition result, the bottom-up rollback SQL grammar aggregation and the top-down hierarchical SQL parsing are respectively described below.
Referring to fig. 12, fig. 12 is a schematic diagram of another exemplary natural language processing flow provided by an embodiment of the present application; as shown in fig. 12, when the entity key string recognition module 12-1 is used to perform entity recognition on the user question 12-2 (what the teaching discipline with the fewest number of female teachers is), the entity recognition result is obtained as an entity key string sequence 12-3 ({ "sex code_female (xbm _female)", "teacher identification (jsid)", "count)", "ascending_1", "teaching discipline (rjkc)" }, called an entity string sequence; then, when SQL grammar aggregation 12-5 which can be rolled back from bottom to top is carried out on the entity key character string sequence 12-3 based on the SQL grammar 12-4 (called target grammar), an aggregation result 12-6 (called semantic information to be analyzed) is obtained; finally, top-down hierarchical SQL parsing is performed on the aggregate result 12-6 to obtain a clause 12-7 to be spliced (where clause, order clause, and select clause are called sub-description to be spliced), so that the SQL statement 12-8 (select rjkc, count (jsid) from teacher table where xbm = "woman" group by rjkc order by count (jsid) DESC LIMIT 1) is obtained by splicing the clause 12-7 to be spliced.
It should be noted that, in the entity key string sequence 12-3, "sex code_girl" is obtained from "girl" in the conversion user question 12-2, "count" is obtained from "number of people" in the conversion user question 12-2, and "ascending_1" is obtained from "least" in the conversion user question 12-2. In the process of aggregation by adopting the SQL grammar aggregation 12-5 capable of rollback from bottom to top, mapping each entity key character string (called entity character string) into a grammar element in the SQL grammar; for example, map "gender_girl" to Condition (COND), map "teacher identification" to column name (COL), map "count" to function (AGG), map "ascending_1" to SORT (SORT), and map "teaching course" to SELECT (SELECT); in this way, the syntax element sequences corresponding to the entity key string sequences are aggregated from bottom to top based on the aggregation mode of the syntax elements in the SQL syntax until the root node is aggregated (called a final single aggregation result, and here, the aggregation result is denoted by "S"). When top-down hierarchical SQL parsing is adopted, parsing is started from a root node, and each clause is obtained based on top-down hierarchical parsing of the aggregation relation among entity key character strings.
Rollback in a bottom-up rollback SQL grammar aggregation procedure is described below.
Referring to fig. 13, fig. 13 is a schematic diagram of an exemplary aggregate rollback procedure according to an embodiment of the present application; as shown in fig. 13, for the user question 13-1 (average value of teacher wages in each county), the corresponding entity extraction result 13-2 ({ "teacher wages", "county", "average value" }, referred to as initial entity string sequence) is obtained, and the entity key string sequence 13-3 ({ "jsgz" (corresponding to entity "teacher wages"), "qxdm" (corresponding to entity "county"), "avg" (corresponding to entity "average value") }) corresponding to the entity extraction result 13-2 is obtained, followed by the syntax element sequence 13-4{ "COL" (column name), "AGG" (function) }, corresponding to the entity key string sequence 13-3. In the process of performing the low-level backward traceable grammar aggregation on the grammar element sequence 13-4, the grammar elements 'AGG' corresponding to the 'average value' and the grammar element 'COL' corresponding to the 'county' cannot be aggregated according to the SQL grammar function and the text column names, so that the column names respectively corresponding to the 'payroll' and the 'county' can be aggregated into a plurality of column (MulC) nodes, the next aggregation is performed, and the MulC node cannot be aggregated with the grammar element 'AGG' corresponding to the 'average value', so that the obtained incorrect SQL statement 13-5 (select jsgz, qxdm from teaching teacher table) for discarding the 'average value') is obtained.
Note that, the MulC node cannot aggregate the syntax element "AGG" corresponding to the "average value", which indicates that the aggregation is interrupted, triggers the rollback, and rolls back to the previous layer of aggregation process, so that the syntax nodes that are adjacent but do not appear in the SQL syntax are aggregated into "Check" nodes (called as specified aggregation results), and the "Check" nodes can aggregate with any SQL syntax nodes. After the aggregation is finished, the entity in the Check node and the entity of the same father node can be analyzed through a top-down hierarchical SQL analysis flow: the tree 13-6 is a subtree where a Check node belongs to a syntax element "COL" corresponding to a teacher wage as a node of a father, and the corresponding select clause is resolved because the teacher wage can be aggregated with an average value in the Check node (aggregation of functions and numerical column names); the corresponding nodes of the remained counties in the Check are used as independent nodes for analysis, and corresponding select clauses are analyzed; finally, splicing the SQL sentences into the correct SQL sentences 13-7 (SELECT AVG (jsid), qxdm from teaching teachers); therefore, the SQL grammar aggregation capable of rollback from bottom to top provided by the embodiment of the application can improve the generalization capability and the robustness of natural language processing.
It should be noted that fig. 13 describes a case of rollback in the entity key string sequence, and the following describes a case of rollback between entity key string sequences when the user problem corresponds to a plurality of entity segmentation manners.
Referring to fig. 14, fig. 14 is a schematic diagram of another exemplary aggregate rollback procedure provided by an embodiment of the present application; as shown in fig. 14, for one entity extraction result 14-2{ "area backbone teacher", "number", "distribution" } of query description 14-1 (area backbone teacher number distribution), the aggregation of "distribution" intent cannot be satisfied in the aggregation process, and an incorrect SQL statement 14-3 (select count where jsdj = "area backbone teacher") is obtained, so that the aggregation is interrupted, a rollback is triggered, another entity extraction result 14-4{ "area", "backbone teacher", "number", "distribution" } of query description 14-1 (area backbone teacher number distribution) is rolled back, and the aggregation result 14-5 is obtained by reusing the low-to-high retroactive grammar aggregation. In the top-down parsing of the aggregate result 14-5, the "distribution" intent node matches the column name entity in the same parent node "C-V-A", parses to group according to "zone" and generates the last correct SQL statement 14-6 (select qxcm, count from teacher table where jsdj = "backbone teacher" group by qxcm). Wherein, "qxdm" (county codes, corresponding to an entity "region"), "jsdj" (teacher level, corresponding to an entity "region backbone teacher" or "backbone teacher"), "count" (count, corresponding to an entity "number of people") and "intent" (intent, corresponding to an entity "distribution") are attributes corresponding to A database, "VAL", "AGG", "INT", "COL", "Mulc", "C-V-A" and "S" are syntax elements or aggregation results in an SQL grammar.
It can be understood that in the embodiment of the application, by constructing the entity key character string recognition module for the target field, the conversion from natural language to structured query language in different fields can be rapidly and accurately applied; the SQL grammar aggregation capable of being rolled back from bottom to top can be suitable for NL2SQL scenes of different languages, can realize accurate SQL analysis in various problem description scenes, and reduces dependence on problem templates; and for the ambiguous problem description, correct aggregation and analysis can be still carried out, so that a correct SQL sentence can be obtained, error transmission of a serial system can be reduced, and the accuracy of NL2SQL is improved.
Continuing with the description below of an exemplary architecture of the natural language processing device 455 implemented as a software module provided by embodiments of the present application, in some embodiments, as shown in fig. 4, the software modules stored in the natural language processing device 455 of the memory 450 may include:
The entity recognition module 4551 is configured to perform entity recognition on a natural language description to obtain an entity string sequence, where the natural language description is information for interacting with a database by using the natural language description, and each entity string in the entity string sequence is a tag of an entity in the natural language description in a target language;
the sequence aggregation module 4552 is configured to aggregate the entity string sequence based on a target grammar, and aggregate and rollback the entity string sequence that fails to aggregate, where the target grammar is a grammar of a target language;
The sequence aggregation module 4552 is further configured to perform re-aggregation based on an aggregation rollback result to obtain semantic information to be parsed, where the semantic information to be parsed is an aggregation relationship between the entity strings in the entity character sequence;
The information analysis module 4553 is configured to analyze the semantic information to be analyzed to obtain a target language description, where the target language description is information for interacting with the database using the target language description.
In the embodiment of the present application, the aggregate backoff includes at least one of entity string backoff and sequence backoff, where the entity string backoff refers to a backoff process for performing re-aggregation on the entity string, and the entity string backoff refers to a backoff process for performing re-aggregation on the next entity string sequence of the entity string sequence.
In the embodiment of the present application, when the aggregation fallback includes entity string fallback, the aggregation fallback result is the consecutive entity strings in the entity string sequence that fail aggregation.
In the embodiment of the present application, the sequence aggregation module 4552 is further configured to aggregate, for the entity strings in the entity string sequence that fail to aggregate, the entity strings that are adjacent and do not belong to the aggregation manner corresponding to the target grammar into a specified aggregation result; and aggregating the appointed aggregation result to obtain the semantic information to be analyzed.
In the embodiment of the present application, the information parsing module 4553 is further configured to obtain, in the semantic information to be parsed, a target entity string that is in a sibling relationship with the entity string in the specified aggregation result; and resolving the entity character string and the target entity character string in the appointed aggregation result to obtain the target language description.
In the embodiment of the present application, when the aggregation fallback includes sequence fallback, the aggregation fallback result is the next entity string sequence of the entity string sequence that fails to aggregate, where the entity string sequence that fails to aggregate and the next entity string sequence belong to at least two entity string sequences corresponding to the natural language description, and each entity string sequence corresponds to an entity segmentation manner of the natural language description.
In this embodiment of the present application, the sequence aggregation module 4552 is further configured to re-aggregate the next entity string sequence to obtain the semantic information to be parsed.
In the embodiment of the present application, when the aggregation and backoff includes entity string backoff and sequence backoff, the sequence aggregation module 4552 is further configured to perform the entity string backoff on the entity string sequence that fails to aggregate, so as to obtain an entity string backoff result; re-aggregating the entity character string rollback results; and carrying out sequence backspacing on the entity character string backspacing result with aggregation failure, wherein the sequence backspacing result is the aggregation backspacing result.
In the embodiment of the present application, the natural language processing device 455 further includes a resource obtaining module 4554 configured to obtain a domain resource of the natural language description, where the domain resource includes at least one of an entity string library and an entity recognition model, and the entity recognition model is a neural network model for recognizing an entity.
In this embodiment of the present application, the entity recognition module 4551 is further configured to perform entity recognition on the natural language description based on the domain resource, so as to obtain the entity string sequence.
In the embodiment of the present application, the entity recognition module 4551 is further configured to perform entity extraction on the natural language description to obtain an initial entity string sequence; and mapping the initial entity character string in the initial entity character string sequence into the entity character string based on the corresponding relation between the database attribute and the entity to obtain the entity character string sequence corresponding to the initial entity character string, wherein the corresponding relation between the database attribute and the entity is the corresponding relation between the attribute in the database and the entity described by the natural language.
In the embodiment of the present application, the sequence aggregation module 4552 is further configured to map each of the entity strings in the entity string sequence to a syntax element of the target syntax, so as to obtain a syntax element sequence corresponding to the entity string sequence; and carrying out layer-by-layer aggregation on the grammar element sequence based on an aggregation rule corresponding to the target grammar until the aggregation is finished when the aggregation is a single aggregation result, wherein the semantic information to be analyzed comprises the single aggregation result.
In this embodiment of the present application, the sequence aggregation module 4552 is further configured to determine that the aggregation is successful when the entity string corresponding to the single aggregation result includes the entity string sequence; and when the entity character string corresponding to the single aggregation result comprises part of the entity character strings in the entity character string sequence, determining that aggregation fails.
In the embodiment of the present application, the information parsing module 4553 is configured to parse the semantic information to be parsed layer by layer to obtain a sub-description to be spliced; and splicing the sub-descriptions to be spliced to obtain the target language description.
In this embodiment of the present application, the natural language processing device 455 further includes a database interaction module 4555, configured to process the database based on the target language description to obtain a database processing result, where the database processing result includes at least one of queried target data, a deletion result, a modification result, and an addition result; and presenting the database processing result.
Embodiments of the present application provide a computer program product or computer program comprising computer instructions stored in a computer readable storage medium. A processor of a computer device (referred to as a natural language processing device) reads the computer instructions from a computer-readable storage medium, and the processor executes the computer instructions, so that the computer device performs the natural language processing method described above according to the embodiment of the present application.
Embodiments of the present application provide a computer readable storage medium having stored therein executable instructions that, when executed by a processor, cause the processor to perform a natural language processing method provided by embodiments of the present application, for example, a natural language processing method as shown in fig. 5.
In some embodiments, the computer readable storage medium may be FRAM, ROM, PROM, EPROM, EEPROM, flash memory, magnetic surface memory, optical disk, or CD-ROM; but may be a variety of devices including one or any combination of the above memories.
In some embodiments, the executable instructions may be in the form of programs, software modules, scripts, or code, written in any form of programming language (including compiled or interpreted languages, or declarative or procedural languages), and they may be deployed in any form, including as stand-alone programs or as modules, components, subroutines, or other units suitable for use in a computing environment.
As an example, executable instructions may, but need not, correspond to files in a file system, may be stored as part of a file that holds other programs or data, such as in one or more scripts in a hypertext markup language (HTML, hyper Text Markup Language) document, in a single file dedicated to the program in question, or in multiple coordinated files (e.g., files that store one or more modules, sub-programs, or portions of code).
As an example, the executable instructions may be deployed to be executed on one computer device (at this time, the one computer device is a natural language processing device), or on a plurality of computer devices located at one place (at this time, the plurality of computer devices located at one place is a natural language processing device), or on a plurality of computer devices distributed at a plurality of places and interconnected by a communication network (at this time, the plurality of computer devices distributed at a plurality of places and interconnected by a communication network is a natural language processing device).
In summary, according to the embodiment of the application, in the process of processing the natural language description, when the aggregation of the entity string sequence corresponding to the natural language description fails, the aggregation can be performed again through the aggregation rollback, so that the correct semantic information to be analyzed can be obtained; therefore, when the semantic information to be analyzed is analyzed, the correct target language text can be obtained; therefore, the accuracy and the robustness of natural language processing can be improved. In addition, the field applicability of natural language processing can be improved.
The foregoing is merely exemplary embodiments of the present application and is not intended to limit the scope of the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and scope of the present application are included in the protection scope of the present application.
Claims (13)
1. A method of natural language processing, the method comprising:
Performing entity recognition on natural language description to obtain an entity character string sequence, wherein the natural language description is information for interacting with a database by adopting natural language description, and each entity character string in the entity character string sequence is a label of an entity in the natural language description in a target language; the entity recognition is performed on the natural language description to obtain an entity character string sequence, which comprises the following steps: extracting the entity from the natural language description to obtain an initial entity character string sequence; mapping an initial entity character string in the initial entity character string sequence into the entity character string based on a corresponding relation between a database attribute and an entity to obtain the entity character string sequence corresponding to the initial entity character string, wherein the corresponding relation between the database attribute and the entity is a corresponding relation between an attribute in a database and an entity described by natural language;
Mapping each entity character string in the entity character string sequence into a grammar element of a target grammar to obtain a grammar element sequence corresponding to the entity character string sequence; performing layer-by-layer aggregation on the grammar element sequence based on an aggregation rule corresponding to the target grammar, and ending the aggregation until the aggregation is a single aggregation result, wherein semantic information to be analyzed comprises the single aggregation result, and performing aggregation rollback on the entity character string sequence with failed aggregation, wherein the target grammar is the grammar of the target language;
Re-aggregating based on an aggregation rollback result to obtain semantic information to be analyzed, wherein the semantic information to be analyzed is an aggregation relation between the entity character strings in the entity character sequence;
Analyzing the semantic information to be analyzed to obtain target language description, wherein the target language description is information which adopts the target language description and is used for interacting with the database.
2. The method of claim 1, wherein the aggregate backoff comprises at least one of an entity string backoff and a sequence backoff, wherein the entity string backoff refers to a backoff process that re-aggregates the entity string, and the entity string backoff refers to a backoff process that re-aggregates a next entity string sequence of the entity string sequence.
3. The method according to claim 1 or 2, wherein when the aggregation fallback comprises entity string fallback, the aggregation fallback result is a succession of the entity strings in the sequence of entity strings that failed aggregation;
the step of performing the re-aggregation based on the aggregation rollback result to obtain semantic information to be analyzed includes:
For the continuous entity character strings which fail to be aggregated in the entity character string sequence, aggregating the adjacent entity character strings which do not belong to the aggregation mode corresponding to the target grammar into a designated aggregation result;
aggregating the appointed aggregation result to obtain the semantic information to be analyzed;
The parsing the semantic information to be parsed to obtain a target language description includes:
Acquiring a target entity character string which is in brother relation with the entity character string in the appointed aggregation result from the semantic information to be analyzed;
And resolving the entity character string and the target entity character string in the appointed aggregation result to obtain the target language description.
4. The method according to claim 1 or 2, wherein when the aggregation fallback includes sequence fallback, the aggregation fallback result is a next entity string sequence of the entity string sequence that fails to aggregate, where the entity string sequence that fails to aggregate and the next entity string sequence belong to at least two entity string sequences corresponding to the natural language description, each entity string sequence corresponds to one entity segmentation manner of the natural language description;
the step of performing the re-aggregation based on the aggregation rollback result to obtain semantic information to be analyzed includes:
And re-aggregating the next entity character string sequence to obtain the semantic information to be analyzed.
5. The method according to claim 1 or 2, wherein when the aggregation fallback includes entity string fallback and sequence fallback, the aggregation fallback of the entity string sequence that fails to aggregate includes:
Performing entity character string rollback on the entity character string sequence with failed aggregation to obtain an entity character string rollback result;
re-aggregating the entity character string rollback results;
And carrying out sequence backspacing on the entity character string backspacing result with aggregation failure, wherein the sequence backspacing result is the aggregation backspacing result.
6. The method according to claim 1 or 2, wherein before performing entity recognition on the natural language description to obtain the entity string sequence, the method further comprises:
acquiring domain resources of the natural language description, wherein the domain resources comprise at least one of an entity character string library and an entity recognition model, and the entity recognition model is a neural network model for recognizing an entity;
the entity recognition is performed on the natural language description to obtain an entity character string sequence, which comprises the following steps:
and carrying out entity recognition on the natural language description based on the domain resource to obtain the entity character string sequence.
7. The method according to claim 1 or 2, wherein after the end of the polymerization, the method further comprises:
When the entity character string corresponding to the single aggregation result comprises the entity character string sequence, determining that the aggregation is successful;
and when the entity character string corresponding to the single aggregation result comprises part of the entity character strings in the entity character string sequence, determining that aggregation fails.
8. The method according to claim 1 or 2, wherein the parsing the semantic information to be parsed to obtain a target language description includes:
Analyzing the semantic information to be analyzed layer by layer to obtain sub-descriptions to be spliced;
and splicing the sub-descriptions to be spliced to obtain the target language description.
9. The method according to claim 1 or 2, wherein after parsing the semantic information to be parsed to obtain a target language description, the method further comprises:
Processing the database based on the target language description to obtain a database processing result, wherein the database processing result comprises at least one of queried target data, a deleting result, a modifying result and an adding result;
And presenting the database processing result.
10. A natural language processing apparatus, the natural language processing apparatus comprising:
The entity recognition module is used for carrying out entity recognition on the natural language description to obtain an entity character string sequence, wherein the natural language description is information for interacting with a database by adopting the natural language description, and each entity character string in the entity character string sequence is a label of an entity in the natural language description in a target language; the entity recognition is performed on the natural language description to obtain an entity character string sequence, which comprises the following steps: extracting the entity from the natural language description to obtain an initial entity character string sequence; mapping an initial entity character string in the initial entity character string sequence into the entity character string based on a corresponding relation between a database attribute and an entity to obtain the entity character string sequence corresponding to the initial entity character string, wherein the corresponding relation between the database attribute and the entity is a corresponding relation between an attribute in a database and an entity described by natural language;
The sequence aggregation module is used for mapping each entity character string in the entity character string sequence into a grammar element of a target grammar to obtain a grammar element sequence corresponding to the entity character string sequence; performing layer-by-layer aggregation on the grammar element sequence based on an aggregation rule corresponding to the target grammar, and ending the aggregation until the aggregation is a single aggregation result, wherein semantic information to be analyzed comprises the single aggregation result, and performing aggregation rollback on the entity character string sequence with failed aggregation, wherein the target grammar is the grammar of the target language;
the sequence aggregation module is further configured to perform re-aggregation based on an aggregation rollback result to obtain semantic information to be resolved, where the semantic information to be resolved is an aggregation relationship between the entity character strings in the entity character sequence;
The information analysis module is used for analyzing the semantic information to be analyzed to obtain target language description, wherein the target language description is information which adopts the target language description and is used for interacting with the database.
11. A natural language processing apparatus, characterized in that the natural language processing apparatus comprises:
a memory for storing executable instructions;
A processor for implementing the natural language processing method of any one of claims 1 to 9 when executing executable instructions stored in the memory.
12. A computer readable storage medium storing executable instructions for implementing the natural language processing method of any one of claims 1 to 9 when executed by a processor.
13. A computer program product comprising a computer program or instructions which, when executed by a processor, implements the natural language processing method of any one of claims 1 to 9.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210106438.2A CN114428788B (en) | 2022-01-28 | 2022-01-28 | Natural language processing method, device, equipment and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210106438.2A CN114428788B (en) | 2022-01-28 | 2022-01-28 | Natural language processing method, device, equipment and storage medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN114428788A CN114428788A (en) | 2022-05-03 |
CN114428788B true CN114428788B (en) | 2024-08-13 |
Family
ID=81314106
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202210106438.2A Active CN114428788B (en) | 2022-01-28 | 2022-01-28 | Natural language processing method, device, equipment and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN114428788B (en) |
Families Citing this family (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN115329753B (en) * | 2022-10-13 | 2023-03-24 | 北京谊慧信息技术有限公司 | Intelligent data analysis method and system based on natural language processing |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109684448A (en) * | 2018-12-17 | 2019-04-26 | 北京北大软件工程股份有限公司 | A kind of intelligent answer method |
CN110717025A (en) * | 2019-10-08 | 2020-01-21 | 北京百度网讯科技有限公司 | Question answering method and device, electronic equipment and storage medium |
Family Cites Families (13)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US10133724B2 (en) * | 2016-08-22 | 2018-11-20 | International Business Machines Corporation | Syntactic classification of natural language sentences with respect to a targeted element |
GB2569953A (en) * | 2017-12-30 | 2019-07-10 | Innoplexus Ag | Method and system for extracting entity information from target data |
CN110111780B (en) * | 2018-01-31 | 2023-04-25 | 阿里巴巴集团控股有限公司 | Data processing method and server |
US11157564B2 (en) * | 2018-03-02 | 2021-10-26 | Thoughtspot, Inc. | Natural language question answering systems |
US11036726B2 (en) * | 2018-09-04 | 2021-06-15 | International Business Machines Corporation | Generating nested database queries from natural language queries |
US11347802B2 (en) * | 2019-07-24 | 2022-05-31 | Citrix Systems, Inc. | Query generation using natural language input |
CN112580357A (en) * | 2019-09-29 | 2021-03-30 | 微软技术许可有限责任公司 | Semantic parsing of natural language queries |
US11222013B2 (en) * | 2019-11-19 | 2022-01-11 | Sap Se | Custom named entities and tags for natural language search query processing |
CN111177184A (en) * | 2019-12-24 | 2020-05-19 | 深圳壹账通智能科技有限公司 | Structured query language conversion method based on natural language and related equipment thereof |
CN111563385B (en) * | 2020-04-30 | 2023-12-26 | 北京百度网讯科技有限公司 | Semantic processing method, semantic processing device, electronic equipment and medium |
CN113918589A (en) * | 2020-07-10 | 2022-01-11 | 阿里巴巴集团控股有限公司 | Query statement generation method, correlation method and device |
CN112632100A (en) * | 2020-12-18 | 2021-04-09 | 中国平安人寿保险股份有限公司 | Natural language sentence analyzing method and device, electronic equipment and storage medium |
CN112860866B (en) * | 2021-02-09 | 2023-09-19 | 北京百度网讯科技有限公司 | Semantic retrieval method, device, equipment and storage medium |
-
2022
- 2022-01-28 CN CN202210106438.2A patent/CN114428788B/en active Active
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109684448A (en) * | 2018-12-17 | 2019-04-26 | 北京北大软件工程股份有限公司 | A kind of intelligent answer method |
CN110717025A (en) * | 2019-10-08 | 2020-01-21 | 北京百度网讯科技有限公司 | Question answering method and device, electronic equipment and storage medium |
Also Published As
Publication number | Publication date |
---|---|
CN114428788A (en) | 2022-05-03 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN111708874B (en) | Man-machine interaction question-answering method and system based on intelligent complex intention recognition | |
US9652719B2 (en) | Authoring system for bayesian networks automatically extracted from text | |
Meziane et al. | Generating natural language specifications from UML class diagrams | |
WO2018149326A1 (en) | Natural language question answering method and apparatus, and server | |
WO2022218186A1 (en) | Method and apparatus for generating personalized knowledge graph, and computer device | |
CN111125309A (en) | Natural language processing method and device, computing equipment and storage medium | |
US20160364377A1 (en) | Language Processing And Knowledge Building System | |
CN115292457B (en) | Knowledge question answering method and device, computer readable medium and electronic equipment | |
US20150286943A1 (en) | Decision Making and Planning/Prediction System for Human Intention Resolution | |
US20220222447A1 (en) | Translation method and apparatus, electronic device, and computer-readable storage medium | |
US20220414463A1 (en) | Automated troubleshooter | |
US11537797B2 (en) | Hierarchical entity recognition and semantic modeling framework for information extraction | |
CN113987199B (en) | BIM intelligent image examination method, system and medium with standard automatic interpretation | |
CN113779062A (en) | SQL statement generation method and device, storage medium and electronic equipment | |
CN111813961A (en) | Data processing method and device based on artificial intelligence and electronic equipment | |
CN113704420A (en) | Method and device for identifying role in text, electronic equipment and storage medium | |
CN116257610A (en) | Intelligent question-answering method, device, equipment and medium based on industry knowledge graph | |
CN114428788B (en) | Natural language processing method, device, equipment and storage medium | |
WO2021135103A1 (en) | Method and apparatus for semantic analysis, computer device, and storage medium | |
CN117932022A (en) | Intelligent question-answering method and device, electronic equipment and storage medium | |
CN115878818B (en) | Geographic knowledge graph construction method, device, terminal and storage medium | |
CN117473054A (en) | Knowledge graph-based general intelligent question-answering method and device | |
Ashfaq et al. | An intelligent analytics approach to minimize complexity in ambiguous software requirements | |
CN114625759B (en) | Model training method, intelligent question-answering method, device, medium and program product | |
CN114840657A (en) | API knowledge graph self-adaptive construction and intelligent question-answering method based on mixed mode |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |