A text processing method, device and device for text processing

By combining vectorized processing of English text and using copy network models, and combining translation of parallel corpus training models, automatic English polishing is achieved, solving the problems of low efficiency and high cost of Chinese and English polishing in the existing technology, and improving the polishing efficiency and accuracy.

CN112199963BActive Publication Date: 2024-12-20BEIJING SOGOU TECHNOLOGY DEVELOPMENT CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202011063600.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-09-30
Publication Date
2024-12-20
Estimated Expiration
2040-12-20

AI Technical Summary

Technical Problem

In the prior art, the English polishing process is inefficient and costly, especially when polishing English text written by non-English users, it is difficult to effectively improve the conformity of grammar and expression habits.

Method used

Using a text processing method, by vectorizing the original text and automatically polishing the model including the copy network, combined with the translation parallel corpus from the first language to the second language, ensure that the copy text in the original text is in Keep correctness in the target text and reduce semantic offsets.

Benefits of technology

Automatic English polishing is realized, labor costs are saved, polishing efficiency and accuracy is improved, training data scarcity is solved, and semantic offset is reduced through copy network.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112199963B_ABST
    Figure CN112199963B_ABST
Patent Text Reader

Abstract

The embodiment of the present invention provides a text processing method, device and device for text processing. The method includes: vectorizing the original text to obtain the original text vector; inputting the original text vector into a first model, outputting the target text through the first model, the original text and the target text correspond to the same language, the first model includes a copy network, the copy network is used to retain the copy text in the original text in the target text, the first model is trained based on the parallel corpus of translations of the first language to the second language and the output result of the second model, and the second model is used to translate the text in the first language into the text in the second language. The embodiment of the present invention can improve the efficiency and accuracy of text polishing.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a text processing method, device and a device for text processing. Background Art

[0002] For non-English speakers, there may be various problems in the process of using English. For example, when writing in English, they may habitually use the expression features of their native language instead of the expression features of English. Although the written English sentences conform to English grammar, they do not conform to the expression habits of English.

[0003] Therefore, in scenarios such as English learning and writing, it is necessary to polish the English texts written by non-English speakers so that the polished English texts conform to English grammar and English expression habits. Currently, polishing is usually done manually, with English speakers manually interpreting, correcting, and revising the English texts written by non-English speakers. Manual polishing not only consumes a lot of manpower costs, but is also inefficient. Summary of the invention

[0004] The embodiments of the present invention provide a text processing method, a device and a device for text processing, which can improve the efficiency and accuracy of text polishing.

[0005] In order to solve the above problem, an embodiment of the present invention discloses a text processing method, which includes:

[0006] Vectorize the original text to obtain the original text vector;

[0007] The original text vector is input into a first model, and a target text is output through the first model. The original text and the target text correspond to the same language. The first model includes a copy network, and the copy network is used to retain the copied text in the original text in the target text. The first model is trained based on a parallel corpus of translations of a first language corresponding to a second language and an output result of a second model. The second model is used to translate text in the first language into text in the second language.

[0008] On the other hand, an embodiment of the present invention discloses a text processing device, the device comprising:

[0009] The first vectorization module is used to perform vectorization processing on the original text to obtain the original text vector;

[0010] A processing module is used to input the original text vector into a first model, and output a target text through the first model, wherein the original text and the target text correspond to the same language, the first model includes a copy network, and the copy network is used to retain the copied text in the original text in the target text, the first model is trained based on a parallel corpus of translations of a first language corresponding to a second language and an output result of a second model, and the second model is used to translate text in the first language into text in the second language.

[0011] In another aspect, an embodiment of the present invention discloses a device for text processing, comprising a memory and one or more programs, wherein the one or more programs are stored in the memory and are configured to be executed by one or more processors. The one or more programs include instructions for performing the following operations:

[0012] Vectorize the original text to obtain the original text vector;

[0013] The original text vector is input into a first model, and a target text is output through the first model. The original text and the target text correspond to the same language. The first model includes a copy network, and the copy network is used to retain the copied text in the original text in the target text. The first model is trained based on a parallel corpus of translations of a first language corresponding to a second language and an output result of a second model. The second model is used to translate text in the first language into text in the second language.

[0014] On the other hand, an embodiment of the present invention discloses a machine-readable medium having instructions stored thereon, which, when executed by one or more processors, enables the device to perform one or more of the text processing methods described above.

[0015] The embodiments of the present invention include the following advantages:

[0016] The embodiment of the present invention pre-trains a first model, and the first model can be used to polish the original text to obtain a target text, wherein the original text and the target text correspond to the same language. The first model is trained based on the parallel corpus of the translation of the first language to the second language and the output result of the second model, and the second model is used to translate the text of the first language into the text of the second language. Through the embodiment of the present invention, the automatic polishing of the original text can be realized through the first model, which can save a lot of manpower costs and improve the efficiency of the polishing process compared with the manual polishing process. In addition, since the translation parallel corpus is easier to obtain than the polishing parallel corpus, the embodiment of the present invention adopts a combination of the first model and the second model, and trains the first text using the parallel corpus of the translation from the first language to the second language and the output result of the second model, which can solve the problem of scarce training data for the first model and improve the robustness of the first model. In addition, the first model includes a copy network, and the copy network is used to retain the copy text in the original text in the target text, that is, the copy network can directly copy the correct part (such as named entity) in the original text that does not need to be translated or modified, which can reduce the probability of semantic drift, thereby improving the accuracy of polishing. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments of the present invention will be briefly introduced below. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative labor.

[0018] Figure 1 is a flowchart of steps of an embodiment of a text processing method of the present invention;

[0019] Figure 2 is a structural block diagram of an embodiment of a text processing device of the present invention;

[0020] Figure 3 is a block diagram of an apparatus 800 for text processing according to the present invention;

[0021] Figure 4 It is a schematic diagram of the structure of the server in some embodiments of the present invention. DETAILED DESCRIPTION

[0022] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0023] Method Embodiment

[0024] Reference Figure 1 , shows a flowchart of a text processing method embodiment of the present invention, which may specifically include the following steps:

[0025] Step 101, vectorizing the original text to obtain the original text vector;

[0026] Step 102: input the original text vector into a first model, and output a target text through the first model, wherein the original text and the target text correspond to the same language, the first model includes a copy network, and the copy network is used to retain the copied text in the original text in the target text, the first model is trained based on a parallel corpus of translations of a first language corresponding to a second language and an output result of a second model, and the second model is used to translate text in the first language into text in the second language.

[0027] Among them, the copy network is used to retain the copied text in the original text in the target text, that is, the copy network can directly copy the correct parts of the original text that do not need to be translated or modified (such as named entities), which can reduce the probability of semantic drift and thus improve the accuracy of polishing.

[0028] The text processing method provided in the embodiment of the present invention can be applied to electronic devices. The electronic devices include but are not limited to: servers, smart phones, voice recorders, tablet computers, e-book readers, MP3 (Moving Picture Experts Group Audio Layer III) players, MP4 (Moving Picture Experts Group Audio Layer IV) players, laptop computers, car computers, desktop computers, set-top boxes, smart TVs, wearable devices, etc.

[0029] The embodiment of the present invention pre-trains a first model, and the first model can be used to automatically polish the original text to obtain a target text, wherein the original text and the target text correspond to the same language.

[0030] In order to ensure the accuracy of the prediction of the first model, a large amount of polished parallel corpora is required in the process of training the first model. Parallel corpora refer to a data set of language materials containing sentence pairs in different domains that are aligned in pairs. Taking English as an example, a large amount of polished parallel corpora in English are required to train the first model, and the polished parallel corpora contain English sentence pairs before and after polishing that are aligned in pairs. However, in practical applications, the polished parallel corpora available are relatively small, resulting in insufficient training data required for the first model. To solve this problem, an embodiment of the present invention trains the first model based on the translation parallel corpora of the first language corresponding to the second language and the output results of the second model. The translation parallel corpora of the first language corresponding to the second language contain sentence pairs of the first language and the second language that are aligned in pairs. The second model can be a machine translation model, which can be used to translate text in the first language into text in the second language.

[0031] The first language and the second language are different languages. In an example, the first language is Chinese and the second language is English. Of course, the embodiment of the present invention does not limit the types of the first language and the second language. For example, the first language is English and the second language is Chinese, or the first language is French and the second language is Japanese, etc. The first language and the second language may include any language such as Chinese, English, French, Italian, German, Portuguese, Japanese, Korean, etc. For ease of description, the embodiments of the present invention are all explained by taking the first language as Chinese and the second language as English as an example, that is, the second model can be used to translate Chinese text into English text, and the first model can be used to polish the original English text to obtain the polished English target translation text.

[0032] In practical applications, translation parallel corpus is easier to obtain than polishing parallel corpus. Therefore, the embodiment of the present invention adopts a combination of the first model and the second model to train the first model using the translation parallel corpus from the first language to the second language and the output result of the second model to solve the problem of scarce training data for the first model.

[0033] After the first model training is completed, the first model can be used to polish the original text in the second language. Specifically, the original text is first vectorized to obtain the original text vector. The original text can be a sentence, a paragraph, an article, etc. Optionally, the embodiment of the present invention performs polishing in units of sentences. First, the original text is vectorized, that is, each word segment in the original text is converted into a corresponding vector. Assuming that the length of the original text is N (the original text includes N word segments, N is a positive integer), each word segment is converted into a fixed-length vector x, then the original text vector can be expressed as (x1, x2,…, x N). Then the original text vector is input into the first model, and the target text after polishing the original text can be output through the first model.

[0034] In an example, the original text is "Overall, in the past people used the letter or email times more than they used telephones." This sentence conforms to English grammar, but does not conform to English expression habits. Through the polishing processing of the first model, the original text can be converted into the following target text "In general, people used letters or email more often than telephones in the past." The target text obtained after the conversion is more in line with English expression habits and more standardized.

[0035] Optionally, in order to solve the problem of scarcity of training data for the first model, the embodiment of the present invention can also use the machine translation model to train a reverse model, which is used to convert text in a standard preset language into text in an irregular preset language, so as to obtain a large amount of polished parallel corpus required for training the first model. The preset language refers to the text language that needs to be polished.

[0036] In practical applications, the first model can be trained based on the trained second model, or the first model and the second model can be trained simultaneously based on the parallel corpus of translations from the first language to the second language. This embodiment of the present invention does not limit this.

[0037] In the embodiment of the present invention, the first model and the second model may be a sequence-to-sequence model (Sequence to Sequence Model). A sequence-to-sequence model refers to a neural network model that can convert a sequence in one domain into a corresponding sequence in another domain.

[0038] It should be noted that the embodiments of the present invention do not limit the model structure and training method of the first model and the second model. The first model and the second model can integrate multiple neural networks. The neural network includes but is not limited to the combination, superposition, and nesting of at least one or at least two of the following: CNN (Convolutional Neural Network), LSTM (Long Short-Term Memory), RNN (Simple Recurrent Neural Network), GRU (Gated Recurrent Unit), attention neural network, etc.

[0039] In an optional embodiment of the present invention, the translation parallel corpus includes a first language text and a second language standard text corresponding to the first language text, and the first model can be trained by the following steps:

[0040] Step S11, performing vectorization processing on the first language text to obtain a first language text vector;

[0041] Step S12: inputting the first language text vector into a second model, and outputting a translation text of the first language text corresponding to a second language through the second model;

[0042] Step S13, inputting the translated text into a first model, and outputting a processed text corresponding to the translated text through the first model;

[0043] Step S14, calculating a total loss value according to the difference between the processed text and the second language standard text;

[0044] Step S15: According to the total loss value, adjust the model parameters of the first model until the calculated total loss value reaches a preset convergence condition, thereby obtaining a trained first model.

[0045] The translation parallel corpus is a pre-collected data set containing sentence pairs of the first language and the second language aligned in pairs. Specifically, the translation parallel corpus includes a first language text and a second language standard text corresponding to the first language text. The first language text and the second language standard text are in units of sentences, and both the first language text and the second language standard text are pre-collected texts with standardized expressions.

[0046] In one example, the first language to second language translation parallel corpus includes the following sentence pairs: the first language text is "In the past, people used letters or e-mails more often than telephones.", and the second language standard text corresponding to the first language text is "People used letters or e-mails more often than telephones in the past.".

[0047] First, the first language text is vectorized to obtain the first language text vector. Assume that the first text vector is recorded as (x1, x2,…, x N ). Then the first language text vector is input into the second model, and the second model outputs the translation text of the first language text corresponding to the second language. Assume that the output translation text is "In the past people used the letters or emails times more than they used telephones." It should be noted that the second model used here can be a trained second model, or it can also be an initial second model. Next, the translation text is input into the first model, and the first model outputs the processed text corresponding to the translation text. The processed text is the text after the translation text is polished, and it is assumed that the processed text is "People used letters or emails times more than telephones in the past." It can be understood that the first model here is the initial first model. Finally, according to the difference between the processed text (such as "People used letters or emails times more than telephones.") and the second language standard text ("People used letters or e-mails more often than telephones in the past."), the total loss value is calculated, and according to the total loss value, the model parameters of the first model are adjusted until the calculated total loss value reaches the preset convergence condition, and the first model that has been trained is obtained.

[0048] Furthermore, if the first model and the second model are trained simultaneously, the model parameters of the first model and the model parameters of the second model can be adjusted according to the total loss value until the calculated total loss value reaches a preset convergence condition, thereby obtaining the trained first model and the trained second model.

[0049] In an optional embodiment of the present invention, the first model includes a first encoder and a first decoder, and the second model includes a second encoder and a second decoder.

[0050] The first encoder and the first decoder can constitute a machine translation model structure from the first language to the second language. The second encoder and the second decoder can constitute a polishing model structure for the second language. After the training process is completed, the polishing model structure including the first encoder and the first decoder can be extracted to obtain a first model for automatically polishing the second language text.

[0051] In an optional embodiment of the present invention, the step S12 of inputting the first language text vector into a second model and outputting a translation text of the first language text corresponding to a second language through the second model includes:

[0052] Step S121: input the first language text vector into the second encoder for encoding to obtain a second encoder intermediate vector;

[0053] Step S122: input the second encoder intermediate vector into the second decoder for decoding to obtain a second decoder intermediate vector;

[0054] Step S123: Generate a translation word segmentation probability sequence according to the second decoder intermediate vector, wherein each element in the translation word segmentation probability sequence represents the probability of each word in the second language vocabulary appearing at each position in the translation text;

[0055] Step S124: Determine the target word segmentation corresponding to each position in the translation text in the second language word table according to the translation word segmentation probability sequence to obtain the translation text.

[0056] The second model includes a second encoder and a second decoder. The first language text vector is input into the second model, that is, the first language text vector is input into the second encoder. The second encoder converts the input first language text vector (x1, x2, ..., x N ) is converted into a vector sequence and then input into the second decoder, which converts the vector sequence output by the second encoder into a translated text.

[0057] The second encoder may be an encoder including a multi-layer neural network, and the second decoder may be a decoder including a multi-layer neural network. The second encoder and the second decoder may use the same neural network or different neural networks.

[0058] The first language text vector is input into the second encoder for encoding to obtain the second encoder intermediate vector. Assume that the second encoder intermediate vector is recorded as , the following formula can be used to express the process of the second encoder encoding the first language text vector to obtain the second encoder intermediate vector: Where encoder2 represents the encoding operation of the second encoder. The intermediate vector of the second encoder is Input the second decoder for decoding, and obtain the second decoder intermediate vector h t , assuming that Wherein, decoder2 represents the decoding operation of the second decoder.

[0059] According to the second decoder intermediate vector h t , a translation word segmentation probability sequence can be generated. Specifically, a normalization function (such as softmax, etc.) can be used to convert the second decoder intermediate vector h t Mapped to a translation word segmentation probability sequence, each element in the translation word segmentation probability sequence represents the probability of each word in the second language word list appearing at each position in the translation text. Taking English as the second language as an example, the second language word list is the English word list. The English word list contains words whose occurrence frequency is above the set threshold by counting the number of occurrences of all words in the English sentence.

[0060] In an example, the generated translation word segmentation probability sequence is: [{word1: 0.01, word2: 0.91, word3: 0.01…}, {word1: 0.01, word2: 0.04, word3: 0.82…}…]. The first element in the translation word segmentation probability sequence is {word1: 0.01, word2: 0.91, word3: 0.01…}, which represents the probability of each word in the English vocabulary appearing in the first position in the translation text, that is, the probability of word1 in the English vocabulary appearing in the first position in the translation text is 0.01, the probability of word2 appearing in the first position in the translation text is 0.91, the probability of word3 appearing in the first position in the translation text is 0.01, and so on. Similarly, the second element in the translation word segmentation probability sequence is {word1: 0.01, word2: 0.04, word3: 0.82...}, which represents the probability of each word in the English vocabulary appearing in the second position in the translation text, that is, the probability of word1 in the English vocabulary appearing in the second position in the translation text is 0.01, the probability of word2 appearing in the second position in the translation text is 0.04, the probability of word3 appearing in the second position in the translation text is 0.82, and so on.

[0061] Among them, the number of elements in the translation word segmentation probability sequence can be determined according to the length of the translation text predicted by the second model. In an embodiment of the present invention, the length of the text can be represented by the number of word segments contained in the text. For example, the length of the translation text predicted by the second model is m (m is a positive integer), indicating that the translation text includes m word segments, and the translation word segmentation probability sequence contains m elements, each element corresponding to the word segmentation probability distribution of a position.

[0062] According to the translation word segmentation probability sequence, the target word segmentation corresponding to each position in the translation text can be determined in the second language word list to obtain the translation text. For example, in the above example, the probability of the word segmentation word2 in the first element is the highest, which is 0.91. Therefore, the target word segmentation corresponding to the first position of the translation text is word2. Similarly, the probability of the word segmentation word3 in the second element is the highest, which is 0.82. Therefore, the target word segmentation corresponding to the second position of the translation text is word3. And so on, until the target word segmentations at m positions are determined, the translation text can be obtained.

[0063] Optionally, after inputting the first language text vector into the second encoder for encoding to obtain a second encoder intermediate vector in step S121, the method may further include: normalizing the second encoder intermediate vector to obtain a predicted length of the translated text.

[0064] Specifically, a normalization function (such as softmax, etc.) can be used to transform the second encoder intermediate vector Mapped to the probability distribution of the length of the predicted translation text relative to each integer between 1 and the maximum length, the value with the largest probability is selected as the length L of the predicted translation text predict . The maximum length refers to the maximum length of the predicted translation text, and the length of the translation text should be between 1 and the maximum length.

[0065] In an optional embodiment of the present invention, after obtaining the translated text in step S124, the method may further include:

[0066] Step S125, determining an out-of-vocabulary word in the translation text, wherein the out-of-vocabulary word is a word that exists in the translation text but does not exist in the second language vocabulary;

[0067] Step S126: adding the out-of-vocabulary word to the second language vocabulary.

[0068] In practical applications, named entities often appear in the original text. Named entities refer to names of people, institutions, places, and all other entities identified by names. If the second language vocabulary does not contain the named entities that appear in the original text, the target text may have semantic deviations during the polishing process of the first model. Semantic deviation refers to the phenomenon that the text after polishing has deviations in sentence meaning or loss of information compared to the original text.

[0069] For example, suppose the original text is "The price given by Hualian is very suitable.", which includes the named entity "Hualian", which is a business name. Since the named entity does not exist in the English dictionary, the first model may output the following target text "The price offered by Hunan is appropriate." after polishing the original text, resulting in semantic deviation.

[0070] In order to avoid the above semantic shift, after obtaining the translated text, the embodiment of the present invention determines the out-of-vocabulary words in the translated text, and adds the out-of-vocabulary words to the second language vocabulary to expand the second language vocabulary.

[0071] The out-of-vocabulary words refer to words that do not need to be translated or modified. For example, the out-of-vocabulary words may include named entities, common abbreviations or abbreviations, etc. The embodiment of the present invention expands the second language vocabulary and adds the out-of-vocabulary words in the translated text, so that in the subsequent training of the first model, the expanded second language vocabulary can be used to avoid the situation where the first model cannot recognize the out-of-vocabulary words in the translated text, resulting in semantic deviation, thereby improving the accuracy of the polishing process of the first model.

[0072] In an optional embodiment of the present invention, the step S13 of inputting the translated text into the first model and outputting a processed text corresponding to the translated text through the first model includes:

[0073] Step S131, performing vectorization processing on the translation text to obtain a translation text vector;

[0074] Step S132, inputting the translation text vector into the first encoder for encoding to obtain a first encoder intermediate vector;

[0075] Step S133: input the first encoder intermediate vector into the first decoder for decoding to obtain a first decoder intermediate vector;

[0076] Step S134: Generate a processed word segmentation probability sequence according to the first decoder intermediate vector, wherein each element in the processed word segmentation probability sequence represents the probability of each word in the first language vocabulary appearing at each position in the processed text;

[0077] Step S135 : determining target word segments corresponding to each position in the processed text in the first language vocabulary according to the processed word segmentation probability sequence, to obtain the processed text.

[0078] The first model includes a first encoder and a first decoder. Inputting the translated text into the first model means inputting the translated text into the first encoder. The first encoder converts the input translated text into a vector sequence and then inputs the vector sequence output by the first encoder into a processed text. The processed text is the text after polishing the first language text.

[0079] The first encoder may be an encoder including a multi-layer neural network, and the first decoder may be a decoder including a multi-layer neural network. The first encoder and the first decoder may use the same neural network or different neural networks.

[0080] Vectorize the translation text of length m to obtain the translation text vector, which is assumed to be Translate the text vector The first encoder is input for encoding, and the first encoder intermediate vector can be obtained. Assume that the first encoder intermediate vector is recorded as Then the first encoder can be expressed as follows: The process of encoding to obtain the first encoder intermediate vector: Where encoder1 represents the encoding operation of the first encoder. The first encoder intermediate vector Input the first decoder for decoding to obtain the first decoder intermediate vector H t , assuming that Here, decoder1 represents the decoding operation of the first decoder.

[0081] According to the intermediate vector of the first decoder, a processed word segmentation probability sequence can be generated, which is assumed to be recorded as P t(w). Each element in the processed word segmentation probability sequence represents the probability of each word segment in the first language vocabulary appearing at each position in the processed text. According to the processed word segmentation probability sequence, the target word segment corresponding to each position in the processed text is determined in the first language vocabulary to obtain the processed text. For example, after polishing the translated text "In the past people used the letters or emails times more than they used telephones.", the following processed text "People used letters or emails times more than telephones in the past." is obtained.

[0082] Furthermore, the embodiment of the present invention adds a copy network to the first model. The copy network can be used to directly copy the correct parts of the original text that do not need to be translated or modified (such as named entities) to reduce the probability of semantic drift.

[0083] In an optional embodiment of the present invention, generating a processed word segmentation probability sequence according to the first decoder intermediate vector in step S134 includes:

[0084] Step A1: generating a first word segmentation probability sequence according to the first decoder intermediate vector;

[0085] Step A2: Based on a preset dimension, connect the first encoder intermediate vector and the first decoder intermediate vector to obtain a combined vector;

[0086] Step A3: input the combined vector into a fully connected layer for calculation to obtain a copy vector;

[0087] Step A4: generating a second word segmentation probability sequence according to the copy vector;

[0088] Step A5: Determine a processed word segmentation probability sequence according to the first word segmentation probability sequence and the second word segmentation probability sequence.

[0089] In the embodiment of the present invention, according to the first decoder intermediate vector H t , generate the processed word segmentation probability sequence P t (w), firstly, according to the first decoder intermediate vector H t , generate the first word segmentation probability sequence. Specifically, use a normalization function (such as softmax, etc.) to convert the first decoder intermediate vector H tMapped to the first word segmentation probability sequence. The first word segmentation probability sequence represents the probability distribution of each word in a sentence relative to the probability of the entire second language vocabulary, that is, the first word segmentation probability sequence is used to represent the probability of each word in the generated text. Therefore, the first word segmentation probability can also be called the "generation probability". Assume that the first word segmentation probability sequence is recorded as P gen .

[0090] Then, based on the preset dimension, the first encoder intermediate vector With the first decoder intermediate vector H t Connect and get the combined vector. Suppose the combined vector is recorded as Wherein, dim=1 indicates that the preset dimension is the first dimension. Furthermore, the first dimension indicates the length of the text. Based on the first dimension, the first encoder intermediate vector and the first decoder intermediate vector are connected, that is, the first encoder intermediate vector and the first decoder intermediate vector corresponding to each word segment in the first language text are merged.

[0091] Next, we combine the vector Input the fully connected layer for calculation to obtain the copy vector. Suppose the copy vector is recorded as H copy , the process of calculating the copy vector through the fully connected layer can be expressed as follows: Among them, W concat Represents the calculation of the fully connected layer, copying the vector H copy The length of the first dimension of the first decoder intermediate vector H t The length of the first dimension is equal.

[0092] The copy vector is obtained by merging the first encoder intermediate vector and the first decoder intermediate vector, wherein the correct information that does not need to be translated or modified is retained. According to the copy vector, a second word segmentation probability sequence can be generated. Specifically, a normalization function (such as softmax, etc.) is used to normalize the copy vector, and the copy vector H copy It is mapped to the probability distribution of each word segment in a sentence relative to the probability of the entire second language vocabulary. Each element in the second word segmentation probability sequence represents the probability that the word segment at each position in the processed text is the corresponding word segment in the original text. Therefore, the second word segmentation probability can also be called the "copy probability". Assume that the second word segmentation probability sequence is recorded as P copy , the greater the copy probability of a certain word in the second word segmentation probability sequence, the greater the probability that the word is copied from the original text.

[0093] Finally, according to the first word segmentation probability sequence P gen and the second word segmentation probability sequence P copy , determine the word segmentation probability sequence P after processingt (w). In the embodiment of the present invention, the processed word segmentation probability sequence P t (w) is determined based on the first word segmentation probability sequence (generation probability) and the second word segmentation probability sequence (copy probability). Specifically, the trainable parameter α can be used. copy and α gen , for the first word segmentation probability sequence P gen and the second word segmentation probability sequence P copy Perform comprehensive calculations to obtain the processed word segmentation probability sequence P t (w), which is the final probability distribution.

[0094] Specifically, P can be calculated by the following formula t (w):

[0095] P t (w) = α copy ×P copy +α gen ×P gen (1)

[0096] According to the processed word segmentation probability sequence P t (w), select the target word at the corresponding position from the second language vocabulary to get the processed text. Suppose the processed text vector is recorded as It should be noted that the length of the processed text may be the same as or different from the length of the translated text. In practical applications, the length of the processed text may be greater than, less than or equal to the length of the translated text. In the embodiment of the present invention, the length of the processed text is equal to the length of the translated text as an example.

[0097] In the embodiment of the present invention, a copy network is added to the first model, and the parameter α of the copy network is copy and α gen The parameter α can be adjusted continuously according to the unchanged parts of the translated text and the second language standard text in the training process of the first model. copy and α gen , learn the paradigm of the correct or unchangeable parts of the standard text in the second language. After the training is completed, the first model can automatically identify the correct or unchangeable parts of the original text and copy them directly.

[0098] For example, for the original text "The price given by Hualian is very suitable.", the copy network will combine the first encoder intermediate vector and the first decoder intermediate vector of the original text to obtain a copy vector, and obtain the copy probability by normalizing the copy vector, thereby obtaining a high copy probability of the word "Hualian". Therefore, in the processed word segmentation probability sequence obtained, the word segmentation "Hualian" can be directly copied, so that the named entity Hualian can be retained in the target text, thereby reducing the probability of semantic deviation due to the inability to recognize the named entity.

[0099] In an optional embodiment of the present invention, the first model and the second model may be trained simultaneously based on the parallel corpus from the first language to the second language, and the total loss value is calculated according to the difference between the processed text and the standard text of the second language in step S14, which may specifically include:

[0100] Step S141, calculating a first loss value according to the difference between the processed text and the second language standard text;

[0101] Step S142, calculating a second loss value according to the difference between the translated text and the second language standard text;

[0102] Step S143, calculating a third loss value according to the difference between the length of the translated text and the length of the second language standard text;

[0103] Step S144: Calculate a total loss value according to the first loss value, the second loss value, and the third loss value.

[0104] Specifically, according to the difference between the processed text and the second language standard text, the first loss value Loss is calculated. polish . Calculate the second loss value Loss based on the difference between the translated text and the second language standard text trans . According to the length of the translation text L predict The actual length of the second language standard text L real The difference between them is used to calculate the third loss value Loss length Finally, according to the first loss value Loss polish 、The second loss value Loss trans , and the third loss value Loss length , calculate the total loss value Loss.

[0105] Optionally, two trainable parameters α and β are used to calculate the total loss value Loss according to the following formula:

[0106] Loss=Loss polish +αLoss trans+ βLoss length (2)

[0107] According to the total loss value Loss, the model parameters of the first model and the model parameters of the second model are adjusted to minimize the value of Loss, and the training process of the first model and the second model is completed. The first model can be extracted and used to automatically polish the original text to be polished in the second language.

[0108] It should be noted that due to the general characteristics of the neural network model, in the early stage of the first model training, it is easy to generate sentence redundancy (for example, a word or phrase in a sentence is repeated several times) or omissions, which manifests as the sentence length being too long or too short. Therefore, the embodiment of the present invention uses the loss value of the translation text length as a training parameter to guide the first model and the second model, which can reduce the probability of the second decoder generating redundant or missing sentences and improve the overall training effect of the first model and the second model. It can be understood that the embodiment of the present invention does not limit the number and type of training parameters for calculating the total loss value.

[0109] The following is a detailed description of the specific process of using the trained first model to polish the original text in the second language to obtain the target text. Taking English as the second language as an example, before polishing the original text, it is necessary to first obtain the trained first model and English vocabulary. The specific process of using the first model to polish the original text in the second language is as follows:

[0110] Step B1: vectorize the original text to obtain the original text vector.

[0111] Specifically, the original text is vectorized in units of sentences, and each word in the sentence is converted into a corresponding vector. Assuming that the length of the original text is N (N is a positive integer), each word is converted into a vector x of a fixed length, then the original text vector can be expressed as (x1, x2, …, x N ).

[0112] Step B2: Input the original text vector into the first encoder for encoding to obtain the first encoder intermediate vector.

[0113] Specifically, the original text vector (x1, x2, ..., x N ) is input into the first encoder for encoding. The first encoder converts the input original text vector (x1, x2, …, x N ) is converted into the first encoder intermediate vector

[0114] Step B3: input the first encoder intermediate vector into the first decoder for decoding to obtain a first decoder intermediate vector.

[0115] Specifically, the first encoder intermediate vector Input the first decoder for decoding and obtain the first decoder intermediate vector

[0116] Step B4: Generate a first word segmentation probability sequence according to the first decoder intermediate vector.

[0117] Specifically, a normalization function such as softmax is used to transform the first decoder intermediate vector H t Mapped to the probability distribution P of each word segment in a sentence relative to the probability of the entire second language vocabulary gen , which can also be referred to as "generation probability".

[0118] Step B5: Based on a preset dimension, connect the first encoder intermediate vector and the first decoder intermediate vector to obtain a combined vector.

[0119] Specifically, the first encoder intermediate vector and the first decoder intermediate vector H t Connect and combine according to the first dimension to get the combined vector

[0120] Step B6: Input the combined vector into the fully connected layer for calculation to obtain the copy vector.

[0121] Specifically, the combined vector Input a fully connected layer for calculation to get the copy vector Among them, H copy The one-dimensional length of the decoder intermediate vector H t The one-dimensional lengths are equal.

[0122] Step B7: Generate a second word segmentation probability sequence based on the copy vector.

[0123] Specifically, a normalization function such as softmax is used to copy the vector H copy Normalize the copy vector H copy Mapped to the probability distribution P of each word segment in a sentence relative to the probability of the entire second language vocabulary copy , which can also be referred to as "copy probability".

[0124] Step B8: Determine a processed word segmentation probability sequence according to the first word segmentation probability sequence, the second word segmentation probability sequence, and the trained parameters.

[0125] Specifically, using the trained parameter αcopy and α gen , P copy With P gen After combined calculation, the word segmentation probability sequence after processing is obtained: P t (w) = α copy ×P copy +α gen ×P gen According to the processed word segmentation probability sequence, the target word segmentation at the corresponding position is selected from the English word list to obtain the target text.

[0126] In an optional embodiment of the present invention, before vectorizing the original text in step S101, the method may further include:

[0127] Step S21, identifying named entities in the original text;

[0128] Step S22, marking the segmented words corresponding to the named entities in the original text;

[0129] After outputting the target text through the first model, the method may further include: replacing the translation result corresponding to the marked word segment in the target text with the named entity.

[0130] In order to further reduce the probability of semantic deviation due to failure to identify named entities, the embodiment of the present invention performs named entity recognition on the original text before polishing the original text to identify the named entities in the original text.

[0131] After identifying the named entities in the original text, the word segments corresponding to the named entities in the original text are marked. The marked original text is polished by the trained first model, and after obtaining the target text, the translation results corresponding to the marked word segments are replaced with the marked word segments (i.e., the named entities) according to the corresponding relationship between the marked word segments and the original text.

[0132] For example, for the original text "The price given by Hualian is very suitable.", before polishing, entity recognition is first performed to obtain that the original text contains the named entity "Hualian", and the segmentation corresponding to the named entity is marked. After the original text is polished using the first model, assuming that the target text obtained is "The price offered by Hunan is appropriate.", according to the correspondence between the marked segmentation and the original text, the translation result (Hunan) corresponding to the marked segmentation (Hualian) is replaced with the marked segmentation (Hualian), and the replaced target text is "The price offered by Hualian is appropriate.", which can further reduce the probability of semantic deviation caused by the failure to recognize the named entity and improve the accuracy of the target text finally obtained.

[0133] In an optional embodiment of the present invention, after outputting the target text through the first model in step 102, the method may further include: displaying modification information of the target text relative to the original text.

[0134] After the embodiment of the present invention polishes the original text through the first model and outputs the target text, the modification information of the target text relative to the original text can also be displayed so that the user can intuitively understand what modifications have been made to the original text. The modification information at least includes deleting participles in the original text, adding new participles, adjusting the order of participles, etc.

[0135] In summary, the embodiment of the present invention pre-trains the first model, and the first model can be used to polish the original text to obtain the target text, and the original text and the target text correspond to the same language. The first model is trained based on the parallel corpus of translations from the first language to the second language and the output result of the second model, and the second model is used to translate the text in the first language into the text in the second language. Through the embodiment of the present invention, the first model can be used to realize automatic polishing of the original text, which can save a lot of manpower costs compared to the manual polishing processing method, and can improve the efficiency of the polishing process. In addition, since the parallel corpus of translation is easier to obtain than the parallel corpus of polishing, the embodiment of the present invention adopts a combination of the first model and the second model, and uses the parallel corpus of translations from the first language to the second language and the output result of the second model to train the first text, which can solve the problem of scarce training data for the first model and improve the robustness of the first model.

[0136] It should be noted that, for the sake of simplicity, the method embodiments are described as a series of action combinations, but those skilled in the art should be aware that the embodiments of the present invention are not limited by the order of the actions described, because according to the embodiments of the present invention, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of the present invention.

[0137] Device Embodiment

[0138] Reference Figure 2 , shows a structural block diagram of an embodiment of a text processing device of the present invention, the device may include:

[0139] The first vectorization module 201 is used to perform vectorization processing on the original text to obtain the original text vector;

[0140] The processing module 202 is used to input the original text vector into the first model, and output the target text through the first model. The original text and the target text correspond to the same language. The first model includes a copy network, and the copy network is used to retain the copied text in the original text in the target text. The first model is trained based on the parallel corpus of translations of the first language corresponding to the second language and the output result of the second model. The second model is used to translate the text in the first language into the text in the second language.

[0141] Optionally, the translation parallel corpus includes a first language text and a second language standard text corresponding to the first language text, and the device further includes:

[0142] A second vectorization module, used for performing vectorization processing on the first language text to obtain a first language text vector;

[0143] A translation module, configured to input the first language text vector into a second model, and output a translation text of the first language text corresponding to a second language through the second model;

[0144] a polishing module, configured to input the translation text into a first model, retain the copy text in the translation text through a copy network of the first model, and output a processed text corresponding to the translation text through the first model, wherein the copy text in the translation text is retained in the processed text;

[0145] a loss calculation module, configured to calculate a total loss value according to the difference between the processed text and the second language standard text;

[0146] A parameter adjustment module is used to adjust the model parameters of the first model according to the total loss value until the calculated total loss value reaches a preset convergence condition to obtain a trained first model.

[0147] Optionally, the copy network includes a first encoder and a first decoder, and the polishing module includes:

[0148] A vectorization submodule, used for performing vectorization processing on the translation text to obtain a translation text vector;

[0149] A first encoding submodule, configured to input the translation text vector into the first encoder for encoding to obtain a first encoder intermediate vector;

[0150] A first decoding submodule, configured to input the first encoder intermediate vector into the first decoder for decoding to obtain a first decoder intermediate vector;

[0151] A copy submodule, configured to generate a copy vector according to the first encoder intermediate vector and the first decoder intermediate vector;

[0152] A first probability calculation submodule is used to generate a processed word segmentation probability sequence according to the copy vector, wherein each element in the processed word segmentation probability sequence represents the probability of each word in the first language vocabulary appearing at each position in the processed text;

[0153] The processing submodule is used to determine the target segmentation corresponding to each position in the processed text in the first language vocabulary according to the processed segmentation probability sequence to obtain the processed text.

[0154] Optionally, the copy submodule includes:

[0155] A first probability calculation unit, configured to generate a first word segmentation probability sequence according to the first decoder intermediate vector;

[0156] a connecting unit, configured to connect the first encoder intermediate vector and the first decoder intermediate vector based on a preset dimension to obtain a combined vector;

[0157] The copy unit is used to input the combined vector into the fully connected layer for calculation to obtain a copy vector.

[0158] Optionally, the first probability calculation submodule includes:

[0159] A second probability calculation unit, used to generate a second word segmentation probability sequence according to the copy vector;

[0160] The third probability calculation unit is used to determine a processed word segmentation probability sequence according to the first word segmentation probability sequence, the second word segmentation probability sequence, the first parameter corresponding to the first word segmentation probability sequence, and the second parameter corresponding to the second word segmentation probability sequence.

[0161] Optionally, the second model includes a second encoder and a second decoder, and the translation module includes:

[0162] A second encoding submodule, configured to input the first language text vector into the second encoder for encoding to obtain a second encoder intermediate vector;

[0163] A second decoding submodule, configured to input the second encoder intermediate vector into the second decoder for decoding to obtain a second decoder intermediate vector;

[0164] A second probability calculation submodule, configured to generate a translation word segmentation probability sequence according to the second decoder intermediate vector, wherein each element in the translation word segmentation probability sequence represents a probability of each word in the second language vocabulary appearing at each position in the translation text;

[0165] The translation submodule is used to determine the target segmentation corresponding to each position in the translation text in the second language vocabulary according to the translation segmentation probability sequence to obtain the translation text.

[0166] Optionally, the device further comprises:

[0167] An out-of-vocabulary word determination module, used to determine out-of-vocabulary words in the translation text, wherein the out-of-vocabulary words are words that exist in the translation text but do not exist in the second language vocabulary;

[0168] The module for adding words outside the vocabulary is used to add the words outside the vocabulary to the second language vocabulary.

[0169] Optionally, the loss calculation module includes:

[0170] A first loss calculation submodule, configured to calculate a first loss value according to a difference between the processed text and the second language standard text;

[0171] A second loss calculation submodule, configured to calculate a second loss value according to a difference between the translated text and the second language standard text;

[0172] A third loss calculation submodule, configured to calculate a third loss value according to a difference between a length of the translated text and a length of the second language standard text;

[0173] The total loss calculation submodule is used to calculate the total loss value according to the first loss value, the second loss value, and the third loss value.

[0174] Optionally, the device further comprises:

[0175] A recognition module, used for recognizing named entities in the original text;

[0176] A marking module, used for marking the word segments corresponding to the named entities in the original text;

[0177] The device also includes:

[0178] A replacement module is used to replace the translation result corresponding to the marked word segment in the target text with the named entity.

[0179] Optionally, the device further comprises:

[0180] The information display module is used to display the modification information of the target text relative to the original text.

[0181] The embodiment of the present invention pre-trains a first model, and the first model can be used to polish the original text to obtain a target text, wherein the original text and the target text correspond to the same language. The first model is trained based on the parallel corpus of translations from the first language to the second language and the output result of the second model, and the second model is used to translate the text in the first language into the text in the second language. Through the embodiment of the present invention, the first model can be used to realize automatic polishing of the original text, which can save a lot of manpower costs compared to the manual polishing method, and can improve the efficiency of the polishing process. In addition, since the parallel corpus of translation is easier to obtain than the parallel corpus of polishing, the embodiment of the present invention adopts a combination of the first model and the second model, and uses the parallel corpus of translations from the first language to the second language and the output result of the second model to train the first text, which can solve the problem of scarce training data for the first model and improve the robustness of the first model. Through the device provided by the embodiment of the present invention, the translation result corresponding to the content to be translated can be obtained in real time in any currently running application interface, without the need to exit the currently running application, open the translation application, input the content to be translated into the translation application, and finally submit and obtain the translation result. This can avoid frequent switching between the current application and the translation application, thereby improving the efficiency of translation and user experience, and maintaining the continuity of the user's use of the current application.

[0182] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0183] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.

[0184] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.

[0185] An embodiment of the present invention provides a device for text processing, including a memory and one or more programs, wherein the one or more programs are stored in the memory and are configured to be executed by one or more processors. The one or more programs include instructions for performing the following operations: vectorizing an original text to obtain an original text vector; inputting the original text vector into a first model, and outputting a target text through the first model, wherein the original text and the target text correspond to the same language, the first model includes a copy network, and the copy network is used to retain the copied text in the original text in the target text, the first model is trained based on a parallel corpus of translations of a first language to a second language and an output result of a second model, and the second model is used to translate text in the first language into text in the second language.

[0186] Figure 3 8 is a block diagram of a device 800 for text processing according to an exemplary embodiment. For example, the device 800 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, etc.

[0187] Reference Figure 3 , the device 800 may include one or more of the following components: a processing component 802 , a memory 804 , a power component 806 , a multimedia component 808 , an audio component 810 , an input / output (I / O) interface 812 , a sensor component 814 , and a communication component 816 .

[0188] The processing component 802 generally controls the overall operation of the device 800, such as operations associated with display, phone calls, data communications, camera operations, and recording operations. The processing component 802 may include one or more processors 820 to execute instructions to complete all or part of the steps of the above-mentioned method. In addition, the processing component 802 may include one or more modules to facilitate the interaction between the processing component 802 and other components. For example, the processing component 802 may include a multimedia module to facilitate the interaction between the multimedia component 808 and the processing component 802.

[0189] The memory 804 is configured to store various types of data to support operations on the device 800. Examples of such data include instructions for any application or method operating on the device 800, contact data, phone book data, messages, pictures, videos, etc. The memory 804 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.

[0190] The power supply component 806 provides power to the various components of the device 800. The power supply component 806 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power for the device 800.

[0191] The multimedia component 808 includes a screen that provides an output interface between the device 800 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundaries of the touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 808 includes a front camera and / or a rear camera. When the device 800 is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera may receive external multimedia data. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.

[0192] The audio component 810 is configured to output and / or input audio signals. For example, the audio component 810 includes a microphone (MIC), and when the device 800 is in an operating mode, such as a call mode, a recording mode, and a voice information processing mode, the microphone is configured to receive an external audio signal. The received audio signal can be further stored in the memory 804 or sent via the communication component 816. In some embodiments, the audio component 810 also includes a speaker for outputting audio signals.

[0193] I / O interface 812 provides an interface between processing component 802 and peripheral interface modules, such as keyboards, click wheels, buttons, etc. These buttons may include but are not limited to: home button, volume button, start button, and lock button.

[0194] The sensor assembly 814 includes one or more sensors for providing various aspects of status assessment for the device 800. For example, the sensor assembly 814 can detect the open / closed state of the device 800, the relative positioning of components, such as the display and keypad of the device 800, the sensor assembly 814 can also detect the position change of the text processing device 800 or a component of the device 800, the presence or absence of user contact with the device 800, the orientation or acceleration / deceleration of the device 800, and the temperature change of the device 800. The sensor assembly 814 may include a proximity sensor configured to detect the presence of nearby objects without any physical contact. The sensor assembly 814 may also include an optical sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 814 may also include an accelerometer, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.

[0195] The communication component 816 is configured to facilitate wired or wireless communication between the device 800 and other devices. The device 800 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 816 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 816 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency information processing (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.

[0196] In an exemplary embodiment, the apparatus 800 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 to perform the above method.

[0197] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 804 including instructions, and the instructions can be executed by the processor 820 of the device 800 to perform the above method. For example, the non-transitory computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.

[0198] Figure 41 is a schematic diagram of the structure of the server in some embodiments of the present invention. The server 1900 may have relatively large differences due to different configurations or performances, and may include one or more central processing units (CPU) 1922 (for example, one or more processors) and memory 1932, and one or more storage media 1930 (for example, one or more mass storage devices) storing application programs 1942 or data 1944. Among them, the memory 1932 and the storage medium 1930 can be short-term storage or permanent storage. The program stored in the storage medium 1930 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations in the server. Furthermore, the central processing unit 1922 can be configured to communicate with the storage medium 1930 and execute a series of instruction operations in the storage medium 1930 on the server 1900.

[0199] The server 1900 may also include one or more power supplies 1926, one or more wired or wireless network interfaces 1950, one or more input and output interfaces 1958, one or more keyboards 1956, and / or, one or more operating systems 1941, such as Windows ServerTM, Mac OS XTM, UnixTM, LinuxTM, FreeBSDTM, etc.

[0200] A non-transitory computer-readable storage medium, when the instructions in the storage medium are executed by a processor of a device (server or terminal), enables the device to perform Figure 1 The text processing method shown.

[0201] A non-transitory computer-readable storage medium, when the instructions in the storage medium are executed by a processor of a device (server or terminal), the device is able to execute a text processing method, the method comprising: vectorizing an original text to obtain an original text vector; inputting the original text vector into a first model, and outputting a target text through the first model, wherein the original text and the target text correspond to the same language, the first model comprises a copy network, and the copy network is used to retain the copied text in the original text in the target text, the first model is trained based on a parallel corpus of translations of a first language to a second language and the output result of a second model, and the second model is used to translate text in the first language into text in the second language.

[0202] The embodiment of the present invention discloses A1, a text processing method, comprising:

[0203] Vectorize the original text to obtain the original text vector;

[0204] The original text vector is input into a first model, and a target text is output through the first model. The original text and the target text correspond to the same language. The first model includes a copy network, and the copy network is used to retain the copied text in the original text in the target text. The first model is trained based on a parallel corpus of translations of a first language corresponding to a second language and an output result of a second model. The second model is used to translate text in the first language into text in the second language.

[0205] A2. According to the method described in A1, the translation parallel corpus includes a first language text and a second language standard text corresponding to the first language text, and the first model is trained by the following steps:

[0206] performing vectorization processing on the first language text to obtain a first language text vector;

[0207] Inputting the first language text vector into a second model, and outputting a translation text of the first language text corresponding to a second language through the second model;

[0208] Inputting the translated text into a first model, retaining the copied text in the translated text through the copy network of the first model, and outputting a processed text corresponding to the translated text through the first model, wherein the copied text in the translated text is retained in the processed text;

[0209] Calculating a total loss value based on the difference between the processed text and the second language standard text;

[0210] According to the total loss value, the model parameters of the first model are adjusted until the calculated total loss value reaches a preset convergence condition, thereby obtaining a trained first model.

[0211] A3. The method according to A2, wherein the copy network includes a first encoder and a first decoder, wherein the translated text is input into a first model, the copied text in the translated text is retained through the copy network of the first model, and the processed text corresponding to the translated text is output through the first model, comprising:

[0212] Performing vectorization processing on the translation text to obtain a translation text vector;

[0213] Inputting the translation text vector into the first encoder for encoding to obtain a first encoder intermediate vector;

[0214] Inputting the first encoder intermediate vector into the first decoder for decoding to obtain a first decoder intermediate vector;

[0215] generating a copy vector according to the first encoder intermediate vector and the first decoder intermediate vector;

[0216] Generate a processed word segmentation probability sequence according to the copy vector, wherein each element in the processed word segmentation probability sequence represents the probability of each word segmentation in the first language vocabulary appearing at each position in the processed text;

[0217] According to the processed word segmentation probability sequence, the target word segmentation corresponding to each position in the processed text is determined in the first language vocabulary to obtain the processed text.

[0218] A4. The method according to A3, wherein generating a copy vector according to the first encoder intermediate vector and the first decoder intermediate vector comprises:

[0219] Generate a first word segmentation probability sequence according to the first decoder intermediate vector;

[0220] Based on a preset dimension, connecting the first encoder intermediate vector and the first decoder intermediate vector to obtain a combined vector;

[0221] The combined vector is input into the fully connected layer for calculation to obtain a copy vector.

[0222] A5. The method according to A4, wherein generating a processed word segmentation probability sequence according to the copy vector comprises:

[0223] Generating a second word segmentation probability sequence according to the copy vector;

[0224] A processed word segmentation probability sequence is determined according to the first word segmentation probability sequence, the second word segmentation probability sequence, a first parameter corresponding to the first word segmentation probability sequence, and a second parameter corresponding to the second word segmentation probability sequence.

[0225] A6. The method according to A2, wherein the second model includes a second encoder and a second decoder, and the step of inputting the first language text vector into the second model and outputting a translation text of the first language text corresponding to the second language through the second model includes:

[0226] Inputting the first language text vector into the second encoder for encoding to obtain a second encoder intermediate vector;

[0227] Inputting the second encoder intermediate vector into the second decoder for decoding to obtain a second decoder intermediate vector;

[0228] generating a translation word segmentation probability sequence according to the second decoder intermediate vector, wherein each element in the translation word segmentation probability sequence represents the probability of each word in the second language vocabulary appearing at each position in the translation text;

[0229] According to the translation word segmentation probability sequence, the target word segmentation corresponding to each position in the translation text is determined in the second language word table to obtain the translation text.

[0230] A7. According to the method of A6, after obtaining the translated text, the method further comprises:

[0231] Determining an out-of-vocabulary word in the translation text, wherein the out-of-vocabulary word is a word that exists in the translation text but does not exist in the second language vocabulary;

[0232] The out-of-vocabulary word is added to the second language vocabulary.

[0233] A8. The method according to A2, wherein the total loss value is calculated based on the difference between the processed text and the second language standard text, comprising:

[0234] Calculating a first loss value according to the difference between the processed text and the second language standard text;

[0235] Calculating a second loss value according to the difference between the translated text and the second language standard text;

[0236] Calculating a third loss value according to the difference between the length of the translated text and the length of the second language standard text;

[0237] A total loss value is calculated according to the first loss value, the second loss value, and the third loss value.

[0238] A9. According to the method of A1, before vectorizing the original text, the method further includes:

[0239] Identifying named entities in the source text;

[0240] Marking the word segments corresponding to the named entities in the original text;

[0241] After outputting the target text through the first model, the method further includes:

[0242] The translation result corresponding to the marked word segment in the target text is replaced with the named entity.

[0243] A10. According to the method of A1, after outputting the target text through the first model, the method further includes:

[0244] Display modification information of the target text relative to the original text.

[0245] The embodiment of the present invention discloses B11, a text processing device, including:

[0246] The first vectorization module is used to perform vectorization processing on the original text to obtain the original text vector;

[0247] A processing module is used to input the original text vector into a first model, and output a target text through the first model, wherein the original text and the target text correspond to the same language, the first model includes a copy network, and the copy network is used to retain the copied text in the original text in the target text, the first model is trained based on a parallel corpus of translations of a first language corresponding to a second language and an output result of a second model, and the second model is used to translate text in the first language into text in the second language.

[0248] B12. The device according to claim 11, wherein the translation parallel corpus includes a first language text and a second language standard text corresponding to the first language text, and the device further comprises:

[0249] A second vectorization module, used for performing vectorization processing on the first language text to obtain a first language text vector;

[0250] A translation module, configured to input the first language text vector into a second model, and output a translation text of the first language text corresponding to a second language through the second model;

[0251] a polishing module, configured to input the translation text into a first model, retain the copy text in the translation text through a copy network of the first model, and output a processed text corresponding to the translation text through the first model, wherein the copy text in the translation text is retained in the processed text;

[0252] a loss calculation module, configured to calculate a total loss value according to the difference between the processed text and the second language standard text;

[0253] A parameter adjustment module is used to adjust the model parameters of the first model according to the total loss value until the calculated total loss value reaches a preset convergence condition to obtain a trained first model.

[0254] B13. The device according to B12, wherein the copy network comprises a first encoder and a first decoder, and the polishing module comprises:

[0255] A vectorization submodule, used for performing vectorization processing on the translation text to obtain a translation text vector;

[0256] A first encoding submodule, configured to input the translation text vector into the first encoder for encoding to obtain a first encoder intermediate vector;

[0257] A first decoding submodule, configured to input the first encoder intermediate vector into the first decoder for decoding to obtain a first decoder intermediate vector;

[0258] A copy submodule, configured to generate a copy vector according to the first encoder intermediate vector and the first decoder intermediate vector;

[0259] A first probability calculation submodule is used to generate a processed word segmentation probability sequence according to the copy vector, wherein each element in the processed word segmentation probability sequence represents the probability of each word in the first language vocabulary appearing at each position in the processed text;

[0260] The processing submodule is used to determine the target segmentation corresponding to each position in the processed text in the first language vocabulary according to the processed segmentation probability sequence to obtain the processed text.

[0261] B14. The device according to B13, wherein the copy submodule comprises:

[0262] A first probability calculation unit, configured to generate a first word segmentation probability sequence according to the first decoder intermediate vector;

[0263] a connecting unit, configured to connect the first encoder intermediate vector and the first decoder intermediate vector based on a preset dimension to obtain a combined vector;

[0264] The copy unit is used to input the combined vector into the fully connected layer for calculation to obtain a copy vector.

[0265] B15. According to the apparatus described in B14, the first probability calculation submodule comprises:

[0266] A second probability calculation unit, used to generate a second word segmentation probability sequence according to the copy vector;

[0267] The third probability calculation unit is used to determine a processed word segmentation probability sequence according to the first word segmentation probability sequence, the second word segmentation probability sequence, the first parameter corresponding to the first word segmentation probability sequence, and the second parameter corresponding to the second word segmentation probability sequence.

[0268] B16. According to the apparatus described in B12, the second model includes a second encoder and a second decoder, and the translation module includes:

[0269] A second encoding submodule, configured to input the first language text vector into the second encoder for encoding to obtain a second encoder intermediate vector;

[0270] A second decoding submodule, configured to input the second encoder intermediate vector into the second decoder for decoding to obtain a second decoder intermediate vector;

[0271] A second probability calculation submodule, configured to generate a translation word segmentation probability sequence according to the second decoder intermediate vector, wherein each element in the translation word segmentation probability sequence represents a probability of each word in the second language vocabulary appearing at each position in the translation text;

[0272] The translation submodule is used to determine the target segmentation corresponding to each position in the translation text in the second language vocabulary according to the translation segmentation probability sequence to obtain the translation text.

[0273] B17. The device according to B16, further comprising:

[0274] An out-of-vocabulary word determination module, used to determine out-of-vocabulary words in the translation text, wherein the out-of-vocabulary words are words that exist in the translation text but do not exist in the second language vocabulary;

[0275] The module for adding words outside the vocabulary is used to add the words outside the vocabulary to the second language vocabulary.

[0276] B18. According to the device described in B12, the loss calculation module comprises:

[0277] A first loss calculation submodule, configured to calculate a first loss value according to a difference between the processed text and the second language standard text;

[0278] A second loss calculation submodule, configured to calculate a second loss value according to a difference between the translated text and the second language standard text;

[0279] A third loss calculation submodule, configured to calculate a third loss value according to a difference between a length of the translated text and a length of the second language standard text;

[0280] The total loss calculation submodule is used to calculate the total loss value according to the first loss value, the second loss value, and the third loss value.

[0281] B19. The device according to B11, further comprising:

[0282] A recognition module, used for recognizing named entities in the original text;

[0283] A marking module, used for marking the word segments corresponding to the named entities in the original text;

[0284] The device also includes:

[0285] A replacement module is used to replace the translation result corresponding to the marked word segment in the target text with the named entity.

[0286] B20. The device according to B11, further comprising:

[0287] The information display module is used to display the modification information of the target text relative to the original text.

[0288] The embodiment of the present invention discloses C21, a device for text processing, comprising a memory and one or more programs, wherein the one or more programs are stored in the memory and are configured to be executed by one or more processors. The one or more programs include instructions for performing the following operations:

[0289] Vectorize the original text to obtain the original text vector;

[0290] The original text vector is input into a first model, and a target text is output through the first model. The original text and the target text correspond to the same language. The first model includes a copy network, and the copy network is used to retain the copied text in the original text in the target text. The first model is trained based on a parallel corpus of translations of a first language corresponding to a second language and an output result of a second model. The second model is used to translate text in the first language into text in the second language.

[0291] C22. According to the apparatus described in C21, the translation parallel corpus includes a first language text and a second language standard text corresponding to the first language text, and the first model is trained by the following steps:

[0292] performing vectorization processing on the first language text to obtain a first language text vector;

[0293] Inputting the first language text vector into a second model, and outputting a translation text of the first language text corresponding to a second language through the second model;

[0294] Inputting the translated text into a first model, retaining the copied text in the translated text through the copy network of the first model, and outputting a processed text corresponding to the translated text through the first model, wherein the copied text in the translated text is retained in the processed text;

[0295] Calculating a total loss value based on the difference between the processed text and the second language standard text;

[0296] According to the total loss value, the model parameters of the first model are adjusted until the calculated total loss value reaches a preset convergence condition, thereby obtaining a trained first model.

[0297] C23. The device according to C22, wherein the copy network includes a first encoder and a first decoder, wherein the step of inputting the translated text into a first model, retaining the copied text in the translated text through the copy network of the first model, and outputting a processed text corresponding to the translated text through the first model comprises:

[0298] Performing vectorization processing on the translation text to obtain a translation text vector;

[0299] Inputting the translation text vector into the first encoder for encoding to obtain a first encoder intermediate vector;

[0300] Inputting the first encoder intermediate vector into the first decoder for decoding to obtain a first decoder intermediate vector;

[0301] generating a copy vector according to the first encoder intermediate vector and the first decoder intermediate vector;

[0302] Generate a processed word segmentation probability sequence according to the copy vector, wherein each element in the processed word segmentation probability sequence represents the probability of each word segmentation in the first language vocabulary appearing at each position in the processed text;

[0303] According to the processed word segmentation probability sequence, the target word segmentation corresponding to each position in the processed text is determined in the first language vocabulary to obtain the processed text.

[0304] C24. The apparatus according to C23, wherein generating a copy vector according to the first encoder intermediate vector and the first decoder intermediate vector comprises:

[0305] Generate a first word segmentation probability sequence according to the first decoder intermediate vector;

[0306] Based on a preset dimension, connecting the first encoder intermediate vector and the first decoder intermediate vector to obtain a combined vector;

[0307] The combined vector is input into the fully connected layer for calculation to obtain a copy vector.

[0308] C25. According to the apparatus described in C24, generating a processed word segmentation probability sequence according to the copy vector includes:

[0309] Generating a second word segmentation probability sequence according to the copy vector;

[0310] A processed word segmentation probability sequence is determined according to the first word segmentation probability sequence, the second word segmentation probability sequence, a first parameter corresponding to the first word segmentation probability sequence, and a second parameter corresponding to the second word segmentation probability sequence.

[0311] C26. According to the apparatus described in C22, the second model includes a second encoder and a second decoder, and the step of inputting the first language text vector into the second model and outputting a translation text of the first language text corresponding to the second language through the second model includes:

[0312] Inputting the first language text vector into the second encoder for encoding to obtain a second encoder intermediate vector;

[0313] Inputting the second encoder intermediate vector into the second decoder for decoding to obtain a second decoder intermediate vector;

[0314] generating a translation word segmentation probability sequence according to the second decoder intermediate vector, wherein each element in the translation word segmentation probability sequence represents the probability of each word in the second language vocabulary appearing at each position in the translation text;

[0315] According to the translation word segmentation probability sequence, the target word segmentation corresponding to each position in the translation text is determined in the second language word table to obtain the translation text.

[0316] C27. The device according to C26, wherein the device is further configured to execute, by one or more processors, the one or more programs including instructions for performing the following operations:

[0317] Determining an out-of-vocabulary word in the translation text, wherein the out-of-vocabulary word is a word that exists in the translation text but does not exist in the second language vocabulary;

[0318] The out-of-vocabulary word is added to the second language vocabulary.

[0319] C28. The device according to C22, wherein the total loss value is calculated based on the difference between the processed text and the second language standard text, comprising:

[0320] Calculating a first loss value according to the difference between the processed text and the second language standard text;

[0321] Calculating a second loss value according to the difference between the translated text and the second language standard text;

[0322] Calculating a third loss value according to the difference between the length of the translated text and the length of the second language standard text;

[0323] A total loss value is calculated according to the first loss value, the second loss value, and the third loss value.

[0324] C29. The device according to C21, wherein the device is further configured to execute, by one or more processors, the one or more programs including instructions for performing the following operations:

[0325] Identifying named entities in the source text;

[0326] Marking the word segments corresponding to the named entities in the original text;

[0327] The device is also configured to execute, by one or more processors, the one or more programs including instructions for performing the following operations:

[0328] The translation result corresponding to the marked word segment in the target text is replaced with the named entity.

[0329] C30. The device according to C21, wherein the device is further configured to execute, by one or more processors, the one or more programs including instructions for performing the following operations:

[0330] Display modification information of the target text relative to the original text.

[0331] The embodiment of the present invention discloses D31, a machine-readable medium having instructions stored thereon, which, when executed by one or more processors, enables the device to execute the text processing method as described in one or more of A1 to A10.

[0332] Those skilled in the art will readily appreciate other embodiments of the invention after considering the specification and practicing the invention disclosed herein. The present invention is intended to cover any variations, uses or adaptations of the present invention that follow the general principles of the present invention and include common knowledge or customary techniques in the art that are not disclosed in this disclosure. The description and examples are to be considered exemplary only, and the true scope and spirit of the present invention are indicated by the following claims.

[0333] It should be understood that the present invention is not limited to the exact construction that has been described above and shown in the drawings and that various modifications and changes may be made without departing from the scope thereof. The scope of the present invention is limited only by the appended claims.

[0334] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

[0335] The above is a detailed introduction to a text processing method, a text processing device and a device for text processing provided by the present invention. Specific examples are used in this article to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. At the same time, for those skilled in the art, according to the idea of ​​the present invention, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.

Claims

1. A text processing method, It is characterized in that The method comprises: Vectorize the original text to obtain the original text vector; Inputting the original text vector into a first model, outputting a target text through the first model, wherein the original text and the target text correspond to the same language, the first model includes a copy network, the copy network is used to retain the copy text in the original text in the target text, the first model is trained based on a parallel corpus of translations of a first language corresponding to a second language and an output result of a second model, and the second model is used to translate text in the first language into text in the second language; The translation parallel corpus includes a first language text and a second language standard text corresponding to the first language text. The first model is trained by the following steps: performing vectorization processing on the first language text to obtain a first language text vector; Inputting the first language text vector into a second model, and outputting a translation text of the first language text corresponding to a second language through the second model; Inputting the translated text into a first model, retaining the copied text in the translated text through the copy network of the first model, and outputting a processed text corresponding to the translated text through the first model, wherein the copied text in the translated text is retained in the processed text; Calculating a total loss value based on the difference between the processed text and the second language standard text; According to the total loss value, adjust the model parameters of the first model until the calculated total loss value reaches a preset convergence condition, thereby obtaining a trained first model; The copy network includes a first encoder and a first decoder, and the step of inputting the translation text into the first model, retaining the copy text in the translation text through the copy network of the first model, and outputting the processed text corresponding to the translation text through the first model includes: Performing vectorization processing on the translation text to obtain a translation text vector; Inputting the translation text vector into the first encoder for encoding to obtain a first encoder intermediate vector; Inputting the first encoder intermediate vector into the first decoder for decoding to obtain a first decoder intermediate vector; Generate a first word segmentation probability sequence according to the first decoder intermediate vector; Based on a preset dimension, connecting the first encoder intermediate vector and the first decoder intermediate vector to obtain a combined vector; Input the combined vector into a fully connected layer for calculation to obtain a copy vector; Generate a processed word segmentation probability sequence according to the copy vector, wherein each element in the processed word segmentation probability sequence represents the probability of each word segmentation in the first language vocabulary appearing at each position in the processed text; According to the processed word segmentation probability sequence, determining the target word segmentation corresponding to each position in the processed text in the first language vocabulary to obtain the processed text; The method further comprises: Using a machine translation model to train a reverse model, the reverse model is used to convert text in a standard preset language into text in an irregular preset language, wherein the preset language is a text language that needs to be polished; Using the text in the preset language with standard expression and the text in the preset language with irregular expression that are aligned in pairs as polished parallel corpus, and using the polished parallel corpus to train the first model; The calculating the total loss value according to the difference between the processed text and the second language standard text comprises: Calculating a first loss value according to the difference between the processed text and the second language standard text; Calculating a second loss value according to the difference between the translated text and the second language standard text; Calculating a third loss value according to the difference between the length of the translated text and the length of the second language standard text; A total loss value is calculated according to the first loss value, the second loss value, and the third loss value.

2. The method according to claim 1, It is characterized in that The step of generating a processed word segmentation probability sequence according to the copy vector includes: Generating a second word segmentation probability sequence according to the copy vector; A processed word segmentation probability sequence is determined according to the first word segmentation probability sequence, the second word segmentation probability sequence, a first parameter corresponding to the first word segmentation probability sequence, and a second parameter corresponding to the second word segmentation probability sequence.

3. The method according to claim 1, It is characterized in that The second model includes a second encoder and a second decoder, and the step of inputting the first language text vector into the second model and outputting a translation text of the first language text corresponding to the second language through the second model includes: Inputting the first language text vector into the second encoder for encoding to obtain a second encoder intermediate vector; Inputting the second encoder intermediate vector into the second decoder for decoding to obtain a second decoder intermediate vector; generating a translation word segmentation probability sequence according to the second decoder intermediate vector, wherein each element in the translation word segmentation probability sequence represents the probability of each word in the second language vocabulary appearing at each position in the translation text; According to the translation word segmentation probability sequence, the target word segmentation corresponding to each position in the translation text is determined in the second language word table to obtain the translation text.

4. The method according to claim 3, It is characterized in that After obtaining the translated text, the method further includes: Determining an out-of-vocabulary word in the translation text, wherein the out-of-vocabulary word is a word that exists in the translation text but does not exist in the second language vocabulary; The out-of-vocabulary word is added to the second language vocabulary.

5. The method according to claim 1, It is characterized in that Before the vectorization processing is performed on the original text, the method further includes: Identifying named entities in the source text; Marking the word segments corresponding to the named entities in the original text; After outputting the target text through the first model, the method further includes: The translation result corresponding to the marked word segment in the target text is replaced with the named entity.

6. The method according to claim 1, It is characterized in that After outputting the target text through the first model, the method further includes: Display modification information of the target text relative to the original text.

7. A text processing device, It is characterized in that The device comprises: The first vectorization module is used to perform vectorization processing on the original text to obtain the original text vector; a processing module, configured to input the original text vector into a first model, and output a target text through the first model, wherein the original text and the target text correspond to the same language, the first model includes a copy network, and the copy network is configured to retain the copy text in the original text in the target text, the first model is trained based on a parallel corpus of translations of a first language corresponding to a second language and an output result of a second model, and the second model is configured to translate text in the first language into text in the second language; The translation parallel corpus includes a first language text and a second language standard text corresponding to the first language text, and the device further includes: A second vectorization module, used for performing vectorization processing on the first language text to obtain a first language text vector; A translation module, configured to input the first language text vector into a second model, and output a translation text of the first language text corresponding to a second language through the second model; a polishing module, configured to input the translation text into a first model, retain the copy text in the translation text through a copy network of the first model, and output a processed text corresponding to the translation text through the first model, wherein the copy text in the translation text is retained in the processed text; a loss calculation module, configured to calculate a total loss value according to the difference between the processed text and the second language standard text; A parameter adjustment module, used to adjust the model parameters of the first model according to the total loss value until the calculated total loss value reaches a preset convergence condition, thereby obtaining a trained first model; The copy network includes a first encoder and a first decoder, and the polishing module includes: A vectorization submodule, used for performing vectorization processing on the translation text to obtain a translation text vector; A first encoding submodule, configured to input the translation text vector into the first encoder for encoding to obtain a first encoder intermediate vector; A first decoding submodule, configured to input the first encoder intermediate vector into the first decoder for decoding to obtain a first decoder intermediate vector; A copy submodule, configured to generate a copy vector according to the first encoder intermediate vector and the first decoder intermediate vector; A first probability calculation submodule is used to generate a processed word segmentation probability sequence according to the copy vector, wherein each element in the processed word segmentation probability sequence represents the probability of each word in the first language vocabulary appearing at each position in the processed text; A processing submodule, configured to determine, in the first language vocabulary, target segmented words corresponding to each position in the processed text according to the processed segmented word probability sequence, to obtain the processed text; The copy submodule includes: A first probability calculation unit, configured to generate a first word segmentation probability sequence according to the first decoder intermediate vector; a connecting unit, configured to connect the first encoder intermediate vector and the first decoder intermediate vector based on a preset dimension to obtain a combined vector; A copy unit, used for inputting the combined vector into a fully connected layer for calculation to obtain a copy vector; Using a machine translation model to train a reverse model, the reverse model is used to convert text in a standard preset language into text in an irregular preset language, wherein the preset language is a text language that needs to be polished; Using the text in the preset language with standard expression and the text in the preset language with irregular expression that are aligned in pairs as polished parallel corpus, and using the polished parallel corpus to train the first model; The loss calculation module comprises: A first loss calculation submodule, configured to calculate a first loss value according to a difference between the processed text and the second language standard text; A second loss calculation submodule, configured to calculate a second loss value according to a difference between the translated text and the second language standard text; A third loss calculation submodule, configured to calculate a third loss value according to a difference between a length of the translated text and a length of the second language standard text; The total loss calculation submodule is used to calculate the total loss value according to the first loss value, the second loss value, and the third loss value.

8. The device according to claim 7, It is characterized in that The first probability calculation submodule includes: A second probability calculation unit, used to generate a second word segmentation probability sequence according to the copy vector; The third probability calculation unit is used to determine a processed word segmentation probability sequence according to the first word segmentation probability sequence, the second word segmentation probability sequence, the first parameter corresponding to the first word segmentation probability sequence, and the second parameter corresponding to the second word segmentation probability sequence.

9. The device according to claim 7, It is characterized in that The second model includes a second encoder and a second decoder, and the translation module includes: A second encoding submodule, configured to input the first language text vector into the second encoder for encoding to obtain a second encoder intermediate vector; A second decoding submodule, configured to input the second encoder intermediate vector into the second decoder for decoding to obtain a second decoder intermediate vector; A second probability calculation submodule, configured to generate a translation word segmentation probability sequence according to the second decoder intermediate vector, wherein each element in the translation word segmentation probability sequence represents a probability of each word in the second language vocabulary appearing at each position in the translation text; The translation submodule is used to determine the target segmentation corresponding to each position in the translation text in the second language vocabulary according to the translation segmentation probability sequence to obtain the translation text.

10. The device according to claim 9, It is characterized in that The device also includes: An out-of-vocabulary word determination module, used to determine out-of-vocabulary words in the translation text, wherein the out-of-vocabulary words are words that exist in the translation text but do not exist in the second language vocabulary; The module for adding words outside the vocabulary is used to add the words outside the vocabulary to the second language vocabulary.

11. The device according to claim 7, It is characterized in that The device also includes: A recognition module, used for recognizing named entities in the original text; A marking module, used for marking the word segments corresponding to the named entities in the original text; The device also includes: A replacement module is used to replace the translation result corresponding to the marked word segment in the target text with the named entity.

12. The device according to claim 7, It is characterized in that The device also includes: The information display module is used to display the modification information of the target text relative to the original text.

13. A device for text processing, It is characterized in that The system comprises a memory and one or more programs, wherein the one or more programs are stored in the memory and are configured to be executed by one or more processors, wherein the one or more programs include instructions for performing the following operations: Vectorize the original text to obtain the original text vector; Inputting the original text vector into a first model, outputting a target text through the first model, wherein the original text and the target text correspond to the same language, the first model includes a copy network, the copy network is used to retain the copy text in the original text in the target text, the first model is trained based on a parallel corpus of translations of a first language corresponding to a second language and an output result of a second model, and the second model is used to translate text in the first language into text in the second language; The translation parallel corpus includes a first language text and a second language standard text corresponding to the first language text. The first model is trained by the following steps: performing vectorization processing on the first language text to obtain a first language text vector; Inputting the first language text vector into a second model, and outputting a translation text of the first language text corresponding to a second language through the second model; Inputting the translated text into a first model, retaining the copied text in the translated text through the copy network of the first model, and outputting a processed text corresponding to the translated text through the first model, wherein the copied text in the translated text is retained in the processed text; Calculating a total loss value based on the difference between the processed text and the second language standard text; According to the total loss value, adjust the model parameters of the first model until the calculated total loss value reaches a preset convergence condition, thereby obtaining a trained first model; The copy network includes a first encoder and a first decoder, and the step of inputting the translation text into the first model, retaining the copy text in the translation text through the copy network of the first model, and outputting the processed text corresponding to the translation text through the first model includes: Performing vectorization processing on the translation text to obtain a translation text vector; Inputting the translation text vector into the first encoder for encoding to obtain a first encoder intermediate vector; Inputting the first encoder intermediate vector into the first decoder for decoding to obtain a first decoder intermediate vector; Generate a first word segmentation probability sequence according to the first decoder intermediate vector; Based on a preset dimension, connecting the first encoder intermediate vector and the first decoder intermediate vector to obtain a combined vector; Input the combined vector into a fully connected layer for calculation to obtain a copy vector; Generate a processed word segmentation probability sequence according to the copy vector, wherein each element in the processed word segmentation probability sequence represents the probability of each word segmentation in the first language vocabulary appearing at each position in the processed text; According to the processed word segmentation probability sequence, determining the target word segmentation corresponding to each position in the processed text in the first language vocabulary to obtain the processed text; Using a machine translation model to train a reverse model, the reverse model is used to convert text in a standard preset language into text in an irregular preset language, wherein the preset language is a text language that needs to be polished; Using the text in the preset language with standard expression and the text in the preset language with irregular expression that are aligned in pairs as polished parallel corpus, and using the polished parallel corpus to train the first model; The calculating the total loss value according to the difference between the processed text and the second language standard text comprises: Calculating a first loss value according to the difference between the processed text and the second language standard text; Calculating a second loss value according to the difference between the translated text and the second language standard text; Calculating a third loss value according to the difference between the length of the translated text and the length of the second language standard text; A total loss value is calculated according to the first loss value, the second loss value, and the third loss value.

14. The device according to claim 13, It is characterized in that The step of generating a processed word segmentation probability sequence according to the copy vector includes: Generating a second word segmentation probability sequence according to the copy vector; A processed word segmentation probability sequence is determined according to the first word segmentation probability sequence, the second word segmentation probability sequence, a first parameter corresponding to the first word segmentation probability sequence, and a second parameter corresponding to the second word segmentation probability sequence.

15. The device according to claim 13, It is characterized in that The second model includes a second encoder and a second decoder, and the step of inputting the first language text vector into the second model and outputting a translation text of the first language text corresponding to the second language through the second model includes: Inputting the first language text vector into the second encoder for encoding to obtain a second encoder intermediate vector; Inputting the second encoder intermediate vector into the second decoder for decoding to obtain a second decoder intermediate vector; generating a translation word segmentation probability sequence according to the second decoder intermediate vector, wherein each element in the translation word segmentation probability sequence represents the probability of each word in the second language vocabulary appearing at each position in the translation text; According to the translation word segmentation probability sequence, the target word segmentation corresponding to each position in the translation text is determined in the second language word table to obtain the translation text.

16. The device according to claim 15, It is characterized in that The device is also configured to execute, by one or more processors, the one or more programs including instructions for: Determining an out-of-vocabulary word in the translation text, wherein the out-of-vocabulary word is a word that exists in the translation text but does not exist in the second language vocabulary; The out-of-vocabulary word is added to the second language vocabulary.

17. The device according to claim 13, It is characterized in that The device is also configured to execute, by one or more processors, the one or more programs including instructions for: Identifying named entities in the source text; Marking the word segments corresponding to the named entities in the original text; The device is also configured to execute, by one or more processors, the one or more programs including instructions for: The translation result corresponding to the marked word segment in the target text is replaced with the named entity.

18. The device according to claim 13, It is characterized in that The device is also configured to execute, by one or more processors, the one or more programs including instructions for: Display modification information of the target text relative to the original text.

19. A machine-readable medium having instructions stored thereon, which, when executed by one or more processors, causes a device to execute the text processing method according to any one of claims 1 to 6.