Table translation processing method and device, equipment and storage medium
By obtaining the table structure features and original content, splicing and constructing the translation table according to the cell order, the problem of semantic discontinuity in table translation is solved, and a translation table with high semantic accuracy and structural consistency is achieved.
Patent Information
- Application Number
- CN202510907545.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-01
- Publication Date
- 2025-10-17
AI Technical Summary
The existing technology fails to consider the positional relationship of cells in the table during the table translation process, resulting in semantic discontinuity and affecting the accuracy of the translation results.
By obtaining the structural feature information and original content of the table to be translated, splicing them in cell order, and using preset connection identifiers to construct the translation table, the consistency of the table structure is maintained.
The semantic accuracy and structural consistency of the translated table are improved, and the semantic discontinuity problem between cells is solved.
Smart Images

Figure CN120805941A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present disclosure relates to the field of data processing, and particularly relates to a table translation processing method and device, equipment and a storage medium. BACKGROUND
[0002] With the continuous development of data processing technology, tables are widely used in various fields, such as data organization and display, data analysis and processing, etc. A table is a two-dimensional data structure composed of rows and columns, and a cell is the basic unit for storing and displaying a single data item in the table, such as storing text, pictures and various types of data.
[0003] In the related art, in the process of table translation, the text in each cell is translated separately, without considering the positional relationship of the cells in the table, which leads to semantic rupture between the cells and affects the accuracy of the translation result. SUMMARY
[0004] In order to solve the above technical problems or at least partially solve the above technical problems, the present disclosure provides a table translation processing method, device, equipment and storage medium.
[0005] In a first aspect, the present disclosure provides a table translation processing method, which comprises:
[0006] obtaining a table to be translated and parsing the table to be translated to obtain table structure data; wherein the table structure data comprises structure feature information of a cell in the table to be translated and original text content in the cell, and the structure feature information of the cell is used to describe display structure features of the cell and / or a hierarchical relationship between elements in the cell and the table to be translated;
[0007] splicing the original text content in each cell in the table to be translated according to a cell order to obtain spliced original text content; wherein the spliced original text content has a preset connection identifier between the original text content corresponding to adjacent cells;
[0008] obtaining a translation result corresponding to the spliced original text content; wherein the translation result comprises translated text content with the preset connection identifier;
[0009] constructing a table according to the structure feature information of the cell in the table to be translated, and adding the translated text content with the preset connection identifier in the translation result to the corresponding cell in the table according to the cell order, to obtain a translated text table corresponding to the table to be translated.
[0010] In an optional embodiment, before splicing the original text contents in each cell in the table to be translated in cell order to obtain the spliced original text contents, the method further includes:
[0011] The table structure data is traversed, and if it is determined that a cell in which the structural feature information indicates a nested hierarchical relationship exists in the table structure data, a placeholder identifier is generated for the nested table in the cell, and the data of the nested table in the table structure data is replaced with the placeholder identifier, and the data of the nested table is recorded; wherein the data of the nested table is used to determine a translation table of the nested table.
[0012] In an optional embodiment, the step of adding the translation contents having the preset connection identifiers in the translation results to corresponding cells in the table according to the cell order to obtain a translation table corresponding to the table to be translated includes:
[0013] Adding the translation contents with the preset connection identifiers in the translation results to corresponding cells in the table according to the cell order;
[0014] Determine a cell in the table containing the placeholder identifier, obtain a translation table of a nested table corresponding to the placeholder identifier, and replace the placeholder identifier in the cell with the translation table of the nested table to obtain a translation table corresponding to the table to be translated.
[0015] In an optional embodiment, the table to be translated includes merged cells, and the structural feature information of the merged cells includes the number of rows and columns spanned and the row and column areas occupied. The step of constructing a table based on the structural feature information of the cells in the table to be translated includes:
[0016] The merged cells in the table are constructed according to the number of rows and columns spanned by the merged cells and the row and column areas occupied by the merged cells.
[0017] In an optional embodiment, the table structure data further includes format parameter information of the table to be translated, the format parameter information including at least one of table width, border style, and cell alignment. Constructing a table based on the structural feature information of cells in the table to be translated includes:
[0018] A table is constructed according to the structural feature information of the cells in the table to be translated and the format parameter information of the table to be translated.
[0019] In an optional implementation, obtaining the translation result corresponding to the spliced original content includes:
[0020] input the spliced original content into a translation model, and output a translation result after processing by the translation model.
[0021] In an alternative embodiment, before the splicing of the original content in each cell in the table to be translated in the order of the cells to obtain the spliced original content, the method further comprises:
[0022] determining whether the original content in each cell in the table to be translated exists in a cache, wherein the cache has pre-stored original-translation pairs;
[0023] determining a target cell corresponding to the original content existing in the cache, and determining the translation content corresponding to the target cell according to the original-translation pairs in the cache;
[0024] the splicing of the original content in each cell in the table to be translated in the order of the cells to obtain the spliced original content, comprising:
[0025] splicing the original content in the cells other than the target cell in the table to be translated in the order of the cells to obtain the spliced content.
[0026] In an alternative embodiment, there is at least one merged cell in the table to be translated, and the table structure data comprises the structural feature information of at least one contentless cell split from the merged cell.
[0027] In an alternative embodiment, after the obtaining of the translation result corresponding to the spliced original content, the method further comprises:
[0028] determining whether the first number of the preset connection identifiers contained in the translation result is the same as the second number of the preset connection identifiers contained in the spliced original content;
[0029] the construction of a table according to the structural feature information of the cells in the table to be translated, and the addition of the translation content with the preset connection identifiers in the translation result into the corresponding cells in the table in the order of the cells to obtain a translation table corresponding to the table to be translated, comprising:
[0030] if it is determined that the first number is the same as the second number, then constructing a table according to the structural feature information of the cells in the table to be translated, and adding the translation content with the preset connection identifiers in the translation result into the corresponding cells in the table in the order of the cells to obtain a translation table corresponding to the table to be translated.
[0031] In a second aspect, the present disclosure provides a table translation processing apparatus, the apparatus comprising:
[0032] a parsing module configured to obtain a table to be translated and parse the table to obtain table structure data, wherein the table structure data comprises structure feature information of a cell in the table to be translated and original content in the cell, and the structure feature information of the cell is used to describe display structure features of the cell and / or a hierarchical relationship between elements in the cell and the table to be translated;
[0033] a splicing module configured to splice original content in each cell in the table to be translated according to a cell order to obtain spliced original content, wherein the spliced original content comprises a preset connection identifier between original content corresponding to adjacent cells;
[0034] an obtaining module configured to obtain a translation result corresponding to the spliced original content, wherein the translation result comprises translated content with the preset connection identifier;
[0035] a constructing module configured to construct a table according to the structure feature information of the cell in the table to be translated, and add the translated content with the preset connection identifier in the translation result into corresponding cells in the table according to the cell order, to obtain a translated table corresponding to the table to be translated.
[0036] In a third aspect, the present disclosure provides an electronic device, the electronic device comprising: a processor; a memory configured to store executable instructions of the processor; and the processor configured to read the executable instructions from the memory and execute the instructions to implement the table translation processing method provided by the embodiments of the present disclosure.
[0037] In a fourth aspect, the present disclosure provides a computer-readable storage medium, the storage medium storing a computer program, and the computer program being configured to execute the table translation processing method provided by the embodiments of the present disclosure.
[0038] In a fifth aspect, the present disclosure provides a computer program product, the computer program product comprising computer programs / instructions, and the computer programs / instructions being configured to implement the above method when executed by a processor.
[0039] Compared with the prior art, the technical solutions provided by the embodiments of the present disclosure have at least the following advantages:
[0040] The table translation processing method provided by the embodiments of the present disclosure comprises the following steps: obtaining a table to be translated, and parsing the table to be translated to obtain table structure data, wherein the table structure data comprises structural feature information and original content of a cell in the table to be translated, and the structural feature information of the cell is used to describe display structural features of the cell and / or a hierarchical relationship between elements in the cell and the table to be translated; splicing the original content in each cell in the table to be translated according to a cell order to obtain spliced original content, wherein the spliced original content comprises a preset connection identifier between original content corresponding to adjacent cells; constructing a table according to the structural feature information of the cell in the table to be translated after obtaining a translation result corresponding to the spliced original content, and adding translated content with the preset connection identifier in the translation result to the corresponding cell in the table respectively according to the cell order to obtain a translated table corresponding to the table to be translated.
[0041] In the embodiments of the present disclosure, the original content in each cell in the table to be translated is spliced according to the cell order to form spliced original content with semantic association. Since the semantic of the spliced original content is relatively coherent, a translation result with high semantic accuracy can be obtained based on the spliced original content. In addition, the structural feature information of the cell obtained by parsing the table to be translated can be used to construct a translated table, so that the structure of the translated table is consistent with that of the table to be translated. It can be seen that the embodiments of the present disclosure can improve the semantic accuracy and structural consistency of the translated table. BRIEF DESCRIPTION OF DRAWINGS
[0042] The above and other features, advantages, and aspects of the embodiments of the present disclosure will become more apparent as various embodiments of the present disclosure are described in conjunction with the following detailed description, taken in conjunction with the accompanying drawings. Throughout the drawings, the same or similar reference numerals can represent the same or similar elements. It should be understood that the drawings are schematic, and the original and elements are not necessarily drawn according to the scale.
[0043] Figure 1 A flowchart of a table translation processing method provided by the embodiments of the present disclosure;
[0044] Figure 2 A flowchart of another table translation processing method provided by the embodiments of the present disclosure;
[0045] Figure 3 A structural schematic diagram of a table translation processing device provided by the embodiments of the present disclosure;
[0046] Figure 4 A structural schematic diagram of a table translation processing device provided by the embodiments of the present disclosure; DETAILED DESCRIPTION
[0047] Embodiments of the present disclosure will be described below in greater detail with reference to the accompanying drawings. While certain embodiments of the present disclosure are shown in the drawings, it is understood that the present disclosure can be embodied in various forms and should not be construed as being limited to the embodiments set forth herein, but rather, these embodiments are provided so as to more completely and thoroughly understand the present disclosure. It is understood that the drawings and embodiments of the present disclosure are only for illustrative purposes and are not intended to limit the scope of protection of the present disclosure.
[0048] It should be understood that each step described in the method embodiments of the present disclosure can be performed in different orders and / or in parallel. In addition, the method embodiments can include additional steps and / or omit the steps shown. The scope of the present disclosure is not limited in this respect.
[0049] The term "comprising" and variations thereof as used herein are open-ended, that is "including but not limited to". The term "based on" is "based, at least in part, on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". Related terms are defined in the following description.
[0050] It should be noted that the terms "first", "second", and the like in the present disclosure are only used to distinguish different devices, modules or units, and are not intended to limit the order or interdependence of the functions performed by these devices, modules or units.
[0051] It should be noted that the terms "one", "multiple" in the present disclosure are illustrative and not limiting, and those skilled in the art should understand that unless otherwise explicitly stated in the context, it should be understood as "one or more".
[0052] The names of the messages or information exchanged between the devices in the embodiments of the present disclosure are only for illustrative purposes, and are not intended to limit the scope of the messages or information.
[0053] With the continuous development of data processing technology, tables are widely used in various fields, such as data organization and display, data analysis and processing, etc. A table is a two-dimensional data structure composed of rows and columns, and a cell is the basic unit for storing and displaying a single data item in a table, such as text, pictures and various types of data.
[0054] In the related art, in the process of table translation, the text in each cell is translated separately, without considering the positional relationship of the cells in the table, resulting in semantic break between the cells and affecting the accuracy of the translation result.
[0055] To this end, the embodiment of the present disclosure provides a table translation processing method, first, a table to be translated is obtained, and the table to be translated is parsed to obtain table structure data, wherein the table structure data includes structure feature information of a cell in the table to be translated and original content, the structure feature information of the cell is used to describe display structure features of the cell and / or hierarchical relationship between elements in the cell and the table to be translated; then, the original content in each cell in the table to be translated is spliced according to a cell order to obtain spliced original content, and the spliced original content has a preset connection identifier between the original content corresponding to adjacent cells; after obtaining a translation result corresponding to the spliced original content, a table is constructed according to the structure feature information of the cell in the table to be translated, and the translated content with the preset connection identifier in the translation result is added to the corresponding cell of the table respectively, to obtain a translated table corresponding to the table to be translated.
[0056] In the embodiment of the present disclosure, the original content of each cell in the table to be translated is spliced according to the cell order to form spliced original content, and since there is a semantic correlation between the original content of each cell in the spliced original content, a translated table with high semantic accuracy can be obtained based on the spliced original content. In addition, the embodiment of the present disclosure constructs a translated table by using the structure feature information of the cell obtained by parsing the table to be translated, which can maintain the structural consistency of the translated table and the table to be translated. It can be seen that the embodiment of the present disclosure can improve the semantic accuracy and structural consistency of the translated table.
[0057] For ease of understanding, the embodiment of the present disclosure provides a table translation processing method, which can be executed by a table translation processing device. The device can be implemented by software and / or hardware, and can be integrated in an electronic device. Referring to Figure 1 The embodiment of the present disclosure provides a flowchart of a table translation processing method, wherein the method comprises:
[0058] S101: obtaining a table to be translated, and parsing the table to be translated to obtain table structure data.
[0059] The table structure data includes structure feature information of a cell in the table to be translated and original content in the cell, and the structure feature information of the cell is used to describe display structure features of the cell and / or hierarchical relationship between elements in the cell and the table to be translated.
[0060] The table translation processing method provided by the embodiment of the present disclosure can be applied to a client, for example, the client can include a client deployed on a smart phone, a client deployed on a tablet computer, etc.
[0061] Tables, as a data display method, are widely used in various types of documents, such as patent documents, thesis documents in word format, etc. In the process of translating a document, the content of the table in the document is usually translated.
[0062] The table to be translated in the embodiments of the present disclosure can be any table in the document, such as a nested table containing a sub-table in a cell, a table with merged cells, a table with a complex border style, a table with a formula, a picture or other elements embedded in a cell, etc.
[0063] In the embodiments of the present disclosure, after obtaining the table to be translated from the document, the table to be translated is first parsed to obtain table structure data, wherein the table structure data can include structure feature information of each cell in the table to be translated, original content stored in each cell, etc.
[0064] The structure feature information of the cell can be used to describe at least one of the display structure feature of the cell and the hierarchical relationship between the elements in the cell and the table to be translated, wherein the display structure feature of the cell is used to describe whether the cell is a merged cell. For example, if the value corresponding to the display structure feature is true, it indicates that the cell is a merged cell, i.e., the elements in the cell are merged into adjacent cells, and if the value corresponding to the display structure feature is false, it indicates that the cell is a main cell, i.e., an unmerged cell or a merged cell containing text content.
[0065] In the embodiments of the present disclosure, the structure feature information of the cell can also be used to describe the hierarchical relationship between the elements in the cell and the table to be translated. For example, if the elements in a cell in the table to be translated include a table, it indicates that the table (i.e., a sub-table) in the cell and the table to be translated (i.e., a parent table) have a nested hierarchical relationship, and the sub-table in the cell is also called a nested table.
[0066] In an alternative embodiment, the table to be translated can also be parsed using a parsing library or a parsing algorithm to obtain a table JSON object containing nested hierarchy and merging attributes, and the table JSON object includes the table structure data. Wherein, JSON (JavaScript Object Notation) is a lightweight data exchange format, and a JSON object usually includes multiple fields, so the fields in the table JSON object can be used to identify the structure feature information of the cell, for example, field A can be used to identify whether the cell is a merged cell, and field B can be used to identify the number of columns of the merged cell, etc.
[0067] It can be seen that, by parsing the table to be translated to obtain the corresponding table structure data, the table structure data is used to accurately describe the hierarchical relationship, merging attribute, format parameter and the like contained in the table to be translated. Subsequently, when the table is translated, the table structure data can also be used to construct the table according to the structure feature information of each cell, so that the translated table consistent with the structure of the table to be translated is obtained.
[0068] In S102, the original content in each cell in the table to be translated is spliced in the order of the cells to obtain spliced original content.
[0069] In the spliced original content, the original content corresponding to adjacent cells has a preset connection identifier.
[0070] In the embodiment of the present disclosure, after the table to be translated is parsed to obtain the table structure data, the original content of each cell in the table to be translated is spliced in the order of the cells to obtain spliced original content. Since the semantics of the original content of each cell in the spliced original content is associated, a translated table with high semantic accuracy can be obtained based on the spliced original content.
[0071] In the embodiment of the present disclosure, the original content corresponding to adjacent cells in the spliced original content has a preset connection identifier. For example, the spliced original content can be represented as "original content of cell 1┄original content of cell 2┄original content of cell 3". Obviously, by using the preset connection relationship, the original content corresponding to each cell in the table to be translated can be effectively distinguished.
[0072] In an optional embodiment, there can be at least one merged cell in the table to be translated. Since the merged cell is obtained by merging multiple cells, when the table to be translated containing the merged cell is parsed, a cell containing original content and at least one cell without content can be parsed, wherein the cell containing original content is also called a main cell, and the cell without content is also called a merged cell. The original content in the merged cell is merged into the main cell, and there is no content to be translated in the cell without content.
[0073] Therefore, for the table to be translated containing at least one merged cell, the structure feature information of at least one cell without content split from the merged cell can be included in the corresponding table structure data. For example, if the display structure feature in the structure feature information of a cell corresponds to true, the cell is identified as a cell without content, i.e., there is no content to be translated in the cell.
[0074] In an alternative embodiment, before splicing the original content in each cell in the table to be translated, the cells without content can also be filtered out. Specifically, first, it is determined whether there are cells without content (i.e., merged cells) in the table to be translated. If it is determined that there are cells without content in the table to be translated, the cells without content are filtered out, that is, only the cells with original content in the table to be translated are spliced to obtain the spliced original content.
[0075] S103: Obtain the translation result corresponding to the spliced original content.
[0076] In the translation result, the translated content with the preset connection identifier is included.
[0077] In the embodiments of the present disclosure, since the original content of adjacent cells in the spliced original content is connected by using the preset connection identifier, in the translation result obtained based on the spliced original content, the translated content of adjacent cells also needs to be spliced by using the preset connection identifier, so as to separate the respective translated content of each cell by using the preset connection identifier.
[0078] Since the spliced original content is a semantically associated long text obtained by splicing the original content of each cell, in the process of translating the spliced original content, the original content of each cell is translated in combination with the context information (i.e., the original content of adjacent cells). Obviously, this way of translating the content of the table by using the semantically associated long text can improve the semantic accuracy of the translation result of the table.
[0079] In an alternative embodiment, after obtaining the spliced original content, the spliced original text can also be input into a translation model, and the translation result is output after processing by the translation model. Since the translation model is obtained by training a large amount of data, it can more accurately grasp the semantic association in long text by learning complex language patterns and rules. Therefore, processing the spliced original content by using the translation model can further improve the semantic accuracy of the translation result of the table.
[0080] S104: Construct a table according to the structure feature information of the cells in the table to be translated, and add the translated content with the preset connection identifier in the translation result to the corresponding cells in the table according to the cell sequence, to obtain the translated table corresponding to the table to be translated.
[0081] In the embodiments of the present disclosure, since the parsed table structure data includes the structural feature information for describing the merging attribute and hierarchical relationship of the cells, after obtaining the translation result corresponding to the spliced original text content, the table can be constructed according to the structural feature information of the cells, so that the structure of the translation table is consistent with the structure of the table to be translated, thereby solving the problems of nested hierarchical loss and merging errors in the related art.
[0082] In the embodiments of the present disclosure, in the process of constructing the table according to the structural feature information of the cells in the table to be translated, the translation content with the preset connection identifier in the translation result can also be added to the corresponding cells in the table according to the cell order, so as to obtain the translation table corresponding to the table to be translated.
[0083] In an optional implementation, the table to be translated includes at least one merged cell, and the structural feature information corresponding to the merged cell can include the number of crossed rows, the number of crossed columns, and the occupied row and column area. The number of crossed rows refers to the number of rows crossed by the merged cell, indicating the number of rows extending downward from the starting row of the merged cell; the number of crossed columns refers to the number of columns crossed by the merged cell, indicating the number of columns extending to the right from the starting column of the merged cell; and the occupied row and column area indicates the range of rows and columns covered by the merged cell in the table to be translated.
[0084] In the embodiments of the present disclosure, for the table to be translated containing the merged cell, in the process of constructing the translation table corresponding to the table to be translated, the merged cell in the table can be constructed according to the number of crossed rows, the number of crossed columns, and the occupied row and column area of the merged cell included in the structural feature information.
[0085] In another optional implementation, the table structure data can also include table parameter information of the table to be translated, wherein the table parameter information of the table to be translated can include at least one of the table width and height, the border style, and the cell alignment mode, for example. The table width and height refer to the horizontal size and vertical size of the table to be translated. The border style includes the width, color, and line style of the table border, such as solid line, dashed line, and dotted line. The cell alignment mode includes horizontal alignment (left alignment, center alignment, and right alignment) and vertical alignment (top alignment, center alignment, and bottom alignment).
[0086] In the embodiments of the present disclosure, in the process of reconstructing the translation table corresponding to the table to be translated, the table can also be constructed according to the structural feature information (nested hierarchical relationship and merging attribute) of the cells in the table to be translated and the format parameter information (table width and height, border style, and cell alignment mode) of the table to be translated.
[0087] It can be seen that the embodiment of the present disclosure can parse the to-be-translated table containing nested tables, merged cells and other structures with relatively complex structures, and retain the table level relationship, merging attribute, format parameter and other information in the translation process, to ensure the structural integrity and format consistency of the translated table. Specifically, in the process of parsing the to-be-translated table and reconstructing the translated table, the hierarchical relationship of the nested table in the to-be-translated table is extracted, the cross-row number, cross-column number, occupied row and column area and other information of the merged cell are recorded, and the format attributes of the to-be-translated table such as table width and height, border style and cell alignment are retained, so that the translated table has consistent structure with the to-be-translated table.
[0088] In the table translation processing method provided by the embodiment of the present disclosure, first, the to-be-translated table is obtained, and the to-be-translated table is parsed to obtain table structure data, wherein the table structure data includes the structure feature information and the original content of the cells in the to-be-translated table, and the structure feature information of the cells is used to describe the display structure feature of the cells and / or the hierarchical relationship between the elements in the cells and the to-be-translated table. Then, the original content in each cell in the to-be-translated table is spliced according to the cell order to obtain spliced original content, and the original content corresponding to the spliced original content has a preset connection identifier between the original content corresponding to adjacent cells in the spliced original content. After obtaining the translation result corresponding to the spliced original content, a table is constructed according to the structure feature information of the cells in the to-be-translated table, and the translated content with the preset connection identifier in the translation result is added to the corresponding cells in the table according to the cell order, to obtain the translated table corresponding to the to-be-translated table.
[0089] In the embodiment of the present disclosure, the original content of each cell in the to-be-translated table is spliced according to the cell order to form the spliced original content with semantic association. Since the semantics of the spliced original content is relatively coherent, a translation result with high semantic accuracy can be obtained based on the spliced original content. In addition, the structure feature information of the cells obtained by parsing the to-be-translated table is used to construct the translated table, which can keep the structure of the translated table consistent with the structure of the to-be-translated table. It can be seen that the embodiment of the present disclosure can improve the semantic accuracy and structural consistency of the translated table.
[0090] In the process of table translation, since the related technology cannot identify the hierarchical relationship of the nested table, the key structure information is lost during translation. Therefore, the embodiment of the present disclosure can also preprocess the nested table in the to-be-translated table before splicing the original content in each cell in the to-be-translated table, so that the structure position information of the nested table in the to-be-translated table can be referred to in the subsequent translation process of the nested table, thereby reducing the translation ambiguity problem caused by the loss of structure information and further improving the accuracy of the translation result.
[0091] In the embodiments of the present disclosure, after the table structure data is obtained by parsing the table to be translated, the table structure data is first traversed to determine whether there is a cell with structure feature information indicating a nested hierarchical relationship in the table structure data; if it is determined that there is a cell with structure feature information indicating a nested hierarchical relationship in the table structure data, a placeholder identifier is generated for the nested table in the cell, and the data of the nested table in the table structure data is replaced by using the placeholder identifier, and the data of the nested table is recorded.
[0092] The data of the nested table can be used to determine the translation table of the nested table. The data of the nested table can include structure feature information of a cell in the nested table and original content in the cell, and the structure feature information of the cell is used to describe the display structure feature of the cell and / or the hierarchical relationship between an element in the cell and the nested table. The placeholder identifier is used to uniquely identify the nested table, and can include a table identifier ID of the nested table, a custom label, a universally unique identifier UUID, etc.
[0093] In an optional implementation, the translation table of the nested table can be determined in the following manner:
[0094] First, the original content in each cell of the nested table is spliced in the order of the cells to obtain spliced original content corresponding to the nested table, wherein the original content corresponding to adjacent cells in the spliced original content has a preset connection identifier; then a translation result corresponding to the spliced original content, i.e., a translation result corresponding to the nested table, is obtained; then, a table is constructed according to the structure feature information of the cells in the nested table, and the translation content with the preset connection identifier in the translation result corresponding to the nested table is added to the cells corresponding to the table according to the order of the cells, to obtain the translation table of the nested table.
[0095] In actual applications, it can also be determined based on a specified field whether there is a cell with structure feature information indicating a nested hierarchical relationship in the table structure data. For example, the table JSON object of the table to be translated is traversed, and if it is determined that the “nested table” field in the table JSON object records data such as a table identifier, it is indicated that there is a nested table in the table to be translated. At this time, a placeholder identifier, such as {{{#002}}}, is generated for the nested table, and the data of the nested table in the table structure data is replaced by using the placeholder identifier.
[0096] In the embodiments of the present disclosure, after obtaining the translation result of the table to be translated, first, the translation content with the preset connection identifier in the translation result is added to the corresponding cell in the table according to the cell order; then, the cell with the placeholder identifier in the table is determined, and the translation table of the nested table corresponding to the placeholder identifier is obtained, and the data of the nested table is replaced with the placeholder identifier in the cell to obtain the translation table corresponding to the table to be translated.
[0097] In an optional implementation, after the data of the nested table is replaced with the placeholder identifier in the table structure data, the data of the nested table can also be stored in the target table array.
[0098] The target table array stores the table to be translated after the data of the nested table is replaced with the placeholder identifier, and the nested table extracted from the table to be translated. Obviously, the target table array constructed by the above method is a one-dimensional table array, which can realize the flat representation of the nested structure, and the nested level of the translation table can be restored based on the table data stored in the target table array.
[0099] In another optional implementation, after obtaining the translation result corresponding to the spliced original text content, first, the translation content with the preset connection identifier in the translation result is added to the table data according to the cell order to obtain the translation table data; then, the translation table data is traversed, and if it is determined that the translation table data includes the placeholder identifier, the data of the corresponding nested table is obtained from the target table array according to the table ID identified by the placeholder identifier, and the data of the nested table is inserted into the translation table data according to the original coordinates to obtain the table structure data; then, the table is reconstructed according to the table structure data to obtain the translation table corresponding to the table to be translated.
[0100] In the embodiments of the present disclosure, since the table structure data of the translation table includes the structure feature information of the cell and the translation content in the cell, the translation table consistent with the structure of the table to be translated can be obtained based on the table structure data.
[0101] In actual application, in the process of processing the spliced original text content by using the translation model, in order to reduce the calling frequency of the translation model and reduce the consumption of computing resources, the cached translation of the same original text content can also be used to improve the translation efficiency of the model.
[0102] In the disclosed embodiment, it is first determined whether the original text content in each cell in the table to be translated exists in the cache; then, the cell corresponding to the original text content existing in the cache is determined as the target cell, and the translation content corresponding to the target cell is determined based on the original text translation in the cache; then, the original text contents of the other cells in the table to be translated except the target cell are spliced in cell order to obtain the spliced original text content; further, the spliced original text content is input into the translation model, and the translation result is input after being processed by the translation model.
[0103] The cache pre-stores source-text translation pairs, such as "claim" and "claims." For example, assuming the table to be translated includes cells A, B, and C, and upon determining that the source text "claim" in cell B exists in the cache, the corresponding translation for cell B, "claims," is directly retrieved from the cached source-text translation pairs. Clearly, this cached translation approach for identical source text improves translation efficiency while ensuring consistent translation.
[0104] Then, the original contents of the cells in the translation table except cell B are concatenated in cell order to obtain the concatenated original content "original content of cell A - original content of cell C". The concatenated original content is then input into the translation model, and the corresponding translation result is output after processing by the translation model.
[0105] In an optional implementation, to ensure semantic coherence between the original text content of each cell, it is also possible to determine whether the original text content in each cell exists in the cache during the process of obtaining the spliced original text content and translating the spliced original text content. In other words, the disclosed embodiment can first obtain the structurally complete spliced original text content and then determine whether the original text content in each cell exists in the cache.
[0106] For cells corresponding to original text content in the cache, the corresponding translated content can be directly obtained from the cache. Moreover, the translated content can also be used as context information to assist in translating the original text content of other cells, thereby further improving the semantic accuracy of the translation results.
[0107] In the disclosed embodiment, for a cell whose original content exists in the cache, the translated content corresponding to the cell can be directly obtained from the cache without using the translation model to translate the original content of the cell again. This can reduce the frequency of calling the translation model and the consumption of computing resources. At the same time, for the same original content, the uniformity of the translated content can also be guaranteed.
[0108] In an alternative embodiment, after obtaining the translation result corresponding to the spliced original text content, the translation result can be verified to ensure that each cell in the spliced original text content has a translated text content.
[0109] In the embodiments of the present disclosure, first, it is determined whether the first number of preset connection identifiers contained in the translation result is the same as the second number of preset connection identifiers contained in the spliced original text content; if it is determined that the first number is the same as the second number, a table is constructed according to the structure feature information of the cells in the table to be translated, and the text content with the preset connection identifier in the translation result is added to the corresponding cell in the table according to the cell order, to obtain a translated text table corresponding to the table to be translated.
[0110] For example, assuming that the spliced original text content is "original text content of cell A-original text content of cell B-original text content of cell C", and the translation result is "translated text content of cell A-translated text content of cell B-translated text content of cell C", it can be determined that the first number of preset connection identifiers contained in the translation result is the same as the second number of preset connection identifiers contained in the spliced original text content, and at this time, the above text content is added to the corresponding cell in the table according to the cell order, to obtain a translated text table corresponding to the table to be translated.
[0111] In addition, if it is determined that the first number is not the same as the second number, the translation result corresponding to the spliced original text content is re-obtained until the retry number reaches a preset threshold (for example, 5 times), or a translation result with the same first number and second number is obtained.
[0112] It can be seen that, by combining the translation result number verification and the retry strategy, the embodiments of the present disclosure can ensure that the original text content in each cell of the table to be translated has a translated text content.
[0113] As shown in FIG. 6, another flowchart of the table translation processing provided by the embodiments of the present disclosure is shown. Figure 2
[0114] S201: Obtain a table to be translated, and parse the table to be translated to obtain table structure data.
[0115] The table structure data includes the structure feature information of the cells in the table to be translated and the original text content in the cells, and the structure feature information of the cells is used to describe the display structure feature of the cells and / or the hierarchical relationship between the elements in the cells and the table to be translated.
[0116] It can be seen that, by analyzing the to-be-translated table to obtain corresponding table structure data, the table structure data is used to accurately describe the hierarchical relationship, merging attribute and format parameter and the like contained in the to-be-translated table, and subsequently, when the table is translated, the table can also be constructed according to the structure feature information of each cell in the table structure data, so that a translation table consistent with the structure of the to-be-translated table is obtained.
[0117] S202: The table structure data is traversed, and if it is determined that there is a cell in the table structure data indicating a nested hierarchical relationship, a placeholder identifier is generated for a nested table in the cell, data of the nested table in the table structure data is replaced by the placeholder identifier, and the data of the nested table is recorded.
[0118] The data of the nested table is used to determine a translation table of the nested table.
[0119] It can be seen that the embodiment of the present disclosure can realize the flat representation of the nested structure, so that the nested level of the translation table can be restored based on the table data stored in the target table array subsequently.
[0120] S203: The original content in each cell in the to-be-translated table is spliced in the order of the cells to obtain spliced original content.
[0121] The spliced original content has a preset connection identifier between the original content corresponding to adjacent cells.
[0122] In the embodiment of the present disclosure, after the table structure data is obtained by analyzing the to-be-translated table, the original content in each cell in the to-be-translated table is spliced in the order of the cells to obtain spliced original content. Since the semantics between the original content of each cell in the spliced original content is associated, a translation table with high semantic accuracy can be obtained based on the spliced original content.
[0123] S204: The spliced original content is input into a translation model, and a translation result is output after processing by the translation model.
[0124] S205: According to the order of the cells, the translation content with the preset connection identifier in the translation result is added to the corresponding cell in the table.
[0125] S206: A cell with the placeholder identifier in the table is determined, a translation table of a nested table corresponding to the placeholder identifier is obtained, the translation table of the nested table is used to replace the placeholder identifier in the cell, and a translation table corresponding to the to-be-translated table is obtained.
[0126] In the embodiments of the present disclosure, the original content in each cell in the table to be translated is spliced in the order of the cells to form spliced original content with semantic association. Since the spliced original content has relatively coherent semantics, a translation result with high semantic accuracy can be obtained based on the spliced original content. In addition, the embodiments of the present disclosure construct a translation table by using the structural feature information of the cells obtained by analysis, so that the structural consistency of the translation table and the table to be translated can be maintained.
[0127] To implement the above-mentioned embodiments, the present disclosure further provides a table translation processing device. Figure 3 A structural schematic diagram of a table translation processing device provided by the embodiments of the present disclosure is shown in the figure. The device can be implemented by software and / or hardware, and can be integrated in an electronic device. As shown in the figure, the device comprises: Figure 3
[0128] The analysis module 301 is configured to obtain a table to be translated and analyze the table to obtain table structure data. The table structure data comprises structural feature information of cells in the table to be translated and original content in the cells. The structural feature information of the cells is used to describe display structural features of the cells and / or hierarchical relationships between elements in the cells and the table to be translated.
[0129] The splicing module 302 is configured to splice the original content in each cell in the table to be translated in the order of the cells to obtain spliced original content. In the spliced original content, the original content corresponding to adjacent cells has a preset connection identifier.
[0130] The obtaining module 303 is configured to obtain a translation result corresponding to the spliced original content. The translation result comprises translation content with the preset connection identifier.
[0131] The construction module 304 is configured to construct a table according to the structural feature information of the cells in the table to be translated, and add the translation content with the preset connection identifier in the translation result into corresponding cells in the table in the order of the cells to obtain a translation table corresponding to the table to be translated.
[0132] In an optional implementation, the device further comprises:
[0133] The replacement module is configured to traverse the table structure data, determine whether a cell in the table structure data has the structure feature information indicating the nested level relationship, generate a placeholder identifier for a nested table in the cell if the cell has the structure feature information indicating the nested level relationship, replace data of the nested table in the table structure data with the placeholder identifier, and store data of the nested table in the target table array.
[0134] In an optional implementation, the construction module comprises:
[0135] The adding submodule is configured to add the translated content with the preset connection identifier in the translation result into the corresponding cell in the table according to the cell order.
[0136] The replacement submodule is configured to determine a cell in the table having the placeholder identifier, obtain data of a nested table corresponding to the placeholder identifier from the target table array, and replace the placeholder identifier in the cell with the data of the nested table to obtain the translated table corresponding to the table to be translated.
[0137] In an optional implementation, the table to be translated comprises a merged cell, and structure feature information of the merged cell comprises a number of crossed rows, a number of crossed columns, and an occupied row-column region. The construction module comprises:
[0138] The first construction submodule is configured to construct the merged cell in the table according to the number of crossed rows, the number of crossed columns, and the occupied row-column region of the merged cell.
[0139] In an optional implementation, the table structure data further comprises format parameter information of the table to be translated, and the format parameter information comprises at least one of a table width, a border style, and a cell alignment mode. The construction module comprises:
[0140] The second construction submodule is configured to construct the table according to the structure feature information of the cell in the table to be translated and the format parameter information of the table to be translated.
[0141] In an optional implementation, the obtaining module comprises:
[0142] The input submodule is configured to input the spliced original content into a translation model, and output a translation result after processing by the translation model.
[0143] In an optional implementation, the apparatus further comprises:
[0144] The first determination module is configured to determine whether the original content in each cell in the table to be translated exists in a cache. The cache pre-stores original-translation pairs.
[0145] The second determining module is configured to determine a cell corresponding to the original content in the cache as a target cell, and determine the translated content corresponding to the target cell according to the original-translation pair in the cache;
[0146] The splicing module comprises:
[0147] The splicing sub-module is configured to splice the original content of the cells other than the target cell in the table to be translated according to the cell order, to obtain the spliced content.
[0148] In an optional implementation, the table to be translated comprises at least one merged cell, and the table structure data comprises structure feature information of at least one content-free cell split from the merged cell.
[0149] In an optional implementation, the apparatus further comprises:
[0150] The third determining module is configured to determine whether a first number of the preset connection identifiers contained in the translation result is the same as a second number of the preset connection identifiers contained in the spliced original content.
[0151] The constructing module comprises:
[0152] The third constructing sub-module is configured to, if it is determined that the first number is the same as the second number, construct a table according to the structure feature information of the cells in the table to be translated, and add the translated content with the preset connection identifier in the translation result into the corresponding cells in the table according to the cell order, to obtain a translated table corresponding to the table to be translated.
[0153] In the table translation processing apparatus provided by the embodiments of the present disclosure, first, a table to be translated is acquired, and the table to be translated is parsed to obtain table structure data, wherein the table structure data comprises structure feature information of cells in the table to be translated and original content, and the structure feature information of the cells is used to describe display structure features of the cells and / or a hierarchical relationship between elements in the cells and the table to be translated; then, the original content in each cell in the table to be translated is spliced according to a cell order, to obtain spliced original content, and the spliced original content comprises a preset connection identifier between the original content corresponding to adjacent cells; after a translation result corresponding to the spliced original content is acquired, a table is constructed according to the structure feature information of the cells in the table to be translated, and translated content with the preset connection identifier in the translation result is added into corresponding cells in the table according to the cell order, to obtain a translated table corresponding to the table to be translated.
[0154] In the embodiments of the present disclosure, the original content of each cell in the table to be translated is spliced in the order of the cells to form spliced original content with semantic association. Since the semantic of the spliced original content is relatively coherent, a translation result with high semantic accuracy can be obtained based on the spliced original content. In addition, the structure consistency of the translation table and the table to be translated can be maintained by constructing the translation table by using the structure feature information of the parsed cells. It can be seen that the embodiments of the present disclosure can improve the semantic accuracy and structure consistency of the translation table.
[0155] In addition to the above method and device, the embodiments of the present disclosure further provide a computer readable storage medium, which stores instructions. When the instructions are run on a terminal device, the terminal device implements the table translation processing method provided by the embodiments of the present disclosure.
[0156] The embodiments of the present disclosure further provide a computer program product, which includes computer programs / instructions. When the computer programs / instructions are executed by a processor, the table translation processing method provided by the embodiments of the present disclosure is implemented.
[0157] In addition, the embodiments of the present disclosure further provide a table translation processing device, which can include Figure 4 as shown, and can include:
[0158] The table translation processing device can include one or more processors 401, memories 402, input devices 403 and output devices 404. Figure 4 In some embodiments of the present disclosure, the processor 401, the memory 402, the input device 403 and the output device 404 can be connected by a bus or other means. Figure 4 In some embodiments of the present disclosure, the processor 401, the memory 402, the input device 403 and the output device 404 can be connected by a bus or other means.
[0159] The memory 402 can be used to store software programs and modules. The processor 401 executes various functions and data processing of the table translation processing device by running the software programs and modules stored in the memory 402. The memory 402 can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, at least one application required by a function, etc. In addition, the memory 402 can include a high-speed random access memory, and can also include a non-volatile memory, such as at least one magnetic disk storage device, a flash memory device, or other volatile solid-state memory device. The input device 403 can be used to receive input digital or character information, and generate signal input related to user settings and function control of the table translation processing device.
[0160] Specifically in the present embodiment, the processor 401 loads the executable file corresponding to the process of one or more applications into the memory 402 according to the following instructions, and runs the application stored in the memory 402 by the processor 401, thereby realizing the various functions of the above-described table translation processing device.
[0161] It should be noted that the relational terms herein such as first and second and the like can be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any such actual relationship or order between such entities or actions. Moreover, the terms "comprises", "comprising", or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but can include other elements not expressly listed or inherent to such process, method, article, or apparatus. An element proceeded by "comprises... a" does not, without more constraints, exclude the existence of additional identical elements in the process, method, article, or apparatus that comprises the element.
[0162] The above description is merely that of the specific implementations of the present disclosure, to enable a person skilled in the art to understand or implement the present disclosure. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present disclosure. Therefore, the present disclosure will not be limited to these embodiments described herein, but is intended to conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A table translation processing method, characterized in that: The method comprises: Obtaining a table to be translated and parsing the table to be translated to obtain table structure data; wherein the table structure data includes structural feature information of cells in the table to be translated and original text content in the cells, the structural feature information of the cells being used to describe display structural features of the cells and / or a hierarchical relationship between elements in the cells and the table to be translated; splicing the original text contents in each cell in the table to be translated in cell order to obtain spliced original text contents; wherein the original text contents corresponding to adjacent cells in the spliced original text contents are respectively connected with a preset connection mark; Obtaining a translation result corresponding to the spliced original content; wherein the translation result includes the translated content with the preset connection identifier; A table is constructed according to the structural feature information of the cells in the table to be translated, and the translation contents with the preset connection identifiers in the translation results are added to the corresponding cells in the table according to the cell order to obtain a translation table corresponding to the table to be translated.
2. The table translation processing method according to claim 1, characterized in that: Before splicing the original text contents in each cell in the table to be translated in cell order to obtain the spliced original text contents, the method further includes: The table structure data is traversed, and if it is determined that a cell in which the structural feature information indicates a nested hierarchical relationship exists in the table structure data, a placeholder identifier is generated for the nested table in the cell, and the data of the nested table in the table structure data is replaced with the placeholder identifier, and the data of the nested table is recorded; wherein the data of the nested table is used to determine a translation table of the nested table.
3. The table translation processing method according to claim 2, characterized in that: The step of adding the translation contents having the preset connection identifiers in the translation results to corresponding cells in the table according to the cell sequence to obtain a translation table corresponding to the table to be translated includes: Adding the translation contents with the preset connection identifiers in the translation results to corresponding cells in the table according to the cell order; Determine a cell in the table containing the placeholder identifier, obtain a translation table of a nested table corresponding to the placeholder identifier, and replace the placeholder identifier in the cell with the translation table of the nested table to obtain a translation table corresponding to the table to be translated.
4. The method according to claim 1, wherein The table to be translated includes merged cells, and structural feature information of the merged cells includes the number of rows and columns spanned and the row and column areas occupied. The step of constructing a table based on the structural feature information of the cells in the table to be translated includes: The merged cells in the table are constructed according to the number of rows and columns spanned by the merged cells and the row and column areas occupied by the merged cells.
5. The method according to claim 1, wherein The table structure data further includes format parameter information of the table to be translated, wherein the format parameter information includes at least one of table width and height, border style, and cell alignment. The step of constructing a table based on the structural feature information of cells in the table to be translated includes: A table is constructed according to the structural feature information of the cells in the table to be translated and the format parameter information of the table to be translated.
6. The method according to claim 1, characterized in that The obtaining of the translation result corresponding to the spliced original content includes: The spliced original text content is input into the translation model, and the translation result is output after being processed by the translation model.
7. The method according to claim 6, characterized in that Before splicing the original text contents in each cell in the table to be translated in cell order to obtain the spliced original text contents, the method further includes: Determining whether the original text content in each cell of the table to be translated exists in a cache; wherein the cache pre-stores original text and translation pairs; Determine a cell corresponding to the original text content in the cache as a target cell, and determine the translation content corresponding to the target cell based on the original text translation pair in the cache; The process of splicing the original text contents in each cell of the table to be translated in the order of cells to obtain the spliced original text contents includes: The original text contents of the cells other than the target cell in the table to be translated are spliced in cell order to obtain spliced original text contents.
8. The method according to claim 1, characterized in that There is at least one merged cell in the table to be translated, and the table structure data includes structural feature information of at least one content-free cell split from the merged cell.
9. The method according to claim 1, characterized in that After obtaining the translation result corresponding to the spliced original content, the method further includes: Determining whether a first number of the preset connection identifiers included in the translation result is the same as a second number of the preset connection identifiers included in the spliced original content; The step of constructing a table according to the structural feature information of the cells in the table to be translated, and adding the translation contents having the preset connection identifiers in the translation results to the corresponding cells in the table according to the cell order, to obtain a translation table corresponding to the table to be translated, includes: If it is determined that the first quantity is the same as the second quantity, a table is constructed according to the structural feature information of the cells in the table to be translated, and the translation contents with the preset connection identifiers in the translation results are added to the corresponding cells in the table according to the cell order to obtain a translation table corresponding to the table to be translated.
10. A table translation processing device, characterized in that: The device comprises: a parsing module, configured to obtain a table to be translated and parse the table to be translated to obtain table structure data; wherein the table structure data includes structural feature information of cells in the table to be translated and the original content within the cells, the structural feature information of the cells being used to describe the display structural features of the cells and / or the hierarchical relationship between the elements within the cells and the table to be translated; a splicing module for splicing the original text contents in each cell of the table to be translated in cell order to obtain spliced original text contents; wherein the original text contents corresponding to adjacent cells in the spliced original text contents are connected by preset connection marks; An acquisition module, configured to acquire a translation result corresponding to the spliced original content; wherein the translation result includes the translated content having the preset connection identifier; A construction module is used to construct a table according to the structural feature information of the cells in the table to be translated, and add the translation content with the preset connection identifier in the translation result to the corresponding cells in the table according to the cell order to obtain a translation table corresponding to the table to be translated.
11. An electronic device, characterized in that: The electronic device comprises: processor; a memory for storing instructions executable by the processor; The processor is configured to read the executable instructions from the memory and execute the instructions to implement the method according to any one of claims 1 to 9.
12. A computer-readable storage medium, characterized in that The storage medium stores a computer program, and the computer program is used to execute the method according to any one of claims 1 to 9.
13. A computer program product, characterized in that The computer program product comprises a computer program / instructions, which implement the method according to any one of claims 1 to 9 when executed by a processor.