Text translation method and device, terminal equipment and computer readable storage medium

By combining vocabulary features and character features, the context of characters in Chinese text is determined, thereby solving the problem of low accuracy in translation of polyphonic characters and achieving higher accuracy in pinyin translation.

CN119903854APending Publication Date: 2025-04-29TCL TECHNOLOGY GROUP CORPORATION
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311408488.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-10-26
Publication Date
2025-04-29

AI Technical Summary

Technical Problem

When generating Chinese pinyin, it is difficult for the prior art to effectively deal with polyphonic characters, resulting in a decrease in translation accuracy.

Method used

By combining vocabulary features, the context of the character is determined, so as to accurately determine the translation result of the character. The specific method includes determining the character feature information and vocabulary feature information of the text to be translated, and determining the translation result of each character based on the combination of the two.

Benefits of technology

It improves the accuracy of pinyin translation and avoids the problem that the translation results of characters do not match the context.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119903854A_ABST
    Figure CN119903854A_ABST
Patent Text Reader

Abstract

The invention provides a text translation method and device, terminal equipment and a computer readable storage medium. The method comprises the steps that character feature information of a to-be-translated text is determined; determining vocabulary feature information of the to-be-translated text; and determining a translation result of each character in the to-be-translated text according to the character feature information and the vocabulary feature information. According to the text translation method, after the character features of the characters in the to-be-translated text are determined, the vocabulary features of the vocabularies in the to-be-translated text are determined, and the character features and the vocabulary features are combined, so that the context where the characters are located can be determined according to the vocabulary features. Furthermore, when a plurality of translation results exist in the character, the accurate translation result can be determined according to the specific context of the character, so that the problem that the translation result context of the character is not matched is avoided, and the translation accuracy of the translation result is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a text translation method, apparatus, terminal device and computer-readable storage medium. Background Art

[0002] Due to the particularity of the target audience, extracurricular reading materials for primary school students, in addition to the Chinese text, also need to have pinyin annotations corresponding to the text to help readers understand. Therefore, editors hope to quickly and accurately generate pinyin corresponding to the text when typesetting.

[0003] Most of the existing methods for generating Chinese pinyin are based on dictionaries or text recognition and translation models to generate pinyin. However, the existing technology sometimes cannot effectively guarantee the accuracy. For example, there are cases where one Chinese character has multiple pronunciations, that is, polyphonic characters. Therefore, the same Chinese character may have different pronunciations in different contexts. Therefore, although the existing technology can recognize specific characters through dictionaries and corresponding text recognition and translation models, it is impossible to correctly translate pinyin when encountering polyphonic characters. Summary of the invention

[0004] The present application provides a text translation method, which determines the context of the current character by combining lexical features, thereby effectively determining the translation result of the character.

[0005] In a first aspect, the present application provides a text translation method, the method comprising:

[0006] Determine character feature information of the text to be translated;

[0007] Determining lexical feature information of the text to be translated;

[0008] The translation result of each character in the text to be translated is determined according to the character feature information and the vocabulary feature information.

[0009] In a second aspect, the present application further provides a text translation device, the device comprising:

[0010] A first determination module, used to determine character feature information of a text to be translated;

[0011] A second determination module, used to determine the vocabulary feature information of the text to be translated;

[0012] The third determination module is used to determine the translation result of each character in the text to be translated according to the character feature information and the vocabulary feature information.

[0013] In a third aspect, the present application also provides a terminal device, comprising a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps in any one of the text translation methods.

[0014] In a fourth aspect, the present application further provides a computer-readable storage medium, on which a computer program is stored, and the computer program is executed by a processor to implement the steps in any one of the text translation methods.

[0015] The text translation method provided by the present application determines the character feature information of each character in the text to be translated, and then determines the lexical feature information of each word in the text to be translated, and combines the character feature information with the lexical feature information, so that the context of each character can be determined according to the lexical feature information. Furthermore, when there are multiple translation results for a character, the accurate translation result can be determined according to the specific context of the character, avoiding the problem of mismatching the translation result of the character with the context, and improving the translation accuracy of the translation result. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.

[0017] Figure 1 is a scenario diagram of a text translation system provided in an embodiment of the present application;

[0018] Figure 2 This is a flowchart of an embodiment of the text translation method in the embodiment of the present application;

[0019] Figure 3 This is a schematic diagram of a model architecture of a text translation method in an embodiment of the present application;

[0020] Figure 4 It is a functional module diagram of a text translation device in an embodiment of the present application;

[0021] Figure 5 It is a schematic diagram of the structure of the terminal device in the embodiment of the present application. DETAILED DESCRIPTION

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

[0023] In the description of the present application, it should be understood that the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the feature. In the description of the present application, "plurality" means two or more, unless otherwise clearly and specifically defined.

[0024] In this application, the word "exemplary" is used to mean "used as an example, illustration or description". Any embodiment described as "exemplary" in this application is not necessarily to be construed as being more preferred or advantageous than other embodiments. At the same time, it is to be understood that in the specific implementation of this application, when user information, user data and other related data are involved, when the above embodiments of this application are applied to specific products or technologies, user permission or consent is required, and the collection, use and processing of relevant data shall comply with relevant laws, regulations and standards of relevant countries and regions.

[0025] In order to enable any person skilled in the art to implement and use the present application, the following description is provided. In the following description, details are listed for the purpose of explanation. It should be understood that those of ordinary skill in the art will recognize that the present application can be implemented without using these specific details. In other examples, known structures and processes will not be elaborated in detail to avoid unnecessary details that make the description of the present application obscure. Therefore, the present application is not intended to be limited to the embodiments shown, but is consistent with the widest range of principles and features disclosed in the present application.

[0026] The present application provides a text translation method, apparatus, device and storage medium, which are described in detail below.

[0027] See also Figure 1 , Figure 1 Schematic diagram of a text translation system provided in an embodiment of the present application. The text translation system may include a terminal device 100 and a storage device 200. The storage device 200 may transmit data to the terminal device 100. Figure 1 The terminal device 100 in the embodiment can obtain the text to be translated stored in the storage device 200 to execute the text translation method in the present application.

[0028] In the embodiment of the present application, the terminal device 100 includes but is not limited to a desktop computer, a portable computer, a network server, a PDA (Personal Digital Assistant), a tablet computer, a wireless terminal device, an embedded device, etc.

[0029] In an embodiment of the present application, communication between the terminal device 100 and the storage device 200 can be achieved through any communication method, including but not limited to mobile communications based on the 3rd Generation Partnership Project (3GPP), Long Term Evolution (LTE), and Worldwide Interoperability for Microwave Access (WiMAX), or computer network communications based on the TCP / IP Protocol Suite (TCP / IP) and User Datagram Protocol (UDP).

[0030] It should be noted that Figure 1 The scenario diagram of the text translation system shown is only an example. The text translation system and scenario described in the embodiment of the present application are intended to more clearly illustrate the technical solution of the embodiment of the present application, and do not constitute a limitation on the technical solution provided in the embodiment of the present application. Ordinary technicians in this field can know that with the evolution of the text translation system and the emergence of new business scenarios, the technical solution provided in the embodiment of the present application is also applicable to similar technical problems.

[0031] like Figure 2 As shown, Figure 2 This is a flow chart of an embodiment of a text translation method in an embodiment of the present application. The text translation method may include the following steps 201 to 203:

[0032] 201. Determine character feature information of a text to be translated.

[0033] In the embodiment of the present application, the text to be translated can be any type of text file, such as a word document, a notepad document, etc. Of course, it can also be a piece of text obtained by image recognition, which is not limited in the specific embodiment of the present application.

[0034] In the embodiment of the present application, the character features of the text to be translated can be determined by using a character recognition model to identify each character in the text to be translated. For example, the character recognition model can read the image features of each character in the text to be translated. Afterwards, the current character can be identified by the image features of each character. Therefore, in the embodiment of the present application, the image features of the character are the character features of the text to be translated.

[0035] It should be noted that, according to the above description, after a specific character is recognized, the pronunciation may be different due to the different contexts in which the character is located. Therefore, there may be a situation where the pinyin translation is wrong based only on the character features. For example: Wu Song shouted: "Bring the wine quickly! I want to drink twelve bowls." Among them, the pinyin of "drink" in "Wu Song shouted" should be read (hè), and the pinyin of "drink" in "I want to drink twelve bowls" should be read (hē). However, if it is based only on the character features, the relevant pinyin translation model can only recognize the specific word "drink" based on the character images of each character, and cannot accurately translate the specific pinyin of the word "drink". In the embodiment of the present application, the pinyin of the character can be regarded as the translation result.

[0036] 202. Determine lexical feature information of the text to be translated.

[0037] According to the above description, after determining the specific character features, the pinyin translation model may not be able to accurately translate the pinyin of each character. Therefore, the embodiment of the present application also needs to determine specific vocabulary features. For example, still take: Wu Song shouted: "Hurry up and bring the wine! I want to drink twelve bowls." This sentence is used as an example. According to the Chinese vocabulary, "loudly shouting" and "drinking a mouthful" are two completely different words. "Loudly shouting" means scolding, so the pronunciation of "drink" in "loudly shouting" should be (hè). And "drinking a mouthful" means drinking water, so the pronunciation of "drink" in "drinking a mouthful" should be (hē). It can be seen from this that it is necessary to determine the vocabulary features in the text to be translated to determine that the current character is in that kind of vocabulary context.

[0038] In the embodiment of the present application, in order to determine the lexical features in the text to be translated, the following methods can be used: for example, first remove the stop words (Stop Words Removal) in the text to be processed: stop words refer to words that frequently appear in the text but have no actual semantic meaning, such as articles, prepositions, conjunctions, etc. A stop word list is usually established, and then these stop words are removed from the text. After the stop words are removed, the text to be processed can be subjected to part-of-speech tagging: part-of-speech tagging is to mark each word in the text with its part of speech, such as nouns, verbs, adjectives, etc. After the part of speech of different words in the text to be processed is determined, the lexical features of each word can be extracted, and compared with the words in the corresponding part-of-speech table respectively, so as to determine the current word. For example: if the current word is an adjective, the current word is searched in a preset adjective word table, so as to determine the current word. So far, the text to be processed is subjected to part-of-speech, entity recognition, etc. in the above-mentioned manner, so as to identify each word in the text to be processed. The part of speech of a word, the image features of a word, and the semantics of a word can all be regarded as the lexical features of the word in the text to be processed. It should be noted that in the embodiment of the present application, there is no order of precedence between step 201 and step 202. The order of their implementation can be exchanged according to the actual situation, or step 201 and step 202 can be performed simultaneously. The specific embodiment of the present application is not limited thereto.

[0039] 203. Determine a translation result for each character in the text to be translated according to the character feature information and the vocabulary feature information.

[0040] According to the above description, after the lexical features and character features are determined, the character features and lexical features can be combined to perform pinyin translation on the text to be translated. For example: through the character features, the pinyin corresponding to the current character can be determined through a preset association table of character features and pinyin. If there are multiple pinyins for the current character, the lexical features corresponding to the current character are combined at this time. For example, the "he" in "hear loudly" means to scold, and "he" corresponds to two pinyins. Therefore, after the word "hear loudly" and the semantics of the word are identified by combining the lexical features, the pinyin of "he" in "hear loudly" can be determined to be (hè) from the two pinyins (hè) and (hē). Finally, (hè) is output as the pinyin of "he" in "hear loudly". In the embodiment of the present application, the process of pinyin translation is specifically described. The pinyin translation process of other characters is the same as the translation process listed in the embodiment of the present application, and the specific embodiment of the present application will not be repeated.

[0041] The text translation method provided by the present application determines the character features of each character in the text to be translated, and then determines the lexical features of each word in the text to be translated, and combines the character features with the lexical features, so that the context of each character can be determined according to the lexical features. Furthermore, when there are multiple translation results for a character, the accurate translation result can be determined according to the specific context of the character, avoiding the problem of mismatching the translation result of the character with the context, and improving the translation accuracy of the translation result.

[0042] In order to better implement the embodiments of the present application, in one embodiment of the present application, determining the character features of the text to be translated includes:

[0043] Determine the initial character features of the text to be translated; determine the first position information of each character in the text to be translated; merge the initial character features with the first position information to obtain the character features of the text to be translated.

[0044] According to the above embodiment, the above embodiment provides a method for identifying characters based on the image features of each character in the text to be translated. Therefore, the above embodiment needs to obtain the corresponding image of each character in the text to be translated. In order to avoid the need to obtain the image of each character in the text to be translated, the embodiment of the present application provides a method based on character vectors to determine the character features of the text to be translated.

[0045] Specifically, in an embodiment of the present application, the text to be translated can be input into a preset BERT model (Bidirectional Encoder Representations from Transformers) model. The BERT model can divide each word in the text sequence into the smallest units, usually characters or letters. Afterwards, the initial character features can be obtained based on the segmented characters. At the same time, the BERT model can also consider the order between characters. The BERT model adds position embedding to the input representation to retain the position information of the characters, that is, the first position information of each character can be obtained. Then, the initial character features are spliced ​​with the first position information to fuse the character features of the text to be translated. In an embodiment of the present application, the initial character features can be fused with the first position information by horizontal splicing. For example, assuming that the dimension of the initial character features is 3 and the dimension of the first position information is 3, the horizontal splicing method is as follows:

[0046]

[0047] Of course, in the embodiment of the present application, the splicing can also be performed by vertical splicing. Assuming that the dimension of the initial character feature is still 3, and the dimension of the first position information is still 3, the vertical splicing method is as follows:

[0048]

[0049]

[0050] Specifically, the fusion method to be adopted can be determined according to the actual situation, and the embodiments of the present application do not limit it.

[0051] In order to better implement the embodiment of the present application, in one embodiment of the present application, determining the vocabulary features of the text to be translated includes:

[0052] The text to be translated is segmented to obtain a segmentation result; based on the segmentation result, the initial vocabulary features of the text to be translated and the second position information of each vocabulary in the text to be translated are determined; the initial vocabulary features are merged with the second position information to obtain the vocabulary features of the text to be translated.

[0053] The above embodiment provides a method based on part of speech and lookup table to determine the implementation method of vocabulary features in the text to be translated. In order to make the vocabulary features of the text to be translated more accurate, the embodiment of the present application also provides other word segmentation methods. For example: word segmentation based on rules, word segmentation based on statistical methods, word segmentation based on machine learning and word segmentation based on deep learning. The word segmentation method based on rules is to divide by some rules and dictionaries, such as maximum matching method, forward maximum matching method, reverse maximum matching method, etc. The word segmentation method of statistical methods is based on a large number of corpora and statistical features for word segmentation, such as Hidden Markov Model (HMM) and Conditional Random Fields (CRF). The word segmentation based on machine learning is to use machine learning algorithms to train the word segmentation data that has been manually annotated, and then to segment new texts. The word segmentation based on deep learning is to use deep learning models (such as recurrent neural networks, convolutional neural networks) to learn language patterns and automatically learn word segmentation rules and features.

[0054] After completing the word segmentation of the text to be processed and obtaining the word segmentation result. Each word in the word segmentation result can still be converted into initial vocabulary features and second position information through the BERT model. Specifically, the way to convert each word in the word segmentation result into initial vocabulary features can be the same as the way to convert characters into initial character features through the BERT model in the above embodiment. For example: each sentence in the text sequence can be divided into units of words through the BERT model. Afterwards, each unit word is converted into initial vocabulary features according to the BERT model. Moreover, the second position information of the vocabulary is also obtained in the same way as the way to obtain the first position information of the character through the BERT model in the above embodiment. For example: still according to the BERT model, considering the order between words, the BERT model adds the position embedding of the words in the input representation to retain the position information of the words, that is, the second position information of each word can be obtained.

[0055] Afterwards, after the initial vocabulary features and the second position information are obtained, the initial vocabulary features and the second position information can also be fused by feature splicing to obtain the vocabulary features of the text to be translated. Specifically, the method of fusing the initial character features with the first position information is the same as in the above embodiment, for example, the method of horizontal splicing is as follows:

[0056]

[0057] Or, vertical stitching looks like this:

[0058]

[0059] In order to better implement the embodiment of the present application, in one embodiment of the present application, the translation result of each character in the text to be translated is determined according to the character features and the vocabulary features, including:

[0060] According to the character features and the vocabulary features, the number of words corresponding to each character is determined; according to the number of words, the input features are determined; according to the input features, the translation result of each character in the text to be translated is determined.

[0061] According to the above description, when a character is a polyphonic character, the translation of pinyin may be inaccurate. On this basis, if a character exists in multiple words in a text, for example, in the middle of a word or at the end of a word, the possibility of multiple pronunciations increases, which leads to inaccurate pinyin translation. For example: assuming that a word is XXXX, if the last X in XXXX is A, then the word is XXXA. Similarly, when a word is XX, if the last X in XX is A, then the word is XA. At this time, the target character is called the end of the corresponding word. When there are multiple words ending with the target character in the word segmentation result, there may be a situation where the target character has different pinyin. Therefore, extra attention needs to be paid to the translation of the target character. That is, it is necessary to record whether the target character is the end of each word in the word segmentation result, and at the same time, when the target character is recorded as the end of a word, the number of words at the end of the target character is recorded. For example: if character A is the end of two words, the number of words is 2; if character A is the end of three words, the number of words is 3. In other words, the more the target character ends in the corresponding vocabulary, the more likely it is that the target character A has multiple pronunciations. It should be noted that in the embodiment of the present application, each character in the text to be translated can be a target character, and when determining the number of target characters that are vocabulary endings, it is actually determining the number of vocabulary endings corresponding to each character.

[0062] Based on this, in the embodiment of the present application, the number of words can be used as a new dimension to add to the splicing features of character features and vocabulary features. Specifically, the corresponding character features and the number of endings corresponding to the character features can be added to the features after splicing as new dimensions of splicing features or fusion features. For example: Assuming that the features of the splicing are: (G, H, J, K, L, Z, C), after analysis, there is a target character A with a number of endings of 0, and a target character B with a number of endings of 1, and assuming that the character feature corresponding to the target character A is G, and the character feature corresponding to the target character B is J. At this point, the corresponding character features and the number of words can be added after the features (G, H, J, K, L, Z, C). For example: the feature (G, H, J, K, L, Z, C) can be changed to (G, H, J, K, L, Z, C, G, 0, J, 1), and then the input feature is obtained. Finally, after the input features are input into the Pinyin translation model, the model can focus on analyzing the actual Pinyin of the corresponding target characters according to the vocabulary quantity features added to the input features and the character features corresponding to the corresponding vocabulary quantity features, so as to reduce the probability of Pinyin translation errors. It should be noted that the above features (G, H, J, K, L, Z, C) can be horizontally spliced ​​features, among which G, H, J, K, L can be assumed to be character features; Z, C can be assumed to be vocabulary features. Moreover, the features listed in the above embodiments are only for illustrative understanding. In specific

[0063] In order to better implement the embodiment of the present application, in one embodiment of the present application, the input features are determined according to the number of words, including:

[0064] If the number of words is zero, the input feature is determined to be a character feature; if the number of words is one, the character feature and the word feature are concatenated to obtain the input feature; if the number of words is at least two, a fusion feature is determined based on the character feature and the word feature; the fusion feature is concatenated with the character feature to obtain the input feature.

[0065] In the above embodiment, when the number of endings corresponding to the target character is 0, the target character and the corresponding number of words 0 can be spliced ​​together into the fusion feature of the character feature and the vocabulary feature to be input into the subsequent pinyin translation model. However, when the number of words of the target character is 0, the target character has less polyphony. Therefore, if the target character with a vocabulary of 0 is still spliced ​​into the character feature, the input feature finally formed will be more redundant. Therefore, when determining the input feature, the input feature can be simplified to a certain extent so that the input feature includes the most effective feature. For example: if the fusion feature of the character feature and the vocabulary feature is (G, H, J, K, L, Z, C), it is assumed that the number of endings of the target character A is 0, the number of endings of the target character B is 1, and it is assumed that the character feature corresponding to the target character A is G, and the character feature corresponding to the target character B is J. At this time, the information that the number of endings of the target character A is 0 can be not spliced ​​into the fusion feature, but only the information that the number of endings of the target character B is 1 can be spliced ​​into the fusion feature, so that the input feature is (G, H, J, K, L, Z, C, J, 1). It can be obtained that compared with the input features G, H, J, K, L, Z, C, G, 0, J, 1) in the above embodiment, the input features (G, H, J, K, L, Z, C, J, 1) in the embodiment of the present application are more streamlined. At the same time, the streamlined input features do not have a target character A with a number of endings of 0. Therefore, the subsequent pinyin translation model can reduce the amount of calculation in feature calculation.

[0066] Based on the above concepts, since the number of words corresponding to the target character is smaller, the number of polyphones corresponding to the target character is lower. When the number of words corresponding to the target character is 0, the lexical feature can be regarded as empty, and the character feature can be regarded as an input feature. When the number of words corresponding to the target character is 1, the character feature and the lexical feature can be fused according to the method of the above embodiment, and the fused feature can be used as the input feature. When the number of words for the target character is at least 2, the character feature and the fused feature can be spliced ​​again to obtain a second fused feature, and the second fused feature can be used as the input feature. Specifically, in the embodiment of the present application, the method of splicing the character feature and the fused feature can also be spliced ​​according to the splicing method provided in the above embodiment, such as horizontal splicing, vertical splicing, etc., which is not limited in the embodiment of the present application.

[0067] In order to better implement the embodiment of the present application, in one embodiment of the present application, the fusion feature is determined according to the character feature and the vocabulary feature, including:

[0068] Attention is calculated based on character features and lexical features to obtain an attention score; based on the attention score, the character features and lexical features are fused to obtain a fused feature.

[0069] The above embodiment provides a solution for splicing character features with fusion features by horizontal splicing, vertical splicing, etc. In order to further improve the translation accuracy of the subsequent pinyin translation model, in the embodiment of the present application, a method of introducing an attention mechanism is also provided to perform splicing to obtain a solution for input features. Among them, the following formula can be referred to for splicing to obtain input features. Specifically, as shown in formulas (1), (2), (3), (4) and (5):

[0070] Query = E 字符 ……(1)

[0071] Key=Value=E 词汇 ……(2)

[0072]

[0073] E 融合 =Attention 微 (Query, Key, Value)……(4)

[0074]

[0075] For each character, E is converted into 字符 Part of it is used as Query, and then according to formula (2), E 词汇 As the key, we calculate the attention weights of various word segmentation results ending with the current position character, and use the character-level embedding E of the character 字符 With the word-level embedding E 词汇 The cross attention calculation is performed through formula (3) to obtain the micro self-attention score, and then E is converted into 词汇 As the multiplication of Value and attention score, we get the fusion embedding E of the character which combines character-level and word-level features. 融合 When E is obtained 融合 After that, feature concatenation can be performed according to formula (5).

[0076] It should be noted that in the third case, that is, when the input feature is equal to the concatenation of the character feature and the fusion feature, each character-level embedding E 字符 Corresponding to multiple vocabulary-level embeddings E 词汇 In the embodiment of the present application, the initial E 字符 With E 词汇 The dimension d = 256, if it is assumed that there are two word segmentation results ending with the character at the current position, then Query∈R in formula (1) 1×256 , Key∈R in formula (2) 2×256 , Value∈R 2×256, d in formula (3) key =256, the input E obtained in formula (5) 输入 The dimension is d key =512. The above operation is performed on all sequences in the input text, and finally the input feature representation of the final input text sequence can be obtained as shown in formula (6):

[0077] E=Linear(E 输入1 , E 输入2 ,…,E 输入n )……(6)

[0078] In order to better implement the embodiments of the present application, in one embodiment of the present application, the translation result of each character in the text to be translated is determined according to the input features, including:

[0079] Perform a linear transformation on the input features to obtain transformation features; perform attention calculation on the transformation features to obtain input features including attention information; encode the input features including attention information to obtain encoded features; decode and translate the encoded features to obtain the translation results of each character in the text to be translated.

[0080] In the above embodiment, a scheme is provided for inputting input features into a trained pinyin translation model to obtain the pinyin corresponding to the character. In the embodiment of the present application, a scheme is also provided for inputting input features into corresponding encoders and decoders to determine the specific pinyin.

[0081] In an embodiment of the present application, the encoder may include multiple encoder blocks. In deep learning, an encoder block refers to a basic module used in the encoder part. The encoder block is mainly responsible for encoding the input data into a higher level, more abstract representation, which is usually used to process sequence data or image data. In an embodiment of the present application, each encoder block is usually composed of multiple sublayers, including a self-attention layer and a feed-forward neural network layer. The self-attention layer is used to capture the associated information inside the input data, and the feed-forward neural network layer is responsible for nonlinear transformation and mapping of the features. The design of the encoder block can be adjusted and changed according to the specific task and model architecture, such as by stacking multiple encoder blocks. The reuse of the encoder block helps to gradually extract the features of the input data and form a higher level representation. Such a design enables the model to better understand the input data and perform subsequent processing and analysis. Specifically, the present application does not limit the structure and quantity of multiple encoder blocks.

[0082] In the embodiment of the present application, each encoder block can have 8 self-attention mechanism layers, that is, head=8. Different matrices are used to extract the input features, capture the contextual relationship between the input text sequences from different angles, and obtain the final feature information through splicing and full connection layers. However, before extracting features through each encoder block, the input features can also be linearly transformed. Specifically, refer to the following formulas (7), (8), (9), and (10):

[0083] EW i Q =Query i ……(7)

[0084] EW i K =Key i ……(8)

[0085] EW i V =Value i ……(9)

[0086]

[0087] Among them, the self-attention calculation is performed in the first sub-layer Multi-Head Attention in the first encoder block. Before each self-attention mechanism calculation, three matrices EW can be used first i Q , E.W. i K , EW i V Perform linear transformation on the input features to obtain Query i 、Key i 、Value i After the linear change is completed, it is then substituted into formula (10) for attention calculation.

[0088] After completing the relevant attention calculations, you also need to refer to the following formulas (11), (12), and (13):

[0089] head i =Attention(Query i ,Key i ,Value i )……(11)

[0090] E′=Multi-Head(Query,Key,Value)=Connect(head1,head2,…,head8)W…

[0091] …(12)

[0092] H1=FNN(E′)……(13)

[0093] Specifically, formulas (11), (12), and (13) are the embodiments of the present application that respectively use different matrices to extract features from input features, capture the contextual relationship between input text sequences from different angles, and obtain the final feature information through splicing and full connection layers. Among them, the input of formula (11) is the calculation result of formula (10). Afterwards, the input of formula (11) is gradually brought into formula (12), and the input of formula (12) is brought into formula (13), and finally the encoding task of completing the pinyin translation is obtained. It should be noted that in the embodiments of the present application, the number of encoder blocks can be 6, so the output H6 of the 6th encoder block can be used as the final encoder output of the encoder module.

[0094] After obtaining the output of the encoder, the output of the encoder is used as the input of the first decoder block in the decoder. It should be noted that, in an embodiment of the present application, the structure of each decoder block may include: Self-Attention Mechanism: The self-attention mechanism in the decoder is similar to the self-attention mechanism in the encoder, which is used to model the dependencies between various positions in the input sequence. By calculating the attention weight of each position to other positions, a context-related representation is obtained. Encoder-Decoder Attention Mechanism: The decoder layer also introduces an encoder-decoder attention mechanism to integrate the information of the encoder layer into the decoder. Each position of the decoder considers the representation generated by the encoder layer, which helps the decoder better understand the input sequence and generate appropriate outputs. Feed-Forward Neural Network: The decoder layer also includes a feed-forward neural network for nonlinear transformation and feature extraction based on the weighted context representation. Layer Normalization: After each submodule, the decoder layer usually applies a layer normalization operation to standardize the input in the submodule to improve the stability of the model.

[0095] Finally, it should be noted that in the present invention, only the word-level embedding representation is actually integrated into the input of the first encoder block of the encoder. In practical applications, the word-level embedding can be integrated into the input of each encoder block or part of the encoder block according to the task requirements to conduct experiments to obtain a model that can better adapt to the task. Specifically, a model framework diagram of an embodiment of the present application can also be seen in Figure 3 .

[0096] In order to better implement the text translation method in the embodiment of the present application, in addition to the text translation method, the embodiment of the present application also provides a text translation device, such as Figure 4 As shown, the device 300 includes:

[0097] The first determination module 301 is used to determine the character feature information of the text to be translated;

[0098] The second determination module 302 is used to determine the vocabulary feature information of the text to be translated;

[0099] The third determination module 303 is used to determine the translation result of each character in the text to be translated according to the character feature information and the vocabulary feature information.

[0100] The text translation device provided by the present application determines the character features of each character in the text to be translated through the first determination module 301, and then determines the lexical features of each word in the text to be translated through the second determination module 302, and combines the character features with the lexical features, so that the context of each character can be determined according to the lexical features. Furthermore, when there are multiple translation results for a character, the accurate translation result can be determined according to the specific context of the character through the third determination module 303, avoiding the problem of mismatching the translation result of the character with the context, and improving the translation accuracy of the translation result.

[0101] In some embodiments of the present application, the first determining module 301 is specifically used to:

[0102] Determining initial character feature information of the text to be translated;

[0103] Determine the first position information of each character in the text to be translated;

[0104] The initial character feature information is merged with the first position information to obtain character feature information of the text to be translated.

[0105] In some embodiments of the present application, the second determining module 302 is specifically used to:

[0106] Perform word segmentation on the translation text to obtain the word segmentation result;

[0107] Determine the initial vocabulary feature information of the text to be translated and the second position information of each vocabulary in the text to be translated according to the word segmentation result;

[0108] The initial vocabulary feature information is merged with the second position information to obtain vocabulary feature information of the text to be translated.

[0109] In some embodiments of the present application, the third determination module 303 is specifically used to:

[0110] Determine the number of words corresponding to each character according to the character feature information and the word feature information;

[0111] Determine input features based on the number of words;

[0112] According to the input features, the translation result of each character in the text to be translated is determined.

[0113] In some embodiments of the present application, the third determining module 303 is further configured to:

[0114] If the number of words is zero, the input feature is determined to be a character feature;

[0115] If the number of words is one, concatenate the character feature information with the word feature information to obtain the input feature;

[0116] If the number of words is at least two, determining a fusion feature based on the character feature information and the word feature information;

[0117] Concatenate the fusion features with the character features to obtain the input features.

[0118] In some embodiments of the present application, the third determining module 303 is further configured to:

[0119] Attention is calculated based on character features and vocabulary features to obtain an attention score;

[0120] According to the attention score, the character features are fused with the vocabulary features to obtain the fused features.

[0121] In some embodiments of the present application, the third determining module 303 is further configured to:

[0122] Perform linear transformation on the input features to obtain transformed features;

[0123] Perform attention calculation on the transformed features to obtain input features including attention information;

[0124] Encode the input features including attention information to obtain encoded features;

[0125] The encoded features are decoded and translated to obtain the translation results of each character in the text to be translated.

[0126] The present application also provides a terminal device, which includes a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps in any one of the text translation methods in the present application. The terminal device integrates any one of the text translation methods provided in the present application, such as Figure 5As shown, it shows a schematic diagram of the structure of the terminal device involved in the embodiment of the present application, specifically:

[0127] The terminal device may include one or more processing core processors 401, one or more computer-readable storage media memories 402, a power supply 403, an input unit 404 and other components. Those skilled in the art will appreciate that Figure 5 The terminal device structure shown in the figure does not constitute a limitation on the terminal device, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently. Among them:

[0128] The processor 401 is the control center of the terminal device, and uses various interfaces and lines to connect various parts of the entire terminal device. By running or executing software programs and / or modules stored in the memory 402, and calling data stored in the memory 402, the processor 401 executes various functions of the terminal device and processes data, thereby monitoring the terminal device as a whole. Optionally, the processor 401 may include one or more processing cores; the processor 401 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc. Preferably, the processor 401 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, the user interface and the application program, etc., and the modem processor mainly processes wireless communication. It is understandable that the above-mentioned modem processor may not be integrated into the processor 401.

[0129] The memory 402 can be used to store software programs and modules. The processor 401 executes various functional applications and data processing by running the software programs and modules stored in the memory 402. The memory 402 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area may store data created according to the use of the terminal device, etc. In addition, the memory 402 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices. Accordingly, the memory 402 may also include a memory controller to provide the processor 401 with access to the memory 402.

[0130] The terminal device also includes a power supply 403 for supplying power to each component. Preferably, the power supply 403 can be logically connected to the processor 401 through a power management system, so as to manage charging, discharging, power consumption management and other functions through the power management system. The power supply 403 can also include any components such as one or more DC or AC power supplies, recharging systems, power failure detection circuits, power converters or inverters, and power status indicators.

[0131] The terminal device may further include an input unit 404, which may be used to receive input digital or character information and generate keyboard, mouse, joystick, optical or trackball signal input related to user settings and function control.

[0132] Although not shown, the terminal device may further include a display unit, etc., which will not be described in detail herein. Specifically in this embodiment, the processor 401 in the terminal device will load the executable files corresponding to the processes of one or more application programs into the memory 402 according to the following instructions, and the processor 401 will run the application programs stored in the memory 402, thereby realizing various functions, such as:

[0133] Determine character feature information of the text to be translated;

[0134] Determine the lexical feature information of the text to be translated;

[0135] The translation result of each character in the text to be translated is determined according to the character feature information and the vocabulary feature information.

[0136] A person of ordinary skill in the art will appreciate that all or part of the steps in the various methods of the above embodiments may be completed by instructions, or by controlling related hardware through instructions. The instructions may be stored in a computer-readable storage medium and loaded and executed by a processor.

[0137] To this end, the embodiment of the present application provides a computer-readable storage medium, which may include: a read-only memory (ROM), a random access memory (RAM), a disk or an optical disk, etc. A computer program is stored thereon, and the computer program is loaded by a processor to execute the steps in any text translation method provided in the embodiment of the present application. For example, the computer program is loaded by the processor to execute the following steps:

[0138] Determine character feature information of the text to be translated;

[0139] Determine the lexical feature information of the text to be translated;

[0140] The translation result of each character in the text to be translated is determined according to the character feature information and the vocabulary feature information.

[0141] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, please refer to the detailed description of other embodiments above, and will not be repeated here.

[0142] In specific implementation, the above units or structures can be implemented as independent entities, or can be arbitrarily combined to be implemented as the same or several entities. The specific implementation of the above units or structures can refer to the previous method embodiments, which will not be repeated here.

[0143] The specific implementation of the above operations can be found in the previous embodiments, which will not be described in detail here.

[0144] The above is a detailed introduction to a text translation method and device provided in an embodiment of the present application. Specific examples are used herein to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea. At the same time, for technical personnel in this field, according to the idea of ​​the present application, 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 application.

Claims

1. A text translation method, characterized in that: The method comprises: Determine character feature information of the text to be translated; Determining lexical feature information of the text to be translated; The translation result of each character in the text to be translated is determined according to the character feature information and the vocabulary feature information.

2. The text translation method according to claim 1, characterized in that: The step of determining the character feature information of the text to be translated includes: Determining initial character feature information of the text to be translated; Determining first position information of each character in the text to be translated; The initial character feature information is merged with the first position information to obtain character feature information of the text to be translated.

3. The text translation method according to claim 1, characterized in that: The determining of the vocabulary feature information of the text to be translated includes: Performing word segmentation processing on the text to be translated to obtain a word segmentation result; Determining initial vocabulary feature information of the text to be translated and second position information of each vocabulary in the text to be translated according to the word segmentation result; The initial vocabulary feature information is merged with the second position information to obtain the vocabulary feature information of the text to be translated.

4. The text translation method according to claim 1, characterized in that: Determining the translation result of each character in the text to be translated according to the character feature information and the vocabulary feature information includes: Determine the number of words corresponding to each character according to the character feature information and the word feature information; Determining input features based on the number of words; A translation result for each character in the text to be translated is determined according to the input feature.

5. The text translation method according to claim 4, characterized in that: The step of determining input features according to the number of words includes: If the number of the words is zero, determining that the input feature is the character feature information; If the number of the words is one, concatenate the character feature information with the word feature information to obtain the input feature; If the number of the words is at least two, determining a fusion feature according to the character feature information and the word feature information; The fusion feature is concatenated with the character feature information to obtain the input feature.

6. The text translation method according to claim 5, characterized in that: The determining of the fusion feature according to the character feature information and the vocabulary feature information includes: Performing attention calculation based on the character feature information and the vocabulary feature information to obtain an attention score; According to the attention score, the character feature information is fused with the vocabulary feature information to obtain the fused feature.

7. The text translation method according to claim 4, characterized in that: Determining the translation result of each character in the text to be translated according to the input feature includes: Performing a linear transformation on the input feature to obtain a transformed feature; Performing attention calculation on the transformed features to obtain input features including attention information; Encoding the input feature including the attention information to obtain an encoded feature; The encoded features are decoded and translated to obtain a translation result for each character in the text to be translated.

8. A text translation device, characterized in that: The device comprises: A first determination module, used to determine character feature information of a text to be translated; A second determination module, used to determine the vocabulary feature information of the text to be translated; The third determination module is used to determine the translation result of each character in the text to be translated according to the character feature information and the vocabulary feature information.

9. A terminal device, characterized in that: The terminal device includes a processor, a memory, and a computer program stored in the memory and executable on the processor, and the processor executes the computer program to implement the steps in the text translation method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and the computer program is executed by a processor to implement the steps in the text translation method according to any one of claims 1 to 7.