A method and device for aligning document elements

By automatically obtaining the grouping and alignment of elements in the document, the problem of low alignment efficiency of document elements in the prior art is solved, and the fast and efficient alignment of document elements is achieved.

CN112287654BActive Publication Date: 2024-11-22ZHUHAI KINGSOFT OFFICE SOFTWARE +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN201910676796.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2019-07-25
Publication Date
2024-11-22
Estimated Expiration
2039-07-25

AI Technical Summary

Technical Problem

In the prior art, the alignment efficiency of document elements is low, especially when there are many elements, users need to manually set it one by one, resulting in serious reduction in efficiency.

Method used

By obtaining elements in the document, grouping, and aligning according to the alignment between groups and within groups, batch alignment operations are realized. The specific method includes determining the region and projection region of the element, grouping according to overlap and attribute distribution, and aligning according to the alignment within and between groups.

Benefits of technology

Improve the efficiency of document element alignment, reduce the number of times the user operates manually, and achieve fast alignment of elements in the document.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112287654B_ABST
    Figure CN112287654B_ABST
Patent Text Reader

Abstract

The embodiment of the present invention provides a document element alignment method and device, which relates to the field of computer information technology, wherein the method comprises: obtaining elements contained in a document, grouping the obtained elements, obtaining an inter-group alignment method between each group, and obtaining an intra-group alignment method of the elements in each group, aligning each group according to the inter-group alignment method, and aligning the elements in each group according to the intra-group alignment method. Compared with the prior art, when the solution provided by the embodiment of the present invention is applied to align document elements, the user does not need to perform multiple repeated manual alignment operations to achieve document element alignment, but rather groups the elements based on the relationship between the elements in the document, and implements batch alignment operations on the elements in the document based on the existing intra-group alignment method and inter-group alignment method. It can be seen that the document element alignment solution provided by the embodiment of the present invention can improve the efficiency of aligning document elements.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer information technology, and in particular to a document element alignment method and device. Background Art

[0002] When users use presentation documents to present information, in order to enhance the presentation effect of the information, the elements within the presentation documents will be aligned according to the layout structure during the production and design of the presentation documents.

[0003] In the prior art, when aligning various elements in a presentation document, it is generally achieved by a user manually setting the alignment of each element in the document one by one.

[0004] It can be seen that the efficiency of implementing the alignment of elements in a document by the method provided by the above-mentioned prior art is low, especially when there are many elements in the document, the low efficiency is more serious. Summary of the invention

[0005] The purpose of the embodiment of the present invention is to provide a document element alignment method and device to improve the efficiency of document element alignment. The specific technical solution is as follows:

[0006] In a first aspect, an embodiment of the present invention provides a document element alignment method, the method comprising:

[0007] Get the elements contained in the document;

[0008] Group the obtained elements;

[0009] Get the inter-group alignment between each group, and get the intra-group alignment of the elements in each group;

[0010] Each group is aligned according to the inter-group alignment, and the elements within each group are aligned according to the intra-group alignment.

[0011] In one embodiment of the present invention, grouping the obtained elements includes:

[0012] determining a region of the obtained element in the document;

[0013] Determine the areas where there are overlapping areas among the determined areas as an area group;

[0014] For each area group, determining the smallest area that includes all areas in the area group;

[0015] A region group having a consistent outer contour of the minimum region is determined, and elements corresponding to the region in each determined region group are divided into a group.

[0016] In one embodiment of the present invention, after determining the group of regions with the same outer contour of the minimum region, the method further includes:

[0017] Determining whether the number of regions in each determined region group is consistent;

[0018] If they are consistent, the step of dividing the elements corresponding to the regions in each determined region group into a group is performed.

[0019] In one embodiment of the present invention, grouping the obtained elements includes:

[0020] Projecting the obtained elements along a preset direction to obtain a projection area;

[0021] Determine the projection areas where there are overlapping areas among the obtained projection areas, and obtain a projection area group;

[0022] For each projection area group, determining a minimum projection area including each projection area in the projection area group;

[0023] A projection area group having consistent minimum projection areas is determined, and elements corresponding to the projection areas in each determined projection area group are divided into a group.

[0024] In one embodiment of the present invention, after determining the projection area group having the same minimum projection areas, the method further includes:

[0025] Determining whether the number of projection areas in each determined projection area group is consistent;

[0026] If they are consistent, the step of dividing the elements corresponding to the projection areas in each determined projection area group into a group is performed.

[0027] In one embodiment of the present invention, grouping the obtained elements includes:

[0028] Determine the properties of each obtained element;

[0029] According to the distribution of each element in the document, the distribution of the determined attribute is obtained, and the attribute distribution law of the element in the document is determined according to the obtained distribution;

[0030] The obtained elements are grouped according to the distribution rule.

[0031] In a second aspect, an embodiment of the present invention provides a document element alignment device, the device comprising:

[0032] The element acquisition module is used to obtain the elements contained in the document;

[0033] An element grouping module, used for grouping the obtained elements;

[0034] An alignment obtaining module is used to obtain the inter-group alignment between each group and the intra-group alignment of the elements in each group;

[0035] The element alignment module is used to align each group according to the obtained inter-group alignment method, and to align the elements within each group according to the obtained intra-group alignment method.

[0036] In one embodiment of the present invention, the element grouping module includes:

[0037] A region determination unit, used to determine the region of the obtained element in the document;

[0038] A region group determination unit, configured to determine regions with overlapping regions among the determined regions as a region group;

[0039] A minimum area determination unit, used for determining, for each area group, a minimum area including each area in the area group;

[0040] A region group identification unit, used to determine a region group with a consistent outer contour of a minimum region;

[0041] The first element grouping unit is used to group the elements corresponding to the regions in each determined region group into a group.

[0042] In one embodiment of the present invention, after the region group identification unit, the element grouping module further includes:

[0043] The region quantity judgment unit is used to determine whether the number of regions included in the region groups with consistent outer contours of each minimum region is consistent, and if consistent, trigger the first element grouping unit.

[0044] In one embodiment of the present invention, the element grouping module includes:

[0045] An element projection unit, used for projecting the obtained element along a preset direction to obtain a projection area;

[0046] A projection area group obtaining unit, used for determining the projection areas where there are overlapping areas among the obtained projection areas, and obtaining the projection area group;

[0047] A minimum projection area determination unit, used to determine, for each projection area group, a minimum projection area including each projection area in the projection area group;

[0048] A projection area group identification unit, used to determine a projection area group with consistent minimum projection areas;

[0049] The second element grouping unit is used to divide the elements corresponding to the projection areas in each determined projection area group into a group.

[0050] In one embodiment of the present invention, after the projection area group identification unit, the element grouping module further includes:

[0051] The projection area quantity judgment unit is used to determine whether the number of projection areas included in the projection area groups with consistent minimum projection areas is consistent. If consistent, the second element grouping unit is triggered.

[0052] In one embodiment of the present invention, the element grouping module is specifically used to:

[0053] Determine the properties of each obtained element;

[0054] According to the distribution of each element in the document, the distribution of the determined attribute is obtained, and the attribute distribution law of the element in the document is determined according to the obtained distribution;

[0055] The obtained elements are grouped according to the distribution rule.

[0056] In a third aspect, an embodiment of the present invention provides an electronic device, including 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;

[0057] Memory, used to store computer programs;

[0058] The processor is used to implement any of the steps of the document element alignment method described in the first aspect when executing the program stored in the memory.

[0059] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the document element alignment method steps described in any one of the first aspects are implemented.

[0060] In a fifth aspect, an embodiment of the present invention further provides a computer program product comprising instructions, which, when executed on a computer, enables the computer to execute any of the document element alignment methods described above.

[0061] Beneficial effects of the embodiments of the present invention:

[0062] The embodiment of the present invention provides a document element alignment solution, which first obtains elements contained in a document, groups the obtained elements, obtains the inter-group alignment between each group, obtains the intra-group alignment of the elements in each group, aligns each group according to the inter-group alignment, and aligns the elements in each group according to the intra-group alignment. Compared with the prior art, when the solution provided by the embodiment of the present invention is used to align document elements, the user does not need to repeat the manual alignment operation many times to achieve document element alignment. Instead, the elements are grouped based on the relationship between the elements in the document, and batch alignment operations of the elements in the document are achieved based on the existing intra-group alignment and inter-group alignment methods.

[0063] It can be seen that the document element alignment solution provided by the embodiment of the present invention can improve the efficiency of aligning document elements. BRIEF DESCRIPTION OF THE DRAWINGS

[0064] 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 some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0065] Figure 1 A schematic flow chart of a first document element alignment method provided by an embodiment of the present invention;

[0066] Figure 2 A schematic diagram of a flow chart of a second document element alignment method provided by an embodiment of the present invention;

[0067] Figure 3 A schematic diagram of a first document page provided by an embodiment of the present invention;

[0068] Figure 4 A schematic diagram of a flow chart of a third document element alignment method provided by an embodiment of the present invention;

[0069] Figure 5a-Figure 5b A schematic diagram of a second document page provided by an embodiment of the present invention;

[0070] Figure 6 A schematic diagram of a flow chart of a fourth document element alignment method provided by an embodiment of the present invention;

[0071] Figure 7 A schematic diagram of a third document page provided by an embodiment of the present invention;

[0072] Figure 8 A schematic diagram of the structure of a document element alignment device provided by an embodiment of the present invention;

[0073] Fig. 9 The present invention is a schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0074] 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.

[0075] The embodiments of the present invention provide a document element alignment method and device to efficiently achieve document element alignment.

[0076] The following first introduces a document element alignment method provided by an embodiment of the present invention.

[0077] like Figure 1 As shown, the embodiment of the present invention provides a first document element alignment method, including the following steps 101 to 104:

[0078] Step 101: Get the elements contained in the document.

[0079] The elements contained in the document may be pictures, texts, graphics, etc., and the document may be a text document, a presentation document, etc.

[0080] In an embodiment of the present invention, all elements contained in a document may be obtained, or elements within a preset area may be obtained. For example, for a presentation, elements within a single page may be obtained, but this is not limited in the embodiment of the present invention.

[0081] In one embodiment of the present invention, the element selected by the user may also be obtained.

[0082] Step 102: Group the obtained elements.

[0083] In an embodiment of the present invention, the elements may be grouped according to the regions where the elements are located, or according to the projection regions of the elements, or according to the attributes of the elements.

[0084] Step 103: Obtain the inter-group alignment between the groups, and obtain the intra-group alignment of the elements in each group.

[0085] The alignment method may be left alignment, top alignment, center alignment, distributed alignment, etc.

[0086] As for the inter-group alignment, in one embodiment of the present invention, a preset inter-group alignment can be obtained, or an inter-group alignment selected by a user can be obtained, or the alignment of one of the groups can be obtained based on the group, that is, the group alignment based on the above-mentioned base can be used as the above-mentioned inter-group alignment.

[0087] As for the intra-group alignment, in one embodiment of the present invention, a preset intra-group alignment can be obtained, or an intra-group alignment selected by a user can be obtained, or the intra-group alignment of one of the groups can be obtained based on the group, that is, the intra-group alignment of the group as the reference is used as the intra-group alignment of other groups. For a group, the alignment of one of the elements in the group can also be obtained as the intra-group alignment of the group.

[0088] Step 104: aligning each group according to the obtained inter-group alignment, and aligning the elements within each group according to the obtained intra-group alignment.

[0089] As can be seen from the above, the document element alignment scheme provided by the above embodiment is applied, firstly, the elements contained in the document are obtained, the obtained elements are grouped, the inter-group alignment between each group is obtained, and the intra-group alignment of the elements in each group is obtained, each group is aligned according to the inter-group alignment, and the elements in each group are aligned according to the intra-group alignment. Compared with the prior art, when the scheme provided by the embodiment of the present invention is applied to align document elements, the user does not need to repeat the manual alignment operation many times to achieve document element alignment, but the elements are grouped based on the relationship between the elements in the document, and the batch alignment operation of the elements in the document is achieved based on the existing intra-group alignment and inter-group alignment. The document element alignment scheme provided by the above embodiment can improve the efficiency of aligning document elements.

[0090] How to implement element grouping is described below through a specific embodiment.

[0091] Embodiment 1

[0092] See also Figure 2 , Figure 2 A flowchart of the second document element alignment method is provided, which is similar to the above Figure 1 Compared with the illustrated embodiment, in this embodiment, the above step 102 groups the obtained elements, including the following steps 102A to 102D.

[0093] Step 102A: Determine the area of ​​the obtained element in the document.

[0094] For each element, the area is the area enclosed by the outer contour of the element in the document. For example, for a text box containing text, the area of ​​the element is the area occupied by the text box, and for a graphic, the area of ​​the element is the area enclosed by the outer contour of the graphic in the document.

[0095] Step 102B: determine the areas with overlapping areas among the determined areas as an area group.

[0096] For example, Figure 3 As shown, it represents a page in a document, wherein elements 301, 302, and 303 represent text boxes, and elements 304, 305, and 306 represent graphics. Since the areas of element 301 and element 304 in the document overlap, the areas where element 301 and element 304 are located are grouped as a region. Similarly, the areas where element 302 and element 305 are located are grouped as a region, and the areas where element 303 and element 306 are located are grouped as a region.

[0097] Step 102C: For each region group, determine the smallest region that includes all regions in the region group.

[0098] In one embodiment of the present invention, the smallest circumscribed rectangular area including each area in the area group may be used as the smallest area. The solution provided in this embodiment is applied to facilitate data processing.

[0099] In another embodiment of the present invention, the minimum area including all areas can be obtained according to the outer contours of each area in the area group. For example, when the outer contours of each area are circular and rectangular, the minimum area is the area surrounded by the circular curve and the rectangular line segment. In this way, when the elements are grouped according to the outer contour of the minimum area, the accuracy of the element grouping can be improved.

[0100] Step 102D: Determine a region group having the same outer contour of the smallest region, and divide the elements corresponding to the region in each determined region group into a group.

[0101] The above outer contours are consistent with each other in shape and size of the smallest area.

[0102] For the elements corresponding to the areas contained in the area group whose minimum area outer contours are inconsistent, it is not determined to be a group.

[0103] For example, Figure 3As shown, since the outer contours of the minimum area of ​​the area group obtained by elements 301 and 304 are consistent with the outer contours of the minimum area of ​​the area group obtained by elements 302 and 305, elements 301 and 304 are a group, and elements 302 and 305 are a group, while the outer contours of the minimum area of ​​the area group obtained by elements 303 and 306 are inconsistent with the outer contours of other minimum areas, so elements 303 and 306 are not a group.

[0104] It can be seen that by applying the solution provided by the above embodiment, elements can be grouped according to the regions of the elements in the document.

[0105] In one embodiment of the present invention, after the step of determining the region group with the same outer contour of the minimum region, the method further includes:

[0106] It is determined whether the number of regions in each determined region group is consistent. If consistent, the step of dividing the elements corresponding to the regions in each determined region group into one group is performed; if inconsistent, the elements corresponding to the regions in each determined region group are not divided into one group.

[0107] For example, Figure 3 As shown, since the region group obtained by element 301 and element 304 includes 2 elements, and the region group obtained by element 302 and element 305 also includes 2 elements, it is considered that element 301 and element 304 are a group, and element 302 and element 305 are a group.

[0108] By applying the solution provided in the above embodiment, after determining the minimum area outer contour, the number of areas in each area group can be judged, which can improve the accuracy of element grouping.

[0109] Embodiment 2

[0110] See also Figure 4 , Figure 4 A flowchart of the third document element alignment method is provided, which is similar to the above Figure 1 Compared with the illustrated embodiment, in this embodiment, the above step 102 groups the obtained elements, including the following steps 102E to 102H.

[0111] Step E: Project the obtained elements along a preset direction to obtain a projection area.

[0112] The preset direction may be a vertical direction or a horizontal direction.

[0113] For example, the preset direction may be vertically downward or horizontally rightward, and this is not limited in the embodiment of the present invention.

[0114] like Figure 5a As shown, there are multiple elements in the document, and each element is projected horizontally to the right and vertically downward. Since the projected area is a line segment, in order to facilitate observation and comparison, the projection width is set in advance, thereby obtaining the projection area shown in the right figure.

[0115] Step F, determining the projection areas where there are overlapping areas among the obtained projection areas, and obtaining a projection area group.

[0116] like Figure 5b As shown, there is an overlapping area between element 1 and element 6 in the horizontal rightward projection area, so it is considered that element 1 and element 6 belong to the same projection area group.

[0117] Step G: for each projection area group, determine the minimum projection area including all projection areas in the projection area group.

[0118] Step H: determining a projection area group having consistent minimum projection areas, and dividing the elements corresponding to the projection areas in each determined projection area group into a group.

[0119] Among them, whether the various minimum projection areas are consistent can be judged based on the size of the minimum projection area. It is also possible to judge whether the various minimum projection areas are consistent based on the length of the side along the direction perpendicular to the projection direction. For example, when the projection direction is horizontal to the right, whether the various minimum projection areas are consistent can be judged based on the height of the projection area.

[0120] like Figure 5b As shown, since the minimum projection areas of the projection area groups obtained by 501, 502, 503, 504, and 505 are consistent, it is considered that 501, 502, 503, 504, and 505 are respectively a group.

[0121] As can be seen from the above, by applying the solution provided by the above embodiment, elements can be grouped according to the projection of the elements in the document, so that elements without overlapping areas in the document can still be grouped. By applying the solution provided by the above embodiment, the coverage rate of the grouped elements in the document can be improved.

[0122] In one embodiment of the present invention, after the above step of determining a group of projection areas having the same minimum projection areas, the method further includes:

[0123] Determine whether the number of projection areas in each determined projection area group is consistent. If consistent, perform the above step of dividing the elements corresponding to the projection areas in each determined projection area group into one group. If inconsistent, do not divide the elements corresponding to the projection areas in each determined projection area group into one group.

[0124] By applying the solution provided in the above embodiment, after determining the outer contour of the minimum projection area, the number of projection areas in each projection area group can be judged, which can improve the accuracy of element grouping.

[0125] Embodiment 3

[0126] See also Figure 6 , Figure 6 A flowchart of the fourth document element alignment method is provided, which is similar to the above Figure 1 Compared with the embodiment shown in the figure, in this embodiment, the above step 102 groups the obtained elements, including the following steps:

[0127] Step 102I, determine the attributes of each obtained element, obtain the distribution of the determined attributes according to the distribution of each element in the above document, and determine the attribute distribution law of the elements in the above document according to the obtained distribution, and group the obtained elements according to the above distribution law.

[0128] The above attribute may be the type of the element, for example, the type includes text, graphic, picture, etc. The above attribute may also be the size, angle, font, etc. of the element. The above distribution rule is a rule obtained according to a preset distribution order of the elements, wherein the preset distribution order may be from left to right, from top to bottom, etc.

[0129] The above distribution rule may be a rule found from a pre-set distribution rule, or a distribution rule obtained by calculating the attribute distribution of elements in the document according to a rule algorithm. For example, the pre-set rule may be "graphics, text", or "font size 36, font size 14, font size 8", or "blue, red, black", etc. The distribution of the determined attribute is matched with the pre-set rule to obtain the distribution rule of the element.

[0130] For example, see Figure 7 , 701-709 represent the elements in the page respectively. The elements in the page are traversed from left to right and from top to bottom, and the attributes of each element are obtained in turn:

[0131] star, arrow, text, star, arrow, text, star, arrow, text

[0132] The distribution pattern of the elements is "star, arrow, text". According to the above pattern, the elements are grouped; since elements 701, 702, and 703 conform to the above distribution pattern, elements 704, 705, and 706 conform to the above pattern, and elements 707, 708, and 709 conform to the above pattern, it can be considered that elements 701, 702, and 703 are a group, elements 704, 705, and 706 are a group, and elements 707, 708, and 709 are a group.

[0133] As can be seen from the above, by applying the solution provided by the above embodiment, elements can be grouped according to the attributes of the elements in the document, so that elements in the document that do not overlap in position can still be grouped. By applying the solution provided by the above embodiment, the coverage rate of the grouped elements in the document can be improved.

[0134] For the solutions provided in the above-mentioned embodiment 1, embodiment 2, and embodiment 3, in the specific implementation of element grouping, one of the solutions may be selected, or multiple solutions may be selected and executed in sequence. For example, the above three solutions are selected to group the elements in the document. First, the elements in the document are grouped according to the solution provided in embodiment 1. If the elements in the document can be grouped, the process ends. If not, the solution provided in embodiment 2 is executed. If the elements in the document can be grouped, the process ends. If not, the solution provided in embodiment 3 is executed. The present invention does not limit the execution order of the solutions provided in the above-mentioned embodiments.

[0135] Corresponding to the above-mentioned document element alignment method, an embodiment of the present invention further provides a document element alignment device.

[0136] Figure 8 A schematic diagram of the structure of a document element alignment device provided by an embodiment of the present invention, the device comprising:

[0137] The element obtaining module 801 is used to obtain the elements contained in the document;

[0138] An element grouping module 802, used to group the obtained elements;

[0139] The alignment obtaining module 803 is used to obtain the inter-group alignment between the groups and obtain the intra-group alignment of the elements in each group;

[0140] The element alignment module 804 is used to align each group according to the obtained inter-group alignment mode, and to align the elements within each group according to the obtained intra-group alignment mode.

[0141] In one embodiment of the present invention, the element grouping module 802 includes:

[0142] A region determination unit, used for determining a region of the obtained element in the document;

[0143] A region group determination unit, configured to determine regions with overlapping regions among the determined regions as a region group;

[0144] A minimum area determination unit, used for determining, for each area group, a minimum area including each area in the area group;

[0145] A region group identification unit, used to determine a region group with a consistent outer contour of a minimum region;

[0146] The first element grouping unit is used to group the elements corresponding to the regions in each determined region group into a group.

[0147] In one embodiment of the present invention, after the region group identification unit, the element grouping module 802 further includes:

[0148] The region quantity judgment unit is used to determine whether the number of regions included in the region groups with consistent outer contours of each minimum region is consistent. If consistent, the first element grouping unit is triggered.

[0149] In one embodiment of the present invention, the element grouping module 802 includes:

[0150] An element projection unit, used for projecting the obtained element along a preset direction to obtain a projection area;

[0151] A projection area group obtaining unit, used for determining the projection areas where there are overlapping areas among the obtained projection areas, and obtaining the projection area group;

[0152] A minimum projection area determination unit, used to determine, for each projection area group, a minimum projection area including each projection area in the projection area group;

[0153] A projection area group identification unit, used to determine a projection area group with consistent minimum projection areas;

[0154] The second element grouping unit is used to divide the elements corresponding to the projection areas in each determined projection area group into a group.

[0155] In one embodiment of the present invention, after the projection area identification unit, the element grouping module 802 further includes:

[0156] The projection area quantity judgment unit is used to determine whether the number of projection areas included in the projection area groups with consistent minimum projection areas is consistent. If consistent, the second element grouping unit is triggered.

[0157] In one embodiment of the present invention, the element grouping module 802 is specifically used to:

[0158] Determine the properties of each obtained element;

[0159] According to the distribution of each element in the document, the distribution of the determined attribute is obtained, and the attribute distribution law of the element in the document is determined according to the obtained distribution;

[0160] The obtained elements are grouped according to the above distribution rules.

[0161] As can be seen from the above, the document element alignment scheme provided by the above embodiment is applied, firstly, the elements contained in the document are obtained, the obtained elements are grouped, the inter-group alignment between each group is obtained, and the intra-group alignment of the elements in each group is obtained, each group is aligned according to the inter-group alignment, and the elements in each group are aligned according to the intra-group alignment. Compared with the prior art, when the scheme provided by the embodiment of the present invention is applied to align document elements, the user does not need to repeat the manual alignment operation many times to achieve document element alignment, but the elements are grouped based on the relationship between the elements in the document, and the batch alignment operation of the elements in the document is achieved based on the existing intra-group alignment and inter-group alignment. The document element alignment scheme provided by the above embodiment can improve the efficiency of aligning document elements.

[0162] Corresponding to the aforementioned document element alignment method, an embodiment of the present invention further provides an electronic device.

[0163] In one embodiment of the present invention, Fig. 9 As shown, a structural schematic diagram of an electronic device is also provided, the electronic device includes: a processor 901, a communication interface 902, a memory 903 and a communication bus 904, wherein the processor 901, the communication interface 902, and the memory 903 communicate with each other through the communication bus 904,

[0164] Memory 903, used for storing computer programs;

[0165] The processor 901 is used to implement the document element alignment method provided by the embodiment of the present invention when executing the program stored in the memory 903.

[0166] 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.

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

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

[0169] 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.

[0170] In another embodiment of the present invention, a computer-readable storage medium is provided, in which a computer program is stored. When the computer program is executed by a processor, the steps of any of the above-mentioned methods for implementing document element alignment are implemented.

[0171] In another embodiment provided by the present invention, a computer program product including instructions is also provided, which, when executed on a computer, enables the computer to execute any one of the document element alignment methods in the above embodiments.

[0172] As can be seen from the above, the document element alignment scheme provided by the above embodiment is applied to first obtain the elements contained in the document, group the obtained elements, obtain the inter-group alignment between the groups, and obtain the intra-group alignment of the elements in each group, align each group according to the inter-group alignment, and align the elements in each group according to the intra-group alignment.

[0173] The electronic device, readable storage medium, and computer program product provided by the embodiments of the present invention can quickly and accurately implement the document element alignment method provided by the embodiments of the present invention. Compared with the prior art, when the solution provided by the embodiments of the present invention is used to align document elements, the user does not need to repeat the manual alignment operation many times to achieve document element alignment. Instead, the elements are grouped based on the relationship between the elements in the document, and the batch alignment operation of the elements in the document is achieved based on the existing intra-group alignment method and inter-group alignment method. The document element alignment solution provided by the above embodiments can improve the efficiency of aligning document elements.

[0174] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented by 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 invention is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website site, computer, server or data center to another website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium can 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 hard disk Solid State Disk (SSD)), etc.

[0175] 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.

[0176] 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 device, electronic device, computer-readable storage medium, and computer program product embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiments.

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

Claims

1. A document element alignment method, characterized in that: The method comprises: Get the elements contained in the document; The obtained elements are grouped; wherein the grouping of the obtained elements includes at least one of the following: grouping the obtained elements according to the overlapping areas of the areas where the elements are located, grouping the obtained elements according to the overlapping projection areas in the projection areas of the elements, and grouping the obtained elements according to the attribute distribution law of the elements, wherein the attribute distribution law is a law obtained according to a preset distribution order of the elements in the document; Get the inter-group alignment between each group, and get the intra-group alignment of the elements in each group; Each group is aligned according to the inter-group alignment, and the elements within each group are aligned according to the intra-group alignment.

2. The method according to claim 1, characterized in that The obtained elements are grouped, comprising: determining a region of the obtained element in the document; Determine the areas where there are overlapping areas among the determined areas as an area group; For each area group, determining the smallest area that includes all areas in the area group; A region group having a consistent outer contour of the minimum region is determined, and elements corresponding to the region in each determined region group are divided into a group.

3. The method according to claim 2, characterized in that After determining the area group with the same outer contour of the minimum area, the method further includes: Determining whether the number of regions in each determined region group is consistent; If they are consistent, the step of dividing the elements corresponding to the regions in each determined region group into a group is performed.

4. The method according to claim 1, characterized in that: The obtained elements are grouped, comprising: Projecting the obtained elements along a preset direction to obtain a projection area; Determine the projection areas where there are overlapping areas among the obtained projection areas, and obtain a projection area group; For each projection area group, determining a minimum projection area including each projection area in the projection area group; A projection area group having consistent minimum projection areas is determined, and elements corresponding to the projection areas in each determined projection area group are divided into a group.

5. The method according to claim 4, characterized in that After determining the projection area group having the same minimum projection areas, the method further includes: Determining whether the number of projection areas in each determined projection area group is consistent; If they are consistent, the step of dividing the elements corresponding to the projection areas in each determined projection area group into a group is performed.

6. The method according to claim 1, characterized in that The obtained elements are grouped, comprising: Determine the properties of each obtained element; According to the distribution of each element in the document, the distribution of the determined attribute is obtained, and the attribute distribution law of the element in the document is determined according to the obtained distribution; The obtained elements are grouped according to the distribution rule.

7. A document element alignment device, characterized in that: The device comprises: The element acquisition module is used to obtain the elements contained in the document; An element grouping module, used for grouping the obtained elements; wherein the grouping of the obtained elements includes at least one of the following: grouping the obtained elements according to the overlapping areas of the areas where the elements are located, grouping the obtained elements according to the overlapping projection areas in the projection areas of the elements, and grouping the obtained elements according to the attribute distribution law of the elements, wherein the attribute distribution law is a law obtained according to the preset distribution order of the elements in the document; An alignment obtaining module is used to obtain the inter-group alignment between each group and the intra-group alignment of the elements in each group; The element alignment module is used to align each group according to the obtained inter-group alignment method, and to align the elements within each group according to the obtained intra-group alignment method.

8. The device according to claim 7, characterized in that The element grouping module comprises: A region determination unit, used to determine the region of the obtained element in the document; A region group determination unit, configured to determine regions with overlapping regions among the determined regions as a region group; A minimum area determination unit, used for determining, for each area group, a minimum area including each area in the area group; A region group identification unit, used to determine a region group with a consistent outer contour of a minimum region; The first element grouping unit is used to group the elements corresponding to the regions in each determined region group into a group.

9. The device according to claim 8, characterized in that After the region group identification unit, the element grouping module further includes: The region quantity judgment unit is used to determine whether the number of regions included in the region groups with consistent outer contours of each minimum region is consistent, and if consistent, trigger the first element grouping unit.

10. The device according to claim 7, characterized in that The element grouping module comprises: An element projection unit, used for projecting the obtained element along a preset direction to obtain a projection area; A projection area group obtaining unit, used for determining the projection areas where there are overlapping areas among the obtained projection areas, and obtaining the projection area group; A minimum projection area determination unit, used to determine, for each projection area group, a minimum projection area including each projection area in the projection area group; A projection area group identification unit, used to determine a projection area group with consistent minimum projection areas; The second element grouping unit is used to divide the elements corresponding to the projection areas in each determined projection area group into a group.

11. The device according to claim 10, characterized in that After the projection area group identification unit, the element grouping module further includes: The projection area quantity judgment unit is used to determine whether the number of projection areas included in the projection area groups with consistent minimum projection areas is consistent. If consistent, the second element grouping unit is triggered.

12. The device according to claim 7, characterized in that The element grouping module is specifically used for: Determine the properties of each obtained element; According to the distribution of each element in the document, the distribution of the determined attribute is obtained, and the attribute distribution law of the element in the document is determined according to the obtained distribution; The obtained elements are grouped according to the distribution rule.

13. An electronic device, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; Memory, used to store computer programs; A processor is used to implement the document element alignment method steps described in any one of claims 1-6 when executing a program stored in a memory.

14. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the document element alignment method according to any one of claims 1 to 6 are implemented.