Document processing method and device
By identifying and marking non-standard protocol modification elements in layout electronic documents, the identification problems in the prior art are solved, and the document conversion and editing effect is improved.
Patent Information
- Application Number
- CN202310740442.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-20
- Publication Date
- 2024-12-20
AI Technical Summary
The prior art is difficult to identify notes such as underscores, wavy underscores and strikethroughs that are not standard protocols in layout electronic documents, resulting in poor conversion and editing effects.
By obtaining the electronic layout document, the basic elements in the text line are identified, and elements that meet the preset conditions are stored in the comment group as modification elements of the non-standard protocol, and corresponding modification attributes are assigned to identify and mark the target modification elements of the non-standard protocol.
Improves the conversion effect and editability of layout electronic documents, improves readability during rearrangement, and can quickly identify and handle non-standard protocol modification elements.
Smart Images

Figure CN119167896A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a document processing method and device. Background Art
[0002] At present, most electronic documents are layout electronic documents mainly in PDF format converted from typesetting tools and typesetting documents. There is usually a part of the content in the layout electronic document that is more important. In order to remind others to pay more attention to this part of the content, we usually add Annotation (an element that can associate notes, sounds, videos and other elements with layout electronic documents, with basic attributes such as BBox (Bounding Box) and subtype. There are 25 standard annotation types) to this part of the content, such as underline.
[0003] In the related art, in the scenario of converting a formatted electronic document to a streaming electronic document, it is necessary to identify annotations such as underline, wavy underline, and strikethrough in a published electronic document. Annotations such as underline, wavy underline, and strikethrough are divided into underline, wavy underline, and strikethrough of standard protocols, and underline, wavy underline, and strikethrough of non-standard protocols. Currently, underline, wavy underline, and strikethrough of standard protocols can be identified, but there is currently no effective solution for identifying underline, wavy underline, and strikethrough of non-standard protocols. Summary of the invention
[0004] In order to solve the technical problem that currently, annotations such as underline, wavy underline, and strikethrough of standard protocols can be recognized, but there is no effective solution for the recognition of annotations such as underline, wavy underline, and strikethrough of non-standard protocols, the embodiments of the present invention provide a document processing method, device, electronic device, and storage medium. The specific technical solutions are as follows:
[0005] In a first aspect of an embodiment of the present invention, a document processing method is first provided, the method comprising:
[0006] Obtaining a layout electronic document and determining annotations in the layout electronic document;
[0007] In the case where the annotation does not contain a target modification element of a standard protocol, identifying all text lines in the formatted electronic document;
[0008] For any of the text lines, traverse the basic elements in the text line, and store the basic elements that meet the preset modification element conditions into the annotation group as modification elements of the non-standard protocol;
[0009] The modified elements of the non-standard protocol in the annotation group are traversed, and corresponding modified attributes are assigned to the modified elements of the non-standard protocol to obtain target modified elements of the non-standard protocol.
[0010] In an optional embodiment, the basic element includes at least one of the following: text, line segment, picture;
[0011] The traversing the basic elements in the text line and storing the basic elements that meet the preset modifying element conditions into the annotation group as modifying elements of the non-standard protocol includes at least one of the following:
[0012] Traversing the text in the text line, and storing the text that meets the preset first modification element condition into the annotation group as a modification element of the non-standard protocol;
[0013] Traversing the line segments in the text line, and storing the line segments meeting the preset second modification element condition as modification elements of the non-standard protocol into the annotation group;
[0014] The pictures in the text line are traversed, and the pictures meeting the preset third modification element condition are stored in the annotation group as modification elements of the non-standard protocol.
[0015] In an optional implementation, traversing the text in the text line and storing the text that meets the preset first modification element condition as a modification element of the non-standard protocol into the annotation group includes:
[0016] Traversing the text in the text line, and determining whether the height of the circumscribed rectangular frame of the text is less than a preset first threshold;
[0017] When the height of the circumscribed rectangular frame of the text is less than the preset first threshold, determining whether the Unicode of the text exists in a preset modified Unicode set;
[0018] In the case where the Unicode of the text exists in the preset modified Unicode set, determining whether the width of the circumscribed rectangular frame of the text is greater than the average character width of the text line;
[0019] When the width of the circumscribed rectangular frame of the text is greater than the average character width of the text line, the text is stored in the annotation group as a modification element of the non-standard protocol.
[0020] In an optional implementation, before traversing the text in the text line and determining whether the height of the circumscribed rectangular frame of the text is less than a preset first threshold, the method further includes:
[0021] Traversing the text in the text line, and determining whether the height of the circumscribed rectangular frame of the text is less than a preset first threshold;
[0022] When the height of the circumscribed rectangular frame of the text is not less than the preset first threshold, storing the text as the target text in the text group;
[0023] When the height of the circumscribed rectangular frame of the text is less than the preset first threshold, determining whether the Unicode of the text exists in a preset modified Unicode set;
[0024] If the Unicode of the text does not exist in the preset modified Unicode set, storing the text as a target text in the text group;
[0025] An average character width of the text line is determined according to the target text in the text group.
[0026] In an optional implementation, determining the average character width of the text line according to the target text in the text group includes:
[0027] For the target text in the text group, the number of Unicodes of the target text is accumulated to obtain the total number of characters;
[0028] Accumulating the widths of the circumscribed rectangular frames of the target texts in the text group to obtain a total width;
[0029] A ratio between the total width and the total number of characters is determined, and the ratio is determined as an average character width of the text line.
[0030] In an optional implementation, traversing the line segments in the text line and storing the line segments meeting the preset second modifying element condition as modifying elements of the non-standard protocol into the annotation group includes:
[0031] Traversing the line segments in the text line, and determining whether the height of the circumscribed rectangular frame of the line segment is less than a preset first threshold;
[0032] When the height of the circumscribed rectangular frame of the line segment is less than the preset first threshold, determining whether the width of the circumscribed rectangular frame of the line segment is greater than the average character width of the text line;
[0033] In the case where the width of the circumscribed rectangular frame of the line segment is greater than the average character width of the text line, determining whether the Y-axis coordinate value corresponding to the starting point of the line segment is consistent with the Y-axis coordinate value corresponding to the end point of the line segment;
[0034] When the Y-axis coordinate value corresponding to the starting point of the line segment is consistent with the Y-axis coordinate value corresponding to the end point of the line segment, the line segment is stored in the annotation group as a modification element of the non-standard protocol.
[0035] In an optional implementation, traversing the pictures in the text line and storing the pictures meeting the preset third modifying element condition as modifying elements of the non-standard protocol into the annotation group includes:
[0036] Traversing the pictures in the text line, and determining whether the height of the circumscribed rectangular frame of the picture is less than a preset first threshold;
[0037] When the height of the circumscribed rectangular frame of the picture is less than the preset first threshold, determining whether the width of the circumscribed rectangular frame of the picture is greater than the average character width of the text line;
[0038] When the width of the circumscribed rectangular frame of the picture is greater than the average character width of the text line, rendering the picture;
[0039] When the rendered image meets the preset color requirement, the image is stored in the annotation group as a modification element of the non-standard protocol.
[0040] In an optional implementation, when the rendered image meets the preset color requirement, storing the image as a modification element of a non-standard protocol in an annotation group includes:
[0041] When the color of any pixel in the rendered image is not white, transposing the rendered image into a grayscale image;
[0042] Performing color histogram statistics on the grayscale image, determining the maximum pixel color proportion, and judging whether the proportion exceeds a preset proportion threshold;
[0043] When the proportion exceeds the preset proportion threshold, the picture is stored in the annotation group as a modification element of the non-standard protocol.
[0044] In an optional embodiment, the target modification element of the non-standard protocol includes a strikethrough of the non-standard protocol;
[0045] The traversing the modified elements of the non-standard protocol in the annotation group, assigning corresponding modification attributes to the modified elements of the non-standard protocol, and obtaining the target modified elements of the non-standard protocol, includes:
[0046] Traversing the non-standard protocol modification elements in the annotation group, and determining the first text line where the non-standard protocol modification elements are located;
[0047] Determine a first Y-axis coordinate value corresponding to an upper boundary of a circumscribed rectangular frame of the modification element of the non-standard protocol;
[0048] Determine a Y-axis second coordinate value corresponding to a lower boundary of a circumscribed rectangular frame of the first text line, and obtain a Y-axis first coordinate difference between the Y-axis first coordinate value and the Y-axis second coordinate value;
[0049] Determine the third Y-axis coordinate value corresponding to the lower boundary of the circumscribed rectangular frame of the modification element of the non-standard protocol;
[0050] Determine a fourth Y-axis coordinate value corresponding to an upper boundary of a circumscribed rectangular frame of the first text line, and obtain a second Y-axis coordinate difference between the fourth Y-axis coordinate value and the third Y-axis coordinate value;
[0051] When the first coordinate difference is greater than the product of a preset second value and the height of the circumscribed rectangular box of the first text line, and the second coordinate difference is less than the product of a preset third value and the height of the circumscribed rectangular box of the first text line, the modification element of the non-standard protocol is assigned a corresponding strikethrough attribute to obtain a strikethrough of the non-standard protocol.
[0052] In an optional embodiment, the target modifier element of the non-standard protocol further includes an underline of the non-standard protocol and a wavy underline of the non-standard protocol, and the method further includes:
[0053] In the case where the first coordinate difference is less than the product of a preset second value and a height of a circumscribed rectangular frame of the first text line, determining whether the modifying element of the non-standard protocol is text or a line segment;
[0054] When the modification element of the non-standard protocol is a text or a line segment, assigning a corresponding wavy underline attribute to the modification element of the non-standard protocol to obtain a wavy underline of the non-standard protocol;
[0055] In the case that the modification element of the non-standard protocol is not text or line segment, a corresponding underline attribute is given to the modification element of the non-standard protocol to obtain an underline of the non-standard protocol.
[0056] In an optional implementation, after traversing the modified elements of the non-standard protocol in the annotation group, assigning corresponding modification attributes to the modified elements of the non-standard protocol, and obtaining the target modified elements of the non-standard protocol, the method further includes:
[0057] Determine a first width range of the target modifying element of the non-standard protocol in the annotation group, and determine a second text line where the target modifying element of the non-standard protocol in the annotation group is located;
[0058] In the case where the first width range includes the width range of N texts in the second text line, assigning the modification attribute of the target modification element of the non-standard protocol in the annotation group to the N texts, wherein N is a positive integer;
[0059] When the first width range does not include the width range of any text in the second text line, a first empty character is created at a first position, and the modification attribute of the target modification element of the non-standard protocol in the annotation group is assigned to the first empty character.
[0060] In an optional implementation, the inclusion is that the first width range intersects with the width range of the text in the second text line, and the intersection is greater than the product of a preset second threshold and the length of the text in the second text line.
[0061] In an optional implementation, before creating the first null character at the first position, the method further includes:
[0062] Determine a first coordinate value on the X-axis corresponding to the center of the target modification element of the non-standard protocol in the annotation group, and determine a fifth coordinate value on the Y-axis corresponding to the center line of the second text line;
[0063] The first position is composed of the first X-axis coordinate value and the fifth Y-axis coordinate value.
[0064] In an optional embodiment, the method further comprises:
[0065] In the case where the annotation includes a target modifier element of a standard protocol, storing the target modifier element of the standard protocol into an annotation group;
[0066] Determine a second width range of the target modifying element of the standard protocol in the annotation group, and determine a third text line where the target modifying element of the standard protocol in the annotation group is located;
[0067] In the case where the second width range includes the width range of M texts in the third text line, assigning the modification attribute of the target modification element of the standard protocol in the annotation group to the M texts, wherein M is a positive integer;
[0068] When the second width range does not include the width range of any text in the third text line, a second empty character is created at a second position, and the modification attribute of the target modification element of the standard protocol in the annotation group is assigned to the second empty character.
[0069] In an optional implementation, the inclusion is that the second width range intersects with the width range of the text in the third text line, and the intersection is greater than the product of a preset second threshold and the length of the text in the third text line.
[0070] In an optional implementation, before creating the second space character at the second position, the method further includes:
[0071] Determine the second coordinate value of the X-axis corresponding to the center of the target modification element of the standard protocol in the annotation group, and determine the sixth coordinate value of the Y-axis corresponding to the center line of the third text line;
[0072] The second position is formed by the second X-axis coordinate value and the sixth Y-axis coordinate value.
[0073] In a second aspect of an embodiment of the present invention, a document processing device is further provided, the device comprising:
[0074] A document acquisition module is used to acquire electronic documents of the layout;
[0075] An annotation determination module, used for determining annotations in the formatted electronic document;
[0076] A text line determination module, for identifying all text lines in the formatted electronic document when the annotation does not contain a target modification element of a standard protocol;
[0077] An element screening module, for traversing the basic elements in any of the text lines, and storing the basic elements that meet the preset modifying element conditions as modifying elements of the non-standard protocol into the annotation group;
[0078] The attribute assignment module is used to traverse the modified elements of the non-standard protocol in the annotation group, assign corresponding modification attributes to the modified elements of the non-standard protocol, and obtain the target modified elements of the non-standard protocol.
[0079] In an optional embodiment, the basic element includes at least one of the following: text, line segment, picture;
[0080] The element screening module includes at least one of the following submodules:
[0081] A text screening submodule, used for traversing the text in the text line, and storing the text that meets the preset first modification element condition as a modification element of the non-standard protocol into the annotation group;
[0082] A line segment screening submodule, used for traversing the line segments in the text line, and storing the line segments meeting the preset second modification element condition as modification elements of the non-standard protocol into the annotation group;
[0083] The picture screening submodule is used to traverse the pictures in the text line and store the pictures that meet the preset third modification element conditions into the annotation group as modification elements of the non-standard protocol.
[0084] In an optional implementation, the text screening submodule is specifically used for:
[0085] Traversing the text in the text line, and determining whether the height of the circumscribed rectangular frame of the text is less than a preset first threshold;
[0086] When the height of the circumscribed rectangular frame of the text is less than the preset first threshold, determining whether the Unicode of the text exists in a preset modified Unicode set;
[0087] In the case where the Unicode of the text exists in the preset modified Unicode set, determining whether the width of the circumscribed rectangular frame of the text is greater than the average character width of the text line;
[0088] When the width of the circumscribed rectangular frame of the text is greater than the average character width of the text line, the text is stored in the annotation group as a modification element of the non-standard protocol.
[0089] In an optional embodiment, the element screening module further includes:
[0090] A first text judgment submodule is used to traverse the text in the text line and judge whether the height of the circumscribed rectangular frame of the text is less than a preset first threshold;
[0091] A text storage first submodule is used to store the text as a target text into a text group if the height of the circumscribed rectangular frame of the text is not less than the preset first threshold value;
[0092] A second text determination submodule is used to determine whether the Unicode of the text exists in a preset modified Unicode set when the height of the circumscribed rectangular frame of the text is less than the preset first threshold value;
[0093] A second submodule for storing text, used for storing the text as a target text into the text group if the Unicode of the text does not exist in the preset modified Unicode set;
[0094] The width determination submodule is used to determine the average character width of the text line according to the target text in the text group.
[0095] In an optional implementation, the width determination submodule is specifically used to:
[0096] For the target text in the text group, the number of Unicodes of the target text is accumulated to obtain the total number of characters;
[0097] Accumulating the widths of the circumscribed rectangular frames of the target texts in the text group to obtain a total width;
[0098] A ratio between the total width and the total number of characters is determined, and the ratio is determined as an average character width of the text line.
[0099] In an optional implementation, the line segment screening submodule is specifically used for:
[0100] Traversing the line segments in the text line, and determining whether the height of the circumscribed rectangular frame of the line segment is less than a preset first threshold;
[0101] When the height of the circumscribed rectangular frame of the line segment is less than the preset first threshold, determining whether the width of the circumscribed rectangular frame of the line segment is greater than the average character width of the text line;
[0102] In the case where the width of the circumscribed rectangular frame of the line segment is greater than the average character width of the text line, determining whether the Y-axis coordinate value corresponding to the starting point of the line segment is consistent with the Y-axis coordinate value corresponding to the end point of the line segment;
[0103] When the Y-axis coordinate value corresponding to the starting point of the line segment is consistent with the Y-axis coordinate value corresponding to the end point of the line segment, the line segment is stored in the annotation group as a modification element of the non-standard protocol.
[0104] In an optional implementation, the picture screening submodule specifically includes:
[0105] A picture determination unit, used to traverse the pictures in the text line and determine whether the height of the circumscribed rectangular frame of the picture is less than a preset first threshold;
[0106] A width judgment unit, configured to judge whether a width of a circumscribed rectangular frame of the picture is greater than an average character width of the text line when a height of the circumscribed rectangular frame of the picture is less than a preset first threshold;
[0107] A picture rendering unit, used for rendering the picture when the width of the circumscribed rectangular frame of the picture is greater than the average character width of the text line;
[0108] The image storing unit is used to store the image as a modification element of the non-standard protocol into the annotation group when the rendered image meets the preset color requirement.
[0109] In an optional implementation manner, the picture storage unit is specifically used for:
[0110] When the color of any pixel in the rendered image is not white, transposing the rendered image into a grayscale image;
[0111] Performing color histogram statistics on the grayscale image, determining the maximum pixel color proportion, and judging whether the proportion exceeds a preset proportion threshold;
[0112] When the proportion exceeds the preset proportion threshold, the picture is stored in the annotation group as a modification element of the non-standard protocol.
[0113] In an optional embodiment, the target modification element of the non-standard protocol includes a strikethrough of the non-standard protocol;
[0114] The attribute assignment module is specifically used for:
[0115] Traversing the non-standard protocol modification elements in the annotation group, and determining the first text line where the non-standard protocol modification elements are located;
[0116] Determine a first Y-axis coordinate value corresponding to an upper boundary of a circumscribed rectangular frame of the modification element of the non-standard protocol;
[0117] Determine a Y-axis second coordinate value corresponding to a lower boundary of a circumscribed rectangular frame of the first text line, and obtain a Y-axis first coordinate difference between the Y-axis first coordinate value and the Y-axis second coordinate value;
[0118] Determine the third Y-axis coordinate value corresponding to the lower boundary of the circumscribed rectangular frame of the modification element of the non-standard protocol;
[0119] Determine a fourth Y-axis coordinate value corresponding to an upper boundary of a circumscribed rectangular frame of the first text line, and obtain a second Y-axis coordinate difference between the fourth Y-axis coordinate value and the third Y-axis coordinate value;
[0120] When the first coordinate difference is greater than the product of a preset second value and the height of the circumscribed rectangular box of the first text line, and the second coordinate difference is less than the product of a preset third value and the height of the circumscribed rectangular box of the first text line, the modification element of the non-standard protocol is assigned a corresponding strikethrough attribute to obtain a strikethrough of the non-standard protocol.
[0121] In an optional implementation, the target modification element of the non-standard protocol further includes an underline of the non-standard protocol and a wavy underline of the non-standard protocol, and the attribute assignment module is further used to:
[0122] In the case where the first coordinate difference is less than the product of a preset second value and a height of a circumscribed rectangular frame of the first text line, determining whether the modifying element of the non-standard protocol is text or a line segment;
[0123] When the modification element of the non-standard protocol is a text or a line segment, assigning a corresponding wavy underline attribute to the modification element of the non-standard protocol to obtain a wavy underline of the non-standard protocol;
[0124] In the case that the modification element of the non-standard protocol is not text or line segment, a corresponding underline attribute is given to the modification element of the non-standard protocol to obtain an underline of the non-standard protocol.
[0125] In an optional embodiment, the device further comprises:
[0126] A first width range determination module is used to determine a first width range of the target modifying element of the non-standard protocol in the annotation group, and determine a second text line where the target modifying element of the non-standard protocol in the annotation group is located;
[0127] N text assignment modules, used for assigning the modification attribute of the target modification element of the non-standard protocol in the annotation group to the N texts when the first width range includes the width range of the N texts in the second text line, wherein N is a positive integer;
[0128] The first empty character assigning module is used to create a first empty character at a first position when the first width range does not include the width range of any text in the second text line, and assign the modification attribute of the target modification element of the non-standard protocol in the annotation group to the first empty character.
[0129] In an optional implementation, the inclusion is that the first width range intersects with the width range of the text in the second text line, and the intersection is greater than the product of a preset second threshold and the length of the text in the second text line.
[0130] In an optional embodiment, the device further comprises:
[0131] The first position determination module is used to determine the first X-axis coordinate value corresponding to the center of the target modification element of the non-standard protocol in the annotation group, and determine the fifth Y-axis coordinate value corresponding to the center line of the second text line; the first position is composed of the first X-axis coordinate value and the fifth Y-axis coordinate value.
[0132] In an optional embodiment, the device further comprises:
[0133] A target modifier element storage module of a standard protocol, used for storing the target modifier element of the standard protocol into an annotation group when the annotation contains the target modifier element of the standard protocol;
[0134] A second width range determining module is used to determine a second width range of the target modifying element of the standard protocol in the annotation group, and determine a third text line where the target modifying element of the standard protocol in the annotation group is located;
[0135] M text assignment module, used for assigning the modification attribute of the target modification element of the standard protocol in the annotation group to the M texts when the second width range includes the width range of the M texts in the third text line, wherein M is a positive integer;
[0136] A second null character assigning module is used to create a second null character at a second position when the second width range does not include the width range of any text in the third text line, and assign the modification attribute of the target modification element of the standard protocol in the annotation group to the second null character.
[0137] In an optional implementation, the inclusion is that the second width range intersects with the width range of the text in the third text line, and the intersection is greater than the product of a preset second threshold and the length of the text in the third text line.
[0138] In an optional embodiment, the device further comprises:
[0139] The second position determination module is used to determine the second X-axis coordinate value corresponding to the center of the target modification element of the standard protocol in the annotation group, and determine the sixth Y-axis coordinate value corresponding to the center line of the third text line; the second position is composed of the second X-axis coordinate value and the sixth Y-axis coordinate value.
[0140] In a third aspect of an embodiment of the present invention, there is further provided an electronic device, comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus;
[0141] Memory, used to store computer programs;
[0142] The processor is used to implement any document processing method described in the first aspect when executing the program stored in the memory.
[0143] In a fourth aspect of the embodiments of the present invention, a storage medium is further provided, wherein instructions are stored in the storage medium, and when the storage medium is run on a computer, the computer executes any document processing method described in the first aspect above.
[0144] In a fifth aspect of the embodiments of the present invention, a computer program product comprising instructions is also provided, which, when executed on a computer, enables the computer to execute any of the document processing methods described above.
[0145] The technical solution provided by the embodiment of the present invention obtains a layout electronic document and determines the annotations in the layout electronic document. When the annotations do not contain the target modifier elements of the standard protocol, all text lines in the layout electronic document are identified. For any text line, the basic elements in the text line are traversed, and the basic elements that meet the preset modifier element conditions are stored as the modifier elements of the non-standard protocol in the annotation group. The modifier elements of the non-standard protocol in the annotation group are traversed, and the modifier elements of the non-standard protocol are assigned corresponding modification attributes to obtain the target modifier elements of the non-standard protocol. By determining the annotations in the layout electronic document, when the annotations do not contain the target modifier elements of the standard protocol, the basic elements in each text line in the layout electronic document are traversed, and the basic elements that meet the preset modifier element conditions are stored as the modifier elements of the non-standard protocol in the annotation group. The modifier elements of the non-standard protocol in the annotation group are assigned corresponding modification attributes to obtain the target modifier elements of the non-standard protocol. In this way, the target modifier elements of the non-standard protocol in the published electronic document can be quickly identified, the conversion effect of the layout electronic document is improved, the editability of the layout electronic document is improved, and the readability of the layout electronic document when it is rearranged is improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0146] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.
[0147] 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, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0148] Figure 1 A schematic diagram of an implementation flow of a document processing method shown in an embodiment of the present invention;
[0149] Figure 2 It is a schematic diagram of an implementation flow of another document processing method shown in an embodiment of the present invention;
[0150] Figure 3 A schematic diagram of an implementation flow of a text traversal method shown in an embodiment of the present invention;
[0151] Figure 4 It is a schematic diagram of an implementation flow of a method for determining average character width shown in an embodiment of the present invention;
[0152] Figure 5 It is a schematic diagram of an implementation flow of a line segment traversal method shown in an embodiment of the present invention;
[0153] Figure 6It is a schematic diagram of an implementation flow of a picture traversal method shown in an embodiment of the present invention;
[0154] Figure 7 It is a schematic diagram showing that the width range of an underline includes the width range of a text in an embodiment of the present invention;
[0155] Figure 8 A schematic diagram of creating a first space character shown in an embodiment of the present invention;
[0156] Fig. 9 It is a structural schematic diagram of a document processing device shown in an embodiment of the present invention;
[0157] Fig.10 It is a schematic diagram of the structure of an electronic device shown in an embodiment of the present invention. DETAILED DESCRIPTION
[0158] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are 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.
[0159] The key terms involved in the present invention are explained as follows: Annotation: An element that can associate elements such as notes, sounds, videos, etc. with layout electronic documents. It has basic attributes such as BBox (Bounding Box) and subtype. There are 25 standard annotation types.
[0160] A standard protocol can be understood to be one that complies with the specifications of, for example, PDF Reference 1.7. For example, a target modifier element in a subsequent standard protocol refers to a target modifier element that complies with the PDF Reference 1.7 specification. A non-standard protocol can be understood to be one that does not comply with the specifications of PDF Reference 1.7. For example, an underline in a subsequent non-standard protocol refers to an underline that does not comply with the PDF Reference 1.7 specification.
[0161] Basic elements: Text text element, including text Unicode, character code CharCode, font information, color, bounding box BBox (Bounding Box) coordinates, etc.; Path line segment element (vector element or path element), usually composed of MoveTo (move but not draw), LineTo (move and draw a straight line), BezierTo (move and draw a Bezier curve), etc., and its StartPoint (coordinates before moving), EndPoint (coordinates after moving), color, bounding box BBox coordinates, etc. can be obtained; Image picture element, including RGB color information, bounding box BBox coordinates, etc.
[0162] like Figure 1 FIG. 1 is a schematic diagram of an implementation flow of a document processing method provided by an embodiment of the present invention. The method is applied to an electronic device and may specifically include the following steps:
[0163] S101, obtaining a layout electronic document and determining annotations in the layout electronic document.
[0164] In the embodiment of the present invention, a layout electronic document is obtained, where the layout electronic document may be a layout electronic document mainly in PDF format converted from a layout tool and a layout document, and may also be a streaming electronic document, which is not limited in the embodiment of the present invention.
[0165] For a layout electronic document, the annotations in the layout electronic document may be determined. The layout electronic document may be parsed to obtain (all) annotations in the layout electronic document, where the number of annotations is not limited in the embodiment of the present invention and may be one or more.
[0166] S102, when the annotation does not contain the target modification element of the standard protocol, identifying all text lines in the layout electronic document.
[0167] In an embodiment of the present invention, for annotations in a layout electronic document, if the annotations do not contain target modification elements of the standard protocol, it means that the target modification elements of the standard protocol do not exist in the layout electronic document and need to be identified separately, that is, the target modification elements of the non-standard protocol are identified, thereby identifying all text lines in the layout electronic document.
[0168] It should be noted that the target modification element of the above standard protocol may be, for example, an underline of the standard protocol, a strikethrough of the standard protocol, a wavy underline of the standard protocol, etc. For the identification of all text lines in the layout electronic document, some line identifiers may be used to identify all text lines in the layout electronic document, which is not limited in the embodiment of the present invention.
[0169] S103, for any text line, traverse the basic elements in the text line, and store the basic elements that meet the preset modification element conditions into the annotation group as modification elements of the non-standard protocol.
[0170] In the embodiment of the present invention, for any text line, the basic elements in the text line are traversed, and the basic elements that meet the preset modification element conditions are stored in an annotation group, such as AnnoGroup, as modification elements of a non-standard protocol.
[0171] It should be noted that the basic elements in a text line can be obtained by parsing the layout electronic document. The basic elements here include at least one of the following: text (Text), line segment (Path), image (Image), and the embodiment of the present invention is not limited to this.
[0172] In addition, it should be noted that the basic elements that meet the preset modification element conditions are stored in the annotation group as modification elements of the non-standard protocol. At this time, the modification elements of the non-standard protocol (i.e., the basic elements) lack corresponding modification attributes and are not target modification elements of the non-standard protocol in the true sense.
[0173] For the modifier elements (i.e., basic elements) of non-standard protocols, there is no corresponding modifier attribute. After being assigned with the corresponding modifier attribute, they become the target modifier elements of non-standard protocols, that is, the modifier elements of non-standard protocols are transformed into the target modifier elements of non-standard protocols after being assigned with the modifier attribute. The target modifier elements of non-standard protocols correspond to the target modifier elements of standard protocols. The difference between the two lies in whether they comply with the specifications of, for example, PDF Reference 1.7. The target modifier elements of non-standard protocols do not comply with the specifications of, for example, PDF Reference 1.7, while the target modifier elements of standard protocols comply with the specifications of, for example, PDF Reference 1.7.
[0174] S104, traversing the modified elements of the non-standard protocol in the annotation group, assigning corresponding modification attributes to the modified elements of the non-standard protocol, and obtaining target modified elements of the non-standard protocol.
[0175] In an embodiment of the present invention, for the modification elements (i.e., basic elements) of the non-standard protocol in the annotation group, the modification elements of the non-standard protocol in the annotation group can be traversed, and the modification elements of the non-standard protocol can be assigned corresponding modification attributes to obtain the target modification elements of the non-standard protocol.
[0176] It should be noted that the modification attributes, such as the strikethrough attribute, the underline attribute, the wavy underline attribute, etc., are different due to the different modification elements of the non-standard protocol, and the embodiments of the present invention do not limit this.
[0177] Through the above description of the technical solution provided by the embodiment of the present invention, a layout electronic document is obtained, and the annotations in the layout electronic document are determined. When the annotations do not contain the target modifying elements of the standard protocol, all text lines in the layout electronic document are identified. For any text line, the basic elements in the text line are traversed, and the basic elements that meet the preset modifying element conditions are stored in the annotation group as modifying elements of the non-standard protocol. The modifying elements of the non-standard protocol in the annotation group are traversed, and the modifying elements of the non-standard protocol are assigned corresponding modifying attributes to obtain the target modifying elements of the non-standard protocol.
[0178] By determining the annotations in the layout electronic document, when the annotations do not contain the target modifying elements of the standard protocol, traversing the basic elements in each text line in the layout electronic document, storing the basic elements that meet the preset modifying element conditions as the modifying elements of the non-standard protocol in the annotation group, assigning the modifying elements of the non-standard protocol in the annotation group corresponding modifying attributes, and obtaining the target modifying elements of the non-standard protocol, the target modifying elements of the non-standard protocol in the published electronic document can be quickly identified, the conversion effect of the layout electronic document can be improved, the editability of the layout electronic document can be improved, and the readability of the layout electronic document when it is rearranged can be improved.
[0179] like Figure 2 FIG. 1 is a schematic diagram of an implementation flow of another document processing method provided by an embodiment of the present invention. The method is applied to an electronic device and may specifically include the following steps:
[0180] S201, obtaining a layout electronic document, and determining annotations in the layout electronic document.
[0181] In the embodiment of the present invention, this step is similar to the above step S101, and the embodiment of the present invention will not be described in detail here.
[0182] S202: When the annotation does not contain the target modification element of the standard protocol, identify all text lines in the layout electronic document.
[0183] In the embodiment of the present invention, this step is similar to the above step S102, and the embodiment of the present invention will not be described in detail here.
[0184] S203: for any text line, traverse the text in the text line, and store the text that meets the preset first modification element condition into the annotation group as a modification element of the non-standard protocol.
[0185] S204, traversing the line segments in the text line, and storing the line segments meeting the preset second modifying element condition as modifying elements of the non-standard protocol into the annotation group.
[0186] S205, traversing the pictures in the text line, and storing the pictures that meet the preset third modification element condition into the annotation group as modification elements of the non-standard protocol.
[0187] In the embodiment of the present invention, the target modification element of the non-standard protocol (such as underline, strikethrough, etc.) is composed of at least one of the following: text, line segment, picture, so the basic element includes at least one of the following: text, line segment, picture.
[0188] Based on this, for any text line, the basic elements in the text line are traversed, and the basic elements that meet the preset modification element conditions are stored in the annotation group as modification elements of the non-standard protocol, including at least one of the following:
[0189] The text in the text line is traversed, and the text that meets the preset first modification element condition is stored in the comment group as a modification element of the non-standard protocol.
[0190] The line segments in the text line are traversed, and the line segments meeting the preset second modification element condition are stored in the annotation group as modification elements of the non-standard protocol.
[0191] The pictures in the text line are traversed, and pictures that meet the preset third modification element conditions are stored in the annotation group as modification elements of the non-standard protocol.
[0192] The text in the text line is traversed, and the text that meets the preset first modification element condition is stored in the annotation group as a modification element of the non-standard protocol, such as AnnoGroup. Figure 3 The text traversal method shown.
[0193] like Figure 3 As shown, it is a schematic diagram of an implementation flow of a text traversal method provided by an embodiment of the present invention. The method is applied to an electronic device and may specifically include the following steps:
[0194] S301, traversing the text in the text line, and determining whether the height of the circumscribed rectangular frame of the text is less than a preset first threshold.
[0195] S302: When the height of the circumscribed rectangular frame of the text is less than a preset first threshold, determine whether the Unicode of the text exists in a preset modified Unicode set.
[0196] S303: When the Unicode of the text exists in the preset modified Unicode set, it is determined whether the width of the circumscribed rectangular frame of the text is greater than the average character width of the text line.
[0197] S304: When the width of the circumscribed rectangular frame of the text is greater than the average character width of the text line, the text is stored in the annotation group as a modification element of the non-standard protocol.
[0198] In an embodiment of the present invention, the text in the text line is traversed, and first, it is determined whether the height of the bounding rectangle of the text (that is, the Text text element mentioned in the above-mentioned basic element, including the bounding rectangle BBox (Bounding Box) coordinates) is less than a preset first threshold. If the height of the bounding rectangle of the text is not less than the preset first threshold, the text is filtered out.
[0199] When the height of the circumscribed rectangular box of the text is less than the preset first threshold, continue to determine whether the Unicode of the text (i.e., the Unicode contained in the Text element mentioned in the above basic element) exists in the preset modified Unicode set. If the Unicode of the text does not exist in the preset modified Unicode set, filter out the text.
[0200] When the Unicode of the text exists in the preset modified Unicode set, continue to determine whether the width of the circumscribed rectangular box of the text is greater than the average character width of the text line. When the width of the circumscribed rectangular box of the text is not greater than the average character width of the text line, filter out the text.
[0201] When the width of the bounding rectangle of the text is greater than the average character width of the text line, it means that the text meets the above three conditions. In this case, the text can be stored in the annotation group as a modification element of the non-standard protocol.
[0202] For example, traverse the text (Text) in the text line, first determine whether the height of the text's bounding rectangle is less than 2. If the height of the text's bounding rectangle is less than 2, that is, Text.BBox.Height (that is, the height of the text's bounding rectangle) < 2 (empirical value), continue to determine whether the text's Unicode exists in the preset modified Unicode set. If the text's Unicode exists in the preset modified Unicode set, that is, Text.Unicode is in the modified character set (where the modified character set consists of a series of Unicode characters that can be modified), continue to determine whether the width of the text's bounding rectangle is greater than the average character width of the text line. When the width of the bounding rectangle is greater than the average character width of the text line, that is, Text.BBox.Width (i.e. the width of the bounding rectangle of the text) > Length (i.e. the average character width of the text line), it means that the text meets the above three conditions (Text.BBox.Height (i.e. the height of the bounding rectangle of the text) < 2, Text.Unicode (i.e. the Unicode of the text) is in the modified character set, Text.BBox.Width (i.e. the width of the bounding rectangle of the text) > Length (i.e. the average character width of the text line)). At this time, the text can be stored in AnnoGroup as a modified element of the non-standard protocol.
[0203] It should be noted that in the process of traversing the text in the text line, first determine whether the height of the bounding rectangle of the text is less than the preset first threshold, then determine whether the Unicode of the text exists in the preset modified Unicode set, and finally determine whether the width of the bounding rectangle of the text is greater than the average character width of the text line. This can achieve optimal performance because the time consumption of the judgment conditions will be different, and the judgment conditions in the front are fast. In addition, here it is determined whether the Unicode of the text exists in the preset modified Unicode set because, for example, 0x2D, 0x5F, etc., correspond to text such as "-", "—", "~", etc., which may look like underlines, strikethroughs, wavy lines, etc., but are not actually, so this situation should be eliminated.
[0204] Before this, you need to calculate the average character width of the text line. For details, refer to Figure 4 As shown in the method. Figure 4 FIG. 1 is a schematic diagram of an implementation flow of a method for determining an average character width provided by an embodiment of the present invention. The method is applied to an electronic device and may specifically include the following steps:
[0205] S401, traversing the text in the text line, and determining whether the height of the circumscribed rectangular frame of the text is less than a preset first threshold.
[0206] S402: When the height of the circumscribed rectangular frame of the text is not less than a preset first threshold, the text is stored in a text group as a target text.
[0207] S403: When the height of the circumscribed rectangular frame of the text is less than a preset first threshold, determine whether the Unicode of the text exists in a preset modified Unicode set.
[0208] S404: If the Unicode of the text does not exist in the preset modified Unicode set, store the text as a target text into the text group.
[0209] S405: Determine an average character width of a text line according to the target text in the text group.
[0210] In an embodiment of the present invention, the text of a text line is traversed, and first it is determined whether the height of the circumscribed rectangular box of the text is less than a preset first threshold. If the height of the circumscribed rectangular box of the text is not less than the preset first threshold, the text is stored in a text group as a target text. If the height of the circumscribed rectangular box of the text is less than the preset first threshold, it is determined whether the Unicode of the text exists in a preset modified Unicode set. If the Unicode of the text does not exist in the preset modified Unicode set, the text is stored in a text group as a target text.
[0211] In this way, in the process of traversing the text of a text line, when the height of the circumscribed rectangular box of the text is not less than the preset first threshold, the text is stored in the text group as the target text; when the height of the circumscribed rectangular box of the text is less than the preset first threshold and the Unicode of the text does not exist in the preset modified Unicode set, the text is stored in the text group as the target text; when the height of the circumscribed rectangular box of the text is less than the preset first threshold and the Unicode of the text exists in the preset modified Unicode set, for example, Text.BBox.Height (that is, the height of the circumscribed rectangular box of the text) <2 and Text.Unicode (that is, the Unicode of the text) is in the modified character set, the text is filtered out.
[0212] Subsequently, the average character width of the text line can be determined based on the target text in the text group. Specifically, for the target text in the text group, the number of Unicodes of the target text is accumulated to obtain the total number of characters, the width of the circumscribed rectangular box of the target text in the text group is accumulated to obtain the total width, the ratio between the total width and the total number of characters is determined, and the ratio is determined as the average character width of the text line.
[0213] For example, the number of Unicode codes of the target text in the text group is accumulated to obtain the total number of characters, such as Count+=Text.Unicode.Length (i.e. the number of Unicode codes of the target text), "Count+=" represents the accumulation, the width of the bounding rectangle of the target text in the text group is accumulated to obtain the total width, such as TotalLength+=Text.BBox.Width (i.e. the width of the bounding rectangle of the target text), "TotalLength+=" represents the accumulation, and the ratio between the total width and the total number of characters is determined, such as Length (i.e. the ratio)=TotalLength (i.e. the total width) / Count (i.e. the total number of characters), and the ratio is determined as the average character width of the text line. Among them, Count (i.e. the total number of characters)=0 and TotalLength (i.e. the total width)=0 are initialized.
[0214] In addition, the line segments in the text line are traversed, and the line segments that meet the preset second modification element conditions are stored as modification elements of the non-standard protocol in the annotation group, such as AnnoGroup, as shown in FIG. Figure 5 The line segment traversal method shown.
[0215] like Figure 5 FIG. 1 is a schematic diagram of an implementation flow of a line segment traversal method provided by an embodiment of the present invention. The method is applied to an electronic device and may specifically include the following steps:
[0216] S501, traverse the line segments in the text line, and determine whether the height of the circumscribed rectangular frame of the line segment is less than a preset first threshold.
[0217] S502: When the height of the circumscribed rectangular frame of the line segment is less than a preset first threshold, determine whether the width of the circumscribed rectangular frame of the line segment is greater than an average character width of the text line.
[0218] S503, when the width of the circumscribed rectangular frame of the line segment is greater than the average character width of the text line, determine whether the Y-axis coordinate value corresponding to the starting point of the line segment is consistent with the Y-axis coordinate value corresponding to the end point of the line segment.
[0219] S504: When the Y-axis coordinate value corresponding to the starting point of the line segment is consistent with the Y-axis coordinate value corresponding to the end point of the line segment, the line segment is stored in the annotation group as a modification element of the non-standard protocol.
[0220] In an embodiment of the present invention, the line segments in the text line are traversed, and first, it is determined whether the height of the circumscribed rectangular box of the line segment (that is, the Path line segment element mentioned in the above basic element, and the circumscribed rectangular box BBox coordinates contained therein) is less than a preset first threshold. If the height of the circumscribed rectangular box of the line segment is not less than the preset first threshold, the line segment is filtered out.
[0221] When the height of the circumscribed rectangular frame of the line segment is less than the preset first threshold, it is further determined whether the width of the circumscribed rectangular frame of the line segment is greater than the average character width of the text line. If the width of the circumscribed rectangular frame of the line segment is not greater than the average character width of the text line, the line segment is filtered out. The average character width of the text line is determined by reference to Figure 4 The method shown.
[0222] When the width of the circumscribed rectangular box of the line segment is greater than the average character width of the text line, continue to determine whether the Y-axis coordinate value corresponding to the starting point of the line segment is consistent with the Y-axis coordinate value corresponding to the end point of the line segment. When the Y-axis coordinate value corresponding to the starting point of the line segment is inconsistent with the Y-axis coordinate value corresponding to the end point of the line segment, filter out this line segment.
[0223] When the Y-axis coordinate value corresponding to the starting point of the line segment is consistent with the Y-axis coordinate value corresponding to the end point of the line segment, it means that the line segment meets the above three conditions. At this time, the line segment can be stored in the annotation group as a modification element of the non-standard protocol.
[0224] For example, traverse the line segment (Path) in the text line, first determine whether the height of the circumscribed rectangular box of the line segment is less than 2. When the height of the circumscribed rectangular box of the line segment is less than 2, that is, Path.BBox.Height (that is, the height of the circumscribed rectangular box of the line segment) < 2, continue to determine whether the width of the circumscribed rectangular box of the line segment is greater than the average character width of the text line. When the width of the circumscribed rectangular box of the line segment is greater than the average character width of the text line, that is, Path.BBox.Width (that is, the width of the circumscribed rectangular box of the line segment) > Length (that is, the average character width of the text line), continue to determine whether the Y-axis coordinate value corresponding to the starting point of the line segment is consistent with the Y-axis coordinate value corresponding to the end point of the line segment. If they are consistent, that is, Path.StartPoint.y (i.e., the Y-axis coordinate value corresponding to the starting point of the line segment) == Path.EndPoint.y (i.e., the Y-axis coordinate value corresponding to the end point of the line segment), it means that this line segment meets the above three conditions (Path.BBox.Height (i.e., the height of the circumscribed rectangular box of the line segment) < 2, Path.BBox.Width (i.e., the width of the circumscribed rectangular box of the line segment) > Length (i.e., the average character width of the text line), Path.StartPoint.y (i.e., the Y-axis coordinate value corresponding to the starting point of the line segment) == Path.EndPoint.y) (i.e., the Y-axis coordinate value corresponding to the end point of the line segment), then the line segment can be stored in AnnoGroup as a modification element of the non-standard protocol.
[0225] It should be noted that in the process of traversing the line segments in the text line, first determine whether the height of the circumscribed rectangular box of the line segment is less than the preset first threshold, then determine whether the width of the circumscribed rectangular box of the line segment is greater than the average character width of the text line, and finally determine whether the Y-axis coordinate value corresponding to the starting point of the line segment is consistent with the Y-axis coordinate value corresponding to the end point of the line segment. This can achieve optimal performance because the time consumption of the judgment conditions will be different, and the judgment conditions close to the front are fast. In addition, here, the Y-axis coordinate value corresponding to the starting point of the line segment is determined to be consistent with the Y-axis coordinate value corresponding to the end point of the line segment to ensure that the line segment is drawn horizontally, indicating that it is not slanted.
[0226] In addition, the pictures in the text line are traversed, and the pictures that meet the preset third modification element conditions are stored in the annotation group as modification elements of the non-standard protocol, such as AnnoGroup, as shown in FIG. Figure 6 The image traversal method shown.
[0227] like Figure 6 FIG. 1 is a schematic diagram of an implementation flow of a method for traversing an image provided by an embodiment of the present invention. The method is applied to an electronic device and may specifically include the following steps:
[0228] S601, traverse the pictures in the text line, and determine whether the height of the circumscribed rectangular frame of the picture is less than a preset first threshold.
[0229] S602: When the height of the circumscribed rectangular frame of the image is less than a preset first threshold, determine whether the width of the circumscribed rectangular frame of the image is greater than an average character width of a text line.
[0230] S603: Render the image when the width of the circumscribed rectangular frame of the image is greater than the average character width of the text line.
[0231] S604: When the rendered image meets the preset color requirement, the image is stored in the annotation group as a modification element of the non-standard protocol.
[0232] In an embodiment of the present invention, the pictures in the text line are traversed, and first, it is determined whether the height of the picture's circumscribed rectangular frame (that is, the Image picture element mentioned in the above-mentioned basic element, and the coordinates of the circumscribed rectangular frame BBox contained therein) is less than a preset first threshold. If the height of the picture's circumscribed rectangular frame is not less than the preset first threshold, the picture is filtered out.
[0233] When the height of the circumscribed rectangular frame of the image is less than the preset first threshold, continue to determine whether the width of the circumscribed rectangular frame of the image is greater than the average character width of the text line. If the width of the circumscribed rectangular frame of the image is not greater than the average character width of the text line, filter out the image.
[0234] If the width of the image's bounding rectangle is greater than the average character width of the text line, the image is rendered. If the rendered image does not meet the preset color requirements, the image is filtered out. The average character width of the text line is determined by reference Figure 4 The method shown.
[0235] When the rendered image meets the preset color requirements, it means that the image meets the above three conditions. At this time, the image can be stored in the annotation group as a modification element of the non-standard protocol.
[0236] It should be noted that for images in layout electronic documents, such as images in layout electronic documents, they are usually saved in binary form. Only when they are rendered can they be viewed by the user's naked eyes, that is, images in the true sense.
[0237] In addition, in the process of traversing the image of the text line, first determine whether the height of the image's circumscribed rectangular frame is less than the preset first threshold, then determine whether the width of the image's circumscribed rectangular frame is greater than the average character width of the text line, and finally determine whether the rendered image meets the preset color requirements. This can achieve optimal performance because the time consumption of the judgment conditions will be different, and the judgment conditions in the front are fast. In addition, the modifying elements of the image type are rare and special, so the purpose of the above judgment is only to determine which straight lines are similar, that is, a picture is a straight line.
[0238] In an embodiment of the present invention, when the rendered image meets the preset color requirements, the image is stored in the annotation group as a modifying element of the non-standard protocol. Specifically, it can be: when the color of any pixel in the rendered image is not white, the rendered image is transposed into a grayscale image; the grayscale image is subjected to color histogram statistics to determine the maximum pixel color proportion, and it is determined whether the proportion exceeds the preset proportion threshold; when the proportion exceeds the preset proportion threshold, the image is stored in the annotation group as a modifying element of the non-standard protocol.
[0239] For example, traverse the image (Image) in the text line, first determine whether the height of the image's bounding rectangle is less than 2. If the height of the image's bounding rectangle is less than 2, that is, Image.BBox.Height (that is, the height of the image's bounding rectangle) < 2, continue to determine whether the width of the image's bounding rectangle is greater than the average character width of the text line. If the width of the image's bounding rectangle is greater than the average character width of the text line, that is, Image.BBox.Width (that is, the width of the image's bounding rectangle) > Length (that is, the average character width of the text line), render the image, and obtain the rendered image. When the color of any pixel is not white (background color), the rendered image is transposed into a grayscale image, and the color histogram of the grayscale image is counted to determine the maximum pixel color ratio, and whether the ratio exceeds 90%. When the ratio exceeds 90%, it means that the image meets the above three conditions (Image.BBox.Height (i.e., the height of the bounding rectangle of the image) <2, Image.BBox.Width (i.e., the width of the bounding rectangle of the image) > Length (i.e., the average character width of the text line), and the rendered image meets the preset color requirements). At this time, the image is stored in AnnoGroup as a modification element of the non-standard protocol.
[0240] It should be noted that the purpose of judging whether the proportion exceeds the preset proportion threshold is to avoid errors caused by jagged edges when rendering images, and the above 90% is an empirical value.
[0241] S206, traversing the modified elements of the non-standard protocol in the annotation group, assigning corresponding modification attributes to the modified elements of the non-standard protocol, and obtaining target modified elements of the non-standard protocol.
[0242] In an embodiment of the present invention, the target modification elements of the non-standard protocol include the deletion line of the non-standard protocol, thereby traversing the modification elements of the non-standard protocol in the annotation group to determine the first text line where the modification elements of the non-standard protocol are located; determining the first Y-axis coordinate value corresponding to the upper boundary of the circumscribed rectangular box of the modification elements of the non-standard protocol; determining the second Y-axis coordinate value corresponding to the lower boundary of the circumscribed rectangular box of the first text line, and obtaining the first Y-axis coordinate difference between the first Y-axis coordinate value and the second Y-axis coordinate value.
[0243] Determine the Y-axis third coordinate value corresponding to the lower boundary of the circumscribed rectangular box of the modifying element of the non-standard protocol; determine the Y-axis fourth coordinate value corresponding to the upper boundary of the circumscribed rectangular box of the first text line, and obtain the Y-axis second coordinate difference between the Y-axis fourth coordinate value and the Y-axis third coordinate value; when the first coordinate difference is greater than the product of the preset second value and the height of the circumscribed rectangular box of the first text line, and the second coordinate difference is less than the product of the preset third value and the height of the circumscribed rectangular box of the first text line, assign the corresponding strikethrough attribute to the modifying element of the non-standard protocol to obtain the strikethrough of the non-standard protocol.
[0244] For example, traverse the non-standard protocol modification elements in the annotation group, determine the first text line (Line) where the non-standard protocol modification elements are located, determine the Y-axis first coordinate value (DecBBox.Top) corresponding to the upper boundary of the circumscribed rectangular box of the non-standard protocol modification elements, determine the Y-axis second coordinate value (LineBBox.Bottom) corresponding to the lower boundary of the circumscribed rectangular box of the first text line, and obtain the Y-axis first coordinate difference (DecBBox.Top-LineBBox.Bottom) between the Y-axis first coordinate value and the Y-axis second coordinate value.
[0245] Determine the Y-axis third coordinate value (DecBBox.Bottom) corresponding to the lower boundary of the bounding rectangle of the modifier element of the non-standard protocol, determine the Y-axis fourth coordinate value (LineBBox.Top) corresponding to the upper boundary of the bounding rectangle of the first text line, and obtain the Y-axis second coordinate difference (LineBBox.Top-DecBBox.Bottom) between the Y-axis fourth coordinate value and the Y-axis third coordinate value, when the first coordinate difference is greater than 1 / 3 and the product of the height (LineHeight) of the bounding rectangle of the first text line, and the second coordinate difference is less than 3 / 4 and the height (LineHeight) of the bounding rectangle of the first text line. eHeight), that is, DecBBox.Top (i.e. the first coordinate value of the Y axis) - LineBBox.Bottom (i.e. the second coordinate value of the Y axis) > 1 / 3*LineHeight (i.e. the height of the circumscribed rectangular box of the first text line), LineBBox.Top (i.e. the fourth coordinate value of the Y axis) - DecBBox.Bottom (i.e. the third coordinate value of the Y axis) < 3 / 4*LineHeight (i.e. the height of the circumscribed rectangular box of the first text line), the corresponding strikethrough attribute is given to the modification element of the non-standard protocol, and the strikethrough (StrikeOut) of the non-standard protocol is obtained.
[0246] In addition, the target modifying elements of the non-standard protocol also include the underline of the non-standard protocol and the wavy underline of the non-standard protocol. Therefore, when the first coordinate difference is less than the product between the preset second value and the height of the circumscribed rectangular frame of the first text line, it is judged whether the modifying element of the non-standard protocol is text or a line segment; when the modifying element of the non-standard protocol is text or a line segment, the modifying element of the non-standard protocol is assigned a corresponding wavy underline attribute to obtain the wavy underline of the non-standard protocol; when the modifying element of the non-standard protocol is not text or a line segment, the modifying element of the non-standard protocol is assigned a corresponding underline attribute to obtain the underline of the non-standard protocol.
[0247] For example, when the first coordinate difference is less than the product of 1 / 3 and the height (LineHeight) of the circumscribed rectangular box of the first text line, that is, DecBBox.Top (i.e., the first coordinate value of the Y axis) - LineBBox.Bottom (i.e., the second coordinate value of the Y axis) < 1 / 3*LineHeight (i.e., the height of the circumscribed rectangular box of the first text line), it is determined whether the modifying element of the non-standard protocol is text or a line segment. When the modifying element of the non-standard protocol is text or a line segment, it indicates that the Unicode of the text is one of the tilde character sets (e.g., 0x70, 0x2dc, etc., which is printed as "~"), or the line segment has a Bezier drawing instruction set (indicating that the Path draws a curve). At this time, the modifying element of the non-standard protocol is assigned a corresponding wavy underline attribute to obtain a wavy underline (Squiggly) of the non-standard protocol. Otherwise, the modifying element of the non-standard protocol can be assigned a corresponding underline attribute to obtain an underline (UnderLine) of the non-standard protocol.
[0248] Through the above description of the technical solution provided by the embodiment of the present invention, by determining the annotations in the layout electronic document, when the annotations do not contain the target modifying elements of the standard protocol, for any text line in the layout electronic document, traverse the text in the text line, and store the text that meets the preset first modifying element condition as the modifying element of the non-standard protocol in the annotation group, traverse the line segments in the text line, and store the line segments that meet the preset second modifying element condition as the modifying element of the non-standard protocol in the annotation group, traverse the pictures in the text line, and store the pictures that meet the preset third modifying element condition as the modifying element of the non-standard protocol in the annotation group, assign corresponding modifying attributes to the modifying elements of the non-standard protocol in the annotation group, and obtain the target modifying elements of the non-standard protocol. In this way, the target modifying elements of the non-standard protocol in the published electronic document can be quickly identified, the conversion effect of the layout electronic document can be improved, the editability of the layout electronic document can be improved, and the readability of the layout electronic document when it is rearranged can be improved.
[0249] In addition, after traversing the modification elements of the non-standard protocol in the annotation group and assigning corresponding modification attributes to the modification elements of the non-standard protocol, and obtaining the target modification elements of the non-standard protocol, the target modification elements of the non-standard protocol can be matched with the corresponding text. This can improve the conversion effect of the layout electronic document, improve the editability of the layout electronic document, and improve the readability of the layout electronic document when it is rearranged.
[0250] Specifically, determine the first width range (i.e., coordinate range, for example, the left endpoint coordinate of the underline of the non-standard protocol is 2, and the right endpoint is 8, then the coordinate range TextRange of the underline of the non-standard protocol is (2, 8)) of the target modifier element of the non-standard protocol in the annotation group, determine the second text line where the target modifier element of the non-standard protocol in the annotation group is located, and when the first width range includes the width range of N texts in the second text line, for example Figure 7 As shown, the modification attribute of the target modification element of the non-standard protocol in the annotation group is assigned to N texts (that is, the target modification element of the non-standard protocol in the annotation group is bound or associated with N texts to facilitate subsequent format electronic document conversion), where N is a positive integer, and when the first width range does not include the width range of any text in the second text line, a first empty character is created at the first position, for example Figure 8 As shown, the modification attribute of the target modification element of the non-standard protocol in the annotation group is assigned to the first empty character (i.e., the target modification element of the non-standard protocol in the annotation group is bound or associated with the first empty character to facilitate subsequent format electronic document conversion, editing and reading).
[0251] It should be noted that the inclusion here means that the first width range intersects with the width range of the text in the second text line, and the intersection (for example, the intersection of the first width range (2, 8) and the width range of the text (5, 9) is (5, 8)) is greater than the product of a preset second threshold (for example, 0.5) and the length of the text in the second text line (for example, the coordinate range of the text is (2, 8), and its length is 8-2=6). This is not limited to the embodiments of the present invention.
[0252] The first position can be determined in the following way: determine the first coordinate value of the X axis corresponding to the center of the target modification element of the non-standard protocol in the annotation group, determine the fifth coordinate value of the Y axis corresponding to the center line of the second text line; the first coordinate value of the X axis and the fifth coordinate value of the Y axis form the first position. It can be understood that the first position here is the position directly above the target modification element of the non-standard protocol in the annotation group, such as Figure 8 shown.
[0253] In addition, for the target modification elements of the standard protocol, they can also be matched with the corresponding text, which can improve the conversion effect of the layout electronic document, improve the editability of the layout electronic document, and improve the readability of the layout electronic document when it is rearranged.
[0254] Specifically, when the annotation contains the target modifier element of the standard protocol, the target modifier element of the standard protocol is stored in the annotation group; the second width range of the target modifier element of the standard protocol in the annotation group is determined, and the third text line where the target modifier element of the standard protocol in the annotation group is located is determined; when the second width range includes the width range of M texts in the third text line, the modification attribute of the target modifier element of the standard protocol in the annotation group is assigned to the M texts, where M is a positive integer; when the second width range does not include the width range of any text in the third text line, a second empty character is created at the second position, and the modification attribute of the target modifier element of the standard protocol in the annotation group is assigned to the second empty character.
[0255] It should be noted that the inclusion here means that the second width range intersects with the width range of the text in the third text line, and the intersection is greater than the product of a preset second threshold (for example, 0.5) and the length of the text in the third text line. This embodiment of the present invention is not limited to this.
[0256] Among them, the second position can be determined specifically in the following manner: determine the second X-axis coordinate value corresponding to the center of the target modification element of the standard protocol in the annotation group, and determine the sixth Y-axis coordinate value corresponding to the center line of the third text line; the second position is composed of the second X-axis coordinate value and the sixth Y-axis coordinate value.
[0257] Corresponding to the above method embodiment, the embodiment of the present invention also provides a document processing device, such as Fig. 9 As shown, the device may include: a document acquisition module 910, an annotation determination module 920, a text line determination module 930, an element screening module 940, and an attribute assignment module 950.
[0258] The document acquisition module 910 is used to acquire a formatted electronic document;
[0259] An annotation determination module 920, used to determine annotations in the formatted electronic document;
[0260] A text line determination module 930, for identifying all text lines in the layout electronic document when the annotation does not contain a target modification element of a standard protocol;
[0261] An element screening module 940 is used for traversing the basic elements in any of the text lines, and storing the basic elements that meet the preset modifying element conditions as modifying elements of the non-standard protocol into the annotation group;
[0262] The attribute assigning module 950 is used to traverse the modified elements of the non-standard protocol in the annotation group, assign corresponding modification attributes to the modified elements of the non-standard protocol, and obtain the target modified elements of the non-standard protocol.
[0263] In an optional embodiment, the basic element includes at least one of the following: text, line segment, picture;
[0264] The element screening module includes at least one of the following submodules:
[0265] A text screening submodule, used for traversing the text in the text line, and storing the text that meets the preset first modification element condition as a modification element of the non-standard protocol into the annotation group;
[0266] A line segment screening submodule, used for traversing the line segments in the text line, and storing the line segments meeting the preset second modification element condition as modification elements of the non-standard protocol into the annotation group;
[0267] The picture screening submodule is used to traverse the pictures in the text line and store the pictures that meet the preset third modification element conditions into the annotation group as modification elements of the non-standard protocol.
[0268] In an optional implementation, the text screening submodule is specifically used for:
[0269] Traversing the text in the text line, and determining whether the height of the circumscribed rectangular frame of the text is less than a preset first threshold;
[0270] When the height of the circumscribed rectangular frame of the text is less than the preset first threshold, determining whether the Unicode of the text exists in a preset modified Unicode set;
[0271] In the case where the Unicode of the text exists in the preset modified Unicode set, determining whether the width of the circumscribed rectangular frame of the text is greater than the average character width of the text line;
[0272] When the width of the circumscribed rectangular frame of the text is greater than the average character width of the text line, the text is stored in the annotation group as a modification element of the non-standard protocol.
[0273] In an optional embodiment, the element screening module further includes:
[0274] A first text judgment submodule is used to traverse the text in the text line and judge whether the height of the circumscribed rectangular frame of the text is less than a preset first threshold;
[0275] A text storage first submodule is used to store the text as a target text into a text group if the height of the circumscribed rectangular frame of the text is not less than the preset first threshold value;
[0276] A second text determination submodule is used to determine whether the Unicode of the text exists in a preset modified Unicode set when the height of the circumscribed rectangular frame of the text is less than the preset first threshold value;
[0277] A second submodule for storing text, used for storing the text as a target text into the text group if the Unicode of the text does not exist in the preset modified Unicode set;
[0278] The width determination submodule is used to determine the average character width of the text line according to the target text in the text group.
[0279] In an optional implementation, the width determination submodule is specifically used to:
[0280] For the target text in the text group, the number of Unicodes of the target text is accumulated to obtain the total number of characters;
[0281] Accumulating the widths of the circumscribed rectangular frames of the target texts in the text group to obtain a total width;
[0282] A ratio between the total width and the total number of characters is determined, and the ratio is determined as an average character width of the text line.
[0283] In an optional implementation, the line segment screening submodule is specifically used for:
[0284] Traversing the line segments in the text line, and determining whether the height of the circumscribed rectangular frame of the line segment is less than a preset first threshold;
[0285] When the height of the circumscribed rectangular frame of the line segment is less than the preset first threshold, determining whether the width of the circumscribed rectangular frame of the line segment is greater than the average character width of the text line;
[0286] In the case where the width of the circumscribed rectangular frame of the line segment is greater than the average character width of the text line, determining whether the Y-axis coordinate value corresponding to the starting point of the line segment is consistent with the Y-axis coordinate value corresponding to the end point of the line segment;
[0287] When the Y-axis coordinate value corresponding to the starting point of the line segment is consistent with the Y-axis coordinate value corresponding to the end point of the line segment, the line segment is stored in the annotation group as a modification element of the non-standard protocol.
[0288] In an optional implementation, the picture screening submodule specifically includes:
[0289] A picture determination unit, used to traverse the pictures in the text line and determine whether the height of the circumscribed rectangular frame of the picture is less than a preset first threshold;
[0290] A width judgment unit, configured to judge whether a width of a circumscribed rectangular frame of the picture is greater than an average character width of the text line when a height of the circumscribed rectangular frame of the picture is less than a preset first threshold;
[0291] A picture rendering unit, used for rendering the picture when the width of the circumscribed rectangular frame of the picture is greater than the average character width of the text line;
[0292] The image storing unit is used to store the image as a modification element of the non-standard protocol into the annotation group when the rendered image meets the preset color requirement.
[0293] In an optional implementation manner, the picture storage unit is specifically used for:
[0294] When the color of any pixel in the rendered image is not white, transposing the rendered image into a grayscale image;
[0295] Performing color histogram statistics on the grayscale image, determining the maximum pixel color proportion, and judging whether the proportion exceeds a preset proportion threshold;
[0296] When the proportion exceeds the preset proportion threshold, the picture is stored in the annotation group as a modification element of the non-standard protocol.
[0297] In an optional embodiment, the target modification element of the non-standard protocol includes a strikethrough of the non-standard protocol;
[0298] The attribute assignment module is specifically used for:
[0299] Traversing the non-standard protocol modification elements in the annotation group, and determining the first text line where the non-standard protocol modification elements are located;
[0300] Determine a first Y-axis coordinate value corresponding to an upper boundary of a circumscribed rectangular frame of the modification element of the non-standard protocol;
[0301] Determine a Y-axis second coordinate value corresponding to a lower boundary of a circumscribed rectangular frame of the first text line, and obtain a Y-axis first coordinate difference between the Y-axis first coordinate value and the Y-axis second coordinate value;
[0302] Determine the third Y-axis coordinate value corresponding to the lower boundary of the circumscribed rectangular frame of the modification element of the non-standard protocol;
[0303] Determine a fourth Y-axis coordinate value corresponding to an upper boundary of a circumscribed rectangular frame of the first text line, and obtain a second Y-axis coordinate difference between the fourth Y-axis coordinate value and the third Y-axis coordinate value;
[0304] When the first coordinate difference is greater than the product of a preset second value and the height of the circumscribed rectangular box of the first text line, and the second coordinate difference is less than the product of a preset third value and the height of the circumscribed rectangular box of the first text line, the modification element of the non-standard protocol is assigned a corresponding strikethrough attribute to obtain a strikethrough of the non-standard protocol.
[0305] In an optional implementation, the target modification element of the non-standard protocol further includes an underline of the non-standard protocol and a wavy underline of the non-standard protocol, and the attribute assignment module is further used to:
[0306] In the case where the first coordinate difference is less than the product of a preset second value and a height of a circumscribed rectangular frame of the first text line, determining whether the modifying element of the non-standard protocol is text or a line segment;
[0307] When the modification element of the non-standard protocol is a text or a line segment, assigning a corresponding wavy underline attribute to the modification element of the non-standard protocol to obtain a wavy underline of the non-standard protocol;
[0308] In the case that the modification element of the non-standard protocol is not text or line segment, a corresponding underline attribute is given to the modification element of the non-standard protocol to obtain an underline of the non-standard protocol.
[0309] In an optional embodiment, the device further comprises:
[0310] A first width range determination module is used to determine a first width range of the target modifying element of the non-standard protocol in the annotation group, and determine a second text line where the target modifying element of the non-standard protocol in the annotation group is located;
[0311] N text assignment modules, used for assigning the modification attribute of the target modification element of the non-standard protocol in the annotation group to the N texts when the first width range includes the width range of the N texts in the second text line, wherein N is a positive integer;
[0312] The first empty character assigning module is used to create a first empty character at a first position when the first width range does not include the width range of any text in the second text line, and assign the modification attribute of the target modification element of the non-standard protocol in the annotation group to the first empty character.
[0313] In an optional implementation, the inclusion is that the first width range intersects with the width range of the text in the second text line, and the intersection is greater than the product of a preset second threshold and the length of the text in the second text line.
[0314] In an optional embodiment, the device further comprises:
[0315] The first position determination module is used to determine the first X-axis coordinate value corresponding to the center of the target modification element of the non-standard protocol in the annotation group, and determine the fifth Y-axis coordinate value corresponding to the center line of the second text line; the first position is composed of the first X-axis coordinate value and the fifth Y-axis coordinate value.
[0316] In an optional embodiment, the device further comprises:
[0317] A target modifier element storage module of a standard protocol, used for storing the target modifier element of the standard protocol into an annotation group when the annotation contains the target modifier element of the standard protocol;
[0318] A second width range determining module is used to determine a second width range of the target modifying element of the standard protocol in the annotation group, and determine a third text line where the target modifying element of the standard protocol in the annotation group is located;
[0319] M text assignment module, used for assigning the modification attribute of the target modification element of the standard protocol in the annotation group to the M texts when the second width range includes the width range of the M texts in the third text line, wherein M is a positive integer;
[0320] A second null character assigning module is used to create a second null character at a second position when the second width range does not include the width range of any text in the third text line, and assign the modification attribute of the target modification element of the standard protocol in the annotation group to the second null character.
[0321] In an optional implementation, the inclusion is that the second width range intersects with the width range of the text in the third text line, and the intersection is greater than the product of a preset second threshold and the length of the text in the third text line.
[0322] In an optional embodiment, the device further comprises:
[0323] The second position determination module is used to determine the second X-axis coordinate value corresponding to the center of the target modification element of the standard protocol in the annotation group, and determine the sixth Y-axis coordinate value corresponding to the center line of the third text line; the second position is composed of the second X-axis coordinate value and the sixth Y-axis coordinate value.
[0324] The embodiment of the present invention further provides an electronic device, such as Fig.10 As shown, it includes a processor 101, a communication interface 102, a memory 103 and a communication bus 104, wherein the processor 101, the communication interface 102, and the memory 103 communicate with each other through the communication bus 104.
[0325] Memory 103, used for storing computer programs;
[0326] The processor 101 is used to execute the program stored in the memory 103, and implements the following steps:
[0327] Acquire a layout electronic document and determine the annotations in the layout electronic document; in the case where the annotations do not contain target modifying elements of a standard protocol, identify all text lines in the layout electronic document; for any of the text lines, traverse the basic elements in the text line, and store the basic elements that meet preset modifying element conditions as modifying elements of a non-standard protocol in an annotation group; traverse the modifying elements of the non-standard protocol in the annotation group, assign corresponding modifying attributes to the modifying elements of the non-standard protocol, and obtain the target modifying elements of the non-standard protocol.
[0328] 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.
[0329] The communication interface is used for communication between the above electronic device and other devices.
[0330] The memory may include a random access memory (RAM) or a non-volatile memory, such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.
[0331] 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.
[0332] In another embodiment of the present invention, a storage medium is provided. The storage medium stores instructions. When the instructions are executed on a computer, the computer executes the document processing method described in any one of the above embodiments.
[0333] In another embodiment of the present invention, a computer program product including instructions is provided. When the computer program product is run on a computer, the computer executes the document processing method described in any one of the above embodiments.
[0334] 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 storage medium, or transmitted from one storage medium to another storage medium. For example, the computer instructions can be transmitted from one 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 storage medium can be any available medium that can be accessed by a computer 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.
[0335] 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.
[0336] Each embodiment in this specification is described in a related manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0337] 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 processing method, characterized in that: The method comprises: Obtaining a layout electronic document and determining annotations in the layout electronic document; In the case where the annotation does not contain a target modification element of a standard protocol, identifying all text lines in the formatted electronic document; For any of the text lines, traverse the basic elements in the text line, and store the basic elements that meet the preset modification element conditions into the annotation group as modification elements of the non-standard protocol; The modified elements of the non-standard protocol in the annotation group are traversed, and corresponding modified attributes are assigned to the modified elements of the non-standard protocol to obtain target modified elements of the non-standard protocol.
2. The method according to claim 1, characterized in that The basic elements include at least one of the following: text, line segment, picture; The traversing the basic elements in the text line and storing the basic elements that meet the preset modifying element conditions into the annotation group as modifying elements of the non-standard protocol includes at least one of the following: Traversing the text in the text line, and storing the text that meets the preset first modification element condition into the annotation group as a modification element of the non-standard protocol; Traversing the line segments in the text line, and storing the line segments meeting the preset second modification element condition as modification elements of the non-standard protocol into the annotation group; The pictures in the text line are traversed, and the pictures meeting the preset third modification element condition are stored in the annotation group as modification elements of the non-standard protocol.
3. The method according to claim 2, characterized in that The traversing the text in the text line and storing the text that meets the preset first modification element condition as a modification element of the non-standard protocol into the annotation group includes: Traversing the text in the text line, and determining whether the height of the circumscribed rectangular frame of the text is less than a preset first threshold; When the height of the circumscribed rectangular frame of the text is less than the preset first threshold, determining whether the Unicode of the text exists in a preset modified Unicode set; In the case where the Unicode of the text exists in the preset modified Unicode set, determining whether the width of the circumscribed rectangular frame of the text is greater than the average character width of the text line; When the width of the circumscribed rectangular frame of the text is greater than the average character width of the text line, the text is stored in the annotation group as a modification element of the non-standard protocol.
4. The method according to claim 3, characterized in that Before traversing the text in the text line and determining whether the height of the circumscribed rectangular frame of the text is less than a preset first threshold, the method further includes: Traversing the text in the text line, and determining whether the height of the circumscribed rectangular frame of the text is less than a preset first threshold; When the height of the circumscribed rectangular frame of the text is not less than the preset first threshold, storing the text as the target text in the text group; When the height of the circumscribed rectangular frame of the text is less than the preset first threshold, determining whether the Unicode of the text exists in a preset modified Unicode set; If the Unicode of the text does not exist in the preset modified Unicode set, storing the text as a target text in the text group; Determining an average character width of the text line according to the target text in the text group; The step of determining the average character width of the text line according to the target text in the text group includes: For the target text in the text group, the number of Unicodes of the target text is accumulated to obtain the total number of characters; Accumulating the widths of the circumscribed rectangular frames of the target texts in the text group to obtain a total width; A ratio between the total width and the total number of characters is determined, and the ratio is determined as an average character width of the text line.
5. The method according to claim 2, characterized in that: The traversing the line segments in the text line and storing the line segments meeting the preset second modifying element condition as modifying elements of the non-standard protocol into the annotation group includes: Traversing the line segments in the text line, and determining whether the height of the circumscribed rectangular frame of the line segment is less than a preset first threshold; When the height of the circumscribed rectangular frame of the line segment is less than the preset first threshold, determining whether the width of the circumscribed rectangular frame of the line segment is greater than the average character width of the text line; In the case where the width of the circumscribed rectangular frame of the line segment is greater than the average character width of the text line, determining whether the Y-axis coordinate value corresponding to the starting point of the line segment is consistent with the Y-axis coordinate value corresponding to the end point of the line segment; When the Y-axis coordinate value corresponding to the starting point of the line segment is consistent with the Y-axis coordinate value corresponding to the end point of the line segment, the line segment is stored in the annotation group as a modification element of the non-standard protocol.
6. The method according to claim 2, characterized in that The traversing the pictures in the text line and storing the pictures meeting the preset third modification element condition as modification elements of the non-standard protocol into the annotation group includes: Traversing the pictures in the text line, and determining whether the height of the circumscribed rectangular frame of the picture is less than a preset first threshold; When the height of the circumscribed rectangular frame of the picture is less than the preset first threshold, determining whether the width of the circumscribed rectangular frame of the picture is greater than the average character width of the text line; When the width of the circumscribed rectangular frame of the picture is greater than the average character width of the text line, rendering the picture; When the rendered image meets the preset color requirement, the image is stored in the annotation group as a modification element of the non-standard protocol.
7. The method according to claim 1, characterized in that The target modification element of the non-standard protocol includes a strikethrough of the non-standard protocol; The traversing the modified elements of the non-standard protocol in the annotation group, assigning corresponding modification attributes to the modified elements of the non-standard protocol, and obtaining the target modified elements of the non-standard protocol, includes: Traversing the non-standard protocol modification elements in the annotation group, and determining the first text line where the non-standard protocol modification elements are located; Determine a first Y-axis coordinate value corresponding to an upper boundary of a circumscribed rectangular frame of the modification element of the non-standard protocol; Determine a Y-axis second coordinate value corresponding to a lower boundary of a circumscribed rectangular frame of the first text line, and obtain a Y-axis first coordinate difference between the Y-axis first coordinate value and the Y-axis second coordinate value; Determine the third Y-axis coordinate value corresponding to the lower boundary of the circumscribed rectangular frame of the modification element of the non-standard protocol; Determine a fourth Y-axis coordinate value corresponding to an upper boundary of a circumscribed rectangular frame of the first text line, and obtain a second Y-axis coordinate difference between the fourth Y-axis coordinate value and the third Y-axis coordinate value; When the first coordinate difference is greater than the product of a preset second value and the height of the circumscribed rectangular box of the first text line, and the second coordinate difference is less than the product of a preset third value and the height of the circumscribed rectangular box of the first text line, the modification element of the non-standard protocol is assigned a corresponding strikethrough attribute to obtain a strikethrough of the non-standard protocol.
8. The method according to claim 1, characterized in that After traversing the modified elements of the non-standard protocol in the annotation group, assigning corresponding modification attributes to the modified elements of the non-standard protocol, and obtaining the target modified elements of the non-standard protocol, the method further includes: Determine a first width range of the target modifying element of the non-standard protocol in the annotation group, and determine a second text line where the target modifying element of the non-standard protocol in the annotation group is located; In the case where the first width range includes the width range of N texts in the second text line, assigning the modification attribute of the target modification element of the non-standard protocol in the annotation group to the N texts, wherein N is a positive integer; In a case where the first width range does not include the width range of any text in the second text line, creating a first empty character at a first position, and assigning the modification attribute of the target modification element of the non-standard protocol in the annotation group to the first empty character; The inclusion means that the first width range intersects with the width range of the text in the second text line, and the intersection is greater than the product of a preset second threshold and the length of the text in the second text line.
9. The method according to claim 1, characterized in that: The method further comprises: In the case where the annotation includes a target modifier element of a standard protocol, storing the target modifier element of the standard protocol into an annotation group; Determine a second width range of the target modifying element of the standard protocol in the annotation group, and determine a third text line where the target modifying element of the standard protocol in the annotation group is located; In the case where the second width range includes the width range of M texts in the third text line, assigning the modification attribute of the target modification element of the standard protocol in the annotation group to the M texts, wherein M is a positive integer; In the case where the second width range does not include the width range of any text in the third text line, creating a second empty character at a second position, and assigning the modification attribute of the target modification element of the standard protocol in the annotation group to the second empty character; The inclusion means that the second width range intersects with the width range of the text in the third text line, and the intersection is greater than the product of a preset second threshold and the length of the text in the third text line.
10. A document processing device, characterized in that: The device comprises: A document acquisition module is used to acquire electronic documents of the layout; An annotation determination module, used for determining annotations in the formatted electronic document; A text line determination module, for identifying all text lines in the formatted electronic document when the annotation does not contain a target modification element of a standard protocol; An element screening module, for traversing the basic elements in any of the text lines, and storing the basic elements that meet the preset modifying element conditions as modifying elements of the non-standard protocol into the annotation group; The attribute assignment module is used to traverse the modified elements of the non-standard protocol in the annotation group, assign corresponding modification attributes to the modified elements of the non-standard protocol, and obtain the target modified elements of the non-standard protocol.
