Document translation method and device, electronic equipment and computer program product

By identifying and utilizing the document's layout structure information for document block translation and rendering, the problem of unsatisfactory translation results caused by the lack of semantic structure in HTML text blocks in existing technologies is solved, achieving semantic integrity and layout consistency in the translated document.

CN121960518APending Publication Date: 2026-05-01ALIBABA CLOUD COMPUTING CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
ALIBABA CLOUD COMPUTING CO LTD
Filing Date
2024-10-31
Publication Date
2026-05-01

AI Technical Summary

Technical Problem

Existing document translation plugins cannot effectively utilize the complete semantic structure of HTML text blocks, resulting in unsatisfactory translation results.

Method used

By identifying the layout structure of the document to be translated, document blocks are determined, and their position and size information are obtained. Based on this information, the text under the document blocks is translated, and the text is rendered and arranged according to the size information of the document blocks to ensure that the translation results remain consistent within the original position and size.

Benefits of technology

The translated documents achieved semantic integrity and consistent layout structure, thus improving the translation quality.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121960518A_ABST
    Figure CN121960518A_ABST
Patent Text Reader

Abstract

The invention discloses a document translation method and device, electronic equipment and a computer program product. The method comprises the following steps: identifying a layout structure of a to-be-translated document, and determining a document block based on the layout structure; obtaining position information and size information of different document blocks and characters in the document blocks; translating characters under different document blocks to obtain translation results; rendering the translation results of the different document blocks based on the size information of the corresponding document blocks to obtain rendering results of the document blocks; and respectively arranging the rendering results of different document blocks in areas indicated by the position information and the size information of the corresponding document blocks to obtain a translated document. According to the document translation method and device, the technical problem that the document translation effect is not ideal due to the fact that the HTML character blocks do not have complete semantic structures when a translation plug-in translates the text in each HTML character block in the document in the related technology is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of text processing technology, and more specifically, to a document translation method, apparatus, electronic device, and computer program product. Background Technology

[0002] With the development of globalization, more and more electronic documents need to be translated into multiple languages. In order to meet the needs of document translation, document editing and management tools in related technologies provide document translation functions.

[0003] While some document editing and management tools can perform translations, they lack translation plugins. For example, PDFescape (a browser-based PDF editing and form filling tool) and PDFtk (a PDF editing and management tool) require manual text input for translation, which is time-consuming and laborious. Furthermore, the translation results are plain text without document structure, resulting in less than ideal translation quality.

[0004] To achieve automatic translation, some document editing and management tools offer translation plugins, such as Adobe Acrobat, Nitro Pro, and Foxit PhantomPDF. These plugins directly recognize HTML (Hypertext Markup Language) text blocks and translate the text of each HTML text block. However, these plugins group texts that are close in position together to form HTML text blocks. HTML text blocks may not have a complete semantic structure. For example, they may separate a two-line heading into two HTML text blocks, or they may group body text that is laid out in two columns into one HTML text block, resulting in an incorrect translation order and poor translation quality.

[0005] There is currently no effective solution to the above problems. Summary of the Invention

[0006] This application provides a document translation method, apparatus, electronic device, and computer program product to at least solve the technical problem in related technologies where translation plugins translate the text in each HTML text block of a document, resulting in unsatisfactory document translation effects because HTML text blocks lack a complete semantic structure.

[0007] According to one aspect of the embodiments of this application, a document translation method is provided, comprising: identifying the layout structure of the document to be translated; determining document blocks based on the layout structure; obtaining position information, size information, and text in different document blocks; translating the text in different document blocks to obtain translation results; rendering the translation results of different document blocks based on the size information of the corresponding document blocks to obtain rendering results of the document blocks; and arranging the rendering results of different document blocks in the areas indicated by the position information and size information of the corresponding document blocks to obtain the translated document.

[0008] Optionally, identifying the layout structure of the document to be translated includes: inputting the document to be translated into an object detection model and processing it to obtain the layout structure of the document to be translated, wherein the object detection model is trained on sample documents, and the sample documents are marked with layout structures, and the marked layout structures include at least one of the following: document blocks, tables, and images, and the document blocks include at least one of the following: titles, body text, headers, and footers.

[0009] Optionally, the translation results of different document blocks are rendered based on the size information of the corresponding document blocks, and the rendering results include: for the target document block, determining the number of words in the translation result of the target document block, wherein the target document block is a document block among different document blocks; determining the font size of the translation result based on the size information of the target document block and the number of words in the translation result; arranging the translation results according to the font size of the translation result and the size information of the target document block, and rendering the arranged translation result.

[0010] Optionally, the rendered translation result includes: determining the font in the target document block as the font of the translation result, or determining the preset font in the language of the translation result as the font of the translation result; determining the text color in the target document block as the text color of the translation result, or determining the preset color as the text color of the translation result; and rendering the translation result based on the font and text color.

[0011] Optionally, if the layout structure also includes at least one of tables and images, arranging the rendering results of different document blocks in the areas indicated by the position and size information of the corresponding document blocks to obtain the translated document includes: arranging images in the original area where the images are located; translating tables to obtain the translation results of the tables, rendering the translation results of the tables, and arranging the rendered results of the tables in the areas indicated by the corresponding tables; and determining the translated document based on the arrangement results of the rendering results of the document blocks, the arrangement results of the images, and / or the arrangement results of the rendering results of the tables.

[0012] Optionally, translating text in different document blocks to obtain translation results includes: determining the domain of the document to be translated and determining the translation dictionary for that domain; inputting the translation dictionary as prompt information into the large language translation model; and, based on the large language translation model, performing the steps of translating text in different document blocks to obtain translation results.

[0013] Optionally, before inputting the translation dictionary as prompt information into the large language translation model, the method further includes: upon receiving hot words in the domain input by the user and their translation results, adding the hot words and their translation results to the translation dictionary to obtain an updated translation dictionary.

[0014] According to another aspect of the embodiments of this application, a document translation method is also provided, comprising: a cloud server receiving a document to be translated input by a client; the cloud server identifying the layout structure of the document to be translated, determining document blocks based on the layout structure, obtaining position information, size information, and text in different document blocks, translating the text under different document blocks to obtain translation results, rendering the translation results of different document blocks based on the size information of the corresponding document blocks to obtain rendering results of the document blocks, arranging the rendering results of different document blocks in the areas indicated by the position information and size information of the corresponding document blocks to obtain the translated document; and the cloud server sending the translated document to the client.

[0015] According to another aspect of the embodiments of this application, a document translation apparatus is also provided, comprising: an identification unit for identifying the layout structure of a document to be translated and determining document blocks based on the layout structure; an acquisition unit for acquiring position information, size information, and text in different document blocks; a translation unit for translating the text under different document blocks to obtain translation results; a rendering unit for rendering the translation results of different document blocks based on the size information of the corresponding document blocks to obtain rendering results of the document blocks; and a layout unit for arranging the rendering results of different document blocks in the areas indicated by the position information and size information of the corresponding document blocks to obtain the translated document.

[0016] According to another aspect of the embodiments of this application, an electronic device is also provided, including: a memory storing an executable program; and a processor for running the program, wherein the program executes the methods in various embodiments of this application when it runs.

[0017] According to another aspect of the embodiments of this application, a computer-readable storage medium is also provided, the computer-readable storage medium including a stored executable program, wherein, when the executable program is running, it controls the device where the computer-readable storage medium is located to perform the methods of various embodiments of this application.

[0018] According to another aspect of the embodiments of this application, a computer program product is also provided, including a non-volatile computer-readable storage medium storing a computer program, which, when executed by a processor, implements the methods in various embodiments of this application.

[0019] In this embodiment, the layout structure of the document to be translated is identified, document blocks are determined based on the layout structure, and the position information, size information, and text within different document blocks are obtained. The text in different document blocks is translated to obtain translation results. Based on the size information of the corresponding document blocks, the translation results of different document blocks are rendered to obtain rendering results of the document blocks. The rendering results of different document blocks are arranged in the areas indicated by the position and size information of the corresponding document blocks to obtain the translated document. By parsing the layout structure of the document to be translated, document blocks with complete semantic structure are determined, and each document block is translated to ensure that the translated document block is semantically complete. The translation results are then rendered in the original position of the document block, making the document layout structure consistent with that before translation. This achieves the technical effect of semantically complete translated document and consistent document layout structure, thereby solving the technical problem in related technologies where translation plugins translate the text in each HTML text block of a document, resulting in unsatisfactory document translation effects because HTML text blocks do not have complete semantic structures.

[0020] It is worth noting that the general description above and the detailed description that follow are merely for illustrative purposes and do not constitute a limitation on this application. Attached Figure Description

[0021] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings:

[0022] Figure 1 A hardware structure block diagram of a computer terminal (or mobile device) for implementing a document translation method is shown.

[0023] Figure 2 This is a structural block diagram of a computing environment according to an embodiment of this application;

[0024] Figure 3 This is a flowchart of a document translation method according to an embodiment of this application;

[0025] Figure 4 This is a schematic diagram of the document to be translated according to an embodiment of this application;

[0026] Figure 5 This is a flowchart of an optional document translation method according to an embodiment of this application;

[0027] Figure 6 This is a flowchart of another document translation method according to an embodiment of this application;

[0028] Figure 7 This is a structural block diagram of a document translation device according to an embodiment of this application;

[0029] Figure 8 This is a structural block diagram of an electronic device according to an embodiment of this application. Detailed Implementation

[0030] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort should fall within the scope of protection of the present application.

[0031] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0032] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties. Furthermore, the collection, use and processing of the relevant data must comply with the relevant laws, regulations and standards of the relevant countries and regions, and corresponding operation portals are provided for users to choose to authorize or refuse.

[0033] Example 1

[0034] According to an embodiment of this application, a document translation method is provided. It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Furthermore, although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in a different order than that shown here.

[0035] The method embodiment provided in Embodiment 1 of this application can be executed on a mobile terminal, computer terminal, or similar computing device. Figure 1 A hardware block diagram of a computer terminal (or mobile device) for implementing a document translation method is shown. Figure 1 As shown, computer terminal 10 (or mobile device) may include one or more ( Figure 1 (Illustrated using 102a, 102b, ..., 102n) Processor 102 (processor 102 may include, but is not limited to, a microprocessor MCU (Microcontroller Unit) or a programmable logic device FPGA (Field Programmable Gate Array), etc.), memory 104 for storing data, and transmission module 106 for communication functions. In addition, it may include: a display, input / output interface (I / O interface), Universal Serial Bus (USB) port (which may be included as one of the ports of a BUS bus), network interface, power supply, and / or camera. Those skilled in the art will understand that... Figure 1 The structure shown is for illustrative purposes only and does not limit the structure of the aforementioned electronic device. For example, computer terminal 10 may also include... Figure 1 The more or fewer components shown, or having the same Figure 1 The different configurations shown.

[0036] It should be noted that the aforementioned one or more processors 102 and / or other data processing circuits are generally referred to herein as "data processing circuits". These data processing circuits may be embodied, in whole or in part, in software, hardware, firmware, or any other combination thereof. Furthermore, the data processing circuits may be a single, independent processing module, or may be integrated, in whole or in part, into any other element within the computer terminal 10 (or mobile device). As involved in the embodiments of this application, the data processing circuits serve as a processor control mechanism (e.g., selection of a variable resistor termination path connected to an interface).

[0037] The memory 104 can be used to store software programs and modules of application software, such as the program instructions / data storage device corresponding to the method in the embodiments of this application. The processor 102 executes various functional applications and data processing by running the software programs and modules stored in the memory 104, thereby implementing the method in the above embodiments. The memory 104 may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include memory remotely located relative to the processor 102, and these remote memories can be connected to the computer terminal 10 via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.

[0038] The transmission device 106 is used to receive or send data via a network. Specific examples of the network described above may include a wireless network provided by the communication provider of the computer terminal 10. In one example, the transmission device 106 includes a Network Interface Controller (NIC), which can connect to other network devices via a base station to communicate with the Internet. In another example, the transmission device 106 may be a Radio Frequency (RF) module, used for wireless communication with the Internet.

[0039] The display can be, for example, a touchscreen liquid crystal display (LCD), which allows the user to interact with the user interface of the computer terminal 10 (or mobile device).

[0040] Figure 1 The hardware structure block diagram shown can serve not only as an exemplary block diagram of the aforementioned computer terminal 10 (or mobile device), but also as an exemplary block diagram of the aforementioned server. In one optional embodiment, Figure 2 The use of the above is illustrated in a block diagram. Figure 1 The computer terminal 10 (or mobile device) shown is an embodiment of a computing node in computing environment 201. Figure 2 This is a structural block diagram of a computing environment according to an embodiment of this application, such as... Figure 2 As shown, the computing environment 201 includes multiple ( ) running on a distributed network. Figure 2The compute nodes (such as servers) are represented by 210-1, 210-2, ..., . Each compute node contains local processing and memory resources, and end user 202 can remotely run applications or store data within the compute environment 201. Applications can be provided as multiple services 220-1, 220-2, 220-3, and 220-4 within the compute environment 201, representing services "A", "D", "E", and "H", respectively.

[0041] End user 202 can provide and access services through a web browser or other software application on a client. In some embodiments, the provisioning and / or requests of end user 202 can be provided to ingress gateway 230. Ingress gateway 230 may include a corresponding agent to handle the provisioning and / or requests for services (one or more services provided in computing environment 201).

[0042] The services are provided or deployed based on various virtualization technologies supported by the computing environment 201. In some embodiments, services may be provided based on virtual machine (VM)-based virtualization, container-based virtualization, and / or similar methods. VM-based virtualization can simulate a real computer by initializing a virtual machine, executing programs and applications without directly accessing any actual hardware resources. While the machine is virtualized by a virtual machine, container-based virtualization can launch containers to virtualize an entire operating system (OS), allowing multiple workloads to run on a single OS instance.

[0043] In one embodiment based on container virtualization, several containers of a service can be assembled into a Pod (e.g., a Kubernetes Pod). For example, such as Figure 2 As shown, service 220-2 can be equipped with one or more Pods 240-1, 240-2, ..., 240-N (collectively referred to as Pods). A Pod can include a proxy 245 and one or more containers 242-1, 242-2, ..., 242-M (collectively referred to as containers). One or more containers within a Pod handle requests related to one or more corresponding functions of the service. Proxy 245 typically controls service-related network functions such as routing and load balancing. Other services can also be equipped with similar Pods.

[0044] During operation, executing a user request from end user 202 may require invoking one or more services in computing environment 201, and executing one or more functions of one service may require invoking one or more functions of another service. For example... Figure 2As shown, service "A" 220-1 receives user requests from terminal user 202 from ingress gateway 230. Service "A" 220-1 can call service "D" 220-2, and service "D" 220-2 can request service "E" 220-3 to perform one or more functions.

[0045] The aforementioned computing environment can be a cloud computing environment, where resource allocation is managed by cloud services, allowing functionality development without needing to consider implementation, adjustment, or server scaling. This computing environment allows developers to execute event-responsive code without building or maintaining complex infrastructure. Services can be partitioned into a set of functions that can automatically and independently scale, rather than scaling a single hardware device to handle potential loads.

[0046] In document translation scenarios, when translating electronic documents, if the text of each HTML text block in the document is translated directly, although the translated document will retain its formatting compared to plain text translation, the translation effect will be poor because the document's layout structure is not taken into account during the translation process.

[0047] This application analyzes the layout structure of the document to be translated, identifies document blocks with complete semantic structure, translates each document block, and renders it to its original position. On the one hand, the translated document blocks are semantically complete; on the other hand, the layout structure of the translated document is consistent with that of the original document, resulting in better translation quality.

[0048] In the above scenarios, this application provides the following: Figure 3 The document translation method shown. Figure 3 This is a flowchart of a document translation method according to an embodiment of this application, such as... Figure 3 As shown, the method includes:

[0049] Step S32: Identify the layout structure of the document to be translated and determine document blocks based on the layout structure.

[0050] The document to be translated can be an electronic document, such as a PDF (Portable Document Format) document.

[0051] In this embodiment, in order to ensure that the appearance and content of the translated document are consistent with the original document, the typesetting habits and format requirements of different languages ​​need to be considered during the translation process. Therefore, the layout structure of the document to be translated is first identified. The layout structure refers to the typesetting and layout of the document. The layout structure can be represented by multiple components in the document and the position and size information of the components. The components may include document blocks, tables, pictures, etc.

[0052] For example, the layout structure of the document to be translated can be identified using image detection methods. Different components of the identified layout structure are marked with detection boxes, and document blocks are determined from the content marked by the detection boxes. Document blocks may include titles, body text, headers, footers, etc., and titles may include article titles and chapter titles. Figure 4 This is a schematic diagram of the document to be translated according to an embodiment of this application, such as... Figure 4 As shown, it can identify sidebars, article titles, chapter titles, body text, images, and tables from the document to be translated.

[0053] Step S34: Obtain the position information, size information, and text in different document blocks.

[0054] Among them, the image detection method identifies document blocks and marks them with detection boxes. The detection boxes can be rectangles, and the text in the detection boxes is the text in the document blocks.

[0055] The location information of a document block refers to the position of the document block within the document. The coordinates of the four points of the rectangular detection box can represent the location information of the document block within the document.

[0056] The size information of a document block refers to its length and width. The length and width of the document block can be determined based on the coordinates of the four points of the rectangular detection box.

[0057] After identifying the location information of the document block, the text region containing the document block is located. The text region is then preprocessed, including denoising and binarization, converting it to black and white to facilitate the distinction between text and background. Next, character segmentation is performed, dividing the text region into individual characters based on the spacing and connectivity features between characters. After obtaining the characters, feature extraction is performed on each character. Character features can be extracted using convolutional neural networks, recurrent neural networks, and long short-term memory networks. Then, a pre-trained classification model can be used to identify the text corresponding to the character features.

[0058] Step S36: Translate the text under different document blocks to obtain the translation results.

[0059] For example, all document blocks are first sorted according to their positions within the document to be translated, resulting in a document block sequence. Each document block in the sequence is associated with both position and size information. Then, the text within each document block in the sequence is translated sequentially, yielding multiple translation results. For instance, when generating the document block sequence, all document blocks can be sorted in descending order of the distance between the top of the detection box and the top of the document page to be translated, resulting in the document block sequence.

[0060] Step S38: Render the translation results of different document blocks based on the size information of the corresponding document blocks to obtain the rendering results of the document blocks.

[0061] It should be noted that different languages ​​may use different numbers of words to describe the same content. When rendering the translation results of a document block, the size information associated with the document block corresponding to the translation result is determined, and the font size of the translation result is adjusted according to the size information of the document block so that the translation result is located within the area indicated by the size information of the document block after rendering.

[0062] For example, for a target document block, if the number of characters in the translation result is greater than the number of characters in the target document block, the font size of the translation result can be reduced so that the rendered translation result does not exceed the area indicated by the size information of the target document block. If the number of characters in the translation result is less than the number of characters in the target document block, the font size of the translation result can be enlarged so that the rendered translation result can be reasonably arranged within the area indicated by the size information of the target document block, without exceeding the area boundary or having excessive white space.

[0063] Step S310: Arrange the rendering results of different document blocks in the areas indicated by the position and size information of the corresponding document blocks to obtain the translated document.

[0064] Determine the position and size information of the document block associated with the translation result. Based on the position and size information of the document block, determine the specific area of ​​the translation result in the document to be translated, which is also the original area of ​​the document block. Arrange the translation result in the original area of ​​the document block so that the translated document and the original document have the same layout structure.

[0065] In this embodiment, the layout structure of the document to be translated is identified, document blocks are determined based on the layout structure, and the position information, size information, and text within different document blocks are obtained. The text in different document blocks is translated to obtain translation results. Based on the size information of the corresponding document blocks, the translation results of different document blocks are rendered to obtain rendering results of the document blocks. The rendering results of different document blocks are arranged in the areas indicated by the position and size information of the corresponding document blocks to obtain the translated document. By parsing the layout structure of the document to be translated, document blocks with complete semantic structure are determined, and each document block is translated to ensure that the translated document block is semantically complete. The translation results are then rendered in the original position of the document block, making the document layout structure consistent with that before translation. This achieves the technical effect of semantically complete translated document and consistent document layout structure, thereby solving the technical problem in related technologies where translation plugins translate the text in each HTML text block of a document, resulting in unsatisfactory document translation effects because HTML text blocks do not have complete semantic structures.

[0066] The layout structure of a document to be translated can be identified using an object detection model. Optionally, in the document translation method of this application embodiment, identifying the layout structure of the document to be translated includes: inputting the document to be translated into an object detection model and processing it to obtain the layout structure of the document to be translated. The object detection model is trained on sample documents, and the sample documents are marked with layout structures. The marked layout structures include at least one of the following: document blocks, tables, and images. The document blocks include at least one of the following: titles, body text, headers, and footers.

[0067] For example, multiple documents can be collected, and the layout structure of each document can be tagged to obtain tagged documents. Multiple tagged documents constitute a sample document dataset.

[0068] For example, when the sample document is a PDF, a detection box is marked on the layout structure of each page of the PDF document. For example, a detection box is marked on the document title to indicate that it is a title, a detection box is marked on the abstract title to indicate that it is an abstract title, a detection box is marked on the abstract body to indicate that it is the abstract body, a detection box is marked on the table to indicate that it is a table, and a detection box is marked on the image to indicate that it is an image.

[0069] Furthermore, an initial model is trained based on the sample document dataset to obtain an object detection model. This initial model can be a deep learning model, such as CNN (Convolutional Neural Network), SSD (Single Shot MultiBox Detector), or RetinaNet. It can also be a machine learning model, such as SVM (Support Vector Machine). The object detection model can identify the layout structure of the document to be translated, obtaining multiple components within the document and their location and size information.

[0070] This embodiment trains an object detection model using sample documents labeled with page layout structure. The object detection model accurately and efficiently identifies the page layout structure of the document to be translated, laying the foundation for determining document blocks from the page layout structure of the document to be translated.

[0071] Different languages ​​may use different word counts for the same content. To ensure that the structure of the same document block remains consistent before and after translation, optionally, in the document translation method of this application embodiment, the translation results of different document blocks are rendered based on the size information of the corresponding document blocks. The rendering results include: for the target document block, determining the word count of the translation result of the target document block, wherein the target document block is one of the different document blocks; determining the font size of the translation result based on the size information of the target document block and the word count of the translation result; arranging the translation results according to the font size of the translation result and the size information of the target document block, and rendering the arranged translation result.

[0072] For example, the target document block can be any document block with a complete semantic structure in the document to be translated. For instance, the target document block could be the document block containing the title. The title is translated from Chinese to English. After translation, the number of characters in the English translation is counted, and the size of the detection box containing the title is obtained. The font size of the translated result is calculated proportionally based on the number of characters and the size of the detection box. The translated result is then filled into the detection box according to the determined font size. During the filling process, the characters in the translated result can be traversed, arranging the first row from left to right. When the length of a row reaches the width of the detection box, a line break is made, and the second row is arranged from left to right, until all characters in the translated result have been traversed, resulting in the final layout. This layout method ensures that characters do not overlap, do not exceed the boundaries of the detection box, and do not leave excessive whitespace. After obtaining the layout result, it is rendered to obtain the final rendering result.

[0073] This embodiment determines the font size and layout of the translation results based on the size information of the document block, and arranges the translation results according to the determined font size and layout, so that the translated results can be located within the area indicated by the size information of the document block after rendering, ensuring that the size of the translated document block is consistent with that of the original document block, and the rendering effect is beautiful.

[0074] In addition to font size, the font and text color also need to be determined when rendering the translation result. Optionally, in the document translation method of this application embodiment, the rendering of the layout translation result includes: determining the font in the target document block as the font of the translation result, or determining the preset font under the language of the translation result as the font of the translation result; determining the text color in the target document block as the text color of the translation result, or determining the preset color as the text color of the translation result; and rendering the translation result according to the font and text color.

[0075] For example, when determining the font of the translation result, a font classification model can be trained in advance to identify the font of the original language in the target document block. Considering that the font of the target language after translation may not be found in the original language, the font of the translation result may not be consistent with the original font of the document block. It can be determined whether a font consistent with the original language exists in the target language. If a font consistent with the original language exists in the target language, the font in the target document block can be determined as the font of the translation result. If no font consistent with the original language exists in the target language, the preset font of the target language is determined as the font of the translation result. For readability consistency, users can also set the preset font of the target language as the font of the translation result, for example, setting all translation results to use a boldface font. Furthermore, for aesthetic rendering, the font of the translation results for different document blocks can be determined to be different fonts, for example, setting the font of the header / footer and the body text to be different fonts to distinguish between the header / footer and the body text.

[0076] For example, when determining the font for the translation results, to ensure greater consistency between the translated and original documents, the text color in the target document block can be set to the same color as the text color in the translation results. To improve rendering efficiency, a preset color can be set as the text color in the translation results; for example, if the preset color is black, all text in the translation results can be set to black. Furthermore, for aesthetic reasons, the text color of the translation results for different document blocks can be set to different colors. For example, the text color of the translated results for headers / footers and body text can be set to different colors to distinguish between headers / footers and body text.

[0077] In this embodiment, when determining the font and text color of the translation result, the font and text color are flexibly determined according to the requirements of consistency, rendering efficiency and aesthetics, so that the rendering result meets the diverse translation rendering needs of users and improves the user experience.

[0078] The document to be translated may contain not only text but also content other than text. To ensure the translation and rendering effect, optionally, in the document translation method of this application embodiment, when the layout structure also includes at least one of tables and images, the rendering results of different document blocks are arranged in the areas indicated by the position information and size information of the corresponding document blocks to obtain the translated document, including: arranging the images in the original area where the images are located; translating the tables to obtain the translation results of the tables, rendering the translation results of the tables, and arranging the rendered results of the tables in the areas indicated by the corresponding tables; determining the translated document based on the arrangement results of the rendering results of the document blocks, the arrangement results of the images, and / or the arrangement results of the rendering results of the tables.

[0079] For example, images in a document to be translated can be identified using an object detection model. If images are identified in the document, this embodiment does not perform image translation; instead, the images are placed back in their original positions within the document, resulting in the correct image arrangement. It should be noted that for text added on a colored background, the object detection model can identify it as background rather than an illustration, and recognize the text on the background. In this embodiment, the text on the background is identified as a document block and then translated.

[0080] For example, tables in a document to be translated can be detected by an object detection model. If a table is detected in the document to be translated, the table can be converted into Markdown (a lightweight markup language) format and translated. The resulting table translation is also in Markdown format. The Markdown translation result is then rendered into a table and the rendered translation result is placed in the original position of the table to obtain the table rendering result.

[0081] Furthermore, when the layout includes document blocks and tables, the rendered table layout and the rendered document block layout are combined to form the translated document. Similarly, when the layout includes document blocks and tables, the rendered image layout and the rendered document block layout are combined to form the translated document. When the layout includes document blocks, tables, and images, the rendered image layout, the rendered table layout, and the rendered document block layout are combined to form the translated document. Compared to the original document, the translated document retains the same positions for images, tables, and document blocks as before, and maintains the same number of pages as before, only the language has changed, ensuring consistency between the translated and original documents.

[0082] To improve translation accuracy, optionally, in the document translation method of this application embodiment, translating text under different document blocks to obtain translation results includes: determining the domain to which the document to be translated belongs, and determining the translation dictionary under the domain; inputting the translation dictionary as prompt information into the large language translation model; and, based on the large language translation model, performing the steps of translating text under different document blocks to obtain translation results.

[0083] After identifying the document block, this application can use a large language translation model to translate the content of the document block. Compared with first performing dictionary matching and then translating by word (translating word by word or word by word), the translation result of this embodiment is not very rigid, and typos can be automatically corrected during the translation process. At the same time, since the semantic content of the document block is complete, the flexibility and accuracy of the translation result can be guaranteed.

[0084] However, different documents to be translated may belong to different fields. To further improve the translation accuracy within the corresponding fields, this embodiment can configure translation dictionaries for different fields. When translating documents, the field of the document to be translated can be identified first (for example, by extracting keywords and terms from the document's topic, chapter titles, and terminology, and matching the extracted words with words in the field dictionary to identify the field of the document to be translated; or by processing text in the abstract or the full text of the document using a classification model to identify the field of the document to be translated; or by using deep learning techniques to understand the context in the document to identify the field of the document to be translated, such as using a Transformer-based model to identify the field of the document to be translated). Then, the translation dictionary under the corresponding field is matched, and the translation dictionary is input as prompt information into the large language translation model. The large language translation model is instructed to refer to the translation dictionary under the corresponding field. For example, dictionaries for the business field, the legal field, and the scientific and technological field can be configured. The dictionary under the corresponding field is selected according to the field of the document, thereby meeting the translation needs of the corresponding fields when translating business documents, legal documents, and scientific and technological documents.

[0085] This embodiment configures translation dictionaries for different fields, matches the corresponding dictionaries to the field of the document to be translated, and intervenes in the translation of the large language translation model through the dictionaries of the corresponding fields, so as to adapt to the translation needs of different fields and improve translation efficiency and quality.

[0086] To further improve translation accuracy, optionally, before inputting the translation dictionary as prompt information into the large language translation model, the method further includes: upon receiving user input of hot words in the domain and their translation results, adding the hot words and their translation results to the translation dictionary to obtain an updated translation dictionary.

[0087] In addition to using a dictionary of the domain to which the document to be translated belongs to intervene in the translation of the large language translation model, users can also update the translation dictionary. For example, users can collect hot words in the relevant domain and provide relatively idiomatic translation results. During translation, the default translation dictionary of the relevant domain is updated in real time based on the hot words and translation results, so as to prompt the large language translation model to refer to professional hot words for translation.

[0088] For example, when translating titles in the financial field, a highly idiomatic translation is required. Users can add hot terms in the financial field to the financial translation dictionary, and the updated dictionary can then influence the translation of financial documents by the large language translation model. Similarly, when translating the main text in the automotive field, which describes various car models, if a newly launched model is described as "Vehicle Brand - Model One," without the intervention of specialized hot terms, the large language model might translate it as "Vehicle Brand - Model 1," which is incorrect. Users can add the car model and its translation to the vehicle translation dictionary, allowing the large language model to provide a correct and idiomatic translation. Furthermore, it should be noted that the large language translation model can understand the meaning of user-configured hot terms. Even if the hot terms change in form or expression, the large language translation model can correctly identify them and provide an idiomatic and accurate translation.

[0089] This embodiment updates the dictionary for the corresponding field based on hot words in the corresponding field and intervenes in the translation of the large language translation model, so that the translation results can meet the user's personalized translation needs.

[0090] Example 2

[0091] According to an embodiment of this application, another document translation method is also provided. Figure 5 This is a flowchart of an optional document translation method according to an embodiment of this application. This method is used to translate PDF documents, such as... Figure 5 As shown, the method includes:

[0092] First, the layout structure of the PDF document is parsed, and then complete text blocks are obtained based on the layout structure to ensure the semantic integrity of each text block. At the same time, the size and position of the document blocks are obtained. For example, four document blocks are obtained, namely document block 1, document block 2, document block 3, and document block 4.

[0093] Then, document block 1, document block 2, document block 3, and document block 4 are translated separately. Since the document blocks have complete semantics, the accuracy of the translation can be guaranteed. During the translation, a large language model can be used to improve the flexibility of the translation. The translation of the large language translation model can also be intervened by industry dictionaries in professional fields. At the same time, users can add industry hot words and their translation results to the industry dictionary to make the translation results more authentic. For example, if the PDF document is a document with financial attributes, the translation of the large language translation model can be intervened by hot words in the financial field.

[0094] Furthermore, based on the size of the document block and the number of characters in the translated document block, the font size is adjusted so that the size of the area occupied by the translation result is consistent with the size of the area occupied by the document block.

[0095] Furthermore, the translation results of the document blocks are laid out, arranging the translation results of each document block in its original position to obtain a translated PDF document with the same layout as the original PDF document.

[0096] Table 1 is a comparison table of translation methods in this embodiment and related technologies.

[0097] Table 1

[0098]

[0099]

[0100] As shown in Table 1, in terms of rendering effect, the rendering result of this embodiment is more aesthetically pleasing than that of the basic model translation and more usable than that of the plugin translation in related technologies. In terms of translation result, this embodiment is more usable than both the basic model translation and the plugin translation in related technologies. In addition, this embodiment comes with an industry dictionary that users can configure and add, resulting in more authentic translation results.

[0101] Example 3

[0102] According to an embodiment of this application, another document translation method is also provided. Figure 6 This is a flowchart of another document translation method according to an embodiment of this application, such as... Figure 6 As shown, the method includes:

[0103] Step S602: The cloud server receives the document to be translated from the client.

[0104] The document to be translated can be an electronic document, such as a PDF (Portable Document Format) document.

[0105] In step S604, the cloud server identifies the layout structure of the document to be translated, determines document blocks based on the layout structure, obtains the position information, size information, and text in different document blocks, translates the text in different document blocks to obtain translation results, renders the translation results of different document blocks based on the size information of the corresponding document blocks to obtain the rendering results of the document blocks, and arranges the rendering results of different document blocks in the areas indicated by the position information and size information of the corresponding document blocks to obtain the translated document.

[0106] The cloud server can first identify the layout structure of the document to be translated. The layout structure refers to the document's typesetting and arrangement. The layout structure can be represented by multiple components in the document and the position and size information of the components. The components can include document blocks, tables, images, etc.

[0107] For example, a cloud server can identify the layout structure of a document to be translated using image detection methods. Different components of the identified layout structure are marked with detection boxes, and document blocks are determined from the content marked by the detection boxes. Document blocks may include titles, body text, headers, footers, etc., and titles may include article titles and chapter titles. The detection box can be rectangular, and the text within the detection box is the text within the document block. The document block's position information refers to its location within the document; the coordinates of the four points of the rectangular detection box represent the document block's position within the document. The document block's size information refers to its length and width; these dimensions can be determined based on the coordinates of the four points of the rectangular detection box.

[0108] Then, the cloud server can sort all document blocks according to their positions within the document to be translated, resulting in a document block sequence. Each document block in the sequence is associated with positional and size information. The text within each document block in the sequence is translated sequentially, yielding multiple translation results. Different languages ​​may use different numbers of words to describe the same content. When rendering the translation results of a document block, the size information associated with the corresponding document block is determined, and the font size of the translation result is adjusted based on the document block's size information, ensuring that the translated result is located within the area indicated by the document block's size information after rendering.

[0109] Furthermore, the cloud server determines the specific area in the document to be translated where the translation result is rendered based on the location and size information associated with the document block. This area is also the original area of ​​the document block. The rendered result of the translation result is then arranged in the original area of ​​the document block to obtain the translated document.

[0110] In step S606, the cloud server sends the translated document to the client.

[0111] The translated document is displayed through the client, and the translated document has the same layout structure as the original document, which can improve the user's reading experience.

[0112] In this embodiment, the cloud server receives a document to be translated from the client; the cloud server identifies the layout structure of the document to be translated, determines document blocks based on the layout structure, obtains the position information, size information, and text in different document blocks, translates the text in different document blocks to obtain translation results, renders the translation results of different document blocks based on the size information of the corresponding document blocks to obtain rendering results of the document blocks, and arranges the rendering results of different document blocks in the areas indicated by the position information and size information of the corresponding document blocks to obtain the translated document; the cloud server sends the translated document to the client. By parsing the layout structure of the document to be translated by the cloud server, determining document blocks with complete semantic structure, translating each document block to make the translated document block semantically complete, and rendering the translation result in the original position of the document block, the layout structure of the document after translation is consistent with that before translation, thereby achieving the technical effect of semantically complete translated document and consistent document layout structure. This solves the technical problem in related technologies where translation plugins translate the text in each HTML text block of a document, resulting in unsatisfactory document translation effects because HTML text blocks do not have complete semantic structure.

[0113] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that this application is not limited to the described order of actions, as some steps may be performed in other orders or simultaneously according to this application. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are preferred embodiments, and the actions and modules involved are not necessarily essential to this application.

[0114] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods according to the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, they can also be implemented by hardware. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, or network device, etc.) to execute the methods described in the various embodiments of this application.

[0115] Example 4

[0116] According to embodiments of this application, an apparatus for implementing the above-described document translation method is also provided. Figure 7 This is a structural block diagram of a document translation device according to an embodiment of this application, such as... Figure 7As shown, the device includes: an identification unit 702, an acquisition unit 704, a translation unit 706, a rendering unit 708, and a layout unit 710.

[0117] The recognition unit 702 is used to recognize the layout structure of the document to be translated and determine document blocks based on the layout structure.

[0118] The acquisition unit 704 is used to acquire the position information, size information, and text in different document blocks.

[0119] Translation unit 706 is used to translate text in different document blocks to obtain translation results.

[0120] The rendering unit 708 is used to render the translation results of different document blocks based on the size information of the corresponding document blocks, so as to obtain the rendering result of the document blocks.

[0121] The layout unit 710 is used to arrange the rendering results of different document blocks in the areas indicated by the position information and size information of the corresponding document blocks to obtain the translated document.

[0122] In this embodiment, the identification unit 702 identifies the layout structure of the document to be translated and determines document blocks based on the layout structure; the acquisition unit 704 acquires the position information, size information, and text in different document blocks; the translation unit 706 translates the text under different document blocks to obtain translation results; the rendering unit 708 renders the translation results of different document blocks based on the size information of the corresponding document blocks to obtain the rendering results of the document blocks; and the layout unit 710 arranges the rendering results of different document blocks in the areas indicated by the position information and size information of the corresponding document blocks to obtain the translated document. By parsing the layout structure of the document to be translated, document blocks with complete semantic structure are identified, and each document block is translated to make the translated document block semantically complete. The translation results are then rendered to the original position of the document block, making the document layout structure after translation consistent with that before translation. This achieves the technical effect of semantically complete translated document and consistent document layout structure, thereby solving the technical problem in related technologies where translation plugins translate the text in each HTML text block of a document, resulting in unsatisfactory document translation effects because HTML text blocks do not have complete semantic structures.

[0123] Optionally, in the document translation apparatus of this application embodiment, the identification unit 702 includes: a processing module, used to input the document to be translated into the target detection model and process it to obtain the layout structure of the document to be translated, wherein the target detection model is trained through sample documents, the sample documents are marked with layout structures, and the marked layout structures include at least one of the following: document blocks, tables, and images, and the document blocks include at least one of the following: titles, body text, headers, and footers.

[0124] Optionally, in the document translation apparatus of this application embodiment, the rendering unit 708 includes: a word count determination module, used to determine the word count of the translation result of the target document block, wherein the target document block is one of different document blocks; a font size determination module, used to determine the font size of the translation result based on the size information of the target document block and the word count of the translation result; and a rendering module, used to arrange the translation result according to the font size of the translation result and the size information of the target document block, and render the arranged translation result.

[0125] Optionally, in the document translation apparatus of this application embodiment, the rendering module includes: a font determination submodule, used to determine the font in the target document block as the font of the translation result, or to determine a preset font in the language of the translation result as the font of the translation result; a text color determination submodule, used to determine the text color in the target document block as the text color in the translation result, or to determine a preset color as the text color in the translation result; and a rendering submodule, used to render the translation result according to the font and text color.

[0126] Optionally, in the document translation apparatus of this application embodiment, if the layout structure further includes at least one of tables and images, the layout unit 710 includes: a first layout module for arranging images in the original area where the images are located; a second layout module for translating tables to obtain translation results of the tables, rendering the translation results of the tables, and arranging the rendered results of the tables in the area indicated by the corresponding tables; and a document determination module for determining the translated document based on the layout results of the rendered results of document blocks, the layout results of images, and / or the layout results of the rendered results of tables.

[0127] Optionally, in the document translation apparatus of this application embodiment, the translation unit 706 includes: a translation dictionary determination module, used to determine the domain to which the document to be translated belongs, and to determine the translation dictionary under the domain; an input module, used to input the translation dictionary as prompt information into the large language translation model; and a translation module, used to perform the step of translating the text under different document blocks based on the large language translation model to obtain the translation result.

[0128] Optionally, in the document translation apparatus of this application embodiment, the apparatus further includes: an update module, configured to add hot words and their translation results to the translation dictionary before inputting the translation dictionary as prompt information into the large language translation model, upon receiving hot words and their translation results in the domain input by the user, thereby obtaining an updated translation dictionary.

[0129] It should be noted that the above-mentioned units and modules correspond to the steps in Embodiment 1. The examples and application scenarios implemented by the above-mentioned units and modules are the same as those implemented by the corresponding steps, but are not limited to the content disclosed in Embodiment 1. It should be noted that the above-mentioned modules or units may be hardware components or software components stored in memory (e.g., memory 104) and processed by one or more processors (e.g., processors 102a, 102b, ..., 102n). The above-mentioned modules may also be part of the device and can run in the computer terminal 10 provided in Embodiment 1.

[0130] It should be noted that the preferred implementation schemes involved in the above embodiments of this application are the same as the schemes, application scenarios and implementation processes provided in Embodiment 1, but are not limited to the schemes provided in Embodiment 1.

[0131] Example 5

[0132] Embodiments of this application may provide an electronic device, which may be any one of a group of electronic devices. Optionally, in this embodiment, the aforementioned electronic device may also be replaced by a terminal device such as a mobile terminal.

[0133] Optionally, in this embodiment, the aforementioned electronic device may be located in at least one of a plurality of network devices in a computer network.

[0134] In this embodiment, the computer terminal described above can execute the program code in the method.

[0135] Optionally, the figure is a structural block diagram of an electronic device according to an embodiment of the present application. Figure 8 This is a structural block diagram of the electronic device according to an embodiment of this application, such as... Figure 8 As shown, the electronic device A may include: one or more ( Figure 8 (Only one is shown) processor 102, memory 104, memory controller, and peripheral interface, wherein the peripheral interface is connected to the radio frequency module, audio module and display.

[0136] The memory can be used to store software programs and modules, such as the program instructions / modules corresponding to the methods and apparatus in the embodiments of this application. The processor executes various functional applications and data processing by running the software programs and modules stored in the memory, thereby implementing the methods in the above embodiments. The memory may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory may further include memory remotely located relative to the processor, and these remote memories can be connected to device A via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.

[0137] The processor can access information and applications stored in memory via a transmission device to perform the following steps: identify the layout structure of the document to be translated, and determine document blocks based on the layout structure; obtain the position information, size information, and text within different document blocks; translate the text in different document blocks to obtain translation results; render the translation results of different document blocks based on the size information of the corresponding document blocks to obtain the rendering results of the document blocks; and arrange the rendering results of different document blocks in the areas indicated by the position information and size information of the corresponding document blocks to obtain the translated document.

[0138] Optionally, the processor may also execute program code for the following steps: identifying the layout structure of the document to be translated includes: inputting the document to be translated into an object detection model and processing it to obtain the layout structure of the document to be translated, wherein the object detection model is trained on sample documents, the sample documents are marked with layout structures, and the marked layout structures include at least one of the following: document blocks, tables, and images, and the document blocks include at least one of the following: titles, body text, headers, and footers.

[0139] Optionally, the processor may also execute program code with the following steps: rendering the translation results of different document blocks based on the size information of the corresponding document blocks, and obtaining the rendering results including: for the target document block, determining the number of words in the translation result of the target document block, wherein the target document block is a document block among different document blocks; determining the font size of the translation result based on the size information of the target document block and the number of words in the translation result; arranging the translation results according to the font size of the translation result and the size information of the target document block, and rendering the arranged translation result.

[0140] Optionally, the processor may also execute program code that performs the following steps: rendering the translated result after layout, including: determining the font in the target document block as the font of the translated result, or determining the preset font in the language of the translated result as the font of the translated result; determining the text color in the target document block as the text color in the translated result, or determining the preset color as the text color in the translated result; and rendering the translated result according to the font and text color.

[0141] Optionally, the processor may also execute program code that performs the following steps: when the layout structure includes at least one of tables and images, arranging the rendering results of different document blocks in the areas indicated by the position information and size information of the corresponding document blocks to obtain the translated document includes: arranging images in the original area where the images are located; translating tables to obtain the translation results of the tables, rendering the translation results of the tables, and arranging the rendered results of the tables in the areas indicated by the corresponding tables; and determining the translated document based on the arrangement results of the rendering results of the document blocks, the arrangement results of the images, and / or the arrangement results of the rendering results of the tables.

[0142] Optionally, the processor may also execute program code that performs the following steps: translating text in different document blocks to obtain translation results, including: determining the domain of the document to be translated and determining the translation dictionary for that domain; inputting the translation dictionary as prompt information into the large language translation model; and, based on the large language translation model, performing the steps of translating text in different document blocks to obtain translation results.

[0143] Optionally, the processor may also execute program code that performs the following steps: before inputting the translation dictionary as prompt information into the large language translation model, the method further includes: upon receiving hot words in the domain input by the user and the translation results of the hot words, adding the hot words and the translation results of the hot words to the translation dictionary to obtain an updated translation dictionary.

[0144] This application provides a document translation scheme. By identifying the layout structure of the document to be translated, document blocks are determined based on the layout structure. The position information, size information, and text within each document block are obtained. The text within each document block is translated to obtain translation results. Based on the size information of the corresponding document blocks, the translation results of each document block are rendered to obtain rendering results. The rendering results of each document block are then arranged in the areas indicated by the position and size information of the corresponding document blocks to obtain the translated document. By parsing the layout structure of the document to be translated, document blocks with complete semantic structures are identified. Each document block is translated, ensuring semantic completeness. The translation results are then rendered back to the original positions of the document blocks, making the document layout structure consistent with the original layout. This achieves the technical effect of semantic completeness and consistent document layout structure after translation, thus solving the technical problem in related technologies where translation plugins translate text within HTML text blocks, resulting in unsatisfactory document translation effects due to the lack of complete semantic structure in HTML text blocks.

[0145] Those skilled in the art will understand that, Figure 8The structure shown is for illustrative purposes only. Electronic device A can also be a smartphone, tablet, PDA, mobile internet device (MID), PAD, or other terminal device. This diagram does not limit the structure of the aforementioned electronic device. For example, electronic device A may also include components that are larger than those shown. Figure 8 The figure may contain more or fewer components (such as network interfaces, display devices, etc.) or have a different configuration than that shown in the figure.

[0146] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be implemented by a program instructing the hardware related to the terminal device. The program can be stored in a computer-readable storage medium, which may include: flash drive, read-only memory (ROM), random access memory (RAM), disk or optical disk, etc.

[0147] Example 6

[0148] Embodiments of this application also provide a computer-readable storage medium. Optionally, in this embodiment, the computer-readable storage medium can be used to store program code executed by the method provided in the above embodiments.

[0149] Optionally, in this embodiment, the storage medium may be located in any one of the electronic devices in the group of electronic devices in the computer network, or in any one of the mobile terminals in the group of mobile terminals.

[0150] Optionally, in this embodiment, the computer-readable storage medium is configured to store program code for performing the following steps: identifying the layout structure of the document to be translated, and determining document blocks based on the layout structure; obtaining the position information, size information, and text in different document blocks; translating the text under different document blocks to obtain translation results; rendering the translation results of different document blocks based on the size information of the corresponding document blocks to obtain rendering results of the document blocks; and arranging the rendering results of different document blocks in the areas indicated by the position information and size information of the corresponding document blocks to obtain the translated document.

[0151] Optionally, the computer-readable storage medium is further configured to store program code for performing the following steps: identifying the layout structure of the document to be translated includes: inputting the document to be translated into an object detection model and processing it to obtain the layout structure of the document to be translated, wherein the object detection model is trained on sample documents, the sample documents are labeled with layout structures, and the labeled layout structures include at least one of the following: document blocks, tables, and images, and the document blocks include at least one of the following: titles, body text, headers, and footers.

[0152] Optionally, the computer-readable storage medium is further configured to store program code for performing the following steps: rendering the translation results of different document blocks based on the size information of the corresponding document blocks, and obtaining the rendering results including: for the target document block, determining the number of words in the translation result of the target document block, wherein the target document block is one of the different document blocks; determining the font size of the translation result according to the size information of the target document block and the number of words in the translation result; arranging the translation results according to the font size of the translation result and the size information of the target document block, and rendering the arranged translation result.

[0153] Optionally, the computer-readable storage medium is further configured to store program code for performing the following steps: rendering the translated result after layout, including: determining the font in the target document block as the font of the translated result, or determining a preset font in the language of the translated result as the font of the translated result; determining the text color in the target document block as the text color of the translated result, or determining a preset color as the text color of the translated result; and rendering the translated result according to the font and text color.

[0154] Optionally, the computer-readable storage medium is further configured to store program code for performing the following steps: when the layout structure also includes at least one of tables and images, arranging the rendering results of different document blocks in the areas indicated by the position information and size information of the corresponding document blocks to obtain a translated document, including: arranging images in the original area where the images are located; translating the tables to obtain the translation results of the tables, rendering the translation results of the tables, and arranging the rendered results of the tables in the areas indicated by the corresponding tables; determining the translated document based on the arrangement results of the rendering results of the document blocks, the arrangement results of the images, and / or the arrangement results of the rendering results of the tables.

[0155] Optionally, the computer-readable storage medium is also configured to store program code for performing the following steps: translating text under different document blocks to obtain translation results, including: determining the domain to which the document to be translated belongs and determining the translation dictionary under the domain; inputting the translation dictionary as prompt information into the large language translation model; and, based on the large language translation model, performing the steps of translating text under different document blocks to obtain translation results.

[0156] Optionally, the computer-readable storage medium is also configured to store program code for performing the following steps: before inputting the translation dictionary as prompt information into the large language translation model, the method further includes: upon receiving hot words in the domain input by the user and the translation results of the hot words, adding the hot words and the translation results of the hot words to the translation dictionary to obtain an updated translation dictionary.

[0157] Example 7

[0158] Embodiments of this application also provide a computer program product. Optionally, the computer program product may include a non-volatile computer-readable storage medium, which can be used to store a computer program that, when executed by a processor, implements the method provided in the above embodiments.

[0159] Example 8

[0160] Embodiments of this application also provide a computer program. Optionally, in this embodiment, when the computer program is executed by a processor, it implements the method provided in the above embodiments.

[0161] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.

[0162] In the above embodiments of this application, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.

[0163] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. The device embodiments described above are merely illustrative; for example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the displayed or discussed mutual coupling, direct coupling, or communication connection may be through some interfaces; the indirect coupling or communication connection between units or modules may be electrical or other forms.

[0164] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0165] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0166] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard drive, magnetic disk, or optical disk.

[0167] The above description is only a preferred embodiment of this application. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of this application, and these improvements and modifications should also be considered within the scope of protection of this application.

Claims

1. A document translation method, characterized in that, include: Identify the layout structure of the document to be translated, and determine document blocks based on the layout structure; Obtain the position and size information of different document blocks, as well as the text within those blocks; The text in the different document blocks is translated to obtain the translation results; The translation results of the different document blocks are rendered based on the size information of the corresponding document blocks to obtain the rendering results of the document blocks; The rendering results of the different document blocks are arranged in the areas indicated by the position and size information of the corresponding document blocks to obtain the translated document.

2. The method according to claim 1, characterized in that, Identifying the layout structure of the document to be translated includes: The document to be translated is input into the object detection model, and the layout structure of the document to be translated is obtained. The object detection model is trained on sample documents, and the sample documents are marked with layout structures. The marked layout structures include at least one of the following: document blocks, tables, and images. The document blocks include at least one of the following: titles, body text, headers, and footers.

3. The method according to claim 1, characterized in that, The translation results of the different document blocks are rendered based on the size information of the corresponding document blocks, and the rendering results include: For a target document block, determine the number of words in the translation result of the target document block, wherein the target document block is one of the different document blocks; The font size of the translation result is determined based on the size information of the target document block and the number of characters in the translation result; Arrange the translation results according to the font size of the translation results and the size information of the target document block, and render the arranged translation results.

4. The method according to claim 3, characterized in that, The translation results after rendering and layout include: The font in the target document block is determined as the font of the translation result, or the preset font in the language of the translation result is determined as the font of the translation result; The text color in the target document block is determined as the text color in the translation result, or a preset color is determined as the text color in the translation result; The translation result is rendered based on the font and the text color.

5. The method according to claim 1, characterized in that, If the layout structure also includes at least one of tables and images, the rendering results of the different document blocks are arranged in the areas indicated by the position and size information of the corresponding document blocks, resulting in a translated document including: Arrange the images in the original area where the images are located; The table is translated to obtain the translation result, the translation result is rendered, and the rendered result is arranged in the area indicated by the corresponding table. The translated document is determined based on the layout of the rendered document blocks, the layout of the images, and / or the layout of the rendered tables.

6. The method according to any one of claims 1 to 5, characterized in that, The text under the different document blocks is translated, and the translation results include: Determine the domain to which the document to be translated belongs, and determine the translation dictionary for that domain; The translation dictionary is input as prompt information into the large language translation model; Based on the large language translation model, the step of translating the text under the different document blocks to obtain the translation results is performed.

7. The method according to claim 6, characterized in that, Before inputting the translation dictionary as prompt information into the large language translation model, the method further includes: Upon receiving user input of hot words in the specified domain and their translation results, the hot words and their translation results are added to the translation dictionary to obtain an updated translation dictionary.

8. A document translation method, characterized in that, The cloud server receives the document to be translated from the client. The cloud server identifies the layout structure of the document to be translated, determines document blocks based on the layout structure, obtains the position information, size information, and text in different document blocks, translates the text in the different document blocks to obtain translation results, renders the translation results of the different document blocks based on the size information of the corresponding document blocks to obtain rendering results of the document blocks, and arranges the rendering results of the different document blocks in the areas indicated by the position information and size information of the corresponding document blocks to obtain the translated document; The cloud server sends the translated document to the client.

9. A document translation device, characterized in that, include: The identification unit is used to identify the layout structure of the document to be translated and to determine document blocks based on the layout structure. The acquisition unit is used to acquire the position information, size information, and text within different document blocks; The translation unit is used to translate the text under the different document blocks to obtain the translation results; The rendering unit is used to render the translation results of the different document blocks based on the size information of the corresponding document blocks, so as to obtain the rendering result of the document blocks; The layout unit is used to arrange the rendering results of the different document blocks in the areas indicated by the position information and size information of the corresponding document blocks, so as to obtain the translated document.

10. An electronic device, characterized in that, include: Memory, which stores executable programs; A processor for running the program, wherein the program, when running, performs the method according to any one of claims 1 to 8.

11. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes a stored executable program, wherein, when the executable program is executed, it controls the device on which the storage medium is located to perform the method according to any one of claims 1 to 8.

12. A computer program product, characterized in that, The method includes a non-volatile computer-readable storage medium storing a computer program that, when executed by a processor, implements the method of any one of claims 1 to 8.