A machine translation method and system based on article classification
By introducing article classification technology into the machine translation system, automatically divide the fields of the sentences to be translated, and use the translation model of the corresponding fields for translation, the problems of poor translation effect and low manual selection efficiency in the existing technology are solved, and more efficient and accurate translation results are achieved.
Patent Information
- Application Number
- CN202411822057.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-11
- Publication Date
- 2025-04-04
AI Technical Summary
When existing machine translation technologies process texts from different fields, they cannot effectively distinguish the fields, resulting in poor translation results; while manual field selection translation systems are inefficient.
Using a machine translation method based on article classification, a preset classifier is used to classify the translated statements in a domain, a set of statement classes for corresponding categories is constructed, and a translation model for corresponding fields is used for translation.
This method can automatically divide the fields of the sentences to be translated, improve translation accuracy, reduce manual intervention, and improve translation efficiency.
Smart Images

Figure CN119761385A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of machine translation, and in particular to a machine translation method and system based on article classification. Background Art
[0002] Machine Translation (MT) is a process that uses computer technology to automatically convert text in one language into text in another language. It is based on natural language processing (NLP) and artificial intelligence (AI) technology, using machine learning algorithms to learn the relevant connections between two languages from bilingual parallel data, and then using the learned rules to convert one natural language into another natural language.
[0003] With the emergence and popularization of the Internet, the amount of data has increased dramatically, and statistical methods have been fully applied, developing rule-based machine translation, statistics-based machine translation, and neural network-based machine translation. At present, with the progress of deep learning, machine translation technology has been further developed, and the mainstream is neural network-based machine translation. Compared with statistical machine translation, it adopts an end-to-end translation method. The main idea of neural network-based machine translation is to adopt a "coding and decoding" structure. The encoding and decoding modules use a recurrent neural network for training and translation respectively. For a sentence to be translated, the encoder first converts the sentence into a vector of fixed dimension, and then uses the vector as input. The decoder will give a sequence of word vectors, and finally convert the output word vector sequence into the target language word by looking up the dictionary.
[0004] However, in actual applications, there are two situations. One is that no matter which field the sentence to be translated input by the user belongs to, it is regarded as input and translated using a general system. The other is that the user selects a specific field translation system and inputs the sentence to be translated, and the corresponding field translation system gives the corresponding translation. The translation of the first mechanism cannot distinguish between fields and the translation effect is poor. The second mechanism requires manual selection and is less efficient. Summary of the invention
[0005] In view of this, an embodiment of the present invention provides a machine translation method and system based on article classification to eliminate or improve one or more defects in the prior art.
[0006] One aspect of the present invention provides a machine translation method based on article classification, the method comprising the steps of:
[0007] receiving a set of sentences to be processed, wherein the set of sentences includes sentences to be translated;
[0008] Classify the sentences to be translated based on a preset classifier, and construct a sentence class set of the corresponding category based on the category of each classification;
[0009] The sentences in the corresponding sentence class set are translated based on the translation model set corresponding to each category to obtain the translation sentence of each corresponding sentence to be translated.
[0010] By adopting the above scheme, the present invention has made improvements on the traditional machine translation mechanism, using a classification algorithm to divide the sentences to be translated into fields, and then put them into the corresponding classification field translation system for translation. Compared with the traditional method of manually selecting a classification field translation system for translation, the invention can save the time of manually judging the classification field to which the sentence belongs. Compared with directly using a general translation system for translation, the invention can effectively improve the translation accuracy.
[0011] In some embodiments of the present invention, before the step of receiving a set of sentences to be processed, wherein the sentence set includes sentences to be translated, the step includes: obtaining an article to be translated, splitting the sentences in the article based on preset tags into multiple sentences to be translated, and constructing them into a sentence set.
[0012] In some embodiments of the present invention, in the step of obtaining an article to be translated, splitting sentences in the article based on preset tags, splitting them into multiple sentences to be translated, and constructing them into a sentence set, the sentences to be translated obtained after the splitting are numbered based on the order of the sentences in the article.
[0013] In some embodiments of the present invention, in the step of obtaining an article to be translated, splitting sentences in the article based on preset tags, splitting them into multiple sentences to be translated, and constructing them into a sentence set, the preset tags are punctuation marks in the article, and the article is split based on the punctuation marks in the article.
[0014] In some embodiments of the present invention, in the step of classifying the sentences to be translated based on a preset classifier, a naive Bayes method is used to perform domain classification on the sentences to be translated.
[0015] In some embodiments of the present invention, in the step of using the naive Bayes method to perform domain classification on the sentence to be translated, the naive Bayes method is used to calculate the category score of the sentence to be translated for each category, and the category of the sentence to be translated is determined based on the category score of the sentence to be translated for each category.
[0016] In some embodiments of the present invention, in the step of using the naive Bayes method to classify the domain of the sentence to be translated:
[0017] Use the Embedding layer to convert the sentence to be translated into a sentence vector;
[0018] The converted sentence vector is input into the pre-trained long short-term memory layer for calculation to determine the category score of the sentence to be translated for each category.
[0019] In some embodiments of the present invention, the long short-term memory layer includes an input gate, a forget gate, an output gate, and a pooling layer. In the step of inputting the converted sentence vector into the pre-trained long short-term memory layer for calculation, and determining the category score of the sentence to be translated for each category:
[0020] The sentence vector is processed based on the input gate, the forget gate and the output gate, and processed through an average pooling layer to obtain a score vector;
[0021] The category score of the sentence vector corresponding to each category is determined based on the value of each dimension in the score vector.
[0022] In some embodiments of the present invention, the method further comprises:
[0023] Get the translation sentence corresponding to each sentence to be translated;
[0024] The translation sentences are combined based on the numbers of the sentences to be translated to obtain a translation article of the corresponding article.
[0025] The second aspect of the present invention also provides a machine translation system based on article classification, the system comprising a computer device, the computer device comprising a processor and a memory, the memory storing computer instructions, the processor being used to execute the computer instructions stored in the memory, and when the computer instructions are executed by the processor, the system implements the steps implemented by the method described above.
[0026] The third aspect of the present invention further provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps implemented by the aforementioned machine translation method based on article classification.
[0027] Additional advantages, purposes, and features of the present invention will be described in part in the following description, and will become apparent to those skilled in the art after studying the following, or may be learned from the practice of the present invention. The purposes and other advantages of the present invention can be specifically pointed out and obtained in the specification and the accompanying drawings.
[0028] Those skilled in the art will appreciate that the objectives and advantages that can be achieved with the present invention are not limited to the above specific description, and the above and other objectives that can be achieved by the present invention will be more clearly understood from the following detailed description. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] The drawings described herein are used to provide a further understanding of the present invention, constitute a part of this application, and do not constitute a limitation of the present invention.
[0030] Figure 1 A schematic diagram of an implementation of the machine translation method based on article classification in this scheme;
[0031] Figure 2 This is a schematic diagram of the architecture of this solution;
[0032] Figure 3 This is a schematic diagram of the classification processing flow of this solution. DETAILED DESCRIPTION
[0033] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the embodiments and the accompanying drawings. Here, the illustrative embodiments of the present invention and their descriptions are used to explain the present invention, but are not intended to limit the present invention.
[0034] It should also be noted that, in order to avoid obscuring the present invention due to unnecessary details, only structures and / or processing steps closely related to the solutions according to the present invention are shown in the accompanying drawings, while other details that are not closely related to the present invention are omitted.
[0035] In the existing mainstream machine translation, whether it is a statistical machine translation system or a neural network-based machine translation system, data-driven technology is used. In theory, the larger the amount of training data, the better the effect of the translation system. However, in actual situations, the greater the correlation between the data to be tested and the training data of the translation system, the better the translation effect. If the sentence to be translated belongs to the education category, the performance of the translation system trained with 9 million sentences of high-quality education training data is likely to be better than the translation system trained with 10 million sentences of high-quality non-education training data. In practical applications, there will be two situations. One is that no matter which field the sentence to be translated input by the user belongs to, it is regarded as input and translated using a general system. The other is that the user selects a specific field translation system, inputs the sentence to be translated, and the corresponding field translation system gives the corresponding translation. Neither of these two mechanisms can achieve the optimal translation result. In the first mechanism, because the sentence to be translated is not closely related to the training set correlation of the corresponding system, in the second mechanism, the input is text, and the sentences in the text may belong to different fields, so it is necessary to manually identify the classification of each paragraph of text and input the corresponding field translation system. This method is not efficient enough. The present invention can effectively solve the above problems.
[0036] like Figure 1 and 2As shown in the figure, the present invention proposes a machine translation method based on article classification. The steps of this method include:
[0037] Step S100: Receive a set of sentences to be processed, where the set of sentences includes sentences to be translated.
[0038] In some embodiments of the present invention, the set of sentences to be processed is obtained by splitting the article to be translated. Specifically, during the process of splitting the article, useless words in the article are deleted. The useless words can be conjunctions, prepositions, pronouns or auxiliary words.
[0039] Specifically, conjunctions such as "and", "or", "but", "because", "so", etc.
[0040] Prepositions such as "in", "to", "at", "about", "for", etc.
[0041] Pronouns such as "he", "she", "it", "they", "we", etc.
[0042] Auxiliary words such as "de", "le", "zhe", "guo", "bei", etc.
[0043] Step S200: Classify the sentences to be translated based on a pre-set classifier, and construct a set of sentence classes corresponding to each classification category.
[0044] In the specific implementation process, a set of sentence classes corresponding to each classification category is constructed. The category is the domain category of the sentence. Specifically, the domain category includes the sports field, the education field, the medical field and other fields.
[0045] Step S300: Translate the sentences in the corresponding set of sentence classes based on the translation model set for each category, and obtain the translation sentences of each sentence to be translated.
[0046] In the specific implementation process, the translation model set for each category is a translation model obtained by pre-training through the training data set of this category through machine learning.
[0047] In the specific implementation process, the translation model set for each category is a natural language processing model (NLP). The natural language processing model can be an encoder-decoder structure model, an attention mechanism model or a Transformer model.
[0048] The encoder-decoder structure is one of the most commonly used architectures in Neural Machine Translation (NMT). It consists of an encoder and a decoder. The encoder encodes the source language sentence into a fixed-length vector (also called a context vector or encoded representation), and the decoder receives this vector and decodes it into a sentence in the target language. This structure has achieved remarkable results in translation tasks between multiple language pairs, such as English to Chinese, French to English, etc.
[0049] The attention mechanism is a technique that allows the decoder to focus on different parts of the source language sentence when generating each word. It enables the translation model to better handle long sentences and retain important information, thereby improving the quality of translation. The attention mechanism includes simple attention mechanism and multi-head attention mechanism. The attention mechanism has been widely used in various neural machine translation models and has achieved significant performance improvements;
[0050] The Transformer model is a neural network model based on the self-attention mechanism. It completely abandons the structure of recurrent neural networks (RNN) and convolutional neural networks (CNN), and instead uses a multi-head self-attention mechanism and position encoding to capture dependencies in sequences. The Transformer model has the advantages of strong parallel computing capabilities, fast training speed, and the ability to capture long-distance dependencies. The Transformer model has become one of the mainstream models in the current machine translation field. Large language models such as BERT and GPT are based on the Transformer architecture.
[0051] By adopting the above scheme, the present invention has made improvements on the traditional machine translation mechanism, using a classification algorithm to divide the sentences to be translated into fields, and then put them into the corresponding classification field translation system for translation. Compared with the traditional method of manually selecting a classification field translation system for translation, the invention can save the time of manually judging the classification field to which the sentence belongs. Compared with directly using a general translation system for translation, the invention can effectively improve the translation accuracy.
[0052] In the specific implementation process, the second module of the present invention is a machine translation module. After calculation by the first module, a score of the corresponding classification field is given for each sentence. In the second module, for each sentence to be translated in the article, the corresponding field translation system is called according to the corresponding field information to translate the sentence, and finally the translated sentences are merged to obtain the final translation result.
[0053] In some embodiments of the present invention, before the step of receiving a set of sentences to be processed, wherein the sentence set includes sentences to be translated, the step includes: obtaining an article to be translated, splitting the sentences in the article based on preset tags into multiple sentences to be translated, and constructing them into a sentence set.
[0054] In some embodiments of the present invention, in the step of obtaining an article to be translated, splitting sentences in the article based on preset tags, splitting them into multiple sentences to be translated, and constructing them into a sentence set, the sentences to be translated obtained after the splitting are numbered based on the order of the sentences in the article.
[0055] In some embodiments of the present invention, in the step of obtaining an article to be translated, splitting sentences in the article based on preset tags, splitting them into multiple sentences to be translated, and constructing them into a sentence set, the preset tags are punctuation marks in the article, and the article is split based on the punctuation marks in the article.
[0056] In a specific implementation process, the punctuation mark may be a comma, a semicolon, a period, or an ellipsis, etc.
[0057] In some embodiments of the present invention, in the step of classifying the sentences to be translated based on a preset classifier, a naive Bayes method is used to perform domain classification on the sentences to be translated.
[0058] In some embodiments of the present invention, in the step of using the naive Bayes method to perform domain classification on the sentence to be translated, the naive Bayes method is used to calculate the category score of the sentence to be translated for each category, and the category of the sentence to be translated is determined based on the category score of the sentence to be translated for each category.
[0059] In the specific implementation process, the naive Bayes method is used to classify the fields of the articles to be translated. For the articles to be translated, the following formula is used to calculate the score of each field category of the article:
[0060] P(x|y i )=p(x1|y i )p(x2|y i )…p(x3|y i )
[0061] Among them, x i Remove all the words after stop in the text, y i For the corresponding category.
[0062] In some embodiments of the present invention, in the step of using the naive Bayes method to classify the domain of the sentence to be translated:
[0063] Use the Embedding layer to convert the sentence to be translated into a sentence vector;
[0064] The converted sentence vector is input into the pre-trained long short-term memory layer for calculation to determine the category score of the sentence to be translated for each category.
[0065] In some embodiments of the present invention, the long short-term memory layer includes an input gate, a forget gate, an output gate, and a pooling layer. In the step of inputting the converted sentence vector into the pre-trained long short-term memory layer for calculation, and determining the category score of the sentence to be translated for each category:
[0066] The sentence vector is processed based on the input gate, the forget gate and the output gate, and processed through an average pooling layer to obtain a score vector;
[0067] The category score of the sentence vector corresponding to each category is determined based on the value of each dimension in the score vector.
[0068] The long short-term memory layer mainly uses word embedding and long short-term memory mechanism (LSTM) for processing. First, the words in the sentence are converted into vectors of a specific dimension, which is called word embedding. The process of converting words into embedding uses an injective function, which can be expressed as a mapping in mathematics, namely:
[0069] f:X→Y
[0070] The transformed word vector is input into the long short-term memory (LSTM) layer for calculation. For the input word vector, the candidate value of the memory unit state at time t is calculated by the following formula And the input gate i t :
[0071] i t =σ(W i x t +U i h t-1 +b i )
[0072]
[0073] Where σ() is the activation function, tanh() represents the hyperbolic tangent function, W i , U i , W c is the corresponding weight matrix, t represents time t, b i With b c Respectively represent bias.
[0074] Then, use the following formula to calculate the value f corresponding to the forget gate of the memory unit at time t: t :
[0075] f t =σ(W f x t +U f h t-1 +b f )
[0076] Where σ() is the activation function, W f , U f is the weight matrix corresponding to the forget gate, t represents time t, b f Indicates the corresponding bias of the forget gate.
[0077] Then according to the above obtained i t , and f t Use the following formula to update the current state value C t :
[0078]
[0079] According to the updated new state value, the final output can be calculated using the following formula:
[0080] o t =σ(W o x t +U o h t-1 +b o )
[0081] h t =o t *tanh(C t )
[0082] Where σ() is the activation function, tanh() represents the hyperbolic tangent function, W o with U o is the corresponding weight matrix, t represents time t, b o Represents the output function bias.
[0083] After the above steps, t hidden long short-term memory neural unit vectors will be obtained. These vectors pass through an average pooling layer, which averages the above t vectors and finally obtains a vector h.
[0084] Next, we classify the vector h. Before classification, we first need to convert the score of the text belonging to the corresponding category into a vector with the same dimension as the vector h. We can use the bag-of-words model to achieve this conversion. If the dimension of the vector h is n, the vector of category i is represented by the i-th dimension value as the corresponding score, and the values of other dimensions are 0.
[0085] like Figure 3 As shown, where X0 is the vector h, X i They are the vectors corresponding to the scores of the categories to which the articles belong. Layer L1 is the input layer. Xn represents the values in the vectors. Layer L2 is the hidden layer, which calculates the hidden features. Layer L3 is the output layer, which outputs the final results. The forward propagation algorithm is used, and the specific formula is as follows:
[0086] z (l) =W (l-1) x (l-1) +b (l-1)
[0087] a (l) =f(z (l) )
[0088] h W,b (x) = a (L-1)
[0089] Where L n For the nth layer, X n is the input feature, W, b are weights and biases respectively, h W,b (x) is the output.
[0090] After the above steps, for a given sentence, the information about the classification field to which the sentence belongs can be obtained through classification.
[0091] In some embodiments of the present invention, the method further comprises:
[0092] Get the translation sentence corresponding to each sentence to be translated;
[0093] The translation sentences are combined based on the numbers of the sentences to be translated to obtain a translation article of the corresponding article.
[0094] By adopting the above scheme, this scheme can number the translated sentences and re-combine the translated sentences based on the numbers, thereby ensuring the order of the translated sentences and directly providing the user with feedback on the entire translated article, thereby improving the user experience.
[0095] In summary, the present invention has made improvements on the traditional machine translation mechanism, using a classification algorithm to divide the sentences to be translated into fields, and then put them into the corresponding classification field translation system for translation. Compared with the traditional method of manually selecting a classification field translation system for translation, the invention can save the time of manually judging the classification field to which the sentence belongs. Compared with directly using a general translation system for translation, the invention can effectively improve the translation accuracy. The method is simple and easy, and the field categories are easy to expand. It can increase the translation accuracy of the system by about 5% of the BLEU value without affecting the overall translation speed.
[0096] An embodiment of the present invention also provides a machine translation system based on article classification, the system comprising a computer device, the computer device comprising a processor and a memory, the memory storing computer instructions, the processor being used to execute the computer instructions stored in the memory, and when the computer instructions are executed by the processor, the system implements the steps implemented by the method described above.
[0097] The embodiment of the present invention also provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps implemented by the aforementioned machine translation method based on article classification are implemented. The computer-readable storage medium can be a tangible storage medium, such as a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a floppy disk, a hard disk, a removable storage disk, a CD-ROM, or any other form of storage medium known in the technical field.
[0098] It should be understood by those skilled in the art that the exemplary components, systems and methods described in conjunction with the embodiments disclosed herein can be implemented in hardware, software or a combination of the two. Whether it is performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention. When implemented in hardware, it can be, for example, an electronic circuit, an application specific integrated circuit (ASIC), appropriate firmware, a plug-in, a function card, etc. When implemented in software, the elements of the present invention are programs or code segments used to perform the required tasks. The program or code segment can be stored in a machine-readable medium, or transmitted on a transmission medium or a communication link via a data signal carried in a carrier.
[0099] It should be clear that the present invention is not limited to the specific configuration and processing described above and shown in the figures. For the sake of simplicity, a detailed description of the known method is omitted here. In the above embodiments, several specific steps are described and shown as examples. However, the method process of the present invention is not limited to the specific steps described and shown, and those skilled in the art can make various changes, modifications and additions, or change the order between the steps after understanding the spirit of the present invention.
[0100] In the present invention, features described and / or illustrated for one embodiment may be used in the same or similar manner in one or more other embodiments, and / or combined with features of other embodiments or replace features of other embodiments.
[0101] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the embodiments of the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A machine translation method based on article classification, characterized in that: The steps of the method include: receiving a set of sentences to be processed, wherein the set of sentences includes sentences to be translated; Classify the sentences to be translated based on a preset classifier, and construct a sentence class set of the corresponding category based on the category of each classification; The sentences in the corresponding sentence class set are translated based on the translation model set corresponding to each category to obtain the translation sentence of each corresponding sentence to be translated.
2. The machine translation method based on article classification according to claim 1 is characterized in that: Before the step of receiving a sentence set to be processed, wherein the sentence set includes sentences to be translated, the step includes: obtaining an article to be translated, splitting sentences in the article based on preset tags into multiple sentences to be translated, and constructing them into a sentence set.
3. The machine translation method based on article classification according to claim 2 is characterized in that: In the step of obtaining an article to be translated, splitting sentences in the article based on preset tags, splitting them into multiple sentences to be translated, and constructing them into a sentence set, the sentences to be translated obtained after the splitting are numbered based on the order of the sentences in the article.
4. The machine translation method based on article classification according to claim 2 is characterized in that: In the step of obtaining an article to be translated, splitting sentences in the article based on preset tags, splitting them into multiple sentences to be translated, and constructing them into a sentence set, the preset tags are punctuation marks in the article, and the article is split based on the punctuation marks in the article.
5. The machine translation method based on article classification according to any one of claims 1 to 4, characterized in that: In the step of classifying the sentences to be translated based on the preset classifier, the naive Bayes method is used to perform domain classification on the sentences to be translated.
6. The machine translation method based on article classification according to claim 5 is characterized in that: In the step of using the naive Bayes method to classify the sentences to be translated into different fields, the naive Bayes method is used to calculate the category score of the sentences to be translated for each category, and the category of the sentences to be translated is determined based on the category score of the sentences to be translated for each category.
7. The machine translation method based on article classification according to claim 6 is characterized in that: In the step of using the naive Bayes method to classify the translated sentences into different fields: Use the Embedding layer to convert the sentence to be translated into a sentence vector; The converted sentence vector is input into the pre-trained long short-term memory layer for calculation to determine the category score of the sentence to be translated for each category.
8. The machine translation method based on article classification according to claim 7 is characterized in that: The long short-term memory layer includes an input gate, a forget gate, an output gate and a pooling layer. In the step of inputting the transformed sentence vector into the pre-trained long short-term memory layer for calculation, determining the category score of the sentence to be translated for each category: The sentence vector is processed based on the input gate, the forget gate and the output gate, and processed through an average pooling layer to obtain a score vector; The category score of the sentence vector corresponding to each category is determined based on the value of each dimension in the score vector.
9. The machine translation method based on article classification according to claim 7 or 8, characterized in that: The method also includes the steps of: Get the translation sentence corresponding to each sentence to be translated; The translation sentences are combined based on the numbers of the sentences to be translated to obtain a translation article of the corresponding article.
10. A machine translation system based on article classification, characterized in that: The system includes a computer device, which includes a processor and a memory. The memory stores computer instructions. The processor is used to execute the computer instructions stored in the memory. When the computer instructions are executed by the processor, the system implements the steps implemented by the method as described in any one of claims 1 to 9.