A semantic parsing method and device based on triples
By generating an entity triple library and matching entity relationships in user input speech, the problem of inaccurate semantic parsing in human-computer interaction is solved and the parsing accuracy is improved.
Patent Information
- Application Number
- CN201910364367.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-04-30
- Publication Date
- 2024-10-18
- Estimated Expiration
- 2039-04-30
AI Technical Summary
It is difficult for existing technologies to accurately parse user semantics in human-computer interaction scenarios, leading to the problem of inaccurate feedback.
By generating an entity triplet library, entity relationships are extracted based on the dependency tree of the corpus, matching the entity relationships in the user's input speech, and then performing semantic analysis.
It improves the accuracy of semantic analysis and ensures correct feedback in human-computer interaction.
Smart Images

Figure CN111858866B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of semantic parsing, and in particular relates to a semantic parsing method and device based on triples. Background Art
[0002] With the rapid development of smart terminals and network technology, various smart products are playing an increasingly important role in people's lives, and people are becoming more and more accustomed to using smart terminals to meet various needs. With the increasing maturity of artificial intelligence-related technologies, the intelligence level of various terminals is also getting higher and higher. Natural language, as the most convenient and natural way for humans to express their thoughts, has gradually become the most mainstream human-computer interaction method in the field of intelligent services.
[0003] In human-computer interaction scenarios, semantic analysis is an indispensable link. It mainly analyzes the user's voice input, parses the user's semantics, and converts it into a structured data format that the machine can understand, and then makes corresponding feedback. Therefore, in human-computer interaction scenarios, accurately parsing the user's semantics is the basis for making correct responses. Summary of the invention
[0004] The purpose of the present invention is to provide a triple-based semantic parsing method and device, which obtains the subject relationship in the speech to be parsed according to the generated entity triples, so as to perform semantic parsing on the speech to be parsed.
[0005] The technical solution provided by the present invention is as follows:
[0006] On the one hand, a semantic parsing method based on triples is provided, comprising:
[0007] Obtain a large amount of corpus;
[0008] Generate an entity triple library according to the dependency trees of the large number of corpora, wherein the entity triple library includes entity triples representing various entity relationships;
[0009] Get the user input voice to be parsed;
[0010] Determine the entity relationship in the speech to be parsed according to the entity triples in the entity triple library, and extract the entity corresponding to the entity relationship;
[0011] According to the entities and the entity relationships between the entities, semantic analysis is performed on the speech to be analyzed.
[0012] Further preferably, generating the entity triple library according to the dependency trees of the large amount of corpora specifically includes:
[0013] Generate a dependency tree from the corpus;
[0014] Extracting noun entities in the corpus;
[0015] In the dependency tree, a valid node representing the noun entity is found;
[0016] Acquire an intermediate node that is simultaneously connected to more than two of the valid nodes;
[0017] Generate an entity triple according to the intermediate node and two or more valid nodes simultaneously connected to the intermediate node;
[0018] An entity triple library is generated according to the entity triples.
[0019] Further preferably, after generating the entity triplet according to the intermediate node and the two or more valid nodes connected to the intermediate node at the same time, the method further comprises:
[0020] Classify entity triples;
[0021] Merge two or more identical entity triples to generate one entity triple.
[0022] Further preferably, determining the entity relationship in the speech to be parsed according to the entity triples in the entity triple library, and extracting the entity corresponding to the entity relationship specifically includes:
[0023] Performing word segmentation and annotation on the speech to be analyzed, and extracting keywords from the speech to be analyzed;
[0024] Matching the keywords with entity triples in the entity triple library to determine entity relationships in the speech to be parsed;
[0025] According to the entity relationship, entities corresponding to the entity relationship are extracted from the speech to be parsed.
[0026] More preferably, it also includes:
[0027] Generate a query knowledge graph corresponding to the speech to be parsed according to the entities and the entity relationships between the entities;
[0028] According to the query knowledge graph, the query intent corresponding to the speech to be analyzed is identified.
[0029] On the other hand, a semantic parsing device based on triples is also provided, comprising:
[0030] Corpus acquisition module, used to acquire a large amount of corpus;
[0031] A triple library generation module, used to generate an entity triple library according to the dependency trees of the large number of corpora, wherein the entity triple library includes entity triples representing various entity relationships;
[0032] A voice acquisition module is used to acquire the voice to be parsed input by the user;
[0033] An extraction module, used to determine the entity relationship in the speech to be parsed according to the entity triples in the entity triple library, and extract the entity corresponding to the entity relationship;
[0034] The semantic parsing module is used to perform semantic parsing on the speech to be parsed according to the entities and the entity relationships between the entities.
[0035] Further preferably, the triple library generation module includes:
[0036] A dependency tree generating unit, used for generating a dependency tree from the corpus;
[0037] A noun entity extraction unit, used to extract noun entities from the corpus;
[0038] A node search unit, used to search for a valid node representing the noun entity in the dependency tree;
[0039] The node search unit is further used to obtain an intermediate node that is simultaneously connected to more than two valid nodes;
[0040] A triplet generation unit, configured to generate an entity triplet according to the intermediate node and two or more valid nodes simultaneously connected to the intermediate node;
[0041] The triple library generation unit is used to generate an entity triple library according to the entity triples.
[0042] Further preferably, the triple library generation module further includes:
[0043] Classification unit, used to classify entity triples;
[0044] The merging unit is used to merge two or more identical entity triples to generate one entity triple.
[0045] Further preferably, the extraction module comprises:
[0046] A keyword extraction unit, used to perform word segmentation and annotation on the speech to be analyzed, and extract keywords from the speech to be analyzed;
[0047] A matching unit, used for matching the keyword with the entity triple in the entity triple library to determine the entity relationship in the speech to be parsed;
[0048] The entity extraction unit is used to extract entities corresponding to the entity relationship in the speech to be parsed according to the entity relationship.
[0049] More preferably, it also includes:
[0050] A graph generation module, used to generate a query knowledge graph corresponding to the speech to be parsed according to the entities and the entity relationships between the entities;
[0051] The intent recognition module is used to identify the query intent corresponding to the speech to be parsed based on the query knowledge graph.
[0052] Compared with the prior art, the beneficial effects of the triple-based semantic parsing method and device provided by the present invention are as follows: first, an entity triple library is automatically generated based on the grammatical dependency tree of a large amount of corpus, and then the entities and entity relationships in the speech to be parsed input by the user are extracted based on the entity triples in the entity triple library. The semantics of the speech to be parsed can be accurately obtained based on the entities and entity relationships, thereby improving the accuracy of semantic parsing. BRIEF DESCRIPTION OF THE DRAWINGS
[0053] The following will explain the preferred implementation mode in a clear and understandable manner with reference to the accompanying drawings, and further explain the above-mentioned characteristics, technical features, advantages and implementation methods of a semantic parsing method and device based on triples.
[0054] Figure 1 It is a flowchart of a first embodiment of a triple-based semantic parsing method of the present invention;
[0055] Figure 2 is a dependency tree diagram of a first embodiment of a triple-based semantic parsing method of the present invention;
[0056] Figure 3 It is a flow chart of a second embodiment of a triple-based semantic parsing method of the present invention;
[0057] Figure 4 is a dependency tree diagram of a second embodiment of a triple-based semantic parsing method of the present invention;
[0058] Figure 5 is a flow chart of a third embodiment of a triple-based semantic parsing method of the present invention;
[0059] Figure 6 is a flow chart of a fourth embodiment of a triple-based semantic parsing method of the present invention;
[0060] Figure 7is a flowchart of a fifth embodiment of a triple-based semantic parsing method of the present invention;
[0061] Figure 8 It is a schematic block diagram of the structure of a semantic parsing device based on triples of the present invention.
[0062] Description of Figure Numbers
[0063] 100. Corpus acquisition module; 200. Triple library generation module;
[0064] 210. Dependency tree generation unit; 220. Noun entity extraction unit;
[0065] 230, node search unit; 240, triple generation unit;
[0066] 250. triple library generation unit; 260. classification unit;
[0067] 270, merging unit; 300, voice acquisition module;
[0068] 400, extraction module; 410, keyword extraction unit;
[0069] 420, matching unit; 430, entity extraction unit;
[0070] 500. semantic parsing module; 600. graph generation module;
[0071] 700. Intent recognition module. DETAILED DESCRIPTION
[0072] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the specific implementation methods of the present invention will be described below with reference to the accompanying drawings. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings and other implementation methods can be obtained based on these drawings without creative work.
[0073] In order to simplify the drawings, only the parts related to the present invention are schematically shown in each figure, and they do not represent the actual structure of the product. In addition, in order to simplify the drawings and facilitate understanding, in some figures, only one of the parts with the same structure or function is schematically drawn or marked. In this article, "one" not only means "only one", but also means "more than one".
[0074] According to a first embodiment provided by the present invention, Figure 1 As shown, a semantic parsing method based on triples includes:
[0075] S100 acquires a large amount of corpus;
[0076] Specifically, the purpose of acquiring a large amount of corpus is to build an entity triple library, so the richer the corpus acquired, the better.
[0077] There are many ways to obtain corpus, for example: corpus collected when users use smart terminals; or crawling a large amount of corpus through crawlers and other technologies. Of course, there are also other ways to collect corpus, and all methods can be used in combination to make the corpus richer and cover a wider range.
[0078] S200 generates an entity triple library according to the dependency trees of the large amount of corpora, wherein the entity triple library includes entity triples representing various entity relationships;
[0079] Specifically, a dependency tree can be used to represent the grammatical dependency relationship between words in a corpus. A dependency tree includes nodes and connecting edges. Nodes can be used to represent words in a corpus, and connecting edges can be used to represent the grammatical relationship between words connected to nodes.
[0080] For example, if the corpus is "Kitten Drinks Milk", the corpus is segmented and POS tagged to get "1 Kitten / n 2 Drink / v 3 Milk / n", and the generated dependency tree is as follows Figure 2 As shown in the figure, nsubj indicates a noun subject relationship, and dobj indicates a direct object relationship.
[0081] An entity triplet can be understood as (entity 1, entity relationship, entity 2), where the entity relationship refers to the entity relationship between entity 1 and entity 2.
[0082] According to the dependency tree of each corpus, the relationship between each entity in the corpus can be obtained, and then the entity triples corresponding to each corpus are generated according to the relationship between each entity in the corpus. The entity triples generated for each corpus can be one or more.
[0083] S300 obtains the speech to be parsed input by the user;
[0084] Specifically, the speech to be analyzed input by the user at the user end is obtained. For example, the speech to be analyzed may be "What movie is starring Xiao Ming?", "Open the video software", "Explain the linear equation of one variable", "Monkey eats banana", etc.
[0085] S400 determines the entity relationship in the speech to be parsed according to the entity triples in the entity triple library, and extracts the entity corresponding to the entity relationship;
[0086] Specifically, after the entity triple library is generated, the speech to be parsed is matched with the entity triples in the entity triple library to determine the entity relationship in the speech to be parsed, and then the entity corresponding to the entity relationship is extracted based on the determined entity relationship.
[0087] S500 performs semantic analysis on the speech to be analyzed according to the entities and the entity relationships between the entities.
[0088] Specifically, finally, semantic analysis is performed on the speech to be analyzed based on the extracted entities and the entity relationships between the entities.
[0089] For example, the speech to be parsed is "Has Xiao Ming starred in a movie directed by Xiao Hong?" Assume that the entity triple library contains two entity triples, the first entity triple is (X, starring, movie), and the second entity triple is (a, director, movie). When the speech to be parsed is matched with the entity triples in the entity triple library, the first entity triple and the second entity triple can be matched. According to the first entity triple and the second entity triple, the entity relationship in the speech to be parsed can be determined to be "starring" and "director"; then the entities "Xiao Ming" and "movie" associated with the entity relationship "starring" are extracted, as well as the entities "Xiao Hong" and "movie" associated with the entity relationship "director". According to the extracted entities and the relationship between entities, the semantics of the speech to be parsed can be parsed as: "Xiao Ming starred in the movie, and the movie was directed by Xiao Hong".
[0090] In this embodiment, an entity triple library is first automatically generated based on the grammatical dependency tree of a large amount of corpus, and then the entities and entity relationships in the speech to be parsed input by the user are extracted based on the entity triples in the entity triple library. The semantics of the speech to be parsed can be accurately obtained based on the entities and entity relationships, thereby improving the accuracy of semantic parsing.
[0091] According to a second embodiment provided by the present invention, Figure 3 As shown, a semantic parsing method based on triples includes:
[0092] S100 acquires a large amount of corpus;
[0093] S210 generates a dependency tree from the corpus;
[0094] Specifically, after obtaining a large amount of corpus, the corpus is segmented into simple phrases. For example, monkeys like to eat bananas, and the segmentation is: monkeys / like / eat / bananas. Then the segmentation is turned to part-of-speech tagging, monkey / n likes / v / eats / v / Hong Kong / n. Then the part-of-speech tagging generates a phrase syntax tree, and finally the phrase syntax tree is converted into a dependency tree (dependency relations can be represented by a tree diagram, and a tree diagram representing dependency relations is called a dependency tree). All corpus are converted into dependency trees through the above steps.
[0095] For another example, the corpus "Has Xiao Ming starred in a movie directed by Xiao Hong?" is segmented into: Xiao Ming / starred / in / a / movie / directed / by / Xiao Hong; then part-of-speech tagging is performed, and the generated dependency tree is as follows: Figure 4 shown.
[0096] S220 extracts noun entities in the corpus;
[0097] Specifically, noun entities are extracted from the corpus, such as "monkey" and "banana" in the corpus "Monkeys like to eat bananas" and "Xiao Ming", "Xiao Hong" and "movie" in the corpus "Has Xiao Ming starred in a movie directed by Xiao Hong?"
[0098] S230: searching, in the dependency tree, for a valid node representing the noun entity;
[0099] Specifically, in the generated dependency tree, nodes representing noun entities are found, such as a node representing "monkey", a node representing "banana", a node representing "Xiao Ming", a node representing "Xiao Hong", and a node representing "movie".
[0100] S240: Acquire an intermediate node that is simultaneously connected to more than two valid nodes;
[0101] Specifically, after finding a valid node representing a noun entity in the dependency tree, an intermediate node simultaneously connected to more than two valid nodes is obtained.
[0102] For example, in the dependency tree, the intermediate node "leading actor" is connected to both the node "Xiao Ming" and the node "movie", and the intermediate node "director" is connected to both the node "Xiao Hong" and the node "movie".
[0103] S250 generates an entity triple according to the intermediate node and two or more valid nodes simultaneously connected to the intermediate node;
[0104] Specifically, after the intermediate node and two or more valid nodes simultaneously connected to the intermediate node are found, an entity triple is generated according to the intermediate node and the valid nodes.
[0105] For example, the entity triple generated based on the intermediate node "starring" and the two valid nodes "Xiao Ming" and "movie" connected to "starring" at the same time is (Xiao Ming, starring, movie).
[0106] For another example, the entity triplet generated based on the intermediate node "director" and the two valid nodes "Xiaohong" and "movie" connected to "director" is (Xiaohong, director, movie).
[0107] S260 generates an entity triple library according to the entity triples, wherein the entity triple library includes entity triples representing various entity relationships;
[0108] Specifically, after generating entity triples according to each corpus, the generated entity triples are placed in the entity triple library. Each corpus can generate one or more entity triples. Of course, there are also corpora that cannot generate entity triples.
[0109] S300 obtains the speech to be parsed input by the user;
[0110] S400 determines the entity relationship in the speech to be parsed according to the entity triples in the entity triple library, and extracts the entity corresponding to the entity relationship;
[0111] S500 performs semantic analysis on the speech to be analyzed according to the entities and the entity relationships between the entities.
[0112] In this embodiment, a large number of entity triples are generated through a large amount of corpus to enrich the entity triple library, so as to improve the success rate of semantic parsing when semantic parsing is performed through the entity triples.
[0113] According to a third embodiment provided by the present invention, Figure 5 As shown, a semantic parsing method based on triples includes:
[0114] S100 acquires a large amount of corpus;
[0115] S210 generates a dependency tree from the corpus;
[0116] S220 extracts noun entities in the corpus;
[0117] S230: searching, in the dependency tree, for a valid node representing the noun entity;
[0118] S240: Acquire an intermediate node that is simultaneously connected to more than two valid nodes;
[0119] S250 generates an entity triple according to the intermediate node and two or more valid nodes simultaneously connected to the intermediate node;
[0120] S260 generates an entity triple library according to the entity triples, wherein the entity triple library includes entity triples representing various entity relationships;
[0121] S270 classifies entity triples;
[0122] Specifically, after entity triples are generated according to the corpus, the generated entity triples are classified, and the classification can be carried out according to fields, such as film and television, tourism, games, finance, etc. Classifying entity triples can improve the search efficiency of entity triples.
[0123] S280 merges two or more identical entity triples to generate one entity triple;
[0124] Specifically, after classifying the entity triples, the entity triples with the same semantics are merged to generate one entity triple, so as to reduce the number of entity triples.
[0125] For example, for entity triple 1 (entity 1, entity relationship 1, entity 2) and entity triple 2 (entity 3, entity relationship 2, entity 4), if the semantics of entity relationship 1 and entity relationship 2 are the same, then entity triple 1 and entity triple 2 are merged into one entity triple (X, entity relationship 1 / entity relationship 2, Y), where X and Y can be words representing a certain category, such as words representing personal names, words representing place names, etc.
[0126] S300 obtains the speech to be parsed input by the user;
[0127] S400 determines the entity relationship in the speech to be parsed according to the entity triples in the entity triple library, and extracts the entities corresponding to the entity relationship;
[0128] S500 performs semantic parsing on the speech to be parsed according to the entities and the entity relationships between the entities.
[0129] According to the fourth embodiment provided by the present invention, as Figure 6 shown, a semantic parsing method based on triples includes:
[0130] S100 obtains a large amount of corpus;
[0131] S200 generates an entity triple library according to the dependency trees of a large amount of the corpus, and the entity triple library includes entity triples representing various entity relationships;
[0132] S300 obtains the speech to be parsed input by the user;
[0133] S410 performs word segmentation and tagging on the speech to be parsed, and extracts the keywords in the speech to be parsed;
[0134] Specifically, after obtaining the speech to be parsed, the existing word segmentation and tagging method is used to perform word segmentation and tagging on the speech to be parsed, and then the keywords in the speech to be parsed are extracted. The keywords in the speech to be parsed are the words after removing meaningless words such as "de", "di", "le", etc.
[0135] S420 matches the keywords with the entity triples in the entity triple library to determine the entity relationship in the speech to be parsed;
[0136] Specifically, the keywords extracted from the speech to be parsed are matched with the words representing the entity relationship in the entity triples, and the entity relationship in the speech to be parsed is determined according to the matched entity triples, that is, the keywords representing the entity relationship are determined. The keywords representing the entity relationship can be one or more, such as "starring" and "director".
[0137] S430 extracting entities corresponding to the entity relationship from the speech to be parsed according to the entity relationship;
[0138] Specifically, after determining the entity relationship in the speech to be analyzed, entities corresponding to the entity relationship are extracted from the speech to be analyzed according to the entity relationship, such as extracting entities related to "starring actor" and extracting entities related to "director".
[0139] S500 performs semantic analysis on the speech to be analyzed according to the entities and the entity relationships between the entities.
[0140] In this embodiment, keywords are first extracted from the speech to be analyzed, and then entity triples are matched according to the keywords, which can improve the matching efficiency and further improve the efficiency of semantic analysis.
[0141] According to a fifth embodiment provided by the present invention, Figure 7 As shown, a semantic parsing method based on triples includes:
[0142] S100 acquires a large amount of corpus;
[0143] S200 generates an entity triple library according to the dependency trees of the large amount of corpora, wherein the entity triple library includes entity triples representing various entity relationships;
[0144] S300 obtains the speech to be parsed input by the user;
[0145] S400 determines the entity relationship in the speech to be parsed according to the entity triples in the entity triple library, and extracts the entity corresponding to the entity relationship;
[0146] S500 performs semantic analysis on the speech to be analyzed according to the entities and the entity relationships between the entities;
[0147] S600 generates a query knowledge graph corresponding to the speech to be parsed according to the entities and the entity relationships between the entities;
[0148] Specifically, after obtaining the entities in the speech to be parsed and the entity relationships between the entities, the entity triples corresponding to the speech to be parsed can be constructed based on the entities and the entity relationships, and then the query knowledge graph corresponding to the speech to be parsed can be constructed based on the constructed entity triples, that is, the corresponding query knowledge graph can be constructed based on the entity relationships between multiple entities. The query knowledge graph includes nodes representing entities and connecting edges between nodes, and the connecting edges between nodes represent the entity relationships between entities.
[0149] S700 identifies the query intent corresponding to the speech to be parsed based on the query knowledge graph.
[0150] Specifically, after constructing the query knowledge graph corresponding to the speech to be analyzed, the constructed query knowledge graph can be used to determine the user's query intention, providing convenience for the user to query information.
[0151] According to a sixth embodiment provided by the present invention, Figure 8 As shown, a semantic parsing device based on triples includes:
[0152] Corpus acquisition module 100, used to acquire a large amount of corpus;
[0153] Specifically, the purpose of acquiring a large amount of corpus is to build an entity triple library, so the richer the corpus acquired, the better.
[0154] There are many ways to obtain corpus, for example: corpus collected when users use smart terminals; or crawling a large amount of corpus through crawlers and other technologies. Of course, there are also other ways to collect corpus, and all methods can be used in combination to make the corpus richer and cover a wider range.
[0155] A triple library generation module 200, for generating an entity triple library according to the dependency trees of the large number of corpora, wherein the entity triple library includes entity triples representing various entity relationships;
[0156] Specifically, a dependency tree can be used to represent the grammatical dependency relationship between words in a corpus. A dependency tree includes nodes and connecting edges. Nodes can be used to represent words in a corpus, and connecting edges can be used to represent the grammatical relationship between words connected to nodes.
[0157] For example, if the corpus is "Kitten Drinks Milk", the corpus is segmented and POS tagged to get "1 Kitten / n 2 Drink / v 3 Milk / n", and the generated dependency tree is as follows Figure 2 As shown in the figure, nsubj indicates a noun subject relationship, and dobj indicates a direct object relationship.
[0158] An entity triplet can be understood as (entity 1, entity relationship, entity 2), where the entity relationship refers to the entity relationship between entity 1 and entity 2.
[0159] According to the dependency tree of each corpus, the relationship between each entity in the corpus can be obtained, and then the entity triples corresponding to each corpus are generated according to the relationship between each entity in the corpus. The entity triples generated for each corpus can be one or more.
[0160] The speech acquisition module 300 is used to acquire the speech to be analyzed input by the user;
[0161] Specifically, the speech to be analyzed input by the user at the user end is obtained. For example, the speech to be analyzed may be "What movie is starring Xiao Ming?", "Open the video software", "Explain the linear equation of one variable", "Monkey eats banana", etc.
[0162] An extraction module 400, configured to determine entity relationships in the speech to be parsed according to entity triples in the entity triple library, and extract entities corresponding to the entity relationships;
[0163] Specifically, after the entity triple library is generated, the speech to be parsed is matched with the entity triples in the entity triple library to determine the entity relationship in the speech to be parsed, and then the entity corresponding to the entity relationship is extracted based on the determined entity relationship.
[0164] The semantic parsing module 500 is used to perform semantic parsing on the speech to be parsed according to the entities and the entity relationships between the entities.
[0165] Specifically, finally, semantic analysis is performed on the speech to be analyzed based on the extracted entities and the entity relationships between the entities.
[0166] For example, the speech to be parsed is "Has Xiao Ming starred in a movie directed by Xiao Hong?" Assume that the entity triple library contains two entity triples, the first entity triple is (X, starring, movie), and the second entity triple is (a, director, movie). When the speech to be parsed is matched with the entity triples in the entity triple library, the first entity triple and the second entity triple can be matched. According to the first entity triple and the second entity triple, the entity relationship in the speech to be parsed can be determined to be "starring" and "director"; then the entities "Xiao Ming" and "movie" associated with the entity relationship "starring" are extracted, as well as the entities "Xiao Hong" and "movie" associated with the entity relationship "director". According to the extracted entities and the relationship between entities, the semantics of the speech to be parsed can be parsed as: "Xiao Ming starred in the movie, and the movie was directed by Xiao Hong".
[0167] In this embodiment, an entity triple library is first automatically generated based on the grammatical dependency tree of a large amount of corpus, and then the entities and entity relationships in the speech to be parsed input by the user are extracted based on the entity triples in the entity triple library. The semantics of the speech to be parsed can be accurately obtained based on the entities and entity relationships, thereby improving the accuracy of semantic parsing.
[0168] Preferably, the triple library generation module 200 includes:
[0169] A dependency tree generating unit 210, configured to generate a dependency tree from the corpus;
[0170] Specifically, after obtaining a large amount of corpus, the corpus is segmented into simple phrases. For example, monkeys like to eat bananas, and the segmentation is: monkeys / like / eat / bananas. Then the segmentation is turned to part-of-speech tagging, monkey / n likes / v / eats / v / Hong Kong / n. Then the part-of-speech tagging generates a phrase syntax tree, and finally the phrase syntax tree is converted into a dependency tree (dependency relations can be represented by a tree diagram, and a tree diagram representing dependency relations is called a dependency tree). All corpus are converted into dependency trees through the above steps.
[0171] For another example, the corpus "Has Xiao Ming starred in a movie directed by Xiao Hong?" is segmented into: Xiao Ming / starred / in / a / movie / directed / by / Xiao Hong; then part-of-speech tagging is performed, and the generated dependency tree is as follows: Figure 4 shown.
[0172] A noun entity extraction unit 220, used to extract noun entities from the corpus;
[0173] Specifically, noun entities are extracted from the corpus, such as "monkey" and "banana" in the corpus "Monkeys like to eat bananas" and "Xiao Ming", "Xiao Hong" and "movie" in the corpus "Has Xiao Ming starred in a movie directed by Xiao Hong?"
[0174] A node search unit 230, configured to search the dependency tree for a valid node representing the noun entity;
[0175] Specifically, in the generated dependency tree, nodes representing noun entities are found, such as a node representing "monkey", a node representing "banana", a node representing "Xiao Ming", a node representing "Xiao Hong", and a node representing "movie".
[0176] The node search unit 230 is further used to obtain an intermediate node connected to more than two valid nodes at the same time;
[0177] Specifically, after finding a valid node representing a noun entity in the dependency tree, an intermediate node simultaneously connected to more than two valid nodes is obtained.
[0178] For example, in the dependency tree, the intermediate node "leading actor" is connected to both the node "Xiao Ming" and the node "movie", and the intermediate node "director" is connected to both the node "Xiao Hong" and the node "movie".
[0179] A triplet generation unit 240, configured to generate an entity triplet according to the intermediate node and two or more valid nodes simultaneously connected to the intermediate node;
[0180] Specifically, after the intermediate node and two or more valid nodes simultaneously connected to the intermediate node are found, an entity triple is generated according to the intermediate node and the valid nodes.
[0181] For example, the entity triple generated based on the intermediate node "starring" and the two valid nodes "Xiao Ming" and "movie" connected to "starring" at the same time is (Xiao Ming, starring, movie).
[0182] For another example, the entity triplet generated based on the intermediate node "director" and the two valid nodes "Xiaohong" and "movie" connected to "director" is (Xiaohong, director, movie).
[0183] The triple library generation unit 250 is configured to generate an entity triple library according to the entity triples.
[0184] Specifically, after generating entity triples according to each corpus, the generated entity triples are placed in the entity triple library. Each corpus can generate one or more entity triples. Of course, there are also corpora that cannot generate entity triples.
[0185] In this embodiment, a large number of entity triples are generated through a large amount of corpus to enrich the entity triple library, so as to improve the success rate of semantic parsing when semantic parsing is performed through the entity triples.
[0186] Preferably, the triple library generation module 200 further includes:
[0187] A classification unit 260, for classifying entity triples;
[0188] Specifically, after entity triples are generated according to the corpus, the generated entity triples are classified, and the classification can be carried out according to fields, such as film and television, tourism, games, finance, etc. Classifying entity triples can improve the search efficiency of entity triples.
[0189] The merging unit 270 is used to merge two or more identical entity triples to generate one entity triple.
[0190] Specifically, after the entity triples are classified, entity triples with the same semantics are merged to generate one entity triple to reduce the number of entity triples.
[0191] For example, for entity triple 1 (entity 1, entity relationship 1, entity 2) and entity triple 2 (entity 3, entity relationship 2, entity 4), if the semantics of entity relationship 1 and entity relationship 2 are the same, then entity triple 1 and entity triple 2 are merged into one entity triple (X, entity relationship 1 / entity relationship 2, Y), where X and Y can be words representing a certain category, such as words representing personal names, words representing place names, etc.
[0192] Preferably, the extraction module 400 includes:
[0193] A keyword extraction unit 410, configured to perform word segmentation and tagging on the to-be-parsed speech, and extract keywords in the to-be-parsed speech;
[0194] Specifically, after obtaining the to-be-parsed speech, an existing word segmentation and tagging method is used to perform word segmentation and tagging on the to-be-parsed speech, and then keywords in the to-be-parsed speech are extracted. The keywords in the to-be-parsed speech are words after removing meaningless words such as "de", "di", and "le".
[0195] A matching unit 420, configured to match the keywords with entity triples in the entity triple library to determine the entity relationship in the to-be-parsed speech;
[0196] Specifically, the keywords extracted from the to-be-parsed speech are matched with the words representing the entity relationship in the entity triples, and according to the matched entity triples, the entity relationship in the to-be-parsed speech is determined, that is, the keywords representing the entity relationship are determined. The keywords representing the entity relationship can be one or more, such as "starring" and "directing".
[0197] An entity extraction unit 430, configured to extract the entity corresponding to the entity relationship in the to-be-parsed speech according to the entity relationship.
[0198] Specifically, after determining the entity relationship in the to-be-parsed speech, the entity corresponding to the entity relationship is extracted from the to-be-parsed speech according to the entity relationship, such as extracting the entity related to "starring" and the entity related to "directing".
[0199] In this embodiment, keywords are first extracted from the to-be-parsed speech, and then entity triples are matched according to the keywords, which can improve the matching efficiency and further improve the efficiency of semantic parsing.
[0200] Preferably, it further includes:
[0201] A graph generation module 600, configured to generate a query knowledge graph corresponding to the to-be-parsed speech according to the entity and the entity relationship between the entities;
[0202] Specifically, after obtaining the entities in the speech to be parsed and the entity relationships between the entities, the entity triples corresponding to the speech to be parsed can be constructed based on the entities and the entity relationships, and then the query knowledge graph corresponding to the speech to be parsed can be constructed based on the constructed entity triples, that is, the corresponding query knowledge graph can be constructed based on the entity relationships between multiple entities. The query knowledge graph includes nodes representing entities and connecting edges between nodes, and the connecting edges between nodes represent the entity relationships between entities.
[0203] The intention recognition module 700 is used to identify the query intention corresponding to the speech to be parsed based on the query knowledge graph.
[0204] Specifically, after constructing the query knowledge graph corresponding to the speech to be analyzed, the constructed query knowledge graph can be used to determine the user's query intention, providing convenience for the user to query information.
[0205] It should be noted that the above embodiments can be freely combined as needed. The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principle of the present invention, and these improvements and modifications should also be considered as the protection scope of the present invention.
Claims
1. A semantic parsing method based on triples, characterized in that: include: Obtain a large amount of corpus; Generate an entity triple library according to the dependency trees of the large number of corpora, wherein the entity triple library includes entity triples representing various entity relationships; Get the user input voice to be parsed; Determine the entity relationship in the speech to be parsed according to the entity triples in the entity triple library, and extract the entity corresponding to the entity relationship; According to the entities and the entity relationships between the entities, semantically analyzing the speech to be analyzed; Determining the entity relationship in the speech to be parsed according to the entity triples in the entity triple library, and extracting the entity corresponding to the entity relationship specifically includes: Performing word segmentation and annotation on the speech to be analyzed, and extracting keywords from the speech to be analyzed; Matching the keywords with entity triples in the entity triple library to determine entity relationships in the speech to be parsed; According to the entity relationship, entities corresponding to the entity relationship are extracted from the speech to be parsed.
2. A semantic parsing method based on triples according to claim 1, characterized in that: The generating of the entity triple library according to the dependency trees of the large amount of corpora specifically includes: Generate a dependency tree from the corpus; Extracting noun entities in the corpus; In the dependency tree, a valid node representing the noun entity is found; Acquire an intermediate node that is simultaneously connected to more than two of the valid nodes; Generate an entity triple according to the intermediate node and two or more valid nodes simultaneously connected to the intermediate node; An entity triple library is generated according to the entity triples.
3. A semantic parsing method based on triples according to claim 2, characterized in that: After generating the entity triple according to the intermediate node and the two or more valid nodes connected to the intermediate node at the same time, the method further includes: Classify entity triples; Merge two or more identical entity triples to generate one entity triple.
4. A triple-based semantic parsing method according to claim 1, characterized in that: Also includes: Generate a query knowledge graph corresponding to the speech to be parsed according to the entities and the entity relationships between the entities; According to the query knowledge graph, the query intent corresponding to the speech to be analyzed is identified.
5. A semantic parsing device based on triples, characterized in that: include: Corpus acquisition module, used to acquire a large amount of corpus; A triple library generation module, used to generate an entity triple library according to the dependency trees of the large number of corpora, wherein the entity triple library includes entity triples representing various entity relationships; A voice acquisition module is used to acquire the voice to be parsed input by the user; An extraction module, used to determine the entity relationship in the speech to be parsed according to the entity triples in the entity triple library, and extract the entity corresponding to the entity relationship; A semantic parsing module, used for performing semantic parsing on the speech to be parsed according to the entities and the entity relationships between the entities; The extraction module comprises: A keyword extraction unit, used to perform word segmentation and annotation on the speech to be analyzed, and extract keywords from the speech to be analyzed; A matching unit, used for matching the keyword with the entity triple in the entity triple library to determine the entity relationship in the speech to be parsed; The entity extraction unit is used to extract entities corresponding to the entity relationship in the speech to be parsed according to the entity relationship.
6. A semantic parsing device based on triples according to claim 5, characterized in that: The triple library generation module includes: A dependency tree generating unit, used for generating a dependency tree from the corpus; A noun entity extraction unit, used to extract noun entities from the corpus; A node search unit, used to search for a valid node representing the noun entity in the dependency tree; The node search unit is further used to obtain an intermediate node that is simultaneously connected to more than two valid nodes; A triplet generation unit, configured to generate an entity triplet according to the intermediate node and two or more valid nodes simultaneously connected to the intermediate node; The triple library generation unit is used to generate an entity triple library according to the entity triples.
7. The triple-based semantic parsing device according to claim 6, characterized in that: The triple library generation module also includes: Classification unit, used to classify entity triples; The merging unit is used to merge two or more identical entity triples to generate one entity triple.
8. The triple-based semantic parsing device according to claim 5, characterized in that: Also includes: A graph generation module, used to generate a query knowledge graph corresponding to the speech to be parsed according to the entities and the entity relationships between the entities; The intent recognition module is used to identify the query intent corresponding to the speech to be parsed based on the query knowledge graph.
Citation Information
Patent Citations
Chinese natural language interrogative sentence semantization knowledge base automatic question-answering method
CN105701253A
Question answering interaction method and system based on intelligent robot
CN108959627A
