A multi-directional text alignment method

By employing a multi-directional text comparison method based on machine learning, and utilizing 2-grams to calculate the forward and reverse order probabilities and coordinate distributions of text to handle line breaks and overlapping text, the accuracy and efficiency issues of text comparison in packaging design drawings are resolved, reducing manual intervention and costs.

CN114048524BActive Publication Date: 2026-03-24PU HUA KE JI YOU XIAN GONG SI
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-10-22
Publication Date
2026-03-24

AI Technical Summary

Technical Problem

In packaging design drawings, text rotated at different angles can cause problems such as text reversal, line breaks, and overlap. Existing technologies are difficult to use for effective comparison, resulting in high labor costs and inaccurate comparison results.

Method used

Machine learning methods are employed, using 2-grams to calculate the probability of forward and reverse text order as a discrimination criterion. Combined with text coordinate distribution, line breaks and overlapping text are merged or processed, and detection accuracy is improved through multi-directional text comparison methods.

Benefits of technology

It reduces the workload of manual intervention, improves the accuracy of text comparison, and reduces packaging design costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114048524B_ABST
    Figure CN114048524B_ABST
Patent Text Reader

Abstract

The application provides a multi-directional text comparison method, comprising: exporting a packaging design drawing into a PDF format and parsing text content and corresponding position information; splitting the text parsed from the PDF according to intervals, and judging whether the split text is consistent; calculating 2-gram word frequency by using a large amount of Chinese corpus, calculating the probability of text in a normal order and a reverse order, and taking the probability as a basis to judge whether the text is in a reverse order; processing all the text according to position coordinates, judging the direction of the text block according to the normal order and the reverse order of the text, then sorting and merging the text in the text block; comparing the PDF text content with the standard text content for examination, matching similar lines, and marking the differences of the similar lines. The processing result can greatly reduce the structured difference between the parsed text and the actual text, improve the detection accuracy of the parsed text and the actual text, reduce the workload of manual intervention, thereby reducing the packaging design cost and precision.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the field of image processing, and more particularly, to a text direction correction and text comparison method based on machine learning. BACKGROUND

[0002] In the field of packaging design, in order to ensure the accuracy of the text information in the packaging design drawing, it is usually necessary to review the text content in the design drawing before finalizing the design drawing, especially important information such as various license numbers, which will cause irreversible loss if there is an error.

[0003] Conventional text error comparison is mostly completed in an artificial manner, but the artificial method not only has high labor and time costs, but also is prone to problems such as missed detection and false detection. Since a printed design drawing can obtain text content through analysis, some manufacturers also use machine learning methods for comparison, which can achieve the desired effect in other printed design fields. However, the packaging design drawing designs a disassembled drawing of the packaging, which results in a large number of text maps rotated to different angles. When the design drawing file is analyzed, the text may appear in reverse order, be split into lines, or overlap, and direct comparison may result in a large number of texts that cannot be successfully compared, affecting the comparison result. SUMMARY

[0004] The present application provides a multi-directional text comparison method to solve the technical problems in the prior art. The method uses machine learning to distinguish between text forward and reverse sequences, uses 2-gram to calculate the probability of text forward and reverse sequences as a discrimination standard, and combines the forward and reverse sequence results and text coordinate distribution to merge or process split and overlapping texts. The processing result can greatly reduce the structured difference between the parsed text and the actual text, improve the detection accuracy of the parsed text and the actual text, reduce the workload of manual intervention, and thus reduce the packaging design cost and precision.

[0005] The technical solution of the present application to solve the above technical problems is as follows: a multi-directional text comparison method,

[0006] which comprises the following steps:

[0007] S10: exporting a packaging design drawing into a PDF format and parsing text content and corresponding position information from the exported PDF file;

[0008] S20: splitting the text parsed from the PDF according to intervals, and judging whether the split text is consistent, so as to judge whether the text is overlapped;

[0009] S30: calculating 2-gram word frequency using a large amount of Chinese corpus, calculating the probability of text forward and reverse sequences, and using the same as a basis to judge whether the text is in reverse order;

[0010] S40: According to the position coordinates, all text blocks are processed, the direction of the text block is judged according to the text sequence, then the text in the text block is sorted and merged;

[0011] S50: The PDF text content is compared with the standard text content for examination, similar lines are matched, and the differences of the similar lines are marked, and the processed result is taken as the final result.

[0012] On the basis of the above technical solutions, the application can also be improved as follows.

[0013] Optionally, in the step S20, when the text parsed from the PDF is split, the interval is split into two texts, the two split texts are compared, if the two split texts are consistent, the original text is an overlapping text, and any text after splitting is taken as a new text to replace the original text for subsequent operation; if the two split texts are inconsistent, it indicates that the original text is not an overlapping text, and no operation is performed at this time, and the original text is used for subsequent operation.

[0014] Optionally, in the step S30, the output text in the step S20 is taken as the input text of the step S30, the pure digital text and the English letter part in the text are removed, then the text is processed in reverse order to obtain the text in the forward and reverse sequences, and the probability value of the two texts in the forward and reverse sequences is calculated according to the calculated 2-gram model, wherein the text with high probability is the correct text sequence, and the output result includes the correct text sequence, the forward and reverse sequence Boolean value of the original text and the text position coordinates; wherein in the forward and reverse sequence Boolean value of the text, the forward sequence is 0, and the reverse sequence is 1.

[0015] Optionally, in the step S40, the information output in the step S30 is taken as the input, the distance between the texts is calculated according to the coordinate position of the text, a threshold value is set as the clustering range, the texts with a distance within the threshold value are clustered into one class as a text block.

[0016] Optionally, the number of text forward and reverse sequence Boolean values in the text block is counted, and it is defined that: if the reverse sequence is more, the text block is in the reverse sequence as a whole, and all the texts in the text block are in the reverse sequence, and the text originally in the forward sequence is processed in the reverse sequence; if the forward sequence is more, the text block is in the forward sequence as a whole, and all the texts in the text block are in the forward sequence, and the text originally in the reverse sequence is processed in the forward sequence.

[0017] Optionally, the texts are sorted according to the position coordinates of the texts in the text block, the text block is in the ascending order if it is in the forward sequence, and the text block is in the descending order if it is in the reverse sequence; then the position relationship between the texts is judged according to the position coordinates to be in the same row or the same column, the texts are spliced in the order that the same row is prior to the same column, and the spliced texts are taken as new text content, and the coordinates of the maximum containing rectangle of the text block are calculated as new position coordinates.

[0018] Optionally, in step S50, when the processed text is compared with the standard text for examination, the similarity between the two sets of texts is calculated and combined, the difference between each pair of texts is extracted, the difference type between the texts is judged, and the final result is output. BRIEF DESCRIPTION OF DRAWINGS

[0019] Figure 1 A flowchart of a multi-directional text comparison method according to the present application.

[0020] Figure 2 A flowchart of a text overlap identification and processing method of a multi-directional text comparison method according to the present application.

[0021] Figure 3 A flowchart of a text forward-reverse sequence detection and processing method of a multi-directional text comparison method according to the present application.

[0022] Figure 4 A flowchart of a text block splitting and merging processing method of a multi-directional text comparison method according to the present application. DETAILED DESCRIPTION

[0023] The specific embodiments of the present application will be further described in detail below with reference to the accompanying drawings and examples. The following examples are used to illustrate the present application, but are not used to limit the scope of the present application.

[0024] In the description of the present application, unless otherwise specified and limited, it should be noted that the terms "mounting", "connection" and "connection" should be understood in a broad sense, for example, they can be mechanical connection or electrical connection, or the communication between two elements, or direct connection, or indirect connection through an intermediate medium. For those skilled in the art, the specific meaning of the above terms can be understood according to the specific circumstances.

[0025] Figure 1 A flowchart of a multi-directional text comparison method according to the present application is shown in FIG. 1, which discloses a multi-directional text comparison method according to the present application, Figure 1

[0026] which comprises the following steps:

[0027] S10: exporting the packaging design drawing into PDF format, and parsing the text content and corresponding position information from the exported PDF file;

[0028] S20: splitting the text according to the interval, and judging whether the split text is consistent, so as to judge whether the text is overlapped;

[0029] ​S30: Calculate 2-gram word frequencies using a large amount of Chinese corpus, calculate the probability of text in forward and reverse order, and use this as a basis to determine whether the text is in reverse order;

[0030] S40: Divide all text into blocks based on their position coordinates, determine the orientation of the text blocks based on their forward or reverse order, and then sort and merge the text within each block.

[0031] S50: Compare the PDF text content with the standard text content for review, match similar lines, and mark the differences in similar lines. The processed result is the final result.

[0032] Understandably, given the shortcomings in the background technology, this embodiment of the invention proposes a multi-directional text comparison method. This method utilizes machine learning to distinguish between forward and reverse text order, employs 2-grams to calculate the probability of forward and reverse text order as the discrimination criterion, and combines the forward / reverse order results with text coordinate distribution to merge or process line breaks and overlapping text. The processing results of this multi-directional text comparison method can significantly reduce the structural differences between the parsed text and the actual text, improve the detection accuracy of both, reduce the workload of manual intervention, and thus reduce packaging design costs and accuracy.

[0033] Optionally, in step S20, when splitting the text parsed from the PDF, it is split into two texts at intervals. The two split texts are compared. If the two split texts are the same, the original text is overlapping text. Any of the split texts is taken as the new text to replace the original text for subsequent operations. If the two split texts are different, it means that the original text is not overlapping text. No operation is performed at this time, and the original text is used for subsequent operations.

[0034] like Figure 2 As shown, Figure 2 This is a flowchart illustrating a text overlap recognition and processing method for a multi-directional text comparison method according to the present invention. It can be understood that in this embodiment, the text parsed from the PDF is split into two texts and compared to remove overlapping text in the original text, and the output text is guaranteed to be non-overlapping text according to a set method.

[0035] Optionally, in step S30, the output text in step S20 is used as the input text in step S30. Pure numeric text and English letters in the text are removed, and then the text is reversed to obtain text in both forward and reverse word order. According to the calculated 2-gram model, the probability values ​​of the two texts in forward and reverse word order are calculated respectively. The text with the higher probability is the correct text order. The output results include the text in the correct word order, the forward and reverse Boolean values ​​of the original text, and the text position coordinates. Among them, in the forward and reverse Boolean values ​​of the text, forward order is 0 and reverse order is 1.

[0036] As shown in Figure 3 , Figure 3 is a flowchart of a text normal and reverse sequence detection and processing method of a multi-directional text alignment method of the present application. It can be understood that in the present embodiment, the non-overlapping text after splitting and screening in step S20 is taken as the input text of the present step, and the pure digital text and the English letter part in the text are further removed, and the reverse sequence processing is performed thereon. At this time, two texts are obtained, one of which is the normal sequence text, and the other is the reverse sequence text. The probability values of the two texts are calculated through the 2-gram model, wherein the text with high probability is the correct text sequence, and the output result is the Boolean value of the normal sequence text, which is 0, and vice versa, which is 1; so as to facilitate the subsequent step to count it.

[0037] Optionally, in step S40, the information output in step S30 is taken as the input, the distance between the texts is calculated according to the coordinate positions of the texts, a threshold value is set as the clustering range, and the texts with a distance within the threshold value are clustered into a class as a text block.

[0038] As shown in Figure 4 , Figure 4 is a flowchart of a text block merging processing method of a multi-directional text alignment method of the present application. It can be understood that in the present embodiment, the texts with a distance within the set threshold value range are taken as a block according to the set threshold value as the clustering range.

[0039] Optionally, the number of text normal and reverse sequence Boolean values in the text block is counted, and it is defined that: in the case of more reverse sequences, the text block as a whole is in reverse sequence, and all the texts therein are in reverse sequence, and the originally normal sequence text is processed in reverse sequence; in the case of more normal sequences, the text block as a whole is in normal sequence, and all the texts are in normal sequence, and the originally reverse sequence text is processed in normal sequence.

[0040] It can be understood that in the present embodiment, the number of text normal and reverse sequence Boolean values in the text block is counted according to the definition of the text normal and reverse sequence Boolean values in the foregoing steps, and the number of normal and reverse sequence Boolean values is compared, and it is defined that: in the case of more reverse sequences, the text block as a whole is in reverse sequence, and all the texts are in reverse sequence, and the originally normal sequence text is processed in reverse sequence; in the case of more normal sequences, the text block as a whole is in normal sequence, and all the texts are in normal sequence, and the originally reverse sequence text is processed in normal sequence.

[0041] Optionally, the texts are sorted according to the position coordinates of the texts in the text block, the text block is in normal sequence, and the ascending order is adopted, the text block is in reverse sequence, and the descending order is adopted; the position relationship between the texts is judged according to the position coordinates as same row or same column, the texts are spliced in the order of same row priority over same column, and the spliced texts are taken as the new text content, and the maximum containing rectangle coordinates of the text block are calculated as the new position coordinates.

[0042] It can be understood that in the embodiment, the position coordinates of the text in the text block are known, and the text is sorted according to the position coordinates, and in the step, if the text block is in the normal order, the text block is arranged in ascending order, and if the text block is in the reverse order, the text block is arranged in descending order. Further, the position relationship between the texts is further judged, and the logical principle followed is that the texts are spliced in the order of the same row being superior to the same column, and the spliced texts are taken as new text content, and a large containing rectangle of the text block is calculated, and new text position coordinates are established according to the rectangle range.

[0043] Optionally, in step S50, when the processed text is compared with the standard text for examination, the similarity between the two groups of texts is calculated and combined, the difference between each pair of texts is extracted, the difference type between the texts is judged, and the final result is output.

[0044] It should be noted that in the above embodiments, the description of each embodiment has its own emphasis, and the parts not described in detail in a certain embodiment can be referred to the related description of other embodiments.

[0045] Those skilled in the art should understand that the embodiments of the present application can be provided as a method, a system, or a computer program product. Therefore, the present application can adopt a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present application can adopt the form of a computer program product implemented on one or more computer usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer usable program codes.

[0046] The present application is described with reference to flowcharts and / or block diagrams of the method, device (system), and computer program product according to the embodiments of the present application. It should be understood that each flow and / or block in the flowcharts and / or block diagrams, and the combination of the flows and / or blocks in the flowcharts and / or block diagrams can be implemented by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded computer, or other programmable data processing devices to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing devices produce a device implemented in the flowcharts and / or block diagrams. Figure 1 The function of one flow or multiple flows and / or blocks Figure 1 The function of one flow or multiple flows and / or blocks

[0047] These computer program instructions can also be stored in a computer readable storage medium capable of guiding the computer or other programmable data processing devices to work in a specific way, so that the instructions stored in the computer readable storage medium produce a manufactured product including instruction devices, which implement the flowcharts and / or block diagrams. Figure 1 The function of one flow or multiple flows and / or blocksFigure 1 the function specified in the one or more blocks.

[0048] These computer program instructions can also be loaded into computer or other programmable data processing devices, so that a series of operations steps are performed on the computer or other programmable data processing devices to generate computer-implemented processes, thus the instructions executed on the computer or other programmable data processing devices provide processes for implementing the flow Figure 1 the flow or flows and / or blocks Figure 1 the steps of the function specified in the one or more blocks.

[0049] Although preferred embodiments of the application have been described, those skilled in the art will recognize that additional modifications and variations may be possible in light of the above teachings. It is therefore intended that the appended claims cover all such modifications and variations as fall within the scope of the application.

[0050] Obviously, numerous modifications and variations of the present application are possible in light of the above teachings. It is therefore intended that the invention be covered by this patent, whatever their form.

Claims

1. A multi-directional text comparison method, characterized in that, It includes the following steps: S10: Export the packaging design drawing as a PDF file, and parse the text content and corresponding location information from the exported PDF file; S20: Split the text content parsed from the PDF into intervals and determine whether the split text is consistent, thereby determining whether the text overlaps; S30: Calculate 2-gram word frequencies using a large amount of Chinese corpus, calculate the probability of text in forward and reverse order, and use this as a basis to determine whether the text is in reverse order; S40: Divide all text into blocks based on their position coordinates, determine the orientation of the text blocks based on their forward or reverse order, and then sort and merge the text within each block. S50: Compare the merged text content with the standard text content for review, match similar lines, and mark the differences between similar lines. The processed result is the final result.

2. The multi-directional text comparison method according to claim 1, characterized in that, In step S20, when splitting the text content parsed from the PDF, it is split into two texts at intervals. The two split texts are compared. If the two split texts are the same, the original text is overlapping text. Any of the split texts is taken as the new text to replace the original text for subsequent operations. If the two split texts are different, it means that the original text is not overlapping text. No operation is performed at this time, and the original text is used for subsequent operations.

3. The multi-directional text comparison method according to claim 2, characterized in that, In step S30, the output text from step S20 is used as the input text for step S30. Pure numeric text and English letters in the text are removed. Then, the text is reversed to obtain text in both forward and reverse word order. According to the calculated 2-gram model, the probability values ​​of the forward and reverse word order texts are calculated respectively. The text with the higher probability is the correct text order. The output results include the text in the correct word order, the forward and reverse Boolean values ​​of the original text, and the text position coordinates. In the forward and reverse Boolean values ​​of the text, forward order is 0 and reverse order is 1.

4. The multi-directional text comparison method according to claim 3, characterized in that, In step S40, the information output in step S30 is used as input, the distance between texts is calculated based on the coordinate position of the text, a threshold is set as the range of clustering, and texts within the threshold are clustered into one class as a text block.

5. The multi-directional text comparison method according to claim 4, characterized in that, To count the number of forward and reverse Boolean values ​​in a text block, define the following: If there are more reverse values, the entire text block is reversed, and all the text within it is reversed, with the original forward text being reversed; if there are more forward values, the entire text block is forward, and all the text within it is forward, with the original reversed text being forwarded.

6. The multi-directional text comparison method according to claim 5, characterized in that, The text is sorted according to its position coordinates within the text block. If the text block is in ascending order, it is sorted in descending order. Then, the position coordinates are used to determine whether the text is in the same row or the same column. Text in the same row is concatenated in order of priority over text in the same column, and this is used as the new text content. The coordinates of the largest containing rectangle of the text block are calculated as the new position coordinates.

7. The multi-directional text comparison method according to claim 1, characterized in that, In step S50, when comparing the processed text with the standard text for review, the similarity between the two sets of texts is calculated line by line and combined. Differences are extracted for each pair of texts, the type of difference between the texts is determined, and the final result is output.

Citation Information

Patent Citations

  • Multi-directional text line detection method based on rectangular box coordinate transformation

    CN108875744A

  • Inspection device and label pasting device

    CN112550886A