A translation method, device, electronic device and readable storage medium
By obtaining and analyzing the number of units appearing and position information in the text to be translated, and selecting appropriate translated content, the problem of repeated content in machine translation is solved and the translation accuracy is improved.
Patent Information
- Application Number
- CN202111437395.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-29
- Publication Date
- 2025-01-10
- Estimated Expiration
- 2041-11-29
AI Technical Summary
In existing machine translation technology, the translation results may have multiple duplications of the same content, resulting in reduced accuracy.
By obtaining the text to be translated, word segmentation process is performed, the number of occurrences and position information of each unit are obtained, and appropriate translation content is selected from the predetermined translation content based on this information, reducing the probability that the same unit is translated into the same content.
It effectively reduces the recurrence of the same content in the translation results and improves the accuracy of machine translation.
Smart Images

Figure CN114254630B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of machine translation, and in particular to a translation method, device, electronic device and readable storage medium. Background Art
[0002] At present, machine translation, also known as automatic translation, is the process of using computers to convert one natural language (source language) into another natural language (target language). Among them, with the rapid development of economic globalization and the Internet, machine translation technology plays an increasingly important role in promoting political, economic, and cultural exchanges. Therefore, machine translation has important practical value.
[0003] For example, if a Chinese sentence "Today's weather is really good" is machine translated into English "today's weather is really nice", the translation result may be "today's weather is really nicenice", which does not conform to grammatical logic.
[0004] Therefore, in current machine translation, the translation result may have multiple words repeated, thereby reducing the accuracy of machine translation. Summary of the invention
[0005] The embodiments of the present application provide a translation method, an apparatus, an electronic device, and a readable storage medium to solve the problem that in current machine translation, the translation result may contain multiple identical contents repeated.
[0006] In a first aspect, an embodiment of the present application provides a translation method, the method comprising:
[0007] Get the text to be translated;
[0008] Performing word segmentation processing on the text to be translated to obtain multiple units;
[0009] Obtaining the number of occurrences of each of the units in the text to be translated;
[0010] When i is an integer between 1 and n, obtaining the position information of the i-th unit in the text to be translated;
[0011] Selecting, according to the occurrence number and position information of the i-th unit in the text to be translated, the translation content of the i-th unit in the text to be translated from a plurality of predetermined translation contents corresponding to the i-th unit;
[0012] Wherein, n represents the number of the plurality of units.
[0013] In a second aspect, an embodiment of the present application provides a translation device, the device comprising:
[0014] A text acquisition module is used to acquire the text to be translated;
[0015] A unit acquisition module, used for performing word segmentation processing on the text to be translated to obtain multiple units;
[0016] A frequency acquisition module, used to acquire the number of occurrences of each unit in the text to be translated;
[0017] A position information acquisition module, used for acquiring the position information of the i-th unit in the text to be translated when i is an integer from 1 to n;
[0018] A first translation content determination module, configured to select the translation content of the i-th unit in the text to be translated from a plurality of predetermined translation contents corresponding to the i-th unit according to the number of occurrences and position information of the i-th unit in the text to be translated;
[0019] Wherein, n represents the number of the plurality of units.
[0020] In a third aspect, an embodiment of the present application provides an electronic device, comprising a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the computer program implements the steps of the above-mentioned translation method when executed by the processor.
[0021] In a fourth aspect, an embodiment of the present application 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 of the above-mentioned translation method are implemented.
[0022] In an embodiment of the present application, a text to be translated can be obtained; the text to be translated is segmented to obtain a plurality of units; the number of occurrences of each of the units in the text to be translated is obtained; when i takes each integer from 1 to n, the position information of the i-th unit in the text to be translated is obtained; according to the number of occurrences and the position information of the i-th unit in the text to be translated, the translation content of the i-th unit in the text to be translated is selected from a plurality of translation contents corresponding to the i-th unit that are predetermined; wherein n represents the number of the plurality of units.
[0023] Among them, the embodiment of the present application selects the appropriate translation content of the unit in the text to be translated from a plurality of predetermined translation contents corresponding to the unit according to the number of occurrences and position information of the unit in the text to be translated. In the prior art, a translation content is directly selected from a plurality of predetermined translation contents corresponding to the unit. Therefore, the embodiment of the present application can reduce the probability that the same unit in the text to be translated is translated into the same content, thereby solving the problem that the result of the translation may have multiple identical contents repeated in the current machine translation to a certain extent. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the description of the embodiments of the present application will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0025] Figure 1 is a flowchart of the steps of a translation method provided in an embodiment of the present application;
[0026] Figure 2 It is a schematic diagram of a model architecture for translating English into Chinese in the prior art provided in an embodiment of the present application;
[0027] Figure 3 It is a schematic diagram of a model architecture for translating Chinese into English in the prior art provided in an embodiment of the present application;
[0028] Figure 4 It is a structural block diagram of a translation device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0029] 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 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 ordinary technicians in this field without creative work are within the scope of protection of this application.
[0030] In order to facilitate understanding of the translation method of the embodiment of the present application, the existing related technologies are now introduced as follows:
[0031] Currently, machine translation is a translation method based on neural network models. Among them, the model frameworks of neural machine translation are all encoder-decoder frameworks. The Encoder contains one or several layers of neural networks, and the Decoder also contains one or several layers of neural networks. The goal of the Encoder is to generate a semantic space, extract the information of the original sentence, and use an abstract semantics to replace the original sentence. The purpose of the Decoder is to convert the abstract semantics into a sentence in the target language, and make the generated sentence perfectly express the meaning of the original sentence and conform to the logical habits of the target language.
[0032] For example, the schematic diagram of the model architecture for translating English into Chinese in the prior art is as Figure 2 shown. Among them, the text to be translated "ABCD" is input into the neural machine translation model. After passing through the Encoder, the text to be translated is represented as a high-dimensional vector, generating a semantic space Vx, extracting the information of the text to be translated, and using an abstract semantics (such as A, B, C, D) to replace the text to be translated. The abstract semantics is input into the Decoder, and after decoding, the text to be translated is represented as a suitable translation.
[0033] In addition, the schematic diagram of the model architecture for translating Chinese into English in the prior art is as Figure 3 shown. Among them, the text to be translated "A, B, C, D" is input into the neural machine translation model. After passing through the Encoder, the text to be translated is represented as a high-dimensional vector, generating a semantic space Vy, extracting the information of the text to be translated, and using an abstract semantics (such as ABCD) to replace the text to be translated. The abstract semantics is input into the Decoder, and after decoding, the text to be translated is represented as a suitable translation.
[0034] Among them <eos>The translation end marker.
[0035] It can be seen from this that in the prior art, when the same multiple units in the text to be translated are translated, each time is directly from a predetermined probability table (the probability table includes the probability of a plurality of translation contents corresponding to each unit included in the text to be translated) to select the maximum probability, so there will be a problem of the same translation content recurring. And the embodiment of the present application selects the suitable translation content of the unit in the text to be translated from the predetermined multiple translation contents corresponding to the unit according to the number of occurrences and position information of the unit in the text to be translated. Therefore, the embodiment of the present application can reduce the probability that the same unit in the text to be translated is translated into the same content, thereby solving in current machine translation to a certain extent, the problem that the result of translation may appear that a plurality of identical contents recur.
[0036] In order to make the above-mentioned purposes, features and advantages of the present application more obvious and easy to understand, the translation method provided in the embodiment of the present application is described in detail below in conjunction with the accompanying drawings and specific implementation methods.
[0037] Reference Figure 1 , shows a step flow chart of a translation method in an embodiment of the present application, which may include the following steps 101 to 105.
[0038] Step 101: Obtain the text to be translated.
[0039] The text to be translated is a text of one language, such as a Chinese text, an English text, etc. For example, the Chinese "today's weather is really nice" is translated into the English "today's weather is really nice", wherein the Chinese "today's weather is really good" is the text to be translated; for example, the English "today's weather is really nice" is translated into the Chinese "today's weather is really good", wherein the English "today's weather is really nice" is the text to be translated.
[0040] In addition, the text to be translated can be obtained, for example, through keyboard input, voice input, image recognition, etc., wherein, when keyboard input is used, the text to be translated is the text generated by the keyboard key sequence; when voice input is used, the text to be translated is the text generated by the voice signal; when image recognition is used, the text to be translated is the text recognized from the image.
[0041] Step 102: performing word segmentation processing on the text to be translated to obtain multiple units.
[0042] Among them, word segmentation refers to the process of recombining a continuous sequence of words into a word sequence according to certain specifications; that is, word segmentation is performed according to a pre-established word segmentation library. In the embodiment of the present application, word segmentation is performed on the text to be translated to obtain multiple units, that is, after word segmentation is performed on the text to be translated, multiple units in the text to be translated are obtained.
[0043] In addition, when the text to be translated is in Chinese, the multiple units obtained are multiple words, for example, if the text to be translated is in Chinese "Today's weather is really nice", the multiple units obtained are "today", "weather", "really", and "good"; or if the text to be translated is in English, the multiple units obtained are multiple words, for example, if the text to be translated is in English "today's weather is really nice", the multiple units obtained are "today", "'s", "weather", "is", "really", and "nice".
[0044] Step 103: Obtain the number of occurrences of each of the units in the text to be translated.
[0045] In an embodiment of the present application, obtaining the number of times each unit appears in the text to be translated is to obtain the total number of times each unit appears in the text to be translated; for example, the text to be translated is the Chinese "the weather is really good", then the number of times the unit "weather" appears is 1, the number of times the unit "really" appears is 1, and the number of times the unit "good" appears is 2.
[0046] Step 104: when i is an integer between 1 and n, obtain the position information of the i-th unit in the text to be translated.
[0047] Wherein, n represents the number of the plurality of units.
[0048] In addition, the position information indicates the position where each unit appears in the text to be translated; for example, if the text to be translated is the Chinese "Today's weather is really good", then the position information of the unit "good" is the 4th unit of the text to be translated, the 1st unit is "today", the 2nd unit is "weather", and the 3rd unit is "true".
[0049] Step 105: According to the occurrence number and position information of the i-th unit in the text to be translated, the translation content of the i-th unit in the text to be translated is selected from a plurality of predetermined translation contents corresponding to the i-th unit.
[0050] Wherein, for example, if the translation content corresponding to the 4th unit "hao" in the text to be translated "The weather is really nice today" is "nice", "good", or "fine", then according to the number of occurrences and position information of the unit "hao" in the text to be translated, the appropriate translation content can be selected from "nice", "good", and "fine".
[0051] In addition, after step 105, the translation content of the text to be translated can be displayed on the screen of the terminal device or played as voice through the output function of the terminal device. Alternatively, after being displayed on the screen of the terminal device, if a preset operation of the user is received (such as setting a play physical button on the terminal device or a swipe operation on the touch screen of the terminal device), then the translation content of the text to be translated is played as voice.
[0052] As can be seen from the above steps 101 to 105, in the embodiment of the present application, the text to be translated can be obtained; the text to be translated is segmented to obtain multiple units; the number of occurrences of each unit in the text to be translated is obtained; when i takes each integer from 1 to n, the position information of the i-th unit in the text to be translated is obtained; according to the number of occurrences and position information of the i-th unit in the text to be translated, the translation content of the i-th unit in the text to be translated is selected from multiple pre-determined translation contents corresponding to the i-th unit; wherein, n represents the number of the multiple units.
[0053] Wherein, in the embodiment of the present application, according to the number of occurrences and position information of the unit in the text to be translated, the appropriate translation content of the unit in the text to be translated is selected from multiple pre-determined translation contents corresponding to the unit. In the prior art, a translation content is directly selected from multiple pre-determined translation contents corresponding to the unit. Therefore, the embodiment of the present application can reduce the probability that the same unit in the text to be translated is translated into the same content, thereby solving to a certain extent the problem that multiple identical contents may repeatedly appear in the translation result in the current machine translation.
[0054] Optionally, the step of selecting the translation content of the i-th unit in the text to be translated from multiple pre-determined translation contents corresponding to the i-th unit according to the number of occurrences and position information of the i-th unit in the text to be translated further includes:
[0055] In the case that there is no unit identical to the i-th unit among the first to i-1-th units, a third probability table is obtained, where the third probability table includes the probabilities of multiple pre-determined translation contents corresponding to each unit in the text to be translated.
[0056] The translation content of the i-th unit in the text to be translated is selected from a plurality of translation contents of the i-th unit in the third probability table according to the probability of the translation content corresponding to the i-th unit in the third probability table.
[0057] Among them, "there is no unit identical to the i-th unit in the 1st to i-1st units", which means that the i-th unit appears in the text to be translated for the first time. In this case, the translation content of the i-th unit in the text to be translated is selected based on the pre-determined probabilities of multiple translation contents corresponding to the i-th unit. For example, if the text to be translated "xxx good x good" is translated into English, where the unit "good" does not have the same unit in the 1st to 3rd units of the text to be translated, and the pre-determined translation contents corresponding to "good" include "good, nice, fine", the translation content of the 4th unit "good" in the text to be translated can be selected based on the probabilities of the three words "good, nice, fine".
[0058] In addition, selecting the translation content of the i-th unit in the text to be translated from the multiple translation contents of the i-th unit in the third probability table according to the probability of the translation content corresponding to the i-th unit in the third probability table includes:
[0059] A translation content with the highest probability is selected from a plurality of translation contents of the i-th unit in the third probability table to serve as the translation content of the i-th unit in the text to be translated.
[0060] For example, the text to be translated "The weather is really nice today" is translated into English. When translating to the unit "good", the maximum probability is selected from the pre-determined probabilities of multiple translation contents corresponding to the unit "good" (such as "nice" is 8%, "good" is 6%, "fine" is 5%, etc.), and the translation content "nice" corresponding to the maximum probability is used as the translation of the unit "good".
[0061] Optionally, selecting the translation content of the i-th unit in the text to be translated from a plurality of predetermined translation contents corresponding to the i-th unit according to the number of occurrences and position information of the i-th unit in the text to be translated comprises:
[0062] When there is a unit identical to the i-th unit in the 1st to i-1th units, obtaining a first probability table, wherein the first probability table includes the probabilities of a plurality of translation contents corresponding to each unit included in the text to be translated after the most recent update;
[0063] Determining a penalty coefficient of the i-th unit according to the number of occurrences and position information of the i-th unit in the text to be translated;
[0064] According to the penalty coefficient, the probability of the target translation content in the first probability table is reduced to obtain a second probability table, wherein the target translation content is the translation content of the target unit in the text to be translated, and the target unit is the unit that is the same as the i-th unit and is closest to the i-th unit among the 1st to i-1th units;
[0065] According to the probability of the translation content corresponding to the i-th unit in the second probability table, the translation content of the i-th unit in the text to be translated is selected from the multiple translation contents of the i-th unit in the second probability table.
[0066] Among them, "there is a unit identical to the i-th unit in the 1st to i-1th units", which means that the i-th unit does not appear for the first time in the text to be translated. In this case, the penalty coefficient of the i-th unit is obtained according to the number of occurrences and position information of the i-th unit in the text to be translated; according to the penalty coefficient of the i-th unit, the probability of the above-mentioned target translation content is reduced to obtain a second probability table; according to the probabilities of multiple translation contents corresponding to the i-th unit in the second probability table, the translation content with the largest probability is selected as the translation of the i-th unit.
[0067] For example, the text to be translated "The weather is really good today" is translated into English, where the 4th unit "good" is translated as "nice", when translating the 5th unit "good", firstly, the probabilities of multiple translation contents corresponding to the predetermined 4th unit "good" are obtained (such as "nice" is 8%, "good" is 6%, and "fine" is 5%); secondly, the penalty coefficient of the 5th unit "good" is determined (for example, 2) according to the number of occurrences (2 times) and position information of the 5th unit "good"; thirdly, the probability of "nice" is reduced according to the penalty coefficient of the 5th unit "good", that is, the probability of "nice" is divided by the penalty coefficient of the 5th unit "good", and a second probability table is obtained (that is, "nice" is 4%, "good" is 6%, and "fine" is 5%), thereby reducing the probability of the 5th unit "good" being translated into "nice" in the text to be translated "The weather is really good today".
[0068] From the above, it can be seen that in the embodiment of the present application, the penalty coefficient of each unit can be determined according to the number of occurrences and position information of each unit in the text to be translated; according to the penalty coefficient of each unit, the probability of translating the same unit in the text to be translated into the same content can be reduced, thereby solving the problem that in the current machine translation, the translation result may have multiple identical contents repeated.
[0069] Optionally, determining the penalty coefficient of the i-th unit according to the occurrence times and position information of the i-th unit in the text to be translated includes:
[0070] Determine the target distance between the i-th unit and the target unit;
[0071] According to the target distance and the occurrence times of the i-th unit in the text to be translated, determine the penalty coefficient of the i-th unit.
[0072] Wherein, the target distance is the number of units in the interval between the i-th unit and the target unit.
[0073] For example, the text to be translated is "xx good x good good”. Among them, the 3rd unit, the 5th unit, and the 6th unit are all "good”. Then, for the 3rd unit "good”, there is no "good” unit among the 1st to 2nd units, and there is no distance from the target unit, so there is no need to calculate the penalty coefficient; for the 5th unit "good”, there is a "good” unit among the 1st to 4th units, then the distance between the 5th unit "good” and the 3rd unit "good” is 1; for the 6th unit "good”, there is a "good” unit among the 1st to 5th units, then the distance between the 6th unit "good” and the 5th unit "good” is 0.
[0074] As can be seen from the above, in the embodiments of the present application, when determining the penalty coefficient of the i-th unit according to the occurrence times and position information of the i-th unit in the text to be translated, the penalty coefficient of the i-th unit is actually determined according to the occurrence times of the i-th unit and the distance between the i-th unit and the target unit.
[0075] Optionally, determining the penalty coefficient of the i-th unit according to the target distance and the occurrence times of the i-th unit in the text to be translated includes:
[0076] Obtain the penalty coefficient corresponding to the target distance and the occurrence times of the i-th unit in the text to be translated from the pre-determined corresponding relationship as the penalty coefficient of the i-th unit;
[0077] Wherein, the corresponding relationship includes the corresponding relationship between the distance between units, the occurrence times of units in the text to be translated, and the penalty coefficient.
[0078] In addition, in the pre-determined corresponding relationship, different target distances and different occurrence times of a unit correspond to different penalty coefficients.
[0079] In the application embodiment, the smaller the target distance and the larger the number of occurrences of the i-th unit in the text to be translated, the larger the penalty coefficient of the i-th unit; the larger the target distance and the smaller the number of occurrences of the i-th unit in the text to be translated, the smaller the penalty coefficient of the i-th unit.
[0080] For example, the text to be translated is "xx good x good good", where the number of occurrences of the unit "good" in the text to be translated is 3 times, and the target distance between the 5th unit "good" and the 3rd unit "good" is 1; then the penalty coefficient of the 5th unit "good" can be 2; the target distance between the 6th unit "good" and the 5th unit "good" is 0, so the penalty coefficient of the 6th unit "good" can be 4.
[0081] Optionally, reducing the probability of the target translation content in the first probability table according to the penalty coefficient includes:
[0082] Calculating the ratio of the probability of the target translation content in the first probability table to the penalty coefficient as the updated probability of the target translation content.
[0083] For example, in the text to be translated "XXX good X good", the 4th unit "good" appears for the first time and has no penalty coefficient, and the probability is pre-determined, for example, 8%; if the penalty coefficient determined according to the distance and the number of occurrences of the 6th unit "good" from the 4th unit "good" is 2, then the probability of the translation content "nice" corresponding to the 6th unit "good" is updated to 4%.
[0084] Optionally, selecting the translation content of the i-th unit in the text to be translated from the multiple translation contents of the i-th unit in the second probability table according to the probability of the translation content corresponding to the i-th unit in the second probability table includes:
[0085] Selecting the translation content with the highest probability from the multiple translation contents of the i-th unit in the second probability table as the translation content of the i-th unit in the text to be translated.
[0086] Wherein, the second probability table is the probability table after the first probability table is updated, that is, the second probability table includes the updated probabilities of multiple translation contents corresponding to each unit included in the text to be translated.
[0087] In the application embodiment of the present application, compared with the first probability table, the second probability table reduces the probability of the translation content of the target unit in the text to be translated, that is, reduces the probability that the same unit is translated into the same translation content, thereby avoiding the problem of repeated occurrence of the same translation content.
[0088] For example, translate the text to be translated "xxx good x" into English. Among them, the probabilities of the translation content corresponding to the 4th unit "good" include: "nice" is 8%, "good" is 7%, and "fine" is 6%. When the 4th unit "good" is translated as "nice", when translating to the 5th unit "good", according to the number of occurrences and position information of the 5th unit "good" in the text to be translated, it is determined that the penalty coefficient of the 5th unit "good" is 2. Then the probability of translating the 5th unit "good" as "nice" is reduced to 4%. The probabilities of the translation content corresponding to the unit "good" are updated to: "nice" is 4%, "good" is 7%, and "fine" is 6%. At this time, the 5th unit "good" selects the word with the highest probability among "good", "fine", and "nice", that is, the 5th unit "good" is no longer translated as "nice".
[0089] Optionally, the obtaining of the third probability table includes:
[0090] Using the neural network model algorithm of machine translation to obtain the third probability table.
[0091] Among them, the neural network model of machine translation (NMT) can train a neural network that maps from one sequence to another sequence, and the output can be a variable-length sequence. In the embodiments of the present application, the text to be translated is input into the neural network model of machine translation, and a third probability table including the probabilities of multiple translation contents corresponding to each unit in the text to be translated is obtained.
[0092] Optionally, the obtaining of the position information of the i-th unit in the text to be translated includes:
[0093] When the number of occurrences of the i-th unit in the text to be translated is greater than a preset threshold, obtain the position information of the i-th unit in the text to be translated.
[0094] In the embodiments of the present application, a preset threshold for the number of occurrences of a unit in the text to be translated is preset (for example, 1). Then, when the number of occurrences of each unit in the text to be translated is greater than 1, obtain the position information of the unit in the text to be translated, that is, when the number of occurrences of the "i"-th unit in the text to be translated is greater than the preset threshold 1, record the position information of the "i"-th unit in the text to be translated, rather than recording the position information of each unit in the text to be translated, thereby saving computing resources in the translation process.
[0095] In summary, the specific implementation manner of the translation method in the embodiments of the present application can be described as follows:
[0096] Step H1: Obtain the text to be translated.
[0097] Step H2: Perform word segmentation on the text to be translated to obtain multiple units;
[0098] Step H3: Obtain the number of occurrences of each unit in the text to be translated;
[0099] Step H4: when i is an integer between 1 and n, and the number of occurrences of the i-th unit in the text to be translated is greater than a preset threshold, recording the position information of the i-th unit in the text to be translated, wherein n represents the number of units included in the text to be translated;
[0100] Step H5: If there is no unit identical to the i-th unit in the 1st to i-1st units, execute step H6; if there is a unit identical to the i-th unit in the 1st to i-1st units, execute steps H7 to H9;
[0101] Step H6: obtaining a third probability table, wherein the third probability table includes predetermined probabilities of multiple translation contents corresponding to the i-th unit; selecting the translation content with the highest probability from the multiple translation contents of the i-th unit in the third probability table as the translation content of the i-th unit in the text to be translated;
[0102] Step H7: Calculate the target distance between the ith unit and the target unit, determine the penalty coefficient of the ith unit according to the number of occurrences of the ith unit in the text to be translated and the target distance, and then execute step H8, wherein the target unit is the unit that is the same as the ith unit and closest to it among the units 1 to i-1;
[0103] Step H8: Obtain a first probability table, wherein the first probability table includes the probabilities of multiple translation contents corresponding to the i-th unit after the most recent update; according to the penalty coefficient of the i-th unit, reduce the probability of the translation content of the target unit in the text to be translated in the first probability table to obtain a second probability table.
[0104] Step H9: Select the translation content with the highest probability from the multiple translation contents of the i-th unit in the second probability table to serve as the translation content of the i-th unit in the text to be translated.
[0105] It can be seen that in an embodiment of the present application, a text to be translated can be obtained; the text to be translated is segmented to obtain a plurality of units; the number of occurrences of each of the units in the text to be translated is obtained; when i takes each integer from 1 to n, the position information of the i-th unit in the text to be translated is obtained; according to the number of occurrences and the position information of the i-th unit in the text to be translated, the translation content of the i-th unit in the text to be translated is selected from a plurality of translation contents corresponding to the i-th unit that are predetermined; wherein n represents the number of the plurality of units.
[0106] Among them, the embodiment of the present application selects the appropriate translation content of the unit in the text to be translated from a plurality of predetermined translation contents corresponding to the unit according to the number of occurrences and position information of the unit in the text to be translated. In the prior art, a translation content is directly selected from a plurality of predetermined translation contents corresponding to the unit. Therefore, the embodiment of the present application can reduce the probability that the same unit in the text to be translated is translated into the same content, thereby solving the problem that the result of the translation may have multiple identical contents repeated in the current machine translation to a certain extent.
[0107] It should be noted that, for the method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the embodiments of the present application are not limited by the described order of actions, because according to the embodiments of the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of the present application.
[0108] Reference Figure 4 , shows a structural block diagram of a translation device in an embodiment of the present application, and the translation device 400 may include the following modules:
[0109] The text acquisition module 401 is used to acquire the text to be translated;
[0110] The unit acquisition module 402 is used to perform word segmentation processing on the text to be translated to obtain multiple units;
[0111] A frequency acquisition module 403 is used to acquire the number of occurrences of each unit in the text to be translated;
[0112] A position information acquisition module 404, configured to acquire position information of the i-th unit in the text to be translated when i is an integer from 1 to n;
[0113] A first translation content determination module 405, configured to select the translation content of the i-th unit in the text to be translated from a plurality of predetermined translation contents corresponding to the i-th unit according to the number of occurrences and position information of the i-th unit in the text to be translated;
[0114] Wherein, n represents the number of the plurality of units.
[0115] Optionally, the first translation content determination module 405 includes:
[0116] A first probability table acquisition submodule, configured to acquire a first probability table when there is a unit identical to the i-th unit in the first to i-1 units, wherein the first probability table includes the most recently updated probabilities of a plurality of translation contents corresponding to each unit included in the text to be translated;
[0117] A penalty coefficient determination submodule, used to determine the penalty coefficient of the i-th unit according to the number of occurrences and position information of the i-th unit in the text to be translated;
[0118] A second probability table acquisition submodule is used to reduce the probability of the target translation content in the first probability table according to the penalty coefficient to obtain a second probability table, wherein the target translation content is the translation content of the target unit in the text to be translated, and the target unit is the unit that is the same as the i-th unit and is closest to the i-th unit among the 1st to i-1th units;
[0119] The translation content determination submodule is used to select the translation content of the i-th unit in the text to be translated from multiple translation contents of the i-th unit in the second probability table according to the probability of the translation content corresponding to the i-th unit in the second probability table.
[0120] Optionally, the penalty coefficient determination submodule includes:
[0121] a distance determination unit, used to determine a target distance between the i-th unit and the target unit;
[0122] The penalty coefficient determination unit is used to determine the penalty coefficient of the i-th unit according to the target distance and the number of occurrences of the i-th unit in the text to be translated.
[0123] Optionally, the penalty coefficient determination unit is specifically used to:
[0124] Obtaining, from a predetermined corresponding relationship, a penalty coefficient corresponding to the target distance and the number of occurrences of the i-th unit in the text to be translated, as the penalty coefficient of the i-th unit;
[0125] The corresponding relationship includes the corresponding relationship between the distance between units, the number of occurrences of the units in the text to be translated, and the penalty coefficient.
[0126] Optionally, the second probability table acquisition submodule is specifically used to:
[0127] The ratio of the probability of the target translation content in the first probability table to the penalty coefficient is calculated as the probability of the target translation content after update.
[0128] Optionally, the translation content determination submodule is specifically used to:
[0129] From the multiple translation contents of the i-th unit in the second probability table, a translation content with the highest probability is selected as the translation content of the i-th unit in the text to be translated.
[0130] Optionally, the translation device 400 further includes:
[0131] A third probability table acquisition module is used to acquire a third probability table when there is no unit identical to the i-th unit in the first to the i-1th units, wherein the third probability table includes predetermined probabilities of a plurality of translation contents corresponding to each unit in the text to be translated;
[0132] The second translation content determination module is used to select the translation content of the i-th unit in the text to be translated from the multiple translation contents of the i-th unit in the third probability table according to the probability of the translation content corresponding to the i-th unit in the third probability table.
[0133] Optionally, the third probability table acquisition module is specifically used to:
[0134] The third probability table is obtained by using a neural network model algorithm of machine translation.
[0135] Optionally, the location information acquisition module 404 is specifically used to:
[0136] When the number of occurrences of the i-th unit in the text to be translated is greater than a preset threshold, position information of the i-th unit in the text to be translated is obtained.
[0137] As can be seen from the above, in an embodiment of the present application, a text to be translated can be obtained; the text to be translated is segmented to obtain a plurality of units; the number of occurrences of each of the units in the text to be translated is obtained; when i takes each integer from 1 to n, the position information of the i-th unit in the text to be translated is obtained; according to the number of occurrences and position information of the i-th unit in the text to be translated, the translation content of the i-th unit in the text to be translated is selected from a plurality of translation contents corresponding to the i-th unit that are predetermined; wherein n represents the number of the plurality of units.
[0138] Among them, the embodiment of the present application selects the appropriate translation content of the unit in the text to be translated from a plurality of predetermined translation contents corresponding to the unit according to the number of occurrences and position information of the unit in the text to be translated. In the prior art, a translation content is directly selected from a plurality of predetermined translation contents corresponding to the unit. Therefore, the embodiment of the present application can reduce the probability that the same unit in the text to be translated is translated into the same content, thereby solving the problem that the result of the translation may have multiple identical contents repeated in the current machine translation to a certain extent.
[0139] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0140] The present application also provides an electronic device, including:
[0141] One or more processors; and one or more machine-readable media having instructions stored thereon, which, when executed by the one or more processors, enable the electronic device to perform the method described in the embodiments of the present application.
[0142] The embodiments of the present application also provide one or more machine-readable media on which instructions are stored, which, when executed by one or more processors, enable the processors to execute the methods described in the embodiments of the present application.
[0143] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.
[0144] Those skilled in the art will appreciate that the embodiments of the present application can be provided as methods, devices, or computer program products. Therefore, the present application can adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application can adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0145] The embodiments of the present application are described with reference to the flowcharts and / or block diagrams of the methods, terminal devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0146] These computer program instructions may also be stored in a computer readable memory capable of directing a computer or other programmable data processing terminal device to operate in a specific manner, so that the instructions stored in the computer readable memory produce a manufactured product including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0147] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions for implementing the process in the computer or other programmable terminal device. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0148] Although the preferred embodiments of the present application have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the embodiments of the present application.
[0149] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or terminal device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or terminal device. In the absence of further restrictions, the elements defined by the sentence "including a..." do not exclude the existence of other identical elements in the process, method, article or terminal device including the elements.
[0150] The above is a detailed introduction to a translation method and device provided by the present application. Specific examples are used in this article 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 those skilled in the art, 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.< / eos>
Claims
1. A translation method, characterized in that: The method comprises: Get the text to be translated; Performing word segmentation processing on the text to be translated to obtain multiple units; Obtaining the number of occurrences of each of the units in the text to be translated; When i is an integer between 1 and n, obtaining the position information of the i-th unit in the text to be translated; Selecting, according to the occurrence number and position information of the i-th unit in the text to be translated, the translation content of the i-th unit in the text to be translated from a plurality of predetermined translation contents corresponding to the i-th unit; Among them, selecting the translation content of the i-th unit in the text to be translated from a plurality of predetermined translation contents corresponding to the i-th unit according to the number of occurrences and position information of the i-th unit in the text to be translated comprises: When there is a unit identical to the i-th unit in the 1st to i-1th units, obtaining a first probability table, wherein the first probability table includes the probabilities of a plurality of translation contents corresponding to each unit included in the text to be translated after the most recent update; Determining a penalty coefficient of the i-th unit according to the number of occurrences and position information of the i-th unit in the text to be translated; According to the penalty coefficient, the probability of the target translation content in the first probability table is reduced to obtain a second probability table, wherein the target translation content is the translation content of the target unit in the text to be translated, and the target unit is the unit that is the same as the i-th unit and is closest to the i-th unit among the 1st to i-1th units; According to the probability of the translation content corresponding to the i-th unit in the second probability table, selecting the translation content of the i-th unit in the text to be translated from multiple translation contents of the i-th unit in the second probability table; Wherein, n represents the number of the plurality of units.
2. The method according to claim 1, characterized in that Determining the penalty coefficient of the i-th unit according to the number of occurrences and position information of the i-th unit in the text to be translated includes: Determine a target distance between the i-th unit and the target unit; A penalty coefficient of the i-th unit is determined according to the target distance and the number of occurrences of the i-th unit in the text to be translated.
3. The method according to claim 2, characterized in that Determining the penalty coefficient of the i-th unit according to the target distance and the number of occurrences of the i-th unit in the text to be translated includes: Obtaining, from a predetermined corresponding relationship, a penalty coefficient corresponding to the target distance and the number of occurrences of the i-th unit in the text to be translated, as the penalty coefficient of the i-th unit; The corresponding relationship includes the corresponding relationship between the distance between units, the number of occurrences of the units in the text to be translated, and the penalty coefficient.
4. The method according to claim 1, characterized in that The reducing the probability of the target translation content in the first probability table according to the penalty coefficient includes: The ratio of the probability of the target translation content in the first probability table to the penalty coefficient is calculated as the probability of the target translation content after update.
5. The method according to claim 1, characterized in that The selecting, according to the probability of the translation content corresponding to the i-th unit in the second probability table, the translation content of the i-th unit in the text to be translated from the multiple translation contents of the i-th unit in the second probability table comprises: From the multiple translation contents of the i-th unit in the second probability table, a translation content with the highest probability is selected as the translation content of the i-th unit in the text to be translated.
6. The method according to claim 1, characterized in that The step of selecting the translation content of the i-th unit in the text to be translated from a plurality of predetermined translation contents corresponding to the i-th unit according to the number of occurrences and position information of the i-th unit in the text to be translated also includes: In the case that there is no unit identical to the i-th unit in the 1st to i-1th units, obtaining a third probability table, wherein the third probability table includes predetermined probabilities of a plurality of translation contents corresponding to each unit included in the text to be translated; The translation content of the i-th unit in the text to be translated is selected from a plurality of translation contents of the i-th unit in the third probability table according to the probability of the translation content corresponding to the i-th unit in the third probability table.
7. A translation device, characterized in that: The device comprises: A text acquisition module is used to acquire the text to be translated; A unit acquisition module, used for performing word segmentation processing on the text to be translated to obtain multiple units; A frequency acquisition module, used to acquire the number of occurrences of each unit in the text to be translated; A position information acquisition module, used for acquiring the position information of the i-th unit in the text to be translated when i is an integer from 1 to n; A first translation content determination module, configured to select the translation content of the i-th unit in the text to be translated from a plurality of predetermined translation contents corresponding to the i-th unit according to the number of occurrences and position information of the i-th unit in the text to be translated; Wherein, the first translation content determination module includes: A first probability table acquisition submodule, configured to acquire a first probability table when there is a unit identical to the i-th unit in the first to i-1 units, wherein the first probability table includes the most recently updated probabilities of a plurality of translation contents corresponding to each unit included in the text to be translated; A penalty coefficient determination submodule, used to determine the penalty coefficient of the i-th unit according to the number of occurrences and position information of the i-th unit in the text to be translated; A second probability table acquisition submodule is used to reduce the probability of the target translation content in the first probability table according to the penalty coefficient to obtain a second probability table, wherein the target translation content is the translation content of the target unit in the text to be translated, and the target unit is the unit that is the same as the i-th unit and is closest to the i-th unit among the 1st to i-1th units; a translation content determination submodule, configured to select, according to the probability of the translation content corresponding to the ith unit in the second probability table, the translation content of the ith unit in the text to be translated from the plurality of translation contents of the ith unit in the second probability table; Wherein, n represents the number of the plurality of units.
8. An electronic device, characterized in that: The method comprises a processor, a memory and a computer program stored in the memory and executable on the processor, wherein the computer program implements the steps of the translation method according to any one of claims 1 to 6 when executed by the processor.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the translation method according to any one of claims 1 to 6 are implemented.
Citation Information
Patent Citations
Machine translation method and apparatus based on RNN model
CN105183720A
Method for avoiding duplication of translation segments in machine translation
CN113191165A