Document translation method and electronic equipment

By constructing a collection of prompt words corresponding to the data type and using translated content for translation, the problem of poor context relevance in document translation in the prior art is solved, and the translation effect and user experience are improved.

CN119167948APending Publication Date: 2024-12-20XFUSION DIGITAL TECH CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202410972044.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-18
Publication Date
2024-12-20

AI Technical Summary

Technical Problem

In the translation of existing documents, the translation results of the literal translation model have poor correlation with the context, resulting in poor translation results, hallucinations, and failure to fully meet the actual translation needs of users.

Method used

By extracting the data type and attribute information in the document to be translated, a corresponding collection of prompt words is constructed, and the translation prompt words in the translated content is translated, and the translation results are displayed in the target document to maintain the consistency of context and improve relevance .

Benefits of technology

It improves translation effect and practicality, adapts to the translation needs of different data types, enhances the context relevance and accuracy of translation results, and improves the overall translation efficiency and user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119167948A_ABST
    Figure CN119167948A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a document translation method and electronic equipment, and the document translation method comprises the steps: extracting each to-be-translated content in a to-be-translated document, and determining the data type and attribute information of each to-be-translated content; the attribute information is used for indicating the attribute of the to-be-translated content in the to-be-translated document; according to the data type of the to-be-translated content, constructing a prompt word set of the to-be-translated content; the cue word set comprises translation cue words, and the translation cue words are extracted from translated contents in the to-be-translated document and used for translating the to-be-translated contents; determining a translation result of the to-be-translated content according to the prompt word set of the to-be-translated content; and according to the attribute information of each to-be-translated content, displaying a translation result of each to-be-translated content in the target document. According to the document translation method provided by the embodiment of the invention, the context relevance of the translation result is improved, and the translation effect is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to the field of natural language processing technology, and in particular to a document translation method and electronic device. Background Art

[0002] Machine Translation (MT) is the process of using a computer program to convert one natural language (source language, i.e. the language before translation) into another natural language (target language, i.e. the language after translation).

[0003] However, in current document translation, literal translation is usually performed using translation models directly. The translation results obtained by literal translation using current translation models are generally poorly correlated with the context, the context cohesion is not high enough, and even hallucinations may occur. The translation effect of document translation needs to be further improved. Summary of the invention

[0004] The embodiments of the present application provide a document translation method and an electronic device, which can improve the translation effect.

[0005] In a first aspect, an embodiment of the present application provides a document translation method, the method comprising:

[0006] Extracting each content to be translated in the document to be translated, and determining the data type and attribute information of each content to be translated; wherein the attribute information is used to indicate the attribute of the content to be translated in the document to be translated;

[0007] According to the data type of the content to be translated, a prompt word set of the content to be translated is constructed; wherein the prompt word set includes translation prompt words, and the translation prompt words are extracted from the translated content in the document to be translated and are used to translate the content to be translated;

[0008] Determine the translation result of the content to be translated according to the prompt word set of the content to be translated;

[0009] The translation results of each content to be translated are displayed in the target document according to the attribute information of each content to be translated.

[0010] The beneficial effects of this embodiment are as follows: by constructing a prompt word set corresponding to the data type, a corresponding processing method is provided for documents to be translated containing different data types, which is more suitable for the actual translation needs of users and can better translate the content to be translated of the corresponding data type, which not only improves the translation effect but also improves the practicality; in addition, the translation prompt words in the prompt word set are extracted from the translated content in the document to be translated, and the translation is performed according to the translated content, which can not only maintain the consistency of the context translation style, but also improve the context relevance of the translation result, and further improve the translation effect.

[0011] In a possible implementation, constructing a prompt word set of the content to be translated according to the data type of the content to be translated includes:

[0012] According to the data type of the content to be translated, retrieve translation-related information of the content to be translated from the cache; wherein the translation-related information represents information related to the translation of the content to be translated in the translated content of the document to be translated, and the translation-related information includes words that meet preset conditions;

[0013] A prompt word set of the content to be translated is constructed according to the translation-related information.

[0014] The beneficial effect of this implementation is that the translation-related information is first retrieved from the cache, and then the prompt word set is constructed, which can improve the efficiency of constructing the prompt word set, thereby improving the overall document translation efficiency.

[0015] In a possible implementation, according to the data type of the content to be translated, retrieving translation-related information of the content to be translated from the cache includes:

[0016] Determine the data range of the translation-related information of the content to be translated according to the data type of the content to be translated and the preset mapping relationship; wherein the preset mapping relationship is used to indicate the corresponding relationship between the data type and the data range;

[0017] Information within the data range is retrieved from the cache and determined to be translation-related information of the content to be translated.

[0018] The beneficial effects of this implementation are as follows: different data ranges of translation-related information are set for different data types, which is more suitable for the actual translation needs of users and can better translate the to-be-translated content of the corresponding data type.

[0019] In a possible implementation, constructing a prompt word set of the content to be translated according to the translation related information includes:

[0020] Parsing the translation-related information and extracting keywords from the translation-related information; wherein the keywords are words in the translation-related information that meet the preset conditions;

[0021] The keyword is determined as a translation prompt word of the content to be translated, and a corpus consisting of the original text and the translation of each translation prompt word is constructed to be determined as a prompt word set of the content to be translated.

[0022] The beneficial effects of this implementation are as follows: the prompt word set constructed based on keywords is more practical and can provide a more accurate data basis for subsequent translation, thereby improving translation accuracy.

[0023] In a possible implementation, the translation-related information includes one or more of the following information: information about n translated contents that are located before and / or after the content to be translated and adjacent to the content to be translated in the document to be translated, document title information, table subject information, and picture subject information; wherein n is an integer greater than or equal to 1.

[0024] Beneficial effects of this implementation: The appropriate range of translation-related information can provide a more accurate data basis for constructing a prompt word set, thereby providing a more accurate data basis for subsequent translation, so as to improve translation accuracy.

[0025] In a possible implementation, before constructing the prompt word set of the content to be translated, the method further includes:

[0026] It is determined whether the text length of the content to be translated is greater than a first preset length threshold. If so, a step of constructing a prompt word set of the content to be translated is executed; if not, the content to be translated is translated based on a standard term library.

[0027] The beneficial effects of this implementation are as follows: only a prompt word set is constructed for long texts, and phrases and words are directly translated using a standard terminology library, which can improve the overall translation efficiency.

[0028] In a possible implementation manner, after determining the translation result of the content to be translated, the method further includes:

[0029] The translation results of the content to be translated are saved in the cache.

[0030] The beneficial effect of this implementation is that the translation result of the content to be translated is saved in the cache, so that when constructing a prompt word set for other content to be translated in the document to be translated, the information of the translated content can be directly retrieved from the cache, thereby improving the efficiency of subsequent data processing.

[0031] In a possible implementation, displaying the translation results of each content to be translated in the target document according to the attribute information of each content to be translated includes:

[0032] According to the attribute information of the content to be translated, the attribute information of the translation result of the content to be translated is adjusted, and each adjusted translation result is filled into the target document for display, so that the layout of each adjusted translation result in the target document is consistent with the layout of the document to be translated.

[0033] The beneficial effects of this implementation method are: the layout of the target document and the document to be translated is kept consistent, which makes it easier for users to compare the original text and the translation, thus improving the user experience.

[0034] In a possible implementation manner, the attribute information of the content to be translated includes relative position information of the content to be translated in the document to be translated.

[0035] The beneficial effect of this implementation method is that the translation results are filled into the target document according to the attribute information of the content to be translated, so that the layout of the target document and the document to be translated can be kept consistent, thereby facilitating users to compare and view the original text and the translation, thereby improving the user experience.

[0036] In a second aspect, an embodiment of the present application further provides an electronic device, the electronic device comprising a processor, the processor being connected to a memory;

[0037] The memory stores computer-executable instructions;

[0038] The processor executes the computer-executable instructions stored in the memory to implement the method as described in any one of the first aspects.

[0039] In a third aspect, an embodiment of the present application further provides a computer program product, including a computer program, which, when executed by a processor, is used to implement a method as described in any one of the first aspects.

[0040] The beneficial effects of the embodiments provided by the second and third aspects are as follows: when the processor executes the document translation method described in any one of the first aspects, it will construct a prompt word set corresponding to the data type, and provide a corresponding processing method for the documents to be translated containing different data types, which is more suitable for the actual translation needs of the user, and can better translate the content to be translated of the corresponding data type, which not only improves the translation effect, but also improves the practicality; in addition, the translation prompt words in the prompt word set are extracted from the translated content, and translation is performed according to the translated content, which can not only maintain the consistency of the context translation style, but also improve the relevance of the context, and further improve the translation effect. BRIEF DESCRIPTION OF THE DRAWINGS

[0041] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the related technologies, the following is a brief introduction to the drawings required for use in the embodiments or the related technical descriptions. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.

[0042] Figure 1 A flowchart of a document translation method provided in an embodiment of the present application;

[0043] Figure 2 A flowchart of another document translation method provided in an embodiment of the present application;

[0044] Figure 3 A schematic diagram of the structure of a document translation device provided in an embodiment of the present application;

[0045] Figure 4 A schematic structural diagram of an electronic device is provided for an embodiment of the present application. DETAILED DESCRIPTION

[0046] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings 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 made by ordinary technicians in this field under the enlightenment of the embodiments belong to the scope of protection of the present application.

[0047] The terms "first", "second", "third", "fourth", etc. (if any) in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0048] First, the terms involved in the embodiments of the present application are explained:

[0049] Large Language Models (LLM): Large language models are very large deep learning models that are pre-trained based on a large amount of data. The underlying transformer of a large language model is a set of neural networks consisting of encoders and decoders with self-attention functions. The encoders and decoders extract meaning from a series of texts and understand the relationship between words and phrases in them to complete the translation.

[0050] Corpus: In linguistics, corpus refers to a large amount of text, which is usually organized and has a certain format and tags. Corpus is used in linguistic research, natural language processing, machine translation and other fields. The establishment and management of corpus is crucial to the development of linguistic research and natural language processing technology, and can help researchers train language models, extract language rules, and analyze and mine text data.

[0051] The embodiment of the present application provides a document translation method. Considering that the document to be translated may include contents to be translated of multiple data types, the embodiment of the present application first determines the data type and attribute information of each content to be translated in the document to be translated, and then constructs a corresponding prompt word set containing keywords extracted from the translated content according to the data type to which each content to be translated belongs, so as to be used for the translation of the content to be translated, and then displays the translation result in the target document based on the attribute information. The embodiment of the present application can adapt to the translation requirements of multiple data types by constructing a prompt word set corresponding to the data type, so as to better translate the contents to be translated of the corresponding data type and improve the translation effect; in addition, the embodiment of the present application also translates the keywords extracted from the translated content to associate the context, thereby increasing the relevance of the context and improving the translation effect.

[0052] The execution subject of the embodiment of the present application may be a document translation device, which may be located on a processor of an electronic device, and the electronic device may be a mobile phone, a tablet, a server, etc., which is not limited by the embodiment of the present application. The embodiment of the present application is described in detail by taking the execution subject as a document translation device as an example.

[0053] The technical solution of the present application and how the technical solution of the present application solves the above-mentioned technical problems are described in detail below with specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below in conjunction with the accompanying drawings.

[0054] Figure 1 A flowchart of a document translation method provided in an embodiment of the present application. Figure 1 As shown, the document translation method provided in the embodiment of the present application may include:

[0055] S101, extracting each content to be translated in the document to be translated, and determining the data type and attribute information of each content to be translated.

[0056] In the embodiment of the present application, the document to be translated is a document that the user needs to translate. It is understandable that in actual scenarios, the document to be translated may include content to be translated in various formats such as text format, table format, and picture format, and the embodiment of the present application does not limit this.

[0057] Among them, the attribute information of the content to be translated is used to indicate the attributes of the content to be translated in the document to be translated. Exemplarily, the attribute information of the content to be translated may include the relative position information of the content to be translated in the document to be translated, wherein the relative position information is used to indicate the coordinates of each content to be translated in the document to be translated. In some other possible embodiments, the attribute information of the content to be translated may also include one or more of the font type, font color, font size, font spacing, line spacing, hyperlink attributes, etc. of the content to be translated in the document to be translated. Optionally, when the data type of the content to be translated is in table format, the attribute information of the content to be translated may also include information such as the overall size of the table, the size of the cell where it is located, and the position of the cell in the table; when the data type of the content to be translated is in picture format, the attribute information of the content to be translated may also include information such as the overall size of the picture, the position of the content to be translated in the picture, etc., which is not limited by the embodiments of the present application.

[0058] Exemplarily, after obtaining the document to be translated, the document translation device needs to identify the document to be translated, so as to extract each content to be translated in the document to be translated, and determine the data type and attribute information of each content to be translated. Among them, the document to be translated obtained by the document translation device may be in other formats such as word, pdf or txt. In order to facilitate processing and analysis, the document to be translated can be converted into editable and processable data through text recognition technology, such as converting the non-editable document to be translated in pdf format into an editable word document, and then extracting each content to be translated according to preset rules. For example, for the content in text format, each content to be translated can be extracted based on punctuation marks, paragraph marks, the distance between each sentence / paragraph, etc., so that the extracted content to be translated may be a sentence, or a paragraph, or a word / phrase, etc. For the content in table format, the cell can be used as a boundary, and the content in each cell is a content to be translated; in addition, since the amount of content in each cell may be different, for each cell, the content in the cell can also be divided based on punctuation marks, paragraph marks, the distance between each sentence / paragraph, etc. For the content in the image format, optical character recognition (OCR) technology can be used to parse and obtain the text data to be translated in the image, and then the corresponding method can be used to extract the content to be translated according to the data type of the text data in the image, which is text or table. According to the above method, each content to be translated in the document to be translated can be extracted. At the same time, natural language processing technology and machine learning algorithms can be used to analyze the content to be translated in the document to be translated, so as to identify the data type of each content to be translated and determine the attribute information of each content to be translated.

[0059] In an embodiment of the present application, a suitable subsequent processing method can be selected according to the data type of the content to be translated. For example, if the data type of the content to be translated is text, the translation processing method corresponding to the text will be used to process the content to be translated. If the data type of the content to be translated is a table, the translation processing method corresponding to the table will be used to process the content to be translated. If the data type of the content to be translated is a picture, the translation processing method corresponding to the picture will be used to process the content to be translated. Different data types have different corresponding subsequent translation processing methods. According to the attribute information of the content to be translated, the attribute information of the translation result of the content to be translated can be determined so as to better display the translation result later.

[0060] S102: construct a prompt word set of the content to be translated according to the data type of the content to be translated.

[0061] The prompt word set includes translation prompt words, which are extracted from the translated content in the document to be translated and used to translate the content to be translated. In the embodiment of the present application, the translation prompt words serve as translation prompts for the content to be translated, which can link the context together and make the translation style of the context consistent, thereby improving the relevance of the context in the translation result and also improving the translation effect.

[0062] Exemplarily, the data types of the content to be translated are different, and the translation prompt words contained in the corresponding prompt word set are also different. In the embodiment of the present application, each prompt word set can be constructed for each content to be translated. According to the data type, the prompt word set containing different translation prompt words is designed to be more suitable for the content translation of the corresponding data type, which can effectively improve the translation effect and better meet the translation needs of the user.

[0063] In a possible implementation, constructing a prompt word set of the content to be translated according to the data type of the content to be translated may include:

[0064] S1. According to the data type of the content to be translated, retrieve translation-related information of the content to be translated from the cache, wherein the translation-related information represents information related to the translation of the content to be translated in the translated content of the document to be translated, and the translation-related information includes words that meet preset conditions.

[0065] S2. Construct a prompt word set for the content to be translated based on the translation-related information.

[0066] Exemplarily, in an embodiment of the present application, the translation results of the translated content can be saved in a cache. In this way, when constructing a prompt word set for the content to be translated, the translation-related information of the content to be translated can be retrieved from the cache based on the data type of the content to be translated, and then the prompt word set for the content to be translated can be constructed based on the translation-related information. This can improve the efficiency of constructing the prompt word set for the content to be translated, thereby improving the overall translation efficiency.

[0067] Optionally, step S1, retrieving translation-related information of the content to be translated from the cache according to the data type of the content to be translated, may include:

[0068] S11, determining the data range of the translation-related information of the content to be translated according to the data type of the content to be translated and the preset mapping relationship, wherein the preset mapping relationship is used to indicate the corresponding relationship between the data type and the data range.

[0069] S12. Retrieve information within the data range from the cache and determine it as translation-related information of the content to be translated.

[0070] Exemplarily, different data types have different corresponding data ranges of translation-related information. That is, the data ranges of translation-related information of different contents to be translated are different, and the data range indicates the amount of data contained in the translation-related information. In the cache, information of all translated contents may be stored. Therefore, when the document translation device obtains translation-related information of the contents to be translated, it can first determine the data range of the translation-related information according to the data type, and then retrieve the information in the cache within the data range to determine it as translation-related information of the contents to be translated. In this way, words that meet the preset conditions can be quickly found.

[0071] Optionally, according to different data types, translation-related information may include one or more of the following information: information of n translated contents adjacent to the content to be translated, document title information, table subject information, picture subject information, etc., located before and / or after the content to be translated in the document to be translated. Wherein, n is an integer greater than or equal to 1. The numerical value of n should not be too large or too small. Information too far from the content to be translated will not be of much help to the translated content, and will also increase the amount of data processed, wasting computing resources, and when there are too few data, it is also possible to find no suitable translation prompt words, therefore, it is necessary to set a suitable n value. In practical applications, different n values ​​can be set for different data types, and the embodiments of the present application are not limited.

[0072] For example, for the content to be translated whose data type is text, it is mainly related to the previous text and document title, so the translation-related information of this type of content to be translated may include the information of the three translated contents that are located before and adjacent to the content to be translated in the document to be translated, as well as the document title information, etc. For example, if the content to be translated is divided into sentences, the translation-related information of a certain sentence of content to be translated may include the three sentences before the sentence of content to be translated, as well as the document title information, etc.

[0073] For the content to be translated whose data type is a table, it is mainly related to information such as the content before and / or after the table and the subject of the table. Therefore, the translation-related information of this type of content to be translated may include information on three translated contents that are located before the table where the content to be translated is located and adjacent to the table in the document to be translated, information on two translated contents that are located after the table where the content to be translated is located and adjacent to the table in the document to be translated, table subject information, etc.

[0074] Optionally, in a possible implementation, if the position of the text information explaining the table in the document can be identified, the text information explaining the table can also be determined as the translation-related information of the content to be translated in the table. For example, if it is determined that the table subject information is located in the first paragraph before the table and the text information explaining the table is located in the first paragraph after the table, it can be determined that the translation-related information of the content to be translated in the table includes the table subject information located before the table and the text information explaining the table located after the table.

[0075] For the content to be translated whose data type is a picture, it is mainly related to information such as the content before and after the picture and the theme of the picture. Therefore, the translation-related information of this type of content to be translated may include information on two translated contents that are located before and adjacent to the picture where the content to be translated is located in the document to be translated, information on three translated contents that are located after and adjacent to the picture where the content to be translated is located in the document to be translated, picture theme information, etc.

[0076] It is understandable that when translating a document to be translated, the translation is generally performed in sequence. Therefore, when the translation-related information includes information that is located after the content to be translated in the document to be translated, the translation-related information that is located after the content to be translated can be translated first and saved in the cache as part of the translation-related information of the content to be translated.

[0077] According to actual needs, for different data types, corresponding translation-related information may also include table attribute information (such as cell size, cell position, etc.), picture attribute information (such as relative position information of pictures, etc.), etc., which are not limited in the embodiments of the present application. Through translation-related information within a suitable range, a more accurate data basis can be provided for constructing a prompt word set, thereby providing a more accurate data basis for subsequent translation to improve translation accuracy.

[0078] Optionally, step S2, constructing a prompt word set of the content to be translated according to the translation-related information, may include:

[0079] S21, parsing translation-related information, and extracting keywords from the translation-related information.

[0080] Among them, the keywords are words that meet the preset conditions in the translation-related information. The embodiments of the present application do not limit the preset conditions. For example, according to the sentence structure, the keywords can be one or more of the noun subject, predicate, object, attributive, adverbial, etc.; in addition, keywords can also be determined according to the frequency of occurrence of each entity word in the document. When the frequency of occurrence is greater than a certain value, it is determined as a keyword, etc. The preset conditions are conditions set according to the characteristics of these keywords.

[0081] S22: Determine the keywords as translation prompt words of the content to be translated, construct a corpus consisting of the original text and the translated text of each translation prompt word, and determine them as a prompt word set of the content to be translated.

[0082] Exemplarily, the embodiment of the present application can use the keywords in the translation-related information related to the translation of the content to be translated in the translated content of the document to be translated as translation prompt words to construct a prompt word set for the content to be translated, so as to prepare for the subsequent translation of the content to be translated. Specifically, the prompt word set can include information such as the original text and translation of each translation prompt word, and the original text and translation of each translation prompt word are set as an associated group according to the translation template. When there are multiple translation prompt words, the prompt word set includes multiple associated groups.

[0083] For example, the translation template can be set to translate "XXX" into "XXX". If the original text of the translation prompt word A is "A" and the translation of the translation prompt word A is "A1", the translation prompt word A can be presented in the prompt word set as: "A" translated into "A1". In other words, the prompt word set of each content to be translated can include multiple translation prompt words in the form of "XXX" translated into "XXX".

[0084] Since the translation-related information of each content to be translated is different, the prompt word sets constructed for each content to be translated are also different, and the translation prompt words in the prompt word set can change dynamically with the change of the translation-related information of the content to be translated.

[0085] Optionally, in a possible implementation, the documents to be translated are some interrelated or relatively professional documents. In some professional fields, some words have corresponding standard translations. Therefore, a standard terminology library can also be pre-built, and some verified and highly accurate terminology words can be pre-set in the standard terminology library to improve the translation accuracy.

[0086] Optionally, when a standard terminology library is pre-built, in a possible implementation, before building a prompt word set for the content to be translated, the document translation device may also first determine whether the text length of the content to be translated is greater than a first preset length threshold. If so, execute the step of building a prompt word set for the content to be translated; if not, translate the content to be translated based on the standard terminology library.

[0087] Exemplarily, when the text length of the content to be translated is greater than a first preset length threshold, the content to be translated can be considered to be a long text, and when the text length of the content to be translated is less than or equal to the first preset length threshold, the content to be translated can be considered to be a word or a phrase. For words and phrases, the standard terminology library can be directly retrieved, and the content to be translated is translated based on the standard terminology library. If there is a corresponding translation result in the standard terminology library, the translation result in the standard terminology library is determined to be the translation result of the word or phrase. If there is no corresponding translation result in the standard terminology library, the MT direct translation model can be used for translation to obtain the translation result. If the content to be translated is a long text, then a prompt word set of the content to be translated can be constructed according to the data type of the content to be translated as in step S102, and then subsequent steps S103 and S104 are executed.

[0088] Before the prompt word set of the content to be translated is generated, as described above, the text length of the content to be translated is first determined. For words and phrases, there is no need to construct corresponding prompt word sets for them. Instead, the standard term library can be directly used for translation, which can improve the overall translation efficiency.

[0089] S103: Determine the translation result of the content to be translated according to the prompt word set of the content to be translated.

[0090] Exemplarily, after constructing the prompt word set of the content to be translated, the document translation apparatus may determine the translation result of the content to be translated according to the prompt word set of the content to be translated.

[0091] Optionally, in a possible implementation, if a corresponding prompt word set is constructed for all contents to be translated, the document translation device may not distinguish the text length of the contents to be translated, and directly input the contents to be translated and the prompt word set of the contents to be translated into a pre-trained language model together. After the language model translates, the translation result of the contents to be translated can be directly output. In this way, the translation result can be quickly obtained. For example, taking the translation of "document translation method and electronic device" as an example, based on this implementation, the text length of the contents to be translated "document translation method and electronic device" may not be distinguished, and the contents to be translated "document translation method and electronic device" and the prompt word set of the contents to be translated may be directly input into the language model together, and the language model directly outputs the translation result. The pre-trained language model can translate the contents to be translated more accurately based on the prompt word set of the contents to be translated, thereby improving the accuracy of the output translation result.

[0092] Optionally, in another possible implementation, if a corresponding prompt word set is constructed only for the long text to be translated, then when the document translation device performs translation, it can first determine whether the text length of the content to be translated is greater than a first preset length threshold. If so, the content to be translated and the prompt word set of the content to be translated are input into a pre-trained language model together, and after translation by the language model, the translation result of the content to be translated is directly output; if not, the standard terminology library is searched, and if the corresponding translation result exists in the standard terminology library, it is determined that the translation result in the standard terminology library is the translation result of the word or phrase. If the corresponding translation result does not exist in the standard terminology library, the MT direct translation small model can be used for translation to obtain the translation result. For example, based on this implementation, to translate "document translation method and electronic device", it is necessary to first determine whether the text length of "document translation method and electronic device" is greater than the first preset length threshold. If it is greater than the first preset length threshold, then directly input "document translation method and electronic device" and the prompt word set corresponding to the content to be translated into the language model for translation; if it is less than or equal to the first preset length threshold, it is necessary to search the standard terminology library, replace the corresponding terminology in the standard terminology library to obtain the translation result, or use the MT direct translation small model to translate to obtain the translation result. Since in this method, there is no need to construct a corresponding prompt word set for words and phrases, the standard terminology library can be used directly for translation, thus improving the overall translation efficiency.

[0093] Optionally, in another possible implementation, if corresponding prompt word sets are constructed for all contents to be translated, determining the translation result of the contents to be translated according to the prompt word sets of the contents to be translated may further include:

[0094] S10. If it is determined that the text length of the content to be translated is less than or equal to the second preset length threshold, then determine the similarity between the content to be translated and each translation prompt word in the prompt word set; if there is a translation prompt word in the prompt word set whose similarity is greater than a preset value, then replace the content to be translated with the translation of the translation prompt word whose similarity is greater than the preset value to obtain a translation result of the content to be translated; if there is no translation prompt word in the prompt word set whose similarity is greater than the preset value, then input the content to be translated into a preset machine translation model for translation to obtain a translation result of the content to be translated.

[0095] S20. If it is determined that the text length of the content to be translated is greater than the second preset length threshold, segmentation processing is performed on the content to be translated to determine the segmentation of the content to be translated, and the similarity between each segmentation and each translation prompt word in the prompt word set is determined. If there is a translation prompt word with a similarity greater than a preset value, the corresponding segmentation in the content to be translated is replaced with the translation of the translation prompt word with a similarity greater than the preset value to obtain the replaced content to be translated, and then the replaced content to be translated is input into a preset machine translation model for translation to obtain a translation result of the content to be translated.

[0096] Exemplarily, in this implementation, the document translation device can first determine the text length of the content to be translated, and determine whether to perform word segmentation according to the text length. If word segmentation is not required, the similarity between the content to be translated and each translation prompt word in the prompt word set is directly calculated. If word segmentation is required, word segmentation is performed first and then the similarity between each word segmentation and each translation prompt word in the prompt word set is calculated. According to the size of the similarity, it is determined whether to perform word replacement. If there is a translation prompt word with a similarity greater than a preset threshold, the translation prompt word is used to replace the word. If it does not exist, it is not replaced, and the replaced content to be translated is input into a preset machine translation model for translation to obtain the translation result of the content to be translated. In this way, the replaced word will not be translated into other translations, which can not only keep the consistency of the context translation style, but also improve the relevance of the context.

[0097] Among them, the similarity between two words can be measured by cosine similarity, Euclidean distance, etc. When determining the similarity between two words, a pre-trained word embedding model (such as Word2Vec, GloVe, FastText, etc.) can be used to represent them as corresponding word embedding vectors, and then the cosine similarity or Euclidean distance is calculated by the word embedding vector to obtain the similarity. The embodiments of the present application are not limited to this.

[0098] The preset machine translation model is a pre-trained machine translation model, which can translate the content to be translated that is all in the source language, and can also translate the content to be translated that is partly in the source language and partly in the target language. In an embodiment of the present application, the words in the content to be translated may be partially replaced or completely replaced by the translation of the translation prompt words in the prompt word set, or may not be replaced at all. When all the words in the content to be translated are replaced, the replaced content to be translated is already all in the target language, which can be directly used as the translation result; and when only part of the words in the content to be translated are replaced, the replaced content to be translated contains both the source language and the target language. At this time, the preset machine translation model is required for re-translation; when the words in the content to be translated are not replaced at all, the preset machine translation model is also required for translation to obtain the translation result.

[0099] For example, taking the content to be translated as "document translation methods and electronic equipment" as an example, to translate it into English, the second preset length threshold of the text length is 4, then it is necessary to first segment the "document translation methods and electronic equipment", for example, it can be divided into "document translation / method / and / electronic equipment", if the prompt word set of the content to be translated includes: "document translation" translated as "document translation", "electronic equipment" translated as "electronic equipments" and other translation prompt words, then after word similarity calculation and word replacement, "document translation methods and electronic equipments" can be obtained, and then "document translation methods and electronic equipments" is input into the preset machine translation model for translation, and the preset machine translation model can output the translation result "Document translation methods and electronic equipments".

[0100] In a possible implementation, in order to facilitate the subsequent retrieval of translation-related information of the content to be translated from the cache and the construction of a prompt word set for the content to be translated, the method of the embodiment of the present application may further include: saving the translation result of the content to be translated in the cache. In this way, when constructing the prompt word set for the content to be translated, the information of the translated content can be directly retrieved from the cache, thereby improving data processing efficiency.

[0101] S104: Displaying the translation results of each content to be translated in the target document according to the attribute information of each content to be translated.

[0102] Exemplarily, after obtaining the translation results of the contents to be translated, the document translation device also needs to perform post-translation processing, and display the translation results of each content to be translated in the target document according to the attribute information of each content to be translated.

[0103] In a possible implementation, displaying the translation result of each content to be translated in the target document according to the attribute information of each content to be translated may include:

[0104] According to the attribute information of the content to be translated, the attribute information of the translation result of the content to be translated is adjusted, and each adjusted translation result is filled into the target document for display, so that the layout of each adjusted translation result in the target document is consistent with the layout of the document to be translated.

[0105] For example, in order to facilitate users to compare and view the content to be translated and the translation results, for each translation result of the content to be translated, the original attribute information of the content to be translated in the document to be translated can be transferred to the translation result of the content to be translated, and certain adjustments are made, and then filled in the target document, so that the layout of the translation results presented in the target document is consistent with the layout of the document to be translated. For example, based on the relative position information, font type, font color, font size, font spacing, line spacing and other attribute information of the content to be translated in the document to be translated, the translation result of the content to be translated can be displayed in the target document with the same attribute information as the content to be translated, so that users can compare and view.

[0106] The document translation method provided by the embodiment of the present application extracts each content to be translated in the document to be translated, and determines the data type and attribute information of each content to be translated; constructs a prompt word set of the content to be translated according to the data type of the content to be translated; determines the translation result of the content to be translated according to the prompt word set of the content to be translated; and displays the translation result of each content to be translated in the target document according to the attribute information of each content to be translated. The embodiment of the present application provides a corresponding processing method for documents to be translated containing different data types by constructing a prompt word set corresponding to the data type, which is more suitable for the actual translation needs of the user, and can better translate the content to be translated of the corresponding data type, which not only improves the translation accuracy, but also improves the practicality; in addition, the translation prompt words in the prompt word set in the embodiment of the present application are extracted from the translated content, and the translation is performed according to the translated content, which can not only keep the consistency of the context translation style, but also improve the context relevance of the translation result, and further improve the translation effect.

[0107] For example, Figure 2 A flowchart of another document translation method provided in an embodiment of the present application is shown below. Figure 2 As shown, the document translation method provided in this embodiment may include:

[0108] S201, acquiring and identifying documents to be translated, extracting each content to be translated, and determining the data type and attribute information of each content to be translated.

[0109] S202: Determine whether the text length of the content to be translated is greater than a first preset length threshold.

[0110] If yes, then execute step S2021 or S2022 or S2023 according to the data type of the content to be translated; if no, execute step S205.

[0111] Among them, step S202 and the following steps S205 to S207 are optional steps.

[0112] S2021. If the data type of the content to be translated is text, then based on the data range corresponding to the text, corresponding translation-related information is retrieved from the cache.

[0113] S2022: If the data type of the content to be translated is a table, then based on a data range corresponding to the table, corresponding translation-related information is retrieved from the cache.

[0114] S2023: If the data type of the content to be translated is a picture, then based on the data range corresponding to the picture, corresponding translation related information is retrieved from the cache.

[0115] S203, parsing the translation-related information, extracting keywords from the translation-related information as translation prompt words, and constructing a prompt word set.

[0116] S204: Input the content to be translated and the prompt word set of the content to be translated into a pre-trained language model for translation to obtain a translation result.

[0117] S205: calling a standard terminology database to determine whether the similarity between the content to be translated and each term in the standard terminology database is greater than a preset threshold.

[0118] If yes, execute S206; if no, execute S207.

[0119] S206: Perform word replacement to obtain a translation result.

[0120] S207, calling the MT direct translation small model to translate and obtain the translation result.

[0121] S208: Store the translation result in a cache.

[0122] S209: Post-process the translation result according to the attribute information to display the translation result in the target document.

[0123] It should be noted that the specific implementation process of the above steps can refer to the description of the previous embodiment and will not be repeated here.

[0124] It can be understood that the document translation method of the embodiment of the present application can be integrated into an overall large language model, and the large language model completes the document translation based on the logic of all the above steps S201 to S209. When the large language model translates the document based on the above document translation process, it can not only maintain the consistency of the context translation style, but also improve the context relevance of the translation result, and obtain better translation effect.

[0125] In addition, each step in the document translation method of the embodiment of the present application can also be completed separately by multiple different functional components, for example, step S201 can be executed by a tool with recognition and parsing functions, steps S2021, S2022, S2023 and S203 can be executed by a tool with prompt word construction function, step S204 can be executed by a language model, steps S202, S205~S206, S208~S209 can be executed by a text processing tool, and step S207 can be executed by a MT direct translation small model; of course, it can also be configured to be performed by other components respectively, and the embodiment of the present application does not limit this. By executing the above-mentioned document translation process separately by different components, the data processing pressure of a single component can be reduced, thereby increasing the data processing speed, while still being able to achieve the consistency of the contextual translation style, and improving the contextual relevance of the translation result and the demand for translation effect.

[0126] The following is an embodiment of the device of the present application, which can be used to execute the embodiment of the method of the present application. For details not disclosed in the embodiment of the device of the present application, please refer to the embodiment of the method of the present application.

[0127] Figure 3 A schematic diagram of the structure of a document translation device provided in an embodiment of the present application. Figure 3 As shown, the document translation device 30 provided in the embodiment of the present application includes a pre-processing unit 301, a construction unit 302, a translation unit 303 and a post-processing unit 304.

[0128] The preprocessing unit 301 is used to extract each content to be translated in the document to be translated, and determine the data type and attribute information of each content to be translated; wherein the attribute information is used to indicate the attribute of the content to be translated in the document to be translated.

[0129] The construction unit 302 is used to construct a prompt word set of the content to be translated according to the data type of the content to be translated; wherein the prompt word set includes translation prompt words, which are extracted from the translated content in the document to be translated and used to translate the content to be translated.

[0130] The translation unit 303 is used to determine the translation result of the content to be translated according to the prompt word set of the content to be translated.

[0131] The post-processing unit 304 is used to display the translation result of each content to be translated in the target document according to the attribute information of each content to be translated.

[0132] In one implementation, the construction unit 302 is specifically configured to:

[0133] According to the data type of the content to be translated, the translation-related information of the content to be translated is retrieved from the cache; wherein the translation-related information represents the information related to the translation of the content to be translated in the translated content of the document to be translated, and the translation-related information includes words that meet the preset conditions;

[0134] According to the translation-related information, a prompt word set of the content to be translated is constructed.

[0135] In one implementation, the construction unit 302 is further configured to:

[0136] Determine the data range of the translation-related information of the content to be translated according to the data type of the content to be translated and the preset mapping relationship; wherein the preset mapping relationship is used to indicate the correspondence between the data type and the data range;

[0137] Information within the data range is retrieved from the cache and determined to be translation-related information of the content to be translated.

[0138] In one implementation, the construction unit 302 is further configured to:

[0139] Parsing translation-related information and extracting keywords from the translation-related information; wherein keywords are words in the translation-related information that meet preset conditions;

[0140] The keywords are determined as translation prompt words of the content to be translated, a corpus consisting of the original text and the translated text of each translation prompt word is constructed, and the prompt word set of the content to be translated is determined.

[0141] In one implementation, the translation-related information includes one or more of the following information: information about n translated contents that are located before and / or after the content to be translated and adjacent to the content to be translated in the document to be translated, document title information, table subject information, and image subject information; wherein n is an integer greater than or equal to 1.

[0142] In one implementation, the preprocessing unit 301 is further configured to:

[0143] Before constructing the prompt word set of the content to be translated, it is determined whether the text length of the content to be translated is greater than a first preset length threshold. If so, the construction unit 302 is controlled to execute the step of constructing the prompt word set of the content to be translated; if not, the translation unit 303 is controlled to translate the content to be translated based on the standard term library.

[0144] In one implementation, the translation unit 303 is further configured to:

[0145] After the translation result of the content to be translated is determined, the translation result of the content to be translated is saved in a cache.

[0146] In one implementation, the post-processing unit 304 is specifically configured to:

[0147] According to the attribute information of the content to be translated, the attribute information of the translation result of the content to be translated is adjusted, and each adjusted translation result is filled into the target document for display, so that the layout of each adjusted translation result in the target document is consistent with the layout of the document to be translated.

[0148] In one implementation, the attribute information of the content to be translated includes relative position information of the content to be translated in the document to be translated.

[0149] The device provided in this embodiment can be used to execute the method of the above embodiment. Its implementation principle and technical effect are similar and will not be described in detail here.

[0150] It should be noted that it should be understood that the division of the various modules of the above device is only a division of logical functions. In actual implementation, they can be fully or partially integrated into one physical entity, or they can be physically separated. And these modules can all be implemented in the form of software called by processing elements; they can also be all implemented in the form of hardware; some modules can also be implemented in the form of software called by processing elements, and some modules can be implemented in the form of hardware. In addition, it can also be stored in the memory of the above device in the form of program code, and the functions of the above data processing modules can be called and executed by a processing element of the above device. The implementation of other modules is similar. In addition, all or part of these modules can be integrated together, or they can be implemented independently. The processing element here can be an integrated circuit with signal processing capabilities. In the implementation process, each step of the above method or each module above can be completed by an integrated logic circuit of hardware in the processor element or instructions in the form of software.

[0151] Figure 4 A schematic diagram of the structure of an electronic device is provided in an embodiment of the present application. Figure 4As shown, the electronic device 40 includes a processor 401, and the processor 401 is connected to a memory 402. The electronic device can be a server, a computer, a notebook, a desktop computer, a mobile phone, or other electronic devices with translation capabilities.

[0152] The memory 402 is used to store computer-executable instructions. The memory 402 may include a high-speed RAM memory, and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory.

[0153] The processor 401 is used to execute the computer-executable instructions stored in the memory 402 to implement the network configuration method described in the aforementioned method embodiment. The processor 401 may be a central processing unit (CPU), or an application specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of the present application.

[0154] The electronic device 40 may further include a communication interface 403, so as to communicate and interact with an external device through the communication interface 403. The external device may be, for example, a server or other electronic devices.

[0155] In specific implementation, if the communication interface 403, the memory 402 and the processor 401 are implemented independently, the communication interface 403, the memory 402 and the processor 401 can be connected to each other through a bus and communicate with each other. The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc., but it does not mean that there is only one bus or one type of bus.

[0156] Optionally, in a specific implementation, if the communication interface 403, the memory 402 and the processor 401 are integrated on a chip, the communication interface 403, the memory 402 and the processor 401 can communicate through an internal interface.

[0157] The electronic device provided in this embodiment can execute the document translation method in the above method embodiment, and its beneficial effects are similar, which will not be described in detail here.

[0158] An embodiment of the present application also provides a computer-readable storage medium, in which computer-executable instructions are stored. When the computer-executable instructions are executed by a processor, they are used to implement the document translation method provided by any of the aforementioned method embodiments.

[0159] The embodiment of the present application also provides a computer program product, including a computer program, which is used to implement the document translation method provided by the aforementioned method embodiment when the computer program is executed by a processor.

[0160] Those skilled in the art can understand that all or part of the steps of implementing the above-mentioned method embodiments can be completed by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, the steps of the above-mentioned method embodiments are executed; and the aforementioned storage medium includes: ROM, RAM, disk or optical disk and other media that can store program codes.

[0161] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the embodiments of the present application, rather than to limit them. Although the embodiments of the present application have been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein by equivalents. These modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present application.

Claims

1. A document translation method, characterized in that: The method comprises: Extracting each content to be translated in the document to be translated, and determining the data type and attribute information of each content to be translated; wherein the attribute information is used to indicate the attribute of the content to be translated in the document to be translated; According to the data type of the content to be translated, a prompt word set of the content to be translated is constructed; wherein the prompt word set includes translation prompt words, and the translation prompt words are extracted from the translated content in the document to be translated and are used to translate the content to be translated; Determine the translation result of the content to be translated according to the prompt word set of the content to be translated; The translation results of each content to be translated are displayed in the target document according to the attribute information of each content to be translated.

2. The method according to claim 1, characterized in that According to the data type of the content to be translated, a prompt word set of the content to be translated is constructed, including: According to the data type of the content to be translated, retrieve translation-related information of the content to be translated from the cache; wherein the translation-related information represents information related to the translation of the content to be translated in the translated content of the document to be translated, and the translation-related information includes words that meet preset conditions; A prompt word set of the content to be translated is constructed according to the translation-related information.

3. The method according to claim 2, characterized in that According to the data type of the content to be translated, the translation-related information of the content to be translated is retrieved from the cache, including: Determine the data range of the translation-related information of the content to be translated according to the data type of the content to be translated and the preset mapping relationship; wherein the preset mapping relationship is used to indicate the corresponding relationship between the data type and the data range; Information within the data range is retrieved from the cache and determined to be translation-related information of the content to be translated.

4. The method according to claim 2, characterized in that: Constructing a prompt word set of the content to be translated according to the translation related information, including: Parsing the translation-related information and extracting keywords from the translation-related information; wherein the keywords are words in the translation-related information that meet the preset conditions; The keyword is determined as a translation prompt word of the content to be translated, and a corpus consisting of the original text and the translation of each translation prompt word is constructed to be determined as a prompt word set of the content to be translated.

5. The method according to claim 2, characterized in that: The translation-related information includes one or more of the following information: information of n translated contents that are located before and / or after the content to be translated and adjacent to the content to be translated in the document to be translated, document title information, table subject information, and picture subject information; wherein n is an integer greater than or equal to 1.

6. The method according to any one of claims 1 to 5, characterized in that Before constructing the prompt word set of the content to be translated, the method further includes: It is determined whether the text length of the content to be translated is greater than a first preset length threshold. If so, a step of constructing a prompt word set of the content to be translated is executed; if not, the content to be translated is translated based on a standard term library.

7. The method according to any one of claims 1 to 5, characterized in that After determining the translation result of the content to be translated, the method further includes: The translation results of the content to be translated are saved in the cache.

8. The method according to any one of claims 1 to 5, characterized in that According to the attribute information of each content to be translated, the translation results of each content to be translated are displayed in the target document, including: According to the attribute information of the content to be translated, the attribute information of the translation result of the content to be translated is adjusted, and each adjusted translation result is filled into the target document for display, so that the layout of each adjusted translation result in the target document is consistent with the layout of the document to be translated.

9. The method according to claim 8, characterized in that The attribute information of the content to be translated includes relative position information of the content to be translated in the document to be translated.

10. An electronic device, characterized in that: The electronic device comprises a processor, and the processor is connected to a memory; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory to implement the method according to any one of claims 1 to 9.

Citation Information

Cited By

  • Content generation method and related equipment

    CN121479080A