A sentence classification method, device, equipment and storage medium
By constructing and analyzing the hierarchical grammatical structure and dependency tree of sentences, the problem that the existing technology cannot classify sentences in grammatical and semantics is solved, and accurate prediction of sentence categories is achieved, which improves the effectiveness of language learning.
Patent Information
- Application Number
- CN202111179076.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-10-09
- Publication Date
- 2025-02-11
- Estimated Expiration
- 2041-10-09
AI Technical Summary
Existing dictionary pens cannot classify sentences at the grammatical and/or semantic levels, limiting the information users get when learning languages.
By obtaining the hierarchical grammatical structure information of the target sentence and the dependency information between words, a component syntax tree and a dependency syntax tree are constructed, and their representation vectors are determined, and a pre-established sentence classification model is used to predict to determine the category of sentences.
It realizes prediction of the category information of sentences at the grammatical and/or semantic level, and provides more detailed language learning resources to help users better understand and master language.
Smart Images

Figure CN113901217B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of natural language processing, and in particular to a sentence classification method, apparatus, device and storage medium. Background Art
[0002] When people learn a language, especially a non-native language, they usually encounter some unfamiliar words. In order to help users learn the language, various dictionary pens are launched on the market. Users can quickly learn the meaning of unfamiliar words by scanning unfamiliar words with dictionary pens. However, existing dictionary pens can only translate the scanned text, and cannot parse the categories of sentences at the grammatical and / or semantic levels. This means that users can only simply understand the meaning of words through dictionary pens, but cannot learn the category information of sentences at the grammatical and / or semantic levels. Therefore, existing dictionary pens are of very limited help to users. Summary of the invention
[0003] In view of this, the present application provides a sentence classification method, apparatus, device and storage medium to determine the category of sentences at the grammatical and / or semantic level, thereby helping users to better learn languages. The technical solution is as follows:
[0004] A sentence classification method, comprising:
[0005] Acquire a component syntax tree capable of presenting hierarchical grammatical structure information of a target sentence and a dependency syntax tree capable of presenting dependency relationship information between words of the target sentence;
[0006] Determining a representation vector of the component syntax tree and a representation vector of the dependency syntax tree;
[0007] The category of the target sentence is predicted according to the representation vectors of the component syntax tree and the representation vectors of the dependency syntax tree.
[0008] Optionally, the step of obtaining a component syntax tree capable of presenting hierarchical grammatical structure information of a target sentence and a dependency syntax tree capable of presenting dependency relationship information between words of the target sentence includes:
[0009] Utilizing a pre-established grammatical parsing model, parsing the hierarchical grammatical structure information and the inter-word dependency relationship information of the target sentence, and generating a joint parse tree capable of simultaneously presenting the hierarchical grammatical structure information and the inter-word dependency relationship information of the target sentence according to the parsing result, wherein the grammatical parsing model is trained using training sentences and the joint parse tree corresponding to the training sentences;
[0010] According to the joint parse tree, the component syntax tree and the dependency syntax tree are obtained.
[0011] Optionally, the determining the representation vector of the component syntax tree and the representation vector of the dependency syntax tree, and the predicting the category of the target sentence according to the representation vector of the component syntax tree and the representation vector of the dependency syntax tree, include:
[0012] Determine the representation vector of the component syntactic tree and the representation vector of the dependency syntactic tree by using a pre-established sentence classification model;
[0013] Using the sentence classification model, based on the representation vectors of the component syntax tree and the representation vectors of the dependency syntax tree, predicting the category of the target sentence;
[0014] The sentence classification model is trained using a component syntax tree that can present the hierarchical grammatical structure information of the training sentences and a dependency syntax tree that can present the dependency relationship information between words of the training sentences as training samples, and is trained using the categories of the training sentences as sample labels.
[0015] Optionally, the component syntax tree includes a plurality of leaf nodes and a plurality of non-leaf nodes, and the next level of each non-leaf node is a leaf node and / or a non-leaf node;
[0016] The highest level node of the component syntax tree is the root node, and the lowest level node is the leaf node;
[0017] Each leaf node of the component syntax tree represents a word in the target sentence, and each non-leaf node represents a phrase in the target sentence;
[0018] The information of each node of the component syntax tree includes the word or phrase represented by the node and the component label of the word or phrase represented by the node.
[0019] Optionally, determining a representation vector of the component syntax tree includes:
[0020] Determine the representation vector of each node in the component syntax tree in order from low level to high level, wherein the representation vector of each leaf node in the component syntax tree is determined according to the information of the leaf node, and the representation vector of each non-leaf node is determined according to the information of the non-leaf node and the representation vector of the node at the next level of the non-leaf node;
[0021] The representation vector of the root node in the component syntax tree is determined as the representation vector of the component syntax tree.
[0022] Optionally, determining a representation vector of a leaf node according to information of the leaf node of the component syntax tree includes:
[0023] According to the information of the leaf node, determine the word vector of the word represented by the leaf node and the part-of-speech representation vector of the word represented by the leaf node;
[0024] Determine the representation vector of the leaf node according to the word vector of the word represented by the leaf node and the part-of-speech representation vector of the word represented by the leaf node;
[0025] Determining a representation vector of a non-leaf node according to information of a non-leaf node of the component syntax tree and a representation vector of a node at a next level of the non-leaf node includes:
[0026] Determine, according to the information of the non-leaf node, a component representation vector of the phrase represented by the non-leaf node and an average word vector of the phrase represented by the non-leaf node;
[0027] The representation vector of the non-leaf node is determined according to the component representation vector of the phrase represented by the non-leaf node, the average word vector of the phrase represented by the non-leaf node, and the representation vector of the next level node of the non-leaf node.
[0028] Optionally, determining the representation vector of the non-leaf node according to the component representation vector of the phrase represented by the non-leaf node, the average word vector of the phrase represented by the non-leaf node, and the representation vector of the node at the next level of the non-leaf node includes:
[0029] Determine the average value of the representation vectors of the next level nodes of the non-leaf node as the average representation vector;
[0030] Concatenate the component representation vector of the phrase represented by the non-leaf node with the average word vector of the phrase represented by the non-leaf node to obtain a concatenated vector;
[0031] A representation vector of the non-leaf node is determined according to the average representation vector and the concatenated vector.
[0032] Optionally, the dependency syntax tree includes a plurality of nodes, each node represents a word in the target sentence, and two nodes representing two words having a dependency relationship are connected by a directed connection line, and the directed connection line points from the node representing the modifier to the node representing the core word;
[0033] The highest level node of the dependency syntax tree is the root node, and the lowest level node is the leaf node;
[0034] The information of each node in the dependency syntax tree includes the word represented by the node and the dependency relationship label between the word represented by the node and the word represented by the previous node.
[0035] Optionally, determining a representation vector of the dependency syntax tree includes:
[0036] Determine the representation vector of each node in the dependency syntax tree in order from low level to high level, wherein the representation vector of each leaf node in the dependency syntax tree is determined according to the information of the leaf node, and the representation vector of each non-leaf node is determined according to the information of the non-leaf node and the representation vector of the node at the next level of the non-leaf node;
[0037] The representation vector of the root node in the dependency syntax tree is determined as the representation vector of the dependency syntax tree.
[0038] Optionally, determining a representation vector of a leaf node according to information of the dependency syntax tree includes:
[0039] According to the information of the leaf node, determine the word vector of the word represented by the leaf node and the dependency representation vector corresponding to the word represented by the leaf node;
[0040] Determine the representation vector of the leaf node according to the word vector of the word represented by the leaf node and the dependency representation vector corresponding to the word represented by the leaf node;
[0041] Determining a representation vector of a non-leaf node according to information of the dependency syntax tree includes:
[0042] According to the information of the non-leaf node, determine the word vector of the word represented by the non-leaf node and the dependency representation vector corresponding to the word represented by the non-leaf node;
[0043] The representation vector of the non-leaf node is determined according to the word vector of the word represented by the non-leaf node, the dependency representation vector corresponding to the word represented by the non-leaf node, and the representation vector of the next-level node of the non-leaf node.
[0044] Optionally, determining the representation vector of the non-leaf node according to the word vector of the word represented by the non-leaf node, the dependency representation vector corresponding to the word represented by the non-leaf node, and the representation vector of the next level node of the non-leaf node includes:
[0045] Sum the representation vectors of the next level nodes of the non-leaf node to obtain a summed vector;
[0046] Concatenate the word vector of the word represented by the non-leaf node with the dependency representation vector corresponding to the word represented by the non-leaf node to obtain a concatenated vector;
[0047] Determine a representation vector of the non-leaf node according to the summed vector and the concatenated vector.
[0048] Optionally, predicting the category of the target sentence based on the representation vector of the component syntax tree and the representation vector of the dependency syntax tree includes:
[0049] concatenating the representation vector of the component syntax tree with the representation vector of the dependency syntax tree to obtain a concatenated vector;
[0050] According to the concatenated vector, the category of the target sentence is predicted from one dimension or multiple dimensions.
[0051] Optionally, predicting the category of the target sentence from one dimension or multiple dimensions according to the concatenated vector includes:
[0052] According to the concatenated vector, the category of the target sentence is predicted from one or more of the following dimensions: sentence pattern, tense, semantics, and grammar.
[0053] A sentence classification device, comprising: a syntax tree acquisition module, a syntax tree representation module and a sentence classification module;
[0054] The syntax tree acquisition module is used to acquire a component syntax tree that can present the hierarchical grammatical structure information of the target sentence and a dependency syntax tree that can present the dependency relationship information between words of the target sentence;
[0055] The syntax tree representation module is used to determine the representation vector of the component syntax tree and the representation vector of the dependency syntax tree;
[0056] The sentence classification module is used to predict the category of the target sentence according to the representation vector of the component syntax tree and the representation vector of the dependency syntax tree.
[0057] A sentence classification device, comprising: a memory and a processor;
[0058] The memory is used to store programs;
[0059] The processor is used to execute the program to implement each step of any one of the sentence classification methods described above.
[0060] A readable storage medium stores a computer program, and when the computer program is executed by a processor, each step of any one of the sentence classification methods described above is implemented.
[0061] It can be seen from the above scheme that the sentence classification method, device, equipment and storage medium provided by the present application first obtain a component syntax tree that can present the hierarchical grammatical structure information of the target sentence and a dependency syntax tree that can present the dependency relationship information between words of the target sentence, and then determine the representation vector of the component syntax tree and the representation vector of the dependency syntax tree. Finally, based on the representation vector of the component syntax tree and the representation vector of the dependency syntax tree, the category of the target sentence is predicted. The sentence classification method provided by the present application can predict the category information of the sentence at the grammatical and / or semantic level, and the obtained category information can help users better learn the language. BRIEF DESCRIPTION OF THE DRAWINGS
[0062] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.
[0063] Figure 1 A flow chart of a sentence classification method provided in an embodiment of the present application;
[0064] Figure 2 A schematic diagram of a process for parsing hierarchical grammatical structure information and inter-word dependency information of a target sentence using a pre-established grammatical parsing model provided in an embodiment of the present application;
[0065] Figure 3 A schematic diagram of an example of a joint parsing tree provided in an embodiment of the present application;
[0066] Figure 4 A schematic diagram of an example of a component syntax tree provided in an embodiment of the present application;
[0067] Figure 5 A schematic diagram of an example of a dependency syntax tree provided in an embodiment of the present application;
[0068] Figure 6 A schematic diagram of the structure of a sentence classification device provided in an embodiment of the present application;
[0069] Figure 7 A schematic diagram of the structure of a sentence classification device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0070] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0071] In order to obtain the category information of sentences at the grammatical and / or semantic level, the applicant conducted research, and through continuous research, finally proposed a sentence classification method with better effect, which can be applied to electronic devices with data processing capabilities. The electronic device can be a server on the network side (it can be a single server, or it can be multiple servers or server clusters). The server can receive sentences sent from terminals connected to it through the network, and determine the category information of sentences at the grammatical and / or semantic level according to the sentence classification method provided by this application, and can send the determined category information to the terminal for display. The electronic device can also be a terminal used on the user side, such as a smart phone, a dictionary pen, etc. The terminal can determine the category information of sentences at the grammatical and / or semantic level according to the sentence classification method provided by this application, and can display the determined category information. Next, the sentence classification method provided by this application is introduced through the following embodiments.
[0072] First embodiment
[0073] See also Figure 1 , shows a schematic flow chart of a sentence classification method provided in an embodiment of the present application, which may include:
[0074] Step S101: Acquire a component syntax tree that can present hierarchical grammatical structure information of a target sentence and a dependency syntax tree that can present dependency relationship information between words of the target sentence.
[0075] Optionally, the process of obtaining a component syntax tree capable of presenting the hierarchical grammatical structure information of the target sentence and a dependency syntax tree capable of presenting the inter-word dependency information of the target sentence may include: using a pre-established syntax parsing model to parse the hierarchical grammatical structure information and inter-word dependency information of the target sentence, and generating a joint parsing tree capable of simultaneously presenting the hierarchical grammatical structure information and inter-word dependency information of the target sentence based on the parsing result; and obtaining a component syntax tree capable of presenting the hierarchical grammatical structure information of the target sentence and a dependency syntax tree capable of presenting the inter-word dependency information of the target sentence based on the joint parsing tree. The syntax parsing model is trained using training sentences and the joint parsing tree corresponding to the training sentences.
[0076] This embodiment is not limited to the above-mentioned method for obtaining the component syntax tree and the dependency syntax tree, and other methods may be used. For example, the target sentence may be parsed using an existing natural language processing package to obtain the component syntax tree and the dependency syntax tree.
[0077] Step S102: Determine the representation vectors of the component syntax tree and the representation vectors of the dependency syntax tree.
[0078] Among them, the representation vector of the component syntax tree is a vector that can represent the hierarchical grammatical structure information of the target sentence, and the representation vector of the dependency syntax tree is a vector that can represent the dependency relationship information between words of the target sentence.
[0079] Step S103: predicting the category of the target sentence according to the representation vectors of the component syntax trees and the representation vectors of the dependency syntax trees.
[0080] Specifically, the representation vector of the component syntax tree can be concatenated with the representation vector of the dependency syntax tree, and the category of the target sentence at the grammatical and / or semantic level can be predicted based on the concatenated vector. When predicting the category of the target sentence based on the concatenated vector, the category of the target sentence can be predicted from one dimension or multiple dimensions.
[0081] In one possible implementation, the above steps S102 to S103 can be implemented using a pre-established sentence classification model, that is, using the pre-established sentence classification model to determine the representation vectors of the component syntactic trees and the representation vectors of the dependency syntactic trees, and using the sentence classification model to predict the category of the target sentence based on the representation vectors of the component syntactic trees and the representation vectors of the dependency syntactic trees.
[0082] Optionally, the sentence classification model may include a tree structure expression module and a classification module, wherein the tree structure expression module is used to determine the representation vectors of the component syntactic tree and the representation vectors of the dependency syntactic tree, and the classification module is used to predict the category of the sentence based on the representation vectors of the component syntactic tree and the representation vectors of the dependency syntactic tree. Optionally, the classification module may include multiple classification sub-modules, each classification sub-module predicting the category of the target sentence from one dimension.
[0083] The sentence classification model in this embodiment uses a component syntax tree that can present the hierarchical grammatical structure information of the training sentences and a dependency syntax tree that can present the dependency relationship information between words of the training sentences as training samples, and is trained using the actual categories of the training sentences as sample labels.
[0084] The training process of the sentence classification model includes: obtaining training samples from the training sample set; using the sentence classification model to determine the representation vectors of the component syntactic tree in the training sample and the representation vectors of the dependency syntactic tree in the training sample; using the sentence classification model, based on the representation vectors of the component syntactic tree in the training sample and the representation vectors of the dependency syntactic tree in the training sample, predicting the probability that the sentence category of the training sample is the set sentence category; according to the probability that the sentence category of the training sample is the set sentence category and the actual category of the target sentence, determining the prediction loss (such as cross entropy loss) of the sentence classification model, and updating the parameters of the sentence classification model according to the prediction loss of the sentence classification model. The sentence classification model is iteratively trained multiple times according to the above process until the training end condition is met, and the model obtained after the training is completed is the established sentence classification model.
[0085] The sentence classification method provided in the embodiment of the present application first obtains a component syntax tree that can present the hierarchical grammatical structure information of the target sentence and a dependency syntax tree that can present the dependency relationship information between words of the target sentence, then determines the representation vector of the component syntax tree and the representation vector of the dependency syntax tree, and finally predicts the category of the target sentence based on the representation vector of the component syntax tree and the representation vector of the dependency syntax tree. The sentence classification method provided in the embodiment of the present application can predict the category information of the sentence at the grammatical and / or semantic level, and the obtained category information can help users learn the language better.
[0086] Second embodiment
[0087] The above embodiment mentioned that a pre-established grammatical parsing model can be used to parse the hierarchical grammatical structure information and inter-word dependency information of the target sentence, and a joint parsing tree that can simultaneously present the hierarchical grammatical structure information and inter-word dependency information of the target sentence is generated based on the parsing results, and then a component syntactic tree that can present the hierarchical grammatical structure information of the target sentence and a dependency syntactic tree that can present the inter-word dependency information of the target sentence are obtained based on the joint parsing tree. Since the key to the above process is "using a pre-established grammatical parsing model to parse the hierarchical grammatical structure information and inter-word dependency information of the target sentence", this embodiment focuses on introducing this process.
[0088] See also Figure 2 , showing a schematic diagram of a process of "parsing hierarchical grammatical structure information and inter-word dependency information of a target sentence using a pre-established grammatical parsing model", which may include:
[0089] Step S201: taking the target sentence as the text to be parsed.
[0090] Step S202: using the grammatical parsing model, predicting the component labels of the text to be parsed, and predicting the segmentation method of the text to be parsed.
[0091] Among them, the component label of the text to be parsed is one of the set multiple component labels, and the component label of the text to be parsed is used to indicate what type of phrase the text to be parsed is. For example, if the component label of the text to be parsed is VP, it means that the text to be parsed is a verb phrase, and if the component label of the text to be parsed is NP, it means that the text to be parsed is a noun phrase.
[0092] Specifically, the implementation process of step S202 may include:
[0093] Step S2021: using the grammatical parsing model, predicting the probability that the component labels of the text to be parsed are the set component labels, and determining the component labels of the text to be parsed according to the probability that the component labels of the text to be parsed are the set component labels.
[0094] The process of predicting the probability that the component labels of the text to be parsed are the set component labels may include:
[0095] Step S2021-1, determine the representation vector of the text to be parsed according to the forward vector of the first word, the forward vector of the backward adjacent word of the second word, the backward vector of the second word and the backward vector of the forward adjacent word of the first word.
[0096] Among them, the first word is the first word of the text to be parsed, the second word is the last word of the text to be parsed, the forward adjacent word of the first word is the word that is located before and adjacent to the first word in the target sentence, and the backward adjacent word of the second word is the word that is located after and adjacent to the second word in the target sentence. It should be noted that the forward vector of a word can represent the semantics of the word when the target sentence is reviewed from front to back, and the backward vector of a word can represent the semantics of the word when the target sentence is reviewed from back to front.
[0097] Specifically, the specific implementation process of step S2021-1 includes: subtracting the forward vector of the first word from the forward vector of the backward adjacent word of the second word to obtain a forward vector difference, and subtracting the backward vector of the second word from the backward vector of the forward adjacent word of the first word to obtain a backward vector difference, splicing the forward vector difference and the backward vector difference, and using the spliced vector as the representation vector of the text to be parsed.
[0098] If the first word is replaced by x i (the first word in the text to be parsed, the i-th word in the target sentence), and the second word is represented by x j (the last word in the text to be parsed, the jth word in the target sentence) means that the first word xi The forward vector of It means that the second word x j The backward vector of It means that the first word x i The forward neighboring word x i-1 The backward vector of It means that the second word x j The backward adjacent word x j+1 The forward vector of Represents, then the representation vector S of the text to be parsed ij It can be expressed as:
[0099]
[0100] It should be noted that the forward vector and backward vector of each word in the target sentence can be obtained as follows:
[0101] Step a1: For each word x in the target sentence i :Use the grammar parsing model to obtain the word x i The word vector, part-of-speech representation vector and position representation vector of the word x i The part-of-speech representation vector of the word is summed with the position representation vector of the word, and the summed vector is added to the word x i The word vectors of the word are concatenated and the concatenated vector is used as the word x i to obtain the representation vector of each word in the text to be parsed.
[0102] The word vector of each word in the target sentence can be determined by a pre-trained language model. When determining the word vector of each word in the target sentence, the target sentence is first pre-processed, wherein the pre-processing includes but is not limited to adding spaces before punctuation marks, replacing the negative form of 't with not, unifying upper and lower case, etc., and then the pre-processed sentence is segmented. Finally, each word obtained by the word segmentation is input into the pre-trained language model, and the pre-trained language model outputs the word vector of each word in the target sentence. After obtaining the word vector of each word in the target sentence, the word vector of each word in the target sentence can be input into the pre-trained part-of-speech tag model, and the part-of-speech tag model outputs the part-of-speech tag of each word in the target sentence. Optionally, the part-of-speech tag model can include a bidirectional LSTM (or a neural network structure of any time sequence) and a fully connected layer. The word vector of each word in the target sentence is sequentially passed through the bidirectional LSTM (or a neural network structure of any time sequence) and the fully connected layer to obtain the part-of-speech tag of each word in the target sentence.
[0103] Step a2: For each word x in the target sentence i :Use the grammar parsing model to analyze word x iThe representation vector of the target sentence and the representation vectors of other words are used for attention calculation to obtain the word x i The context vector of word x i The context vector of word x is obtained i The forward and backward vectors of .
[0104] In one possible implementation, the word x can be centered based on a single-head self-attention mechanism. i The representation vector of the target sentence and the representation vectors of other words in the target sentence are used for attention calculation. In this way, a context vector can be obtained, and the context vector is split into a forward vector and a backward vector. The forward vector obtained by the splitting is used as the word x i The forward vector of , and the backward vector obtained by segmentation is used as the word x i In another possible implementation, the word x can be centered based on a multi-head self-attention mechanism. i The representation vector of the target sentence and the representation vectors of other words in the target sentence are used for attention calculation. In this way, multiple context vectors can be obtained. Each context vector is divided into a forward vector and a backward vector. All the forward vectors are concatenated and the concatenated vector is used as the word x. i Similarly, all the backward vectors are concatenated and the concatenated vector is used as the word x i The backward vector of .
[0105] Step S2021 - 2: predict the probability of the component labels of the text to be parsed being the set component labels based on the representation vector of the text to be parsed.
[0106] Specifically, the probability s that the component label of the text to be parsed is the set component label can be determined using the following formula: labels (i, j):
[0107] s labels (i, j) = V l g(W l s ij +b l ) (2)
[0108] Among them, g represents nonlinear transformation, W l and b l are the parameters of the grammar parsing model, which are obtained through training.
[0109] After predicting the probability that the component label of the text to be parsed is the set component label, the component label corresponding to the maximum probability among the predicted probabilities is determined as the component label of the text to be parsed.
[0110] Step S2022: using the grammatical parsing model, predicting the scores of the candidate segmentation methods of the text to be parsed, and determining the segmentation method of the text to be parsed according to the scores of the candidate segmentation methods of the text to be parsed.
[0111] The candidate segmentation methods of the text to be parsed are all possible segmentation methods of the text to be parsed. The process of predicting the scores of the candidate segmentation methods of the text to be parsed includes:
[0112] For each candidate segmentation method of the text to be parsed, execute:
[0113] Step S2022-1: predict the probability that each text segment obtained by segmenting the to-be-parsed text according to the candidate segmentation method is a phrase component, so as to obtain the probabilities corresponding to each text segment obtained by segmenting according to the candidate segmentation method.
[0114] Specifically, for each text segment obtained by segmenting the text to be parsed according to the candidate segmentation method: determine the representation vector of the text segment based on the forward vector of the first word of the text segment, the forward vector of the backward adjacent word of the last word of the text segment, the backward vector of the last word of the text segment, and the backward vector of the forward adjacent word of the first word of the text segment, and determine the probability that the text segment is a phrase component based on the representation vector of the text segment. It should be noted that the method of determining the representation vector of a text segment here is similar to the implementation method of determining the representation vector of the text to be parsed mentioned above. For a more specific implementation method of determining the representation vector of a text segment, please refer to the specific implementation method of determining the representation vector of the text to be parsed, which will not be repeated in this embodiment.
[0115] The probability of a text segment being a phrase component can be determined by the following formula:
[0116] s span (m, n) = V s g(W s s mn +b s ) (3)
[0117] Among them, s mn Represents the representation vector of the text segment consisting of the mth to nth words in the text to be parsed, s span (m, n) represents the probability that the text segment consisting of the mth to nth words in the text to be parsed is a phrase component, W s and b s are the parameters of the grammar parsing model, which are obtained through training.
[0118] Step S2022-2: sum the probabilities corresponding to the text segments obtained by segmenting the candidate segmentation method, and use the summed probability as the score of the candidate segmentation method.
[0119] The scores of the candidate segmentation methods for the text to be parsed can be obtained through the above process. After the scores of the candidate segmentation methods for the text to be parsed are obtained, the candidate segmentation method with the highest score can be determined as the segmentation method for the text to be parsed.
[0120] Step S203: using the grammatical parsing model, predicting dependency relationship labels between text segments obtained after segmenting the text to be parsed according to the segmentation method of the text to be parsed.
[0121] Among them, the dependency relationship between text segments refers to the dependency relationship between a word in one text segment and a word in another text segment, that is, the dependency relationship actually refers to the dependency relationship between two words. It should be noted that of the two words with a dependency relationship, one is the core word (head) and the other is the dependent word (dependent). There are many types of dependency relationships: nominal clause modification, related clause modification, adverbial clause modification, clause complement, clause subject (including passive), open complement, etc.; adverbial modification, emphasis, place adverbial modification, adjective modification, preposition modification, noun modification (possessive, time, etc.), time modification, place modification, etc.; compound words (verbs, nouns, etc.), foreign words, quantifiers, possessive, pronoun reference relationship, etc.; noun subject (including passive), object (time and space, etc.), auxiliary verb, passive voice auxiliary verb, etc.; root, coordinating conjunction, parallel, conjunction preposition, determiner, punctuation and other marks. The dependency relationship label between two words is used to indicate the specific dependency relationship between the two words.
[0122] Specifically, the implementation process of step S203 includes:
[0123] Step S2031: using the grammatical parsing model, predicting the scores of the candidate arc drawing methods of the text segment obtained after segmenting the text to be parsed according to the segmentation method of the text to be parsed, and determining the target arc drawing method according to the scores of the candidate arc drawing methods.
[0124] Each arc drawn according to each candidate arc drawing method is a directed arc pointing from a word in one text segment to a word in another text segment. It should be noted that the arc drawing in this embodiment refers to drawing a directed arc for two words that may have a dependency relationship, and the directed arc points from the core word to the dependent word. It should also be noted that the arcs under the same candidate arc drawing method should not cross.
[0125] Among them, the process of predicting the score of a candidate arc drawing method of a text segment obtained after segmenting the text to be parsed according to the segmentation method of the text to be parsed includes: for each arc drawn according to the candidate arc drawing method, obtaining the characterization vector of the arc, determining the score of the arc according to the characterization vector of the arc, so as to obtain the score of each arc drawn according to the candidate arc drawing method; summing the scores of the arcs drawn according to the candidate arc drawing method, and using the summed score as the score of the candidate arc drawing method. The scores of each candidate arc drawing method can be obtained in the above manner, and after obtaining the scores of each candidate arc drawing method, the candidate arc drawing method with the highest score can be determined as the target arc drawing method.
[0126] Among them, the process of determining the representation vector of an arc may include: obtaining one or more of the following features of the two words connected by the arc: word-level features, distance features, sentence-level features (preferably, these three features are obtained at the same time); determining the representation vector of the arc based on the obtained features, specifically, the obtained features can be input into a fully connected layer, and the output of the fully connected layer is used as the representation vector of the arc.
[0127] In this embodiment, the target vector (the concatenated vector of the forward vector and the backward vector) of each word in the target sentence can be input into BiLSTM to obtain the word-level features of each word in the target sentence. For two words connected by an arc, the word-level features of the two words connected by the arc can be obtained from the word-level features of each word in the target sentence. The distance feature of two words connected by an arc can characterize the distance between the two words. Optionally, if there is no other word between the two words connected by an arc, the distance between the two words connected by the arc is considered to be "1", and "1" is represented as a vector as the distance feature of the two words connected by the arc. If there is a word between the two words connected by the arc, the distance between the two words connected by the arc is determined to be "2", and "2" is represented as a vector as the distance feature of the two words connected by the arc, and so on. The sentence-level features of two words connected by an arc can be obtained in the following way: using the two words connected by the arc as the dividing line, divide the target sentence into three parts, obtain the representation vector of the first part and the representation vector of the last part obtained by the division according to the target vector of each word in the target sentence (the concatenation vector of the forward vector and the backward vector), and subtract the representation vector of the last part from the representation vector of the first part to obtain the vector as the sentence-level feature of the two words connected by the arc. Optionally, the target vector of each word in the target sentence can be first input into BiLSTM, and then the output of BiLSTM can be input into LSTM to obtain the representation vector of the first part and the representation vector of the last part.
[0128] Step S2032: For each arc in the target arc drawing mode, the grammatical parsing model is used to predict the probability that the dependency tags of the two words connected by the arc are the set dependency tags, and the dependency tags of the two words connected by the arc are determined according to the probability that the dependency tags of the two words connected by the arc are the set dependency tags.
[0129] The process of predicting the probability that the dependency labels of the two words connected by the arc are the set dependency labels may include: predicting the probability that the dependency labels of the two words connected by the arc are the set dependency labels based on the representation vector of the arc. Specifically, the representation vector of the arc may be passed through a nonlinear layer and a fully connected layer to obtain the probability that the dependency labels of the two words connected by the arc are the set dependency labels.
[0130] After predicting the probability that the dependency labels of the two words connected by the arc are the set dependency labels, the dependency label corresponding to the maximum probability is determined as the dependency label of the two words connected by the arc.
[0131] Step S204: for each text segment obtained by segmenting the text to be parsed according to the segmentation method of the text to be parsed, if the text segment includes multiple words, the text segment is used as the text to be parsed, and step S202 and subsequent steps are executed.
[0132] It should be noted that for each text segment obtained by segmentation, if the text segment includes a word, the processing of the text segment can be terminated. For a text segment containing only one word, the part-of-speech tag of the word can be used as the component tag of the text segment.
[0133] The above analysis process is explained below with reference to a specific example.
[0134] Assume that the text to be parsed is "Federal Paper Board sells paper and wood products.":
[0135] Take the text to be parsed "Federal Paper Board sells paper and wood products." as the text to be parsed and execute:
[0136] First, predict the component labels of "Federal Paper Board sells paper and wood products."; then, determine the segmentation method of "Federal Paper Board sells paper and wood products.", assuming the segmentation method is "Federal Paper Board / sells paper and wood products / .", then after segmentation according to this segmentation method, three text segments "Federal Paper Board", "sells paper and woodproducts" and "." can be obtained; finally, predict the dependency syntactic relationship labels between the three text segments obtained by segmentation. It is predicted that "sells" in "sells paper and wood products" has a dependency relationship with "Board" in "Federal Paper Board", and the dependency relationship label is "nsubj", "nsubj" represents the noun subject, among which "sells" is the core word and "Board" is the dependent word. In addition, it is predicted that "sells" also has a dependency relationship with ".", and the dependency relationship label is "punct", "punct" represents punctuation.
[0137] Since both "Federal Paper Board" and "sells paper and wood products" obtained by segmenting "Federal Paper Board sells paper and wood products." include multiple words, the text segment "Federal Paper Board" is further parsed as the text to be parsed, and the text segment "sells paper and wood products" is also further parsed as the text to be parsed. Take the parsing of the text segment "sells paper and wood products" as an example:
[0138] First, predict the component label of "sells paper and wood products". It is predicted that the component label of "sellspaper and wood products" is "VP"; then, predict the segmentation method of "sells paper and woodproducts". It is predicted that the segmentation method of "sells paper and wood products" is to segment after "sells", that is, "sells / paper and wood products". According to this segmentation method, two text segments "sells" and "paper and wood products" can be obtained; finally, predict the dependency relationship label of the words in "sells" and "paper and woodproducts". It is predicted that "sells" has a dependency relationship with the word "products" in "paper and wood products", and the dependency relationship label of "sells" and "products" is "obj", and "obj" means the object.
[0139] Since the text segment "paper and wood products" contains multiple words, it is necessary to further parse "paper and wood products" as the text to be parsed according to the above parsing method...
[0140] By parsing "Federal Paper Board sells paper and wood products." according to the above process, we can finally obtain the hierarchical grammatical structure information and the dependency relationship information between words of this sentence.
[0141] After predicting the parsing results, a joint parsing tree may be generated according to the parsing results. Optionally, since the parsing is performed layer by layer (or from coarse granularity to fine granularity), the joint parsing tree may be gradually generated according to the continuous generation of parsing results.
[0142] In this embodiment, the joint parse tree that can simultaneously present the hierarchical grammatical structure information and the inter-word dependency information of the target sentence includes a number of leaf nodes and a number of non-leaf nodes, each leaf node represents a word in the target sentence, each non-leaf node represents a phrase in the target sentence, the next level of each non-leaf node is a leaf node and / or a non-leaf node, the information of each node includes the word or phrase represented by the node and the component label of the word or phrase represented by the node, nodes of different levels with a hierarchical relationship are connected by a first connecting line, and nodes of the same level with a dependency relationship are connected by a second connecting line (such as a directed arc), and each second connecting line has a dependency label. The joint parse tree vertically presents the hierarchical grammatical structure information of the target sentence, and the joint parse tree horizontally presents the inter-word dependency information of the target sentence.
[0143] See also Figure 3, shows a schematic diagram of a joint parse tree obtained by parsing "Federal Paper Board sells paperand wood products." using a grammatical parsing model (dependency labels are not shown). The node marked (1,9) in the figure represents the phrase "Federal Paper Board sells paper and wood products.", and the "S" at the node is the component label of "Federal Paper Board sells paper and wood products.". The node marked (1,3) in the figure and the node marked (4,8) in the figure represent the phrases "Federal Paper Board" and "sells paper and wood products" obtained after segmentation according to the segmentation method "Federal Paper Board / sells paper and wood products.", respectively. The "NP" at the node marked (1,3) is the component label of the phrase "Federal Paper Board", and the "VP" at the node marked (4,8) is the component label of the phrase "Federal Paper Board". The directed arcs between nodes at the same level in the figure represent dependency relationships. For example, there is a directed arc between the node marked (1,3) and the node marked (4,8), indicating that "sells paper and wood products" There is a dependency relationship between "sells" in "products" and "Board" in "Federal Paper Board". The directed arc points from "sells" to "Board", indicating that "sells" is the core word and "Board" is the dependent word. The connecting lines between nodes at different levels represent the hierarchical relationship. For example, the node labeled (5,8) is the subordinate node of the node labeled (4,8), and the phrase represented by the node labeled (5,8) is the phrase obtained by segmenting the phrase represented by the node labeled (4,8).
[0144] It can be seen from the above embodiments that the grammatical parsing of the target sentence is implemented using a pre-established grammatical parsing model, and the grammatical parsing model is trained using training sentences and a joint parse tree corresponding to the training sentences. Next, the training process of the grammatical parsing model is introduced.
[0145] The training process of the grammar parsing model may include:
[0146] Step b1: Obtain training text from the training text set and use the training text as the text to be parsed.
[0147] Step b2: Use the grammatical parsing model to predict the probability that the component labels of the text to be parsed are the set component labels and the scores of each candidate segmentation method of the text to be parsed as the first prediction result.
[0148] Step b3: For each candidate segmentation method of the text to be parsed, predict the scores of each candidate arc drawing method of the text segment obtained by segmenting the text to be parsed according to the candidate segmentation method, and the probability that the dependency labels of the two words connected by each arc under each candidate arc drawing method are the set dependency labels, so as to obtain the prediction results under each candidate segmentation method as the second prediction results.
[0149] It should be noted that the implementation process of step b2 is similar to the above-mentioned implementation process of using the grammatical parsing model to predict the probability of the component labels of the text to be parsed being the set component labels and using the grammatical parsing model to predict the scores of the candidate segmentation methods of the text to be parsed. The implementation process of predicting the scores of the candidate arc drawing methods of the text segment obtained by segmenting the text to be parsed according to a candidate segmentation method in step b3 is similar to the implementation process of predicting the scores of the candidate arc drawing methods of the text segment obtained by segmenting the text to be parsed according to the segmentation method of the text to be parsed in the above-mentioned embodiment. The implementation process of predicting the probability of the dependency labels of the two words connected by each arc under the candidate arc drawing method being the set dependency labels in step b3 is similar to the implementation process of predicting the probability of the dependency labels of the two words connected by each arc under the target arc drawing method being the set dependency labels. Please refer to each other for details, and this embodiment will not be repeated here.
[0150] Step b4: Update the parameters of the grammatical parsing model according to the first prediction result, the second prediction result and the relevant part of the joint parsing tree corresponding to the training text.
[0151] Specifically, a first prediction loss (such as cross entropy loss) of the grammatical parsing model is determined based on relevant parts of the hierarchical grammatical structure information presented by the joint parse tree corresponding to the first prediction result and the training text, and a second prediction loss (such as cross entropy loss) of the grammatical parsing model is determined based on relevant parts of the inter-word dependency information presented by the joint parse tree corresponding to the second prediction result and the training text. The first prediction loss is fused with the second prediction loss (such as directly summing the first prediction loss and the second prediction loss, or weightedly summing the first prediction loss and the second prediction loss), and parameters of the grammatical parsing model are updated according to the fused loss.
[0152] Step b5: For each text segment obtained by segmenting according to each candidate segmentation method, if the text segment includes one word, the processing of the text segment is terminated; if the text segment includes multiple words, the text segment is treated as the text to be parsed and the process proceeds to step b2; if the text segment includes one word, the processing of the text segment is terminated.
[0153] The grammar parsing model is trained iteratively for multiple times according to the above process until the training end condition is met. The model obtained after the training is completed is the established grammar parsing model.
[0154] Third embodiment
[0155] After obtaining the joint parse tree, a component syntactic tree can be obtained based on the joint parse tree. The component syntactic tree includes several leaf nodes and several non-leaf nodes. The next level of each non-leaf node is a leaf node and / or a non-leaf node. The highest-level node of the component syntactic tree is the root node, and the lowest-level node is a leaf node. Each leaf node of the component syntactic tree represents a word in the target sentence, and each non-leaf node represents a phrase in the target sentence. The information of each node of the component syntactic tree includes the word or phrase represented by the node and the component label of the word or phrase represented by the node.
[0156] See also Figure 4 , showing a schematic diagram of the constituent syntax tree of the target sentence "Federal Paper Board sells paper and wood products." Figure 4 Nodes 411-413, 421, 4221-4224, and 43 in the data are leaf nodes. Each node represents a word in "Federal Paper Board sells paper and wood products." The information of each leaf node includes the word represented by the leaf node and the part-of-speech tag of the word represented by the leaf node. Figure 4 The other nodes in are non-leaf nodes, among which node 4 is the root node, nodes 41-43 are subordinate nodes of node 4, nodes 411-413 are subordinate nodes of node 41, nodes 421 and 422 are subordinate nodes of node 42, nodes 4221-4224 are subordinate nodes of node 422, nodes 41-43 represent three text segments obtained by segmenting the phrase "Federal Paper Board sells paper and wood products." represented by node 4, nodes 421 and 422 represent three text segments obtained by segmenting the phrase "sells paper and wood products" represented by node 42, and the others are similar.
[0157] After obtaining the component syntactic tree, it is necessary to use the sentence classification model to determine the representation vector of the component syntactic tree. The following is an introduction to the process of using the sentence classification model to determine the representation vector of the component syntactic tree. The process of using the sentence classification model to determine the representation vector of the component syntactic tree includes:
[0158] Step c1: Determine the representation vector of each node in the component syntax tree in order from low level to high level.
[0159] Among them, the representation vector of each leaf node in the component syntax tree is determined according to the information of the leaf node, and the representation vector of each non-leaf node is determined according to the information of the non-leaf node and the representation vector of the next level node of the non-leaf node.
[0160] The process of determining the representation vector of a leaf node according to the information of the leaf node of the component syntax tree may include:
[0161] Step d1: According to the information of the leaf node, obtain the word vector of the word represented by the leaf node and the part-of-speech representation vector of the word represented by the leaf node.
[0162] Step d2: Determine the representation vector of the leaf node based on the word vector of the word represented by the leaf node and the part-of-speech representation vector of the word represented by the leaf node.
[0163] Specifically, the word vector of the word represented by the leaf node can be concatenated with the part-of-speech representation vector of the word represented by the leaf node, the concatenated vector can be input into LSTM, and the vector output by LSTM can be used as the representation vector of the leaf node.
[0164] The process of determining the representation vector of a non-leaf node according to information of a non-leaf node of the component syntax tree and the representation vector of the next-level node of the non-leaf node may include:
[0165] Step e1: According to the information of the non-leaf node, determine the component representation vector of the phrase represented by the non-leaf node and the average word vector of the phrase represented by the non-leaf node.
[0166] Among them, the component representation vector of the phrase represented by the non-leaf node is determined according to the component label of the phrase represented by the non-leaf node, and the average word vector of the phrase represented by the non-leaf node is the average value of the word vectors of each word contained in the phrase represented by the non-leaf node.
[0167] Step e2, determine the representation vector of the non-leaf node based on the component representation vector of the phrase represented by the non-leaf node, the average word vector of the phrase represented by the non-leaf node, and the representation vector of the next level node of the non-leaf node.
[0168] Specifically, the component representation vector of the phrase represented by the non-leaf node is concatenated with the average word vector of the phrase represented by the non-leaf node to obtain a concatenated vector, and the average value of the representation vectors of the nodes at the next level of the non-leaf node is determined as the average representation vector, and then the representation vector of the non-leaf node is determined based on the average representation vector and the concatenated vector. Optionally, after obtaining the average representation vector and the concatenated vector, the average representation vector and the concatenated vector can be input into LSTM, and the vector output by LSTM is used as the representation vector of the non-leaf node.
[0169] Step c2: determine the representation vector of the root node in the component syntax tree as the representation vector of the component syntax tree.
[0170] Below Figure 4 Taking the component syntax tree shown as an example, the process of determining the representation vector of the component syntax tree is explained:
[0171] Determine the characterization vector of each leaf node among leaf nodes 411-413, leaf node 421, leaf nodes 4221-4224 and leaf node 43:
[0172] Take node 4221 as an example: determine the word vector of the word "paper" represented by node 4221 and the part-of-speech representation vector of "paper" (the part-of-speech representation vector of "paper" is determined based on the part-of-speech tag NN of "paper"), and determine the representation vector h4 of node 4221 based on the word vector of the word "paper" represented by node 4221 and the part-of-speech representation vector. In the same way, the representation vectors h5 of node 4222, h6 of node 4223, h7 of node 4224, h0 of node 411, h1 of node 412, h2 of node 413, h3 of node 421, and h8 of node 43 can be determined.
[0173] Determine the characterization vectors of non-leaf nodes 41, 422, 42, 4:
[0174] For non-leaf node 41: determine the average word vector of the phrase "Federal Paper Board" represented by node 41 (the average of the word vectors of each word in "Federal Paper Board") and the component representation vector of "Federal Paper Board" (the component representation vector of "Federal Paper Board" is determined according to the component label NP of "Federal Paper Board"), concatenate the average word vector of "Federal Paper Board" with the component representation vector of "Federal Paper Board" to obtain the concatenated vector, determine the average of the representation vectors h0, h1 and h2 of the subordinate nodes 411 to 413 of node 41 as the average representation vector, and determine the representation vector of node 41 according to the concatenated vector and the average representation vector.
[0175] For non-leaf node 422: determine the average word vector of the phrase "paper and wood products" represented by node 422 (the average of the word vectors of each word in "paper and wood products") and the component representation vector of "paper and wood products" (the component representation vector of "paper and wood products" is determined according to the component label NP of "paper and wood products"), concatenate the average word vector of "paper and wood products" with the component representation vector of "paper and wood products" to obtain the concatenated vector, determine the average of the representation vectors h4, h5, h6, and h7 of the subordinate nodes 411 to 413 of node 422 as the average representation vector, and determine the representation vector of node 422 according to the concatenated vector and the average representation vector.
[0176] The characterization vector of node 42 can be obtained in a similar manner. After obtaining the characterization vectors of nodes 41, 42, and 43, the characterization vector of root node 4 can be determined:
[0177] Determine the average word vector of the phrase "Federal Paper Board sells paper and woodproducts." represented by root node 4 and the component representation vectors of "Federal Paper Board sells paper and woodproducts.", concatenate the average word vector of "Federal Paper Board sells paper and woodproducts." with the component representation vectors to obtain a concatenated vector, determine the average value of the representation vectors of nodes 41, 42 and 43 as the average representation vector, and determine the representation vector of root node 4 based on the concatenated vector and the average representation vector.
[0178] The final representation vector of the root node 4 is determined as Figure 4 The representation vectors of the component syntax trees are shown.
[0179] After obtaining the joint parse tree, a dependency syntactic tree can also be obtained based on the joint parse tree. The dependency syntactic tree includes several nodes, each node represents a word in the target sentence, and two nodes representing two words with a dependency relationship are connected by a directed connection line. The directed connection line points from the node representing the modifier to the node representing the core word. The highest-level node of the dependency syntactic tree is the root node, and the lowest-level node is the leaf node. The information of each node in the dependency syntactic tree includes the word represented by the node and the dependency relationship label between the word represented by the node and the word represented by the previous node.
[0180] See also Figure 5 , showing a schematic diagram of the dependency syntax tree of the target sentence "Federal Paper Board sells paper and wood products." Figure 4Node 511 in represents the word "Federal", which has a dependency relationship with the word "Board" represented by its parent node 51, and the dependency label of "Federal" and "Board" is "compound". Node 512 represents the word "Paper", which has a dependency relationship with the word "Board" represented by its parent node 51, and the dependency label of "Paper" and "Board" is "compound". Node 51 represents the word "Board", and the "Board" represented by node 51 has a dependency relationship with the word "sells" represented by its parent node 5, and the dependency label of "Board" and "sells" is "nsubj". Node 5221 represents the word "and", and the word "and" represented by node 5221 has a dependency relationship with the word "wood" represented by its parent node 522, and the dependency label is "cc". The word "wood" represented by node 522 has a dependency relationship with the word "products" represented by its parent node 52, and the dependency label is "obj". Other nodes are similar.
[0181] After obtaining the dependency syntactic tree, it is necessary to use a sentence classification model to determine the representation vector of the dependency syntactic tree. Next, the process of determining the representation vector of the dependency syntactic tree using a sentence classification model is introduced.
[0182] The process of determining the representation vector of the component syntactic tree using the sentence classification model includes:
[0183] Step f1: Using the sentence classification model, determine the representation vector of each node in the dependency syntax tree in order from low level to high level.
[0184] Among them, the representation vector of each leaf node in the dependency syntax tree is determined according to the information of the leaf node, and the representation vector of each non-leaf node is determined according to the information of the non-leaf node and the representation vector of the next level node of the non-leaf node.
[0185] The process of determining the representation vector of a leaf node according to information of the dependency syntax tree may include:
[0186] Step g1: According to the information of the leaf node, obtain the word vector of the word represented by the leaf node and the dependency representation vector corresponding to the word represented by the leaf node.
[0187] Among them, the dependency representation vector corresponding to the word represented by the leaf node is determined according to the dependency label between the word represented by the leaf node and the word represented by its upper-level node.
[0188] Step g2: determine the representation vector of the leaf node based on the word vector of the word represented by the leaf node and the dependency representation vector corresponding to the word represented by the leaf node.
[0189] Optionally, the word vector of the word represented by the leaf node can be concatenated with the dependency representation vector corresponding to the word represented by the leaf node, the concatenated vector can be input into LSTM, and the vector output by LSTM can be used as the representation vector of the leaf node.
[0190] The process of determining a representation vector of a non-leaf node according to information of the non-leaf node of the dependency syntax tree may include:
[0191] Step h1: Based on the information of the non-leaf node, obtain the word vector of the word represented by the non-leaf node and the dependency representation vector corresponding to the word represented by the non-leaf node.
[0192] Among them, the dependency representation vector corresponding to the word represented by the non-leaf node is determined according to the dependency label between the word represented by the non-leaf node and the word represented by its upper-level node.
[0193] Step h2, determine the representation vector of the non-leaf node based on the word vector of the word represented by the non-leaf node, the dependency representation vector corresponding to the word represented by the non-leaf node, and the representation vector of the next-level node of the non-leaf node.
[0194] Specifically, the representation vectors of the next-level nodes of the non-leaf node are summed to obtain a summed vector, the word vector of the word represented by the non-leaf node is concatenated with the dependency representation vector corresponding to the word represented by the non-leaf node to obtain a concatenated vector, and the representation vector of the non-leaf node is determined based on the summed vector and the concatenated vector. Optionally, the summed vector and the concatenated vector can be input into LSTM, and the vector output by LSTM is used as the representation vector of the non-leaf node.
[0195] Step f2: determine the representation vector of the root node in the dependency syntax tree as the representation vector of the dependency syntax tree.
[0196] Through steps f1 and f2, the representation vector of the root node in the dependency syntax tree can be finally obtained. In the present application, the representation vector of the root node in the dependency syntax tree is determined as the representation vector of the dependency syntax tree.
[0197] Below Figure 5 Taking the component syntax tree shown as an example, the process of determining the representation vector of the dependency syntax tree is explained:
[0198] Determine the representation vectors of nodes 511, 512, 5221, and 53: Taking node 511 as an example, determine the word vector of the word "Federal" represented by node 511 and the dependency representation vector corresponding to the word "Federal" represented by node 511 (the dependency representation vector corresponding to "Federal" is determined based on the dependency label compound of "Federal" and "Board"). Determine the representation vector h0 of node 511 based on the word vector of "Federal" and the dependency representation vector corresponding to "Federal". In a similar manner, the representation vector h1 of node 512, the representation vector h5 of node 5221, and the representation vector of node 53 can be obtained.
[0199] Determine the representation vector of node 51: determine the word vector of the word "Board" represented by node 51 and the dependency representation vector corresponding to the word "Board" represented by node 51 (the dependency representation vector corresponding to "Federal" is determined based on the dependency label "nsubj" of "Federal" and "sells"), concatenate the word vector of "Board" with the dependency representation vector corresponding to "Board" to obtain a concatenated vector, sum the representation vectors h0 and h1 of the subordinate nodes 511 and 512 of node 51 to obtain a summed vector, and determine the representation vector h2 of node 51 based on the concatenated vector and the summed vector.
[0200] Determine the representation vector of node 5211: determine the word vector of the word "wood" represented by node 5211 and the dependency representation vector corresponding to the word "wood" represented by node 5211 (the dependency representation vector corresponding to "wood" is determined based on the dependency label "conj" between "wood" and "paper"), concatenate the word vector of "wood" with the dependency representation vector corresponding to "wood" to obtain the concatenated vector, and determine the representation vector of node 5211 based on the concatenated vector and the representation vector of node 5221.
[0201] Determine the representation vectors of nodes 521 and 522: Taking node 521 as an example, determine the word vector of the word "paper" represented by node 521 and the dependency representation vector corresponding to the word "paper" represented by node 521 (the dependency representation vector corresponding to "paper" is determined based on the dependency label "compound" between "paper" and "products"). Concatenate the word vector of "paper" with the dependency representation vector corresponding to "paper" to obtain a concatenated vector. Determine the representation vector of node 521 based on the concatenated vector and the representation vector of node 5211. The representation vector of node 522 can be obtained in a similar manner.
[0202] Determine the representation vector of node 52: determine the word vector of the word "products" represented by node 52 and the dependency representation vector corresponding to the word "products" represented by node 52 (the dependency representation vector corresponding to "products" is determined based on the dependency label "obj" of "products" and "sells"), concatenate the word vector of "products" with the dependency representation vector corresponding to "products" to obtain a concatenated vector, sum the representation vectors of the subordinate nodes 521 and 522 of node 52 to obtain a summed vector, and determine the representation vector h7 of node 52 based on the concatenated vector and the summed vector.
[0203] Determine the representation vector of the root node 5: determine the word vector of the word "sells" represented by node 5 and the dependency representation vector corresponding to the word "sells" represented by node 5 (the dependency representation vector corresponding to "products" is determined according to the dependency label "Root"), concatenate the word vector of "sells" with the dependency representation vector corresponding to "sells" to obtain a concatenated vector, sum the representation vectors of the subordinate nodes 51, 52 and 53 of node 5 to obtain a summed vector, and determine the representation vector of node 5 based on the concatenated vector and the summed vector.
[0204] The final representation vector of the root node 5 is determined as Figure 5 The representation vectors of the component syntax trees are shown.
[0205] The above content gives the process of determining the representation vectors of the component syntactic tree and the representation vectors of the dependency syntactic tree of the target sentence using a pre-established sentence classification model. The first embodiment mentions that the sentence classification model is trained using training samples. When training the sentence classification model, the sentence classification model is used to determine the representation vectors of the component syntactic trees in the training samples and the representation vectors of the dependency syntactic trees in the training samples. The process of determining the representation vectors of the component syntactic trees in the training samples and the representation vectors of the dependency syntactic trees in the training samples using the sentence classification model is similar to the process of determining the representation vectors of the component syntactic tree and the representation vectors of the dependency syntactic tree of the target sentence using the sentence classification model. Please refer to each other for details.
[0206] Fourth embodiment
[0207] After obtaining the representation vectors of the component syntactic tree and the representation vectors of the dependency syntactic tree through the method provided in the above embodiment, the representation vectors of the component syntactic tree and the representation vectors of the dependency syntactic tree can be concatenated using a sentence classification model to obtain a concatenated vector, and then the sentence classification model can be used to predict the category of the target sentence based on the concatenated vector.
[0208] The process of predicting the category of the target sentence based on the concatenated vector using the sentence classification model may include: predicting the category of the target sentence based on the concatenated vector using the sentence classification model from one or more of the following dimensions: sentence pattern, tense, semantics, and grammar. Optionally, the sentence classification model may include multiple classification modules, each of which is used to determine the sentence category of one dimension.
[0209] It should be noted that the sentence categories of the sentence pattern dimension may include but are not limited to negative sentences, passive sentences, inverted sentences, etc.; the sentence categories of the tense dimension may include but are not limited to present tense, present continuous tense, present perfect tense, present perfect continuous tense, past tense, past continuous tense, past perfect tense, past perfect continuous tense, future tense, future continuous tense, future perfect tense, future perfect continuous tense, past future tense, past future continuous tense, past future perfect tense, past future perfect continuous tense, verb prototype without tense, subjunctive mood, etc.; the sentence categories of the semantic dimension may include but are not limited to declarative sentences, interrogative sentences, rhetorical questions, imperative sentences, etc.; the sentence categories of the grammatical dimension may include but are not limited to simple sentences, parallel sentences, noun clauses (subject, object, predicate, appositive), adjective clauses (attributive clauses), adverbial clauses (adverbial clauses), etc.
[0210] It should be noted that for each dimension, the major category of the target sentence in the dimension can be determined, and further, the subcategories under the major category can be determined. For example, after determining that the target sentence is an adverbial clause, it can be further determined what type of adverbial clause the target sentence is. For another example, after determining that the target sentence is a noun clause, it can be further determined what type of noun clause the target sentence is.
[0211] In addition, for each dimension, the category of the target sentence can also be predicted from multiple sub-dimensions. For example, past and future serial tenses and subjunctive mood often appear in complex sentences, so it can be predicted that the target sentence belongs to the past tense, past progressive tense, past perfect tense, and past perfect progressive tense. At the same time, it can be predicted that the target sentence belongs to the future tense, future progressive tense, future perfect tense, and future perfect progressive tense.
[0212] After predicting the category of the target sentence from one dimension or multiple dimensions, the predicted category can be output.
[0213] Fifth embodiment
[0214] The embodiment of the present application also provides a sentence classification device. The sentence classification device provided in the embodiment of the present application is described below. The sentence classification device described below and the sentence classification method described above can be referenced to each other.
[0215] See also Figure 6, shows a schematic diagram of the structure of a sentence classification device provided in an embodiment of the present application, which may include: a syntax tree acquisition module 601, a syntax tree representation module 602 and a sentence classification module 603.
[0216] The syntax tree acquisition module 601 is used to acquire a component syntax tree that can present the hierarchical grammatical structure information of the target sentence and a dependency syntax tree that can present the dependency relationship information between words of the target sentence.
[0217] The syntax tree representation module 602 is used to determine the representation vector of the component syntax tree and the representation vector of the dependency syntax tree.
[0218] The sentence classification module 603 is used to predict the category of the target sentence according to the representation vector of the component syntax tree and the representation vector of the dependency syntax tree.
[0219] Optionally, the syntax tree acquisition module 601 may include: a syntax parsing module, and a component syntax tree and a dependency syntax tree acquisition module. The acquisition of the component syntax tree that can present the hierarchical grammatical structure information of the target sentence and the dependency syntax tree that can present the dependency relationship information between words of the target sentence includes:
[0220] The grammatical parsing module is used to parse the hierarchical grammatical structure information and inter-word dependency information of the target sentence using a pre-established grammatical parsing model, and generate a joint parsing tree that can simultaneously present the hierarchical grammatical structure information and inter-word dependency information of the target sentence based on the parsing result, wherein the grammatical parsing model is trained using training sentences and the joint parsing tree corresponding to the training sentences.
[0221] The component syntax tree and dependency syntax tree acquisition module is used to obtain the component syntax tree and the dependency syntax tree according to the joint parse tree.
[0222] Optionally, the syntax tree representation module 602 and the sentence classification module 603 are implemented using a pre-established sentence classification model, i.e., a sentence classification model, which is used to determine the representation vector of the component syntax tree and the representation vector of the dependency syntax tree, and predict the category of the target sentence based on the representation vector of the component syntax tree and the representation vector of the dependency syntax tree.
[0223] The sentence classification model is trained using a component syntax tree that can present the hierarchical grammatical structure information of the training sentences and a dependency syntax tree that can present the dependency relationship information between words of the training sentences as training samples, and is trained using the categories of the training sentences as sample labels.
[0224] Optionally, the component syntax tree includes several leaf nodes and several non-leaf nodes, and the next level of each non-leaf node is a leaf node and / or a non-leaf node; the highest-level node of the component syntax tree is the root node, and the lowest-level node is a leaf node; each leaf node of the component syntax tree represents a word in the target sentence, and each non-leaf node represents a phrase in the target sentence; the information of each node of the component syntax tree includes the word or phrase represented by the node and the component label of the word or phrase represented by the node.
[0225] Optionally, when determining the representation vector of the component syntactic tree, the sentence classification model is specifically used to:
[0226] Determine the representation vector of each node in the component syntax tree in order from low level to high level, wherein the representation vector of each leaf node in the component syntax tree is determined according to the information of the leaf node, and the representation vector of each non-leaf node is determined according to the information of the non-leaf node and the representation vector of the next level node of the non-leaf node; determine the representation vector of the root node in the component syntax tree as the representation vector of the component syntax tree.
[0227] Optionally, when the sentence classification model determines the representation vector of a leaf node according to the information of the leaf node of the component syntax tree, it is specifically used to:
[0228] According to the information of the leaf node, determine the word vector of the word represented by the leaf node and the part-of-speech representation vector of the word represented by the leaf node; according to the word vector of the word represented by the leaf node and the part-of-speech representation vector of the word represented by the leaf node, determine the representation vector of the leaf node;
[0229] Optionally, when the sentence classification model determines the representation vector of a non-leaf node according to the information of the non-leaf node of the component syntax tree and the representation vector of the next-level node of the non-leaf node, it is specifically used to:
[0230] Based on the information of the non-leaf node, determine the component representation vector of the phrase represented by the non-leaf node and the average word vector of the phrase represented by the non-leaf node; based on the component representation vector of the phrase represented by the non-leaf node, the average word vector of the phrase represented by the non-leaf node and the representation vector of the next-level node of the non-leaf node, determine the representation vector of the non-leaf node.
[0231] Optionally, when the sentence classification model determines the representation vector of the non-leaf node according to the component representation vector of the phrase represented by the non-leaf node, the average word vector of the phrase represented by the non-leaf node, and the representation vector of the next-level node of the non-leaf node, it is specifically used to:
[0232] Determine the average value of the representation vectors of the next-level nodes of the non-leaf node as the average representation vector; concatenate the component representation vectors of the phrase represented by the non-leaf node with the average word vector of the phrase represented by the non-leaf node to obtain a concatenated vector; determine the representation vector of the non-leaf node based on the average representation vector and the concatenated vector.
[0233] Optionally, the dependency syntax tree includes several nodes, each node represents a word in the target sentence, and two nodes representing two words with a dependency relationship are connected by a directed line, and the directed line points from the node representing the modifier to the node representing the core word; the highest-level node of the dependency syntax tree is the root node, and the lowest-level node is the leaf node; the information of each node in the dependency syntax tree includes the word represented by the node and the dependency relationship label between the word represented by the node and the word represented by the previous node.
[0234] Optionally, when determining the representation vector of the dependency syntax tree, the sentence classification model is specifically used to:
[0235] Determine the representation vector of each node in the dependency syntax tree in order from low level to high level, wherein the representation vector of each leaf node in the dependency syntax tree is determined according to the information of the leaf node, and the representation vector of each non-leaf node is determined according to the information of the non-leaf node and the representation vector of the next level node of the non-leaf node; determine the representation vector of the root node in the dependency syntax tree as the representation vector of the dependency syntax tree.
[0236] Optionally, when the sentence classification model determines the representation vector of a leaf node according to the information of the leaf node of the dependency syntax tree, it is specifically used to:
[0237] According to the information of the leaf node, determine the word vector of the word represented by the leaf node and the dependency representation vector corresponding to the word represented by the leaf node; according to the word vector of the word represented by the leaf node and the dependency representation vector corresponding to the word represented by the leaf node, determine the representation vector of the leaf node;
[0238] Optionally, when the sentence classification model determines the representation vector of a non-leaf node according to the information of the non-leaf node of the dependency syntax tree, it is specifically used to:
[0239] According to the information of the non-leaf node, determine the word vector of the word represented by the non-leaf node and the dependency representation vector corresponding to the word represented by the non-leaf node; according to the word vector of the word represented by the non-leaf node, the dependency representation vector corresponding to the word represented by the non-leaf node and the representation vector of the next-level node of the non-leaf node, determine the representation vector of the non-leaf node.
[0240] Optionally, when the sentence classification model determines the representation vector of the non-leaf node according to the word vector of the word represented by the non-leaf node, the dependency representation vector corresponding to the word represented by the non-leaf node, and the representation vector of the next-level node of the non-leaf node, it is specifically used to:
[0241] The representation vectors of the next-level nodes of the non-leaf node are summed to obtain a summed vector; the word vector of the word represented by the non-leaf node is concatenated with the dependency representation vector corresponding to the word represented by the non-leaf node to obtain a concatenated vector; the representation vector of the non-leaf node is determined based on the summed vector and the concatenated vector.
[0242] Optionally, when the sentence classification model predicts the category of the target sentence according to the representation vector of the component syntax tree and the representation vector of the dependency syntax tree, it is specifically used to:
[0243] The representation vector of the component syntax tree is concatenated with the representation vector of the dependency syntax tree to obtain a concatenated vector; and the category of the target sentence is predicted from one dimension or multiple dimensions according to the concatenated vector.
[0244] Optionally, when the sentence classification model predicts the category of the target sentence from one dimension or multiple dimensions according to the concatenated vector, it is specifically used to:
[0245] According to the concatenated vector, the category of the target sentence is predicted from one or more of the following dimensions: sentence pattern, tense, semantics, and grammar.
[0246] The sentence classification device provided in the embodiment of the present application first obtains a component syntax tree that can present the hierarchical grammatical structure information of the target sentence and a dependency syntax tree that can present the dependency relationship information between words of the target sentence, then determines the representation vector of the component syntax tree and the representation vector of the dependency syntax tree, and finally predicts the category of the target sentence based on the representation vector of the component syntax tree and the representation vector of the dependency syntax tree. The sentence classification device provided in the embodiment of the present application can predict the category information of the sentence at the grammatical and / or semantic level, and the obtained category information can help users learn the language better.
[0247] Sixth embodiment
[0248] The present application also provides a sentence classification device. Figure 7 , showing a schematic diagram of the structure of the sentence classification device, the sentence classification device may include: at least one processor 701, at least one communication interface 702, at least one memory 703 and at least one communication bus 704;
[0249] In the embodiment of the present application, the number of the processor 701, the communication interface 702, the memory 703, and the communication bus 704 is at least one, and the processor 701, the communication interface 702, and the memory 703 communicate with each other through the communication bus 704;
[0250] The processor 701 may be a central processing unit (CPU), or an application-specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of the present invention;
[0251] The memory 703 may include a high-speed RAM memory, and may also include a non-volatile memory, such as at least one disk memory;
[0252] The memory stores a program, and the processor can call the program stored in the memory, and the program is used to:
[0253] Acquire a component syntax tree capable of presenting hierarchical grammatical structure information of a target sentence and a dependency syntax tree capable of presenting dependency relationship information between words of the target sentence;
[0254] Determining a representation vector of the component syntax tree and a representation vector of the dependency syntax tree;
[0255] The category of the target sentence is predicted according to the representation vectors of the component syntax tree and the representation vectors of the dependency syntax tree.
[0256] Optionally, the detailed functions and extended functions of the program may refer to the above description.
[0257] Seventh embodiment
[0258] The embodiment of the present application further provides a readable storage medium, which may store a program suitable for execution by a processor, wherein the program is used to:
[0259] Acquire a component syntax tree capable of presenting hierarchical grammatical structure information of a target sentence and a dependency syntax tree capable of presenting dependency relationship information between words of the target sentence;
[0260] Determining a representation vector of the component syntax tree and a representation vector of the dependency syntax tree;
[0261] The category of the target sentence is predicted according to the representation vectors of the component syntax tree and the representation vectors of the dependency syntax tree.
[0262] Optionally, the detailed functions and extended functions of the program may refer to the above description.
[0263] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0264] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.
[0265] The above description of the disclosed embodiments enables one skilled in the art to implement or use the present invention. Various modifications to these embodiments will be apparent to one skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A sentence classification method, characterized in that: include: Obtaining a component syntax tree capable of presenting hierarchical grammatical structure information of a target sentence and a dependency syntax tree capable of presenting inter-word dependency information of the target sentence, wherein the hierarchical grammatical structure information presented by the component syntax tree includes component labels of the target sentence and component labels of each layer of segmentation results obtained by segmenting the target sentence layer by layer; Determining a representation vector of the component syntax tree and a representation vector of the dependency syntax tree; Predicting the category of the target sentence according to the representation vectors of the component syntax tree and the representation vectors of the dependency syntax tree; The determining of the representation vectors of the component syntax tree and the representation vectors of the dependency syntax tree, and the predicting of the category of the target sentence according to the representation vectors of the component syntax tree and the representation vectors of the dependency syntax tree, include: Determine the representation vector of the component syntactic tree and the representation vector of the dependency syntactic tree by using a pre-established sentence classification model; Using the sentence classification model, based on the representation vectors of the component syntax tree and the representation vectors of the dependency syntax tree, predicting the category of the target sentence; The sentence classification model is trained using a component syntax tree that can present the hierarchical grammatical structure information of the training sentences and a dependency syntax tree that can present the dependency relationship information between words of the training sentences as training samples, and is trained using the categories of the training sentences as sample labels.
2. The sentence classification method according to claim 1, characterized in that: The step of obtaining a component syntax tree capable of presenting hierarchical grammatical structure information of a target sentence and a dependency syntax tree capable of presenting dependency relationship information between words of the target sentence includes: Utilizing a pre-established grammatical parsing model, parsing the hierarchical grammatical structure information and the inter-word dependency relationship information of the target sentence, and generating a joint parse tree capable of simultaneously presenting the hierarchical grammatical structure information and the inter-word dependency relationship information of the target sentence according to the parsing result, wherein the grammatical parsing model is trained using training sentences and the joint parse tree corresponding to the training sentences; According to the joint parse tree, the component syntax tree and the dependency syntax tree are obtained.
3. The sentence classification method according to claim 1, characterized in that: The component syntax tree includes a plurality of leaf nodes and a plurality of non-leaf nodes, and the next level of each non-leaf node is a leaf node and / or a non-leaf node; The highest level node of the component syntax tree is the root node, and the lowest level node is the leaf node; Each leaf node of the component syntax tree represents a word in the target sentence, and each non-leaf node represents a phrase in the target sentence; The information of each node of the component syntax tree includes the word or phrase represented by the node and the component label of the word or phrase represented by the node.
4. The sentence classification method according to claim 3, characterized in that: Determining a representation vector of the component syntax tree includes: Determine the representation vector of each node in the component syntax tree in order from low level to high level, wherein the representation vector of each leaf node in the component syntax tree is determined according to the information of the leaf node, and the representation vector of each non-leaf node is determined according to the information of the non-leaf node and the representation vector of the node at the next level of the non-leaf node; The representation vector of the root node in the component syntax tree is determined as the representation vector of the component syntax tree.
5. The sentence classification method according to claim 4, characterized in that: Determining a representation vector of a leaf node according to information of the leaf node of the component syntax tree includes: According to the information of the leaf node, determine the word vector of the word represented by the leaf node and the part-of-speech representation vector of the word represented by the leaf node; Determine the representation vector of the leaf node according to the word vector of the word represented by the leaf node and the part-of-speech representation vector of the word represented by the leaf node; Determining a representation vector of a non-leaf node according to information of a non-leaf node of the component syntax tree and a representation vector of a node at a next level of the non-leaf node includes: Determine, based on the information of the non-leaf node, a component representation vector of the phrase represented by the non-leaf node and an average word vector of the phrase represented by the non-leaf node; The representation vector of the non-leaf node is determined according to the component representation vector of the phrase represented by the non-leaf node, the average word vector of the phrase represented by the non-leaf node, and the representation vector of the next level node of the non-leaf node.
6. The sentence classification method according to claim 5, characterized in that: The step of determining the representation vector of the non-leaf node according to the component representation vector of the phrase represented by the non-leaf node, the average word vector of the phrase represented by the non-leaf node, and the representation vector of the next level node of the non-leaf node includes: Determine the average value of the representation vectors of the next level nodes of the non-leaf node as the average representation vector; Concatenate the component representation vector of the phrase represented by the non-leaf node with the average word vector of the phrase represented by the non-leaf node to obtain a concatenated vector; A representation vector of the non-leaf node is determined according to the average representation vector and the concatenated vector.
7. The sentence classification method according to claim 1, characterized in that: The dependency syntax tree includes a plurality of nodes, each node represents a word in the target sentence, and two nodes representing two words having a dependency relationship are connected by a directed connection line, and the directed connection line points from the node representing the modifier to the node representing the core word; The highest level node of the dependency syntax tree is the root node, and the lowest level node is the leaf node; The information of each node in the dependency syntax tree includes the word represented by the node and the dependency relationship label between the word represented by the node and the word represented by the previous node.
8. The sentence classification method according to claim 7, characterized in that: Determining a representation vector of the dependency syntax tree includes: Determine the representation vector of each node in the dependency syntax tree in order from low level to high level, wherein the representation vector of each leaf node in the dependency syntax tree is determined according to the information of the leaf node, and the representation vector of each non-leaf node is determined according to the information of the non-leaf node and the representation vector of the node at the next level of the non-leaf node; The representation vector of the root node in the dependency syntax tree is determined as the representation vector of the dependency syntax tree.
9. The sentence classification method according to claim 8, characterized in that: Determining a representation vector of a leaf node according to information of the dependency syntax tree includes: According to the information of the leaf node, determine the word vector of the word represented by the leaf node and the dependency representation vector corresponding to the word represented by the leaf node; Determine the representation vector of the leaf node according to the word vector of the word represented by the leaf node and the dependency representation vector corresponding to the word represented by the leaf node; Determining a representation vector of a non-leaf node according to information of the dependency syntax tree includes: According to the information of the non-leaf node, determine the word vector of the word represented by the non-leaf node and the dependency representation vector corresponding to the word represented by the non-leaf node; The representation vector of the non-leaf node is determined according to the word vector of the word represented by the non-leaf node, the dependency representation vector corresponding to the word represented by the non-leaf node, and the representation vector of the next-level node of the non-leaf node.
10. The sentence classification method according to claim 9, characterized in that: The step of determining the representation vector of the non-leaf node according to the word vector of the word represented by the non-leaf node, the dependency representation vector corresponding to the word represented by the non-leaf node, and the representation vector of the next level node of the non-leaf node includes: Sum the representation vectors of the next level nodes of the non-leaf node to obtain a summed vector; Concatenate the word vector of the word represented by the non-leaf node with the dependency representation vector corresponding to the word represented by the non-leaf node to obtain a concatenated vector; Determine a representation vector of the non-leaf node according to the summed vector and the concatenated vector.
11. The sentence classification method according to claim 1, characterized in that: The predicting the category of the target sentence based on the representation vector of the component syntax tree and the representation vector of the dependency syntax tree includes: concatenating the representation vector of the component syntax tree with the representation vector of the dependency syntax tree to obtain a concatenated vector; According to the concatenated vector, the category of the target sentence is predicted from one dimension or multiple dimensions.
12. The sentence classification method according to claim 11, characterized in that: The predicting the category of the target sentence from one dimension or multiple dimensions according to the concatenated vector includes: According to the concatenated vector, the category of the target sentence is predicted from one or more of the following dimensions: sentence pattern, tense, semantics, and grammar.
13. A sentence classification device, characterized in that: include: Syntax tree acquisition module, syntax tree representation module and sentence classification module; The grammar tree acquisition module is used to acquire a component grammar tree that can present the hierarchical grammar structure information of the target sentence and a dependency grammar tree that can present the dependency relationship information between words of the target sentence, wherein the hierarchical grammar structure information presented by the component grammar tree includes the component label of the target sentence and the component label of each layer of segmentation result obtained by segmenting the target sentence layer by layer; The syntax tree representation module is used to determine the representation vector of the component syntax tree and the representation vector of the dependency syntax tree; The sentence classification module is used to predict the category of the target sentence according to the representation vector of the component syntax tree and the representation vector of the dependency syntax tree; When determining the representation vector of the component syntax tree and the representation vector of the dependency syntax tree, the syntax tree representation module is specifically used to determine the representation vector of the component syntax tree and the representation vector of the dependency syntax tree by using a pre-established sentence classification model; When the sentence classification module predicts the category of the target sentence according to the representation vector of the component syntax tree and the representation vector of the dependency syntax tree, the sentence classification module is specifically used to predict the category of the target sentence based on the representation vector of the component syntax tree and the representation vector of the dependency syntax tree using the sentence classification model; The sentence classification model is trained using a component syntax tree that can present the hierarchical grammatical structure information of the training sentences and a dependency syntax tree that can present the dependency relationship information between words of the training sentences as training samples, and is trained using the categories of the training sentences as sample labels.
14. A sentence classification device, characterized in that: include: Memory and processor; The memory is used to store programs; The processor is used to execute the program to implement each step of the sentence classification method according to any one of claims 1 to 12.
15. A readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, each step of the sentence classification method according to any one of claims 1 to 12 is implemented.
Citation Information
Patent Citations
Semantic role recognition method based on phrase structure tree
CN107818082A
Linear model method used for simplified-Chinese readability measurement
CN107977449A