Worksheet coding for language models
By encoding and compressing worksheets, a worksheet representation that meets the input requirements of the language model is generated, solving the problem that language models have difficulty understanding complex worksheets in the existing technology, and achieving efficient worksheet processing and reducing computing costs.
Patent Information
- Application Number
- CN202410927617.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-11
- Publication Date
- 2026-01-13
AI Technical Summary
Existing worksheet encoding methods are difficult for language models to understand and exceed the limit of the number of input word blocks, making it difficult for language models to quickly and accurately process worksheets with a large number of cells and complex layouts.
By encoding the cells in the worksheet, a worksheet representation that meets the input requirements of the language model is generated, including the encoding of cell addresses, content, and format. The number of word chunks is reduced through compression, inverted index transformation, and data format aggregation, resulting in a more concise representation.
This enables the language model to quickly and accurately understand the structure and semantic information of the worksheet, reduces processing costs, and adapts to the input limitations of the language model.
Smart Images

Figure CN121328487A_ABST
Abstract
Description
BACKGROUND
[0001] Such as Spreadsheet applications, such as Excel, provide computer users with a convenient way of managing data. Users can use a spreadsheet application to create a workbook that includes one or more sheets. Each sheet is a two-dimensional grid of cells. Each cell is identified by its row index and column index in the two-dimensional grid. Users can use the computer's graphical user interface to organize data, such as numerical values, text, formulas, etc., in the cells of a sheet. SUMMARY
[0002] This Summary is provided to introduce a set of concepts in a simplified form that are further described below in the DETAILED DESCRIPTION. This Summary is not intended to identify key features or essential features of the claimed subject matter, nor is it intended to be used in limiting the scope of the claimed subject matter.
[0003] Embodiments of the present disclosure provide a method, an apparatus, and a computer program product for sheet encoding. A set of cells in a sheet can be encoded to obtain a set of cell encodings, each cell encoding including a cell address of a corresponding cell and cell content. The set of cell encodings can be converted into a set of inverted encodings by using the cell content as an index of the cell address. A plurality of inverted encodings in the set of inverted encodings having a same cell content can be identified. The identified plurality of inverted encodings can be merged into a merged encoding including the same cell content and a merged address merged from a plurality of cell addresses in the plurality of inverted encodings. The merged encoding and the remaining inverted encodings in the set of inverted encodings can be combined into a sheet representation of the sheet.
[0004] It should be noted that the above one or more aspects include features in detail in the following description and specifically pointed out in the claims. The following description and drawings set forth in detail certain illustrative features of the one or more aspects. These features are indicative, however, of but a few of the various ways in which the principles of various aspects can be employed, and this disclosure is intended to include all such aspects and their equivalents. BRIEF DESCRIPTION OF DRAWINGS
[0005] The disclosed aspects will hereinafter be described in conjunction with the appended drawings, provided to illustrate and not to limit the scope of the disclosed aspects.
[0006] Figure 1 An exemplary sheet and its sheet representation according to embodiments of the present disclosure are shown.
[0007] Figure 2An exemplary process for work sheet encoding is shown, in accordance with an embodiment of the present disclosure.
[0008] Figure 3 An exemplary process for compressing a work sheet is shown, in accordance with an embodiment of the present disclosure.
[0009] Figure 4 An exemplary process for detecting boundary rows and boundary columns in a work sheet by a heuristic approach is shown, in accordance with an embodiment of the present disclosure.
[0010] Figure 5 Another exemplary work sheet and its work sheet representation are shown, in accordance with an embodiment of the present disclosure.
[0011] Figure 6 An exemplary process for performing an inverted index conversion on a work sheet representation is shown, in accordance with an embodiment of the present disclosure.
[0012] Figure 7 An exemplary work sheet representation obtained by performing an inverted index conversion is shown, in accordance with an embodiment of the present disclosure.
[0013] Figure 8 An exemplary work sheet representation obtained by performing a data format aggregation is shown, in accordance with an embodiment of the present disclosure.
[0014] Figure 9 An exemplary process for performing a table detection task with a work sheet representation is shown, in accordance with an embodiment of the present disclosure.
[0015] Figure 10 is a flow diagram of an exemplary method for work sheet encoding, in accordance with an embodiment of the present disclosure.
[0016] Figure 11 An exemplary apparatus for work sheet encoding is shown, in accordance with an embodiment of the present disclosure.
[0017] Figure 12 Another exemplary apparatus for work sheet encoding is shown, in accordance with an embodiment of the present disclosure. DETAILED DESCRIPTION
[0018] The present disclosure will now be discussed with reference to several exemplary embodiments. It should be understood that the discussion of these embodiments is merely intended to provide a better understanding of the present disclosure and to enable the best possible implementation of the embodiments of the present disclosure, and is not intended to teach any limitation of the scope of the present disclosure.
[0019] Workbooks play an important role in data management. Understanding the layout and structure of a workbook is fundamental to many data analysis and user interaction tasks. Language Models (LMs) can be employed to perform processing and reasoning tasks for workbooks. In this context, a language model refers to a deep learning model that is capable of understanding the meaning of natural language, generating natural language text, or performing other natural language tasks. It should be understood that a language model encompasses multi-modal models that are capable of performing processing tasks for natural language as well as other modalities. Due to factors such as the conversational text interface of a language model, the large two-dimensional grid structure and diverse layouts of a workbook, and so on, the workbook representation generated by existing encoding methods can be difficult for a language model to understand and often exceeds the input token limit of a language model.
[0020] Embodiments of the present disclosure propose improved worksheet encoding for language models. A group of cells in a worksheet can be encoded to obtain a group of cell encodings. Each cell encoding can include a cell address and a cell content of a corresponding cell. The group of cell encodings can be combined into a worksheet representation of the worksheet. There can be some worksheet-specific features in the worksheet. For example, some cells in the worksheet can have specific cell formats, such as font bold, with fill color, containing border, etc. In addition, there can be some merged cells in the worksheet. Embodiments of the present disclosure propose multiple efficient encoding manners for cell formats in the worksheet. In one implementation, for a cell with a specific cell format, the cell content and the cell format of the cell can be encoded together to generate a single cell encoding of the cell. In another implementation, for a cell with a specific cell format, the cell content and the cell format of the cell can be encoded separately to generate two cell encodings of the cell. In yet another implementation, when multiple cells have the same cell format, for each cell of the multiple cells, the cell content of the cell can be encoded to generate a cell encoding of the cell. Meanwhile, a format description in natural language can be generated based on the same cell format and multiple cell addresses corresponding to the same cell format. In this document, natural language refers to the language used by humans to communicate with each other. Natural language is in contrast to computer languages, such as source code languages, object code languages, computer script languages, etc., although it should be understood that there can be some overlap between natural languages and computer languages. In addition, for a merged cell in the worksheet, an address range of the merged cell can be obtained, and the worksheet representation is updated by adding the address range of the merged cell. The technical effects of the above encoding manners are to serialize the worksheet into a text sequence including the addresses, contents, formats, and merged cells of the cells in the worksheet, and to generate an efficient worksheet representation that meets the linear and sequential input requirements of the language model, which helps the language model to quickly and accurately understand the structure and semantic information of the worksheet.
[0021] Furthermore, to reduce the number of word chunks included in the worksheet representation to accommodate the input word chunk limit of the language model, embodiments of this disclosure propose various methods to compress the worksheet representation to obtain a more refined worksheet representation containing fewer word chunks. In one implementation, worksheet compression can be achieved by detecting boundary rows and columns in the worksheet and removing rows and columns far from the boundary rows and columns far from the boundary columns. In another implementation, a set of cell codes can be converted into a set of inverted codes using cell content as the index of cell address, and multiple inverted codes with the same cell content can be merged. In this document, the code that uses cell content as the index of cell address is called an inverted code. In yet another implementation, multiple codes with the same data format can be aggregated. The technical effect of the above compression methods is that they achieve efficient worksheet encoding, reduce the number of word chunks included in the worksheet representation, enable language models to process worksheets containing a large number of cells and / or with complex layouts and formats, and reduce the computational cost of language models when processing worksheets. Furthermore, feeding the language model a worksheet representation containing fewer word blocks as input when performing worksheet processing tasks helps maintain the language model's performance. Additionally, the three implementation methods described above can be implemented as modular components. One or more of the three implementation methods can be selected for different worksheet processing tasks.
[0022] The various embodiments of this disclosure will now be described in detail with reference to the accompanying drawings.
[0023] A worksheet consists of a set of cells, each with a corresponding cell address and cell content. Embodiments of this disclosure propose using the Markdown markup language to encode the cells in the worksheet, as shown in the following formula:
[0024]
[0025] in, Represents a worksheet. This represents the cell code of a cell in a worksheet, where i represents the row index, j represents the column index, m represents the range of rows in the worksheet, and n represents the range of rows in the worksheet. A set of cell codes corresponding to a group of cells in a worksheet can be combined to form a worksheet representation of that worksheet. A worksheet representation can also be called a worksheet code.
[0026] Figure 1An exemplary worksheet 100a and its worksheet representation 100b according to an embodiment of the present disclosure are shown. Worksheet 100a contains a table. Worksheet representation 100b includes a set of cell codes corresponding to a set of cells in worksheet 100a. Each cell code includes the cell address and cell content of the corresponding cell. For example, cell code 104[A1,Company] of cell 102 includes the cell address "A1" and the cell content "Company" of cell 102.
[0027] Some cells in a worksheet may have specific cell formatting, such as bold font, fill color, or borders. Directly encoding cell formatting can consume a large number of word blocks. Embodiments of this disclosure propose several efficient encoding methods for cell formatting in worksheets.
[0028] In one implementation, for cells with a specific cell format, the cell content and cell format can be encoded together to generate a single cell code for that cell. For example, in worksheet 100a, the first row, which serves as the header, has a gray fill color. This row can be encoded as follows:
[0029] |A1,Company,Grey Fill Color|B1,Sales,Grey Fill Color|C1,Market Share,Grey Fill Color|\n Where "\n" is a newline character. This encoding method intuitively and comprehensively records cell-level text and formatting information.
[0030] In another implementation, for cells with a specific cell format, the cell content and cell format can be encoded separately to generate two cell codes for that cell. For example, the first row in worksheet 100a can be encoded as follows:
[0031] |A1,Company|B1,Sales|C1,Market Share|\n
[0032] |A1,Gray Fill Color|B1,Gray Fill Color|C1,Gray Fill Color|\n
[0033] This encoding method uses a cell matrix to record cell content and cell format separately, while preserving the original text and format information at the cell level.
[0034] In another implementation, when multiple cells have the same cell format, the cell content of each cell can be encoded to generate a cell code. Simultaneously, a format description in natural language can be generated based on the shared cell format and multiple cell addresses corresponding to that format. Preferably, when multiple cell addresses include adjacent cell addresses, these adjacent cell addresses can be merged into a single address range. For example, the first row in worksheet 100a can be encoded as follows:
[0035] |A1,Company|B1,Sales|C1,Market Share|\n
[0036] The A1:C1 region has gray fill color.
[0037] In this approach, adjacent cell addresses "A1,B1,C1" are merged into the address range "A1:C1". This encoding method summarizes the cell format according to a pattern and generates a concise natural language description of the format. Such a description is easy for language models to understand and reduces the use of word blocks.
[0038] Additionally, for multiple cells with the same cell format, the format information can be encoded by using the cell format as an index for the cell address. Preferably, when multiple cell addresses include adjacent cell addresses, the adjacent cell addresses can be merged into a single address range. For example, the format information of row 1 in worksheet 100a can be encoded as follows:
[0039] 'Grey Fill Color': [A1:C1]
[0040] The worksheet 100b uses this encoding method, as shown in encoding 106.
[0041] In addition, there may be some merged cells. It's possible to obtain the address range of merged cells in a set of cells in a worksheet and add this address range to the worksheet representation. For example, in row 5 of worksheet 100a, there is a merged cell containing "Date:2023-11-26". The address range of this merged cell, "A5:C5", can be added to worksheet representation 100b, as shown in code 108.
[0042] The technical advantage of the above encoding method is that it serializes the worksheet into a text sequence that includes the addresses, contents, formats, and merged cells of the worksheet. It can also generate an effective worksheet representation that meets the linear and sequential input requirements of the language model, which helps the language model to quickly and accurately understand the structure and semantic information of the worksheet.
[0043] It should be understood that Figure 1 The worksheets 100a and 100b shown are merely examples of worksheets and worksheet representations. Depending on the actual application requirements, worksheets may have other layouts and contain other formatting information. For example, cells may have borders. Multiple border patterns can be predefined, such as top border, bottom border, left border, right border, etc. Cells with the same border type can be identified, and formatting descriptions in natural language can be generated based on the cell addresses of these cells, or the formatting information can be encoded by using the cell format as an index to the cell address. Furthermore, worksheet 100a contains only one table, but in actual applications, worksheets may contain multiple tables. The above encoding method also applies to worksheets containing multiple tables.
[0044] Worksheets may contain a large number of cells, or have complex layouts or formatting. The worksheet representation generated by encoding the worksheet in the above manner may exceed the word block limit of the language model. Embodiments of this disclosure propose further improvements to the above encoding method to generate a more refined worksheet representation containing fewer word blocks. Figure 2 An exemplary process 200 for worksheet encoding according to an embodiment of this disclosure is shown. Through process 200, worksheet 202 can be encoded into a refined worksheet representation.
[0045] Worksheet 202 is a two-dimensional grid containing a set of cells, which may contain one or more tables.
[0046] At 210, worksheet 202 can be compressed to obtain compressed worksheet 212. For example, worksheet 202 can be compressed by detecting boundary rows and columns and removing rows and columns far from the boundary rows and columns far from the boundary columns. Large worksheets may contain a large number of isomorphic rows and columns that are typically located within the table, which may play a relatively minor role in understanding the worksheet's layout and structure. To compress the worksheet while preserving its important layout and structural information, embodiments of this disclosure propose detecting boundary rows and columns located at the table boundaries in worksheet 202. Boundary rows and columns can also be referred to as structural anchors of the worksheet. Boundary rows and columns can be expressed as follows:
[0047]
[0048] Where, r p ={Cell i,j} i∈p,j∈n And c q ={Cell i,j} i∈m,j∈q .
[0049] Rows and columns far from the boundary can be removed from worksheet 202. These rows and columns typically contain redundant, homogeneous data for understanding the worksheet's layout and structure. A row far from the boundary can be a row whose distance from the boundary row exceeds a first predetermined distance (k rows). A column far from the boundary can be a column whose distance from the boundary column exceeds a second predetermined distance (t rows). After removing these rows and columns from worksheet 202, the remaining rows and columns can be represented as follows:
[0050]
[0051] Where, r p+ ={Cell i,j} |i-p|≤k,j∈n And c q+ ={Cell i,j} i∈m,|j-q|≤t Subsequently, the compressed worksheet 212 can be obtained, as follows:
[0052]
[0053] The first and second predetermined distances can have the same or different values. The first and second predetermined distances can be empirical values derived from past experimental results. Alternatively, the first and second predetermined distances can be dynamically set. For example, the first predetermined distance (k rows) can be inversely proportional to the total number of columns in the worksheet. When the total number of columns in the worksheet is large, the first predetermined distance can be set to a smaller value, such as "2"; while when the total number of columns in the worksheet is small, the first predetermined distance can be set to a larger value, such as "8". Similarly, the second predetermined distance (t rows) can also be inversely proportional to the total number of rows in the worksheet. When the total number of rows in the worksheet is large, the second predetermined distance can be set to a smaller value, such as "2"; while when the total number of rows in the worksheet is small, the second predetermined distance can be set to a larger value, such as "8". This will be discussed later in conjunction with... Figure 3 This section illustrates an exemplary process for compressing worksheets. The technical effect of worksheet compression is to reduce the number of cells in a worksheet while preserving the heterogeneous rows and columns that are important for understanding the worksheet's layout and structure. This helps reduce the number of chunks in the subsequently generated worksheet representation.
[0054] After obtaining the compressed worksheet 212 Next, at position 220, a group of cells in the compressed worksheet 212 can be encoded to obtain a set of cell codes. Each cell code can include the cell address and cell content of the corresponding cell. This set of cell codes can be combined into worksheet representation 222. By combining the above with formulas (1)-(2) and Figure 1 The described process is used to perform the cell encoding operation at step 220. It should be understood that the worksheet compression operation at step 210 is optional. Without performing the worksheet compression operation at step 210, a group of cells in worksheet 202 can be encoded to obtain a set of cell codes, and these cell codes can be combined to form worksheet representation 222.
[0055] Preferably, when encoding a group of cells, a set of cell formats corresponding to that group of cells can be obtained. Identical cell formats within this group of cell formats can be identified. Subsequently, a format description in natural language can be generated based on this identical cell format and multiple cell addresses corresponding to it. The worksheet representation can be updated by adding this format description.
[0056] Preferably, when encoding a group of cells, the address range of merged cells within that group can be obtained. The worksheet representation can be updated by adding the address range of merged cells.
[0057] After generating worksheet representation 222 through cell encoding at 220, an inverted index transformation can be performed on worksheet representation 222 at 230 to update it into a more refined worksheet representation 232. The worksheet may contain empty rows, columns, or scattered cells. The encoding operation at step 220 uses a grid-based format to associate cell addresses with their contents, such as [|A1,Company|], [|B1,Sales|]. This method requires recording empty cells to maintain the two-dimensional integrity of the worksheet, thus consuming a large number of additional word blocks. Furthermore, cells with the same content are repeatedly encoded, further increasing the number of word blocks used. To improve encoding efficiency, embodiments of this disclosure propose performing an inverted index transformation on the worksheet representation. The inverted index transformation can include two stages. In the first stage, a set of cell codes in a matrix encoding pattern can be converted into a set of inverted codes by using cell contents as indices for cell addresses. In the second stage, multiple inverted codes with the same cell content within a set of inverted codes can be identified, and these multiple inverted codes can be merged into a merged code. The merged code can include the same cell content as well as a merged address formed by merging multiple cell addresses from multiple inverted codes. During this process, cell codes with empty cell content can be removed. Furthermore, adjacent cell addresses can be further merged into an address range, thereby further reducing the number of word blocks. For example, adjacent cell addresses "B3,B4,B5,B6" can be merged into the address range "B3:B6". This process can be expressed as follows:
[0058]
[0059] The merged encoding and the remaining inverted encodings from a set of inverted encodings can be combined into a worksheet representation 232. The technical advantage of inverted index transformation lies in its reduction of the number of word blocks through operations such as removing empty cells and merging inverted encodings with identical cell content. Furthermore, through inverted index transformation, the semantic relationships between cells with identical content are explicitly encoded, even if these cells are far apart, which helps the subsequent language model understand the structure and semantic information of the worksheet. In addition, inverted index transformation is lossless compression; it does not reduce useful information in the worksheet. This will be discussed later in conjunction with... Figure 6 This illustrates an exemplary procedure for performing inverted index transformations on a worksheet representation.
[0060] Preferably, after performing the inverted index transformation at 230 to obtain worksheet representation 232, at 240, data format aggregation can be performed on worksheet representation 232 to further update it into a more refined worksheet representation 242. In a worksheet, some adjacent cells, such as cells in the same column and adjacent rows, may have the same data format, although the specific values may differ. The specific values of the cells may not be necessary for understanding the structure and semantics of the worksheet. In contrast, the data format of the cells can express the semantic attributes of the cells, which may be more important for understanding the worksheet. Embodiments of this disclosure propose identifying multiple codes with the same data format from worksheet representation 232, and updating worksheet representation 232 by aggregating the identified multiple codes.
[0061] You can use built-in cell properties in a worksheet, such as Number FormatString (NFS), to describe the data format of a cell. For example, the number format string for "2024.2.14" could be "yyyy-mm-dd". If a cell in the worksheet has a number format string explicitly added, or if the number format string has not been intentionally cleared, you can directly determine the cell's data format based on that number format string; otherwise, you can map the cell's data format to one of the following data formats according to predefined rules: Year, Integer, Float, Percentage, Scientific notation, Date, Time, Currency, Email, Others, etc. Cells with the same data format can be aggregated. This process can be expressed as follows:
[0062] NFSs = nfs({Cell i,j} i∈m,j∈n (7)
[0063]
[0064] Here, R represents a predefined aggregation rule. Multiple codes with the same data format can be aggregated into an aggregate code. This aggregate code includes the same data format and an aggregate address formed by aggregating multiple cell addresses from these codes. Furthermore, adjacent cell addresses can be further merged into an address range. The technical advantage of data format aggregation is that it further reduces the number of word blocks while preserving the semantic information of the data in the worksheet.
[0065] By performing one or more of the following operations—worksheet compression (210 points), inverted index transformation (230 points), and data format aggregation (240 points)—efficient worksheet encoding can be achieved, reducing the number of word blocks included in the worksheet representation. This allows language models to process worksheets with large numbers of cells and / or complex layouts and formats, and reduces the computational cost for language models when processing worksheets. Furthermore, the three implementation methods described above can be implemented as modular components. One or more of these three implementation methods can be selected for different worksheet processing tasks. For example, for table detection tasks that do not require fine-grained information, worksheet compression, inverted index transformation, and data format aggregation can be used; for formula recommendation tasks that require relatively fine-grained information, inverted index transformation and data format aggregation can be used; and for question-answering tasks that require fine-grained information, only inverted index transformation can be used.
[0066] It should be understood that the above text, in combination with... Figure 2 The described process for worksheet coding is merely exemplary. Depending on the specific application requirements, the steps in the worksheet coding process can be replaced or modified in any way, and the process may include more or fewer steps.
[0067] Figure 3 An exemplary process 300 for compressing a worksheet according to an embodiment of this disclosure is shown. Process 300 may correspond to Figure 2 Step 210 in the process.
[0068] At position 302, boundary rows and columns in a worksheet can be detected. A worksheet may contain multiple tables. Boundary rows and columns can be rows and columns located at the boundaries of tables. Boundary rows and columns in a worksheet can be detected in various ways. In one implementation, a machine learning model can be used to detect boundary rows and columns. As an example, this machine learning model could be a combination of a Recurrent Neural Network (RNN) and a Convolutional Neural Network (CNN). In another implementation, heuristic methods can be used to detect boundary rows and columns in a worksheet. This will be discussed later. Figure 4 This section illustrates an exemplary process for detecting boundary rows and columns in a worksheet using heuristics.
[0069] At position 304, rows that are more than a first predetermined distance from the boundary row and columns that are more than a second predetermined distance from the boundary column can be removed from the worksheet. Rows that are more than a first predetermined distance from the boundary row and columns that are more than a second predetermined distance from the boundary column can be considered as rows and columns far from the boundary row and columns, respectively, and typically contain redundant homogeneous data for understanding the layout and structure of the worksheet. The first and second predetermined distances can have the same value or different values. The first and second predetermined distances can be empirical values derived from past experimental results. Alternatively, the first and second predetermined distances can be dynamically set. For example, the first predetermined distance can be inversely proportional to the total number of columns in the worksheet. When the total number of columns in the worksheet is large, the first predetermined distance can be set to a smaller value; and when the total number of columns in the worksheet is small, the first predetermined distance can be set to a larger value. Similarly, the second predetermined distance can be inversely proportional to the total number of rows in the worksheet. When the total number of rows in the worksheet is large, the second predetermined distance can be set to a smaller value; and when the total number of rows in the worksheet is small, the second predetermined distance can be set to a larger value.
[0070] By performing steps 302 and 304, a compressed worksheet containing fewer cells can be obtained. The technical effect of worksheet compression is to reduce the number of cells in the worksheet while preserving the heterogeneous rows and columns that are important for understanding the layout and structure of the worksheet. This helps to reduce the number of chunks in the subsequently generated worksheet representation.
[0071] To maintain the continuity of cell addresses, preferably at 306, for each cell in the compressed worksheet, the cell address can be updated from the original address to the current address corresponding to the cell's position in the compressed worksheet.
[0072] At address 308, the mapping relationship between the original address and the current address can be recorded.
[0073] The technical effect of steps 306 and 308 is to maintain the integrity of the data relationships in the worksheet, so that the processing results can be accurately transformed when the worksheet processing task is executed in the future, and to ensure the consistency and reliability of data analysis during the worksheet compression process.
[0074] It should be understood that the above text, in combination with... Figure 3The described process for compressing a worksheet is merely exemplary. Depending on the specific application requirements, the steps in the process for compressing a worksheet can be replaced or modified in any way, and the process may include more or fewer steps. For example, steps 306 and 308 are performed in process 300, but embodiments of this disclosure are not limited thereto. In some embodiments, steps 306 and 308 may be omitted.
[0075] Figure 4 An exemplary process 400 for detecting boundary rows and boundary columns in a worksheet using a heuristic method, according to an embodiment of this disclosure, is illustrated. Process 400 may correspond to... Figure 3 One implementation of step 302 in the process.
[0076] At position 402, a set of candidate rows and a set of candidate columns in the worksheet that differ from the rows on either side can be detected. Differences can refer to different cell content, different cell formatting, or the presence of merged cells. Cell formatting can include, for example, font style, fill color, and cell border type.
[0077] At position 404, the candidate row set and candidate column set can be combined into a first candidate border set. For example, two candidate rows can be arbitrarily selected from the candidate row set, and two candidate columns can be arbitrarily selected from the candidate column set to form a candidate border.
[0078] At position 406, a second set of candidate borders whose enclosing regions meet a predetermined sparsity criterion can be extracted from the first set of candidate borders. For example, for each candidate border in the first set, the proportion of cells with content within the region enclosed by the candidate border to the total number of cells in that region can be calculated. Alternatively or additionally, the proportion of cells with content at the boundary of the region enclosed by the candidate border to the total number of cells at that boundary can be calculated. Whether a candidate border meets the sparsity criterion can be determined based on either or both of the calculated proportions. For example, if either of the calculated proportions is higher than a predetermined threshold, or if the sum or weighted sum of the two proportions is higher than a predetermined threshold, then the enclosing region of the candidate border meets the predetermined sparsity criterion. An enclosing region meeting the predetermined sparsity criterion indicates that the region contains fewer empty cells. Accordingly, the region may be a table region.
[0079] At point 408, candidate borders that overlap with or are contained within other candidate borders can be removed from the second candidate border set to obtain the third candidate border set. When two candidate borders overlap, the relative position of the two candidate borders, the position of the table header, etc., can be used to determine which candidate border to remove. For example, if the first candidate border is located at the bottom right corner of the second candidate border, the first candidate border does not contain a table header, the second candidate border does contain a table header, and the cell content in the first candidate border corresponds to at least a portion of the table header in the second candidate border, then the area corresponding to the first candidate border is likely to belong to the table area corresponding to the second candidate border. In this case, the first candidate border is likely not a boundary row or column of the table and can therefore be removed. As another example, if the first candidate border is located below the second candidate border, the first candidate border does not contain a table header, the second candidate border contains a table header and several blank rows and encompasses the area where the first candidate border is located, then the area corresponding to the first candidate border is likely to belong to the table area corresponding to the second candidate border. In this case, the first candidate border is likely not a boundary row or column of the table and can therefore be removed. It should be understood that the above rules are merely illustrative, and other rules can also be used to determine whether to remove candidate borders.
[0080] At position 410, the rows and columns corresponding to the third candidate border set can be used as the boundary rows and boundary columns.
[0081] It should be understood that the above text, in combination with... Figure 4 The described process for detecting boundary rows and columns in a worksheet using heuristics is merely exemplary. Depending on the specific application requirements, the steps in the process for detecting boundary rows and columns using heuristics can be replaced or modified in any way, and the process may include more or fewer steps. For example, in process 400, steps 404 to 408 are performed, but embodiments of this disclosure are not limited thereto. In some embodiments, one or more of steps 404 to 408 may be omitted. Without performing steps 404 to 408, the candidate row set and candidate column set detected in step 402 can be directly used as boundary rows and boundary columns, respectively. Furthermore, the specific order or hierarchy of the steps in process 400 is merely exemplary, and the process for detecting boundary rows and columns using heuristics may be performed in an order different from the described order.
[0082] Figure 5 Another exemplary worksheet 500a and its worksheet representation 500b according to embodiments of the present disclosure are shown. Worksheet 500a may be the original worksheet or a compressed worksheet. For example, worksheet 500a may correspond to Figure 2Worksheet 202 or the compressed worksheet 212, worksheet representation 500b can correspond to Figure 2 The worksheet in the image is represented as 222. For simplification, in... Figure 5 The table only shows a portion of the worksheet representation, which may correspond to rows 3 through 6 of worksheet 500b. Furthermore, worksheet representation 500b only shows codes related to the cell content; however, it should be understood that worksheet representation 500b may also include codes related to the cell formatting.
[0083] Figure 6 An exemplary procedure 600 for performing an inverted index transformation on a worksheet representation according to an embodiment of the present disclosure is shown. Procedure 600 may correspond to Figure 2 Step 230 in the process.
[0084] The worksheet representation generated using cell codes can include a set of cell codes corresponding to a group of cells in the worksheet. This set of cell codes may contain cell codes with empty cell contents. Optionally, at 602, cell codes with empty cell contents can be removed from the set of cell codes in the worksheet to obtain an updated set of cell codes. Figure 5 Taking worksheet 500b as an example, this group of cell codes includes multiple cell codes with empty cell contents, such as cell code 502, cell code 504, etc. These cell codes with empty cell contents can be removed. It should be understood that step 602 can be performed only if there are cell codes with empty cell contents in this group of cell codes.
[0085] At position 604, an updated set of cell codes can be converted into a set of inverted codes by using the cell content as an index to the cell address. For example, cell code [D3,20-Aug] can be converted into inverted code ["20-Aug":"D3"], cell code [D4,20-Aug] can be converted into inverted code ["20-Aug":"D4"], cell code [F4,Region A] can be converted into inverted code ["Region A":"F4"], cell code [A5,Region A] can be converted into inverted code ["Region A":"A5"], cell code [D5,20-Aug] can be converted into inverted code ["20-Aug":"D5"], cell code [D6,20-Sep] can be converted into inverted code ["20-Sep":"D6"], and so on.
[0086] At position 606, multiple inverted codes with the same cell content within a set of inverted codes can be identified. For example, inverted codes ["20-Aug":"D3"], ["20-Aug":"D4"], and ["20-Aug":"D5"] are three inverted codes with the same cell content; inverted codes ["Region A":"F4"] and ["Region A":"A5"] are two inverted codes with the same cell content; and so on.
[0087] At point 608, multiple identified inverted codes can be merged into a single merged code. This merged code can include the same cell content as well as a merged address formed by combining multiple cell addresses from multiple inverted codes. For example, inverted codes ["20-Aug":"D3"], ["20-Aug":"D4"], and ["20-Aug":"D5"] can be merged into a single merged code ["20-Aug":"D3,D4,D5"], and inverted codes ["Region A":"F4"] and ["Region A":"A5"] can be merged into a single merged code ["Region A":"F4,A5"]. Preferably, when the merged address contains adjacent cell addresses, the adjacent cell addresses can be further merged into an address range to further reduce the number of word blocks. For example, adjacent cell addresses "D3,D4,D5" can be merged into the address range "D3:D5", thus the merged encoding ["20-Aug":"D3,D4,D5"] can be further compressed into ["20-Aug":"D3:D5"]. The technical effect of this step is to explicitly encode the semantic relationships between cells with the same content, even if these cells are far apart, which helps the subsequent language model understand the structure and semantic information of the worksheet.
[0088] At point 610, the merged code and the remaining inverted codes from the set of inverted codes can be combined into a worksheet representation of the worksheet. The remaining inverted codes refer to the inverted codes in the set of inverted codes obtained in step 604 that did not undergo the merge operation at point 608.
[0089] The technical advantage of inverted index transformation lies in its reduction of word chunks through operations such as removing empty cells and merging inverted codes with identical cell content. Furthermore, through inverted index transformation, the semantic relationships between cells with identical content are explicitly encoded, even if these cells are geographically distant. This helps subsequent language models understand the worksheet's structure and semantic information. Moreover, inverted index transformation is a lossless compression process, meaning it does not reduce useful information within the worksheet.
[0090] It should be understood that the above text, in combination with... Figure 6The described process for performing inverted index transformations on a worksheet representation is merely exemplary. Depending on the specific application requirements, the steps in the process for performing inverted index transformations on a worksheet representation can be replaced or modified in any way, and the process may include more or fewer steps. Furthermore, the specific order or hierarchy of the steps in process 600 is merely exemplary, and the process for performing inverted index transformations on a worksheet representation can be performed in an order different from the described order.
[0091] Figure 7 An exemplary worksheet representation 700 obtained by performing an inverted index transformation according to an embodiment of this disclosure is shown. The worksheet representation 700 can be obtained by performing an inverted index transformation on... Figure 5 The inverted index transformation was performed on worksheet representation 500b. In worksheet representation 700, cell codes with empty cell contents are removed. For example, cell codes 502 and 504 with empty cell contents in worksheet representation 500b are not included in worksheet representation 700. Additionally, in worksheet representation 700, multiple inverted codes with the same cell content are merged into a merged code. This merged code can include the same cell content as well as a merged address formed by merging multiple cell addresses from multiple inverted codes. For example, merged codes 702 ["Region C":"A3,F5,A6"] and merged code 704 [20-Aug":"D3:D5"] are formed by merging multiple inverted codes. Furthermore, adjacent cell addresses are further merged into an address range. For example, the address range "D3:D5" in merged code 704 [20-Aug":"D3:D5"] is formed by merging three adjacent cell addresses "D3,D4,D5". Figure 5 and Figure 7 It can be clearly seen that the number of word blocks included in worksheet representation 700, which is obtained by performing an inverted index transformation on worksheet representation 500b, is significantly less than the number of word blocks in worksheet representation 500b.
[0092] Figure 8 An exemplary worksheet representation 800 obtained by performing data format aggregation according to an embodiment of this disclosure is shown. The worksheet representation 800 can be obtained by performing data format aggregation on... Figure 7The worksheet representation 700 is obtained by performing data format aggregation. As an example, worksheet representation 700 includes multiple codes whose data format is integer, namely codes 706 to 716. According to embodiments of this disclosure, multiple codes with the same data format can be identified from worksheet representation 700, and worksheet representation 700 can be updated by aggregating the identified multiple codes, thereby further reducing the number of word blocks. For example, in worksheet representation 800, codes 706 to 716 are aggregated into code 802. Similarly, codes 804 and 806 are also aggregated from multiple codes with the same data format. Figure 7 and Figure 8 It can be clearly seen that the number of word blocks included in worksheet representation 800, which is obtained by performing data format aggregation on worksheet representation 700, is significantly less than the number of word blocks in worksheet representation 700.
[0093] Based on the above... Figures 1 to 8 The worksheet representation obtained from the described worksheet encoding process can be provided to the language model as part of the prompt words, and then used to perform various worksheet processing tasks, such as table detection tasks, formula recommendation tasks, question answering tasks, table structure recognition tasks, etc. Figure 9 An exemplary process 900 according to an embodiment of the present disclosure for performing a table detection task using a worksheet representation is illustrated. The table detection task aims to detect all tables in a worksheet and determine their regions within the worksheet. Table detection of the worksheet can be performed using a language model. The language model can be a large language model such as GPT-4 or a small language model such as Phi-3.
[0094] At position 902, the number of word blocks representing a worksheet can be calculated. A worksheet representation can be obtained by combining the above... Figures 1 to 8 This was obtained through the worksheet coding process described.
[0095] At position 904, it can be determined whether the calculated number of word chunks exceeds the word chunk limit of the language model. Compared to the worksheet representation obtained through traditional methods, the above combination... Figures 1 to 8 The worksheet representation obtained through the described worksheet encoding process includes far fewer word chunks. However, for some worksheets containing a large number of cells and / or with complex layouts and formats, the number of word chunks included in the worksheet representation may still exceed the word chunk limit of the language model.
[0096] If it is determined at step 904 that the number of calculated word chunks does not exceed the word chunk limit of the language model, then process 900 can proceed to step 906. At step 906, tables in the worksheet can be detected using the language model based on the worksheet representation. For example, the worksheet representation can be provided to the language model as part of a prompt. The language model can then perform table detection on the worksheet based on this worksheet representation and the instructions in the prompt, utilizing its semantic understanding, logical reasoning, and big data support capabilities.
[0097] If at step 904 it is determined that the number of calculated word chunks exceeds the word chunk limit of the language model, then process 900 can proceed to step 908. At step 908, the worksheet can be split into multiple sub-worksheets. The worksheet can be split in several ways. In one implementation, the worksheet can be split into multiple sub-worksheets horizontally according to the number of rows. In another implementation, the worksheet can be split into multiple sub-worksheets vertically according to the number of columns. In yet another implementation, the worksheet can be split into multiple sub-worksheets both horizontally and vertically according to the number of rows and columns.
[0098] At point 910, multiple sub-worksheets can be encoded as separate sub-worksheet representations. For each sub-worksheet, this can be achieved by combining it with the above... Figures 1 to 8 A similar process to the described worksheet encoding process is used to encode the sub-worksheet into a sub-worksheet representation. Preferably, it can be determined whether the number of word chunks in the sub-worksheet representation exceeds the word chunk limit of the language model. If it does, process 900 can return to step 908 for further splitting.
[0099] At point 912, for each sub-worksheet, a language model can detect tables within that sub-worksheet based on its corresponding sub-worksheet representation to obtain one or more tables. For example, the sub-worksheet representation can be provided to the language model as part of a prompt. The language model can then leverage its semantic understanding, logical reasoning, and big data support capabilities to perform table detection for that sub-worksheet based on the sub-worksheet representation and the instructions in the prompt.
[0100] At position 914, predefined merge rules can be used to merge one or more tables obtained at position 912 to obtain the table detection result for that worksheet. For example, when two tables obtained at position 912 are adjacent to each other and can be aligned, such as when columns in one table have the same data type as corresponding columns in the other table, these two tables can be merged into one table. It should be understood that the above rules are merely exemplary, and other rules can be used to evaluate whether two or more tables can be merged.
[0101] In process 900, when the number of word blocks in the worksheet representation exceeds the word block limit of the language model, the worksheet can be split into multiple sub-worksheets. Each sub-worksheet is then encoded into its own sub-worksheet representation. The language model performs table detection on each sub-worksheet separately, and the detection results are merged to obtain the table detection result for the entire worksheet. This process conforms to the map-reduce principle, and its technical advantage lies in enabling the language model to quickly execute processing tasks for worksheets containing a large number of cells and / or with complex layouts and formats.
[0102] It should be understood that the above text, in combination with... Figure 9 The described process for performing table checks on a worksheet is merely exemplary. Depending on the specific application requirements, the steps in the process for performing table checks on a worksheet can be replaced or modified in any way, and the process may include more or fewer steps. Furthermore, the specific order or hierarchy of the steps in process 900 is merely exemplary, and the process for performing table checks on a worksheet may be performed in an order different from the described order.
[0103] Preferably, the worksheet representation obtained according to the embodiments of this disclosure, for example, through the above-described combination of... Figures 1 to 8 The worksheet representations obtained through the described worksheet encoding process can be used to fine-tune the language model. For example, these worksheet representations can be used to construct a training dataset for a specific worksheet processing task, and this training dataset can be used to fine-tune the language model. Because this training dataset contains effective and refined worksheet representations, the fine-tuned language model can significantly outperform the un-fine-tuned language model when performing the worksheet processing task.
[0104] Figure 10 This is a flowchart of an exemplary method 1000 for worksheet encoding according to an embodiment of the present disclosure.
[0105] At position 1010, a group of cells in a worksheet can be encoded to obtain a set of cell codes, each of which includes the cell address and cell content of the corresponding cell.
[0106] At position 1020, the set of cell codes can be converted into a set of inverted codes by using the cell content as an index to the cell address.
[0107] At 1030, multiple inverted codes with the same cell content in the set of inverted codes can be identified.
[0108] At position 1040, the identified multiple inverted codes can be merged into a merged code, which includes the content of the same cell and a merged address formed by merging the cell addresses of the multiple inverted codes.
[0109] At 1050, the merged code and the remaining inverted codes in the set of inverted codes can be combined to form a worksheet representation of the worksheet.
[0110] In one implementation, method 1000 may further include: removing cell codes with empty cell content from the set of cell codes to obtain an updated set of cell codes. Converting the set of cell codes into a set of inverted codes may include: converting the updated set of cell codes into a set of inverted codes by using cell content as an index to the cell address.
[0111] In one embodiment, method 1000 may further include: compressing the worksheet to obtain a compressed worksheet, the compression including: detecting boundary rows and boundary columns in the worksheet; and removing rows from the worksheet whose distance from the boundary rows exceeds a first predetermined distance and columns whose distance from the boundary columns exceeds a second predetermined distance. Encoding a set of cells in the worksheet may include: encoding a set of cells in the compressed worksheet.
[0112] The detection of boundary rows and boundary columns in the worksheet may include: detecting the boundary rows and boundary columns in the worksheet using a machine learning model.
[0113] The detection of boundary rows and boundary columns in the worksheet may include: detecting a set of candidate rows and a set of candidate columns that differ from the rows on both sides of the worksheet; combining the set of candidate rows and the set of candidate columns into a first candidate border set; extracting a second candidate border set from the first candidate border set whose enclosed area meets a predetermined sparsity criterion; removing candidate borders from the second candidate border set that overlap with other candidate borders or are contained by other candidate borders to obtain a third candidate border set; and using the rows and columns corresponding to the third candidate border set as the boundary rows and the boundary columns.
[0114] The first predetermined distance may be inversely proportional to the total number of columns in the worksheet. The second predetermined distance may be inversely proportional to the total number of rows in the worksheet.
[0115] The compression may further include, for each cell in the compressed worksheet: updating the cell address of the cell from the original address to the current address corresponding to the position of the cell in the compressed worksheet; and recording the mapping relationship between the original address and the current address.
[0116] In one embodiment, method 1000 may further include: identifying multiple codes having the same data format from the worksheet representation; and updating the worksheet representation by aggregating the identified multiple codes.
[0117] In one implementation, method 1000 may further include: obtaining a set of cell formats corresponding to the set of cells; identifying identical cell formats in the set of cell formats; generating a format description in natural language based on the identical cell formats and multiple cell addresses corresponding to the identical cell formats; and updating the worksheet representation by adding the format description.
[0118] In one implementation, method 1000 may further include: obtaining the address range of merged cells in the set of cells; and updating the worksheet representation by adding the address range of the merged cells.
[0119] In one implementation, method 1000 may further include: calculating the number of word blocks in the worksheet representation; splitting the worksheet into multiple sub-worksheets in response to the number of word blocks exceeding the word block limit of the language model; encoding the multiple sub-worksheets into multiple sub-worksheet representations respectively; for each sub-worksheet, detecting tables in the sub-worksheet based on the sub-worksheet representation corresponding to the sub-worksheet using the language model to obtain one or more tables; and merging the one or more tables using predefined merging rules to obtain a table detection result for the worksheet.
[0120] It should be understood that method 1000 may also include any other steps / processes for worksheet coding according to embodiments of the present disclosure as described above.
[0121] Figure 11 An exemplary apparatus 1100 for worksheet encoding according to an embodiment of the present disclosure is shown.
[0122] The apparatus 1100 may include: a cell encoding module 1110 for encoding a group of cells in a worksheet to obtain a set of cell codes, each cell code including the cell address and cell content of the corresponding cell; an encoding conversion module 1120 for converting the set of cell codes into a set of inverted codes by using the cell content as an index of the cell address; an encoding recognition module 1130 for recognizing multiple inverted codes with the same cell content in the set of inverted codes; an encoding merging module 1140 for merging the recognized multiple inverted codes into a merged code, the merged code including the same cell content and a merged address formed by merging multiple cell addresses from the multiple inverted codes; and an encoding combination module 1150 for combining the merged code and the remaining inverted codes in the set of inverted codes into a worksheet representation of the worksheet. Furthermore, the apparatus 1100 may also include any other modules configured for worksheet encoding according to embodiments of the present disclosure as described above.
[0123] Figure 12 Another exemplary apparatus 1200 for worksheet encoding according to an embodiment of the present disclosure is shown.
[0124] The device 1200 may include: a processor 1210; and a memory 1220 storing computer-executable instructions. When executed, the computer-executable instructions cause the processor 1210 to: encode a set of cells in a worksheet to obtain a set of cell codes, each cell code including the cell address and cell content of the corresponding cell; convert the set of cell codes into a set of inverted codes using the cell content as an index to the cell address; identify multiple inverted codes in the set of inverted codes that have the same cell content; merge the identified multiple inverted codes into a merged code, the merged code including the same cell content and a merged address formed by merging the cell addresses of the multiple inverted codes; and combine the merged code and the remaining inverted codes in the set of inverted codes into a worksheet representation of the worksheet.
[0125] In one embodiment, the computer-executable instructions, when executed, may further cause the processor 1210 to: compress the worksheet to obtain a compressed worksheet, the compression including: detecting boundary rows and boundary columns in the worksheet; and removing rows from the worksheet whose distance from the boundary rows exceeds a first predetermined distance and columns whose distance from the boundary columns exceeds a second predetermined distance. Encoding a group of cells in the worksheet may include: encoding a group of cells in the compressed worksheet.
[0126] The detection of boundary rows and boundary columns in the worksheet may include: detecting a set of candidate rows and a set of candidate columns that differ from the rows on both sides of the worksheet; combining the set of candidate rows and the set of candidate columns into a first candidate border set; extracting a second candidate border set from the first candidate border set whose enclosed area meets a predetermined sparsity criterion; removing candidate borders from the second candidate border set that overlap with other candidate borders or are contained by other candidate borders to obtain a third candidate border set; and using the rows and columns corresponding to the third candidate border set as the boundary rows and the boundary columns.
[0127] The compression may further include, for each cell in the compressed worksheet: updating the cell address of the cell from the original address to the current address corresponding to the position of the cell in the compressed worksheet; and recording the mapping relationship between the original address and the current address.
[0128] In one embodiment, the computer-executable instructions, when executed, may also cause processor 1210 to: identify multiple codes having the same data format from the worksheet representation; and update the worksheet representation by aggregating the identified multiple codes.
[0129] In one embodiment, when the computer-executable instructions are executed, the processor 1210 may further: obtain a set of cell formats corresponding to the set of cells; identify identical cell formats in the set of cell formats; generate a format description in natural language form based on the identical cell formats and multiple cell addresses corresponding to the identical cell formats; and update the worksheet representation by adding the format description.
[0130] In one implementation, the computer-executable instructions, when executed, may also cause processor 1210 to: obtain the address range of merged cells in the set of cells; and update the worksheet representation by adding the address range of the merged cells.
[0131] In one embodiment, the computer-executable instructions, when executed, may further cause the processor 1210 to: calculate the number of word blocks in the worksheet representation; in response to the number of word blocks exceeding the word block limit of the language model, split the worksheet into multiple sub-worksheets; encode the multiple sub-worksheets into multiple sub-worksheet representations respectively; for each sub-worksheet, detect tables in the sub-worksheet based on the sub-worksheet representation corresponding to the sub-worksheet using the language model to obtain one or more tables; and merge the one or more tables using predefined merging rules to obtain the table detection result of the worksheet.
[0132] It should be understood that the processor 1210 may also perform any other steps / processes of the method for worksheet encoding according to the embodiments of the present disclosure as described above.
[0133] Embodiments of this disclosure provide a computer program product for worksheet encoding, comprising a computer program executed by a processor to: encode a set of cells in a worksheet to obtain a set of cell codes, each cell code including a cell address and cell content of the corresponding cell; convert the set of cell codes into a set of inverted codes using the cell content as an index of the cell address; identify multiple inverted codes having the same cell content in the set of inverted codes; merge the identified multiple inverted codes into a merged code, the merged code including the same cell content and a merged address formed by merging multiple cell addresses from the multiple inverted codes; and combine the merged code and the remaining inverted codes in the set of inverted codes into a worksheet representation of the worksheet. Furthermore, the computer program may also be executed to perform any other steps / processes for implementing the method for worksheet encoding according to embodiments of this disclosure as described above.
[0134] Embodiments of this disclosure can be embodied in a computer-readable medium for worksheet encoding. The computer-readable medium may include instructions that, when executed, cause a processor to: encode a set of cells in a worksheet to obtain a set of cell codes, each cell code including the cell address and cell content of the corresponding cell; convert the set of cell codes into a set of inverted codes using the cell content as an index to the cell address; identify multiple inverted codes in the set of inverted codes that have the same cell content; merge the identified multiple inverted codes into a merged code, the merged code including the same cell content and a merged address formed by merging the multiple cell addresses from the multiple inverted codes; and combine the merged code and the remaining inverted codes in the set of inverted codes into a worksheet representation of the worksheet. Furthermore, when executed, the instructions may also cause the processor to perform any other steps / processes of the method for worksheet encoding according to embodiments of this disclosure as described above.
[0135] It should be understood that all operations in the methods described above are merely exemplary, and this disclosure is not limited to any operation in the methods or the order of such operations, but should cover all other equivalent variations under the same or similar concept. Furthermore, unless otherwise specified or clearly indicated from the context as relating to the singular form, the articles “a” and “an” as used in this specification and the appended claims should generally be interpreted as meaning “one” or “one or more”.
[0136] It should also be understood that all modules in the apparatus described above can be implemented in various ways. These modules can be implemented as hardware, software, or a combination thereof. Furthermore, any of these modules can be further functionally divided into sub-modules or combined together.
[0137] Processors have been described in conjunction with various devices and methods. These processors can be implemented using electronic hardware, computer software, or any combination thereof. Whether these processors are implemented as hardware or software will depend on the specific application and the overall design constraints imposed on the system. As an example, the processors, any portions of processors, or any combinations of processors given in this disclosure can be implemented using microprocessors, microcontrollers, digital signal processors (DSPs), field-programmable gate arrays (FPGAs), programmable logic devices (PLDs), state machines, gated logic units, discrete hardware circuits, and other suitable processing components configured to perform the various functions described in this disclosure. The functionality of the processors, any portions of processors, or any combinations of processors given in this disclosure can be implemented using software executed by a microprocessor, microcontroller, DSP, or other suitable platform.
[0138] Software should be broadly considered to refer to instructions, instruction sets, code, code segments, program code, programs, subroutines, software modules, applications, software applications, software packages, routines, subroutines, objects, running threads, procedures, functions, etc. Software may reside on a computer-readable medium. Computer-readable media may include, for example, memory, which may be, for example, magnetic storage devices (e.g., hard disks, floppy disks, magnetic stripes), optical disks, smart cards, flash memory devices, random access memory (RAM), read-only memory (ROM), programmable ROM (PROM), erasable PROM (EPROM), electrically erasable PROM (EEPROM), registers, or removable disks. Although memory is shown as separate from the processor in several aspects set forth in this disclosure, memory may also reside within the processor, such as in a cache or register.
[0139] The above description is provided to enable any person skilled in the art to practice the various aspects described herein. Various modifications to these aspects will be apparent to those skilled in the art, and the general principles defined herein may be applied to other aspects. Therefore, the claims are not intended to be limited to the aspects shown herein. All structural and functional equivalents of the elements of the various aspects described herein, known or likely to be known by one of ordinary skill in the art, are expressly incorporated herein and covered by the claims.
Claims
1. A method for worksheet coding, comprising: Encode a group of cells in a worksheet to obtain a set of cell codes, each cell code including the cell address and cell content of the corresponding cell; By using the cell content as the index of the cell address, the set of cell codes is converted into a set of inverted codes; Identify multiple inverted codes with the same cell content within the set of inverted codes; The identified multiple inverted codes are merged into a merged code, which includes the contents of the same cell and a merged address formed by merging the cell addresses of the multiple inverted codes; as well as The merged code and the remaining inverted codes in the set of inverted codes are combined to form the worksheet representation of the worksheet.
2. The method according to claim 1, further comprising: Remove cell codes with empty cell content from the set of cell codes to obtain an updated set of cell codes, and The step of converting the set of cell codes into a set of inverted codes includes: The updated set of cell codes is converted into a set of inverted codes by using the cell content as an index to the cell address.
3. The method according to claim 1, further comprising: The worksheet is compressed to obtain a compressed worksheet, the compression including: Detect the boundary rows and boundary columns in the worksheet; and Remove rows from the worksheet that are more than a first predetermined distance from the boundary row and columns that are more than a second predetermined distance from the boundary column. The encoding of a group of cells in the worksheet includes: Encode a set of cells in the compressed worksheet.
4. The method according to claim 3, wherein, The detection of boundary rows and boundary columns in the worksheet includes: The boundary rows and boundary columns in the worksheet are detected using a machine learning model.
5. The method according to claim 3, wherein, The detection of boundary rows and boundary columns in the worksheet includes: Detect the set of candidate rows and the set of candidate columns that differ from the rows on both sides of the worksheet; The candidate row set and the candidate column set are combined into a first candidate border set; Extract a second set of candidate bounding boxes whose enclosed regions meet a predetermined sparsity criterion from the first set of candidate bounding boxes; Remove candidate borders from the second candidate border set that overlap with or are contained within other candidate borders to obtain a third candidate border set; and The rows and columns corresponding to the third candidate border set are used as the boundary rows and the boundary columns.
6. The method according to claim 3, wherein: The first predetermined distance is inversely proportional to the total number of columns in the worksheet, and / or The second predetermined distance is inversely proportional to the total number of rows in the worksheet.
7. The method according to claim 3, wherein, The compression also includes, for each cell in the compressed worksheet: Update the cell address of the cell from its original address to the current address corresponding to the cell's position in the compressed worksheet; as well as Record the mapping relationship between the original address and the current address.
8. The method according to claim 1, further comprising: Identify multiple codes with the same data format from the worksheet representation; as well as The worksheet representation is updated by aggregating the identified multiple codes.
9. The method according to claim 1, further comprising: Obtain a set of cell formats corresponding to the set of cells; Identify cells with the same format within the set of cell formats; Based on the same cell format and multiple cell addresses corresponding to the same cell format, a format description in natural language is generated; as well as The worksheet representation is updated by adding the aforementioned format description.
10. The method according to claim 1, further comprising: Obtain the address range of merged cells in the aforementioned group of cells; as well as The worksheet representation is updated by adding the address range of the merged cells.
11. The method according to claim 1, further comprising: Calculate the number of word blocks represented by the worksheet; In response to the number of word chunks exceeding the word chunk limit of the language model, the worksheet is split into multiple sub-worksheets; The multiple sub-worksheets are respectively encoded into multiple sub-worksheet representations; For each sub-worksheet, the tables in the sub-worksheet are detected using the language model based on the sub-worksheet representation corresponding to the sub-worksheet, to obtain one or more tables; as well as The one or more tables are merged using predefined merge rules to obtain the table detection results for the worksheet.
12. An apparatus for worksheet encoding, comprising: processor; as well as A memory storing computer-executable instructions, which, when executed, cause the processor to: Encode a group of cells in a worksheet to obtain a set of cell codes. Each cell code includes the cell address and cell content of the corresponding cell. By using the cell content as an index to the cell address, the set of cell codes is converted into a set of inverted codes. Identify multiple inverted codes with the same cell content within the set of inverted codes. The identified multiple inverted codes are merged into a merged code, which includes the content of the same cell and a merged address formed by merging the cell addresses from the multiple inverted codes. The merged code and the remaining inverted codes in the set of inverted codes are combined to form the worksheet representation of the worksheet.
13. The apparatus according to claim 12, wherein, When executed, the computer-executable instructions also cause the processor to: The worksheet is compressed to obtain a compressed worksheet, the compression including: Detect the boundary rows and boundary columns in the worksheet; and Remove rows from the worksheet that are more than a first predetermined distance from the boundary row and columns that are more than a second predetermined distance from the boundary column. The encoding of a group of cells in the worksheet includes: Encode a set of cells in the compressed worksheet.
14. The apparatus according to claim 13, wherein, The detection of boundary rows and boundary columns in the worksheet includes: Detect the set of candidate rows and the set of candidate columns that differ from the rows on both sides of the worksheet; The candidate row set and the candidate column set are combined into a first candidate border set; Extract a second set of candidate bounding boxes whose enclosed regions meet a predetermined sparsity criterion from the first set of candidate bounding boxes; Remove candidate borders from the second candidate border set that overlap with or are contained within other candidate borders to obtain a third candidate border set; and The rows and columns corresponding to the third candidate border set are used as the boundary rows and the boundary columns.
15. The apparatus according to claim 13, wherein, The compression also includes, for each cell in the compressed worksheet: Update the cell address of the cell from its original address to the current address corresponding to the cell's position in the compressed worksheet; as well as Record the mapping relationship between the original address and the current address.
16. The apparatus according to claim 12, wherein, When executed, the computer-executable instructions also cause the processor to: Identify multiple codes with the same data format from the worksheet representation; as well as The worksheet representation is updated by aggregating the identified multiple codes.
17. The apparatus according to claim 12, wherein, When executed, the computer-executable instructions also cause the processor to: Obtain a set of cell formats corresponding to the set of cells; Identify cells with the same format within the set of cell formats; Based on the same cell format and multiple cell addresses corresponding to the same cell format, a format description in natural language is generated; as well as The worksheet representation is updated by adding the aforementioned format description.
18. The apparatus according to claim 12, wherein, When executed, the computer-executable instructions also cause the processor to: Obtain the address range of merged cells in the aforementioned set of cells; and The worksheet representation is updated by adding the address range of the merged cells.
19. The apparatus according to claim 12, wherein, When executed, the computer-executable instructions also cause the processor to: Calculate the number of word blocks represented by the worksheet; In response to the number of word chunks exceeding the word chunk limit of the language model, the worksheet is split into multiple sub-worksheets; The multiple sub-worksheets are respectively encoded into multiple sub-worksheet representations; For each sub-worksheet, the tables in the sub-worksheet are detected using the language model based on the sub-worksheet representation corresponding to the sub-worksheet, to obtain one or more tables; as well as The one or more tables are merged using predefined merge rules to obtain the table detection results for the worksheet.
20. A computer program product for worksheet encoding, comprising a computer program that is executed by a processor to: Encode a group of cells in a worksheet to obtain a set of cell codes, each cell code including the cell address and cell content of the corresponding cell; By using the cell content as the index of the cell address, the set of cell codes is converted into a set of inverted codes; Identify multiple inverted codes with the same cell content within the set of inverted codes; The identified multiple inverted codes are merged into a merged code, which includes the contents of the same cell and a merged address formed by merging the cell addresses of the multiple inverted codes; as well as The merged code and the remaining inverted codes in the set of inverted codes are combined to form the worksheet representation of the worksheet.