Text context processing method, device, electronic device and storage medium
Through the grammatical analysis tree statistical model, the text units are deleted and added to generate streamlined text that conforms to the grammatical specifications, which solves the problem that users find it difficult to grasp the key points when reading too long sentences, and improves the efficiency and effectiveness of language learning.
Patent Information
- Application Number
- CN202210107962.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-01-28
- Publication Date
- 2025-08-01
- Estimated Expiration
- 2042-01-28
AI Technical Summary
Users find it difficult to grasp the key points when reading too long sentences, which increases the difficulty of language learning.
By obtaining the pending text, using the grammar analysis tree statistical model to delete the target text unit to generate streamlined text, and adding text without destroying the grammatical relationships is generated to generate streamlined text that conforms to the grammatical specifications.
This makes the streamlined text structure clearer, facilitates user learning, and enriches the content of language learning.
Smart Images

Figure CN114417827B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technologies, and in particular, to a method, an apparatus, an electronic device, and a storage medium for processing text context. Background Art
[0002] Natural Language Processing (NLP) is an important direction in the fields of computer science and artificial intelligence. It studies various theories and methods for realizing effective communication between humans and computers in natural language.
[0003] In related technologies, users learn languages by reading articles to train their language sense. However, long sentences are usually used in articles to express rich meanings. For users, it is difficult to grasp the key points of overly long sentences, increasing the difficulty of language learning. Summary of the Invention
[0004] The present disclosure provides a method, an apparatus, an electronic device, and a storage medium for processing text context to at least solve the problem in related technologies that it is difficult for users to grasp the key points of overly long sentences and the difficulty of language learning is relatively high. The technical solution of the present disclosure is as follows:
[0005] According to a first aspect of an embodiment of the present disclosure, there is provided a method for processing text context, including: obtaining a text to be processed; in response to a user's operation of streamlining the following text, inputting the text to be processed into a syntactic analysis tree statistical model to obtain a target text unit, deleting the target text unit from the text to be processed, and generating a streamlined text; wherein, the text to be processed includes multiple text units, and the text unit is a word or a phrase; in response to a user's operation of adding preceding text, obtaining a new text unit, determining a target position in the text to be processed corresponding to the new text unit, and adding the new text unit to the target position to generate new text.
[0006] In some embodiments, the operation of inputting the text to be processed into a syntactic analysis tree statistical model in response to a user's operation of streamlining the following text to obtain a target text unit, deleting the target text unit from the text to be processed, and generating a streamlined text includes: inputting the text to be processed into a syntactic analysis tree statistical model to obtain a target syntactic rule matching the text to be processed; according to the target syntactic rule, obtaining multiple text units corresponding to the text to be processed and weight levels corresponding to the text units; in the case where it is determined according to the weight levels that there is a target text unit, in response to a user's operation of streamlining the following text, deleting the target text unit from the text to be processed to generate the streamlined text.
[0007] In some embodiments, when it is determined, according to the weight level, that the target text unit exists, in response to the user's operation of streamlining the following text, deleting the target text unit in the text to be processed to generate the streamlined text includes:
[0008] When it is determined, according to the weight level, that there are text units of N levels, in response to the user's first operation of streamlining the following text, according to the weight level, determining the text unit with the first level of the weight level in the text to be processed as the target text unit, deleting the target text unit to generate the first streamlined text; where N is an integer greater than 3; in response to the user's second operation of streamlining the following text, according to the weight level, determining the text unit with the second level of the weight level in the first streamlined text as the target text unit, deleting the target text unit to generate the second streamlined text; and so on, until in response to the user's (N - 1)th operation of streamlining the following text, according to the weight level, determining the text unit with the (N - 1)th level of the weight level in the (N - 2)th streamlined text as the target text unit, deleting the target text unit to generate the streamlined text.
[0009] In some embodiments, the method further includes: when it is determined, according to the weight level, that the target text unit does not exist, prompting that the text to be processed is a streamlined text and exiting.
[0010] In some embodiments, the method further includes: inputting the streamlined text into the syntactic analysis tree statistical model, and when there is a matching syntactic rule, providing the streamlined text to the user; when there is no matching syntactic rule, prompting an error in the streamlined text and exiting.
[0011] In some embodiments, the response to the user's operation of adding text above, obtaining the added text unit, determining the target position of the added text unit in the text to be processed, and adding the added text unit to the target position to generate the added text includes:
[0012] In response to the user's operation of adding text above, dividing the text to be processed into at least one text unit sequence according to a preset condition; inputting the text unit sequence into the trained word vector model to predict the added text unit; traversing the text to be processed to determine the first reserved position of the added text unit in the text to be processed; and adding the added text unit to the first reserved position of the text to be processed to generate the added text.
[0013] In some embodiments, the method further includes: inputting the newly added text into the syntax analysis tree statistical model, and providing the newly added text to the user when there is a matching syntax rule; and prompting an error in the newly added text and exiting when there is no matching syntax rule.
[0014] In some embodiments, the method further includes: obtaining a first number of text units included in the newly added text; and when the first number is greater than a first preset threshold, in response to an operation above the newly added text by the user, prompting that the newly added text has reached the upper limit and exiting.
[0015] In some embodiments, the method further includes: in response to a first operation above the generated text by the user, inputting the text to be processed into the syntax analysis tree statistical model, and obtaining the syntax rules included in the text to be processed; matching the syntax rules with a target statement library for target constraints, and constructing new syntax rules according to the syntax rules and the statement library syntax rules in the target statement library; wherein the new syntax rules and the syntax rules form a parent-child relationship or a sibling relationship; obtaining a plurality of generated text units from a dedicated word library according to the new syntax rules, and determining a second reserved position corresponding to the generated text units in the text to be processed; adding the generated text units to the second reserved position of the text to be processed to obtain a plurality of generated texts; obtaining a plurality of target statements in the target statement library; calculating the similarity between the generated texts and the target statements respectively, and determining one of the plurality of generated texts as the target generated text.
[0016] In some embodiments, the method further includes: obtaining corpus data; processing the corpus data to obtain a plurality of target statements; summarizing the target statements to generate the target statement library; processing the target statements to obtain the corresponding relationship between words and parts of speech; and summarizing the corresponding relationship to generate the dedicated word library.
[0017] In some embodiments, the method further includes: inputting the target generated text into the syntax analysis tree statistical model, and providing the target generated text to the user when there is a matching syntax rule; and prompting an error in the generated text and exiting when there is no matching syntax rule.
[0018] In some embodiments, the method further includes: obtaining a second number of text units included in the target generated text; and when the second number is greater than a second preset threshold, in response to an operation above the generated text by the user, prompting that the generated text has reached the upper limit and exiting.
[0019] In some embodiments, the method further includes: in response to a second upstream operation by the user to replace text, inputting the target text unit into a trained word vector model to obtain a replacement text unit, adding the replacement text unit to a third reserved position of the target text unit in the text to be processed, and generating a replacement text; wherein, the replacement text unit has the highest text vector similarity with the target text unit.
[0020] In some embodiments, the step of in response to a second upstream operation by the user to replace text, inputting the target text unit into a trained word vector model to obtain a replacement text unit, adding the replacement text unit to a third reserved position of the target text unit in the text to be processed, and generating a replacement text includes:
[0021] In the case where there are N levels of text units, in response to the user's N-1th downstream operation to streamline text, according to the weight level, determining the text unit with the N-1th weight level in the N-2th streamlined text as the target text unit, deleting the target text unit, and generating the streamlined text, in response to the user's first second upstream operation to replace text, inputting the target text unit of the first level into a trained word vector model to obtain the target replacement text unit of the first level, adding the target replacement text unit of the first level to the third reserved position of the target text unit of the first level in the streamlined text to generate a first replacement text; in response to the user's second second upstream operation to replace text, inputting the target text unit of the second level into a trained word vector model to obtain the target replacement text unit of the second level, adding the target replacement text unit of the second level to the third reserved position of the target text unit of the second level in the first replacement text to generate a second replacement text; and so on, until in response to the user's N-1th second upstream operation to replace text, inputting the target text unit of the N-1th level into a trained word vector model to obtain the target replacement text unit of the N-1th level, adding the target replacement text unit of the N-1th level to the third reserved position of the target text unit of the N-1th level in the N-2th replacement text to generate the replacement text.
[0022] In some embodiments, the method further includes: inputting the replacement text into the syntax analysis tree statistical model, and in the case where there is a matching syntax rule, providing the new text to the user; in the case where there is no matching syntax rule, prompting an error in the replacement text and exiting.
[0023] In some embodiments, the method further includes: obtaining a corpus text; inputting the corpus text into a syntax analysis model based on constituent analysis to generate a syntax analysis tree, parsing the syntax analysis tree bottom-up to generate a table structure, and obtaining a syntax analysis tree library; wherein, the syntax analysis tree library includes a plurality of corpus text units; the table structure includes the relationships of parent-child nodes and sibling nodes; assigning weights to the corpus text units to generate the syntax analysis tree statistical model.
[0024] In some embodiments, the method further includes: obtaining a training data set; inputting the training data set into a word vector model, training the word vector model, and generating a trained word vector model.
[0025] According to a second aspect of the embodiments of the present disclosure, there is provided a text context processing device, including: a text acquisition unit configured to acquire a text to be processed; a first processing unit configured to, in response to a user's operation of streamlining the following text, input the text to be processed into a syntax analysis tree statistical model, obtain a target text unit, delete the target text unit from the text to be processed, and generate a streamlined text; wherein, the text to be processed includes a plurality of text units, and the text unit is a word or a phrase; a second processing unit configured to, in response to a user's operation of adding preceding text, obtain a new text unit, determine a target position in the text to be processed corresponding to the new text unit, and add the new text unit to the target position to generate new text.
[0026] According to a third aspect of the embodiments of the present disclosure, there is provided an electronic device, including: a processor; a memory for storing executable instructions of the processor; wherein, the processor is configured to execute the instructions to implement the text context processing method as described in the first aspect above.
[0027] According to a fourth aspect of the embodiments of the present disclosure, there is provided a storage medium, when the instructions in the storage medium are executed by a processor of an electronic device, enabling the electronic device to execute the text context processing method as described in the first aspect above.
[0028] According to a fifth aspect of the embodiments of the present disclosure, there is provided a computer program product, including a computer program, which implements the text context processing method as described in the first aspect above when executed by a processor.
[0029] The technical solutions provided by the embodiments of the present disclosure at least bring the following beneficial effects:
[0030] By implementing the embodiments of the present disclosure, the text to be processed is obtained. In response to the user's operation of streamlining the following text of the text to be processed, the text to be processed is input into the syntactic analysis tree statistical model to obtain the target text unit, and the target text unit in the text to be processed is deleted to generate the streamlined text. Wherein, the text to be processed includes a plurality of text units, and the text unit is a word or a phrase. In response to the user's operation of adding the preceding text of the text, the new text unit is obtained, the target position in the text to be processed corresponding to the new text unit is determined, and the new text unit is added to the target position to generate the new text. Thus, text deletion can be performed without destroying the original syntactic relationship, and a streamlined text that conforms to the syntactic specification can be generated, making the structure of the streamlined text clearer. At the same time, text addition can be performed to enrich the content of language learning and facilitate user learning.
[0031] It should be understood that the above general description and the following detailed description are only exemplary and explanatory, and do not limit the present disclosure. Brief Description of the Drawings
[0032] The drawings herein are incorporated into the specification and form a part of the specification, showing embodiments consistent with the present disclosure, and are used together with the specification to explain the principles of the present disclosure and do not constitute an improper limitation to the present disclosure.
[0033] Figure 1 is a flowchart of a method for processing text context shown according to an exemplary embodiment;
[0034] Figure 2 is a flowchart of S2 in a method for processing text context shown according to an exemplary embodiment;
[0035] Figure 3 is a structural diagram of a syntactic analysis tree shown according to an exemplary embodiment;
[0036] Figure 4 is a flowchart of S3 in a method for processing text context shown according to an exemplary embodiment;
[0037] Figure 5 is a flowchart of another method for processing text context shown according to an exemplary embodiment;
[0038] Figure 6 is a flowchart of yet another method for processing text context shown according to an exemplary embodiment;
[0039] Figure 7 is a flowchart of S100 in a method for processing text context shown according to an exemplary embodiment;
[0040] Figure 8 is a structural diagram of a text context processing device shown according to an exemplary embodiment;
[0041] Figure 9 It is a structural diagram of a first processing unit in a text context processing device shown according to an exemplary embodiment;
[0042] Figure 10 It is a structural diagram of a concise text generation module in a text context processing device shown according to an exemplary embodiment;
[0043] Figure 11 It is a structural diagram of another first processing unit in a text context processing device shown according to an exemplary embodiment;
[0044] Figure 12 It is a structural diagram of a second processing unit in a text context processing device shown according to an exemplary embodiment;
[0045] Figure 13 It is a structural diagram of another second processing unit in a text context processing device shown according to an exemplary embodiment;
[0046] Figure 14 It is a structural diagram of yet another second processing unit in a text context processing device shown according to an exemplary embodiment;
[0047] Figure 15 It is a structural diagram of another text context processing device shown according to an exemplary embodiment;
[0048] Figure 16 It is a structural diagram of yet another text context processing device shown according to an exemplary embodiment;
[0049] Figure 17 It is a structural diagram of yet another text context processing device shown according to an exemplary embodiment;
[0050] Figure 18 It is a structural diagram of yet another text context processing device shown according to an exemplary embodiment;
[0051] Figure 19 It is a structural diagram of yet another text context processing device shown according to an exemplary embodiment;
[0052] Figure 20 It is a structural diagram of a replacement text generation unit in yet another text context processing device shown according to an exemplary embodiment;
[0053] Figure 21 It is a structural diagram of yet another text context processing device shown according to an exemplary embodiment;
[0054] Figure 22It is a structural diagram of another text context processing device shown according to an exemplary embodiment;
[0055] Figure 23 It is a structural diagram of another text context processing device shown according to an exemplary embodiment;
[0056] Figure 24 It is a block diagram of an electronic device shown according to an exemplary embodiment. Detailed implementation manners
[0057] In order to enable those of ordinary skill in the art to better understand the technical solutions of the present disclosure, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below with reference to the accompanying drawings.
[0058] Unless otherwise required in the text, throughout the specification and claims, the term "comprising" is to be construed in an open, inclusive sense, i.e., "including, but not limited to". In the description of the specification, the term "some embodiments" etc. are intended to indicate that specific features, structures, materials, or characteristics related to the embodiment or example are included in at least one embodiment or example of the present disclosure. The schematic representation of the above terms is not necessarily directed to the same embodiment or example. In addition, the specific features, structures, materials, or characteristics may be included in any one or more embodiments or examples in any suitable manner.
[0059] It should be noted that the terms "first", "second", etc. in the specification and claims of the present disclosure and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that such used data may be interchanged under appropriate circumstances so that the embodiments of the present invention and the present disclosure described herein can be implemented in an order other than those illustrated or described herein. The implementation manners described in the following exemplary embodiments do not represent all implementation manners consistent with the present disclosure. On the contrary, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.
[0060] Hereinafter, the terms "first" and "second" are only used for descriptive purposes and cannot be understood as indicating or implying relative importance or implicitly specifying the quantity of the indicated technical features. Thus, the features defined with "first" and "second" may explicitly or implicitly include one or more of such features. In the description of the present invention, the meaning of "a plurality" is at least two, such as two, three, etc., unless otherwise specifically defined.
[0061] It should be noted that the text context processing method of the embodiments of the present disclosure can be executed by the text context processing device of the embodiments of the present disclosure. The text context processing device can be implemented in software and / or hardware, and can be configured in an electronic device. The electronic device can install and run a text processing program. The electronic device can include, but is not limited to, hardware devices such as smart phones and tablet computers with various operating systems.
[0062] Figure 1 is a flowchart of a text context processing method shown according to an exemplary embodiment.
[0063] As Figure 1 shown, the text context processing method provided by the embodiments of the present disclosure includes, but is not limited to, the following steps:
[0064] S1: Obtain the text to be processed.
[0065] It can be understood that in the embodiments of the present disclosure, the text to be processed is the text provided by the user for language learning, or can also be the text provided by the text context processing device to facilitate the user's language learning.
[0066] Among them, when the text to be processed is the text provided by the user for language learning, the user can select an article or a paragraph of text and paste it to the corresponding position of the text context processing device in the embodiments of the present disclosure, so that the text context processing device obtains the text to be processed, and further uses the text context processing device in the embodiments of the present disclosure to process the text provided by the user.
[0067] When the text to be processed is the text provided by the text context processing device to facilitate the user's language learning, in the embodiments of the present disclosure, text materials for the user to learn are pre-stored in the text context processing device. The user selects the corresponding text, that is, the text context processing device obtains the text selected by the user and can further process the text.
[0068] In the embodiments of the present disclosure, the text to be processed can be an article or a paragraph of text. It can be understood that the text to be processed includes multiple words or phrases, and can include multiple words, or multiple phrases, or both words and phrases at the same time.
[0069] In the embodiments of the present disclosure, to facilitate subsequent processing of the text to be processed, there is a constraint on the number of words included in the text to be processed. Exemplarily, the number of words included in the text to be processed is limited to between 10 and 35 words, which can reduce the calculation time when processing the text to be processed subsequently.
[0070] It should be noted that the number of words included in the text to be processed can also be restricted to other ranges, which can be set according to the hardware environment such as the server. The number of words included in the text to be processed can increase with the improvement of hardware performance. This is only for illustration and does not constitute a specific limitation on the embodiments of the present disclosure.
[0071] It should be noted that in the embodiments of the present disclosure, the text to be processed can be an English text, or it can also be a Chinese text, a French text, a German text, an Italian text, a Japanese text, a Korean text, etc. The embodiments of the present disclosure do not make specific limitations in this regard.
[0072] S2: In response to the user's operation of streamlining the following text of the text to be processed, input the text to be processed into the syntactic analysis tree statistical model, obtain the target text unit, delete the target text unit in the text to be processed, and generate the streamlined text; wherein, the text to be processed includes multiple text units, and the text unit is a word or a phrase.
[0073] It can be understood that in the embodiments of the present disclosure, the text context processing device is provided with a button for the user to streamline the text. Correspondingly, the user's operation of streamlining the following text of the text can be that the user clicks the button for streamlining the text; or the text context processing device is provided with a control instruction for the user to streamline the text. Correspondingly, the user's operation of streamlining the following text of the text can be that the user triggers the control instruction corresponding to streamlining the text.
[0074] In the embodiments of the present disclosure, in the case of the user's operation of streamlining the following text of the text, the target text unit in the text to be processed is deleted to generate the streamlined text.
[0075] It should be noted that in the embodiments of the present disclosure, the text to be processed includes multiple text units. The text unit can be a word or a phrase, and the target text unit can be one or more words in the text to be processed, or can be one or more phrases in the text to be processed, or can also be words and phrases in the text to be processed, etc.
[0076] Among them, when the text unit is a word, the target text unit in the text to be processed is determined according to the part of speech corresponding to the word and the syntactic relationship between different words in the text to be processed.
[0077] Exemplarily, taking the text to be processed as an English text as an example, when the text unit is a word and the corresponding part of speech is an adjective, the syntactic relationship between the word and other words in the text to be processed is judged. Assuming that the syntactic relationship with the next adjacent word is: the parent-child relationship is like NP->JJ+NN, indicating that the noun phrase is composed of an adjective (JJ) and a noun (NN), then it can be determined that the word with the part of speech of an adjective is the target text unit and can be deleted under the user's operation of streamlining the following text of the text.
[0078] Thus, in the embodiments of the present disclosure, by constraining the grammatical relationships between different words in the text to be processed without destroying the original grammatical relationships, when the text to be processed is streamlined, the streamlined result conforms to the grammatical norms.
[0079] Among them, when the text unit is a phrase, the corresponding grammatical rules of the text unit are identified, and the target text unit is determined according to the corresponding grammatical rules of the text unit.
[0080] Exemplarily, taking the text to be processed as an English text as an example, when the text unit is a phrase, assuming that the corresponding grammatical rule of the text unit is: NP->JJ+NN, indicating that a noun phrase is composed of an adjective (JJ) and a noun (NN), then the word that is an adjective in this text unit can be determined as the target text unit and can be deleted under the operation of the user streamlining the following text.
[0081] Assuming that the corresponding grammatical rule of the text unit is: NP->DT+JJ+NN, indicating that a noun phrase is composed of an article (DT), an adjective (JJ), and a noun (NN), then the word that is an adjective in this text unit can be determined as the target text unit, or the word that is an article in this text unit can be determined as the target text unit, or the words that are an adjective and an article in this text unit can be determined as the target text units, and then can be deleted under the operation of the user streamlining the following text.
[0082] Thus, in the embodiments of the present disclosure, by constraining the corresponding grammatical rules of the text units in the text to be processed without destroying the original grammatical relationships, when the text to be processed is streamlined, the streamlined result conforms to the grammatical norms.
[0083] It can be understood that in the embodiments of the present disclosure, for the deleted target text units, they are displayed below the generated streamlined text and there are corresponding explanations.
[0084] Exemplarily, taking an English text as an example, the text to be processed is "blue sky", and the deleted one is the adjective "blue" before the noun "sky". The explanation can be that the part of speech of the target text unit "blue" is an adjective, which is used to modify the noun "sky". Furthermore, similar words of "blue" can be added, such as "cerulean", so that the user can learn more vocabulary, learn the vocabulary association of synonyms or near-synonyms, and improve the user's learning experience.
[0085] It can be understood that in the embodiments of the present disclosure, further, the translation and voice of the streamlined text can be provided, and the user can learn the translated text and pronunciation synchronously.
[0086] S3: In response to the user's operation of adding text above, obtain the newly added text unit, determine the target position of the newly added text unit in the text to be processed, add the newly added text unit to the target position, and generate the newly added text.
[0087] It can be understood that in the embodiments of the present disclosure, the text context processing device is provided with a button for the user to add text. Correspondingly, the user's operation of adding text above can be the user clicking the button for adding text; or the text context processing device is provided with a control instruction for the user to add text. Correspondingly, the user's operation of adding text above can be the user triggering the control instruction corresponding to adding text.
[0088] In the embodiments of the present disclosure, in response to the user's operation of adding text above, the newly added text unit obtained can be the newly added text unit obtained in advance according to the text to be processed. The method for obtaining the newly added text unit can adopt the methods in related technologies, and the embodiments of the present disclosure do not make specific limitations on this.
[0089] It should be noted that in the embodiments of the present disclosure, the newly added text unit can be one or more words, or can be one or more phrases, or can also be one or more words and phrases, etc.
[0090] It can be understood that in the embodiments of the present disclosure, further, the translation and voice of the newly added text can be provided, and the user can learn the translated text and pronunciation synchronously.
[0091] By implementing the embodiments of the present disclosure, obtain the text to be processed, in response to the user's operation of streamlining text below, input the text to be processed into the syntax analysis tree statistical model, obtain the target text unit, delete the target text unit in the text to be processed, and generate the streamlined text; wherein, the text to be processed includes multiple text units, and the text unit is a word or a phrase. In response to the user's operation of adding text above, obtain the newly added text unit, determine the target position of the newly added text unit in the text to be processed, add the newly added text unit to the target position, and generate the newly added text. Thus, text deletion can be performed without destroying the original grammatical relationship, and a streamlined text that conforms to the grammatical norms can be generated, making the structure of the streamlined text clearer. At the same time, text addition can be performed to enrich the content of language learning and facilitate user learning.
[0092] Such as Figure 2 shown, in some embodiments, S2 includes but is not limited to the following steps:
[0093] S21: Input the text to be processed into the syntax analysis tree statistical model, and obtain the target syntax rule that matches the text to be processed.
[0094] It can be understood that in the embodiments of the present disclosure, before inputting the text to be processed into the syntax analysis tree statistical model to obtain the target syntax rule matching the text to be processed, obtaining a syntax analysis tree model is further included.
[0095] In some embodiments, obtaining a syntax analysis tree model includes: obtaining corpus texts; inputting the corpus texts into a syntax analysis model based on constituent analysis to generate syntax analysis trees; parsing the syntax analysis trees from bottom to top to generate a table structure to obtain a syntax analysis tree library; wherein, the syntax analysis tree library includes multiple corpus text units; the table structure includes the relationships of parent and child nodes and sibling nodes; assigning weights to the corpus text units to generate a syntax analysis tree statistical model.
[0096] In the embodiments of the present disclosure, the corpus texts can be obtained from publicly available articles. By preprocessing the articles, the corpus texts are obtained. Among them, preprocessing the articles includes: deleting the markup symbols in the articles, then performing segmentation processing, removing overly long or overly short sentences, and selecting sentences with the number of words within a certain range as the corpus texts.
[0097] Exemplarily, the number of words selected is between 10 and 35.
[0098] Certainly, in the embodiments of the present disclosure, obtaining the corpus texts is not limited to the above examples and can be set as needed. The embodiments of the present disclosure do not make specific limitations in this regard.
[0099] In the embodiments of the present disclosure, taking the corpus text as an English text as an example, inputting the corpus text into a syntax analysis tree model based on constituent analysis. For example, when the corpus text is "the medical imaging technology currently has made significant progress in many important domains", the generated syntax analysis tree is as Figure 3 shown, where the leaf nodes are the words in the sentence; other non-leaf nodes are the parts of speech of the words and the phrase components composed of the words. The characteristic of the syntax analysis tree is that the components closer to the root are the core components of the sentence, and the components closer to the leaf nodes are non-core components.
[0100] In the embodiments of the present disclosure, after obtaining the syntax analysis trees corresponding to the corpus texts, a syntax analysis tree library is obtained. Among them, the syntax analysis tree library includes syntax analysis trees generated from multiple corpus texts, including multiple corpus text units, and the corpus text units are different nodes of the syntax analysis trees. After assigning weights to the corpus text units, a syntax analysis tree statistical model is generated.
[0101] In a possible implementation, in the embodiments of the present disclosure, weights are assigned to corpus text units. In order to sort the corpus text units, a corresponding table is generated from the syntax analysis tree, which facilitates the assignment of weights to the corpus text units.
[0102] In the embodiments of the present disclosure, taking an English text as an example, the tokens used in English grammar parsing adopt the language token set of the Penn Treebank. TreeBank is a large corpus annotated with syntactic and semantic sentence structures. These syntactic structures are usually in the form of trees, so it is called TreeBank (tree bank).
[0103] The syntax analysis tree representation method adopts the nested manner of () parentheses because it occupies less resources and the tree structure is relatively easy to read without software tools. When a sentence is given, the grammar can be parsed in the order from left to right. For example, the sentence "the dog run" can be represented as (S(NP(DT the)(NN dog))(VP run)).
[0104] The token descriptions are shown in Table 1 below:
[0105]
[0106] Table 1
[0107] It should be noted that the above examples are only partial examples and do not list all examples. For details, please refer to the language token set of the Penn Treebank.
[0108] Exemplarily, when the corpus text is "image classification and object detection applications are becoming more robust and more accurate.", a syntax analysis tree is generated, and the syntax analysis tree is parsed from bottom to top. According to the tree structure, it is transformed into a table structure, and the corresponding table structure is shown in Table 2 below:
[0109]
[0110] Table 2
[0111] It can be understood that in the embodiments of the present disclosure, when there are multiple corpus texts, after the above processing is performed on the multiple corpus texts, a corresponding table structure is generated, weights are assigned to the corpus text units, and a syntax analysis tree statistical model is generated.
[0112] In the embodiments of the present disclosure, in the syntax analysis tree statistical model, the symbols and expressions are described as follows:
[0113] 1) NP -> DT + JJ + NN: It means that NP is generated (parsed) into DT, JJ, and NN.
[0114] 2) JJ ∈ (NP -> DT + JJ + NN, NP -> JJ + NN): It means that JJ matches NP -> DT + JJ + NN and NP -> JJ + NN.
[0115] 3) JJ ∈ (NP -> DT + JJ + NN, NP -> JJ + NN) & (ORDER(1)): It means that JJ matches NP -> DT + JJ + NN and NP -> JJ + NN, and at the same time the weight level is 1.
[0116] 4) JJ ∈ ((NP -> DT + JJ + NN, NP -> JJ + NN) & (ORDER(1))) / JJ: It means the percentage of the statements where JJ matches NP -> DT + JJ + NN, NP -> JJ + NN, and the weight level is 1 among all JJ records.
[0117] [[ID=**12**]]According to the above symbol and expression conventions, count the proportions of the following matching rules:
[0118] JJ ∈ ((NP -> DT + JJ + NN, NP -> JJ + NN) & (ORDER(1))) / JJ;
[0119] RB ∈ ((ADVP -> RB) & (ORDER(2))) / RB;
[0120] PP ∈ ((VP -> VBN + NP + PP) & (ORDER(3))) / PP;...
[0121] According to the above rules, perform statistical analysis on the database that generates the corresponding table to generate a statistical model of the syntax analysis tree:
[0122] Model = {JJ ∈ (NP -> DT + JJ + NN, NP -> JJ + NN) & (ORDER(1))) / JJ,...,}.
[0123] Thus, based on obtaining the statistical model of the syntax analysis tree in the embodiments of the present disclosure, input the text to be processed into the statistical model of the syntax analysis tree, and the target syntax rules matching the text to be processed can be obtained.
[0124] S22: According to the target syntax rules, obtain multiple text units corresponding to the text to be processed, and the weight levels corresponding to the text units.
[0125] In an embodiment of the present disclosure, after inputting the text to be processed into the syntactic analysis tree statistical model and obtaining the target syntactic rule that matches the text to be processed, a plurality of text units corresponding to the text to be processed and the weight levels corresponding to the text units can be obtained. Thus, the target text unit can be determined according to the determined weight levels of the text units.
[0126] S23: When it is determined that there is a target text unit according to the weight level, in response to the user's operation of streamlining the subsequent text, the target text unit in the text to be processed is deleted to generate a streamlined text.
[0127] In an embodiment of the present disclosure, when it is determined that there is a target text unit according to the weight level, in response to the user's operation of streamlining the subsequent text, the target text unit in the text to be processed is deleted to generate a streamlined text.
[0128] It should be noted that in an embodiment of the present disclosure, obtaining the weight level corresponding to the text unit includes at least two weight levels. When it is determined that the text unit with the first weight level is the target text unit according to the weight level, the target text unit with the first weight level is deleted, and the text unit with the second weight level is retained to generate a streamlined text.
[0129] In some embodiments, when it is determined that there are text units with N levels according to the weight level, in response to the user's first operation of streamlining the subsequent text, according to the weight level, the text unit with the first weight level in the text to be processed is determined as the target text unit, and the target text unit is deleted to generate a first streamlined text; where N is an integer greater than 3; in response to the user's second operation of streamlining the subsequent text, according to the weight level, the text unit with the second weight level in the first streamlined text is determined as the target text unit, and the target text unit is deleted to generate a second streamlined text; and so on, until in response to the user's (N - 1)th operation of streamlining the subsequent text, according to the weight level, the text unit with the (N - 1)th weight level in the (N - 2)th streamlined text is determined as the target text unit, and the target text unit is deleted to generate a streamlined text.
[0130] Exemplarily, when N is 5, the text to be processed determines text units including 5 levels according to the weight level. In response to the user's first operation of streamlining the following text of the text, according to the weight level, it is determined that the text unit with the first-level weight level in the text to be processed is the target text unit, and the target text unit is deleted to generate the first streamlined text; in response to the user's second operation of streamlining the following text of the text, according to the weight level, it is determined that the text unit with the second-level weight level in the first streamlined text is the target text unit, and the target text unit is deleted from the first streamlined text to generate the second streamlined text; in response to the user's third operation of streamlining the following text of the text, according to the weight level, it is determined that the text unit with the third-level weight level in the second streamlined text is the target text unit, and the target text unit is deleted from the second streamlined text to generate the third streamlined text; in response to the user's fourth operation of streamlining the following text of the text, according to the weight level, it is determined that the text unit with the fourth-level weight level in the third streamlined text is the target text unit, and the target text unit is deleted from the third streamlined text, and finally the streamlined text is generated.
[0131] It can be understood that in the embodiments of the present disclosure, the text to be processed is taken as an English text as an example, and the streamlined text is five basic sentence patterns in English.
[0132] Exemplarily, the five basic sentence patterns are as follows:
[0133] S+V subject-predicate structure;
[0134] S+V+P subject-linking verb-predicative structure;
[0135] S+V+O subject-verb-object structure;
[0136] S+V+O1+O2 subject-verb-indirect object-direct object structure;
[0137] S+V+O+C subject-verb-object-complement structure.
[0138] Wherein, S = subject; V = predicate; P = predicative; O = object; O1 = indirect object; O2 = direct object; C = object complement.
[0139] 1. S+V sentence pattern: In this sentence pattern, V is an intransitive verb, also called an intransitive verb (vi).
[0140] 2. S+V+P sentence pattern: In this sentence pattern, V is a linking verb. Common linking verbs are: look, seem, appear, sound, feel, taste, smell, grow, get, fall ill / asleep, stand / sit still, become, turn, etc.
[0141] 3. S+V+O sentence pattern: In this sentence pattern, V is a transitive verb (vt.), so there is an object.
[0142] 4. S + V + O1 + O2 sentence pattern: In this sentence pattern, V is a transitive verb with a double object. Common verbs that must take a double object include give, ask, bring, offer, send, pay, lend, show, tell, buy, get; rob, warn, etc.
[0143] 5. S + V + O + C sentence pattern.
[0144] In the embodiments of the present disclosure, in response to the user's operation of streamlining the following text, the target text unit in the text to be processed is deleted to generate a streamlined text, and the streamlined text is the five basic sentence patterns of English.
[0145] Of course, for texts other than English texts, similar concepts can be adopted, and the embodiments of the present disclosure do not make specific limitations thereto.
[0146] In some embodiments, when it is determined according to the weight level that there is no target text unit, it is prompted that the text to be processed is a streamlined text and the process exits.
[0147] It can be understood that when the text to be processed is input into the syntax analysis tree statistical model to obtain the target syntax rule matching the text to be processed, and the weight levels corresponding to multiple text units included in the text to be processed are determined according to the target syntax rule. When there is only one weight level, at this time, it is determined that there is no target text unit. In this case, it is prompted that the text to be processed is a streamlined text and the process exits.
[0148] Taking the text to be processed as an English text as an example, when the text to be processed is the five basic sentence patterns of English, it is determined that there is no target text unit in the text to be processed. At this time, it is prompted that the text to be processed is a streamlined text and the process exits.
[0149] In some embodiments, the streamlined text is input into the syntax analysis tree statistical model. When there is a matching syntax rule, the streamlined text is provided to the user; when there is no matching syntax rule, it is prompted that the streamlined text is incorrect and the process exits.
[0150] In the embodiments of the present disclosure, the target text unit in the text to be processed is deleted to obtain a streamlined text, which needs to be input into the syntax analysis tree statistical model to determine whether the generated streamlined text can be parsed and whether there is a matching syntax rule. When there is a matching syntax rule, the streamlined text is provided to the user; when there is no matching syntax rule, it is prompted that the streamlined text is incorrect and the process exits. Thus, it can be ensured that the obtained streamlined text conforms to the syntax rules and can express a complete meaning, so as to obtain a streamlined text that conforms to the syntax specification and avoid the obtained streamlined text not conforming to the language specification and misleading the user's learning.
[0151] As Figure 4 shown, in some embodiments, S3 includes but is not limited to the following steps:
[0152] S31: In response to the user's operation of adding text above the text to be processed, divide the text to be processed into at least one text unit sequence according to preset conditions.
[0153] In the embodiments of the present disclosure, on the basis of the text to be processed, text can be added to the text to be processed to enrich the text, facilitate users' learning, and improve users' experience.
[0154] Among them, the preset condition can be to divide adjacent preset numbers of text units into one text unit sequence in turn. The text unit can be a word or a phrase.
[0155] Exemplarily, the preset number can be two, or can be four, or can also be six, etc. The embodiments of the present disclosure do not make specific limitations on this.
[0156] In a possible implementation manner, taking the text to be processed as an English text as an example, for example, the text to be processed is: "size are important for a model".
[0157] Start sliding the window from the beginning of the sentence, and use every 2 or 4 words as a text unit sequence for prediction. Here, 4 words are used as an example. (This parameter can be set according to the system training model).
[0158] Sliding window illustration: The first text unit sequence generated by the first sliding window is "size are importantfor", the second text unit sequence generated by the second sliding window is "are important for a", and the third text unit sequence generated by the third sliding window is "important for a model".
[0159] S32: Input the text unit sequence into the trained word vector model to predict and obtain the newly added text unit.
[0160] Input the text unit sequences into the trained word vector model in turn to predict and obtain the corresponding newly added text units. Exemplarily, as shown in Table 3 below:
[0161] previous2 previous1 next1 next2 out Previous second Previous first Next first Next second Output Sample size are important None size are important for very are important for a None import for a model None for a model learning
[0162] Table 3
[0163] S33: Traverse the text to be processed to determine the first reserved position of the newly added text unit in the text to be processed.
[0164] In the embodiments of the present disclosure, the to-be-processed text is traversed to obtain the first reserved position in the to-be-processed text corresponding to the newly added text unit.
[0165] S34: Add the newly added text unit to the first reserved position of the to-be-processed text to generate the newly added text.
[0166] In the embodiments of the present disclosure, in response to the user's operation of adding text above for the first time, a new sentence is generated: "Sample size are very important for a learning model". Among them, "very" and "learning" are newly added text units.
[0167] Based on the operation of adding text above for the first time, in response to the user's operation of adding text above for the second time, the above process is continued to obtain the text unit sequence, and the text unit sequence is input into the trained word vector model in turn to predict the newly added text unit. Exemplarily, as shown in Table 4 below:
[0168] previous2 previous1 next1 next2 out Previous second Previous first Next first Next second Output Sample size are very None … … … … None for a learning a machine a learning model None
[0169] Table 4
[0170] In response to the user's operation of adding text above for the second time, a new sentence is generated: "sample size are very important for a machine learning model".
[0171] Among them, "machine" is a newly added text unit, generated on the basis of the previous time.
[0172] It should be noted that the above examples are only for illustration. In the embodiments of the present disclosure, the user can also add text multiple times, and the embodiments of the present disclosure do not make specific restrictions on this.
[0173] Based on this, in the embodiments of the present disclosure, without changing the original grammar and semantics, in response to the user's operation of adding text above, new text is added on the basis of the to-be-processed text, which can enrich the user's vocabulary.
[0174] It can be understood that in the embodiments of the present disclosure, further, the translation and voice of the newly added text can be provided, and the user can learn the translated text and pronunciation synchronously.
[0175] In some embodiments, the newly added text is input into the grammar analysis tree statistical model. When there is a matching grammar rule for the newly added text, the newly added text is provided to the user; when there is no matching grammar rule, an error of the newly added text is prompted and the process exits.
[0176] In the embodiments of the present disclosure, when adding a new text unit to the text to be processed to obtain new text, it is necessary to input it into the syntax analysis tree statistical model to determine whether the generated new text can be parsed and whether there are matching syntax rules. In the case where there are matching syntax rules, the new text is provided to the user. In the case where there are no matching syntax rules, an error of the new text is prompted and the process exits. Thus, it can be ensured that the obtained new text conforms to the syntax rules and can express a complete meaning, so as to avoid the obtained new text not conforming to the language specification and misleading the user's learning.
[0177] In some embodiments, obtain a first number of text units included in the new text; in the case where the first number is greater than a first preset threshold, in response to an operation above the new text by the user, prompt that the new text reaches the upper limit and exit.
[0178] It can be understood that in the embodiments of the present disclosure, there can be multiple operations above the new text. As the new text is added multiple times, the number of text units included in the generated new text will also increase. The more text units the new text includes, the more time required for the system to process data will inevitably increase, and the computing efficiency will inevitably decrease.
[0179] Based on this, in the embodiments of the present disclosure, the data of the text units included in the new text is statistically analyzed to obtain a first number of text units included in the new text. In the case where the first number is greater than a first preset threshold, if there is an operation above the new text by the user, prompt that the new text reaches the upper limit and exit.
[0180] Among them, the first preset threshold can be 100, or 80, or 50, etc., and can be set according to the computing power of the server used by the system and the network bandwidth. The embodiments of the present disclosure do not make specific limitations on this.
[0181] As Figure 5 shown, in some embodiments, the text context processing method provided by the embodiments of the present disclosure further includes:
[0182] S10: In response to a first operation above the text generated by the user, input the text to be processed into the syntax analysis tree statistical model to obtain the syntax rules included in the text to be processed.
[0183] S20: Perform target constraint on the syntax rules by matching the target statement library, and construct new syntax rules according to the syntax rules and the statement library syntax rules in the target statement library; wherein, the new syntax rules and the syntax rules form a parent-child relationship or a sibling relationship.
[0184] In a possible implementation manner, taking the text to be processed as an English text as an example, for example, the text to be processed is: "applications are becoming more accurate".
[0185] The text to be processed is input into the syntax analysis tree statistical model, and the obtained statement analysis tree is "(ROOT(S(NP(NNS applications))(VP(VBP are)(VP(VBG becoming)(ADJP(RBR more)(JJ accurate))))))". Traverse this syntax analysis tree to obtain the corresponding table, where the syntax rules include NP->NNS, NNS->applications.
[0186] In the embodiments of the present disclosure, a plurality of statement library syntax rules are pre-stored in the target statement library. The syntax rules included in the obtained text to be processed are matched with the statement library syntax rules in the target statement library to construct new syntax rules; wherein, the new syntax rules and the syntax rules form a parent-child relationship or a sibling relationship.
[0187] Exemplarily, when the syntax rules included in the obtained text to be processed are matched with the statement library syntax rules in the target statement library, the new syntax rules constructed are: NP->NN+NNS, NP->NN+NN+NNS.
[0188] It can be understood that the above examples are only for illustration. There may be only one new syntax rule, or there may be no new syntax rule, or there may be more than two new syntax rules, etc. The above examples do not specifically limit the embodiments of the present disclosure.
[0189] S30: According to the new syntax rules, obtain a plurality of generated text units from the dedicated word library, and determine the second reserved position corresponding to the generated text units in the text to be processed.
[0190] S40: Add the generated text units to the second reserved position of the text to be processed to obtain a plurality of generated texts.
[0191] In the embodiments of the present disclosure, the dedicated word library can be pre-set, and the dedicated word library includes the corresponding relationships between a plurality of words and their parts of speech.
[0192] Exemplarily, in the embodiments of the present disclosure, words with the part of speech of NN are obtained from the dedicated word library as the generated text units. It can be understood that there are a plurality of words with the part of speech of NN in the dedicated word library, and thus, a plurality of generated text units are obtained from the dedicated word library.
[0193] Exemplarily, it is determined that the generated text unit "NN" is the word "classification", and it is determined that the generated text unit and the corresponding second reserved position added to the text to be processed is the position before "applications", and the generated text is obtained: "classification applications are becoming more accurate".
[0194] It should be noted that there are multiple words with the part of speech NN in the dedicated vocabulary. Selecting all words with the part of speech NN as the generated text units will lead to a decrease in calculation efficiency. In the embodiments of the present disclosure, some words with the part of speech NN can be selected as the generated text units to improve the calculation efficiency.
[0195] S50: Obtain multiple target statements from the target statement library; calculate the similarity between the generated text and the target statements respectively, and determine one as the target generated text from multiple generated texts.
[0196] It can be understood that in the embodiments of the present disclosure, the target statement library includes multiple target statements. When obtaining multiple target statements from the target statement library, some target statements in the target statement library can be obtained.
[0197] Exemplarily, 20% of the target statements are randomly recalled from the target statement library, or 10% of the target statements can also be randomly recalled, etc. The embodiments of the present disclosure do not make specific limitations on this.
[0198] In some embodiments, the text context processing method provided by the embodiments of the present disclosure further includes: obtaining corpus data; processing the corpus data to obtain multiple target statements; summarizing the target statements to generate a target statement library; processing the target statements to obtain the corresponding relationship between words and parts of speech; summarizing the corresponding relationship to generate a dedicated vocabulary.
[0199] In the embodiments of the present disclosure, corpus data is obtained. Among them, the corpus data can adopt a publicly available corpus set or be crawled from the Internet, etc. The corpus data can include news corpus, historical famous work corpus, professional book corpus, etc. Different corpus data can be classified, and methods such as theme judgment can be used for classification. Thus, when the category of the corpus data is determined, processing the corpus data can generate target statements corresponding to the category.
[0200] It should be noted that since the corpus data is text that has passed content review, the target statements obtained according to the corpus data can ensure compliance, legality, and semantic completeness.
[0201] Based on this, in the embodiments of the present disclosure, target statements of a specific category can be obtained from the target statement library based on the category of the target statement. Among them, the specific category can be obtained by performing corpus parsing on the text to be processed, or predicted by a relevant feature judgment algorithm. Thus, appropriate target statements can be selected, so that in subsequent processing, relatively matching generated text units can be obtained.
[0202] In the embodiments of the present disclosure, processing the target statements in the target statement library may include performing deduplication, part-of-speech tagging, etc. to obtain the corresponding relationship between words and parts of speech; summarizing the corresponding relationship to generate a special vocabulary.
[0203] Among them, when the target statements in the target statement library are non-English texts, such as Chinese texts, it is also necessary to segment the target statements, and then perform deduplication, part-of-speech tagging, etc. to obtain the corresponding relationship between words and parts of speech; summarize the corresponding relationship to generate a special vocabulary.
[0204] In the embodiments of the present disclosure, the special vocabulary obtained based on the target statement library can be used to determine the generated text units from the special vocabulary, add the generated text units to the text to be processed to obtain the generated text, and further, the obtained generated text has homology with the word source of the target statement, ensuring that the generated text is compliant and legal, and the efficiency of data processing is relatively high when calculating similarity in subsequent processing.
[0205] In the embodiments of the present disclosure, the generated text and the target statement are respectively input into a sentence vector model to obtain the text vectors corresponding to the generated text and the target statement, and then the cosine distance between the two text vectors is calculated for similarity calculation.
[0206] Among them, the sentence vector model can be a doc2vec model. The doc2vec model can generate vectors of sentences or paragraphs. By inputting the generated text and the target statement into the doc2vec model respectively, the text vectors corresponding to the generated text and the target statement can be obtained.
[0207] It can be understood that in the embodiments of the present disclosure, there are multiple generated texts and multiple target statements. The similarity is calculated for each generated text and each target statement respectively, and finally the similarities are sorted to determine the one with the largest similarity as the target generated text.
[0208] It should be noted that in the above example, only obtaining the target generated text in response to the user's first operation of generating the previous text is taken as an example. In the embodiments of the present disclosure, the user can also perform the operation of generating the previous text multiple times, and obtain a new target generated text based on the previously obtained target generated text. The embodiments of the present disclosure do not make specific limitations on this.
[0209] It can be understood that in the embodiments of the present disclosure, further, translations and voices of the target generated text can be provided, and users can learn the translated text and pronunciation synchronously.
[0210] In the embodiments of the present disclosure, by presetting a target statement library, selecting a target statement from the target statement library, calculating the similarity between the generated text and the target statement respectively, and determining one of the multiple generated texts as the target generated text. In the embodiments of the present disclosure, by using the target statement for target constraint, the generated target generated text conforms to the grammar rules, meets compliance and legality, and has high efficiency in calculating similarity.
[0211] In some embodiments, the target generated text is input into a syntax analysis tree statistical model. When there is a matching grammar rule for the target generated text, the target generated text is provided to the user; when there is no matching grammar rule, an error in the generated text is prompted and the process exits.
[0212] In the embodiments of the present disclosure, when the generated text unit is added to the text to be processed to obtain the target generated text, it needs to be input into the syntax analysis tree statistical model to determine whether the generated target generated text can be parsed and whether there is a matching grammar rule. When there is a matching grammar rule, the target generated text is provided to the user; when there is no matching grammar rule, an error in the generated text is prompted and the process exits. Thus, it can be ensured that the obtained target generated text conforms to the grammar rules and can express a complete meaning, so as to avoid the obtained target generated text not conforming to the language specification and misleading users' learning.
[0213] In some embodiments, the second number of text units included in the target generated text is obtained; when the second number is greater than the second preset threshold, in response to the user's first previous operation of generating text, it is prompted that the generated text has reached the upper limit and the process exits.
[0214] It can be understood that in the embodiments of the present disclosure, the first previous operation of generating text can be performed multiple times. As the text is generated multiple times, the number of text units included in the obtained target generated text is also more. The more text units the target generated text includes, the longer the time required for the system to process data will be, and the calculation efficiency will inevitably decrease.
[0215] Based on this, in the embodiments of the present disclosure, the number of text units included in the target generated text is counted, the second number of text units included in the target generated text is obtained, and when the second number is greater than the second preset threshold, if there is the user's first previous operation of generating text, it is prompted that the generated text has reached the upper limit and the process exits.
[0216] Among them, the second preset threshold can be 100, or 80, or 50, etc., and can be set according to the computing power of the server used by the system and the network bandwidth. The embodiments of the present disclosure do not make specific limitations on this.
[0217] In some embodiments, the second preset threshold is equal to the first preset threshold.
[0218] In the embodiments of the present disclosure, the first number of text units included in the newly added text is greater than the first preset threshold. In the case of an upper text operation of the user's newly added text, it will be prompted that the newly added text reaches the upper limit and exits. At the same time, the second number of text units included in the target generated text is greater than the second preset threshold. In the case of a first upper text operation of the user's generated text, it will be prompted that the generated text reaches the upper limit and exits. The first preset threshold and the second preset threshold are equal, and the server and network bandwidth used by the text context processing device in the embodiments of the present disclosure can satisfy the implementation of the above two processes simultaneously.
[0219] As Figure 6 shown, in some embodiments, the text context processing method provided by the embodiments of the present disclosure further includes:
[0220] S100: In response to a second upper text operation of the user to replace the text, input the target text unit into the trained word vector model to obtain a replacement text unit, and add the replacement text unit to the third reserved position of the target text unit in the text to be processed to generate a replacement text; wherein, the replacement text unit has the largest text vector similarity with the target text unit.
[0221] In the embodiments of the present disclosure, on the basis of deleting the target text unit in the text to be processed in response to the lower text operation of the user to streamline the text, for the deleted target text unit, in response to a second upper text operation of the user to add new text, input the target text unit into the trained word vector model to obtain a replacement text unit, and add the replacement text unit to the third reserved position of the target text unit in the text to be processed to generate a replacement text.
[0222] In a possible implementation manner, input the target text unit into the trained word vector model to generate a text vector corresponding to the target text unit, and obtain a replacement text unit with the largest text vector similarity with the target text unit from the corpus or the thesaurus through the trained word vector model, and add the replacement text unit to the third reserved position of the target text unit in the text to be processed to generate a replacement text.
[0223] Thus, in the embodiments of the present disclosure, by obtaining a replacement text unit corresponding to a target text unit deleted from the text to be processed and adding the replacement text unit to the third reserved position of the target text unit in the text to be processed to generate a replacement text unit, the text to be processed can be enriched, which is beneficial to users' language learning and improves the user experience.
[0224] It can be understood that in the embodiments of the present disclosure, further, the translation and voice of the replacement text unit can be provided, and the user can learn the translated text and pronunciation synchronously.
[0225] As Figure 7 shown, in some embodiments, S100 includes but is not limited to the following steps:
[0226] S101: When there are N levels of text units, in response to the user's operation of trimming the following text for the (N - 1)-th time, according to the weight level, determine the text unit with the (N - 1)-th weight level in the (N - 2)-th trimmed text as the target text unit, delete the target text unit, and generate a trimmed text. In response to the user's first operation of replacing the text for the second time above the text, input the target text unit of the first level into the trained word vector model, obtain the replacement text unit of the first level, and add the replacement text unit of the first level to the third reserved position of the target text unit of the first level in the trimmed text to generate the first replacement text.
[0227] S102: In response to the user's second operation of replacing the text for the second time above the text, input the target text unit of the second level into the trained word vector model, obtain the replacement text unit of the second level, and add the replacement text unit of the second level to the third reserved position of the target text unit of the second level in the text to be processed to generate the second replacement text.
[0228] S103: And so on, until in response to the user's (N - 1)-th operation of replacing the text for the second time above the text, input the target text unit of the (N - 1)-th level into the trained word vector model, obtain the replacement text unit of the (N - 1)-th level, and add the replacement text unit of the (N - 1)-th level to the third reserved position of the target text unit of the (N - 1)-th level in the (N - 2)-th replacement text to generate the replacement text.
[0229] Exemplarily, when N is 5, there are 5 levels of text units in the text to be processed. In response to the user's fourth operation of streamlining the following text, according to the weight level, it is determined that the text unit with the fourth weight level in the third streamlined text is the target text unit. After deleting the target text unit to generate the streamlined text, in response to the user's first operation of replacing the second preceding text, the target text unit of the first level is input into the trained word vector model to obtain the replacement text unit of the first level, and the replacement text unit of the first level is added to the third reserved position of the target text unit of the first level in the streamlined text to generate the first replacement text.
[0230] In response to the user's second operation of replacing the second preceding text, the target text unit of the second level is input into the trained word vector model to obtain the replacement text unit of the second level, and the replacement text unit of the second level is added to the third reserved position of the target text unit of the second level in the first replacement text to generate the replacement text of the second level.
[0231] In response to the user's third operation of adding text to the second preceding text, the target text unit of the third level is input into the trained word vector model to obtain the replacement text unit of the third level, and the replacement text unit of the third level is added to the third reserved position of the target text unit of the third level in the second replacement text to generate the replacement text of the third level.
[0232] In response to the user's fourth operation of adding text to the second preceding text, the target text unit of the fourth level is input into the trained word vector model to obtain the replacement text unit of the fourth level, and the replacement text unit of the fourth level is added to the third reserved position of the target text unit of the fourth level in the third replacement text to generate the replacement text.
[0233] It can be understood that in the embodiments of the present disclosure, in response to the user's operation of streamlining the following text, when the target text units in the text to be processed are deleted K times, where each deleted target text unit is different. In response to the user's operation of replacing the second preceding text, the target text units deleted K times are replaced. On the basis that each deleted target text unit is different, the target text units replaced K times are also different, and K is a positive integer. Thus, the user can streamline the text multiple times to learn the sentence structure of the text to be processed. Further, replace the text units deleted during streamlining to learn more approximate words, synonyms, etc., and enrich the vocabulary.
[0234] In some embodiments, the replacement text is input into the syntax analysis tree statistical model. When there is a matching syntax rule, the replacement text is provided to the user; when there is no matching syntax rule, an error with the replacement text is prompted and the process exits.
[0235] In the embodiments of the present disclosure, to obtain a replacement text by replacing a target text unit in the text to be processed, it is necessary to input it into a syntactic analysis tree statistical model to determine whether the generated replacement text can be parsed and whether there is a matching syntactic rule. If there is a matching syntactic rule, the replacement text is provided to the user. If there is no matching syntactic rule, an error of the replacement text is prompted and the process exits. Thereby, it can be ensured that the obtained replacement text conforms to the syntactic rule and can express a complete meaning, so as to avoid the obtained replacement text not conforming to the language specification and misleading users in learning.
[0236] In some embodiments, the text context processing method provided in the embodiments of the present disclosure further includes: obtaining a trained word vector model, where obtaining a trained word vector model includes: obtaining a training data set; inputting the training data set into the word vector model to train the word vector model to generate a trained word vector model.
[0237] In the embodiments of the present disclosure, taking an English text as an example, to obtain a training data set, the corpus can be an English novel in a public version text format. The sentences in the English novel are tokenized, and based on the tokenization, a training data set is generated through a sliding window (the window length can be set. Exemplarily, it is set to the target word and the two adjacent words before and after, a total of four adjacent words).
[0238] It should be noted that the window length can be set. The window length can also be 3, obtaining the target word and one adjacent word before and after, a total of two adjacent words, to generate a training data set. Or, the window length can also be 7, etc., which can be set according to needs.
[0239] In a possible implementation manner, the method for obtaining a training data set and inputting the training data set into the word vector model to train the word vector model is as follows:
[0240] Example sentence: the technology currently has made significant progress in many important domains. Traverse the entire sentence through a sliding window. For example, if the length of the sliding window is set to 5, the first two and the last two words of each word are used as inputs, and the output is the target word.
[0241] The training data set generated by the example sentence is shown in Table 5 below:
[0242] previous2 previous1 next1 next2 out Previous second Previous first Next first Next second Output / / technology currently the / the currently has technology the technology has made currently technology currently made significant has currently has significant progress made has made progress in significant made significant in many progress significant progress many important in progress in important domains many in many domains / important many important / / domains
[0243] Table 5
[0244] In an embodiment of the present disclosure, in response to a second upstream operation of the user to replace text, the target text unit is input into a trained word vector model to obtain a text vector of the target text unit, a replacement text unit with the highest similarity to the text vector of the target text unit is obtained, the replacement text unit is obtained, and the replacement text unit is added to a third reserved position of the target text unit in the text to be processed to generate a replacement text.
[0245] Exemplarily, when the text to be processed is "a big truck", and in the case that in response to a downstream operation of the user to streamline the text, the target text unit "big" in the text to be processed is deleted, in response to a second upstream operation of the user to replace text, the target text unit "big" is input into a trained word vector model to generate a text vector of "big", a replacement text unit "huge" with the highest similarity to it is obtained, and the replacement text unit is added to a third reserved position of the target text unit in the text to be processed to generate a replacement text "a huge truck".
[0246] Figure 8 It is a structural diagram of a text context processing device shown according to an exemplary embodiment.
[0247] As Figure 8 shown, the text context processing device 1 includes: a text acquisition unit 11, a first processing unit 12, and a second processing unit 13.
[0248] The text acquisition unit 11 is configured to acquire the text to be processed.
[0249] The first processing unit 12 is configured to, in response to a downstream operation of the user to streamline the text, input the text to be processed into a syntax analysis tree statistical model to obtain a target text unit, delete the target text unit from the text to be processed, and generate a streamlined text; wherein, the text to be processed includes multiple text units, and the text unit is a word or a phrase.
[0250] The second processing unit 13 is configured to, in response to an upstream operation of the user to add text, acquire an added text unit, determine a target position of the added text unit in the text to be processed, and add the added text unit to the target position to generate an added text.
[0251] As Figure 9 shown, in some embodiments, the first processing unit 12 includes:
[0252] The syntax rule acquisition module 121 is configured to input the text to be processed into a syntax analysis tree statistical model to obtain a target syntax rule that matches the text to be processed.
[0253] A rank acquisition module 122, configured to obtain multiple text units corresponding to the text to be processed and the weight ranks corresponding to the text units according to the target grammar rules.
[0254] A refined text generation module 123, configured to, when it is determined according to the weight ranks that there are target text units, in response to the user's operation of refining the subsequent text of the text to be processed, delete the target text units in the text to be processed and generate a refined text.
[0255] As Figure 10 shown, in some embodiments, the refined text generation module 123 includes:
[0256] A first refined text generation sub-module 1231, configured to, when it is determined according to the weight ranks that there are text units of N ranks, in response to the user's first operation of refining the subsequent text of the text to be processed, determine, according to the weight ranks, that the text units with the first rank in the text to be processed are target text units, delete the target text units, and generate a first refined text; where N is an integer greater than 3;.
[0257] A second refined text generation sub-module 1232, configured to, in response to the user's second operation of refining the subsequent text of the text to be processed, determine, according to the weight ranks, that the text units with the second rank in the first refined text are target text units, delete the target text units, and generate a second refined text.
[0258] A third refined text generation sub-module 1233, and so on, until in response to the user's (N - 1)th operation of refining the subsequent text of the text to be processed, determine, according to the weight ranks, that the text units with the (N - 1)th rank in the (N - 2)th refined text are target text units, delete the target text units, and generate a refined text.
[0259] As Figure 11 shown, in some embodiments, the first processing unit 12 further includes:
[0260] A refined text prompt module 124, configured to, when it is determined according to the weight ranks that there are no target text units, prompt that the text to be processed is a refined text and exit. [[ID=…]]
[0261] Please refer to again Figure 11 , in some embodiments, the first processing unit 12 further includes: [[ID=…]]
[0262] A refined text providing module 125, configured to input the refined text into a grammar analysis tree statistical model, and provide the refined text to the user when there are matching grammar rules.
[0263] A refined error reporting module 126, configured to, when there are no matching grammar rules, prompt that the refined text is incorrect and exit.
[0264] As Figure 12 shown, in some embodiments, the second processing unit 13 includes:
[0265] A sequence division module 131, configured to divide the text to be processed into at least one text unit sequence according to preset conditions in response to an operation on the previous text of the newly added text by the user.
[0266] A prediction module 132, configured to input the text unit sequence into a trained word vector model to predict a newly added text unit.
[0267] A first position acquisition module 133, configured to traverse the text to be processed to determine a first reserved position in the text to be processed corresponding to the newly added text unit.
[0268] A newly added text generation module 134, configured to add the first newly added text unit to the first reserved position of the text to be processed to generate newly added text.
[0269] As Figure 13 shown, in some embodiments, the second processing unit 13 includes:
[0270] A newly added text providing module 135, configured to input the newly added text into a syntax analysis tree statistical model, and provide the newly added text to the user when there is a matching syntax rule.
[0271] A newly added text error reporting module 136, configured to prompt an error in the newly added text and exit when there is no matching syntax rule.
[0272] As Figure 14 shown, in some embodiments, the second processing unit 13 includes:
[0273] A first number acquisition module 137, configured to acquire a first number of text units included in the newly added text.
[0274] A newly added limit reached prompt module 138, configured to prompt that the newly added text has reached the limit and exit in response to an operation on the previous text of the newly added text by the user when the first number is greater than a first preset threshold.
[0275] As Figure 15 shown, in some embodiments, the text context processing device 1 further includes:
[0276] A model processing unit 14, configured to input the text to be processed into a syntax analysis tree statistical model in response to a first operation on the previous text of the generated text by the user, and acquire the syntax rules included in the text to be processed.
[0277] A syntax rule acquisition unit 15 is configured to perform target constraints on a syntax rule matching a target statement library, and construct a new syntax rule according to the syntax rule and the statement library syntax rule in the target statement library; wherein, the new syntax rule and the syntax rule form a parent-child relationship or a sibling relationship.
[0278] A second position acquisition unit 16 is configured to obtain a plurality of generated text units from a dedicated word library according to the new syntax rule, and determine a second reserved position corresponding to the generated text unit in the text to be processed.
[0279] A generated text acquisition unit 17 is configured to add the generated text unit to the second reserved position of the text to be processed to obtain a plurality of generated texts.
[0280] A target generated text determination unit 18 is configured to obtain a plurality of target statements in the target statement library; calculate the similarity between the generated text and the target statements respectively, and determine one of the plurality of generated texts as the target generated text.
[0281] As Figure 16 shown, in some embodiments, the text context processing device 1 further includes:
[0282] A corpus data acquisition unit 19 is configured to acquire corpus data.
[0283] A target statement acquisition unit 20 is configured to process the corpus data to obtain a plurality of target statements.
[0284] A target statement library acquisition unit 21 is configured to summarize the target statements to generate a target statement library.
[0285] A part-of-speech table acquisition unit 22 is configured to process the target statements to obtain the correspondence between words and parts of speech.
[0286] A dedicated word library acquisition unit 23 is configured to summarize the correspondence to generate a dedicated word library.
[0287] As Figure 17 shown, in some embodiments, the text context processing device 1 further includes:
[0288] A target generated text providing unit 24 is configured to input the target generated text into a syntax analysis tree statistical model, and provide the target generated text to the user when there is a matching syntax rule;
[0289] A generated text error reporting unit 25 is configured to prompt a generated text error and exit when there is no matching syntax rule.
[0290] As Figure 18 shown, in some embodiments, the text context processing device 1 further includes:
[0291] A second number obtaining unit 26, configured to obtain a second number of text units included in the target generated text;
[0292] A generation reaching upper limit prompt module 27, configured to, when the second number is greater than a second preset threshold, in response to a first upstream operation of the user to generate text, prompt that the generated text reaches the upper limit and exit.
[0293] As Figure 19 shown, in some embodiments, the text context processing device 1 further includes:
[0294] A replacement text generation unit 28, configured to, in response to a second upstream operation of the user to replace text, input a target text unit into a trained word vector model, obtain a replacement text unit, add the replacement text unit to a third reserved position of the target text unit in the text to be processed, and generate a replacement text; wherein, the replacement text unit has the largest similarity with the text vector corresponding to the target text unit.
[0295] As Figure 20 shown, in some embodiments, the replacement text generation unit 28 includes:
[0296] A first replacement text generation module 281, configured to, when there are N levels of text units, in response to a downstream operation of the user to streamline the text for the (N - 1)th time, according to the weight level, determine that the text unit with the weight level of the (N - 1)th level in the (N - 2)th streamlined text is the target text unit, delete the target text unit, and generate the streamlined text, in response to a first upstream operation of the user to replace text, input the target text unit of the first level into a trained word vector model, obtain a target replacement text unit of the first level, add the target replacement text unit of the first level to a third reserved position of the target text unit of the first level in the streamlined text, and generate a first replacement text.
[0297] A second replacement text generation module 282, configured to, in response to a second upstream operation of the user to replace text, input the target text unit of the second level into a trained word vector model, obtain a target replacement text unit of the second level, add the target replacement text unit of the second level to a third reserved position of the target text unit of the second level in the first replacement text, and generate a second replacement text.
[0298] A replacement text generation module 283, and so on, until in response to a (N - 1)th upstream operation of the user to replace text, input the target text unit of the (N - 1)th level into a trained word vector model, obtain a target replacement text unit of the (N - 1)th level, add the target replacement text unit of the (N - 1)th level to a third reserved position of the target text unit of the (N - 1)th level in the (N - 2)th replacement text, and generate a replacement text.
[0299] As Figure 21 shown, in some embodiments, the text context processing device 1 further includes:
[0300] A replacement text providing unit 29, configured to input the replacement text into the syntax analysis tree statistical model, and provide the replacement text to the user when there is a matching syntax rule;
[0301] A replacement text error reporting unit 30, configured to prompt a replacement text error and exit when there is no matching syntax rule.
[0302] As Figure 22 shown, in some embodiments, the text context processing device 1 further includes:
[0303] A corpus text obtaining unit 3|, configured to obtain corpus text.
[0304] A tree bank obtaining unit 32, configured to input the corpus text into a syntax analysis model based on constituent analysis to generate a syntax analysis tree, parse the syntax analysis tree from bottom to top to generate a table structure, and obtain a syntax analysis tree bank; wherein, the syntax analysis tree bank includes multiple corpus text units; the table structure includes the relationship between parent and child nodes and the relationship between sibling nodes.
[0305] A statistical model generating unit 33, configured to assign weights to the corpus text units to generate a syntax analysis tree statistical model.
[0306] As Figure 23 shown, in some embodiments, the text context processing device 1 further includes:
[0307] A training data obtaining unit 34, configured to obtain a training data set.
[0308] A word vector model generating unit 35, configured to input the training data set into a word vector model, train the word vector model, and generate a trained word vector model.
[0309] Regarding the device in the above embodiments, the specific manners in which each module performs operations have been described in detail in the embodiments related to the method, and will not be elaborated herein.
[0310] The beneficial effects that can be achieved by the text context processing device provided in the embodiments of the present disclosure are the same as those of the text context processing method provided in the above examples, and will not be repeated here.
[0311] Figure 24 is a block diagram of an electronic device 100 for a text context processing method shown according to an exemplary embodiment.
[0312] Exemplarily, the electronic device 100 can be a mobile phone, computer, digital broadcast terminal, messaging device, game console, tablet device, medical device, fitness device, personal digital assistant, etc.
[0313] As Figure 24 shown, the electronic device 100 may include one or more of the following components: a processing component 101, a memory 102, a power component 103, a multimedia component 104, an audio component 105, an input / output (I / O) interface 106, a sensor component 107, and a communication component 108.
[0314] The processing component 101 generally controls the overall operation of the electronic device 100, such as operations associated with display, telephone calls, data communication, camera operations, and recording operations. The processing component 101 may include one or more processors 1011 to execute instructions to complete all or part of the steps of the above-described methods. In addition, the processing component 101 may include one or more modules to facilitate the interaction between the processing component 101 and other components. For example, the processing component 101 may include a multimedia module to facilitate the interaction between the multimedia component 104 and the processing component 101.
[0315] The memory 102 is configured to store various types of data to support the operation of the electronic device 100. Examples of such data include instructions for any application or method operating on the electronic device 100, contact data, phone book data, messages, pictures, videos, etc. The memory 102 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as SRAM (Static Random-Access Memory), EEPROM (Electrically Erasable Programmable read only memory), EPROM (Erasable Programmable Read-Only Memory), PROM (Programmable read-only memory), ROM (Read-Only Memory), magnetic memory, flash memory, a magnetic disk, or an optical disk.
[0316] The power component 103 provides power to the various components of the electronic device 100. The power component 103 may include a power management system, one or more power sources, and other components associated with generating, managing, and distributing power for the electronic device 100.
[0317] The multimedia component 104 includes a touch display screen that provides an output interface between the electronic device 100 and the user. In some embodiments, the touch display screen may include an LCD (Liquid Crystal Display) and a TP (Touch Panel). The touch panel includes one or more touch sensors to sense touches, swipes, and gestures on the touch panel. The touch sensors can sense not only the boundaries of touch or swipe actions but also detect the duration and pressure associated with the touch or swipe operations. In some embodiments, the multimedia component 104 includes a front camera and / or a rear camera. When the electronic device 100 is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera can receive external multimedia data. Each of the front camera and the rear camera can be a fixed optical lens system or have a focal length and optical zoom capabilities.
[0318] The audio component 105 is configured to output and / or input audio signals. For example, the audio component 105 includes a MIC (Microphone). When the electronic device 100 is in an operating mode, such as a call mode, a recording mode, and a voice recognition mode, the microphone is configured to receive external audio signals. The received audio signals can be further stored in the memory 102 or sent via the communication component 108. In some embodiments, the audio component 105 further includes a speaker for outputting audio signals.
[0319] The I / O interface 2112 provides an interface between the processing component 101 and a peripheral interface module, and the peripheral interface module can be a keyboard, a click wheel, buttons, etc. These buttons can include but are not limited to: a home button, a volume button, a start button, and a lock button.
[0320] The sensor assembly 107 includes one or more sensors for providing a status assessment of various aspects of the electronic device 100. For example, the sensor assembly 107 can detect the on / off state of the electronic device 100, the relative positioning of components, such as the display and keypad of the electronic device 100. The sensor assembly 107 can also detect a change in the position of the electronic device 100 or a component of the electronic device 100, the presence or absence of user contact with the electronic device 100, the orientation or acceleration / deceleration of the electronic device 100, and a change in the temperature of the electronic device 100. The sensor assembly 107 can include a proximity sensor configured to detect the presence of nearby objects without any physical contact. The sensor assembly 107 can also include a light sensor, such as a CMOS (Complementary Metal Oxide Semiconductor) or CCD (Charge-coupled Device) image sensor, for use in imaging applications. In some embodiments, the sensor assembly 107 can also include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
[0321] The communication component 108 is configured to facilitate communication between the electronic device 100 and other devices in a wired or wireless manner. The electronic device 100 can access a wireless network based on a communication standard, such as WiFi, 2G, or 3G, or a combination thereof. In an exemplary embodiment, the communication component 108 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 108 further includes an NFC (Near Field Communication) module to facilitate short-range communication. For example, the NFC module can be implemented based on RFID (Radio Frequency Identification) technology, IrDA (Infrared Data Association) technology, UWB (Ultra Wide Band) technology, BT (Bluetooth) technology, and other technologies.
[0322] In an exemplary embodiment, the electronic device 100 may be implemented by one or more application specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components, and is used to execute the above-mentioned text context processing method.
[0323] It should be noted that for the implementation process and technical principle of the electronic device in this embodiment, refer to the foregoing explanation of the text context processing method of the embodiments of the present disclosure, which will not be elaborated here.
[0324] The electronic device provided by the embodiments of the present disclosure can execute the text context processing method as described in some of the above embodiments, and its beneficial effects are the same as those of the above-mentioned text context processing method, which will not be elaborated here.
[0325] To implement the above embodiments, the present disclosure also proposes a storage medium.
[0326] Among them, when the instructions in the storage medium are executed by the processor of the electronic device, the electronic device can execute the text context processing method as described above. For example, the storage medium may be a read only memory image (ROM), random access memory (RAM), compact disc read-only memory (CD-ROM), magnetic tape, floppy disk, and optical data storage device, etc.
[0327] To implement the above embodiments, the present disclosure also provides a computer program product. When the computer program is executed by the processor of the electronic device, the electronic device can execute the text context processing method as described above.
[0328] After considering the specification and practicing the invention disclosed herein, those skilled in the art will readily conceive of other embodiments of the present disclosure. This application is intended to cover any variations, uses, or adaptations of the present disclosure, which follow the general principles of the present disclosure and include known common knowledge or conventional technical means in the technical field not disclosed by the present disclosure. The specification and embodiments are only regarded as exemplary, and the true scope and spirit of the present disclosure are pointed out by the following claims.
[0329] It should be understood that the present disclosure is not limited to the exact structures described above and shown in the drawings, and various modifications and changes can be made without departing from its scope. The scope of the present disclosure is limited only by the appended claims.
Claims
1. A method for processing text context, characterized in that, Including: Obtain the text to be processed, where the text to be processed is an English text; In response to the user's operation of streamlining the following text, input the text to be processed into the syntactic analysis tree statistical model to obtain the target syntactic rule that matches the text to be processed; According to the target syntactic rule, obtain multiple text units corresponding to the text to be processed, and the weight level corresponding to the text unit; In the case where it is determined according to the weight level that there is a target text unit, in response to the user's operation of streamlining the following text, delete the target text unit in the text to be processed to generate the streamlined text; wherein, the text to be processed includes multiple text units, and the text unit is a word or a phrase; Input the streamlined text into the syntactic analysis tree statistical model, and provide the streamlined text to the user when there is a matching syntactic rule; In the case where there is no matching syntactic rule, prompt an error in the streamlined text and exit; In response to the user's operation of adding text above, obtain the newly added text unit, determine the target position of the newly added text unit in the text to be processed, and add the newly added text unit to the target position to generate the newly added text.
2. The method according to claim 1, wherein The step of, in the case where it is determined according to the weight level that there is a target text unit, in response to the user's operation of streamlining the following text, deleting the target text unit in the text to be processed to generate the streamlined text, includes: In the case where it is determined according to the weight level that there are text units of N levels, in response to the user's first operation of streamlining the following text, according to the weight level, determine that the text unit with the weight level of the first level in the text to be processed is the target text unit, and delete the target text unit to generate the first streamlined text; where N is an integer greater than 3; In response to the user's second operation of streamlining the following text, according to the weight level, determine that the text unit with the weight level of the second level in the first streamlined text is the target text unit, and delete the target text unit to generate the second streamlined text; And so on, until in response to the user's (N - 1)th operation of streamlining the following text, according to the weight level, determine that the text unit with the weight level of the (N - 1)th level in the (N - 2)th streamlined text is the target text unit, and delete the target text unit to generate the streamlined text.
3. The method according to claim 1, characterized in that, The method further includes: In the case where it is determined according to the weight level that there is no target text unit, prompt that the text to be processed is the streamlined text and exit.
4. The method according to claim 1, wherein The step of, in response to the user's operation of adding text above, obtaining the newly added text unit, determining the target position of the newly added text unit in the text to be processed, and adding the newly added text unit to the target position to generate the newly added text, includes: In response to the user's operation of adding text above, divide the text to be processed into at least one text unit sequence according to preset conditions; Input the text unit sequence into the trained word vector model to predict the newly added text unit; Traverse the text to be processed to determine the first reserved position of the newly added text unit in the text to be processed; Add the newly added text unit to the first reserved position of the text to be processed to generate the newly added text.
5. The method according to claim 4, wherein The method further includes: Input the newly added text into the syntax analysis tree statistical model. If there is a matching syntax rule, provide the newly added text to the user; If there is no matching syntax rule, prompt an error for the newly added text and exit.
6. The method according to claim 4, wherein The method further includes: Obtain the first number of text units included in the newly added text; If the first number is greater than the first preset threshold, in response to the user's operation on the previous text of the newly added text, prompt that the newly added text reaches the upper limit and exit.
7. The method according to claim 1, characterized in that, The method further includes: In response to the user's first operation of generating text, input the text to be processed into the syntax analysis tree statistical model to obtain the syntax rules included in the text to be processed; Perform target constraints on the syntax rules by matching the target statement library. According to the syntax rules and the syntax rules in the target statement library, construct new syntax rules; wherein, the new syntax rules and the syntax rules form a parent-child relationship or a sibling relationship; According to the new syntax rules, obtain multiple generated text units from the dedicated word library and determine the second reserved position of the generated text unit in the text to be processed; Add the generated text unit to the second reserved position of the text to be processed to obtain multiple generated texts; Obtain multiple target statements in the target statement library; Calculate the similarity between the generated texts and the target statements respectively, and determine one of the multiple generated texts as the target generated text.
8. The method according to claim 7, characterized in that The method further includes: Obtain corpus data; Process the corpus data to obtain multiple target statements; Summarize the target statements to generate the target statement library; Process the target statements to obtain the corresponding relationship between words and parts of speech; Summarize the corresponding relationship to generate the dedicated word library.
9. The method according to claim 7, characterized in that The method further includes: Input the target generated text into the syntax analysis tree statistical model. If there is a matching syntax rule, provide the target generated text to the user; If there is no matching syntax rule, prompt an error for the generated text and exit.
10. The method according to claim 7, characterized in that, The method further includes: Obtain the second number of text units included in the target generated text; If the second number is greater than the second preset threshold, in response to the user's first operation on the previous text of the generated text, prompt that the generated text reaches the upper limit and exit.
11. The method according to claim 1, characterized in that, The method further includes: In response to the user's second operation on the previous text of replacing text, input the target text unit into the trained word vector model to obtain the replacement text unit, and add the replacement text unit to the third reserved position of the target text unit in the text to be processed to generate the replacement text; wherein, the replacement text unit has the maximum similarity with the text vector corresponding to the target text unit.
12. The method according to claim 11, wherein In response to the second upstream operation of the user replacing text, input the target text unit into the trained word vector model to obtain a replacement text unit, and add the replacement text unit to the third reserved position of the target text unit in the text to be processed to generate a replacement text, including: In the case where there are N levels of text units, in response to the downstream operation of the user's (N - 1)-th text simplification, according to the weight level, determine that the text unit with the weight level of the (N - 1)-th level in the (N - 2)-th simplified text is the target text unit, delete the target text unit, and generate the simplified text In response to the second upstream operation of the user's first text replacement, input the target text unit of the first level into the trained word vector model to obtain the target replacement text unit of the first level, and add the target replacement text unit of the first level to the third reserved position of the target text unit of the first level in the simplified text to generate a first replacement text; In response to the second upstream operation of the user's second text replacement, input the target text unit of the second level into the trained word vector model to obtain the target replacement text unit of the second level, and add the target replacement text unit of the second level to the third reserved position of the target text unit of the second level in the first replacement text to generate a second replacement text; And so on, until in response to the second upstream operation of the user's (N - 1)-th text replacement, input the target text unit of the (N - 1)-th level into the trained word vector model to obtain the target replacement text unit of the (N - 1)-th level, and add the target replacement text unit of the (N - 1)-th level to the third reserved position of the target text unit of the (N - 1)-th level in the (N - 2)-th replacement text to generate the replacement text.
13. The method according to claim 11, wherein The method further includes: Input the replacement text into the syntax analysis tree statistical model, and provide the replacement text to the user when there is a matching syntax rule; When there is no matching syntax rule, prompt that the replacement text is incorrect and exit.
14. The method according to any one of claims 1 to 13, characterized in that, The method further includes: Obtain a corpus text; Input the corpus text into a syntax analysis model based on constituent analysis to generate a syntax analysis tree; Parse the syntax analysis tree from bottom to top to generate a table structure to obtain a syntax analysis tree library; wherein, the syntax analysis tree library includes multiple corpus text units; the table structure includes the relationship between parent and child nodes and the relationship between sibling nodes; Assign weights to the corpus text units to generate the syntax analysis tree statistical model.
15. The method according to any one of claims 4 to 13, characterized in that, The method further includes: Obtain a training data set; Input the training data set into the word vector model to train the word vector model to generate a trained word vector model.
16. A text context processing device, characterized in that, including: A text acquisition unit for acquiring a text to be processed, and the text to be processed is an English text; A first processing unit, configured to, in response to a user's operation of shortening the following text, input the text to be processed into a syntax analysis tree statistical model to obtain a target syntax rule that matches the text to be processed; according to the target syntax rule, obtain multiple text units corresponding to the text to be processed, and weight levels corresponding to the text units; in the case where it is determined, according to the weight levels, that there are target text units, in response to the user's operation of shortening the following text, delete the target text units in the text to be processed to generate the shortened text; wherein, the text to be processed includes multiple text units, and the text units are words or phrases. The first processing unit further includes: A shortened text providing module, configured to input the shortened text into the syntax analysis tree statistical model, and provide the shortened text to the user in the case where there is a matching syntax rule. A shortening error reporting module, configured to, in the case where there is no matching syntax rule, prompt a shortening text error and exit. A second processing unit, configured to, in response to a user's operation of adding text above, obtain an added text unit, determine a target position of the added text unit in the text to be processed, and add the added text unit to the target position to generate added text.
17. An electronic device, characterized in that, It includes: A processor; A memory for storing instructions executable by the processor; Wherein, the processor is configured to execute the instructions to implement the method according to any one of claims 1 to 15.
18. A storage medium, characterized in that, When the instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the method according to any one of claims 1 to 15.
19. A computer program product, including a computer program, where the computer program, when executed by a processor, implements the method according to any one of claims 1 to 15.
Citation Information
Patent Citations
Natural language text habitual statement pattern extraction method and electronic device
CN113779961A
Method for generating educational foreign language text by adjusting text difficulty
KR102251554B1