A method, device and storage medium for extracting table data with missing outer border
By determining and supplementing the vertical and horizontal range of the missing outer border in the PDF document, the problem of inaccurate table data extraction in the prior art is solved, and accurate extraction and storage of table data in the PDF document is achieved.
Patent Information
- Application Number
- CN201910871534.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-09-16
- Publication Date
- 2024-10-15
- Estimated Expiration
- 2039-09-18
AI Technical Summary
When the existing technology processes table data with missing outer borders in PDF documents, misconnection problems are prone to occur, resulting in inaccurate extraction.
By obtaining a table with a missing outer border, determine the vertical and horizontal range of the outer border to be supplemented based on the existing table lines, and supplement the outer border based on these ranges to obtain a table with a complete outer border, thereby accurately extracting data.
It achieves the accurate extraction of missing outer border table data in PDF documents, avoids the problem of misconnection, and improves the accuracy of extraction.
Smart Images

Figure CN110598196B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field, and more particularly to a method, device and storage medium for extracting table data with missing outer borders. Background Art
[0002] PDF documents are commonly used documents. When used in specific applications, the table data involved in the PDF document may need to be applied to various fields. For example, in the financial field, authoritative information of enterprises is published in PDF format, such as listing prospectuses, quarterly reports, annual reports, semi-annual reports, etc.
[0003] Through the table extraction technology with missing outer borders, the company's information can be extracted more completely, and the machine-unreadable PDF files can be quickly converted into formatted information; thus laying the foundation for subsequent processing, such as "key-value" identification, map construction, database construction, public opinion analysis, buying and selling recommendations, etc.
[0004] The PDF table extraction process extracts it into formatted list information and stores it in Json, csv or other formatted forms, thereby realizing the extraction of table data in the PDF document into structured information. Based on this structuring, it can be applied to the above-mentioned fields.
[0005] like Figure 1 The figure shows a schematic diagram of adding an outer border to a table with a missing outer border in the prior art. For a table that only lacks an outer border, since its inner border still exists, the information of its leftmost, rightmost, highest, and lowest lines can be obtained through the inner border to supplement it. The information of all horizontal lines on the page is obtained, the left vertices of the horizontal lines are aggregated, and a vertical line is added to pass through all the leftmost vertices, where (a) is the table before the outer border is added, and (b) is the table after the outer border is added.
[0006] However, if Figure 1 The solution of adding an outer border in the prior art shown is prone to the problem of misconnection when there are many tables. Different tables are treated as the same table and connected together, where (a) is the table before the outer border is added, and (b) is the table after the outer border is added. The added outer border on the left side mistakenly connects the two tables together as one table.
[0007] Therefore, there is an urgent need for a method for extracting table data that can accurately detect missing outer borders in PDF documents. Summary of the invention
[0008] In view of this, the present invention provides a method for extracting table data with missing outer borders, so as to overcome the problem in the prior art that table data with missing outer borders in a PDF document cannot be accurately extracted.
[0009] To achieve the above object, the present invention provides the following technical solutions:
[0010] A method for extracting table data with missing outer borders, comprising:
[0011] Get the table with missing outer borders;
[0012] Based on the existing table lines in the table, determine the vertical range and horizontal range of the outer border to be supplemented;
[0013] According to the longitudinal range and the lateral range of the outer border to be supplemented, the outer border missing in the table is supplemented to obtain a table with a complete outer border;
[0014] Extract the data in the table with complete outer borders.
[0015] The embodiment of the present invention further provides a device for extracting table data with missing outer borders, comprising:
[0016] The acquisition module is used to obtain the table with missing outer borders;
[0017] An analysis module, used to determine the longitudinal range and the lateral range of the outer border to be supplemented based on the existing table lines in the table; supplement the missing outer border in the table according to the longitudinal range and the lateral range of the outer border to be supplemented, so as to obtain a table with a complete outer border;
[0018] The extraction module is used to extract the data in the table with a complete outer border.
[0019] Through the above technical solution, it can be known that compared with the prior art, the present invention provides a method for extracting data from a table with a missing outer border, including: obtaining a table with a missing outer border; determining the vertical range and horizontal access of the outer border to be supplemented based on the existing table lines in the table, and supplementing the missing outer border in the table based on the determined horizontal range and vertical access to obtain a table with a complete outer border, and then extracting data from the table with a complete outer border. By adopting this solution, the missing outer border can be reasonably supplemented, and the original line information can be used, thereby ensuring the accuracy of extraction. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] In order to more clearly illustrate the embodiments of the present invention 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, the drawings described below are only embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.
[0021] Figure 1A schematic diagram of adding an outer border to a table with a missing outer border in the prior art;
[0022] Figure 2 A flowchart of a method for extracting table data with missing outer borders provided by an embodiment of the present invention;
[0023] Figure 3 A schematic diagram of edge cells in a method for extracting table data with missing outer borders provided in an embodiment of the present invention;
[0024] Figure 4 A schematic diagram of an application scenario of a method for extracting table data with missing outer borders provided by an embodiment of the present invention;
[0025] Figure 5 A structural block diagram of a device for extracting table data with missing outer borders provided by an embodiment of the present invention;
[0026] Figure 6 A hardware structure block diagram of a device for extracting table data with missing outer borders provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0027] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0028] In this solution, the inventor analyzed and summarized the table and obtained the following conclusions:
[0029] A reasonable table has two characteristics:
[0030] (1) There is no connection or intersection between the tables;
[0031] (2) Tables are all straight and horizontal squares, and there are basically no irregular-shaped tables.
[0032] Figure 2 A flowchart of a method for extracting table data with missing outer borders provided by an embodiment of the present invention, the method may include:
[0033] Step S100: obtaining a table with a missing outer border;
[0034] Among them, by analyzing the PDF document, the table therein is determined.
[0035] The table lacks an outer border. Specifically, the missing outer border may be any one or more of an upper border, a lower border, a left border and a right border.
[0036] In the specific implementation, open source third-party libraries can be used to read PDF files, such as pdfminer, tabula, pdfplumber, etc. This solution is based on the steps of reading PDF files using the above third-party libraries.
[0037] In the specific implementation, the third-party library analyzes the PDF document, reads the line segment information of each page of the PDF, and pieces together the table information based on the line segment information.
[0038] In a specific implementation, the device executing this solution obtains the table from the information output by the third-party library.
[0039] Step S200: determining the vertical range and horizontal range of the outer border to be supplemented based on the existing table lines in the table;
[0040] Among them, based on the existing table lines in the table, the range of the table can be determined, and the vertical range and horizontal range of the outer frame to be supplemented can be calculated / determined according to the table lines.
[0041] Wherein, step S200 determines the vertical range and horizontal range of the outer border to be supplemented based on the existing table lines in the table, including:
[0042] Step S201: Select the target outer frame to be supplemented;
[0043] Specifically, whether any table lines in the existing table lines have an intersection can be used to determine whether there is a border to be supplemented in the table.
[0044] In a specific implementation, because a complete table is composed of a closed outer frame (table line) and the table lines inside it, when each table line in the table has an intersection with other table lines, there is no outer frame to be supplemented in the table.
[0045] If the table is missing the right border, the table lines in the table have no intersection in the right border area of the table. Figure 1 the table in (a);
[0046] If the table is missing a left border, the table lines in the table have no intersection in the left border area. Figure 1 the table in (a);
[0047] If the table lacks an upper border, the table lines in the table have no intersection in the upper border area;
[0048] If the table lacks a bottom border, the table lines in the table have no intersection in the bottom border area.
[0049] Then, according to whether the table lines in the table have no intersection, it can be determined that the area where the no intersection occurs is the area where the border is missing.
[0050] Step S202: analyzing the target outer frame to obtain the type of the target outer frame;
[0051] Specifically, the type of the target outer border is determined according to the area of the missing border, such as a side border or an upper / lower border.
[0052] Step S203: Based on the fact that the type of the target outer border is a side border, analyzing the existing table lines in the table to obtain the horizontal coordinate and the vertical coordinates of the upper and lower end points of the target outer border;
[0053] The horizontal axis represents the horizontal value range of the target outer border in the page where the table is located, and the vertical axis represents the vertical value range of the target outer border in the page where the table is located.
[0054] Specifically, based on the table, in the distribution area of the table, the distribution of the existing table lines of the table is analyzed to determine the horizontal and vertical coordinate area ranges of the target outer frame.
[0055] Wherein, based on the type of the target outer border being a side border, step S203 specifically includes:
[0056] Step S2031: analyzing existing table lines in the table, and obtaining at least one vertical table line parallel to the target outer border;
[0057] Specifically, in the table, a vertical table line parallel to the side frame is obtained.
[0058] Step S2032: based on the information of the intersection of the line segments, obtaining a horizontal table line intersecting with the at least one vertical table line;
[0059] Based on the information of the intersection of the line segments, a horizontal table line intersecting with the vertical table line is obtained from the page where the table is located.
[0060] It should be noted that the horizontal table line determined based on the information of the intersection of line segments must be a table line in the table. Due to the existence of the intersection relationship, it is avoided to obtain the horizontal line of other adjacent tables.
[0061] Step S2033: In a preset coordinate system, from at least one longitudinal table line intersecting with the transverse table line, select the longitudinal coordinates of the maximum and minimum endpoints of the longitudinal coordinates as the value range of the longitudinal coordinates of the target outer frame;
[0062] Specifically, the longitudinal coordinates of the maximum and minimum endpoints of the longitudinal coordinates are selected from the plurality of longitudinal table lines intersecting with the transverse table line as the value range of the longitudinal coordinate of the target outer frame.
[0063] The maximum endpoint and the minimum endpoint of the longitudinal coordinate may not be on the same longitudinal table line.
[0064] Since the maximum endpoint in the vertical coordinate represents the highest position of the table in the vertical direction, and the minimum endpoint in the vertical coordinate represents the lowest position of the table in the vertical direction, based on these two endpoints, the highest and lowest points of the table in the vertical direction can be determined, that is, the highest and lowest points of the side border in the vertical direction.
[0065] In a specific implementation, the coordinates of each point in the table can be represented by absolute coordinates in the PDF page.
[0066] Step S2034: Based on the fact that the side frame is a left frame, in a preset coordinate system, the horizontal coordinate of the vertex with the smallest horizontal coordinate is selected from the horizontal table line as the horizontal coordinate of the target outer frame.
[0067] When the side frame is a left frame, in the preset coordinate system, a leftmost point in the table is selected as the horizontal coordinate of the side frame.
[0068] Specifically, the horizontal coordinate of the vertex with the smallest horizontal coordinate is selected from the horizontal table line as the horizontal coordinate of the target outer frame.
[0069] For example, a line segment is represented by a four-dimensional coordinate (X0, Y0, X1, Y1), where X0 is the start of the horizontal coordinate, X1 is the end of the horizontal coordinate, Y0 is the start of the vertical coordinate, and Y1 is the end of the vertical coordinate.
[0070] In this step S2033, the starting point Y0 and the end point Y1 of the vertical coordinate are determined.
[0071] In this step S2034, the horizontal coordinate X is determined, and the obtained coordinates of the side frame are (X, Y0, X, Y1).
[0072] Step S2035: Based on the fact that the side border is the right border, in the preset coordinate system, the horizontal coordinate of the vertex with the largest horizontal coordinate is selected from the horizontal table line as the horizontal coordinate.
[0073] When the side frame is a right frame, in the preset coordinate system, a rightmost point in the table is selected as the horizontal coordinate of the side frame.
[0074] Specifically, the horizontal coordinate of the vertex with the largest horizontal coordinate is selected from the horizontal table line as the horizontal coordinate of the target outer frame.
[0075] For example, in step S2033, the starting point Y0 and the end point Y1 of the ordinate are determined. In step S2035, the abscissa X' is determined, and the obtained coordinates of the side frame are (X', Y0, X', Y1).
[0076] Step S204: Based on the type of the target outer border being an upper / lower border, analyzing the existing table lines in the table to obtain the vertical coordinate of the target outer border and the horizontal coordinates of the left and right end points.
[0077] Specifically, based on the table, in the distribution area of the table, the distribution of the existing table lines of the table is analyzed to determine the vertical coordinate and horizontal coordinate area ranges of the target outer frame.
[0078] Wherein, based on the type of the target outer border being an upper / lower border, step S204 specifically includes:
[0079] Step S2041: analyzing existing table lines in the table, and obtaining at least one horizontal table line parallel to the target outer border;
[0080] Specifically, in the table, a horizontal table line parallel to the side border is obtained.
[0081] Step S2042: based on the information of the intersection of line segments, obtaining a longitudinal table line intersecting with the at least one transverse table line;
[0082] Based on the information of the intersection of the line segments, a vertical table line intersecting with the horizontal table line is obtained from the page where the table is located.
[0083] It should be noted that the vertical table line determined based on the information of the intersection of line segments must be a table line in the table. Due to the existence of the intersection relationship, it is avoided to obtain the vertical line of another adjacent table.
[0084] Step S2043: In a preset coordinate system, from at least one horizontal table line intersecting with the vertical table line, select the horizontal coordinates of the maximum end point and the minimum end point of the horizontal coordinate as the horizontal value range of the horizontal coordinate of the target outer frame;
[0085] Specifically, the horizontal coordinates of the maximum endpoint and the minimum endpoint of the horizontal coordinate are selected from the multiple horizontal table lines intersecting with the vertical table line as the value range of the horizontal coordinate of the target outer frame.
[0086] The maximum endpoint and the minimum endpoint of the horizontal coordinate may not be on the same horizontal table line.
[0087] Since the maximum endpoint in the horizontal coordinate represents the rightmost horizontal position of the table, and the minimum endpoint in the horizontal coordinate represents the leftmost horizontal position of the table, based on these two endpoints, the leftmost and rightmost horizontal points of the table, that is, the leftmost and rightmost horizontal points of the side border, can be determined.
[0088] In a specific implementation, the coordinates of each point in the table can be represented by absolute coordinates in the PDF page.
[0089] Step S2044: Based on the target outer frame being the upper frame, in the preset coordinate system, the ordinate of the vertex with the largest ordinate is selected from the longitudinal table line as the ordinate of the target outer frame;
[0090] When the target outer frame is an upper frame, in the preset coordinate system, a point with the largest vertical coordinate in the table is selected as the vertical coordinate of the side frame.
[0091] Specifically, the ordinate of the vertex with the largest ordinate is selected from the longitudinal table line as the ordinate of the target outer frame.
[0092] For example, a line segment is represented by a four-dimensional coordinate (X0, Y0, X1, Y1), where X0 is the start of the horizontal coordinate, X1 is the end of the horizontal coordinate, Y0 is the start of the vertical coordinate, and Y1 is the end of the vertical coordinate.
[0093] In step S2043, the starting point X0 and the end point X1 of the horizontal coordinate are determined.
[0094] In this step S2044, the vertical coordinate Y is determined, and the coordinates of the target outer frame obtained are (X0, Y, X1, Y).
[0095] Step S2045: Based on the target outer border being a lower border, in a preset coordinate system, the vertical coordinate of the vertex with the smallest vertical coordinate is selected from the vertical table line as the vertical coordinate of the target outer border.
[0096] When the target outer frame is a lower frame, in the preset coordinate system, a point with the smallest vertical coordinate in the table is selected as the vertical coordinate of the target outer frame.
[0097] Specifically, the ordinate of the vertex with the largest ordinate is selected from the longitudinal table line as the ordinate of the target outer frame.
[0098] For example, in step S2043, the starting point X0 and the end point X1 of the horizontal coordinate are determined.
[0099] In this step S2045, the vertical coordinate Y' is determined, and the coordinates of the target outer frame are obtained as (X0, Y', X1, Y').
[0100] Step S300: supplementing the missing outer border in the table according to the longitudinal range and the lateral range of the outer border to be supplemented, so as to obtain a table with a complete outer border;
[0101] According to the longitudinal range and the transverse range of the outer border to be supplemented determined in the above step S200, the missing outer border in the table is supplemented to obtain a table with a complete outer border.
[0102] Wherein, step S300 supplements the missing outer border in the table according to the ordinate and abscissa of the outer border to be supplemented, including:
[0103] Step S311: obtaining a longitudinal line segment based on the value ranges of the horizontal coordinate and the vertical coordinate of the target outer frame;
[0104] Wherein, a vertical line segment is obtained based on the value range of the vertical coordinate determined based on the horizontal coordinate of the target outer frame and the vertical coordinates of the upper and lower end points in the above step S203.
[0105] For example, when the target outer border is a left border, the value of the line segment is (X, Y0, X, Y1); when the target outer border is a right border, the value of the line segment is (X', Y0, X', Y1).
[0106] Step S312: Add the vertical line segment to the table as the outer border of the table.
[0107] Specifically, based on the coordinates of the line segment, the line segment is added to the table as an outer border of the table, so that the table has a side border.
[0108] Wherein, step S300 supplements the missing outer border in the table according to the ordinate and abscissa of the outer border to be supplemented, including:
[0109] Step S321: obtaining a horizontal line segment based on the value ranges of the ordinate and abscissa of the target outer frame;
[0110] Wherein, a horizontal line segment is obtained based on the value range of the horizontal coordinate determined based on the vertical coordinate of the target outer frame and the horizontal coordinates of the left and right end points in the above step S204.
[0111] For example, when the target outer border is an upper border, the value of the line segment is (X0, Y, X1, Y); when the target outer border is a lower border, the value of the line segment is (X0, Y', X1, Y').
[0112] Step S322: Add the horizontal line segment to the table as the outer border of the table.
[0113] Specifically, based on the coordinates of the line segment, the line segment is added to the table as an outer border of the table, so that the table has an upper / lower border.
[0114] Specifically, step S200 determines the vertical range and horizontal range of the outer border to be supplemented based on the existing table lines in the table, which may include:
[0115] Step S211: obtaining edge cells corresponding to the direction of the outer frame to be supplemented, wherein the edge cells have no adjacent cells in the direction of the outer frame to be supplemented;
[0116] Here, the line segments in the page are first obtained, and based on the intersection points of each line segment, a minimum rectangle with four intersection points as vertices is determined, and the minimum rectangle is used as a cell in the table.
[0117] Specifically, whether any table lines in the existing table lines have an intersection can be used to determine whether there is a border to be supplemented in the table.
[0118] Based on the border to be supplemented, cells adjacent to the border area to be supplemented are selected as edge cells.
[0119] like Figure 3 Schematic diagram of edge cells shown in FIG. 1 , in which the gray area indicates edge cells.
[0120] Step S212: aligning the text information in the edge cells according to a preset text alignment method;
[0121] The text information in the edge cell is aligned according to a preset text alignment method, so that the area occupied by the edge cell can be determined based on the text distribution area in the edge cell.
[0122] Step S213: determining the vertical range and horizontal range of the outer border to be supplemented based on the alignment position of the text information in the edge cells.
[0123] Specifically, based on the alignment of the text information in the edge cell for several times, the area occupied by the edge cell is determined, and then the missing edge of the edge cell is obtained based on the analysis of the area.
[0124] By analyzing in sequence, the missing edges of several edge cells can be obtained. For the plurality of edge sets, the vertical range and horizontal range of the outer frame to be supplemented can be calculated.
[0125] For example, a table has two edge cells with missing edges, where the missing edge of edge cell 1 has coordinates (X0, Y, X1, Y), and the missing edge of edge cell 2 has coordinates (X1, Y, X2, Y), then the coordinate range of the outer border is (X0, Y, X2, Y).
[0126] Step S400: extracting data in the table with a complete outer border.
[0127] Among them, after the outer border of the table is supplemented in the above steps, a table with a complete outer border is obtained.
[0128] The corresponding information extraction program can then extract the data in the table completely and accurately.
[0129] As a specific example, the table with a complete outer border is shown in Table 1 below:
[0130] Table 1
[0131] Absentee Director Name of Director Absent Reasons for Directors’ Absence Name of the person entrusted Independent Director Liu Shoubao Official business reasons Li Dan
[0132] Extract it into formatted information. Taking Json as an example, it extracts the information in the table and stores it as follows:
[0133] 1 ▼ [
[0134] 2 ▼ ["Absent Director Position","Absent Director Name","Absent Director Reason","Name of Delegated Person"],
[0135] 3 ▼ ["Independent Director","Liu Shoubao","Business reasons","Li Dan"]
[0136] 4 ▼ ]
[0137] Accordingly, subsequent programs can process the stored content.
[0138] The following introduces the application scenario of the method for extracting table data with missing outer borders provided by an embodiment of the present invention.
[0139] Figure 4 What is shown is a schematic diagram of an application scenario of a method for extracting table data with a missing outer border. In this application scenario, the left border of the outer border to be supplemented.
[0140] Where (a) represents the table of borders to be supplemented;
[0141] Wherein (b) is to select a vertical line (vertical line segment) parallel to the border to be supplemented in the table, and a thick dotted line is used to represent the selected horizontal line;
[0142] Where (c) is to select a horizontal line that intersects the vertical line in the table, and a thick dotted line is used to represent the selected horizontal line;
[0143] Where (d) represents the horizontal coordinate of the leftmost point in the horizontal line selected in the table, the vertical coordinates of the highest and lowest points in the vertical line are selected, and the selected points are represented by circles;
[0144] Wherein (e) indicates that the vertical coordinates of the highest and lowest points in the table are selected, and the horizontal coordinate of the leftmost point in the horizontal line is used to supplement the left border in the table, which is represented by a thick solid line in the figure.
[0145] The following is an introduction to a table data extraction device with missing outer borders provided in an embodiment of the present invention. The table data extraction device with missing outer borders described below can be referenced in correspondence with the table data extraction method with missing outer borders described above.
[0146] Figure 5 The structure block diagram of the apparatus for extracting data from a table with a missing outer frame provided by an embodiment of the present invention, wherein the apparatus for extracting data from a table with a missing outer frame may be a client for extracting the table, Figure 4 , the table data extraction device with missing outer border may include: an acquisition module 501, an analysis module 502 and an extraction module 503;
[0147] Wherein, the acquisition module 501 is used to acquire a table with a missing outer border;
[0148] The analysis module 502 is used to determine the longitudinal range and the transverse range of the outer border to be supplemented based on the existing table lines in the table; supplement the missing outer border in the table according to the longitudinal range and the transverse range of the outer border to be supplemented, so as to obtain a table with a complete outer border;
[0149] The extraction module 503 is used to extract the data in the table with a complete outer frame.
[0150] Preferably, the analysis module is specifically used for:
[0151] Select the outer frame of the target to be supplemented;
[0152] Analyze the target outer frame to obtain the type of the target outer frame;
[0153] Based on the type of the target outer border being a side border, analyzing the existing table lines in the table, obtaining the abscissa and the ordinates of the upper and lower end points of the target outer border, wherein the abscissa represents the horizontal value range of the target outer border in the page where the table is located, and the ordinate represents the vertical value range of the target outer border in the page where the table is located;
[0154] Based on the type of the target outer border being an upper / lower border, existing table lines in the table are analyzed to obtain the ordinate of the target outer border and the abscissas of the left and right end points.
[0155] Preferably, the analysis module is specifically used for:
[0156] Analyze existing table lines in the table to obtain at least one vertical table line parallel to the target outer border;
[0157] Based on the information of the intersection of the line segments, obtaining a horizontal table line intersecting with the at least one vertical table line;
[0158] In a preset coordinate system, from at least one longitudinal table line intersecting with the transverse table line, select the longitudinal coordinates of the maximum endpoint and the minimum endpoint as the value range of the longitudinal coordinate of the target outer frame;
[0159] Based on the fact that the side frame is a left frame, in a preset coordinate system, the horizontal coordinate of the vertex with the smallest horizontal coordinate is selected from the horizontal table line as the horizontal coordinate of the target outer frame.
[0160] Based on the fact that the side frame is the right frame, in the preset coordinate system, the horizontal coordinate of the vertex with the largest horizontal coordinate is selected from the horizontal table line as the horizontal coordinate.
[0161] Preferably, the analysis module is specifically used for:
[0162] Analyze existing table lines in the table to obtain at least one horizontal table line parallel to the target outer border;
[0163] Based on the information of the intersection of the line segments, obtaining a longitudinal table line intersecting with the at least one transverse table line;
[0164] In the preset coordinate system, from at least one horizontal table line intersecting with the vertical table line, select the points with the minimum and maximum horizontal coordinates as the value range of the horizontal coordinate;
[0165] Based on the fact that the side frame is a left frame, in a preset coordinate system, the horizontal coordinate of the vertex with the smallest horizontal coordinate is selected from the horizontal table line as the horizontal coordinate.
[0166] In a preset coordinate system, from at least one horizontal table line intersecting with the vertical table line, select the horizontal coordinates of the maximum end point and the minimum end point of the horizontal coordinate as the horizontal value range of the horizontal coordinate of the target outer frame;
[0167] Based on the fact that the side frame is an upper frame, in a preset coordinate system, the ordinate of the vertex with the largest ordinate is selected from the longitudinal table line as the ordinate of the target outer frame;
[0168] Based on the fact that the side frame is a bottom frame, in a preset coordinate system, the vertical coordinate of the vertex with the smallest vertical coordinate is selected from the vertical table line as the vertical coordinate of the target outer frame.
[0169] Preferably, the analysis module is specifically used for:
[0170] Based on the value ranges of the horizontal coordinate and the vertical coordinate of the target outer frame, a vertical line is obtained;
[0171] The longitudinal lines are added to the table as side borders of the table.
[0172] Preferably, the analysis module is specifically used for:
[0173] Based on the value ranges of the ordinate and abscissa of the target outer frame, a horizontal line is obtained;
[0174] The horizontal line is added to the table as a side border of the table.
[0175] Preferably, the analysis module is specifically used for:
[0176] Acquire an edge cell corresponding to the direction of the outer border to be supplemented, wherein the edge cell has no adjacent cell in the direction of the outer border to be supplemented;
[0177] Aligning the text information in the edge cells according to a preset text alignment method;
[0178] Based on the alignment position of the text information in the edge cells, the vertical range and the horizontal range of the outer border to be supplemented are determined.
[0179] Optionally, the apparatus for extracting data from a table with missing outer borders may be a hardware device, and the modules and units described above may be provided as functional modules in the apparatus for extracting data from a table with missing outer borders. Figure 6 The hardware structure block diagram of the table data extraction device with missing outer frame is shown. Figure 6 , the device for logging into a mobile game may include: a processor 1, a communication interface 2, a memory 3 and a communication bus 4; wherein the processor 1, the communication interface 2, and the memory 3 communicate with each other via the communication bus 4; optionally, the communication interface 2 may be an interface of a communication module, such as an interface of a GSM module;
[0180] Processor 1, used for executing a program; memory 3, used for storing a program; the program may include a program code, and the program code includes a computer operation instruction;
[0181] The processor 1 may be a central processing unit CPU, or an application-specific integrated circuit ASIC (Application Specific Integrated Circuit), or one or more integrated circuits configured to implement an embodiment of the present invention; the memory 3 may include a high-speed RAM memory, and may also include a non-volatile memory (non-volatile memory), such as at least one disk storage.
[0182] The program can be used specifically for:
[0183] Get the table with missing outer borders;
[0184] Based on the existing table lines in the table, determine the vertical range and horizontal range of the outer border to be supplemented;
[0185] According to the longitudinal range and the lateral range of the outer border to be supplemented, the outer border missing in the table is supplemented to obtain a table with a complete outer border;
[0186] Extract the data in the table with complete outer borders.
[0187] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.
[0188] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0189] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
[0190] The above description of the disclosed embodiments enables one skilled in the art to implement or use the present invention. Various modifications to these embodiments will be apparent to one skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A method for extracting table data with missing outer borders, characterized in that: include: Get the table with missing outer borders; Based on the existing table lines in the table, determine the vertical range and horizontal range of the outer border to be supplemented; According to the longitudinal range and the lateral range of the outer border to be supplemented, the outer border missing in the table is supplemented to obtain a table with a complete outer border; Extracting data from the table with a complete outer border; Based on the existing table lines in the table, determining the vertical range and horizontal range of the outer border to be supplemented includes: Select the outer frame of the target to be supplemented; Analyze the target outer frame to obtain the type of the target outer frame; Based on the type of the target outer border being a side border, analyzing the existing table lines in the table, obtaining the abscissa and the ordinates of the upper and lower end points of the target outer border, wherein the abscissa represents the horizontal value range of the target outer border in the page where the table is located, and the ordinate represents the vertical value range of the target outer border in the page where the table is located; Based on the type of the target outer border being an upper / lower border, analyzing the existing table lines in the table to obtain the ordinate of the target outer border and the abscissas of the left and right end points; The method of analyzing the existing table lines in the table based on the type of the target outer border being a side border to obtain the horizontal coordinate and the vertical coordinates of the upper and lower end points of the target outer border includes: Analyze existing table lines in the table to obtain at least one vertical table line parallel to the target outer border; Based on the information of the intersection of the line segments, obtaining a horizontal table line intersecting with the at least one vertical table line; In a preset coordinate system, from at least one longitudinal table line intersecting with the transverse table line, select the longitudinal coordinates of the maximum endpoint and the minimum endpoint as the value range of the longitudinal coordinate of the target outer frame; Based on the side frame being the left frame, in a preset coordinate system, the abscissa of the vertex with the smallest abscissa is selected from the horizontal table line as the abscissa of the target outer frame; Based on the fact that the side frame is the right frame, in the preset coordinate system, the horizontal coordinate of the vertex with the largest horizontal coordinate is selected from the horizontal table line as the horizontal coordinate.
2. The method according to claim 1, characterized in that The method of analyzing the existing table lines in the table based on the type of the target outer border being an upper / lower border to obtain the ordinate of the target outer border and the abscissas of the left and right end points includes: Analyze existing table lines in the table to obtain at least one horizontal table line parallel to the target outer border; Based on the information of the intersection of the line segments, obtaining a longitudinal table line intersecting with the at least one transverse table line; In a preset coordinate system, from at least one horizontal table line intersecting with the vertical table line, select the horizontal coordinates of the maximum end point and the minimum end point of the horizontal coordinate as the horizontal value range of the horizontal coordinate of the target outer frame; Based on the fact that the side frame is an upper frame, in a preset coordinate system, the ordinate of the vertex with the largest ordinate is selected from the longitudinal table line as the ordinate of the target outer frame; Based on the fact that the side frame is a bottom frame, in a preset coordinate system, the vertical coordinate of the vertex with the smallest vertical coordinate is selected from the vertical table line as the vertical coordinate of the target outer frame.
3. The method according to claim 1, characterized in that: Supplementing the missing outer border in the table according to the ordinate and abscissa of the outer border to be supplemented, including: Based on the value ranges of the horizontal coordinate and the vertical coordinate of the target outer frame, a vertical line segment is obtained; The longitudinal line segment is added to the table as an outer border of the table.
4. The method according to claim 2, characterized in that: Supplementing the missing outer border in the table according to the ordinate and abscissa of the outer border to be supplemented, including: Based on the value ranges of the ordinate and abscissa of the target outer frame, a horizontal line segment is obtained; The horizontal line segment is added to the table as an outer border of the table.
5. The method according to claim 1, characterized in that The determining, based on the existing table lines in the table, the vertical range and the horizontal range of the outer border to be supplemented includes: Acquire an edge cell corresponding to the direction of the outer border to be supplemented, wherein the edge cell has no adjacent cell in the direction of the outer border to be supplemented; Aligning the text information in the edge cells according to a preset text alignment method; Based on the alignment position of the text information in the edge cells, the vertical range and the horizontal range of the outer border to be supplemented are determined.
6. A device for extracting data from a table with a missing outer frame, characterized in that: include: The acquisition module is used to obtain the table with missing outer borders; An analysis module, used to determine the longitudinal range and the lateral range of the outer border to be supplemented based on the existing table lines in the table; supplement the missing outer border in the table according to the longitudinal range and the lateral range of the outer border to be supplemented, so as to obtain a table with a complete outer border; An extraction module, used for extracting data in the table with a complete outer border; The analysis module is specifically used for: Select the outer frame of the target to be supplemented; Analyze the target outer frame to obtain the type of the target outer frame; Based on the type of the target outer border being a side border, analyzing the existing table lines in the table, obtaining the abscissa and the ordinates of the upper and lower end points of the target outer border, wherein the abscissa represents the horizontal value range of the target outer border in the page where the table is located, and the ordinate represents the vertical value range of the target outer border in the page where the table is located; Based on the type of the target outer border being an upper / lower border, analyzing the existing table lines in the table to obtain the ordinate of the target outer border and the abscissas of the left and right end points; The analysis module is specifically used for: Analyze existing table lines in the table to obtain at least one vertical table line parallel to the target outer border; Based on the information of the intersection of the line segments, obtaining a horizontal table line intersecting with the at least one vertical table line; In a preset coordinate system, from at least one longitudinal table line intersecting with the transverse table line, select the longitudinal coordinates of the maximum endpoint and the minimum endpoint as the value range of the longitudinal coordinate of the target outer frame; Based on the side frame being the left frame, in a preset coordinate system, the abscissa of the vertex with the smallest abscissa is selected from the horizontal table line as the abscissa of the target outer frame; Based on the fact that the side frame is the right frame, in the preset coordinate system, the horizontal coordinate of the vertex with the largest horizontal coordinate is selected from the horizontal table line as the horizontal coordinate.
7. The device according to claim 6, characterized in that The analysis module is specifically used for: Analyze existing table lines in the table to obtain at least one horizontal table line parallel to the target outer border; Based on the information of the intersection of the line segments, obtaining a longitudinal table line intersecting with the at least one transverse table line; In a preset coordinate system, from at least one horizontal table line intersecting with the vertical table line, select the horizontal coordinates of the maximum end point and the minimum end point of the horizontal coordinate as the horizontal value range of the horizontal coordinate of the target outer frame; Based on the fact that the side frame is an upper frame, in a preset coordinate system, the ordinate of the vertex with the largest ordinate is selected from the longitudinal table line as the ordinate of the target outer frame; Based on the fact that the side frame is a bottom frame, in a preset coordinate system, the vertical coordinate of the vertex with the smallest vertical coordinate is selected from the vertical table line as the vertical coordinate of the target outer frame.
8. The device according to claim 6, characterized in that The analysis module is specifically used for: Based on the value ranges of the horizontal coordinate and the vertical coordinate of the target outer frame, a vertical line is obtained; The longitudinal lines are added to the table as side borders of the table.
9. The device according to claim 7, characterized in that The analysis module is specifically used for: Based on the value ranges of the ordinate and abscissa of the target outer frame, a horizontal line is obtained; The horizontal line is added to the table as a side border of the table.
10. The device according to claim 6, characterized in that The analysis module is specifically used for: Acquire an edge cell corresponding to the direction of the outer border to be supplemented, wherein the edge cell has no adjacent cell in the direction of the outer border to be supplemented; Aligning the text information in the edge cells according to a preset text alignment method; Based on the alignment position of the text information in the edge cells, the vertical range and the horizontal range of the outer border to be supplemented are determined.
11. A device for extracting data from a table with a missing outer border, characterized in that: include: Memory and processor; The processor is used to execute the computer program stored in the memory; The memory is used to store a computer program, and the computer program is used to execute the method according to any one of claims 1 to 5.
12. A storage medium, characterized in that: The method comprises several instructions for executing the method according to any one of claims 1 to 5.
