Document paragraph structure restoration method, device and computer equipment
By identifying the text content and location information in PDF format pictures, and combining document segmentation functions and document division evaluation networks, identifying and adjusting document paragraph structure, the problem of low accuracy in restoring document paragraph structure in the existing technology is solved, and higher recognition accuracy and user experience are achieved.
Patent Information
- Application Number
- CN202411995495.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-31
- Publication Date
- 2025-04-08
AI Technical Summary
After the prior art recognizes the text content in PDF format pictures, it is difficult to accurately restore the document paragraph structure, resulting in low recognition accuracy and affecting the user experience.
By obtaining document pictures, using the image recognition network to identify text content and location information, combining document segmentation functions and document division evaluation networks, identifying and adjusting document paragraph structure to ensure that the division accuracy reaches the preset threshold.
It improves the accuracy of document paragraph structure restoration, avoids segmentation abnormal problems caused by not considering document structure in traditional methods, and improves user experience.
Smart Images

Figure CN119783643A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of text information processing, and in particular to a method, device and computer equipment for restoring document paragraph structure. Background Art
[0002] In the process of text recognition through images, especially when it is necessary to recognize the text content in PDF format images, it is often necessary to structurally segment the recognized text content according to the content of the image, so as to avoid the problem of text recognition anomalies due to the inability to recognize the text content of the image due to recent text restoration, and improve the user experience. Therefore, how to improve the structural restoration of the text paragraph structure after text recognition is the current research focus.
[0003] The traditional way to restore the structure of a text paragraph is through a recursive block method based on a separator list, which can solve the problem of simply segmenting by a fixed number of characters without considering the document structure. The document is segmented by specifying a series of separators, such as using line breaks, spaces, etc. as separators. However, this method is likely to split the original paragraph into different segments, destroying the paragraph structure of the original text, resulting in a low accuracy in restoring the document paragraph structure. Summary of the invention
[0004] Based on this, it is necessary to provide a document paragraph structure restoration method, device, computer equipment, computer readable storage medium and computer program product to address the above technical problems.
[0005] In a first aspect, the present application provides a method for restoring a document paragraph structure, comprising:
[0006] Obtaining a document image of a target document, and based on the document image, identifying each text content in the document image and position information of each text content in the document image through an image recognition network;
[0007] Based on the position information of each of the text contents in the document image, the document segments corresponding to each of the text contents are identified through a document segmentation function, and based on the text contents corresponding to each of the document segments, the document identification information corresponding to each of the document segments and the semantic content corresponding to each of the document segments are identified;
[0008] Based on the paragraph identification information of each document segment of the target document, the document position information of the paragraph identification information of each document segment, and the semantic content corresponding to each document segment, the division accuracy of each document segment is identified through a document division evaluation network;
[0009] In the case where the division accuracy is lower than a preset accuracy threshold, each abnormal document segment in the target document is identified, and based on the text content of each abnormal document segment, the text content in each abnormal document segment is adjusted through the document segmentation function to obtain each target document segment of the target document.
[0010] Optionally, the identifying, based on the document image, each text content in the document image and the position information of each text content in the document image through an image recognition network includes:
[0011] Collecting a unit text range in the document image, and based on the unit text range, performing grid splitting processing on the document image to obtain each grid document image of the document image;
[0012] The text content corresponding to each grid document image is identified through an image recognition network, and the position information of each grid document image in the document image is used as the position information of each text content in the document image.
[0013] Optionally, the identifying, based on the position information of each text content in the document image, the document segment corresponding to each text content by using a document segmentation function includes:
[0014] Based on the position information of each text content in the document image, each text content is divided into text groups corresponding to each line, and the number of characters in each text group is counted;
[0015] Based on the text data in each text group, identifying the distribution information of the number of characters in a line of the document image, and based on the distribution information of the number of characters in a line and the number of characters in the text group corresponding to each line, calculating the probability value of the end line of each behavior segment through a document segmentation function;
[0016] The segmentation end lines corresponding to the probability values less than the probability threshold are selected as the target segmentation end lines, and based on the target segmentation end lines, the text contents are divided into text contents corresponding to each document segment.
[0017] Optionally, the identifying, based on the text contents corresponding to each document segment, document identification information corresponding to each document segment and semantic content corresponding to each document segment includes:
[0018] For each document segment, sorting the text contents corresponding to the document segment according to the position information of each text content to obtain the document segment content corresponding to each document segment, and based on each document segment content, identifying the semantic content corresponding to each document segment through a semantic recognition network;
[0019] Based on the document segment content corresponding to each document segment, identify the text sequence of each text content of each document segment, and according to each of the text sequences, filter the first text content of each document segment and the last text content of each document segment by using the first and last text filtering strategy;
[0020] The text content at the beginning of each document segment and the text content at the end of each document segment are used as document identification information corresponding to each document segment.
[0021] Optionally, the identifying the division accuracy of each document segment through a document division evaluation network based on the paragraph identification information of each document segment of the target document, the document position information of the paragraph identification information of each document segment, and the semantic content corresponding to each document segment includes:
[0022] Based on the paragraph identification information of each document segment of the target document and the document position information of the paragraph identification information of each document segment, the paragraph structure accuracy of each document segment is identified through a document division structure evaluation strategy;
[0023] Based on the semantic content corresponding to each of the document segments, the paragraph semantic rationality of each document segment is identified through the document segmentation evaluation network, and the paragraph structure accuracy of each document segment and the paragraph semantic rationality of each document segment are used as the segmentation accuracy of each document segment.
[0024] Optionally, the adjusting the text contents in each of the abnormal document segments based on the text contents of each of the abnormal document segments by using the document segmentation function to obtain each target document segment of the target document includes:
[0025] Dividing each text content of adjacent abnormal document segments into abnormal text content groups, and for each abnormal text content group, performing paragraph division processing on the abnormal text content group by using the document segmentation function to obtain each new document segment;
[0026] Replace the text contents of each document segment with the text contents of each new document segment, and return to execute the step of identifying the document identification information corresponding to each document segment and the semantic content corresponding to each document segment based on the text contents corresponding to each document segment, until the division accuracy of all document segments is greater than the preset accuracy threshold, and all document segments obtained in the last iteration are used as the target document segments of the target document.
[0027] In a second aspect, the present application also provides a document paragraph structure restoration device, comprising:
[0028] An acquisition module, used to acquire a document image of a target document, and based on the document image, identify each text content in the document image and position information of each text content in the document image through an image recognition network;
[0029] an identification module, for identifying, based on the position information of each of the text contents in the document image, the document segments corresponding to each of the text contents through a document segmentation function, and identifying, based on the text contents corresponding to each of the document segments, the document identification information corresponding to each of the document segments and the semantic content corresponding to each of the document segments;
[0030] An evaluation module, configured to identify the division accuracy of each document segment through a document division evaluation network based on the paragraph identification information of each document segment of the target document, the document position information of the paragraph identification information of each document segment, and the semantic content corresponding to each document segment;
[0031] The adjustment module is used to identify the abnormal document segments in the target document when the division accuracy is lower than a preset accuracy threshold, and adjust the text content in each abnormal document segment based on the text content of each abnormal document segment through the document segmentation function to obtain the target document segments of the target document.
[0032] Optionally, the acquisition module is specifically used to:
[0033] Collecting a unit text range in the document image, and based on the unit text range, performing grid splitting processing on the document image to obtain each grid document image of the document image;
[0034] The text content corresponding to each grid document image is identified through an image recognition network, and the position information of each grid document image in the document image is used as the position information of each text content in the document image.
[0035] Optionally, the identification module is specifically used to:
[0036] Based on the position information of each text content in the document image, each text content is divided into text groups corresponding to each line, and the number of characters in each text group is counted;
[0037] Based on the text data in each text group, identifying the distribution information of the number of characters in a line of the document image, and based on the distribution information of the number of characters in a line and the number of characters in the text group corresponding to each line, calculating the probability value of the end line of each behavior segment through a document segmentation function;
[0038] The segmentation end lines corresponding to the probability values less than the probability threshold are selected as the target segmentation end lines, and based on the target segmentation end lines, the text contents are divided into text contents corresponding to each document segment.
[0039] Optionally, the identification module is specifically used to:
[0040] For each document segment, sorting the text contents corresponding to the document segment according to the position information of each text content to obtain the document segment content corresponding to each document segment, and based on each document segment content, identifying the semantic content corresponding to each document segment through a semantic recognition network;
[0041] Based on the document segment content corresponding to each document segment, identify the text sequence of each text content of each document segment, and according to each of the text sequences, filter the first text content of each document segment and the last text content of each document segment by using the first and last text filtering strategy;
[0042] The text content at the beginning of each document segment and the text content at the end of each document segment are used as document identification information corresponding to each document segment.
[0043] Optionally, the evaluation module is specifically used to:
[0044] Based on the paragraph identification information of each document segment of the target document and the document position information of the paragraph identification information of each document segment, the paragraph structure accuracy of each document segment is identified through a document division structure evaluation strategy;
[0045] Based on the semantic content corresponding to each of the document segments, the paragraph semantic rationality of each document segment is identified through a document segmentation evaluation network, and the paragraph structure accuracy of each document segment and the paragraph semantic rationality of each document segment are used as the segmentation accuracy of each document segment.
[0046] Optionally, the adjustment module is specifically used to:
[0047] Dividing each text content of adjacent abnormal document segments into abnormal text content groups, and for each abnormal text content group, performing paragraph division processing on the abnormal text content group by using the document segmentation function to obtain each new document segment;
[0048] Replace the text contents of each document segment with the text contents of each new document segment, and return to execute the step of identifying the document identification information corresponding to each document segment and the semantic content corresponding to each document segment based on the text contents corresponding to each document segment, until the division accuracy of all document segments is greater than the preset accuracy threshold, and all document segments obtained in the last iteration are used as the target document segments of the target document.
[0049] In a third aspect, the present application provides a computer device, wherein the computer device comprises a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the steps of any one of the methods in the first aspect are implemented.
[0050] In a fourth aspect, the present application provides a computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the steps of any one of the methods in the first aspect are implemented.
[0051] In a fifth aspect, the present application provides a computer program product. The computer program product includes a computer program, and when the computer program is executed by a processor, the steps of any one of the methods in the first aspect are implemented.
[0052] The document paragraph structure restoration method, device and computer equipment described above obtain a document image of a target document, and based on the document image, identify each text content in the document image and the position information of each text content in the document image through an image recognition network; based on the position information of each text content in the document image, identify the document segment corresponding to each text content through a document segmentation function, and based on each text content corresponding to each document segment, identify the document identification information corresponding to each document segment and the semantic content corresponding to each document segment; based on the paragraph identification information of each document segment of the target document, the document position information of the paragraph identification information of each document segment, and the semantic content corresponding to each document segment, identify the division accuracy of each document segment through a document division evaluation network; in the case where the division accuracy is lower than a preset accuracy threshold, identify each abnormal document segment in the target document, and based on each text content of each abnormal document segment, adjust each text content in each abnormal document segment through the document segmentation function to obtain each target document segment of the target document. This solution, after splitting each text content of image recognition, uses a document segmentation function to segment each text content, thereby obtaining each document segment, avoiding the segmentation anomaly problem of document segmentation by the traditional recursive method without considering the document structure, and improving the accuracy of document structure segmentation. Then, this solution uses the paragraph identification information and semantic content of each document segment to perform precision analysis on each document segment from the perspective of document semantic rationality and paragraph structure accuracy of the document segment, thereby identifying the accuracy of paragraph division in each document segment, and then performing paragraph adjustment on each abnormal document segment, avoiding the problem of abnormal document segment division, making the paragraph division of each document segment more accurate, thereby improving the accuracy of restoring the document paragraph structure. BRIEF DESCRIPTION OF THE DRAWINGS
[0053] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the related technologies, the drawings required for use in the embodiments or the related technical descriptions are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0054] Figure 1 A schematic diagram of a process of restoring a document paragraph structure in one embodiment;
[0055] Figure 2 A schematic diagram of a process of restoring a document paragraph structure in an embodiment;
[0056] Figure 3 A structural block diagram of a document paragraph structure restoration device in one embodiment;
[0057] Figure 4 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0058] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0059] The document paragraph structure restoration method provided by the embodiment of the present application can be applied to the application environment of document paragraph structure restoration. Among them, the method can be applied to a terminal, can also be applied to a server, can also be applied to a system including a terminal and a server, and is implemented through the interaction between the terminal and the server. Among them, the terminal can be, but is not limited to, various personal computers, laptops, medium-sized computers, etc. Among them, after the terminal splits each text content of the image recognition, it segments each text content through a document segmentation function to obtain each document segment, thereby avoiding the segmentation anomaly problem of document segmentation by the traditional recursive method without considering the document structure, and improving the accuracy of document structure segmentation. Then, this scheme uses the paragraph identification information and semantic content of each document segment to perform accuracy analysis on each document segment from the document semantic rationality and the paragraph structure accuracy of the document segment, thereby identifying the paragraph division accuracy in each document segment, thereby performing paragraph adjustment on each abnormal document segment, avoiding the problem of abnormal document segment division, making the paragraph division of each document segment obtained more accurate, thereby improving the accuracy of restoration of the document paragraph structure.
[0060] In an exemplary embodiment, Figure 1As shown, a document paragraph structure restoration method is provided, which is described by taking the method applied to a terminal as an example, and includes the following steps S101 to S104. Among them:
[0061] Step S101, obtaining a document image of a target document, and based on the document image, identifying each text content in the document image and the position information of each text content in the document image through an image recognition network.
[0062] In this embodiment, the terminal obtains a document image of the target document in response to the staff's information upload operation, wherein the image format of the document image includes but is not limited to jpg format, vector image format, GIF format, and JPG format. Then, based on the document image, the terminal identifies each text content in the document image and the position information of each text content in the document image through an image recognition network. Among them, the image recognition network is a convolutional neural network based on a self-attention mechanism. Among them, each text content is each text, wherein the text can be but is not limited to Chinese characters, letters, numbers, symbols, and special symbols. Finally, the position information of each text content in the document image is the two-dimensional position information of each text content in the document image.
[0063] Step S102, based on the position information of each text content in the document image, the document segment corresponding to each text content is identified through a document segmentation function, and based on the text content corresponding to each document segment, the document identification information corresponding to each document segment and the semantic content corresponding to each document segment are identified.
[0064] In this embodiment, the terminal identifies the document segments corresponding to each text content through a document segmentation function based on the position information of each text content in the document image, and identifies the document identification information corresponding to each document segment and the semantic content corresponding to each document segment based on the text content corresponding to each document segment. Among them, the document segmentation function is a Sigmoid function. Among them, the function range is limited: the output value domain of the Sigmoid function is between (0,1), which means that it can map any real number between 0 and 1 to form an output in the form of probability. Asymptotic properties: when x tends to positive infinity, the function value tends to 1; when x tends to negative infinity, the function value tends to 0. The specific recognition process will be described in detail later. Among them, the paragraph identification information includes the beginning of the paragraph identification information and the end of the paragraph identification information.
[0065] Step S103, based on the paragraph identification information of each document segment of the target document, the document position information of the paragraph identification information of each document segment, and the semantic content corresponding to each document segment, the division accuracy of each document segment is identified through a document division evaluation network.
[0066] In this embodiment, the terminal identifies the division accuracy of each document segment through a document division evaluation network based on the paragraph identification information of each document segment of the target document, the document location information of the paragraph identification information of each document segment, and the semantic content corresponding to each document segment. Among them, the document division evaluation network is a large language model based on natural language processing technology. The division accuracy includes the paragraph structure accuracy of each document segment and the paragraph semantic rationality of each document segment. The specific identification process will be described in detail later.
[0067] Step S104, when the division accuracy is lower than a preset accuracy threshold, identify each abnormal document segment in the target document, and based on the text content of each abnormal document segment, adjust the text content in each abnormal document segment through a document segmentation function to obtain each target document segment of the target document.
[0068] In this embodiment, when the segmentation accuracy is lower than the preset accuracy threshold, the terminal identifies each abnormal document segment in the target document, and adjusts each text content in each abnormal document segment through the document segmentation function based on each text content of each abnormal document segment to obtain each target document segment of the target document. Among them, the preset accuracy threshold is the paragraph structure accuracy threshold and the paragraph semantic rationality threshold preset in the terminal. The specific adjustment process will be described in detail later.
[0069] Based on the above scheme, after splitting each text content of image recognition, each text content is segmented through the document segmentation function to obtain each document segment, avoiding the segmentation anomaly problem of document segmentation by the traditional recursive method without considering the document structure, and improving the accuracy of document structure segmentation. Then, this scheme uses the paragraph identification information and semantic content of each document segment to perform accuracy analysis on each document segment from the perspective of document semantic rationality and paragraph structure accuracy of the document segment, thereby identifying the accuracy of paragraph division in each document segment, and then adjusting each abnormal document segment, avoiding the problem of abnormal document segment division, making the paragraph division of each document segment more accurate, thereby improving the accuracy of restoring the document paragraph structure.
[0070] Optionally, based on the document image, an image recognition network is used to identify the text content in the document image and the position information of each text content in the document image, including: collecting a unit text range in the document image, and based on the unit text range, performing grid splitting processing on the document image to obtain grid document images of the document image; identifying the text content corresponding to each grid document image through an image recognition network, and using the position information of each grid document image in the document image as the position information of each text content in the document image.
[0071] In this embodiment, the terminal collects the unit text range in the document image, and based on the unit text range, performs grid splitting processing on the document image to obtain each grid document image of the document image. Specifically, the terminal collects the font model and font size of each text content in each document image, and then, based on the image size, font model, and font size of the document image, the terminal identifies the range of each text content in the document image to obtain the unit text range. Among them, the terminal presets the corresponding ratio values between each font model and font size of different image sizes and the range of the font in the image. The terminal identifies the unit text range based on the corresponding ratio value.
[0072] Then, the terminal identifies the text content corresponding to each grid document image through the image recognition network, and uses the position information of each grid document image in the document image as the position information of each text content in the document image.
[0073] Based on the above solution, the unit text range of each text content is first identified, and then the position information is identified, which improves the recognition accuracy and efficiency of the position information.
[0074] Optionally, based on the position information of each text content in the document image, a document segmentation function is used to identify the document segment corresponding to each text content, including: based on the position information of each text content in the document image, each text content is divided into text groups corresponding to each line, and the number of characters in each text group is counted; based on the text data in each text group, the line text number distribution information of the document image is identified, and based on the line text number distribution information and the number of characters in the text group corresponding to each line, the probability value of each behavior segmentation end line is calculated through a document segmentation function; the line segmentation end line corresponding to the probability value less than the probability threshold is selected as the target segmentation end line, and based on each target segmentation end line, each text content is divided into each text content corresponding to each document segment.
[0075] In this embodiment, the terminal divides each text content into text groups corresponding to each line based on the position information of each text content in the document image, and counts the number of characters in each text group. Then, the terminal identifies the distribution information of the number of characters in the line of the document image based on the text data in each text group, and calculates the probability value of each behavior segmentation end line through the document segmentation function based on the distribution information of the number of characters in the line and the number of characters in the text group corresponding to each line. Finally, the terminal selects the line segmentation end line corresponding to the probability value greater than the probability threshold as the target segmentation end line, and divides each text content into each text content corresponding to each document segment based on each target segmentation end line.
[0076] Specifically, if each line in the document is long enough, the carriage return is removed and the paragraph is merged with the next line of text.
[0077] 1. Count the number of words in all lines of the PDF document, and calculate the mean, standard deviation, skewness, and kurtosis based on the normal distribution.
[0078] 2. When the skewness is 0, it is a normal distribution. When the skewness is greater than 0, it means that the data distribution is to the right of the mean. When the skewness is less than 0, the data distribution is to the left of the mean. If the data distribution is to the left, it means that the mean has been pulled down and needs to be shifted to the right, and vice versa.
[0079] 3. When the kurtosis is equal to 0, it means it is a standard normal. The larger the kurtosis, the more concentrated the data is, and the smaller the skewness adjustment should be.
[0080] 4. Define the skewness value as s. In order to control the adjustment range, introduce the sigmoid function to control the adjustment range within 1 standard deviation.
[0081] 5. In order to achieve the above effects, the relevant functions are defined as follows:
[0082] double upThreshold=mean+(sFactor*kFactor)*standardDeviation;
[0083] double sFactor=0.5-1.0 / (1+Math.exp(-skewness));
[0084] double kFactor=2.0 / (1+Math.exp(kurtosis));
[0085] in:
[0086] upThreshold: The length of a complete line in the external PDF is finally calculated. Lines greater than this value are considered to be still in the paragraph.
[0087] mean: The number of words in each line of the PDF is used as a random value, and the mean of the number of words in the entire PDF is calculated.
[0088] standardDeviation: The number of words in each line of the PDF is used as a random value, and the standard value is calculated by counting the number of words in the entire PDF.
[0089] Skewness: The number of words in each line of the PDF is used as a random value, and the skewness of the word count of the entire PDF is calculated.
[0090] sFactor: skewness factor, calculated based on skewness and sigmoid. When the skewness is large enough, the sFactor value is -0.5, and the upThreshold can be adjusted to the left. When the skewness is small enough, the value is 0.5, and the upThreshold can be adjusted to the right.
[0091] kurtosis: The number of words in each line of the PDF is used as a random value, and the kurtosis of the word count of the entire PDF is calculated.
[0092] kFactor: Kurtosis factor, calculated based on kurtosis and sigmoid. When the kurtosis is large enough, the kFactor value is 0, and no mean value adjustment is performed. When the kurtosis is small enough, the kFactor value is 2, which amplifies the adjustment effect of sFactor and achieves the effect of controlling the mean (mean) adjustment within one standard deviation.
[0093] Based on the above scheme, by first dividing the recognized text content into lines, then recognizing the line distribution corresponding to each line, and then dividing the document into segments, the recognition accuracy and efficiency of each document segment are improved.
[0094] Optionally, based on the text contents corresponding to each document segment, document identification information corresponding to each document segment and semantic content corresponding to each document segment are identified, including: for each document segment, the text contents corresponding to the document segment are sorted according to the position information of each text content to obtain the document segment content corresponding to each document segment, and based on each document segment content, the semantic content corresponding to each document segment is identified through a semantic recognition network; based on the document segment content corresponding to each document segment, the text sequence of the text contents of each document segment is identified, and according to each text sequence, the first text content of each document segment and the last text content of each document segment are filtered through a first and last text filtering strategy; the first text content of each document segment and the last text content of each document segment are used as the document identification information corresponding to each document segment.
[0095] In this embodiment, for each document segment, the terminal sorts the text contents corresponding to the document segment according to the position information of each text content, obtains the document segment content corresponding to each document segment, and identifies the semantic content corresponding to each document segment through a semantic recognition network based on the content of each document segment. The semantic recognition network is a large language model based on natural language processing technology.
[0096] Then, based on the document segment content corresponding to each document segment, the terminal identifies the text sequence of each text content of each document segment, and according to each text sequence, screens the first text content of each document segment and the last text content of each document segment through the first and last text screening strategy. The first and last text screening strategy is to screen a preset number of text contents from the beginning to the end of each document segment as the first text content, and screen a preset number of text contents from the end to the beginning of each document segment as the last text content, wherein the last symbol of the paragraph is also counted as the text content of the paragraph.
[0097] Finally, the terminal uses the text content at the beginning of each document segment and the text content at the end of each document segment as the document identification information corresponding to each document segment.
[0098] Based on the above scheme, the beginning and end filtering strategies are used to filter the text content at the beginning and end of each document segment, thereby facilitating the filtering of the text content at the beginning and end of each document segment.
[0099] Optionally, based on the paragraph identification information of each document segment of the target document, the document location information of the paragraph identification information of each document segment, and the semantic content corresponding to each document segment, the division accuracy of each document segment is identified through a document division evaluation network, including: based on the paragraph identification information of each document segment of the target document, and the document location information of the paragraph identification information of each document segment, the paragraph structure accuracy of each document segment is identified through a document division structure evaluation strategy; based on the semantic content corresponding to each document segment, the paragraph semantic rationality of each document segment is identified through a document division evaluation network, and the paragraph structure accuracy of each document segment and the paragraph semantic rationality of each document segment are used as the division accuracy of each document segment.
[0100] In this embodiment, the terminal identifies the paragraph structure accuracy of each document segment based on the paragraph identification information of each document segment of the target document and the document position information of the paragraph identification information of each document segment through the document division structure evaluation strategy. Among them, the document division structure evaluation strategy is to evaluate whether there is a subject noun in the first text of the paragraph, whether there is an indentation at the beginning of the paragraph, and whether there is a separator (a period, a semicolon, an exclamation mark, a question mark, etc.) at the paragraph position. When one of the above conditions is met, the evaluation accuracy is increased by a preset accuracy percentage value. When all conditions are met, the paragraph structure accuracy of the document segment is 100%.
[0101] Based on the semantic content corresponding to each document segment, the terminal identifies the paragraph semantic rationality of each document segment through the document segmentation evaluation network, and uses the paragraph structure accuracy of each document segment and the paragraph semantic rationality of each document segment as the segmentation accuracy of each document segment. The document segmentation evaluation network is a text analysis network based on a large language model, which identifies the paragraph semantic rationality of each document segment by analyzing the content logic fluency and content logic rationality of the semantic content corresponding to each document segment.
[0102] Based on the above scheme, by identifying the paragraph structure accuracy and paragraph semantic rationality of each document segment, the division accuracy of each document segment is analyzed, thereby improving the recognition accuracy of the division accuracy.
[0103] Optionally, based on the text contents of each abnormal document segment, the text contents in each abnormal document segment are adjusted through a document segmentation function to obtain target document segments of the target document, including: dividing the text contents of adjacent abnormal document segments into abnormal text content groups, and for each abnormal text content group, performing paragraph division processing on the abnormal text content group through a document segmentation function to obtain new document segments; replacing the text contents of each document segment with the text contents of each new document segment, returning to execute the step of identifying the document identification information corresponding to each document segment and the semantic content corresponding to each document segment based on the text contents corresponding to each document segment, until the division accuracy of all document segments is greater than a preset accuracy threshold, and then using all document segments obtained in the last iteration as target document segments of the target document.
[0104] In this embodiment, the terminal divides the text contents of adjacent abnormal document segments into abnormal text content groups, and for each abnormal text content group, performs paragraph division processing on the abnormal text content group through a document segmentation function to obtain new document segments. Then, the terminal replaces the text contents of each document segment with the text contents of each new document segment, and returns to execute the steps of identifying the document identification information corresponding to each document segment and the semantic content corresponding to each document segment based on the text contents corresponding to each document segment, until the division accuracy of all document segments is greater than the preset accuracy threshold, and all document segments obtained in the last iteration are used as the target document segments of the target document.
[0105] Based on the above scheme, the text content of the abnormal document segment is re-divided according to the adjacent division strategy, so as to identify each target document segment of the target document, thereby improving the accuracy of identifying each target document segment.
[0106] This application also provides an example of document paragraph structure restoration, such as Figure 2 As shown, the specific processing process includes the following steps:
[0107] Step S201, obtaining a document image of a target document.
[0108] Step S202 , collecting the unit text range in the document image, and based on the unit text range, performing grid splitting processing on the document image to obtain each grid document image of the document image.
[0109] Step S203, identifying the text content corresponding to each grid document image through an image recognition network, and using the position information of each grid document image in the document image as the position information of each text content in the document image.
[0110] Step S204: based on the position information of each text content in the document image, each text content is divided into text groups corresponding to each line, and the number of characters in each text group is counted.
[0111] Step S205, based on the text data in each text group, identify the line text number distribution information of the document image, and based on the line text number distribution information and the number of characters in the text group corresponding to each line, calculate the probability value of the end line of each behavior segment through the document segmentation function.
[0112] Step S206, selecting the segmentation end lines corresponding to the probability values less than the probability threshold as the target segmentation end lines, and dividing the text contents into text contents corresponding to each document segment based on the target segmentation end lines.
[0113] Step S207, for each document segment, sort the text contents corresponding to the document segment according to the position information of each text content to obtain the document segment content corresponding to each document segment, and based on each document segment content, identify the semantic content corresponding to each document segment through a semantic recognition network.
[0114] Step S208, based on the document segment content corresponding to each document segment, identify the text sequence of each text content of each document segment, and according to each text sequence, filter the first text content of each document segment and the last text content of each document segment through the first and last text filtering strategy.
[0115] Step S209: Use the text content at the beginning of each document segment and the text content at the end of each document segment as document identification information corresponding to each document segment.
[0116] Step S210 , based on the paragraph identification information of each document segment of the target document and the document position information of the paragraph identification information of each document segment, the paragraph structure accuracy of each document segment is identified through a document division structure evaluation strategy.
[0117] Step S211, based on the semantic content corresponding to each document segment, the paragraph semantic rationality of each document segment is identified through the document segmentation evaluation network, and the paragraph structure accuracy of each document segment and the paragraph semantic rationality of each document segment are used as the segmentation accuracy of each document segment.
[0118] Step S212: when the segmentation accuracy is lower than a preset accuracy threshold, identifying abnormal document segments in the target document.
[0119] Step S213, dividing the text contents of adjacent abnormal document segments into abnormal text content groups, and for each abnormal text content group, performing paragraph division processing on the abnormal text content group through a document segmentation function to obtain new document segments.
[0120] Step S214, replace the text contents of each document segment with the text contents of each new document segment, and return to the step of identifying the document identification information corresponding to each document segment and the semantic content corresponding to each document segment based on the text contents corresponding to each document segment, until the division accuracy of all document segments is greater than the preset accuracy threshold, and all document segments obtained in the last iteration are used as the target document segments of the target document.
[0121] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0122] Based on the same inventive concept, the embodiment of the present application also provides a document paragraph structure restoration device for implementing the document paragraph structure restoration method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in one or more document paragraph structure restoration device embodiments provided below can refer to the limitations of the document paragraph structure restoration method above, and will not be repeated here.
[0123] In an exemplary embodiment, Figure 3As shown, a document paragraph structure restoration device is provided, comprising: an acquisition module 310, a recognition module 320, an evaluation module 330 and an adjustment module 340, wherein:
[0124] The acquisition module 310 is used to acquire a document image of a target document, and based on the document image, identify each text content in the document image and the position information of each text content in the document image through an image recognition network;
[0125] The identification module 320 is used to identify the document segments corresponding to the text contents based on the position information of the text contents in the document image through the document segmentation function, and identify the document identification information corresponding to each document segment and the semantic content corresponding to each document segment based on the text contents corresponding to each document segment;
[0126] An evaluation module 330, configured to identify the division accuracy of each document segment through a document division evaluation network based on the paragraph identification information of each document segment of the target document, the document position information of the paragraph identification information of each document segment, and the semantic content corresponding to each document segment;
[0127] The adjustment module 340 is used to identify the abnormal document segments in the target document when the division accuracy is lower than a preset accuracy threshold, and adjust the text content in each abnormal document segment based on the text content of each abnormal document segment through the document segmentation function to obtain the target document segments of the target document.
[0128] Optionally, the acquisition module 310 is specifically configured to:
[0129] Collecting a unit text range in the document image, and based on the unit text range, performing grid splitting processing on the document image to obtain each grid document image of the document image;
[0130] The text content corresponding to each grid document image is identified through an image recognition network, and the position information of each grid document image in the document image is used as the position information of each text content in the document image.
[0131] Optionally, the identification module 320 is specifically configured to:
[0132] Based on the position information of each text content in the document image, each text content is divided into text groups corresponding to each line, and the number of characters in each text group is counted;
[0133] Based on the text data in each text group, identifying the distribution information of the number of characters in a line of the document image, and based on the distribution information of the number of characters in a line and the number of characters in the text group corresponding to each line, calculating the probability value of the end line of each behavior segment through a document segmentation function;
[0134] The segmentation end lines corresponding to the probability values less than the probability threshold are selected as the target segmentation end lines, and based on the target segmentation end lines, the text contents are divided into text contents corresponding to each document segment.
[0135] Optionally, the identification module 320 is specifically configured to:
[0136] For each document segment, sorting the text contents corresponding to the document segment according to the position information of each text content to obtain the document segment content corresponding to each document segment, and based on each document segment content, identifying the semantic content corresponding to each document segment through a semantic recognition network;
[0137] Based on the document segment content corresponding to each document segment, identify the text sequence of each text content of each document segment, and according to each of the text sequences, filter the first text content of each document segment and the last text content of each document segment by using the first and last text filtering strategy;
[0138] The text content at the beginning of each document segment and the text content at the end of each document segment are used as document identification information corresponding to each document segment.
[0139] Optionally, the evaluation module 330 is specifically used to:
[0140] Based on the paragraph identification information of each document segment of the target document and the document position information of the paragraph identification information of each document segment, the paragraph structure accuracy of each document segment is identified through a document division structure evaluation strategy;
[0141] Based on the semantic content corresponding to each of the document segments, the paragraph semantic rationality of each document segment is identified through a document segmentation evaluation network, and the paragraph structure accuracy of each document segment and the paragraph semantic rationality of each document segment are used as the segmentation accuracy of each document segment.
[0142] Optionally, the adjustment module 340 is specifically configured to:
[0143] Dividing each text content of adjacent abnormal document segments into abnormal text content groups, and for each abnormal text content group, performing paragraph division processing on the abnormal text content group by using the document segmentation function to obtain each new document segment;
[0144] Replace the text contents of each document segment with the text contents of each new document segment, and return to execute the step of identifying the document identification information corresponding to each document segment and the semantic content corresponding to each document segment based on the text contents corresponding to each document segment, until the division accuracy of all document segments is greater than the preset accuracy threshold, and all document segments obtained in the last iteration are used as the target document segments of the target document.
[0145] Each module in the above-mentioned document paragraph structure restoration device can be implemented in whole or in part by software, hardware or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute the operations corresponding to each module.
[0146] In an exemplary embodiment, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as shown in FIG. Figure 4 As shown. The computer device includes a processor, a memory, an input / output interface, a communication interface, a display unit and an input device. The processor, the memory and the input / output interface are connected via a system bus, and the communication interface, the display unit and the input device are connected to the system bus via the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner can be implemented through WIFI, a mobile cellular network, NFC (near field communication) or other technologies. When the computer program is executed by the processor, a method for restoring the structure of a document paragraph is implemented. The display unit of the computer device is used to form a visually visible picture, which can be a display screen, a projection device or a virtual reality imaging device. The display screen can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covering the display screen, or a button, trackball or touchpad set on the computer device shell, or an external keyboard, touchpad or mouse.
[0147] Those skilled in the art will understand that Figure 4 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0148] In an exemplary embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps of a document paragraph structure restoration method when executing the computer program.
[0149] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of the document paragraph structure restoration method are implemented.
[0150] In one embodiment, a computer program product is provided, including a computer program, which implements the steps of the document paragraph structure restoration method when executed by a processor.
[0151] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant regulations.
[0152] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.
[0153] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0154] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A method for restoring a document paragraph structure, characterized in that: The method comprises: Obtain a document image of a target document, and based on the document image, identify each text content in the document image and position information of each text content in the document image through an image recognition network; Based on the position information of each of the text contents in the document image, the document segments corresponding to each of the text contents are identified through a document segmentation function, and based on the text contents corresponding to each of the document segments, the document identification information corresponding to each of the document segments and the semantic content corresponding to each of the document segments are identified; Based on the paragraph identification information of each document segment of the target document, the document position information of the paragraph identification information of each document segment, and the semantic content corresponding to each document segment, the division accuracy of each document segment is identified through a document division evaluation network; In the case where the division accuracy is lower than a preset accuracy threshold, each abnormal document segment in the target document is identified, and based on the text content of each abnormal document segment, the text content in each abnormal document segment is adjusted through the document segmentation function to obtain each target document segment of the target document.
2. The method according to claim 1, characterized in that The identifying, based on the document image, each text content in the document image and the position information of each text content in the document image through an image recognition network includes: Collecting a unit text range in the document image, and based on the unit text range, performing grid splitting processing on the document image to obtain each grid document image of the document image; The text content corresponding to each grid document image is identified through an image recognition network, and the position information of each grid document image in the document image is used as the position information of each text content in the document image.
3. The method according to claim 2, characterized in that The identifying the document segment corresponding to each of the text contents by using a document segmentation function based on the position information of each of the text contents in the document image includes: Based on the position information of each text content in the document image, each text content is divided into text groups corresponding to each line, and the number of characters in each text group is counted; Based on the text data in each text group, identifying the distribution information of the number of characters in a line of the document image, and based on the distribution information of the number of characters in a line and the number of characters in the text group corresponding to each line, calculating the probability value of the end line of each behavior segment through a document segmentation function; The segmentation end lines corresponding to the probability values less than the probability threshold are selected as the target segmentation end lines, and based on the target segmentation end lines, the text contents are divided into text contents corresponding to each document segment.
4. The method according to claim 1, characterized in that The identifying of the document identification information corresponding to each document segment and the semantic content corresponding to each document segment based on the text content corresponding to each document segment includes: For each document segment, sorting the text contents corresponding to the document segment according to the position information of each text content to obtain the document segment content corresponding to each document segment, and based on each document segment content, identifying the semantic content corresponding to each document segment through a semantic recognition network; Based on the document segment content corresponding to each document segment, identify the text sequence of each text content of each document segment, and according to each of the text sequences, filter the first text content of each document segment and the last text content of each document segment by using the first and last text filtering strategy; The text content at the beginning of each document segment and the text content at the end of each document segment are used as document identification information corresponding to each document segment.
5. The method according to claim 1, characterized in that The method of identifying the division accuracy of each document segment through a document division evaluation network based on the paragraph identification information of each document segment of the target document, the document position information of the paragraph identification information of each document segment, and the semantic content corresponding to each document segment includes: Based on the paragraph identification information of each document segment of the target document and the document position information of the paragraph identification information of each document segment, the paragraph structure accuracy of each document segment is identified through a document division structure evaluation strategy; Based on the semantic content corresponding to each of the document segments, the paragraph semantic rationality of each document segment is identified through a document segmentation evaluation network, and the paragraph structure accuracy of each document segment and the paragraph semantic rationality of each document segment are used as the segmentation accuracy of each document segment.
6. The method according to claim 5, characterized in that The step of adjusting the text contents in each of the abnormal document segments based on the text contents of each of the abnormal document segments by using the document segmentation function to obtain each target document segment of the target document includes: Dividing each text content of adjacent abnormal document segments into abnormal text content groups, and for each abnormal text content group, performing paragraph division processing on the abnormal text content group by using the document segmentation function to obtain each new document segment; Replace the text contents of each document segment with the text contents of each new document segment, and return to execute the step of identifying the document identification information corresponding to each document segment and the semantic content corresponding to each document segment based on the text contents corresponding to each document segment, until the division accuracy of all document segments is greater than the preset accuracy threshold, and all document segments obtained in the last iteration are used as the target document segments of the target document.
7. A document paragraph structure restoration device, characterized in that: The device comprises: An acquisition module, used to acquire a document image of a target document, and based on the document image, identify each text content in the document image and position information of each text content in the document image through an image recognition network; an identification module, for identifying, based on the position information of each of the text contents in the document image, the document segments corresponding to each of the text contents through a document segmentation function, and identifying, based on the text contents corresponding to each of the document segments, the document identification information corresponding to each of the document segments and the semantic content corresponding to each of the document segments; An evaluation module, configured to identify the division accuracy of each document segment through a document division evaluation network based on the paragraph identification information of each document segment of the target document, the document position information of the paragraph identification information of each document segment, and the semantic content corresponding to each document segment; The adjustment module is used to identify the abnormal document segments in the target document when the division accuracy is lower than a preset accuracy threshold, and adjust the text content in each abnormal document segment based on the text content of each abnormal document segment through the document segmentation function to obtain the target document segments of the target document.
8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.