Form frame generation method and device

By obtaining and utilizing the text coordinates of each text in the table, generating and merging table borders, the problem of the inability to effectively generate table borders in the existing technology when text arrangement is crowded, and effective border generation for any table structure is realized.

CN119720968APending Publication Date: 2025-03-28ZHUHAI KINGSOFT OFFICE SOFTWARE +2
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311265470.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-09-27
Publication Date
2025-03-28

AI Technical Summary

Technical Problem

When generating table borders of borderless tables, the prior art depends on the gaps between texts, resulting in the inability to effectively generate table borders when the text arrangement is crowded and the gaps are narrow.

Method used

By getting the text coordinates of each text in the table, classifying the text to generate candidate text sets, using these text coordinates to generate horizontal and vertical borders on the table, and combining them to generate a complete table border.

Benefits of technology

It is realized that table borders are effectively generated in any table structure, including crowded text arrangement and narrow gaps in any table structure, solving the problem of insufficient generation of the prior art.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119720968A_ABST
    Figure CN119720968A_ABST
Patent Text Reader

Abstract

The invention relates to a table frame generation method and device, and the method comprises the steps: obtaining a table of a to-be-generated table frame, and determining the text coordinate of each text in the table; generating a table transverse frame and a table vertical frame for the table through the text coordinate of each text in the table; and combining the transverse frame of the table and the vertical frame of the table to obtain a table frame of the table. In this way, the table frame of the table is generated depending on the text coordinate of each text in the table, the table frame is not inserted depending on gaps between the texts in the table any more, and the table frame can still be effectively generated even if text arrangement in the table is crowded and the gaps between the texts are very narrow.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a method and device for generating a table border. Background Art

[0002] A borderless table is a table structure that has a table layout but lacks a table border. Currently, in scenarios such as table restoration and table format conversion, for borderless tables, it is necessary to generate corresponding table borders to restore the table structure.

[0003] Currently, for borderless tables, the corresponding table border is generated by inserting the table border only based on the gap between texts in the borderless table. However, when the text in the borderless table is crowded and the gap between texts is very narrow, the table border cannot be effectively generated. Summary of the invention

[0004] In order to solve the above technical problem that for borderless tables, the method of generating corresponding table borders is to insert table borders only based on the gaps between texts in the borderless table, and when the texts in the borderless table are crowded and the gaps between texts are very narrow, the table border cannot be effectively generated, the embodiments of the present application provide a method, device, electronic device and storage medium for generating table borders. The specific technical solutions are as follows:

[0005] In a first aspect of an embodiment of the present application, a method for generating a table border is first provided, the method comprising:

[0006] Obtain a table whose table border is to be generated, and determine the text coordinates of each text in the table;

[0007] Generate a table horizontal border and a table vertical border for the table according to the text coordinates of each text in the table;

[0008] The horizontal border of the table and the vertical border of the table are merged to obtain a table border of the table.

[0009] In an optional implementation, generating a table horizontal border and a table vertical border for the table according to the text coordinates of each text in the table includes:

[0010] Classifying all texts in the table according to the text coordinates of each text in the table to obtain a plurality of candidate text sets, wherein the texts in each candidate text set belong to the same row;

[0011] Generate a table horizontal border for the table using the text coordinates of the texts in the plurality of candidate text sets;

[0012] A vertical border of the table is generated for the table by using the gaps between adjacent texts in the plurality of candidate text sets.

[0013] In an optional implementation, all the texts in the table are classified according to the text coordinates of each text in the table to obtain a plurality of candidate text sets, including:

[0014] Traversing the text coordinates of each of the texts in the table, storing the texts with similar Y-axis coordinate values ​​in the text coordinates into a candidate text set, and obtaining a plurality of candidate text sets;

[0015] Among them, the Y-axis difference between the Y-axis coordinate values ​​in the text coordinates that are similar to text is less than a preset Y-axis difference threshold.

[0016] In an optional implementation manner, the text coordinates of each of the texts in the table are traversed, and the texts with similar Y-axis coordinate values ​​in the text coordinates are stored in a candidate text set to obtain multiple candidate text sets, including:

[0017] Sort all texts in the table according to the Y-axis coordinate values ​​in the text coordinates;

[0018] According to the sorting result, the text coordinates of each text in the table are traversed, and the following processing is performed to obtain multiple candidate text sets:

[0019] Obtain the first coordinate value of the Y axis in the text coordinates of the text, and the second coordinate value of the Y axis in the text coordinates of the previous text that has been traversed;

[0020] When the first coordinate value of the Y-axis is close to the second coordinate value of the Y-axis, the text is stored in the candidate text set where the last traversed text is located;

[0021] In the case that the first Y-axis coordinate value is not close to the second Y-axis coordinate value, a candidate text set is created, and the text is stored in the created candidate text set.

[0022] In an optional implementation, generating a table horizontal border for the table using the text coordinates of the texts in the plurality of candidate text sets includes:

[0023] For any of the candidate text sets, determining an average Y-axis coordinate value corresponding to the Y-axis coordinate value of the text coordinates of the text in the candidate text set;

[0024] According to the average value of the Y-axis coordinate, insert an initial table horizontal border of the table corresponding to the candidate text set;

[0025] The initial table horizontal borders corresponding to the candidate text sets are screened to obtain the table horizontal borders of the table.

[0026] In an optional implementation, before the screening process of the plurality of initial table horizontal borders corresponding to the plurality of candidate text sets to obtain the table horizontal border of the table, the process further includes:

[0027] Selecting a target candidate text set from the plurality of candidate text sets, wherein the row to which the text in the target candidate text set belongs is the last row in the table;

[0028] Determine an average value of widths corresponding to the widths of the circumscribed rectangular boxes of the texts in the target candidate text set;

[0029] According to the average width, an initial table horizontal border of the table corresponding to the target candidate text set is inserted below the text in the target candidate text set.

[0030] In an optional implementation, the screening process of the plurality of initial table horizontal borders corresponding to the plurality of candidate text sets to obtain the table horizontal border of the table includes:

[0031] Searching for adjacent initial table horizontal borders from a plurality of initial table horizontal borders corresponding to a plurality of candidate text sets;

[0032] Determine the distance between adjacent horizontal borders of the initial table, and determine whether the distance is less than a preset distance threshold;

[0033] When the distance is less than the preset distance threshold, deleting any one of the adjacent initial table horizontal borders;

[0034] The remaining initial table horizontal border is subjected to tilt correction to obtain the table horizontal border of the table.

[0035] In an optional implementation, the step of performing tilt correction on the remaining horizontal border of the initial table to obtain the horizontal border of the table includes:

[0036] The tilt angle of the table is determined, and the remaining horizontal border of the initial table is tilt-corrected according to the tilt angle to obtain the horizontal border of the table.

[0037] In an optional implementation, generating a vertical border for the table by using gaps between adjacent texts in a plurality of the candidate text sets includes:

[0038] For any of the candidate text sets, finding gaps between adjacent texts in the candidate text set, and evenly inserting vertical line segments in the gaps between adjacent texts;

[0039] Deduplication processing is performed on all the vertical line segments, and the remaining vertical line segments are classified to obtain a plurality of vertical line segment sets, wherein the vertical line segments in each vertical line segment set belong to the same column;

[0040] A table vertical border is generated for the table through the plurality of vertical line segment sets.

[0041] In an optional implementation, before performing deduplication processing on all the vertical line segments, the method further includes:

[0042] For any of the candidate text sets, searching for the leftmost text in the table in the candidate text set and the rightmost text in the table;

[0043] Determine a left gap between the leftmost text in the table and the left border of the table, and evenly insert vertical line segments in the left gap;

[0044] A right gap between the rightmost text in the table and the right border of the table is determined, and vertical line segments are evenly inserted in the right gap.

[0045] In an optional implementation, the performing deduplication processing on all the vertical line segments includes:

[0046] Find adjacent vertical line segments from all the vertical line segments, and determine the horizontal distances between the adjacent vertical line segments;

[0047] When the horizontal distance is less than a preset horizontal distance threshold, any one of the adjacent vertical line segments is deleted.

[0048] In an optional implementation, the remaining vertical line segments are classified to obtain a plurality of vertical line segment sets, including:

[0049] Traversing the remaining vertical line segments, storing the vertical line segments with similar X-axis coordinate values ​​into a vertical line segment set, and obtaining multiple vertical line segment sets;

[0050] The similarity refers to that the X-axis difference between the X-axis coordinate values ​​corresponding to the vertical line segments is less than a preset X-axis difference threshold.

[0051] In an optional implementation, the traversing of the remaining vertical line segments and storing the vertical line segments with similar X-axis coordinate values ​​into a vertical line segment set to obtain multiple vertical line segment sets include:

[0052] Sort the remaining vertical line segments according to the X-axis coordinate values ​​corresponding to the vertical line segments;

[0053] According to the sorting result, traverse the remaining vertical line segments and perform the following processing to obtain multiple vertical line segment sets;

[0054] Obtain the first X-axis coordinate value corresponding to the vertical line segment and the second X-axis coordinate value corresponding to the previous vertical line segment that has been traversed;

[0055] When the first X-axis coordinate value is close to the second X-axis coordinate value, the vertical line segment is stored in the vertical line segment set where the last vertical line segment that has been traversed is located;

[0056] When the first X-axis coordinate value is not close to the second X-axis coordinate value, a vertical line segment set is created, and the vertical line segment is stored in the created vertical line segment set.

[0057] In an optional implementation, generating a vertical border for the table by using the plurality of vertical line segment sets includes:

[0058] For any of the vertical line segment sets, determining an X-axis average value of X-axis coordinates corresponding to the vertical line segments in the vertical line segment set;

[0059] According to the X-axis average value, a vertical border of the table corresponding to the vertical line segment set is inserted.

[0060] In an optional implementation, inserting a vertical border of the table corresponding to the vertical line segment set according to the X-axis average value includes:

[0061] According to the X-axis average value, insert the vertical border of the reference table corresponding to the vertical line segment set;

[0062] The vertical border of the reference table is extended to obtain the vertical border of the table.

[0063] In a second aspect of the embodiments of the present application, a device for generating a table border is further provided, the device comprising:

[0064] A table acquisition module is used to acquire the table whose table border is to be generated;

[0065] A coordinate determination module, used to determine the text coordinates of each text in the table;

[0066] A border generation module, used for generating a table horizontal border and a table vertical border for the table according to the text coordinates of each text in the table;

[0067] The frame merging module is used to merge the horizontal frame of the table and the vertical frame of the table to obtain the table frame of the table.

[0068] In an optional implementation, the border generation module specifically includes:

[0069] A text classification submodule, used for classifying all the texts in the table according to the text coordinates of each text in the table to obtain a plurality of candidate text sets, wherein the texts in each candidate text set belong to the same row;

[0070] A table horizontal border generation submodule, used for generating a table horizontal border for the table according to the text coordinates of the texts in the plurality of candidate text sets;

[0071] The table vertical border generation submodule is used to generate a table vertical border for the table by using the gaps between adjacent texts in the plurality of candidate text sets.

[0072] In an optional implementation, the text classification submodule specifically includes:

[0073] A text classification unit, used for traversing the text coordinates of each of the texts in the table, storing the texts with similar Y-axis coordinate values ​​in the text coordinates into a candidate text set, and obtaining a plurality of candidate text sets;

[0074] Among them, the Y-axis difference between the Y-axis coordinate values ​​in the text coordinates that are similar to text is less than a preset Y-axis difference threshold.

[0075] In an optional implementation, the text classification unit is specifically used for:

[0076] Sort all texts in the table according to the Y-axis coordinate values ​​in the text coordinates;

[0077] According to the sorting result, the text coordinates of each text in the table are traversed, and the following processing is performed to obtain multiple candidate text sets:

[0078] Obtain the first coordinate value of the Y axis in the text coordinates of the text, and the second coordinate value of the Y axis in the text coordinates of the previous text that has been traversed;

[0079] When the first coordinate value of the Y-axis is close to the second coordinate value of the Y-axis, the text is stored in the candidate text set where the last traversed text is located;

[0080] In the case that the first Y-axis coordinate value is not close to the second Y-axis coordinate value, a candidate text set is created, and the text is stored in the created candidate text set.

[0081] In an optional implementation, the table horizontal border generation submodule specifically includes:

[0082] A Y-axis coordinate average value determining unit, used for determining, for any of the candidate text sets, a Y-axis coordinate average value corresponding to the Y-axis coordinate values ​​of the text coordinates of the text in the candidate text set;

[0083] An initial table horizontal border first insertion unit, used for inserting an initial table horizontal border of the table corresponding to the candidate text set according to the Y-axis coordinate average value;

[0084] The initial table horizontal border screening processing unit is used to screen the multiple initial table horizontal borders corresponding to the multiple candidate text sets to obtain the table horizontal borders of the table.

[0085] In an optional embodiment, the device further comprises:

[0086] A text set selection unit, configured to select a target candidate text set from the plurality of candidate text sets, wherein the row to which the text in the target candidate text set belongs is the last row in the table;

[0087] A width average value determining unit, used to determine a width average value corresponding to the width of the circumscribed rectangular box of the text in the target candidate text set;

[0088] The second initial table horizontal border inserting unit is used to insert an initial table horizontal border of the table corresponding to the target candidate text set below the text in the target candidate text set according to the average width.

[0089] In an optional implementation, the initial table horizontal border screening processing unit specifically includes:

[0090] an initial table horizontal border searching subunit, used for searching adjacent initial table horizontal borders from a plurality of initial table horizontal borders corresponding to a plurality of candidate text sets;

[0091] A distance judgment subunit, used to determine the distance between adjacent horizontal borders of the initial table, and to judge whether the distance is less than a preset distance threshold;

[0092] An initial table horizontal border deletion subunit, used for deleting any one of the adjacent initial table horizontal borders when the distance is less than the preset distance threshold;

[0093] The initial table horizontal frame correction subunit is used to perform tilt correction on the remaining initial table horizontal frame to obtain the table horizontal frame of the table.

[0094] In an optional implementation, the initial table horizontal border correction subunit is specifically used for:

[0095] The tilt angle of the table is determined, and the remaining horizontal border of the initial table is tilt-corrected according to the tilt angle to obtain the horizontal border of the table.

[0096] In an optional implementation, the table vertical border generation submodule specifically includes:

[0097] A vertical line segment first inserting unit, used for searching for gaps between adjacent texts in any candidate text set, and uniformly inserting vertical line segments in the gaps between adjacent texts;

[0098] A vertical line segment deduplication unit, used for performing deduplication processing on all the vertical line segments;

[0099] A vertical line segment classification unit, used for classifying the remaining vertical line segments to obtain a plurality of vertical line segment sets, wherein the vertical line segments in each vertical line segment set belong to the same column;

[0100] The table vertical border generating unit is used to generate a table vertical border for the table by using a plurality of the vertical line segment sets.

[0101] In an optional embodiment, the device further comprises:

[0102] A text search unit, configured to search, for any of the candidate text sets, the leftmost text in the table in the candidate text set and the rightmost text in the table;

[0103] A second vertical line segment insertion unit is used to determine a left gap between the leftmost text in the table and the left border of the table, and to insert vertical line segments uniformly in the left gap;

[0104] The vertical line segment inserting third unit is used to determine the right gap between the rightmost text in the table and the right border of the table, and to insert vertical line segments uniformly in the right gap.

[0105] In an optional implementation, the vertical line segment deduplication unit is specifically used to:

[0106] Find adjacent vertical line segments from all the vertical line segments, and determine the horizontal distances between the adjacent vertical line segments;

[0107] When the horizontal distance is less than a preset horizontal distance threshold, any one of the adjacent vertical line segments is deleted.

[0108] In an optional implementation, the vertical line segment classification unit specifically includes:

[0109] A vertical line segment classification subunit is used to traverse the remaining vertical line segments, store the vertical line segments with similar X-axis coordinate values ​​into a vertical line segment set, and obtain multiple vertical line segment sets;

[0110] The similarity refers to that the X-axis difference between the X-axis coordinate values ​​corresponding to the vertical line segments is less than a preset X-axis difference threshold.

[0111] In an optional implementation, the vertical line segment classification subunit is specifically used for:

[0112] Sort the remaining vertical line segments according to the X-axis coordinate values ​​corresponding to the vertical line segments;

[0113] According to the sorting result, traverse the remaining vertical line segments and perform the following processing to obtain multiple vertical line segment sets;

[0114] Obtain the first X-axis coordinate value corresponding to the vertical line segment and the second X-axis coordinate value corresponding to the previous vertical line segment that has been traversed;

[0115] When the first X-axis coordinate value is close to the second X-axis coordinate value, the vertical line segment is stored in the vertical line segment set where the last vertical line segment that has been traversed is located;

[0116] When the first X-axis coordinate value is not close to the second X-axis coordinate value, a vertical line segment set is created, and the vertical line segment is stored in the created vertical line segment set.

[0117] In an optional implementation, the table vertical border generating unit specifically includes:

[0118] An X-axis average value determining subunit is used to determine, for any of the vertical line segment sets, an X-axis average value of X-axis coordinates corresponding to the vertical line segments in the vertical line segment set;

[0119] The table vertical border inserting subunit is used to insert the table vertical border of the table corresponding to the vertical line segment set according to the X-axis average value.

[0120] In an optional implementation, the table vertical border insertion subunit is specifically used for:

[0121] According to the X-axis average value, insert the vertical border of the reference table corresponding to the vertical line segment set;

[0122] The vertical border of the reference table is extended to obtain the vertical border of the table.

[0123] In a third aspect of the embodiments of the present application, there is further provided an electronic device, comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus;

[0124] Memory, used to store computer programs;

[0125] The processor is used to implement any method for generating a table border as described in the first aspect above when executing a program stored in the memory.

[0126] In a fourth aspect of the embodiments of the present application, a storage medium is further provided, wherein instructions are stored in the storage medium, and when the storage medium is run on a computer, the computer executes the method for generating a table border as described in any one of the first aspects above.

[0127] In a fifth aspect of the embodiments of the present application, a computer program product comprising instructions is also provided, which, when executed on a computer, enables the computer to execute any of the above-mentioned methods for generating a table border.

[0128] The technical solution provided by the embodiment of the present application obtains a table for which a table border is to be generated, determines the text coordinates of each text in the table, generates a table horizontal border and a table vertical border for the table through the text coordinates of each text in the table, and merges the table horizontal border and the table vertical border to obtain a table border of the table. By using the text coordinates of each text in the table, a table horizontal border and a table vertical border are generated for the table, and the table horizontal border and the table vertical border are merged to obtain a table border of the table. In this way, the table border of the table is generated by relying on the text coordinates of each text in the table, and no longer relies on the gaps between the texts in the table to insert the table border. Even if the text arrangement in the table is relatively crowded and the gaps between the texts are very narrow, the table border can still be effectively generated. BRIEF DESCRIPTION OF THE DRAWINGS

[0129] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.

[0130] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0131] One or more embodiments are exemplarily described by pictures in the corresponding drawings, and these exemplified descriptions do not constitute limitations on the embodiments. Elements with the same reference numerals in the drawings represent similar elements, and unless otherwise stated, the figures in the drawings do not constitute proportional limitations.

[0132] Figure 1 A schematic diagram of an implementation flow of a method for generating a table border shown in an embodiment of the present application;

[0133] Figure 2 A schematic diagram of a borderless table shown in an embodiment of the present application;

[0134] Figure 3 A schematic diagram of a complete table border of a table shown in an embodiment of the present application;

[0135] Figure 4 It is a schematic diagram of an implementation process of another method for generating a table border shown in an embodiment of the present application;

[0136] Figure 5 It is a schematic diagram of the implementation process of a method for generating a horizontal border of a table shown in an embodiment of the present application;

[0137] Figure 6 A schematic diagram of inserting a horizontal border into a borderless table shown in an embodiment of the present application;

[0138] Figure 7 It is a schematic diagram of the implementation process of a method for generating a vertical border of a table shown in an embodiment of the present application;

[0139] Figure 8 This is a schematic diagram of uniformly inserting multiple vertical line segments into the gaps between adjacent texts shown in an embodiment of the present application;

[0140] Fig. 9 A schematic diagram of inserting a vertical border into a borderless table shown in an embodiment of the present application;

[0141] Fig.10 It is a structural schematic diagram of a device for generating a table border shown in an embodiment of the present application;

[0142] Fig.11 It is a schematic diagram of the structure of an electronic device shown in an embodiment of the present application. DETAILED DESCRIPTION

[0143] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.

[0144] The disclosure below provides many different embodiments or examples to realize the different structures of the present application. In order to simplify the disclosure of the present application, the parts and settings of specific examples are described below. Of course, they are only examples, and the purpose is not to limit the present application. In addition, the present application can repeat reference numbers and / or letters in different examples. This repetition is for the purpose of simplification and clarity, and does not itself indicate the relationship between the various embodiments and / or settings discussed.

[0145] like Figure 1 FIG. 1 is a schematic diagram of an implementation flow of a method for generating a table border provided in an embodiment of the present application. The method is applied to an electronic device and may specifically include the following steps:

[0146] S101, obtaining a table whose table border is to be generated, and determining the text coordinates of each text in the table.

[0147] In the embodiment of the present application, in scenarios such as table restoration or table format conversion, it is necessary to generate a corresponding table border for the table. The table here can be a borderless table (such as Figure 2 As shown) or a wired table or a three-line table, etc., the above table can be used as a table for the table border to be generated, thereby obtaining the table for the table border to be generated.

[0148] It should be noted that the table border refers to all border lines in the table, including the horizontal border lines and the vertical border lines, including the outer border lines and the border lines inside the table. Specifically, the table border can be as follows: Figure 3 The horizontal border lines and the vertical border lines are shown.

[0149] For a table whose table border is to be generated, the text coordinates of each text in the table whose table border is to be generated can be determined. In particular, an embodiment of the present application provides a text detection algorithm, according to which the diagonal vertex coordinates of the circumscribed rectangular box of each text in the table whose table border is to be generated are obtained, and the coordinates of the center point of the circumscribed rectangular box are calculated by the diagonal vertex coordinates, and are used as the text coordinates of the text.

[0150] For example, according to the above-mentioned text detection algorithm, the upper left vertex coordinates (x1, y1) and lower right vertex coordinates (x2, y2) of the circumscribed rectangular box of each text in the table to generate the table border are obtained, and the center point coordinates of the circumscribed rectangular box are calculated based on the upper left vertex coordinates (x1, y1) and the lower right vertex coordinates (x2, y2) and used as the text coordinates of the text.

[0151] It should be noted that the diagonal vertex coordinates may be, for example, the upper left vertex coordinates and the lower right vertex coordinates, or may be the lower left vertex coordinates and the upper right vertex coordinates, and this embodiment of the present application does not limit this.

[0152] In addition, the text may be a single character, such as a cell filled with a single character, and this single character may constitute a text, or it may be a plurality of characters gathered together, such as a cell filled with a plurality of characters, and the plurality of characters may also constitute a text.

[0153] S102: Generate a table horizontal border and a table vertical border for the table according to the text coordinates of each text in the table.

[0154] In an embodiment of the present application, for the text coordinates of each text in the table for which the table border is to be generated, a table horizontal border and a table vertical border can be generated for the table for which the table border is to be generated through the text coordinates of each text, which means that the corresponding table horizontal border and table vertical border in the table can be generated depending on the text coordinates of each text in the table.

[0155] It should be noted that, the horizontal border of a table can be understood as the table line in the horizontal direction of the table, and the vertical border of a table can be understood as the table line in the vertical direction of the table, and the embodiments of the present application do not limit this.

[0156] S103, merging the table horizontal border and the table vertical border to obtain a table border of the table.

[0157] In the embodiment of the present application, for the horizontal border and the vertical border of the table, the horizontal border and the vertical border of the table can be merged to obtain a complete table border of the table, which means that the complete table border of the table is composed of the horizontal border and the vertical border of the table, such as Figure 3 shown.

[0158] In this way, the table border of the table is generated by relying on the text coordinates of each text in the table, and no longer relies on the gaps between the texts in the table to insert the table border. Even if the texts in the table are crowded and the gaps between the texts are very narrow, the table border can still be effectively generated.

[0159] Through the above description of the technical solution provided in the embodiment of the present application, a table with a table border to be generated is obtained, the text coordinates of each text in the table are determined, and a horizontal table border and a vertical table border are generated for the table through the text coordinates of each text in the table. The horizontal table border and the vertical table border are merged to obtain a table border of the table.

[0160] Through the text coordinates of each text in the table, a horizontal table border and a vertical table border are generated for the table. The horizontal table border and the vertical table border are merged to obtain the table border of the table. In this way, the table border of the table is generated relying on the text coordinates of each text in the table, and the table border is no longer inserted relying on the gaps between the texts in the table. Even if the texts in the table are crowded and the gaps between the texts are narrow, the table border can still be effectively generated.

[0161] In addition, in the embodiments of the present application, in addition to relying on the text coordinates of each text in the table, you can also rely on the gaps between the texts in the table, that is, combining the text coordinates of each text in the table and the gaps between the texts in the table, you can further accurately generate the table border of the table, especially in the face of the text arrangement in the table is relatively crowded and the gaps between the texts are very narrow, you can also further accurately generate the table border of the table.

[0162] Based on this, Figure 4 FIG. 1 is a schematic diagram of an implementation flow of another method for generating a table border provided in an embodiment of the present application. The method is applied to an electronic device and may specifically include the following steps:

[0163] S401, obtaining a table whose table border is to be generated, and determining the text coordinates of each text in the table.

[0164] In the embodiment of the present application, this step is similar to the above-mentioned step S101, and the embodiment of the present application will not be described one by one here.

[0165] S402, classifying all texts in the table according to the text coordinates of each text in the table to obtain a plurality of candidate text sets, wherein the texts in each candidate text set belong to the same row.

[0166] In an embodiment of the present application, a text clustering algorithm is proposed to classify all texts in a table by row, which means that texts belonging to the same row are divided into a candidate text set. Thus, according to the text coordinates of each text in the table, all texts in the table are classified to obtain multiple candidate text sets, wherein the texts in each candidate text set belong to the same row, which means that the texts in each candidate text set belong to the same row in the table.

[0167] Among them, for the text clustering algorithm, its core is to traverse each text in the table and assign texts with similar y-axis coordinates in the text coordinates to the same row. Based on this, the text coordinates of each text in the table are traversed, and the texts with similar Y-axis coordinate values ​​in the text coordinates are stored in a candidate text set to obtain multiple candidate text sets, and the texts in each candidate text set belong to the same row; wherein the Y-axis difference between the Y-axis coordinate values ​​in the text coordinates of the similar texts is less than the preset Y-axis difference threshold.

[0168] It should be noted that after clustering this article, multiple candidate text sets with row number identifiers can be obtained, and the candidate text set can represent which texts are in the Nth row of the table, where N is a positive integer. In addition, the row number identifier can be customized, such as 1, 2, 3..., in order to distinguish different rows, and this embodiment of the application does not limit this.

[0169] In addition, for the text clustering algorithm, it can be further as follows: sort all the texts in the table according to the Y-axis coordinate value in the text coordinates; according to the sorting result, traverse the text coordinates of each text in the table, and perform the following processing to obtain multiple candidate text sets: obtain the first Y-axis coordinate value in the text coordinates of the text, and the second Y-axis coordinate value in the text coordinates of the previous text that has been traversed; when the first Y-axis coordinate axis and the second Y-axis coordinate value are close, store the text in the candidate text set where the previous text that has been traversed is located; when the first Y-axis coordinate axis and the second Y-axis coordinate value are not close, create a candidate text set and store the text in the created candidate text set.

[0170] For example, all texts in the table are sorted from small to large according to the Y-axis coordinate value in the text coordinates. The sorting result here affects the traversal order of the text, such as the traversal order of the text ranked first is 1, the traversal order of the text ranked second is 2, and so on. Therefore, according to the sorting result, the text coordinates of each text in the table are traversed, and the following processing is performed to obtain multiple candidate text sets: obtain Y1 in the text coordinates of the text and Y2 in the text coordinates of the last text that has been traversed. When Y1 and Y2 are close, the text is stored in the candidate text set where the last text that has been traversed is located. When Y1 and Y2 are not close, a candidate text set is created and the text is stored in the created candidate text set.

[0171] S403: Generate a table horizontal border for the table using the text coordinates of the texts in the plurality of candidate text sets.

[0172] In the embodiment of the present application, after the text classification is completed, multiple candidate text sets are obtained, and the texts in each candidate text set belong to the same row. Therefore, the horizontal border of the table can be generated for the table through the text coordinates of the texts in the multiple candidate text sets.

[0173] Among them, multiple candidate text sets can be traversed, and the initial table horizontal border of the table corresponding to the candidate text set can be inserted through the text coordinates of the text in the candidate text set, and then all the initial table horizontal borders are screened to obtain the table horizontal border of the table.

[0174] Based on this, Figure 5 FIG. 1 is a schematic diagram of an implementation flow of a method for generating a horizontal border of a table provided in an embodiment of the present application. The method is applied to an electronic device and may specifically include the following steps:

[0175] S501 : for any candidate text set, determining the Y-axis coordinate average value corresponding to the Y-axis coordinate values ​​of the text coordinates of the text in the candidate text set.

[0176] S502: inserting an initial table horizontal border of the table corresponding to the candidate text set according to the average value of the Y-axis coordinate.

[0177] In an embodiment of the present application, for any candidate text set, the Y-axis coordinate average value corresponding to the Y-axis coordinate value of the text coordinates of the text in the candidate text set is determined, and the initial table horizontal border of the table corresponding to the candidate text set is inserted according to the Y-axis coordinate average value, which means that the initial table horizontal border is inserted for each row in the table.

[0178] It should be noted that inserting the initial table horizontal border of the table corresponding to the candidate text set according to the average value of the Y-axis coordinate is actually inserting the initial table horizontal border. The Y-axis coordinate value corresponding to the table horizontal border is the average value of the Y-axis coordinate, and the starting position and ending position of the table horizontal border are both within the left and right range of the table. The embodiments of the present application are not limited to this.

[0179] In addition, in the embodiment of the present application, in order to fill the horizontal border of the table, an additional horizontal border needs to be added to the last row in the table. For example, if there are 3 rows in the table, there should be 4 horizontal borders in theory. After the above processing, a horizontal border can be added above each row. For this purpose, a horizontal border needs to be added below the last row of the table, such as Figure 6 shown.

[0180] Based on this, a target candidate text set is selected from multiple candidate text sets, and the behavior to which the text in the target candidate text set belongs is the last row in the table; the average width corresponding to the width of the circumscribed rectangular box of the text in the target candidate text set is determined; according to the average width, an initial table horizontal border of the table corresponding to the target candidate text set is inserted below the text in the target candidate text set.

[0181] It should be noted that, according to the average width, the initial table horizontal border of the table corresponding to the target candidate text set is inserted below the text in the target candidate text set. Specifically, the initial table horizontal border may be inserted below the text in the target candidate text set, and the distance between the initial table horizontal border and the upper boundary of the circumscribed rectangular box of the text in the target candidate text set is the average width, and the starting position and the ending position of the initial table horizontal border are both within the left and right range of the table. The embodiments of the present application are not limited to this.

[0182] S503: Screening multiple initial table horizontal borders corresponding to multiple candidate text sets to obtain a table horizontal border of the table.

[0183] In the embodiment of the present application, after the above processing, for each candidate text set, there is a corresponding initial table horizontal border, and multiple initial table horizontal borders corresponding to multiple candidate text sets can be screened to obtain the table horizontal border of the table. Among them, the screening process mainly deletes redundant initial table horizontal borders and performs tilt correction on the initial table horizontal border.

[0184] Specifically, adjacent initial table horizontal borders are searched from multiple initial table horizontal borders corresponding to multiple candidate text sets; the distance between adjacent initial table horizontal borders is determined, and it is judged whether the distance is less than a preset distance threshold; when the distance is less than the preset distance threshold, any initial table horizontal border among the adjacent initial table horizontal borders is deleted; and the remaining initial table horizontal borders are tilt-corrected to obtain the table horizontal border of the table.

[0185] It should be noted that the initial horizontal table border is generated based on the text coordinates of the text in the same row. For different rows, the gaps may be smaller and essentially belong to the same row, resulting in redundant initial table horizontal borders. Therefore, the redundant initial table horizontal borders need to be deleted.

[0186] In addition, the table itself may be tilted, so its horizontal table border also needs to be tilted, so the remaining initial table horizontal border needs to be tilted. The tilt angle of the table can be determined, and the remaining initial table horizontal border is tilted according to the tilt angle to obtain the table horizontal border of the table.

[0187] S404: Generate a vertical border for the table by using the gaps between adjacent texts in the plurality of candidate text sets.

[0188] In the embodiment of the present application, after the text classification is completed, multiple candidate text sets are obtained, and the texts in each candidate text set belong to the same row. Therefore, a vertical border of the table can be generated for the table through the gaps between adjacent texts in the multiple candidate text sets.

[0189] Among them, vertical line segments can be inserted by row, that is, vertical line segments of each row are generated separately, and then the vertical line segments are deduplicated and clustered to obtain multiple vertical line segment sets. The vertical line segments in each vertical line segment set belong to the same column, so that the vertical borders of the table are generated for the table through multiple vertical line segment sets.

[0190] Based on this, Figure 7 FIG. 1 is a schematic diagram of an implementation flow of a method for generating a vertical border of a table provided in an embodiment of the present application. The method is applied to an electronic device and may specifically include the following steps:

[0191] S701 , for any candidate text set, finding gaps between adjacent texts in the candidate text set, and evenly inserting vertical line segments in the gaps between adjacent texts.

[0192] In the embodiment of the present application, for each candidate text set, the texts therein belong to the same row, for any candidate text set, the gaps (referring to the horizontal gaps) between adjacent texts in the candidate text set are found, and vertical line segments are uniformly inserted in the gaps between adjacent texts. Here, uniformly inserting vertical line segments refers to inserting vertical line segments at equal intervals (or spacings) in the gaps, which means that the intervals between any two vertical line segments inserted are equal.

[0193] It should be noted that vertical line segments are evenly inserted in the gaps between adjacent texts, and the starting and ending positions of the vertical line segments are in the gaps between adjacent texts, that is, they cannot exceed the upper and lower boundaries of the circumscribed rectangular frames of the adjacent texts. This embodiment of the present application does not limit this.

[0194] For example, taking the adjacent texts "age" and "name" as examples, vertical line segments are evenly inserted in the gaps between the adjacent texts. Here, multiple vertical line segments are evenly inserted, such as Figure 8 As shown, the same is true for the processing of the remaining adjacent texts.

[0195] In addition, in the embodiment of the present application, after the above processing, multiple vertical line segments are evenly inserted into the gaps between adjacent texts belonging to the same row in the table, and the vertical borders of the table in the table can be generated through these vertical line segments later, but the leftmost vertical borders of the table and the rightmost vertical borders of the table cannot be generated, so it is necessary to use the leftmost text and the rightmost text of each row in the table to generate the leftmost vertical borders of the table and the rightmost vertical borders of the table. As the leftmost text and the rightmost text of each row in the table cannot form a gap with other texts, special processing is required so that the leftmost vertical borders of the table and the rightmost vertical borders of the table can be generated.

[0196] To this end, in an embodiment of the present application, for any candidate text set, the leftmost text in the table and the rightmost text in the table in the candidate text set are searched; the left gap between the leftmost text in the table and the left border of the table is determined, and vertical line segments are evenly inserted in the left gap; the right gap between the rightmost text in the table and the right border of the table is determined, and vertical line segments are evenly inserted in the right gap.

[0197] It should be noted that, for any candidate text set, the texts in the candidate text set can be sorted according to the X-axis coordinate value of the text coordinate (for example, sorted from small to large), so as to find the leftmost text in the table in the candidate text set and the rightmost text in the table. The embodiments of the present application are not limited to this.

[0198] In addition, for tables, which are usually located in electronic documents, table detection is performed on the electronic document through a table detection algorithm to obtain the table in the electronic document and limit the range of the table, that is, it is clarified that the table has four upper, lower, left and right boundaries to limit the range of the table. In this way, the left gap between the leftmost text in the table and the left boundary of the table can be determined, and multiple vertical line segments are evenly inserted in the left gap, and the right gap between the rightmost text in the table and the right boundary of the table can be determined, and multiple vertical line segments are evenly inserted in the right gap.

[0199] S702, performing deduplication processing on all vertical line segments, and classifying the remaining vertical line segments to obtain multiple vertical line segment sets, wherein the vertical line segments in each vertical line segment set belong to the same column.

[0200] In an embodiment of the present application, a deduplication operation can be performed on all vertical line segments, that is, all vertical line segments are deduplicated, and then the remaining vertical line segments can be clustered, that is, the remaining vertical line segments are classified to obtain multiple vertical line segment sets, and the vertical line segments in each vertical line segment set belong to the same column.

[0201] Specifically, the deduplication process may be to search for adjacent vertical line segments from all vertical line segments and determine the horizontal distance between the adjacent vertical line segments; when the horizontal distance is less than a preset horizontal distance threshold, delete any one of the adjacent vertical line segments.

[0202] The vertical line segment clustering is similar to the above text clustering, the only difference is that the clustering objects are different. The above clustering objects are texts, and the clustering objects here are vertical line segments.

[0203] Based on this, the remaining vertical line segments are traversed, and the vertical line segments with similar X-axis coordinate values ​​are stored in a vertical line segment set to obtain multiple vertical line segment sets, and the vertical line segments in each vertical line segment set belong to the same column; wherein, similar means that the X-axis difference between the X-axis coordinate values ​​corresponding to the vertical line segments is less than a preset X-axis difference threshold.

[0204] Specifically, the remaining vertical line segments are traversed, and the vertical line segments with similar X-axis coordinate values ​​are stored in a vertical line segment set to obtain multiple vertical line segment sets, as shown below: sort the remaining vertical line segments according to the X-axis coordinate values ​​corresponding to the vertical line segments; according to the sorting results, traverse the remaining vertical line segments, perform the following processing, and obtain multiple vertical line segment sets; obtain the first X-axis coordinate value corresponding to the vertical line segment, and the second X-axis coordinate value corresponding to the previous vertical line segment that has been traversed; when the first X-axis coordinate value is close to the second X-axis coordinate value, store the vertical line segment in the vertical line segment set where the previous vertical line segment that has been traversed is located; when the first X-axis coordinate value is not close to the second X-axis coordinate value, create a vertical line segment set, and store the vertical line segment in the created vertical line segment set. Reference can be made to the above-mentioned text clustering, and the embodiments of the present application will not be repeated here one by one.

[0205] S703: Generate a vertical border for the table using multiple vertical line segment sets.

[0206] In the embodiment of the present application, multiple vertical line segment sets can be obtained through the above processing, and the vertical line segments in each vertical line segment set belong to the same column. Therefore, a vertical border of a table can be generated for the table through multiple vertical line segment sets.

[0207] Among them, for any vertical line segment set, the X-axis average value of the X-axis coordinates corresponding to the vertical line segments in the vertical line segment set is determined; according to the X-axis average value, the table vertical border of the table corresponding to the vertical line segment set is inserted, so as to generate a table vertical border for the table, such as Fig. 9 shown.

[0208] It should be noted that inserting a vertical border of the table corresponding to the vertical line segment set according to the X-axis average value is actually inserting a vertical border of the table. The X-axis coordinate corresponding to the vertical border of the table is the X-axis average value, and the starting and ending positions of the vertical border of the table do not exceed the range of the table.

[0209] In addition, in the embodiment of the present application, a reference table vertical border corresponding to the vertical line segment set can be inserted according to the X-axis average value; the reference table vertical border is extended to obtain the table vertical border of the table.

[0210] It should be noted that the vertical border of the base table may be a short line segment and needs to be further extended so that each vertical border of the base table can cover all rows in the table and cannot exceed the range of the table, so that the vertical border of the table can be obtained.

[0211] In addition, the table itself may be tilted, so its vertical border must also be tilted accordingly. Therefore, the tilt angle of the table can be determined, and the vertical border of the table can be tilt-corrected according to the tilt angle to obtain the final vertical border of the table.

[0212] S405: Merge the table horizontal border and the table vertical border to obtain a table border of the table.

[0213] In the embodiment of the present application, this step is similar to the above-mentioned step S103, and the embodiment of the present application will not be described one by one here.

[0214] In this way, by combining the text coordinates of each text in the table and the gaps between the texts in the table, the table border of the table can be further accurately generated, especially in the scenario where the texts in the table are crowded and the gaps between the texts are very narrow, the table border of the table can be further accurately generated.

[0215] Corresponding to the above method embodiment, the present application embodiment also provides a device for generating a table border, such as Fig.10 As shown, the device may include: a table acquisition module 1010 , a coordinate determination module 1020 , a frame generation module 1030 , and a frame merging module 1040 .

[0216] The table acquisition module 1010 is used to acquire the table whose table border is to be generated;

[0217] A coordinate determination module 1020, used to determine the text coordinates of each text in the table;

[0218] A border generation module 1030, configured to generate a table horizontal border and a table vertical border for the table according to the text coordinates of each text in the table;

[0219] The border merging module 1040 is used to merge the horizontal border of the table and the vertical border of the table to obtain the table border of the table.

[0220] In an optional implementation, the border generation module specifically includes:

[0221] A text classification submodule, used for classifying all the texts in the table according to the text coordinates of each text in the table to obtain a plurality of candidate text sets, wherein the texts in each candidate text set belong to the same row;

[0222] A table horizontal border generation submodule, used for generating a table horizontal border for the table according to the text coordinates of the texts in the plurality of candidate text sets;

[0223] The table vertical border generation submodule is used to generate a table vertical border for the table by using the gaps between adjacent texts in the plurality of candidate text sets.

[0224] In an optional implementation, the text classification submodule specifically includes:

[0225] A text classification unit, used for traversing the text coordinates of each of the texts in the table, storing the texts with similar Y-axis coordinate values ​​in the text coordinates into a candidate text set, and obtaining a plurality of candidate text sets;

[0226] Among them, the Y-axis difference between the Y-axis coordinate values ​​in the text coordinates that are similar to text is less than a preset Y-axis difference threshold.

[0227] In an optional implementation, the text classification unit is specifically used for:

[0228] Sort all texts in the table according to the Y-axis coordinate values ​​in the text coordinates;

[0229] According to the sorting result, the text coordinates of each text in the table are traversed, and the following processing is performed to obtain multiple candidate text sets:

[0230] Obtain the first coordinate value of the Y axis in the text coordinates of the text, and the second coordinate value of the Y axis in the text coordinates of the previous text that has been traversed;

[0231] When the first coordinate value of the Y-axis is close to the second coordinate value of the Y-axis, the text is stored in the candidate text set where the last traversed text is located;

[0232] In the case that the first Y-axis coordinate value is not close to the second Y-axis coordinate value, a candidate text set is created, and the text is stored in the created candidate text set.

[0233] In an optional implementation, the table horizontal border generation submodule specifically includes:

[0234] A Y-axis coordinate average value determining unit, used for determining, for any of the candidate text sets, a Y-axis coordinate average value corresponding to the Y-axis coordinate values ​​of the text coordinates of the text in the candidate text set;

[0235] An initial table horizontal border first insertion unit, used for inserting an initial table horizontal border of the table corresponding to the candidate text set according to the Y-axis coordinate average value;

[0236] The initial table horizontal border screening processing unit is used to screen the multiple initial table horizontal borders corresponding to the multiple candidate text sets to obtain the table horizontal borders of the table.

[0237] In an optional embodiment, the device further comprises:

[0238] A text set selection unit, configured to select a target candidate text set from the plurality of candidate text sets, wherein the row to which the text in the target candidate text set belongs is the last row in the table;

[0239] A width average value determining unit, used to determine a width average value corresponding to the width of the circumscribed rectangular box of the text in the target candidate text set;

[0240] The second initial table horizontal border inserting unit is used to insert an initial table horizontal border of the table corresponding to the target candidate text set below the text in the target candidate text set according to the average width.

[0241] In an optional implementation, the initial table horizontal border screening processing unit specifically includes:

[0242] an initial table horizontal border searching subunit, used for searching adjacent initial table horizontal borders from a plurality of initial table horizontal borders corresponding to a plurality of candidate text sets;

[0243] A distance judgment subunit, used to determine the distance between adjacent horizontal borders of the initial table, and to judge whether the distance is less than a preset distance threshold;

[0244] An initial table horizontal border deletion subunit, used for deleting any one of the adjacent initial table horizontal borders when the distance is less than the preset distance threshold;

[0245] The initial table horizontal frame correction subunit is used to perform tilt correction on the remaining initial table horizontal frame to obtain the table horizontal frame of the table.

[0246] In an optional implementation, the initial table horizontal border correction subunit is specifically used for:

[0247] The tilt angle of the table is determined, and the remaining horizontal border of the initial table is tilt-corrected according to the tilt angle to obtain the horizontal border of the table.

[0248] In an optional implementation, the table vertical border generation submodule specifically includes:

[0249] A vertical line segment first inserting unit, used for searching for gaps between adjacent texts in any candidate text set, and uniformly inserting vertical line segments in the gaps between adjacent texts;

[0250] A vertical line segment deduplication unit, used for performing deduplication processing on all the vertical line segments;

[0251] A vertical line segment classification unit, used for classifying the remaining vertical line segments to obtain a plurality of vertical line segment sets, wherein the vertical line segments in each vertical line segment set belong to the same column;

[0252] The table vertical border generating unit is used to generate a table vertical border for the table by using a plurality of the vertical line segment sets.

[0253] In an optional embodiment, the device further comprises:

[0254] A text search unit, configured to search, for any of the candidate text sets, the leftmost text in the table in the candidate text set and the rightmost text in the table;

[0255] A second vertical line segment insertion unit is used to determine a left gap between the leftmost text in the table and the left border of the table, and to insert vertical line segments uniformly in the left gap;

[0256] The vertical line segment inserting third unit is used to determine the right gap between the rightmost text in the table and the right border of the table, and to insert vertical line segments uniformly in the right gap.

[0257] In an optional implementation, the vertical line segment deduplication unit is specifically used to:

[0258] Find adjacent vertical line segments from all the vertical line segments, and determine the horizontal distances between the adjacent vertical line segments;

[0259] When the horizontal distance is less than a preset horizontal distance threshold, any one of the adjacent vertical line segments is deleted.

[0260] In an optional implementation, the vertical line segment classification unit specifically includes:

[0261] A vertical line segment classification subunit is used to traverse the remaining vertical line segments, store the vertical line segments with similar X-axis coordinate values ​​into a vertical line segment set, and obtain multiple vertical line segment sets;

[0262] The similarity refers to that the X-axis difference between the X-axis coordinate values ​​corresponding to the vertical line segments is less than a preset X-axis difference threshold.

[0263] In an optional implementation, the vertical line segment classification subunit is specifically used for:

[0264] Sort the remaining vertical line segments according to the X-axis coordinate values ​​corresponding to the vertical line segments;

[0265] According to the sorting result, traverse the remaining vertical line segments and perform the following processing to obtain multiple vertical line segment sets;

[0266] Obtain the first X-axis coordinate value corresponding to the vertical line segment and the second X-axis coordinate value corresponding to the previous vertical line segment that has been traversed;

[0267] When the first X-axis coordinate value is close to the second X-axis coordinate value, the vertical line segment is stored in the vertical line segment set where the last vertical line segment that has been traversed is located;

[0268] When the first X-axis coordinate value is not close to the second X-axis coordinate value, a vertical line segment set is created, and the vertical line segment is stored in the created vertical line segment set.

[0269] In an optional implementation, the table vertical border generating unit specifically includes:

[0270] An X-axis average value determining subunit is used to determine, for any of the vertical line segment sets, an X-axis average value of X-axis coordinates corresponding to the vertical line segments in the vertical line segment set;

[0271] The table vertical border inserting subunit is used to insert the table vertical border of the table corresponding to the vertical line segment set according to the X-axis average value.

[0272] In an optional implementation, the table vertical border insertion subunit is specifically used for:

[0273] According to the X-axis average value, insert the vertical border of the reference table corresponding to the vertical line segment set;

[0274] The vertical border of the reference table is extended to obtain the vertical border of the table.

[0275] The present application also provides an electronic device, such as Fig.11 As shown, it includes a processor 111, a communication interface 112, a memory 113 and a communication bus 114, wherein the processor 111, the communication interface 112, and the memory 113 communicate with each other through the communication bus 114.

[0276] Memory 113, used for storing computer programs;

[0277] The processor 111 is used to execute the program stored in the memory 113 to implement the following steps:

[0278] Obtain a table for which a table border is to be generated, and determine the text coordinates of each text in the table; generate a table horizontal border and a table vertical border for the table through the text coordinates of each text in the table; merge the table horizontal border and the table vertical border to obtain a table border of the table.

[0279] The communication bus mentioned in the above electronic device can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.

[0280] The communication interface is used for communication between the above electronic device and other devices.

[0281] The memory may include a random access memory (RAM) or a non-volatile memory, such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.

[0282] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.

[0283] In another embodiment provided in the present application, a storage medium is also provided, in which instructions are stored. When the storage medium is run on a computer, the computer executes the method for generating a table border described in any of the above embodiments.

[0284] In another embodiment provided by the present application, a computer program product including instructions is also provided, which, when executed on a computer, enables the computer to execute the method for generating a table border described in any one of the above embodiments.

[0285] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a storage medium, or transmitted from one storage medium to another storage medium, for example, the computer instructions may be transmitted from a website site, a computer, a server or a data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The storage medium may be any available medium that a computer can access or a data storage device such as a server or a data center that includes one or more available media integrations. The available medium may be a magnetic medium, (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive Solid State Disk (SSD)), etc.

[0286] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.

[0287] Each embodiment in this specification is described in a related manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0288] The above description is only a preferred embodiment of the present application and is not intended to limit the protection scope of the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application are included in the protection scope of the present application.

Claims

1. A method for generating a table border, characterized in that: The method comprises: Obtain a table whose table border is to be generated, and determine the text coordinates of each text in the table; Generate a table horizontal border and a table vertical border for the table according to the text coordinates of each text in the table; The horizontal border of the table and the vertical border of the table are merged to obtain a table border of the table.

2. The method according to claim 1, characterized in that The step of generating a table horizontal border and a table vertical border for the table according to the text coordinates of each text in the table includes: Classifying all texts in the table according to the text coordinates of each text in the table to obtain a plurality of candidate text sets, wherein the texts in each candidate text set belong to the same row; Generate a table horizontal border for the table using the text coordinates of the texts in the plurality of candidate text sets; A vertical border of the table is generated for the table by using the gaps between adjacent texts in the plurality of candidate text sets.

3. The method according to claim 2, characterized in that The step of generating a table horizontal border for the table by using the text coordinates of the texts in the plurality of candidate text sets includes: For any of the candidate text sets, determining an average Y-axis coordinate value corresponding to the Y-axis coordinate value of the text coordinates of the text in the candidate text set; According to the average value of the Y-axis coordinate, insert an initial table horizontal border of the table corresponding to the candidate text set; The initial table horizontal borders corresponding to the candidate text sets are screened to obtain the table horizontal borders of the table.

4. The method according to claim 3, characterized in that Before the screening process of the plurality of the initial table horizontal borders corresponding to the plurality of the candidate text sets to obtain the table horizontal border of the table, the method further comprises: Selecting a target candidate text set from the plurality of candidate text sets, wherein the row to which the text in the target candidate text set belongs is the last row in the table; Determine an average value of widths corresponding to the widths of the circumscribed rectangular boxes of the texts in the target candidate text set; According to the average width, an initial table horizontal border of the table corresponding to the target candidate text set is inserted below the text in the target candidate text set.

5. The method according to claim 2, characterized in that: The step of generating a vertical border for the table by using gaps between adjacent texts in the plurality of candidate text sets includes: For any of the candidate text sets, finding gaps between adjacent texts in the candidate text set, and evenly inserting vertical line segments in the gaps between adjacent texts; Deduplication processing is performed on all the vertical line segments, and the remaining vertical line segments are classified to obtain a plurality of vertical line segment sets, wherein the vertical line segments in each vertical line segment set belong to the same column; A table vertical border is generated for the table through the plurality of vertical line segment sets.

6. The method according to claim 5, characterized in that Before performing deduplication processing on all the vertical line segments, the method further includes: For any of the candidate text sets, searching for the leftmost text in the table in the candidate text set and the rightmost text in the table; Determine a left gap between the leftmost text in the table and the left border of the table, and evenly insert vertical line segments in the left gap; A right gap between the rightmost text in the table and the right border of the table is determined, and vertical line segments are evenly inserted in the right gap.

7. The method according to claim 5 or 6, characterized in that: The remaining vertical line segments are classified to obtain a plurality of vertical line segment sets, including: Traversing the remaining vertical line segments, storing the vertical line segments with similar X-axis coordinate values ​​into a vertical line segment set, and obtaining multiple vertical line segment sets; The similarity refers to that the X-axis difference between the X-axis coordinate values ​​corresponding to the vertical line segments is less than a preset X-axis difference threshold.

8. The method according to claim 7, characterized in that The traversing of the remaining vertical line segments, storing the vertical line segments with similar X-axis coordinate values ​​into a vertical line segment set, and obtaining multiple vertical line segment sets, including: Sort the remaining vertical line segments according to the X-axis coordinate values ​​corresponding to the vertical line segments; According to the sorting result, traverse the remaining vertical line segments and perform the following processing to obtain multiple vertical line segment sets; Obtain the first X-axis coordinate value corresponding to the vertical line segment and the second X-axis coordinate value corresponding to the previous vertical line segment that has been traversed; When the first X-axis coordinate value is close to the second X-axis coordinate value, the vertical line segment is stored in the vertical line segment set where the last vertical line segment that has been traversed is located; When the first X-axis coordinate value is not close to the second X-axis coordinate value, a vertical line segment set is created, and the vertical line segment is stored in the created vertical line segment set.

9. The method according to claim 5 or 6, characterized in that: Generating a vertical border for the table by using the plurality of vertical line segment sets includes: For any of the vertical line segment sets, determining an X-axis average value of X-axis coordinates corresponding to the vertical line segments in the vertical line segment set; According to the X-axis average value, a vertical border of the table corresponding to the vertical line segment set is inserted.

10. A device for generating a table border, characterized in that: The device comprises: A table acquisition module is used to acquire the table whose table border is to be generated; A coordinate determination module, used to determine the text coordinates of each text in the table; A border generation module, used for generating a table horizontal border and a table vertical border for the table according to the text coordinates of each text in the table; The frame merging module is used to merge the horizontal frame of the table and the vertical frame of the table to obtain the table frame of the table.