Text plot extraction method, device, electronic device and storage medium
By coding and semantic understanding of the extracted text with multiple candidate plot texts, the problem of low accuracy and efficiency of text plot extraction is solved, and efficient and complete plot extraction is achieved.
Patent Information
- Application Number
- CN202111552724.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-17
- Publication Date
- 2025-08-01
- Estimated Expiration
- 2041-12-17
AI Technical Summary
In the prior art, the text plot extraction accuracy is low and the efficiency is low, making it easy to disassemble the complete plot into discontinuous plots.
By encoding and fusing the text to be extracted with the plot text of multiple candidate plots, the fusion features are obtained, and semantic understanding is carried out based on the fusion features, the plot extraction results are determined, and the plot extraction model is used for training and update.
It improves the accuracy and efficiency of plot extraction, ensures the integrity and continuity of plot extraction, and is suitable for various types of text plot extraction.
Smart Images

Figure CN114254590B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of natural language processing, and in particular, to a method, an apparatus, an electronic device, and a storage medium for text plot extraction. Background Art
[0002] Text plot extraction is to extract the plots corresponding to each clause from the text, so that the plots contained in the text can be quickly learned.
[0003] Currently, the text to be extracted is usually subjected to plot extraction by means of sequence labeling. Specifically, it includes: using the candidate plots of the text to be extracted as extraction labels, and then determining whether each character in the text to be extracted belongs to the extraction label, so as to obtain the plot extraction result. However, using the above method may disassemble a complete plot into multiple discontinuous plots, that is, the plot extraction accuracy is relatively low. Summary of the Invention
[0004] The present invention provides a method, an apparatus, an electronic device, and a storage medium for text plot extraction, so as to solve the defect of relatively low text plot extraction accuracy in the prior art.
[0005] The present invention provides a method for text plot extraction, including:
[0006] Determine the text to be extracted and the plot texts of a plurality of candidate plots corresponding to the text to be extracted;
[0007] Encode and fuse the text to be extracted with the plot texts of the plurality of candidate plots to obtain a fusion feature;
[0008] Based on the fusion feature, perform semantic understanding on the text to be extracted and each plot text respectively, to obtain the sentence representations of each clause in the text to be extracted and the plot representations of each plot text;
[0009] Based on the sentence representations of each clause and the text representations of each plot text, determine the plot extraction result of the text to be extracted.
[0010] According to the method for text plot extraction provided by the present invention, the performing semantic understanding on the text to be extracted based on the fusion feature to obtain the sentence representations of each clause in the text to be extracted includes:
[0011] Perform semantic encoding on the fusion text to obtain the word vectors of each word segment in each clause of the text to be extracted;
[0012] Based on the correlation between the word vectors in any clause, obtain the sentence representations of each clause in the text to be extracted.
[0013] A text plot extraction method provided by the present invention, obtaining the sentence representations of each clause in the text to be extracted based on the correlation between the word segmentation vectors in any clause, includes:
[0014] Based on the correlation between the word segmentation vectors in any clause, as well as the start identification vector and / or end identification vector of each clause, obtaining the sentence representations of each clause in the text to be extracted; the start identification vector and the end identification vector are obtained by performing semantic encoding on the fused text.
[0015] A text plot extraction method provided by the present invention, encoding and fusing the text to be extracted with the plot texts of the multiple candidate plots to obtain a fused feature, includes:
[0016] Concatenating the word segmentation representation of the text to be extracted with the text representations of multiple plot texts to obtain the fused feature.
[0017] A text plot extraction method provided by the present invention, determining the plot extraction result of the text to be extracted based on the sentence representations of each clause and the text representations of each plot text, includes:
[0018] Determining the semantic similarity between each clause and each plot text based on the sentence representations of each clause and the text representations of each plot text;
[0019] Determining the plot extraction result of the text to be extracted based on the semantic similarity between each clause and each plot text.
[0020] A text plot extraction method provided by the present invention, semantically understanding the text to be extracted and each plot text respectively based on the fused feature to obtain the sentence representations of each clause in the text to be extracted and the plot representations of each plot text; determining the plot extraction result of the text to be extracted based on the sentence representations of each clause and the text representations of each plot text, includes:
[0021] Based on the plot extraction model and the fused feature, semantically understanding the text to be extracted and each plot text respectively to obtain the sentence representations of each clause in the text to be extracted and the plot representations of each plot text, and determining the plot extraction result of the text to be extracted based on the sentence representations of each clause and the text representations of each plot text;
[0022] Wherein, the plot extraction model is trained based on the sample fused feature and its sample plot extraction result; the sample fused feature is obtained by encoding and fusing the sample extraction text and the sample plot text of the sample candidate plot.
[0023] A text plot extraction method provided by the present invention, after training the plot extraction model based on the sample fusion features and their sample plot extraction results, further includes:
[0024] When there is a new plot, obtain the new sample text, and perform encoding fusion on the new sample text and the new plot text to obtain new fusion features;
[0025] Input the new fusion features into the plot extraction model to obtain the new sample plot extraction results output by the plot extraction model;
[0026] Update the plot extraction model based on the new fusion features and the new sample plot extraction results.
[0027] According to a text plot extraction method provided by the present invention, the performing encoding fusion on the new sample text and the new plot text to obtain new fusion features includes:
[0028] Convert the new plot text into a translation text expressed in another language, and perform encoding fusion on each translation text and the new sample text respectively to obtain corresponding new fusion features, where the other language is a language other than the language applied by the new plot text.
[0029] The present invention also provides a text plot extraction device, including:
[0030] A text determination unit, configured to determine the text to be extracted and the plot texts of multiple candidate plots corresponding to the text to be extracted;
[0031] A text fusion unit, configured to perform encoding fusion on the text to be extracted and the plot texts of the multiple candidate plots to obtain fusion features;
[0032] A text representation unit, configured to perform semantic understanding on the text to be extracted and each plot text respectively based on the fusion features to obtain the sentence representations of each clause in the text to be extracted and the plot representations of each plot text;
[0033] A plot extraction unit, configured to determine the plot extraction results of the text to be extracted based on the sentence representations of each clause and the text representations of each plot text.
[0034] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored on the memory and executable on the processor, where when the processor executes the program, the steps of any one of the above-mentioned text plot extraction methods are implemented.
[0035] The present invention also provides a non-transitory computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the text plot extraction method described in any one of the above are implemented.
[0036] The present invention also provides a computer program product, including a computer program. When the computer program is executed by a processor, the steps of the text plot extraction method described in any one of the above are implemented.
[0037] The text plot extraction method, device, electronic device, and storage medium provided by the present invention encode and fuse the text to be extracted with the plot texts of multiple candidate plots to obtain a fusion feature, so that the semantic understanding of the text to be extracted and multiple plot texts can be performed simultaneously based on the fusion feature, thereby improving the plot extraction efficiency. In addition, the present invention performs semantic understanding on the text to be extracted and multiple plot texts based on the fusion feature, so as to realize plot extraction from the overall semantic level of the text to be extracted, thereby ensuring the integrity and continuity of plot extraction. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following will briefly introduce the drawings required for the description of the embodiments or the prior art. Obviously, the drawings in the following description are some embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.
[0039] Figure 1 is a flowchart of the text plot extraction method provided by the present invention;
[0040] Figure 2 is a flowchart of the implementation manner of step 130 in the text plot extraction method provided by the present invention;
[0041] Figure 3 is a flowchart of the implementation manner of step 140 in the text plot extraction method provided by the present invention;
[0042] Figure 4 is a schematic diagram of the structure of the plot extraction model provided by the present invention;
[0043] Figure 5 is a flowchart of the method for updating the plot extraction model provided by the present invention;
[0044] Figure 6 is a schematic diagram of the structure of the text plot extraction device provided by the present invention;
[0045] Figure 7 is a schematic diagram of the structure of the electronic device provided by the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0046] To make the objectives, technical solutions and advantages of the present invention clearer, the technical solutions in the present invention will be clearly and completely described below with reference to the accompanying drawings in the present invention. Obviously, the described embodiments are some, but not all, of the embodiments of the present invention. All other embodiments obtained by those of ordinary skill in the art based on the embodiments in the present invention without making creative efforts shall fall within the protection scope of the present invention.
[0047] Currently, when extracting the plot from the text to be extracted, the candidate plots of the text to be extracted are mostly used as extraction labels through the sequence annotation method, and then it is determined whether each character in the text to be extracted belongs to the extraction label, so as to obtain the plot extraction result. However, the same plot may correspond to several clauses, and using the above method may disassemble a complete plot into multiple discontinuous plots, that is, the plot extraction accuracy is relatively low.
[0048] In addition, in the traditional method, the method of reading comprehension of the text to be extracted is also used for plot extraction, that is, the text to be extracted and the plot text of the candidate plots are input into the reading comprehension model, and the reading comprehension model determines the probability that the text to be extracted belongs to the corresponding candidate plot, so as to obtain the plot extraction result. However, when there are multiple candidate plots, such as when there are 10 candidate plots, it is necessary to input the text to be extracted and each plot text into the reading comprehension model 10 times to obtain the probability that the text to be extracted belongs to each candidate plot, and the plot extraction efficiency is relatively low.
[0049] In response to this, the present invention provides a text plot extraction method. This method can be applied to the plot extraction of the text for answering read-after-writing questions, and can also be applied to the plot extraction of other types of texts, such as the plot extraction of story texts, etc. For the convenience of explanation, the following embodiments will take the plot extraction of the text for answering read-after-writing questions as an example for illustration. Read-after-writing requires continuing to write a short passage with logical connection, complete plot and structure based on the given language material, the given beginning of the paragraph and the marked keywords. Figure 1 is a schematic flow chart of the text plot extraction method provided by the present invention, as Figure 1 shown, this method includes:
[0050] Step 110, determine the text to be extracted and the plot texts of multiple candidate plots corresponding to the text to be extracted.
[0051] Here, the text to be extracted is the text for which plot extraction is required. The text to be recognized can be directly input by the user, or can be obtained by speech transcription of the collected audio, or can also be obtained by collecting images through image collection devices such as scanners, mobile phones, cameras, etc. and performing OCR character recognition on the images. The embodiments of the present invention do not make specific limitations in this regard.
[0052] The text to be extracted can be understood as the answer text for continuation writing. According to the content logic of the given language material corresponding to the text to be extracted, the plot texts of multiple candidate plots corresponding to the text to be extracted can be determined. For example, according to the content logic of the given language material, if the key sentence of the given language material is "Then Janey called the police on the telephone", then when doing continuation writing based on this given material, the plot texts of the candidate plots that may be involved include "Why call the police", "What did she say", "What’s the result", etc.
[0053] Step 120: Code and fuse the text to be extracted with the plot texts of multiple candidate plots to obtain fused features.
[0054] Step 130: Based on the fused features, perform semantic understanding on the text to be extracted and each plot text respectively to obtain the sentence representations of each clause in the text to be extracted and the plot representations of each plot text.
[0055] Specifically, after coding and fusing the text to be extracted with the plot texts of multiple candidate plots, the obtained fused features can contain both the information of the text to be extracted and the information of multiple plot texts. Optionally, the word representations of each word in the text to be extracted can be fused with the text representations of multiple plot texts to obtain fused features. Among them, when coding and fusing the text to be extracted with the plot texts of multiple candidate plots, the text to be extracted can be coded and fused with at least two plot texts, or the text to be extracted can be coded and fused with all plot texts.
[0056] After obtaining the fused features, since the fused features contain the information of the text to be extracted and the information of multiple plot texts, semantic understanding can be performed on the text to be extracted and each plot text based on the fused features to obtain the sentence representations of each clause in the text to be extracted and the plot representations of each plot text. Among them, the sentence representations of each clause are used to describe the semantic information of each clause in the text to be extracted, and the plot representations of each plot text are used to describe the semantic information of each plot text.
[0057] Optionally, the fused features can be input into a reading comprehension model, and the reading comprehension model performs semantic understanding on the text to be extracted and each plot text to obtain the sentence representations of each clause in the text to be extracted and the plot representations of each plot text.
[0058] Step 140: Based on the sentence representations of each clause and the text representations of each plot text, determine the plot extraction result of the text to be extracted.
[0059] Specifically, since the sentence representation of each clause is used to describe the semantic information of each clause in the text to be extracted, and the plot representation of each plot text is used to describe the semantic information of each plot text, the semantic similarity between each clause and each plot text can be determined based on the sentence representation of each clause and the plot representation of each plot text. The higher the semantic similarity, the higher the probability that the corresponding clause belongs to the candidate plot corresponding to the plot text; the lower the semantic similarity, the lower the probability that the corresponding clause belongs to the candidate plot corresponding to the plot text.
[0060] On this basis, the probability that each sentence in the text to be extracted belongs to each candidate plot can be obtained, and the candidate plot corresponding to the maximum probability can be used as the plot to which the corresponding sentence belongs, and then the plot to which each sentence in the text to be extracted belongs can be obtained, and the plot to which each sentence belongs can be used as the plot extraction result. Alternatively, the probability that each sentence belongs to each candidate plot can be directly used as the plot extraction result. The embodiment of the present invention does not make specific limitations on this.
[0061] Compared to traditional methods that use sequence annotation, which can potentially break down a complete plot into multiple discrete plots, the present invention employs semantic understanding of both the text to be extracted and the individual plot texts, thereby extracting plots from the overall semantics of the text to be extracted, thereby ensuring the integrity and continuity of the extracted plots. Compared to traditional methods that feed the text to be extracted and the plot text of a candidate plot into the reading comprehension model one at a time, resulting in low plot extraction efficiency, the present invention, based on feature fusion, achieves semantic understanding of both the text to be extracted and multiple plot texts simultaneously, significantly improving plot extraction efficiency.
[0062] The text plot extraction method provided by the embodiments of the present invention fuses the text to be extracted with the plot texts of multiple candidate plots to generate fused features. This fused features can then be used to simultaneously perform semantic understanding of the text to be extracted and the multiple plot texts, thereby improving plot extraction efficiency. Furthermore, the embodiments of the present invention use the fused features to perform semantic understanding of the text to be extracted and the multiple plot texts, thereby achieving plot extraction from the overall semantic level of the text to be extracted, thereby ensuring the integrity and continuity of the plot extraction.
[0063] Based on the above embodiments, Figure 2 1 is a flow chart of an implementation of step 130 in the text plot extraction method provided by the present invention, as shown in FIG. Figure 2 As shown, in step 130, semantic understanding of the text to be extracted is performed based on the fusion features to obtain sentence representations of each clause in the text to be extracted, including:
[0064] Step 131: semantically encode the fused text to obtain the word vectors of each sentence in the text to be extracted;
[0065] Step 132: Obtain the sentence representations of each clause in the text to be extracted based on the correlation between the token vectors in any clause.
[0066] Specifically, perform semantic encoding on the fused text, so that based on the context semantic information of each token in each clause of the text to be extracted, obtain the token vectors for characterizing the semantic information of each token in each clause.
[0067] Meanwhile, since the correlation between the token vectors in any clause is used to characterize the importance of each token in the corresponding clause, the higher the correlation, the higher the importance of the corresponding token in the clause, and the lower the correlation, the lower the importance of the corresponding token in the clause. Therefore, the sentences of each clause determined based on the correlation between the token vectors in any clause can combine the semantic information of each token and the importance of each token in the clause to express the information of the corresponding clause, that is, can accurately obtain the sentence representations of each clause in the text to be extracted.
[0068] Optionally, based on the correlation between the token vectors in any clause, determine the importance of each token in the corresponding clause, and use this importance as a weight to perform weighted fusion on the token vectors in the clause, so as to obtain the sentence representations of each clause in the text to be extracted.
[0069] It can be seen that the embodiment of the present invention is based on the correlation between the token vectors in any clause, and thus can accurately obtain the sentence representations of each clause by combining the semantic information of each token and the importance of each token in the clause.
[0070] Based on any of the above embodiments, step 132 includes:
[0071] Obtain the sentence representations of each clause in the text to be extracted based on the correlation between the token vectors in any clause, and the start identification vector and / or end identification vector of each clause; the start identification vector and end identification vector are obtained by performing semantic encoding on the fused text.
[0072] Specifically, when performing semantic encoding on the fused text, not only can the token vectors of each clause in the text to be extracted be determined, but also the start identification vector and / or end identification vector of each clause can be determined. Among them, the start identification vector of each clause is used to characterize the start position of each clause, and the end identification vector of each clause is used to characterize the end position of each clause.
[0073] Meanwhile, since the correlation between the token vectors in any clause is used to characterize the importance of each token in the corresponding clause, the attention representation of each clause that combines the semantic information of each token and the importance information of each token in the corresponding clause can be obtained based on the importance of each token in the corresponding clause. Then, by combining the start identification vector and / or end identification vector of each clause, the sentence representation of each clause in the text to be extracted is obtained.
[0074] It can be understood that the attention representation h of each clause can be used as and the start identification vector h of each clause ss to obtain the sentence representation h of the corresponding clause s = h as + h ss . It can also be based on the attention representation h of each clause as and the end identification vector h of each clause se to obtain the sentence representation h of the corresponding clause s = h as + h se . It can also be based on the attention representation h of each clause as , the start identification vector h of each clause ss and the end identification vector h of each clause se to obtain the sentence representation h of the corresponding clause s = h as + h ss + h se .
[0075] It can be seen that the embodiment of the present invention is based on the correlation between the token vectors in any clause, as well as the start identification vector and / or end identification vector of each clause, so that the importance of each token in the clause and the start position and / or end position of each clause can be combined to obtain the sentence representation of each clause in the text to be extracted.
[0076] Based on any of the above embodiments, step 120 includes:
[0077] Concatenate the token representation of the text to be extracted with the text representations of multiple scenario texts to obtain a fused feature.
[0078] Specifically, the tokenized representation of the text to be extracted contains the feature information of each token in the text to be extracted, and the text representation of each plot text contains the text feature information of each plot text. Therefore, after encoding and fusing the tokenized representation of the text to be extracted with the text representations of multiple plot texts, the resulting fused features can contain both the feature information of each token in the text to be extracted and the text feature information of multiple plot texts. Subsequently, when semantically understanding the text to be extracted and each plot text based on the fused features, the sentence representations of each clause in the text to be extracted and the plot representations of each plot text can be accurately obtained.
[0079] Based on any of the above embodiments, Figure 3 is a schematic flowchart of the implementation manner of step 140 in the text plot extraction method provided by the present invention, as Figure 3 shown, step 140 includes:
[0080] Step 141, based on the sentence representations of each clause and the text representations of each plot text, determine the semantic similarity between each clause and each plot text;
[0081] Step 142, based on the semantic similarity between each clause and each plot text, determine the plot extraction result of the text to be extracted.
[0082] Specifically, since the sentence representations of each clause are used to describe the semantic information of each clause in the text to be extracted, and the plot representations of each plot text are used to describe the semantic information of each plot text, the semantic similarity between each clause and each plot text can be determined based on the sentence representations of each clause and the plot representations of each plot text. The higher the semantic similarity, the higher the probability that the corresponding clause belongs to the corresponding candidate plot of the plot text; the lower the semantic similarity, the lower the probability that the corresponding clause belongs to the corresponding candidate plot of the plot text.
[0083] On this basis, the probability that each clause in the text to be extracted belongs to each candidate plot can be obtained. The candidate plot corresponding to the maximum probability can be used as the belonging plot of the corresponding clause, and then the belonging plots of each clause in the text to be extracted can be obtained, and the belonging plots of each clause are used as the plot extraction result. Alternatively, the probabilities that each clause belongs to each candidate plot can be directly used as the plot extraction result. The embodiments of the present invention do not make specific limitations on this.
[0084] It can be seen that the embodiments of the present invention can accurately determine the semantic similarity between each clause and each plot text based on the semantic information of each clause in the sentence representation of each clause and the semantic information of each plot text in each text representation. Therefore, based on the semantic similarity between each clause and each plot text, the plot extraction result of the text to be extracted can be accurately obtained.
[0085] Based on any of the above embodiments, in steps 120 and 130, semantic understanding is performed on the text to be extracted and each plot text respectively based on the fusion features, to obtain the sentence representations of each clause in the text to be extracted and the plot representations of each plot text; based on the sentence representations of each clause and the text representations of each plot text, the plot extraction result of the text to be extracted is determined, including:
[0086] Based on the plot extraction model and the fusion features, semantic understanding is performed on the text to be extracted and each plot text respectively, to obtain the sentence representations of each clause in the text to be extracted and the plot representations of each plot text, and based on the sentence representations of each clause and the text representations of each plot text, the plot extraction result of the text to be extracted is determined;
[0087] Among them, the plot extraction model is trained based on the sample fusion features and their sample plot extraction results; the sample fusion features are obtained by encoding and fusing the sample extraction text and the sample plot text of the sample candidate plots.
[0088] Specifically, the fusion features contain the information of the text to be extracted and the information of multiple plot texts, so that the plot extraction model can perform semantic understanding on the text to be extracted and each plot text based on the fusion features, accurately obtain the sentence representations of each clause in the text to be extracted and the plot representations of each plot text, and accurately determine the plot extraction result of the text to be extracted based on the sentence representations of each clause and the text representations of each plot text.
[0089] In addition, before performing semantic understanding on the text to be extracted and each plot text based on the plot extraction model, the plot extraction model can be pre-trained, which can be specifically implemented by performing the following steps: First, a large number of sample fusion features are collected, and their corresponding sample plot extraction results are determined through manual annotation. Then, the initial model is trained based on the sample fusion features and their sample plot extraction results, so as to obtain the plot extraction model. Among them, the sample fusion features are obtained by encoding and fusing the sample extraction text and the sample plot text of the sample candidate plots.
[0090] Figure 4 is a schematic diagram of the plot extraction model structure provided by the present invention, as Figure 4As shown in the figure, the event extraction model is constructed based on the language model BERT (Bidirectional Encoder Representations from Transformers). First, determine the text to be extracted and the event texts corresponding to the candidate events of the text to be extracted. Then, splice the tokenized representation of the text to be extracted with the text representations corresponding to each event text to obtain a fused feature. Input the fused feature into the semantic understanding layer of the event extraction model to obtain the event representations of each event text output by the semantic understanding layer and the initial sentence representations of each clause in the text to be extracted. Next, input the initial sentence representations of each clause into the attention layer of the event extraction model to obtain the attention representations of each clause, and combine the start identification vector and the end identification vector of each clause to determine the sentence representation of each clause. Finally, input the sentence representations of each clause and the event representations of each event text into the event extraction layer of the event extraction model. The event extraction layer performs a dot product of the sentence representation of each clause with the event representation of each event text respectively to determine the probability that each clause belongs to each candidate event, and use the candidate event corresponding to the maximum probability as the event of the corresponding clause, and then output the event extraction result.
[0091] It can be seen that in the embodiment of the present invention, by encoding and fusing the text to be extracted with the event texts of multiple candidate events, a fused feature is obtained, so that the semantic understanding of the text to be extracted and multiple event texts can be simultaneously performed based on the fused feature, thereby improving the event extraction efficiency. In addition, in the embodiment of the present invention, the semantic understanding of the text to be extracted and multiple event texts is performed based on the fused feature, so as to realize event extraction from the overall semantic level of the text to be extracted, thereby ensuring the integrity and continuity of event extraction.
[0092] Based on any of the above embodiments Figure 5 is a schematic flowchart of the method for updating the event extraction model provided by the present invention. As Figure 5 shown, the method for updating the event extraction model includes:
[0093] Step 510: After training the event extraction model based on the sample fused feature and its sample event extraction result, when there is a new event, obtain the new sample text, and perform encoding and fusion on the new sample text and the new event text to obtain a new fused feature;
[0094] Step 520: Input the new fused feature into the event extraction model to obtain the new sample event extraction result output by the event extraction model;
[0095] Step 530: Update the event extraction model based on the new fused feature and the new sample event extraction result.
[0096] Specifically, when there are new plot elements, since the plot extraction model trained based on the sample fusion features and their sample plot extraction results before did not learn the information of the text corresponding to the new plot elements, the plot extraction model cannot accurately extract the plots from the text to be extracted that contains the new plot elements. At this time, it is necessary to update the plot extraction model.
[0097] Therefore, when there are new plot elements, obtain the new sample text. Some clauses in the new sample text may contain new plot elements, and some clauses may not. Then, encode and fuse the new sample text and the new plot text to obtain the new fusion features. After obtaining the new fusion features, input the new fusion features into the plot extraction model, so that the plot extraction model can determine the probability that each clause in the new sample text belongs to the new plot element, and then obtain the new sample plot extraction result.
[0098] After obtaining the new sample plot extraction result, it is possible to label the clauses in the new sample text that correspond to the new plot elements. Then, use the new sample plot extraction result as the sample label and the corresponding new fusion features as the samples, and input them into the plot extraction model to update the plot extraction model.
[0099] Since the updated plot extraction model learns the information of the text corresponding to the new plot elements, the updated plot extraction model can accurately extract the plots from the text that contains the new plot elements, and then obtain the plot extraction result.
[0100] Based on any of the above embodiments, in step 510, encoding and fusing the new sample text and the new plot text to obtain the new fusion features includes:
[0101] Convert the new plot text into a translation text expressed in another language, and encode and fuse each translation text with the new sample text respectively to obtain the corresponding new fusion features. The other language is a language other than the language in which the new plot text is expressed.
[0102] Specifically, in order to enable the plot extraction model to better learn the information of the text corresponding to the new plot elements and improve the generalization ability of the model, the embodiments of the present invention convert the new plot text into a translation text expressed in another language, and encode and fuse each translation text with the new sample text respectively to obtain the corresponding new fusion features. Among them, the new plot text can be converted into a translation text expressed in one other language. For example, convert the new plot text expressed in Chinese into a translation text expressed in English, or it can be converted into translation texts expressed in multiple other languages. For example, convert the new plot text expressed in Chinese into translation texts expressed in English, French, and German. The embodiments of the present invention do not make specific limitations on this.
[0103] For example, for the newly added plot text "What is my reaction to my brother's leaving", it can be converted into multiple translated texts expressed in English. For example, it can be converted into three translated texts in English: "What is my reaction to my brother’s leaving", "My brother left. How do I think", and "How do I react to my brother’s leaving". Then, each translated text is respectively encoded and fused with the newly added plot text to obtain the newly added fusion features corresponding to each translated text. Based on the newly added fusion features corresponding to each translated text, the result of newly added plot extraction is determined. Finally, based on the result of newly added plot extraction corresponding to each translated text and its corresponding newly added fusion features, the plot extraction model is updated.
[0104] As can be seen, the embodiment of the present invention converts the newly added plot text into translated texts expressed in other languages, so that the plot extraction model can be updated based on the results of newly added plot extraction corresponding to each translated text, improving the generalization ability of the model. Furthermore, the updated plot extraction model can more accurately extract the plot of the text containing the newly added plot to obtain the plot extraction result.
[0105] Based on any of the above embodiments, the present invention further provides a text plot extraction method, which is applied to extract the plot of the answer text for continuation writing. Specifically, it includes:
[0106] Taking the answer text for continuation writing as the text to be extracted, and determining the plot text corresponding to the candidate plot of the answer text. For example, according to the content logic in the given material for continuation writing, the plot texts corresponding to the candidate plots include "What is my reaction to my brother's leaving", "How am I saved", "What is my mother's reaction to this matter", and "What lesson do I learn".
[0107] Then, the tokenized representation of the text to be extracted and the text representations of each plot text are concatenated to obtain the fusion features, and the fusion features are input into the plot extraction model. The plot extraction model performs semantic understanding on the text to be extracted and each plot text to obtain the sentence representations of each clause in the text to be extracted and the plot representations of each plot text. Then, based on the sentence representations of each clause and the plot representations of each plot text, the probability that each clause belongs to each candidate plot is determined, and the candidate plot corresponding to the maximum probability is used as the plot of each clause to obtain the plot extraction result. Among them, the sentence representation of each clause in the text to be extracted is obtained after attention calculation on the initial sentence representation of each clause obtained after semantic understanding of the text to be extracted.
[0108] In addition, when there are new plot elements, obtain the answer text containing the new plot elements as the new sample text. After converting the new plot element text into multiple translated texts in English, fuse each translated text with the new sample text encoding respectively to obtain the corresponding new fused features. Then, input the new fused features into the plot extraction model to obtain the new sample plot extraction result. Thus, based on the new fused features and the new sample plot extraction result, the plot extraction model can be updated, so that the updated plot extraction model can accurately extract the plot of the answer text containing new plot elements.
[0109] In addition, after the embodiments of the present invention extract the plots of the answer texts for read - on - writing, teachers can display the answer texts containing the same plots to master the learning situation of the class. At the same time, the answer texts can be classified according to different plots, and the excellent answer texts in the same plot can be recommended to students for learning to help students learn.
[0110] The text plot device provided by the present invention will be described below. The text plot device described below can be correspondingly referred to the text plot method described above.
[0111] Based on any of the above - mentioned embodiments, Figure 6 is the structural diagram of the text plot extraction device provided by the present invention, as Figure 6 shown. The device includes:
[0112] A text determination unit 610, configured to determine the text to be extracted and the plot texts of multiple candidate plots corresponding to the text to be extracted;
[0113] A text fusion unit 620, configured to encode and fuse the text to be extracted with the plot texts of the multiple candidate plots to obtain fused features;
[0114] A text representation unit 630, configured to perform semantic understanding on the text to be extracted and each plot text respectively based on the fused features to obtain the sentence representations of each clause in the text to be extracted and the plot representations of each plot text;
[0115] A plot extraction unit 640, configured to determine the plot extraction result of the text to be extracted based on the sentence representations of each clause and the text representations of each plot text.
[0116] Based on any of the above - mentioned embodiments, the text representation unit 630 includes:
[0117] A word - segmentation representation unit, configured to perform semantic encoding on the fused text to obtain the word - vector of each word segment of each clause in the text to be extracted;
[0118] A sentence representation unit, configured to obtain the sentence representations of the clauses in the text to be extracted based on the correlation between the word segmentation vectors in any clause.
[0119] Based on any of the above embodiments, the sentence representation unit is configured to:
[0120] Based on the correlation between the word segmentation vectors in any clause, as well as the start identification vector and / or end identification vector of each clause, obtain the sentence representations of the clauses in the text to be extracted; the start identification vector and the end identification vector are obtained by performing semantic encoding on the fused text.
[0121] Based on any of the above embodiments, the text fusion unit 620 is configured to:
[0122] Concatenate the word segmentation representation of the text to be extracted with the text representations of multiple plot texts to obtain the fused feature.
[0123] Based on any of the above embodiments, the plot extraction unit 640 includes:
[0124] A semantic determination unit, configured to determine the semantic similarity between each clause and each plot text based on the sentence representation of each clause and the text representation of each plot text;
[0125] A result determination unit, configured to determine the plot extraction result of the text to be extracted based on the semantic similarity between each clause and each plot text.
[0126] Based on any of the above embodiments, the text representation unit 630 and the plot extraction unit 640 are configured to:
[0127] Based on the plot extraction model and the fused feature, respectively perform semantic understanding on the text to be extracted and each plot text, obtain the sentence representations of the clauses in the text to be extracted, as well as the plot representations of each plot text, and determine the plot extraction result of the text to be extracted based on the sentence representations of the clauses and the text representations of each plot text;
[0128] Wherein, the plot extraction model is trained based on the sample fused feature and its sample plot extraction result; the sample fused feature is obtained by encoding and fusing the sample extraction text and the sample plot text of the sample candidate plot.
[0129] Based on any of the above embodiments, the apparatus further includes:
[0130] A new fusion unit, configured to, after training the plot extraction model based on the sample fused feature and its sample plot extraction result, when there is a new plot, obtain the new sample text, and perform encoding and fusion on the new sample text and the new plot text to obtain the new fused feature;
[0131] A new extraction unit is used to input the new fusion feature into the plot extraction model to obtain the new sample plot extraction result output by the plot extraction model;
[0132] A model update unit is used to update the plot extraction model based on the new fusion feature and the new sample plot extraction result.
[0133] Based on any of the above embodiments, the new fusion unit is used for:
[0134] Convert the new plot text into a translation text expressed in another language, and respectively encode and fuse each translation text with the new sample text to obtain the corresponding new fusion feature, where the other language is a language other than the language applied by the new plot text.
[0135] Figure 7 It is a schematic structural diagram of an electronic device provided by the present invention. As Figure 7 shown, the electronic device may include: a processor 710, a memory 720, a communication interface 730, and a communication bus 740. Among them, the processor 710, the memory 720, and the communication interface 730 complete mutual communication through the communication bus 740. The processor 710 can call the logical instructions in the memory 720 to execute a text plot extraction method, which includes: determining the text to be extracted and the plot texts of a plurality of candidate plots corresponding to the text to be extracted; encoding and fusing the text to be extracted with the plot texts of the plurality of candidate plots to obtain a fusion feature; based on the fusion feature, respectively performing semantic understanding on the text to be extracted and each plot text to obtain the sentence representation of each clause in the text to be extracted and the plot representation of each plot text; based on the sentence representation of each clause and the text representation of each plot text, determining the plot extraction result of the text to be extracted.
[0136] In addition, when the logical instructions in the above-mentioned memory 720 are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The foregoing storage medium includes: various media such as USB flash drives, mobile hard disks, read-only memories (ROM, Read-Only Memory), random access memories (RAM, Random Access Memory), magnetic disks, or optical discs that can store program codes.
[0137] On the other hand, the present invention also provides a computer program product. The computer program product includes a computer program stored on a non-transitory computer-readable storage medium. The computer program includes program instructions. When the program instructions are executed by a computer, the computer can execute the text plot extraction method provided by the above-mentioned various methods. The method includes: determining the text to be extracted and the plot texts of a plurality of candidate plots corresponding to the text to be extracted; encoding and fusing the text to be extracted with the plot texts of the plurality of candidate plots to obtain a fusion feature; based on the fusion feature, respectively performing semantic understanding on the text to be extracted and each plot text to obtain the sentence representations of each clause in the text to be extracted and the plot representations of each plot text; and based on the sentence representations of each clause and the text representations of each plot text, determining the plot extraction result of the text to be extracted.
[0138] On another aspect, the present invention also provides a non-transitory computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, it is implemented to execute the text plot extraction method provided by the above-mentioned various methods. The method includes: determining the text to be extracted and the plot texts of a plurality of candidate plots corresponding to the text to be extracted; encoding and fusing the text to be extracted with the plot texts of the plurality of candidate plots to obtain a fusion feature; based on the fusion feature, respectively performing semantic understanding on the text to be extracted and each plot text to obtain the sentence representations of each clause in the text to be extracted and the plot representations of each plot text; and based on the sentence representations of each clause and the text representations of each plot text, determining the plot extraction result of the text to be extracted.
[0139] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed to multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the solution of this embodiment. Those of ordinary skill in the art can understand and implement it without creative effort.
[0140] Through the description of the above embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on such an understanding, the essence of the above technical solution, or the part that contributes to the prior art, can be embodied in the form of a software product. The computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to enable a computer device (which can be a personal computer, server, or network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0141] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit them. Although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions recorded in the foregoing embodiments, or perform equivalent replacements for some of the technical features. And these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for extracting text plots, characterized in that, Including: Determine the text to be extracted and the plot texts of multiple candidate plots corresponding to the text to be extracted; Perform encoding fusion on the text to be extracted and the plot texts of the multiple candidate plots to obtain a fusion feature; Based on the fusion feature, perform semantic understanding on the text to be extracted and each plot text respectively to obtain the sentence representations of each clause in the text to be extracted and the plot representations of each plot text; Based on the sentence representations of each clause and the text representations of each plot text, determine the plot extraction result of the text to be extracted; The performing semantic understanding on the text to be extracted based on the fusion feature to obtain the sentence representations of each clause in the text to be extracted includes: Perform semantic encoding on the fusion feature to obtain the word vector of each word segment in each clause of the text to be extracted; Based on the correlation between the word vectors in any clause, obtain the sentence representation of each clause in the text to be extracted.
2. The text plot extraction method according to claim 1, wherein The obtaining the sentence representation of each clause in the text to be extracted based on the correlation between the word vectors in any clause includes: Based on the correlation between the word vectors in any clause, and the start identification vector and / or end identification vector of each clause, obtain the sentence representation of each clause in the text to be extracted; the start identification vector and the end identification vector are obtained by performing semantic encoding on the fusion feature.
3. The text plot extraction method according to any one of claims 1 to 2, characterized in that, The performing encoding fusion on the text to be extracted and the plot texts of the multiple candidate plots to obtain a fusion feature includes: Concatenate the word segmentation representation of the text to be extracted and the text representations of multiple plot texts to obtain the fusion feature.
4. The text plot extraction method according to any one of claims 1 to 2, characterized in that The determining the plot extraction result of the text to be extracted based on the sentence representations of each clause and the text representations of each plot text includes: Based on the sentence representations of each clause and the text representations of each plot text, determine the semantic similarity between each clause and each plot text; Based on the semantic similarity between each clause and each plot text, determine the plot extraction result of the text to be extracted.
5. The text plot extraction method according to any one of claims 1 to 2, characterized in that The performing semantic understanding on the text to be extracted and each plot text respectively based on the fusion feature to obtain the sentence representations of each clause in the text to be extracted and the plot representations of each plot text; The determining the plot extraction result of the text to be extracted based on the sentence representations of each clause and the text representations of each plot text includes: Based on the plot extraction model and the fusion feature, perform semantic understanding on the text to be extracted and each plot text respectively to obtain the sentence representations of each clause in the text to be extracted and the plot representations of each plot text, and based on the sentence representations of each clause and the text representations of each plot text, determine the plot extraction result of the text to be extracted; Wherein, the plot extraction model is trained based on the sample fusion feature and its sample plot extraction result; the sample fusion feature is obtained by performing encoding fusion on the sample extraction text and the sample plot text of the sample candidate plot.
6. The text plot extraction method according to claim 5, wherein After training the plot extraction model based on the sample fusion feature and its sample plot extraction result, it further includes: When there is a new plot, obtain the new sample text, and encode and fuse the new sample text and the new plot text to obtain a new fused feature; Input the new fused feature into the plot extraction model to obtain the new sample plot extraction result output by the plot extraction model; Update the plot extraction model based on the new fused feature and the new sample plot extraction result.
7. The text plot extraction method according to claim 6, characterized in that, The encoding and fusing of the new sample text and the new plot text to obtain a new fused feature includes: Convert the new plot text into a translation text expressed in another language, and encode and fuse each translation text with the new sample text respectively to obtain the corresponding new fused feature, where the other language is a language other than the language used in the new plot text.
8. A text plot extraction device, characterized in that, Includes: A text determination unit for determining the text to be extracted and the plot texts of multiple candidate plots corresponding to the text to be extracted; A text fusion unit for encoding and fusing the text to be extracted with the plot texts of the multiple candidate plots to obtain a fused feature; A text representation unit for semantically understanding the text to be extracted and each plot text based on the fused feature to obtain the sentence representations of each clause in the text to be extracted and the plot representations of each plot text; A plot extraction unit for determining the plot extraction result of the text to be extracted based on the sentence representations of each clause and the text representations of each plot text; The semantically understanding the text to be extracted based on the fused feature to obtain the sentence representations of each clause in the text to be extracted includes: Performing semantic encoding on the fused feature to obtain the word vectors of each token in each clause of the text to be extracted; Based on the correlation between the word vectors in any clause, obtain the sentence representations of each clause in the text to be extracted.
9. An electronic device, comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, wherein, When the processor executes the program, it implements the steps of the text plot extraction method according to any one of claims 1 to 7.
10. A non-transitory computer-readable storage medium, having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the steps of the text plot extraction method according to any one of claims 1 to 7.