Sentence component recognition method, device, computer equipment and storage medium
Through the pre-trained sentence component recognition model, the encoding and decoding layers are used to identify sentence components and their locations, solving the problem of complex dependent syntax analysis operations, and achieving simple and efficient sentence component recognition and nested analysis.
Patent Information
- Application Number
- CN202110436059.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-04-22
- Publication Date
- 2025-08-22
- Estimated Expiration
- 2041-04-22
AI Technical Summary
The existing dependent syntax analysis and rule methods require manual definition of rules, and the operation is complex and it is difficult to achieve simple sentence component recognition.
The pre-trained sentence component recognition model is adopted, the word feature vector is output through the encoding layer and the entire sentence-level component label sequence is obtained using the decoding layer, the sentence components and their locations are identified in the sentence, the nested decoding of complex components is supported, and the model is adjusted using the training corpus.
It realizes simple and efficient sentence component recognition, can identify target components in sentences, supports nested structure analysis of complex sentences, and improves operation convenience.
Smart Images

Figure CN115238672B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of natural language processing technology, and in particular to a sentence component recognition method, apparatus, computer equipment, and storage medium. Background Art
[0002] Syntactic analysis is a key technology in natural language processing. Its fundamental task is to determine the syntactic structure of a sentence or the dependencies between words within it. For example, dependency parsing can be used to identify dependencies between words, such as the subject-predicate relationship with a central word. Therefore, dependency relationships can be used to analyze sentence components. This is specifically based on dependency parsing and rule-based methods.
[0003] However, dependency parsing and rule-based methods require manual rule definition and maintenance, which is complex to operate. Summary of the Invention
[0004] Based on this, it is necessary to provide a simple-to-operate sentence component recognition method, device, computer equipment and storage medium to address the above technical problems.
[0005] A sentence component recognition method, the method comprising:
[0006] Obtain a sentence and a target sentence component to be identified;
[0007] The sentence is input into a pre-trained sentence component recognition model, and the encoding layer of the sentence component recognition model outputs the word feature vector of each word in the sentence; the decoding layer of the sentence component recognition model decodes the word feature vector of each word to obtain a whole sentence level component label sequence, and the whole sentence level component label sequence identifies the sentence component to which each word in the whole sentence belongs, and the position of each word in the sentence component to which it belongs;
[0008] If it is determined based on the entire sentence-level component label sequence that the sentence does not contain a complex component, then the text content corresponding to the target sentence component is obtained based on the sentence component to which each word in the entire sentence belongs, as identified by the entire sentence-level component label sequence, and the position of each word in the sentence component to which it belongs.
[0009] In one embodiment, the method further comprises:
[0010] If it is determined that the sentence contains a complex component based on the whole sentence component label sequence, then obtaining a word feature vector of the complex component, decoding the word feature vector of the complex component through the decoding layer, and obtaining a sub-level component label sequence corresponding to each complex component; the sub-level component label sequence identifies the sentence component to which each word in the complex component belongs, and the position of each word in the sentence component to which it belongs;
[0011] If it is determined based on the subordinate component label sequence that the complex component does not have a nested sentence component or the nested sentence component is a simple component, then the text content corresponding to the target sentence component is obtained based on the output valid component label sequence, wherein the valid component label sequence includes the whole-sentence-level component label sequence, or the whole-sentence-level component label sequence and the subordinate component label sequence.
[0012] In one embodiment, if the complex component contains nested complex components, the steps of obtaining the word feature vector of the complex component, decoding the word feature vector of the complex component through the decoding layer, and obtaining the sub-level component label sequence corresponding to each of the complex components are performed on the nested complex component until the corresponding sub-level component label sequence indicates that the complex component does not contain nested sentence components or the nested sentence components are simple components.
[0013] In one embodiment, if it is determined according to the whole sentence-level component label sequence that a sentence contains a sentence component with a character count greater than 1, then the sentence contains a complex component.
[0014] In one embodiment, if the number of characters of the nested sentence component identified by the sub-level component label sequence is 1, the nested sentence component is a simple component; if the number of characters of the nested sentence component identified by the sub-level component label sequence is greater than 1, the nested sentence component is a complex component.
[0015] In one embodiment, the method further comprises:
[0016] Obtaining a sentence set for training, the sentence set including training corpus for each sentence, the training corpus including component label sequences graded according to nested components, the component label sequences including a whole sentence-level component label sequence and a sub-level component label sequence of a nested complex component, each component label sequence including the sentence component to which each word in the sentence belongs in the corresponding component grade, and the position of each word in the sentence component to which it belongs;
[0017] The step of training the sentence component recognition model to be trained using the training sentence set includes: inputting the training corpus of the sentences in the sentence set into the sentence component recognition model to be trained, the encoding layer of the sentence component recognition model outputting the word feature vector of each word in the sentence; the decoding layer of the sentence component recognition model decoding according to the word feature vector of each word to obtain a predicted component label sequence,
[0018] adjusting the sentence component recognition model according to the predicted component label sequence and the component label sequence;
[0019] The step of training the sentence component recognition model to be trained by using the training sentence set is repeated until the training end condition is met, thereby obtaining a trained sentence component recognition model.
[0020] In one embodiment, obtaining a sentence set for training includes:
[0021] Obtaining the sentence component hierarchy determined based on the nested relationship of the sentences, the words corresponding to each sentence component in each component hierarchy, and the start and end positions of the sentence components;
[0022] According to the words corresponding to each sentence component of each component level, as well as the starting position and ending position of the sentence component, the whole sentence level component label sequence and the sub-level component label sequence of the nested complex component are obtained;
[0023] According to the whole sentence component label sequence and the nested component label sequence, constructing the training corpus for each sentence component as the model input;
[0024] According to the training corpus described in each sentence, a training sentence set is obtained.
[0025] A sentence component recognition device, comprising:
[0026] An input acquisition module is used to acquire sentences and target sentence components to be recognized;
[0027] A component label sequence acquisition module is configured to input the sentence into a pre-trained sentence component recognition model, wherein the encoding layer of the sentence component recognition model outputs a word feature vector for each word in the sentence; the decoding layer of the sentence component recognition model decodes each word according to the word feature vector to obtain a whole-sentence component label sequence, wherein the whole-sentence component label sequence identifies the sentence component to which each word in the whole sentence belongs and the position of each word within the sentence component to which it belongs;
[0028] The recognition module is used to obtain the text content corresponding to the target sentence component based on the sentence component to which each word in the whole sentence belongs, as identified by the whole sentence-level component label sequence, and the position of each word in the sentence component to which it belongs, if it is determined that the sentence does not have a complex component based on the whole sentence-level component label sequence.
[0029] A computer device includes a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:
[0030] Obtain a sentence and a target sentence component to be identified;
[0031] The sentence is input into a pre-trained sentence component recognition model, and the encoding layer of the sentence component recognition model outputs the word feature vector of each word in the sentence; the decoding layer of the sentence component recognition model decodes the word feature vector of each word to obtain a whole sentence level component label sequence, and the whole sentence level component label sequence identifies the sentence component to which each word in the whole sentence belongs, and the position of each word in the sentence component to which it belongs;
[0032] If it is determined based on the whole sentence-level component label sequence that the sentence does not have complex components, then the text content corresponding to the target sentence component is obtained based on the sentence component to which each word in the whole sentence belongs identified by the whole sentence-level component label sequence, and the position of each word in the sentence component to which it belongs.
[0033] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the following steps:
[0034] Obtain a sentence and a target sentence component to be identified;
[0035] The sentence is input into a pre-trained sentence component recognition model, and the encoding layer of the sentence component recognition model outputs the word feature vector of each word in the sentence; the decoding layer of the sentence component recognition model decodes the word feature vector of each word to obtain a whole sentence level component label sequence, and the whole sentence level component label sequence identifies the sentence component to which each word in the whole sentence belongs, and the position of each word in the sentence component to which it belongs;
[0036] If it is determined based on the whole sentence-level component label sequence that the sentence does not have complex components, then the text content corresponding to the target sentence component is obtained based on the sentence component to which each word in the whole sentence belongs identified by the whole sentence-level component label sequence, and the position of each word in the sentence component to which it belongs.
[0037] The above-described sentence component identification method, apparatus, computer device, and storage medium utilize a trained sentence component model to output a sequence of whole-sentence component labels. This whole-sentence component label sequence identifies the sentence component to which each word in the sentence belongs and the position of each word within that component. This component label sequence allows the target component in the sentence to be identified, thus achieving sentence component identification. This method, which utilizes a pre-trained component identification model, enables simple and convenient sentence component identification. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] Figure 1 A diagram illustrating an application environment of a sentence component recognition method according to an embodiment;
[0039] Figure 2 1 is a flow chart of a sentence component identification method according to an embodiment;
[0040] Figure 3 Schematic diagram of the structure of a sentence component recognition model in one embodiment;
[0041] Figure 4 is a flow chart of a sentence component identification method in another embodiment;
[0042] Figure 5 A schematic diagram of a component identification process in one embodiment;
[0043] Figure 6 A flowchart of the sentence component recognition model training steps in one embodiment;
[0044] Figure 7 is a structural block diagram of a sentence component recognition device in one embodiment;
[0045] Figure 8 FIG. 1 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0046] In order to make the purpose, technical solutions and advantages of this application more clear, the following further describes this application in detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain this application and are not intended to limit this application.
[0047] The sentence component recognition method provided by this application can be applied to Figure 1 In the application environment shown. Among them, the terminal 102 communicates with the server 104 through the network. The terminal obtains the sentence to be analyzed input by the user, sends the recognition instruction and the sentence to the server, and the server obtains the sentence and the target sentence component to be recognized; the sentence is input into a pre-trained sentence component recognition model, and the encoding layer of the sentence component recognition model outputs the word feature vector of each word in the sentence; the decoding layer of the sentence component recognition model decodes according to the word feature vector of each word to obtain a whole sentence level component label sequence, and the whole sentence level component label sequence identifies the sentence component to which each word in the whole sentence belongs, and the position of each word in the sentence component to which it belongs; if it is determined that the sentence does not have a complex component according to the whole sentence level component label sequence, then the text content corresponding to the target sentence component is obtained according to the sentence component to which each word in the whole sentence belongs identified by the whole sentence level component label sequence, and the position of each word in the sentence component to which it belongs.
[0048] The terminal 102 may be, but is not limited to, various personal computers, laptops, smart phones, tablet computers, and portable wearable devices, and the server 104 may be implemented as an independent server or a server cluster consisting of multiple servers.
[0049] In one embodiment, Figure 2As shown, a sentence component recognition method is provided, which is applied to Figure 1 The following steps are used as an example to illustrate the server in the example:
[0050] Step 202: Obtain a sentence and target sentence components to be recognized.
[0051] In language learning, identifying sentence components can help you better understand semantics. The components of a sentence are called sentence elements, also known as syntactic elements. Within a sentence, words form certain relationships with each other, and based on these relationships, sentences can be divided into different components. Sentence components are represented by words or phrases. For example, in English, sentence components include subject, predicate, object, predicate, attributive, adverbial, complement, and appositive.
[0052] In one embodiment, the target sentence components to be identified can be all default sentence components. In a language learning application scenario, after the user enters the sentence to be analyzed, all pre-set sentence components are automatically obtained. In one embodiment, the target sentence component is the sentence component specified for analysis. For example, in a language learning interface, a sentence input box and optional sentence component options are provided. After the user enters the sentence, they select the sentence component to be analyzed, such as "subject", in which case the subject is the target sentence component.
[0053] In step 204, the sentence is input into a pre-trained sentence component recognition model. The encoding layer of the sentence component recognition model outputs the word feature vector of each word in the sentence. The decoding layer of the sentence component recognition model decodes the word feature vector of each word to obtain a whole sentence-level component label sequence. The whole sentence-level component label sequence identifies the sentence component to which each word in the whole sentence belongs, as well as the position of each word in the sentence component to which it belongs.
[0054] Specifically, the sentence component recognition model is trained based on a sentence set that identifies a sentence component label sequence. The sentence component label sequence includes the sentence component to which each word in the sentence belongs and the position of each word in the sentence component to which it belongs. That is to say, for each word in the sentence, the sentence component to which it belongs and its position in the sentence component are marked. The position includes the starting position, the ending position, the single position and other positions. For a sentence component with multiple words, the position includes the starting position, the ending position and the middle position. The starting position refers to the first word of a sentence component in which the word is located, the middle position refers to the word in the middle position of a sentence component (not the first word or the last word), and the ending position refers to the last word of a sentence component in which the word is located. The single position refers to the case where there is only one word in the sentence component. For example, if the sentence has only one sentence He, the identifier of the word He is s-0, where 0 indicates that the sentence component of the word He is the subject, and S indicates that the word He is the word in the single position of the subject component, that is, the subject component contains only one word. Other positions are used to identify words other than set sentence components. For example, set sentence components include subject, predicate, object, attributive, predicate and adverbial. If a sentence does not belong to the set sentence components, it is marked as other positions.
[0055] In one embodiment, the sentence component label sequence can be annotated using the BIEOS format, or the BIO or BMES annotation formats. Taking the BIEOS annotation format as an example, BX represents the start position of sentence component X, IX represents the middle position of sentence component X, and EX represents the end position of sentence component X. When sentence component X contains only one character, that character is annotated as SX, and other positions are annotated as O. For sentence component X, 0 represents the subject, 1 represents the predicate, 2 represents the object, 3 represents the attributive, 4 represents the adverbial, and 5 represents the predicative.
[0056] The sentence component label sequence of an embodiment is shown in Table 1.
[0057] Table 1 Sentence component label sequence format
[0058] enter He refused to talk about the sufferings he had during the disaster . Annotation 1 s-0 s-1 b-2 e-2 o o o b-3 i-3 i-3 i-3 e-3 o Annotation 2 - - - - - - - s-0 s-1 b-4 i-4 e-4 -
[0059] The structure of the sentence component recognition model of an embodiment is as follows Figure 3 As shown in Figure 1, it includes an encoding layer and a decoding layer. The encoding layer is used to construct word feature vectors for each word in the sentence, and the decoder is used to output a sentence component label sequence based on the word feature vectors output by the encoder. The component label sequence identifies the sentence component to which each word belongs and the position of each word within the sentence component.
[0060] Specifically, the encoding layer can use models such as LSTM, CNN, BERT, ELMO, Robert, XLNet, and Flair to map each character in the sentence to be analyzed into a context-sensitive vector. This vector can be a combination of the outputs of multiple models (BERT+LSTM, CNN+LSTM). The decoding layer mainly decodes the word feature vector corresponding to each word into the corresponding component label, generally using CRF (conditional random field).
[0061] The encoding layer outputs a sentence-level component label sequence based on the word feature vector of the entire sentence. In other words, the sentence-level component label sequence is the component recognition result for the entire sentence.
[0062] Step 206: Determine whether the sentence contains complex components based on the entire sentence-level component label sequence.
[0063] Specifically, the highest-scoring whole-sentence-level component label sequence output by the decoding layer is obtained. The whole-sentence-level component label sequence is the result of the whole-sentence-level component analysis, and is the result of the first-level component analysis of the sentence.
[0064] Sentences typically include simple sentences and complex sentences. A complex sentence can be formed by linking two or more simple sentences together, but the components of a complex sentence are not equally important. One sentence is introduced by a subordinate conjunction (a subordinate clause) to modify another sentence (the main clause). Complex sentences mainly include the following types of clauses: subject clauses, object clauses, predicative clauses, attributive clauses, adverbial clauses, and appositive clauses. For example, "I believe that everything is going on well" is a complex sentence, with "that" being the conjunction and "everything is going on well" being the object clause.
[0065] Therefore, the sentence-level component identification tag identifies the sentence component to which the word belongs and the position of each word in the sentence component to which it belongs. For clauses in complex sentences, only the sentence component to which the clause belongs, such as the object, is identified, and the sentence components nested in the clause are not identified.
[0066] Since the whole sentence-level component label sequence identifies the sentence component to which each word in the sentence belongs, if a sentence component has two or more words, the component is determined to be a complex component. Therefore, whether it is a complex component can be determined by the number of characters of each sentence component. For example, if the whole sentence-level component label sequence identifies that the number of characters of each sentence component is not greater than 1, then the sentence does not include a complex sentence. For example, according to the whole sentence-level component label sequence of the sentence "I like red", the whole sentence-level sentence components that can be determined are: (I, subject), (like, predicate), (red, object), and the number of characters of each sentence component is not greater than 1, then the sentence does not include a complex sentence.
[0067] If a sentence-level component label is determined to have more than one character, the component is classified as a complex component. For example, the sentence-level component label sequence for "He refused to talk about the sufferings he had during the disaster." can be determined to have the following sentence-level components: (He, subject), (refused, predicate), (to talk, object), (he had during the disaster, attributive). The predicate component has two characters, and the object component has five characters. Therefore, the predicate component and the object component are complex components of the sentence-level component.
[0068] If the sentence does not contain complex components, step S208 is executed.
[0069] Step 208 : Obtain the text content corresponding to the target sentence component according to the sentence component to which each word in the whole sentence belongs, as identified by the sentence-level component label sequence, and the position of each word in the sentence component to which it belongs.
[0070] For sentences without complex components, the sentence-level component label sequence identifies the component to which each word in the sentence belongs. Based on the position of each word in the component, the text content of each component can be extracted, and the text content corresponding to the target sentence component can be obtained. For example, the sentence-level component label sequence corresponding to the sentence "I like red." is shown in Table 2.
[0071] Table 2 Sentence-level component label sequences
[0072]
[0073]
[0074] Among them, S represents a single character, S-0 means that the sentence component to which the character belongs is the subject, and the subject has only one character. S-1 means that the sentence component to which the character belongs is the predicate, and the predicate has only one character, and S-2 means that the sentence component to which the character belongs is the object, and the object has only one character. If the target sentence component is all the preset sentence components, the final sentence component recognition result is:
[0075] Subject: He
[0076] Predicate: like
[0077] Object: red.
[0078] If the target sentence component is the subject, the final sentence component recognition result is the subject: He.
[0079] In one embodiment, obtaining the text content corresponding to the sentence component includes: identifying the text content of the target sentence component. Among them, the text content of all sentence components can be identified as needed, or the text content of a specified sentence component can be identified. The identification method can be to mark the text content of each sentence component on the sentence with a mark, and at the same time identify the sentence component to which it belongs under the corresponding mark. For example, circle the text content of the subject with a red frame, and mark it as the subject above the red frame. In this way, the text content of each sentence component can be seen intuitively. The identification method can also be to display the component identification and text content in the form of a list, and the text content is the attribute value of the component identification. For example, subject: He.
[0080] The above-mentioned sentence component identification method uses a trained sentence component model to output a sequence of sentence-level component labels. This sequence identifies the sentence component to which each word belongs and its position within that component. This allows the target component in the sentence to be identified based on the component label sequence, achieving sentence component identification. This method, which pre-trains the component identification model, allows for simple and convenient sentence component identification.
[0081] In one embodiment, Figure 4 As shown, the sentence component recognition method includes:
[0082] S402: Acquire a sentence and target sentence components to be recognized.
[0083] S404: Input the sentence into a pre-trained sentence component recognition model. The encoding layer of the sentence component recognition model outputs the word feature vector of each word in the sentence. The decoding layer of the sentence component recognition model decodes the word feature vector of each word to obtain a whole sentence-level component label sequence.
[0084] S406: Determine whether the sentence has complex components based on the entire sentence-level component label sequence.
[0085] Specifically, the entire sentence-level component label sequence is used to determine whether there is a sentence component with a character count greater than 1. If the entire sentence-level component label sequence determines that there is a sentence component with a character count greater than 1, then the sentence contains a complex component. If the entire sentence-level component label sequence determines that the character count of each sentence character is not greater than 1, then the sentence does not contain a complex component.
[0086] If not, execute step S407; if so, execute step S408.
[0087] S407 , obtaining text content corresponding to the target sentence component according to the sentence component to which each word in the sentence belongs, as identified by the entire sentence-level component label sequence, and the position of each word in the sentence component to which it belongs.
[0088] For sentences without complex components, the text content corresponding to the target sentence component is obtained based on the sentence component to which each word in the sentence belongs, as identified by the entire sentence-level component label sequence, and the position of each word in the sentence component to which it belongs.
[0089] S408, obtain the word feature vector of the complex component, decode the word feature vector of the complex component through the decoding layer, and obtain the subordinate component label sequence corresponding to each complex component; the subordinate component label sequence identifies the sentence component to which each word in the complex component belongs, and the position of each word in the sentence component to which it belongs.
[0090] For sentences with complex components, firstly, a complex sentence is obtained according to wherein a complex component of the whole sentence is a sentence component whose number of characters identified by the whole sentence level component label sequence is greater than 1.
[0091] Taking the sentence “He refused to talk about the sufferings he had during the disaster.” as an example, its entire sentence-level component label sequence is shown in Table 3:
[0092] Table 3 Sentence-level component label sequence
[0093] He refused to talk about the sufferings he had during the disaster . s-0 s-1 b-2 e-2 o o o b-3 i-3 i-3 i-3 e-3 o
[0094] Among them, the predicate component has two characters and the object component has five characters, so the predicate component and the object component are complex components in the first-level components.
[0095] The word feature vectors of each complex component in the first level component are added with start and end symbols at the beginning and end, and then decoded through the decoding layer to obtain the sub-level component label sequence for the complex components of the whole sentence, that is, the second-level component label sequence. It can be understood that each complex component has the number of second-level component label sequences. Figure 5 As shown in the figure, the first-level component analysis of the sentence "He refused to talk about the sufferings he had during the disaster." has two complex components, "to talk" and "he had during the disaster." After adding the start and end symbols to the word feature vectors of these two complex components, they are decoded by the decoding layer.
[0096] In this embodiment, the decoding layer uses CRF (conditional random field). CRF can learn the transfer relationship between labels from the data, and can also be set to a fixed value so that the model does not have similar illegal label sequences. Taking into account special cases, there may be different entity labels for the same start and end positions. An independent CRF structure can be used for each entity. However, this situation usually does not exist in component recognition tasks. Therefore, the same CRF is used for decoding all components to speed up the decoding speed. The parameters of CRF (transition matrix) are set to fixed, legal transitions are set to 0, and illegal transitions are set to -1e4.
[0097] In the CRF transfer matrix, the sequence from the one without the start and end symbols to the one with the start and end symbols is a legal transition, and the values in the transfer matrix are equal. If we continue to select the label with the largest score, we will only get the same sequence as the first-level component recognition. Therefore, we select the sequence with the second largest probability as the required result to obtain the secondary component label sequence of the complex component. For the complex components of the entire sentence, the secondary component label sequence is the second-level component label sequence. Figure 5 As shown, the second-level component label sequence corresponding to “to talk” is (O,O), and the second-level component label sequence corresponding to “he had during the disaster” is (S-0,S-1,B-4,I-4,E-4).
[0098] S410 , determining whether a corresponding complex component has a nested sentence component or whether the nested sentence component is a simple component based on the secondary component label sequence.
[0099] Specifically, if it is determined from the sub-level component label sequence that the corresponding complex component does not have any nested sentence components, that is, the analysis result of the sub-level component label sequence shows that the words including the complex component do not belong to any sentence component, such as the components obtained from the sub-level component label sequence are all other positions (O, O), such as the second-level component label sequence corresponding to "to talk" is (O, O)", then the analysis result of the complex component is determined to show that the complex component does not contain any nested sentence components, and there is no need to continue decoding. If no nested sentence components are included, execute step S412. If nested sentence components are included, continue to determine whether the nested sentence components are simple components.
[0100] A simple component is a sentence component whose nested components identified by the level component label sequence have only one character. Figure 5 As shown in the figure, the second-level component label sequence corresponding to "he had during the disaster" is (S-0, S-1, B-4, I-4, E-4), indicating that both the subject and predicate have only one character, and the nested subject and predicate are simple components. If the nested sentence component is larger than one character, it is a complex component. For example, if the adverbial consists of three characters, "during the disaster," then the adverbial is a complex component.
[0101] If the nested sentence component is a simple component, it means that there will be no nested sentence components under the sentence component, and step S412 is executed. If the nested sentence component is a complex component, it indicates that there may still be nested sentence components under the sentence component, and then return to step S408 to continue decoding the complex component until there is no nested sentence component in the complex component or the nested sentence component is a simple component.
[0102] S412, obtaining the text content corresponding to the target sentence component according to the output valid component label sequence, wherein the valid component label sequence includes a whole sentence level component label sequence, or a whole sentence level component label sequence and a sub-level component label sequence.
[0103] Among them, the output effective component label sequence refers to the whole sentence-level component label and clause-level component label with an effective component identification label sequence output by the decoding layer when the judgment result of step S410 is that the complex component does not have a nested sentence component or the nested sentence component is a simple component. The effective component identification label sequence refers to a component label sequence that only contains effective sentence components, that is, it does not contain a component identification label sequence whose sentence components are other categories.
[0104] Specifically, if the second-level component label sequence obtained by the second-level component analysis determines that there are no nested sentence components in the complex component, the second-level component label sequence is an invalid component label sequence, and the valid component label sequence that has been output is the whole-sentence component label sequence. In this case, the corresponding text content of the target sentence component is obtained based on the whole-sentence label sequence. For example, the whole-sentence component label sequence of the sentence "I like red apple" indicates the presence of the complex object component "redapple". In this case, "red apple" is further decoded through the decoding layer to obtain the second-level component label sequence (O, O). In this second-level component label sequence, no valid sentence components are included. In this case, the valid component label sequence includes the whole-sentence label sequence. Therefore, the corresponding text content of the target sentence component is obtained based on the whole-sentence label sequence.
[0105] If the second-level component label sequence obtained from the second-level component analysis is determined, and the nested sentence component of the complex component is a simple component, the output valid component label sequence includes the sentence-level component label sequence of the first-level component and the second-level component label sequence (i.e., the subordinate component label sequence). At this time, the corresponding text content of the target sentence component is obtained based on the sentence-level component label sequence and the subordinate component label sequence.
[0106] If the subordinate component label sequence obtained by the second-level component analysis determines that the nested sentence component is a complex component, the complex component needs to be decoded again to obtain the next clause-level component label sequence, that is, the third-level component label sequence. The judgment of S408 is continued for the third-level component label sequence until the complex component does not have a nested sentence component or the nested sentence component is a simple component. At this time, the output valid component label sequence includes the entire sentence-level label sequence and all valid clause-level label sequences. For example, if the judgment result of the third-level component label sequence is that the complex component does not have a nested sentence component, the output valid component label sequence includes the entire sentence-level component label sequence (first-level component label sequence) and the subordinate component label sequence (second-level component label sequence). If the judgment result of the third-level component label sequence is that the nested sentence component is a simple component, the output valid component label sequence includes the entire sentence-level component label sequence (first-level component label sequence) and the subordinate component label sequence (second-level component label sequence and third-level component label sequence).
[0107] Specifically, the whole sentence is identified according to the whole sentence-level component label sequence, and the text content corresponding to each sentence component is obtained according to the sentence component to which each word in the sentence belongs identified by the whole sentence-level component label sequence, as well as the position of each word in the sentence component to which it belongs. Then, the corresponding complex sentence is identified using the subordinate component label sequence, and the text content corresponding to the nested sentence components is obtained according to the sentence component to which each word in the complex component identified by the subordinate clause-level component label sequence, as well as the position of each word in the sentence component to which it belongs, thereby obtaining the text content corresponding to all the sentence components. The text content corresponding to the sentence components of the target sentence can be extracted as needed.
[0108] The above sentence component recognition method can recognize nested sentence components.
[0109] In one embodiment, the training process of the sentence component recognition model is as follows: Figure 6 As shown, the following steps are included:
[0110] S602, obtaining a sentence set for training, the sentence set includes training corpus of each sentence, the training corpus includes component label sequences graded according to nested relationship components, the component label sequences include whole sentence-level component label sequences, and sub-level component label sequences of nested complex components, each component label sequence includes the sentence component to which each word in the sentence belongs in the corresponding component grade, and the position of each word in the sentence component to which it belongs.
[0111] Specifically, the sentence training corpus is processed into sentence component identification data and integrated into the required format. The sentence component identification corpus can be a publicly available dataset on the Internet or a self-annotated dataset. Each sample in the dataset includes the sentence to be analyzed and its corresponding components. Common sentence components in English can be divided into: subject, predicate, object, predicative, attributive, adverbial, complement and appositive. The sample format is shown in Table 4:
[0112] Table 4. Corpus examples for sentence component recognition
[0113]
[0114] Specifically, obtaining a sentence set for training includes: obtaining a component hierarchy of sentences determined according to the nested relationship of sentences, the words corresponding to each sentence component in each component hierarchy, and the starting position and ending position of the sentence component; obtaining a whole sentence-level component label sequence and a sub-level component label sequence of nested complex components according to the words corresponding to each sentence component in each component hierarchy, and the starting position and ending position of the sentence component; constructing training corpus for each sentence component of the sentence as model input according to the whole sentence-level component label sequence and the nested component label sequence; and obtaining a training sentence set according to the training corpus of each sentence.
[0115] Among them, the sentence component recognition corpus is processed and integrated into the format required by the model.
[0116] Preprocess the sentence component recognition corpus, mainly including filtering out some special characters, such as non-ASCII characters, emoticons, etc. Replace URLs, phone numbers, dates, etc. with unified characters to filter out some illegal samples.
[0117] Based on the sequence tagging method, BIEOS is annotated for each token in the input text to extract the required blocks. For example, for the named entity task, BX represents the starting position of entity X, IX represents the middle position of entity X, and EX represents the end position of entity X. When entity X contains only one token, the token is annotated as SX, and other positions are annotated as O. Identifying entity X means extracting the block corresponding to X. For entities without nested structures, each character position has only one label; for entities with nested structures, there are cases where a character is assigned multiple labels. When there are clauses, the sentence component recognition task also contains nested structures. As shown in Table 5, the position of he had during the disaster has two labels.
[0118] Table 5 Example conversion sequence notation format (0-subject 1-verb 2-object 3-attributive 4-adverbial 5-predicate)
[0119] enter He refused to talk about the sufferings he had during the disaster . Annotation 1 s-0 s-1 b-2 e-2 o o o b-3 i-3 i-3 i-3 e-3 o Annotation 2 - - - - - - - s-0 s-1 b-4 i-4 e-4 -
[0120] The sentence component recognition method proposed in this application draws on the nested named entity recognition method to identify nested entities from the outside to the inside, and the input model samples need to be processed into the form of Table 6. During the training or testing process of the sentence component recognition model, the first-level component, that is, the whole sentence-level label sequence, is first identified through the sequence with the largest score, and then, based on the identified first-level component, the second-level component is identified through the sequence with the second largest score. Similarly, based on the sequence that has been identified at the second level, the third-level component is identified through the sequence with the second largest score, and so on, until the component contains only one character (that is, a simple component), or the labels are all other positions (that is, there is no sentence component with a bridge).
[0121] Table 6 Model input examples
[0122]
[0123] The above steps convert the original data of sentence components into the data format required by the model.
[0124] Step 604, the step of training the sentence component recognition model to be trained using the training sentence set, includes: inputting the training corpus of the sentences in the sentence set into the sentence component recognition model to be trained, the encoding layer of the sentence component recognition model outputting the word feature vector of each word in the sentence; the decoding layer of the sentence component recognition model decoding the word feature vector of each word to obtain a predicted component label sequence; and adjusting the sentence component recognition model based on the predicted component label sequence and the annotated component label sequence.
[0125] Specifically, using Figure 3 The sentence component recognition model shown in the figure is trained. The sentence is input into the encoding layer, which maps each word in the sentence to be analyzed into a context-dependent vector. This vector can be a combination of the outputs of multiple models (BERT+LSTM, CNN+LSTM). The decoding layer mainly decodes the vector corresponding to each character into the corresponding component label, generally using a CRF. The CRF can learn the transfer relationship between labels from the data and can also be set to a fixed value to prevent the model from generating illegal label sequences. Using the same CRF for decoding all components speeds up decoding. The parameters of the CRF (transition matrix) are set to be fixed, with legal transfers set to 0 and illegal transfers set to -1e4.
[0126] During the training phase, the sentence's annotation results determine the sentence's component hierarchy. In the decoding layer, due to the characteristics of the CRF transfer matrix, the values in the transfer matrix for legitimate transitions are equal. Therefore, if the label with the highest score is continued to be selected from the sub-component label sequence, the obtained label sequence will be the same as the first-level component identification. Therefore, the sub-component label sequence typically selects the sequence with the second highest probability as the desired result to obtain the second-level component. Based on this, according to the annotated component hierarchy, the predicted sentence-level label sequence (with the highest probability score) and clause-level label sequence (with the second highest probability score) can be obtained from the predicted component label sequence.
[0127] Furthermore, back propagation is performed based on the difference between the predicted sentence-level label sequence and the annotated sentence-level label sequence to adjust the parameters of the sentence component recognition model.
[0128] Among them, in the sequence labeling model of the sentence component recognition model, the label y corresponding to the i-th position i The score is φ(y i-1 ,y i ,z i ):
[0129]
[0130]
[0131] in, Indicates the label y corresponding to the i-th position i The score, For labels from y i-1 Transfer y i 's score. It is y i The corresponding trainable parameters, z i is the word vector of the i-th position output by the encoder. In order to ensure the decoding process, it is necessary to design a corresponding loss function:
[0132] L(θ)=-logp(Y|Z;θ)
[0133]
[0134] Among them, L 1st is the maximum likelihood probability of the optimal path, corresponding to the entire sentence level from the label sequence, L 2nd is the maximum likelihood probability of the second best path, corresponding to the clause-level component label sequence. l,j Represents the starting position of the jth sequence to be decoded at level l, e l,j Represents the end position of the jth sequence to be decoded at level l. The first level (sentence level) considers the entire text to be analyzed, so s 1,1 =1,e 1,1 =n,y 1,1 ,...,y 1,n is the first-level true annotation sequence. The start and end positions of the second level depend on the components identified in the first level. l,i represents the true BIEOS label at the i-th position at level l. Z is the encoder output, and θ is the parameter to be trained.
[0135] Calculate the first-level loss function, ζ s:e represents all possible sequences from position s to position e, ψ s:e (y,Z) is the score of the actual component label from position s to position e, ψ 1:n (y1, Z) is the score of the actual component label of the first level whole sentence, that is, s = 1, e = n. (EXP is an exponential function with e as the base, for example, exp(x) = e x ).
[0136]
[0137] y1=[y 1,1 ,y 1,2 ,...,y 1,n ]
[0138]
[0139] ys-1 =[S]
[0140] y e+1 =[E]
[0141] Calculate the second-level loss function, From position s l,j To position e l,j All possible sequences except the optimal path, is the score of the actual component label of the j-th sequence at level l.
[0142]
[0143] During the training process, the value of the loss function L(θ) is minimized, the model is trained, and the model with the best component recognition effect on the validation set is saved.
[0144] S606: When the training end condition is met, a trained sentence component recognition model is obtained.
[0145] Specifically, if the training termination condition is not met, the sentence component recognition model to be trained is iteratively trained using the training samples until the training termination condition is met, thereby obtaining a trained sentence component recognition model. The termination condition includes the number of iterations reaching the maximum number of iterations or the model output accuracy meeting the requirements.
[0146] This application proposes a sentence component identification method based on sequence annotation to directly extract the components of the sentence to be analyzed. For examples containing clause components, we draw on the method of nested named entity recognition to obtain the inner component by taking the sequence with the second highest decoding score. This method is simpler than the original method and achieves an F1 score of 95.62% on a self-compiled test set, demonstrating its effectiveness.
[0147] Consider the sentence "He refused to talk about the sufferings he had during the disaster." Through the encoding and decoding layers, we obtain the optimal path and the optimal sentence-level component label sequence: [S]s-0s-1b-2e-2o oo b-3i-3i-3i-3e-3o[E]. This is converted into the subject component "He," the predicate component "refused," the object component "to talk," and the attributive component "he had during the disaster." The object and attributive components contain complex components, so we add start and end symbols, respectively. The decoding layer decodes the complex components to obtain the second-level component label sequence.
[0148] For the first sequence to be analyzed at the second level, "to talk," the second-highest-scoring, second-best sequence is obtained as the subordinate-level label sequence, [S]oo[E]. No nested components are identified based on this sequence. For the second sequence to be analyzed at the second level, "he had during the disaster," the second-highest-scoring, second-best sequence is obtained, [S]s-0s-1b-4i-4e-4[E]. This sequence is converted to the subject component "he," the predicate component "had," and the adverbial component "during the disaster." This subordinate-level label sequence contains the nested complex component "during the disaster." Start and end symbols are added to it and decoded by the decoding layer to obtain the third-level component label sequence.
[0149] For the first sequence to be analyzed at the third level, the second-best sequence with the second highest score is obtained: [S]o oo[E], where all o's indicate no components were identified. At this point, component recognition is complete for the entire text. The final component recognition results are shown below.
[0150]
[0151] It should be understood that although Figure 2 、 4 The steps in the flowcharts of FIG6 and FIG7 are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and these steps can be executed in other orders. Figure 2 、 4 At least part of the steps in 6 may include multiple steps or multiple stages. These steps or stages do not necessarily have to be performed at the same time, but can be performed at different times. The order of execution of these steps or stages is not necessarily one by one, but can be performed in turn or alternately with other steps or at least part of the steps or stages in other steps.
[0152] In one embodiment, Figure 7 As shown, a sentence component recognition device is provided, comprising:
[0153] An input acquisition module 702 is used to acquire a sentence and a target sentence component to be recognized;
[0154] The component label sequence acquisition module 704 is configured to input the sentence into a pre-trained sentence component recognition model. The encoding layer of the sentence component recognition model outputs a word feature vector for each word in the sentence. The decoding layer of the sentence component recognition model decodes each word based on the word feature vector to obtain a whole-sentence component label sequence. The whole-sentence component label sequence identifies the sentence component to which each word in the sentence belongs and the position of each word within the sentence component to which it belongs.
[0155] Identification module 706 is used to obtain the text content corresponding to the target sentence component based on the sentence component to which each word in the whole sentence belongs, as identified by the whole sentence-level component label sequence, and the position of each word in the sentence component to which it belongs, if it is determined that the sentence does not have a complex component based on the whole sentence-level component label sequence.
[0156] The above-mentioned sentence component identification device uses a trained sentence component model to output a sequence of whole-sentence component labels. This whole-sentence component label sequence identifies the sentence component to which each word in the sentence belongs and the position of each word within the sentence component. Based on the component label sequence, the target component in the sentence can be obtained, achieving sentence component identification. This method, which can achieve sentence component identification by pre-training the component identification model, is simple to operate and highly convenient.
[0157] In one embodiment, the component label sequence acquisition module is further configured to, if it is determined that the sentence contains a complex component based on the whole sentence-level component label sequence, obtain a word feature vector of the complex component, decode the word feature vector of the complex component through the decoding layer, and obtain a sub-level component label sequence corresponding to each complex component; the sub-level component label sequence identifies the sentence component to which each word in the complex component belongs, and the position of each word in the sentence component to which it belongs;
[0158] The recognition module is also used to obtain the text content corresponding to the target sentence component based on the output valid component label sequence if it is determined based on the subordinate component label sequence that the complex component does not have a nested sentence component or the nested sentence component is a simple component, wherein the valid component label sequence includes the whole sentence-level component label sequence, or the whole sentence-level component label sequence and the subordinate component label sequence.
[0159] In another embodiment, the component label sequence identification module is further configured to, if the complex component contains nested complex components, decode the nested complex components to obtain subordinate component label sequences corresponding to each of the complex components.
[0160] In another embodiment, if it is determined according to the whole sentence-level component label sequence that a sentence contains a sentence component with a character count greater than 1, then the sentence contains a complex component.
[0161] In another embodiment, if the number of characters of the nested sentence component identified by the sub-level component label sequence is 1, the nested sentence component is a simple component; if the number of characters of the nested sentence component identified by the sub-level component label sequence is greater than 1, the nested sentence component is a complex component.
[0162] In another embodiment, the component identification device further includes: a sentence set acquisition module and a training module.
[0163] A sentence set acquisition module is used to acquire a sentence set for training, wherein the sentence set includes training corpus for each sentence, and the training corpus includes a component label sequence graded according to nested components, wherein the component label sequence includes a whole sentence-level component label sequence and a sub-level component label sequence of a nested complex component, and each component label sequence includes the sentence component to which each word in the sentence belongs in the corresponding component grade, and the position of each word in the sentence component to which it belongs;
[0164] A training module is used to input the training corpus of the sentences in the sentence set into the sentence component recognition model to be trained, and the encoding layer of the sentence component recognition model outputs the word feature vector of each word in the sentence; the decoding layer of the sentence component recognition model decodes according to the word feature vector of each word to obtain a predicted component label sequence, and adjusts the sentence component recognition model according to the predicted component label sequence and the marked component label sequence until the training end condition is met to obtain a trained sentence component recognition model.
[0165] In another embodiment, a sentence set acquisition module is used to obtain the component hierarchy of sentences determined according to the nested relationship of sentences, the words corresponding to each sentence component in each component hierarchy, and the starting position and ending position of the sentence component; according to the words corresponding to each sentence component in each component hierarchy, and the starting position and ending position of the sentence component, a whole sentence-level component label sequence and a sub-level component label sequence of the nested complex component are obtained; according to the whole sentence-level component label sequence and the nested component label sequence, training corpus for each sentence component of the sentence is respectively constructed for use as model input; according to the training corpus of each sentence, a training sentence set is obtained.
[0166] For the specific definition of the sentence component identification device, please refer to the definition of the sentence component identification method above, which will not be repeated here. The various modules in the above-mentioned sentence component identification device can be implemented in whole or in part by software, hardware, or a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
[0167] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Figure 8 As shown. The computer device includes a processor, a memory and a network interface connected via a system bus. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store a training sentence set and query data corresponding to sentence components. The network interface of the computer device is used to communicate with an external terminal via a network connection. When the computer program is executed by the processor, a sentence component recognition method is implemented.
[0168] Those skilled in the art will understand that Figure 8 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different component arrangement.
[0169] In one embodiment, a computer device is provided, including a memory and a processor. The memory stores a computer program, and the processor implements the steps of the methods of the above embodiments when executing the computer program.
[0170] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of the methods of the above embodiments are implemented.
[0171] Those skilled in the art will appreciate that all or part of the processes in the above-mentioned embodiment methods can be implemented by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application may include at least one of non-volatile and volatile memory. Non-volatile memory may include read-only memory (ROM), magnetic tape, floppy disk, flash memory or optical memory, etc. Volatile memory may include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM).
[0172] The technical features of the above embodiments can be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0173] The above-described embodiments merely represent several implementation methods of the present application. While the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the present invention. It should be noted that a person skilled in the art could make various modifications and improvements without departing from the spirit of the present application, all of which fall within the scope of protection of the present application. Therefore, the scope of protection of the present patent application shall be determined by the appended claims.
Claims
1. A method for identifying sentence components, the method comprising: Obtain a sentence and a target sentence component to be identified; The sentence is input into a pre-trained sentence component recognition model, and the encoding layer of the sentence component recognition model outputs the word feature vector of each word in the sentence; the decoding layer of the sentence component recognition model decodes the word feature vector of each word to obtain a whole sentence level component label sequence, and the whole sentence level component label sequence identifies the sentence component to which each word in the whole sentence belongs, and the position of each word in the sentence component to which it belongs; If it is determined according to the whole sentence-level component label sequence that the sentence does not have a complex component, then obtaining the text content corresponding to the target sentence component according to the sentence component to which each word in the whole sentence belongs, as identified by the whole sentence-level component label sequence, and the position of each word in the sentence component to which it belongs; If it is determined that the sentence contains a complex component based on the whole sentence component label sequence, then obtaining a word feature vector of the complex component, decoding the word feature vector of the complex component through the decoding layer, and obtaining a sub-level component label sequence corresponding to each complex component; the sub-level component label sequence identifies the sentence component to which each word in the complex component belongs, and the position of each word in the sentence component to which it belongs; If it is determined based on the subordinate component label sequence that the complex component does not have a nested sentence component or the nested sentence component is a simple component, then the text content corresponding to the target sentence component is obtained based on the output valid component label sequence, wherein the valid component label sequence includes the whole-sentence-level component label sequence, or the whole-sentence-level component label sequence and the subordinate component label sequence.
2. The method according to claim 1, characterized in that If the complex component contains nested complex components, the steps of obtaining the word feature vector of the complex component, decoding the word feature vector of the complex component through the decoding layer, and obtaining the subordinate component label sequence corresponding to each complex component are performed on the nested complex component, until the corresponding subordinate component label sequence indicates that the complex component does not contain nested sentence components or the nested sentence components are simple components.
3. The method according to claim 1, characterized in that If it is determined according to the whole sentence-level component label sequence that a sentence contains a sentence component with a character count greater than 1, then the sentence contains a complex component.
4. The method according to claim 1, wherein If the number of characters of the nested sentence component identified by the subordinate component label sequence is 1, the nested sentence component is a simple component; if the number of characters of the nested sentence component identified by the subordinate component label sequence is greater than 1, the nested sentence component is a complex component.
5. The method according to claim 1, wherein The method further comprises: Obtaining a sentence set for training, the sentence set including training corpus for each sentence, the training corpus including component label sequences graded according to nested components, the component label sequences including a whole sentence-level component label sequence and a sub-level component label sequence of a nested complex component, each component label sequence including the sentence component to which each word in the sentence belongs in the corresponding component grade, and the position of each word in the sentence component to which it belongs; The step of training a sentence component recognition model to be trained using the training sentence set includes: inputting training corpus of sentences in the sentence set into the sentence component recognition model to be trained, the encoding layer of the sentence component recognition model outputting a word feature vector of each word in the sentence; the decoding layer of the sentence component recognition model decoding according to the word feature vector of each word to obtain a predicted component label sequence; and adjusting the sentence component recognition model according to the predicted component label sequence and the annotated component label sequence; The step of training the sentence component recognition model to be trained by using the training sentence set is repeated until the training end condition is met, thereby obtaining a trained sentence component recognition model.
6. The method according to claim 5, characterized in that The acquiring of a sentence set for training includes: Obtaining the sentence component hierarchy determined based on the nested relationship of the sentences, the words corresponding to each sentence component in each component hierarchy, and the start and end positions of the sentence components; According to the words corresponding to each sentence component of each component level, as well as the starting position and ending position of the sentence component, the whole sentence level component label sequence and the sub-level component label sequence of the nested complex component are obtained; According to the whole sentence component label sequence and the nested component label sequence, constructing the training corpus for each sentence component as the model input; According to the training corpus described in each sentence, a training sentence set is obtained.
7. A sentence component recognition device, characterized in that: The device comprises: An input acquisition module is used to acquire sentences and target sentence components to be recognized; A component label sequence acquisition module is configured to input the sentence into a pre-trained sentence component recognition model, wherein the encoding layer of the sentence component recognition model outputs a word feature vector for each word in the sentence; the decoding layer of the sentence component recognition model decodes each word according to the word feature vector to obtain a whole-sentence component label sequence, wherein the whole-sentence component label sequence identifies the sentence component to which each word in the whole sentence belongs and the position of each word within the sentence component to which it belongs; an identification module configured to, if it is determined according to the whole sentence-level component label sequence that the sentence does not have a complex component, obtain text content corresponding to the target sentence component based on the sentence component to which each word in the whole sentence belongs, as identified by the whole sentence-level component label sequence, and the position of each word in the sentence component to which it belongs; The component label sequence acquisition module is further configured to, if it is determined that the sentence contains a complex component based on the whole-sentence component label sequence, obtain a word feature vector of the complex component, decode the word feature vector of the complex component through the decoding layer, and obtain a subordinate component label sequence corresponding to each complex component; the subordinate component label sequence identifies the sentence component to which each word in the complex component belongs, as well as the position of each word in the sentence component to which it belongs; The recognition module is also used to obtain the text content corresponding to the target sentence component based on the output valid component label sequence if it is determined based on the subordinate component label sequence that the complex component does not have a nested sentence component or the nested sentence component is a simple component, wherein the valid component label sequence includes the whole sentence-level component label sequence, or the whole sentence-level component label sequence and the subordinate component label sequence.
8. The device according to claim 7, characterized in that The component label sequence acquisition module is also used to: if the complex component has nested complex components, execute the steps of obtaining the word feature vector of the nested complex component, decode the word feature vector of the complex component through the decoding layer, and obtain the subordinate component label sequence corresponding to each complex component, until the corresponding subordinate component label sequence indicates that the complex component does not have a nested sentence component or the nested sentence component is a simple component.
9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
Citation Information
Patent Citations
Sentence meaning composition relationship lamination identification method based on central blocks
CN103177089A
Automated question generation using semantics and deep learning
US20190354848A1