Translation generation method and device for translated file, equipment and medium
By performing layout analysis and information division of translated files, the problem of manually adjusting the layout in the existing technology is solved, and the consistency between the translation and original paragraph typesetting is achieved, and position abnormalities are automatically fixed, and user experience is improved.
Patent Information
- Application Number
- CN202411483625.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-23
- Publication Date
- 2025-02-25
AI Technical Summary
In the prior art, manual adjustment of typesetting is required, which is time-consuming and labor-intensive, and there is a problem of overlapping elements.
By performing layout analysis of the translated files, dividing text information, non-text information and attribute information, and translating and parsing them separately. After generating the initial translation, the text content is positionally detected and relocated to generate the target translation.
It realizes consistency between translation and original paragraph layout, automatically repairs text with abnormal locations, avoids manual manual adjustments, reduces user operations, and improves user experience.
Smart Images

Figure CN119514561A_ABST
Abstract
Description
[Technical field]
[0001] The present application relates to the field of text processing technology, and in particular to a method, device, equipment and medium for generating a translation of a translation file. [Background technology]
[0002] Layout document translation refers to translating documents with complex formats (such as PDF, CAJ, etc.) from one language to another while keeping the original layout and format unchanged. This translation process requires not only accurate communication of content, but also the preservation or restoration of the visual layout, charts, font styles, colors and other format elements in the original document as much as possible; and the accuracy of the translated content also depends on the accuracy of the layout analysis of the document structure, layout and object order. Layout document translation has become particularly important in the process of globalization, especially in the dissemination of professional documents in the fields of law, technology, medicine, marketing, education and publishing, which usually have strict format requirements. Any change in format may lead to misunderstanding or distortion of the content.
[0003] In view of this situation, the common practices in related technologies are:
[0004] Step 1: Extract text content: First, use a dedicated tool (OCR tool) to extract translatable text content from the layout document. This process requires parsing the document structure, extracting text information, and ensuring that non-text elements such as tables, pictures, and paragraphs are correctly retained. Retain format information: In addition to text, the format of the layout document (such as font, color, paragraph, image position, etc.) also needs to be recorded so that the original layout can be restored after translation.
[0005] Step 2: Text machine translation: You can use machine translation tools (such as Google Translate) to translate the extracted text. This method cannot restore the layout structure and can only be read in plain text.
[0006] Step 3: Automatically adjust the layout: Use the layout position and size information obtained by OCR to adjust the position of the translated text. Reinsert the translated text into the layout structure of the original document. At this time, the contents such as charts, paragraphs, titles, footnotes, etc. should remain the same.
[0007] Step 4: Manual adjustment: Manually adjust the position based on the generated translation formats such as HTML and PDF to adjust the original information structure.
[0008] This method has the problem of overlapping element content and requires manual adjustment of the layout, which is time-consuming. [Summary of the invention]
[0009] The embodiments of the present application provide a method, device, equipment and medium for generating a translation of a translation file, aiming to solve technical problems in related technologies such as the need for manual adjustment of typesetting, which is time-consuming and labor-intensive.
[0010] In a first aspect, an embodiment of the present application provides a method for generating a translation of a translation file, comprising:
[0011] Perform layout analysis on the document to be translated to obtain layout analysis result information;
[0012] Dividing the layout analysis result information into text information, non-text information and attribute information according to the document type;
[0013] Respectively translating and parsing the text information and the non-text information to obtain parsing result information;
[0014] An initial translation is generated according to each parsing result information, the attribute information and a preset translation template; a position detection is performed on the text content in the initial translation, and a target text with an abnormal position is relocated to obtain a target translation.
[0015] In one embodiment, optionally, a layout analysis is performed on the file to be translated to obtain layout analysis result information, including:
[0016] Analyze the layout of each page of the file to be translated in order according to the page number of the file to be translated, so as to obtain the metadata XML information corresponding to each page;
[0017] The metadata XML information corresponding to each page is divided into hierarchical nodes according to the XML hierarchical structure, wherein the hierarchical nodes include at least one of the following: page node, segment node, row node, picture node, table node and formula node, as well as attribute information corresponding to each node.
[0018] In one embodiment, optionally, the layout analysis result information is divided into text information, non-text information and attribute information according to the document type, including:
[0019] According to the hierarchical nodes, the first metadata XML information corresponding to the segment nodes and row nodes is divided into text information, the second metadata XML information corresponding to the picture nodes, table nodes and formula nodes is divided into non-text information, and the third metadata XML information corresponding to the attribute information of each node is divided into attribute information.
[0020] In one embodiment, optionally, the text information and the non-text information are translated and parsed respectively to obtain parsing result information, including:
[0021] For the text information, parse the metadata XML information of all row nodes corresponding to each segment node in the first metadata XML information, and add them into a text array to obtain a text array set corresponding to the entire page of text;
[0022] Performing text translation on the text array set to obtain a text translation;
[0023] For the non-text information, parse the metadata XML information of the picture node, the table node and the formula node in the second metadata XML information, determine the position information and the coordinate range information corresponding to each node in the form of an image tag, and capture the corresponding target image;
[0024] For the attribute information, parse the third metadata XML information and generate corresponding structure tags in HTML.
[0025] In one embodiment, optionally, generating an initial translation according to each parsing result information, the attribute information and a preset translation template includes:
[0026] According to the text translation, the image tag and the structure tag are marked in the preset translation template, and the corresponding text translation and target image are inserted into the preset translation template to generate the initial translation.
[0027] In one embodiment, optionally, performing position detection on the text content in the initial translation and relocating the target text with abnormal position to obtain the target translation includes:
[0028] According to the attribute information corresponding to each segment node, each segment node of each page in the initial translation is sorted to obtain a sorted result;
[0029] Determine whether the target areas corresponding to any two segment nodes intersect in order from top to bottom and from left to right;
[0030] When it is determined that there is an intersection, the segment nodes sorted later are shifted downward according to the intersection height until all segment nodes have no intersection.
[0031] In one embodiment, optionally, the method further comprises:
[0032] Obtaining paragraph format information and column layout information of the file to be translated;
[0033] The paragraph format and column layout of the target translation are adjusted according to the paragraph format information and column layout information.
[0034] In a second aspect, an embodiment of the present application provides a translation generating device for a translation file, comprising:
[0035] An analysis module is used to perform layout analysis on the document to be translated to obtain layout analysis result information;
[0036] A division module, used for dividing the layout analysis result information into text information, non-text information and attribute information according to document type;
[0037] A processing module, used for translating and parsing the text information and non-text information respectively to obtain parsing result information;
[0038] A generation module, used to generate an initial translation according to each parsing result information, the attribute information and a preset translation template;
[0039] The relocation module is used to detect the position of the text content in the initial translation and relocate the target text with abnormal position to obtain the target translation.
[0040] In a third aspect, a computer device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the method for generating a translation file when executing the computer program.
[0041] In a fourth aspect, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the method for generating a translation of the above-mentioned translation file are implemented.
[0042] In the scheme implemented by the translation generation method, device, equipment and medium of the above translation file, the layout analysis of the file to be translated is performed to obtain the layout analysis result information; the layout analysis result information is divided into text information, non-text information and attribute information according to the document type; the text information and non-text information are translated and parsed accordingly to obtain the parsing result information; the initial translation is generated according to each parsing result information, the attribute information and the preset translation template; the position of the text content in the initial translation is detected, and the target text with abnormal position is relocated to obtain the target translation. In the present invention, on the premise of achieving the consistency of paragraph typesetting between the translation and the original text, the position of the text content in the translation can also be automatically detected, so as to repair the text with abnormal position and relocate it, thereby avoiding manual position adjustment, thereby reducing user operations and improving user experience.
Brief Description of the Drawings
[0043] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0044] Figure 1 A schematic flow chart of a method for generating a translation of a translation file according to an embodiment of the present application is shown.
[0045] Figure 2 A schematic flow chart of step S105 in a method for generating a translation of a translation file according to an embodiment of the present application is shown.
[0046] Figure 3 The figure shows the effect of the translation without adding position repair in the related art.
[0047] Figure 4 A schematic diagram showing the effect of position repair of a translation according to an embodiment of the present application is shown.
[0048] Figure 5 A block diagram of a translation generating device for a translation file according to an embodiment of the present application is shown. [Specific implementation method]
[0049] In order to better understand the technical solution of the present application, the embodiments of the present application are described in detail below with reference to the accompanying drawings.
[0050] It should be clear that the described embodiments are only part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without creative work are within the scope of protection of the present application.
[0051] The terms used in the embodiments of the present application are only for the purpose of describing specific embodiments, and are not intended to limit the present application. The singular forms "a", "said" and "the" used in the embodiments of the present application and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings.
[0052] In conjunction with the accompanying drawings, some embodiments of the present application are described in detail below. In the absence of conflict, the following embodiments and features in the embodiments can be combined with each other.
[0053] See also Figure 1 , Figure 1A schematic flow chart of a method for generating a translation file according to an embodiment of the present application is shown. The method for generating a translation file is used to solve technical problems in related technologies such as requiring manual adjustment of typesetting, which is time-consuming and labor-intensive.
[0054] like Figure 1 As shown, according to a method for generating a translation of a translation file in one embodiment of the present application, the process includes:
[0055] Step S101, performing layout analysis on the document to be translated to obtain layout analysis result information;
[0056] In one embodiment, optionally, step S101 includes:
[0057] Analyze the layout of each page of the file to be translated in order according to the page number of the file to be translated, so as to obtain the metadata XML information corresponding to each page;
[0058] In this step, the layout analysis is performed on each page of the document in turn according to the page number of the document to be translated, so as to parse out various metadata information such as characters, figures, tables, formulas, paragraphs, lines, etc. on each page of the document.
[0059] The metadata XML information corresponding to each page is divided into hierarchical nodes according to the XML hierarchical structure, wherein the hierarchical nodes include at least one of the following: page node, segment node, row node, picture node, table node and formula node, as well as attribute information corresponding to each node.
[0060] In this step, the XML hierarchical structure is generated, including <pages> <page> <block> <rect> <fontinfo> <text> <rect> <mainfont>, each level node includes page number, page size, paragraph type, paragraph position size, each line of text characters, size position, font style information, and also includes size and position information of pictures, formulas, tables, etc.
[0061] Step S102, dividing the layout analysis result information into text information, non-text information and attribute information according to the document type;
[0062] In one embodiment, optionally, step S102 includes:
[0063] According to the hierarchical nodes, the first metadata XML information corresponding to the segment nodes and row nodes is divided into text information, the second metadata XML information corresponding to the picture nodes, table nodes and formula nodes is divided into non-text information, and the third metadata XML information corresponding to the attribute information of each node is divided into attribute information.
[0064] Step S103, translating and parsing the text information and non-text information respectively to obtain parsing result information;
[0065] In one embodiment, optionally, step S103 includes:
[0066] For the text information, parse the metadata XML information of all row nodes corresponding to each segment node in the first metadata XML information, and add them into a text array to obtain a text array set corresponding to the entire page of text; perform text translation on the text array set to obtain a text translation;
[0067] In this step, for text information, all text line nodes in each block segment node in the XML are parsed and added to a string; this process is repeated to parse all blocks, and the string text in each block is added to an array. In this way, the entire page of text can be used as the translation granularity, and then the text array is machine translated, thereby increasing the context information in the translation process, improving the accuracy and professionalism of the translation, and finally obtaining a set of Chinese translations.
[0068] For the non-text information, parse the metadata XML information of the picture node, the table node and the formula node in the second metadata XML information, determine the position information and the coordinate range information corresponding to each node in the form of an image tag, and capture the corresponding target image;
[0069] In this step, for non-text information, parse each img picture node, table table node, and formula formula node in the xml, and obtain the position and size of these nodes in the form of img picture tags.
[0070] For the attribute information, parse the third metadata XML information and generate corresponding structure tags in HTML.
[0071] In this step, the attributes of each text and each block in the XML are parsed, and a tag suitable for HTML is generated accordingly. At the same time, the present invention can customize the template to personalize the display of the translation, which is more efficient and convenient for users to read.
[0072] Step S104, generating an initial translation according to each parsing result information, the attribute information and a preset translation template;
[0073] In one embodiment, optionally, step S104 includes:
[0074] According to the text translation, the image tag and the structure tag are marked in the preset translation template, and the corresponding text translation and target image are inserted into the preset translation template to generate the initial translation.
[0075] In this step, when rendering the HTML page, all block texts, all image nodes and all attribute information parsed in the above step are inserted into the DOM corresponding to the preset translation template according to the sequence number. The position attribute used by each DOM node is derived from the position of the layout analysis, and the four attributes of left, top, width and height are consistent. Repeat all pages to get the translation information of the entire article.
[0076] Among them, when translating documents, a dynamic lazy loading mechanism can be used, which can effectively meet the user's current translation and comparison reading needs without affecting other programs and functions, and consumes less resources.
[0077] Step S105 , performing position detection on the text content in the initial translation, and relocating the target text with abnormal position to obtain the target translation.
[0078] like Figure 2 As shown, in one embodiment, optionally, step S105 includes:
[0079] Step S201, sorting the segment nodes of each page in the initial translation according to the attribute information corresponding to each segment node to obtain a sorted result;
[0080] Step S202, determining whether the target areas corresponding to any two segment nodes intersect in order from top to bottom and from left to right;
[0081] Step S203, when it is determined that there is an intersection, the segment nodes sorted later are shifted downward according to the intersection height until all segment nodes have no intersection.
[0082] In this embodiment, due to the different lengths of Chinese and English characters before and after translation, there will be overlap in the translation, such as Figure 3 As shown. Therefore, detect it and automatically fix the position. Assume that the coordinates of the upper left corner of all natural paragraphs in the page, that is, the i-th block of the DOM element in the html, are (x1, y1) and the size is width i height i The following is the general repair process:
[0083] 1) Traverse all block elements in the page node page in ascending order of y value and x value, and then update the sorted DOM to the original DOM. In this way, the page to be relocated conforms to the normal reading order, that is, from top to bottom and from left to right.
[0084] 2) Detection block i and block j Is there any intersection between them? If there is no intersection, then: x i +width i <=x j or i +height i <=y j , other cases are crossovers, record the overlapping height diff (ij) =x i +height i -y i In this way, the diffs of two adjacent DOMs are detected and stored in an array of size n+1, diffs[n+1]. The first element of the array, diffs[1], is the diff of block1 and block2. The i-th element of the array, diffs[i], stores all the previous diffs[1]+diffs[2]+...diffs[i-1]+(block i and block j ) is the sum of the diffs between .
[0085] 3) Traverse all DOMs, add diffs[1] to y1 of DOM1, and add diffs[2] to y1 of DOM2. Repair all blocks one by one. Then the positions of all text blocks are correct, and there will be no overlap. The effect after repair is as follows Figure 4 shown.
[0086] Among them, for chart types, there may be multiple charts on a page. The implementation method is to use only one original picture. The charts in the translated text of this page use CSS styles, capture the pictures at the picture positions in the layout analysis, and embed them into the corresponding picture positions in the translated text to display the pictures. In this way, when the user reads the original text on the left, the original picture resources can be reused on the right to save space.
[0087] In one embodiment, optionally, the method further comprises:
[0088] Obtaining paragraph format information and column layout information of the file to be translated;
[0089] The paragraph format and column layout of the target translation are adjusted according to the paragraph format information and column layout information.
[0090] In this embodiment, the translated text layout can also be automatically adjusted, including the column layout adjustment and the paragraph format automatic adjustment. The present invention allows the customized translated text display page template, and the automatic adjustment program automatically adjusts the layout according to the translated text display page template style. For example, the first line indentation is achieved by inserting a fixed-width blank character in the first line of the translated text block after layout analysis; bold and black fonts are achieved through the font attribute corresponding to the DOM element; the centering effect is achieved by corresponding to the left value of the translated text through the left value of the layout analysis. If the translated text is too long and the text is not centered, the left value of the centered block will be automatically changed to achieve it; if the translated text is too long and causes line break, it is achieved by keeping the width consistent with the original text block and increasing the height; the relative paragraph spacing between paragraphs will also be consistent in the repair algorithm. The present invention fully considers the complex layout layout of the layout document page with single column, multi-column, and mixed typesetting, and can automatically adjust the layout of the translated text page according to the original layout. Through the results of layout analysis, single-column areas and multi-column areas with two or more columns in the page are found. The paragraph format of the single-column area can be automatically adjusted according to the above method; for multi-column reading, for example, the width of each column will be kept consistent with the original text, and the height will be increased to correspond to the additional translated text, so that the reading order is similar to the original version.
[0091] After the repair, you will get a complete reading result of the original and translated texts with no overlap and consistent layout. In this way, for PDF, CAJ and other layout documents with various layouts, the style attributes of the translated text and the original text will be consistent.
[0092] In the above embodiment, the layout analysis of the file to be translated is performed to obtain layout analysis result information; the layout analysis result information is divided into text information, non-text information and attribute information according to the document type; the text information and non-text information are translated and parsed accordingly to obtain parsing result information; an initial translation is generated according to each parsing result information, the attribute information and a preset translation template; the position of the text content in the initial translation is detected, and the target text with abnormal position is relocated to obtain the target translation. In the present invention, on the premise of achieving consistency in paragraph typesetting between the translation and the original text, the position of the text content in the translation can also be automatically detected, thereby repairing the text with abnormal position and relocating it, thereby avoiding manual position adjustment, thereby reducing user operations and improving user experience.
[0093] Through the above technical scheme, the present invention can simply and efficiently achieve consistent layout of the original text and the translated text, and realize efficient and fast translation and viewing effects for users. Since it is only necessary to traverse the results of the analysis once and then repair the position to achieve consistent layout of the original text and the translated text, the time complexity is O(n); at the same time, the lazy loading mechanism is adopted, which greatly simplifies the processing task and achieves smooth reading of the translated text. Because of the real-time rendering used, that is, what the user sees is what he gets, the final display effect of the translated text is the effect after repair, so that the translated text is accurate and has no overlap. At the same time, common display effects such as bold, black, indentation, font, and centering are retained, and the translation is more realistic and consistent
[0094] It should be understood that the order of execution of the steps in the above embodiment does not necessarily mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiment of the present invention.
[0095] Figure 5 A block diagram of a translation generating device for a translation file according to an embodiment of the present application is shown.
[0096] like Figure 5 As shown, in a second aspect, an embodiment of the present application provides a translation generating device 50 for translating a file, comprising:
[0097] An analysis module 51 is used to perform layout analysis on the document to be translated to obtain layout analysis result information;
[0098] A division module 52, used for dividing the layout analysis result information into text information, non-text information and attribute information according to the document type;
[0099] A processing module 53 is used to translate and analyze the text information and non-text information respectively to obtain analysis result information;
[0100] A generating module 54, for generating an initial translation according to each parsing result information, the attribute information and a preset translation template;
[0101] The relocation module 55 is used to detect the position of the text content in the initial translation and relocate the target text with abnormal position to obtain the target translation.
[0102] In one embodiment, optionally, the analysis module 51 includes:
[0103] A layout analysis unit, used to analyze the layout of each page of the file to be translated in order according to the page sequence of the file to be translated, so as to obtain the metadata XML information corresponding to each page;
[0104] The node division unit is used to divide the metadata XML information corresponding to each page into hierarchical nodes according to the XML hierarchical structure, wherein the hierarchical nodes include at least one of the following: page node, segment node, row node, picture node, table node and formula node, as well as attribute information corresponding to each node.
[0105] In one embodiment, optionally, the partitioning module is used to:
[0106] According to the hierarchical nodes, the first metadata XML information corresponding to the segment nodes and row nodes is divided into text information, the second metadata XML information corresponding to the picture nodes, table nodes and formula nodes is divided into non-text information, and the third metadata XML information corresponding to the attribute information of each node is divided into attribute information.
[0107] In one embodiment, optionally, the processing module includes:
[0108] A parsing unit, configured to parse the metadata XML information of all row nodes corresponding to each segment node in the first metadata XML information for the text information, and add the metadata XML information into a text array to obtain a text array set corresponding to the entire page of text;
[0109] A translation unit, used for performing text translation on the text array set to obtain a text translation;
[0110] A screenshot unit, configured to parse the metadata XML information of the picture node, the table node and the formula node in the second metadata XML information for the non-text information, determine the position information and the coordinate range information corresponding to each node in the form of an image tag, and capture the corresponding target image;
[0111] The tag generating unit is used to parse the third metadata XML information for the attribute information and generate corresponding structure tags in HTML.
[0112] In one embodiment, optionally, the generating module is used to:
[0113] According to the text translation, the image tag and the structure tag are marked in the preset translation template, and the corresponding text translation and target image are inserted into the preset translation template to generate the initial translation.
[0114] In one embodiment, optionally, the relocation module includes:
[0115] A sorting unit, used to sort the segment nodes of each page in the initial translation according to the attribute information corresponding to each segment node, to obtain a sorted result;
[0116] A determination unit, used to determine whether target areas corresponding to any two segment nodes intersect in order from top to bottom and from left to right;
[0117] The intersection processing unit is used to, when it is determined that there is an intersection, shift the segment nodes sorted later downward according to the intersection height until all segment nodes have no intersection.
[0118] In one embodiment, optionally, the device further comprises:
[0119] An acquisition module, used for acquiring paragraph format information and column layout information of the file to be translated;
[0120] The adjustment module is used to adjust the paragraph format and column layout of the target translation according to the paragraph format information and column layout information.
[0121] The specific definition of the translation generation device for the translation file can be found in the definition of the translation generation method for the translation file in the above text, which will not be repeated here. Each module in the above-mentioned translation generation device for the translation file can be implemented in whole or in part by software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory in the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
[0122] In one embodiment, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the following steps when executing the computer program:
[0123] Perform layout analysis on the document to be translated to obtain layout analysis result information;
[0124] Dividing the layout analysis result information into text information, non-text information and attribute information according to the document type;
[0125] Respectively translating and parsing the text information and the non-text information to obtain parsing result information;
[0126] Generate an initial translation according to each parsing result information, the attribute information and a preset translation template;
[0127] The position of the text content in the initial translation is detected, and the target text with abnormal position is relocated to obtain the target translation.
[0128] In one embodiment, optionally, a layout analysis is performed on the file to be translated to obtain layout analysis result information, including:
[0129] Analyze the layout of each page of the file to be translated in order according to the page number of the file to be translated, so as to obtain the metadata XML information corresponding to each page;
[0130] The metadata XML information corresponding to each page is divided into hierarchical nodes according to the XML hierarchical structure, wherein the hierarchical nodes include at least one of the following: page node, segment node, row node, picture node, table node and formula node, as well as attribute information corresponding to each node.
[0131] In one embodiment, optionally, the layout analysis result information is divided into text information, non-text information and attribute information according to the document type, including:
[0132] According to the hierarchical nodes, the first metadata XML information corresponding to the segment nodes and row nodes is divided into text information, the second metadata XML information corresponding to the picture nodes, table nodes and formula nodes is divided into non-text information, and the third metadata XML information corresponding to the attribute information of each node is divided into attribute information.
[0133] In one embodiment, optionally, the text information and the non-text information are translated and parsed respectively to obtain parsing result information, including:
[0134] For the text information, parse the metadata XML information of all row nodes corresponding to each segment node in the first metadata XML information, and add them into a text array to obtain a text array set corresponding to the entire page of text;
[0135] Performing text translation on the text array set to obtain a text translation;
[0136] For the non-text information, parse the metadata XML information of the picture node, the table node and the formula node in the second metadata XML information, determine the position information and the coordinate range information corresponding to each node in the form of an image tag, and capture the corresponding target image;
[0137] For the attribute information, parse the third metadata XML information and generate corresponding structure tags in HTML.
[0138] In one embodiment, optionally, generating an initial translation according to each parsing result information, the attribute information and a preset translation template includes:
[0139] According to the text translation, the image tag and the structure tag are marked in the preset translation template, and the corresponding text translation and target image are inserted into the preset translation template to generate the initial translation.
[0140] In one embodiment, optionally, performing position detection on the text content in the initial translation and relocating the target text with abnormal position to obtain the target translation includes:
[0141] According to the attribute information corresponding to each segment node, each segment node of each page in the initial translation is sorted to obtain a sorted result;
[0142] Determine whether the target areas corresponding to any two segment nodes intersect in order from top to bottom and from left to right;
[0143] When it is determined that there is an intersection, the segment nodes sorted later are shifted downward according to the intersection height until all segment nodes have no intersection.
[0144] In one embodiment, optionally, the method further comprises:
[0145] Obtaining paragraph format information and column layout information of the file to be translated;
[0146] The paragraph format and column layout of the target translation are adjusted according to the paragraph format information and column layout information.
[0147] It should be noted that the above functions or steps that can be implemented by the computer-readable storage medium or electronic device can refer to the relevant description in the aforementioned method embodiment. To avoid repetition, they will not be described one by one here.
[0148] It should be understood that the term "and / or" used in this article is only a description of the association relationship of associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the associated objects before and after are in an "or" relationship.
[0149] It should be understood that, although the terms first, second, etc. may be used to describe the setting unit in the embodiments of the present application, these setting units should not be limited to these terms. These terms are only used to distinguish the setting units from each other. For example, without departing from the scope of the embodiments of the present application, the first setting unit may also be referred to as the second setting unit, and similarly, the second setting unit may also be referred to as the first setting unit.
[0150] The word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining" or "in response to detecting", depending on the context. Similarly, the phrases "if it is determined" or "if (stated condition or event) is detected" may be interpreted as "when it is determined" or "in response to determining" or "when detecting (stated condition or event)" or "in response to detecting (stated condition or event)", depending on the context.
[0151] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0152] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of hardware plus software functional units.
[0153] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in the present application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0154] The embodiments described above are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included in the protection scope of the present invention.< / mainfont> < / rect> < / text> < / fontinfo> < / rect> < / block> < / page> < / pages>
Claims
1. A method for generating a translation of a translation file, characterized in that: include: Perform layout analysis on the document to be translated to obtain layout analysis result information; Dividing the layout analysis result information into text information, non-text information and attribute information according to the document type; Respectively translating and parsing the text information and the non-text information to obtain parsing result information; Generate an initial translation according to each parsing result information, the attribute information and a preset translation template; The position of the text content in the initial translation is detected, and the target text with abnormal position is relocated to obtain the target translation.
2. The method according to claim 1, characterized in that Perform layout analysis on the file to be translated to obtain layout analysis result information, including: Analyze the layout of each page of the file to be translated in order according to the page number of the file to be translated, so as to obtain the metadata XML information corresponding to each page; The metadata XML information corresponding to each page is divided into hierarchical nodes according to the XML hierarchical structure, wherein the hierarchical nodes include at least one of the following: page node, segment node, row node, picture node, table node and formula node, as well as attribute information corresponding to each node.
3. The method according to claim 2, characterized in that The layout analysis result information is divided into text information, non-text information and attribute information according to the document type, including: According to the hierarchical nodes, the first metadata XML information corresponding to the segment nodes and row nodes is divided into text information, the second metadata XML information corresponding to the picture nodes, table nodes and formula nodes is divided into non-text information, and the third metadata XML information corresponding to the attribute information of each node is divided into attribute information.
4. The method according to claim 3, characterized in that: The text information and the non-text information are translated and parsed respectively to obtain parsing result information, including: For the text information, parse the metadata XML information of all row nodes corresponding to each segment node in the first metadata XML information, and add them into a text array to obtain a text array set corresponding to the entire page of text; Performing text translation on the text array set to obtain a text translation; For the non-text information, parse the metadata XML information of the picture node, the table node and the formula node in the second metadata XML information, determine the position information and the coordinate range information corresponding to each node in the form of an image tag, and capture the corresponding target image; For the attribute information, parse the third metadata XML information and generate corresponding structure tags in HTML.
5. The method according to claim 4, characterized in that Generate an initial translation based on each parsing result information, the attribute information and a preset translation template, including: According to the text translation, the image tag and the structure tag are marked in the preset translation template, and the corresponding text translation and target image are inserted into the preset translation template to generate the initial translation.
6. The method according to claim 1, characterized in that Performing position detection on the text content in the initial translation and relocating the target text with abnormal position to obtain the target translation includes: According to the attribute information corresponding to each segment node, each segment node of each page in the initial translation is sorted to obtain a sorted result; Determine whether the target areas corresponding to any two segment nodes intersect in order from top to bottom and from left to right; When it is determined that there is an intersection, the segment nodes sorted later are shifted downward according to the intersection height until all segment nodes have no intersection.
7. The method according to any one of claims 1 to 6, characterized in that The method further comprises: Obtaining paragraph format information and column layout information of the file to be translated; The paragraph format and column layout of the target translation are adjusted according to the paragraph format information and column layout information.
8. A translation generating device for a translation file, characterized in that: include: An analysis module is used to perform layout analysis on the document to be translated to obtain layout analysis result information; A division module, used for dividing the layout analysis result information into text information, non-text information and attribute information according to document type; A processing module, used for translating and parsing the text information and non-text information respectively to obtain parsing result information; A generation module, used to generate an initial translation according to each parsing result information, the attribute information and a preset translation template; The relocation module is used to detect the position of the text content in the initial translation and relocate the target text with abnormal position to obtain the target translation.
9. A computer device, characterized in that: include: at least one processor; and, a memory communicatively coupled to the at least one processor; The memory stores instructions executable by the at least one processor, wherein the instructions are configured to execute the method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: Computer executable instructions are stored, and the computer executable instructions are used to execute the method according to any one of claims 1 to 7.