Text paragraph acquisition method and device, storage medium and program product
By combining document image and text information, and using pre-trained models and regular expression matching techniques, the problem of low accuracy in text paragraph recognition has been solved, achieving higher precision in text paragraph acquisition and content understanding.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- TENCENT TECH (BEIJING) CO LTD
- Filing Date
- 2022-09-05
- Publication Date
- 2026-05-19
AI Technical Summary
Existing technologies have low accuracy when recognizing text paragraphs in PDF and scanned documents. They tend to identify multiple paragraphs as one paragraph or one paragraph as multiple paragraphs, making it difficult to read the subsequent text content.
By acquiring the image and text of the document to be processed, a pre-trained document paragraph detection model and text line classification network model are used, combined with regular expression matching and regular expressions, to perform text line classification and aggregation, and correct paragraph information to improve accuracy.
It improves the accuracy of text paragraph acquisition, reduces the probability of errors, and ensures the accuracy of text line information and classification results, thereby improving the reading accuracy of subsequent text content.
Smart Images

Figure CN117009595B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer technology, and in particular to a method, apparatus, storage medium, and program product for obtaining text paragraphs. Background Technology
[0002] When reading text from Portable Document Format (PDF) documents or scanned documents, it is usually necessary to identify text paragraphs and then recognize and understand the text content within those paragraphs. The traditional method is to first obtain the document's page parameters, such as the position of headers and footers, left and right margins, and the font and size of text objects. Then, by combining this with line indentation and punctuation, the text position is determined, thus identifying the area where the text paragraph is located. However, this method of analyzing the text paragraph area using page parameters and formatting can be inaccurate, easily misidentifying multiple text paragraphs as one or one text paragraph as multiple paragraphs. This results in low accuracy of the final obtained text paragraphs, making it difficult to accurately read the subsequent text content. Summary of the Invention
[0003] The following is an overview of the subject matter described in detail herein. This overview is not intended to limit the scope of the claims.
[0004] This invention provides a method, apparatus, storage medium, and program product for obtaining text paragraphs, which can improve the accuracy of text paragraph acquisition.
[0005] On one hand, embodiments of the present invention provide a method for obtaining text paragraphs, including the following steps:
[0006] Get the document to be processed;
[0007] Based on the document to be processed, obtain the text to be processed and the corresponding image of the document to be processed;
[0008] The paragraph information of the document to be processed is obtained from the image of the document to be processed;
[0009] The paragraph information is updated based on the text to be processed to obtain the updated paragraph information;
[0010] The text lines in the text to be processed are classified to obtain classification results; wherein, the classification results include undetermined classification results and determined classification results;
[0011] The undetermined classification result is updated based on the updated paragraph information to obtain the classification update result;
[0012] Based on the determined classification result and the classification update result, the text lines in the text to be processed are aggregated to obtain the target text paragraph.
[0013] On the other hand, embodiments of the present invention also provide a text paragraph acquisition device, including:
[0014] The target acquisition unit is used to acquire the document to be processed, the text to be processed, and the image of the document to be processed corresponding to the document to be processed.
[0015] A paragraph information acquisition unit is used to obtain paragraph information of the document to be processed based on the image of the document to be processed;
[0016] The paragraph information update unit is used to update the paragraph information according to the text to be processed, so as to obtain the updated paragraph information;
[0017] A text line classification unit is used to classify the text lines in the text to be processed to obtain classification results; wherein, the classification results include undetermined classification results and determined classification results;
[0018] The classification result update unit is used to update the undetermined classification result based on the updated paragraph information to obtain the classification update result;
[0019] The text paragraph acquisition unit is used to aggregate the text lines in the text to be processed according to the determined classification result and the classification update result to obtain the target text paragraph.
[0020] Optionally, the paragraph information includes paragraph coordinate information and paragraph text information; the paragraph information updating unit is further configured to:
[0021] The step of updating the paragraph information based on the text to be processed to obtain the updated paragraph information includes:
[0022] Obtain the text line position information and text line content of the text to be processed;
[0023] Based on the text line position information, the paragraph coordinate information is aligned to obtain the aligned paragraph coordinate information;
[0024] Based on the content of the text line, the paragraph text information is corrected to obtain the corrected paragraph text information;
[0025] The aligned paragraph coordinate information and the corrected paragraph text information are used to determine the updated paragraph information.
[0026] Optionally, the text line classification unit is further configured to:
[0027] The text lines in the text to be processed are classified into content categories to obtain content classification results, wherein the content classification results include determined content classification results and undetermined content classification results;
[0028] The text lines in the text to be processed are classified according to their paragraph completion status to obtain paragraph completion status classification results, wherein the paragraph completion status classification results include determined paragraph completion status classification results and undetermined paragraph completion status classification results.
[0029] The determined content classification result and the determined paragraph completion status classification result are determined as the determined classification result, and the undetermined content classification result and the undetermined paragraph completion status classification result are determined as the undetermined classification result.
[0030] Optionally, the classification update result includes the paragraph completion status classification update result and the content classification update result; the classification result update unit is further used for:
[0031] The step of updating the undetermined classification result based on the updated paragraph information to obtain the classification update result includes:
[0032] The text lines corresponding to the classification results of the undetermined paragraph completion status are identified as the text lines to be updated.
[0033] Based on the text line to be updated and the updated paragraph information, the target paragraph information corresponding to the text line to be updated is obtained;
[0034] The classification result of the undetermined paragraph completion status is updated based on the target paragraph information to obtain the paragraph completion status classification update result;
[0035] Obtain the determined content classification result corresponding to the previous text line of the text line to be updated;
[0036] Based on the determined content classification result corresponding to the previous text line, the content classification result corresponding to the text line to be updated is updated to obtain the content classification update result.
[0037] Optionally, the text line classification unit is further configured to:
[0038] The text lines corresponding to the undetermined classification results are identified as text lines to be classified.
[0039] The text line to be classified is concatenated with the associated text line to obtain the text information to be classified, wherein the associated text line is the context text line of the text line to be classified within a preset range;
[0040] The text information to be classified is input into a pre-trained text line classification network model to perform text line classification prediction, and the target paragraph completion status classification result and status classification confidence of the text line to be classified are obtained.
[0041] When the confidence level of the state classification is lower than the preset confidence threshold, the classification result of the target paragraph completion status is determined as the classification result of the undetermined paragraph completion status.
[0042] Optionally, the text line classification unit is further configured to:
[0043] Get the preset first regular expression;
[0044] Based on the first regular expression, regular expression matching is performed on the characters in the text line to obtain the content classification result.
[0045] Optionally, the text line classification unit is further configured to:
[0046] Get the content classification result for the current text line and the content classification result for the next text line;
[0047] The content classification result corresponding to the current text line is compared with the content classification result corresponding to the next text line to obtain a comparison result;
[0048] If the comparison result is inconsistent between the content classification result corresponding to the current text line and the content classification result corresponding to the next text line, the paragraph completion status classification result corresponding to the current text line is determined to be a determined paragraph completion status classification result; or, if the comparison result is consistent between the content classification result corresponding to the current text line and the content classification result corresponding to the next text line, the paragraph completion status classification result corresponding to the current text line is determined to be an undetermined paragraph completion status classification result.
[0049] Optionally, the text line classification unit is further configured to:
[0050] Get the preset second regular expression;
[0051] Based on the second regular expression, perform regular expression matching on the characters in the next text line to obtain the regular expression matching result;
[0052] If the regular expression matching result is that the character in the next text line matches the second regular expression, the paragraph completion status classification result corresponding to the current text line is determined to be a determined paragraph completion status classification result; or, if the regular expression matching result is that the character in the next text line does not match the second regular expression, the paragraph completion status classification result corresponding to the current text line is determined to be an undetermined paragraph completion status classification result.
[0053] Optionally, the paragraph information acquisition unit is also used for:
[0054] Obtain a pre-trained document paragraph detection model;
[0055] The document image to be processed is input into the document paragraph detection model to detect paragraph positions and obtain paragraph information.
[0056] Optionally, the paragraph information acquisition unit is also used for:
[0057] Obtain training samples and training labels;
[0058] The training samples are input into the document paragraph detection model to detect paragraph positions, and the classification loss value, target center loss value and regression loss value are obtained.
[0059] The parameters of the document paragraph detection model are adjusted based on the classification loss value, the target center loss value, the regression loss value, and the training labels.
[0060] Optionally, the text paragraph generation unit is further configured to:
[0061] Assign line numbers to all lines of text in the text to be processed;
[0062] Obtain all target line numbers from all the line numbers, wherein the target line number is the line number corresponding to the text line whose paragraph completion status classification result is a completion status result;
[0063] The text lines between two adjacent target line numbers are aggregated to obtain the intermediate text paragraph;
[0064] The text line corresponding to the target line number with the larger line number value adjacent to the intermediate text paragraph is aggregated with the intermediate text paragraph to obtain the target text paragraph.
[0065] On the other hand, embodiments of the present invention also provide a text paragraph acquisition device, including:
[0066] At least one processor;
[0067] At least one memory for storing at least one program;
[0068] The text paragraph acquisition method described above is implemented when at least one of the programs is executed by at least one of the processors.
[0069] On the other hand, embodiments of the present invention also provide a computer-readable storage medium storing a processor-executable program, which, when executed by a processor, is used to implement the text paragraph acquisition method as described above.
[0070] On the other hand, embodiments of the present invention also provide a computer program product, including a computer program or computer instructions, the computer program or computer instructions being stored in a computer-readable storage medium, a processor of a computer device reading the computer program or computer instructions from the computer-readable storage medium, and the processor executing the computer program or computer instructions to cause the computer device to perform the text paragraph acquisition method as described above.
[0071] The embodiments of the present invention include at least the following beneficial effects: acquiring a document to be processed; obtaining the text to be processed and the corresponding image of the document to be processed based on the document to be processed; obtaining paragraph information of the document to be processed based on the image of the document to be processed; updating the paragraph information based on the text to be processed to obtain updated paragraph information; simultaneously, classifying the text lines in the text to be processed to obtain classification results; wherein, the classification results include undetermined classification results and determined classification results; then updating the undetermined classification results based on the updated paragraph information to obtain updated classification results; finally, aggregating the text lines in the text to be processed based on the determined classification results and the updated classification results to obtain the target text paragraph. In other words, in this embodiment of the invention, the determination of text paragraph positions is not based solely on the image of the document to be processed. Instead, both the image of the document to be processed and the text to be processed are acquired simultaneously, and the two are used to correct each other, making the paragraph information corresponding to the image of the document to be processed more accurate. At the same time, considering that the content and completion of text lines also affect the determination of text paragraphs, the text lines are classified, and the more accurate paragraph information is used to correct the text line classification results, resulting in more accurate text line classification results. Therefore, even if there are some errors in the image of the document to be processed and the text to be processed, the mutual correction between the two can obtain more accurate text line information and text line classification information with a lower error probability. Then, the text lines are aggregated according to the text line classification results to obtain the target text paragraph, which can improve the accuracy of text paragraph acquisition.
[0072] Other features and advantages of the invention will be set forth in the description which follows, and will be apparent in part from the description, or may be learned by practicing the invention. The objects and other advantages of the invention may be realized and obtained by means of the structures particularly pointed out in the description, claims, and drawings. Attached Figure Description
[0073] The accompanying drawings are provided to further understand the technical solutions of the present invention and constitute a part of the specification. They are used together with the embodiments of the present invention to explain the technical solutions of the present invention, and do not constitute a limitation on the technical solutions of the present invention.
[0074] Figure 1This is a diagram illustrating the paragraph recognition results obtained by using relevant technologies for text paragraph recognition.
[0075] Figure 2 This is a schematic diagram of an implementation environment provided by an embodiment of the present invention;
[0076] Figure 3 This is a schematic diagram of another implementation environment provided by an embodiment of the present invention;
[0077] Figure 4 This is a flowchart of a text paragraph acquisition method provided in an embodiment of the present invention;
[0078] Figure 5 This is a schematic diagram of a document paragraph detection model structure provided in an embodiment of the present invention;
[0079] Figure 6 This is a schematic diagram of the position of the detection box in the regression loss function provided in this embodiment of the invention;
[0080] Figure 7 This is a schematic diagram of a text line classification network model structure provided in an embodiment of the present invention;
[0081] Figure 8(a) is a schematic diagram of text paragraphs in the original document provided in the embodiment of the present invention;
[0082] Figure 8(b) is a schematic diagram of a text paragraph obtained using the text paragraph acquisition method provided by the present invention;
[0083] Figure 8(c) is a schematic diagram of the text paragraphs extracted using the first correlation technique;
[0084] Figure 8(d) is a schematic diagram of the text paragraphs extracted using the second correlation technique;
[0085] Figure 8(e) is a schematic diagram of the text paragraphs extracted using the third correlation technique;
[0086] Figure 9 This is a complete flowchart of a text paragraph acquisition method provided by a specific example of the present invention;
[0087] Figure 10 This is a schematic diagram of the process for obtaining training sample data for a paragraph detection model, provided by a specific example of the present invention.
[0088] Figure 11 This is a schematic diagram of the user interface of a script management system for casting provided in a specific scenario of the present invention;
[0089] Figure 12 This is a schematic diagram of a text paragraph acquisition device provided in an embodiment of the present invention;
[0090] Figure 13 This is a schematic diagram of another text paragraph acquisition device provided in an embodiment of the present invention. Detailed Implementation
[0091] The present invention will be further described below with reference to the accompanying drawings and specific embodiments. The described embodiments should not be considered as limitations on the present invention, and all other embodiments obtained by those skilled in the art without inventive effort are within the scope of protection of the present invention.
[0092] In the following description, references are made to “some embodiments,” which describe a subset of all possible embodiments. However, it is understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.
[0093] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains. The terminology used herein is for the purpose of describing embodiments of the invention only and is not intended to limit the invention.
[0094] Before providing a further detailed description of the embodiments of the present invention, the nouns and terms involved in the embodiments of the present invention will be explained, and the nouns and terms involved in the embodiments of the present invention shall be interpreted as follows.
[0095] 1) Documents to be processed: These can be documents in Portable Document Format (PDF), Open Fixed-layout Document (OFD), scanned documents, or other formats.
[0096] 2) Regular expressions are logical formulas for string manipulation. They are "rule strings" formed by using predefined specific characters and combinations of these characters. These "rule strings" are used to express a filtering logic for strings.
[0097] 3) Artificial Intelligence (AI) is the theory, methods, technology, and application systems that use digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, perceive the environment, acquire knowledge, and use that knowledge to achieve optimal results. In other words, AI is a comprehensive technology within computer science that attempts to understand the essence of intelligence and produce a new kind of intelligent machine that can react in a way similar to human intelligence. AI studies the design principles and implementation methods of various intelligent machines, enabling them to possess the functions of perception, reasoning, and decision-making.
[0098] Artificial intelligence (AI) is a comprehensive discipline encompassing a wide range of fields, including both hardware and software technologies. Fundamental AI technologies generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing, operating / interactive systems, and mechatronics. AI software technologies primarily include computer vision, speech processing, natural language processing, and machine learning / deep learning.
[0099] 4) Machine Learning (ML) is a multidisciplinary field involving probability theory, statistics, approximation theory, convex analysis, and algorithm complexity theory. It specifically studies how computers can simulate or implement human learning behavior to acquire new knowledge or skills and reorganize existing knowledge structures to continuously improve their performance. Machine learning is the core of artificial intelligence and the fundamental way to endow computers with intelligence; its applications span all areas of artificial intelligence. Machine learning and deep learning typically include techniques such as artificial neural networks, belief networks, reinforcement learning, transfer learning, inductive learning, and instructional learning.
[0100] 5) Natural Language Processing (NLP) is an important field within computer science and artificial intelligence. It studies the theories and methods for enabling effective communication between humans and computers using natural language. NLP is a science that integrates linguistics, computer science, and mathematics. Therefore, research in this field involves natural language—the language people use in daily life—and thus it has a close relationship with linguistic research. NLP techniques typically include text processing, semantic understanding, machine translation, question answering, and knowledge graphs.
[0101] 6) Blockchain is a new application model of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanisms, and cryptographic algorithms. Essentially, a blockchain is a decentralized database, a chain of data blocks linked together using cryptographic methods. Each data block contains information about a batch of network transactions, used to verify the validity of the information (anti-counterfeiting) and generate the next block. A blockchain can include an underlying platform, a platform product service layer, and an application service layer.
[0102] 7) Intelligent Traffic System (ITS), also known as Intelligent Transportation System, effectively integrates advanced science and technology (information technology, computer technology, data communication technology, sensor technology, electronic control technology, automatic control theory, operations research, artificial intelligence, etc.) into transportation, service control, and vehicle manufacturing, strengthening the connection between vehicles, roads, and users, thereby forming a comprehensive transportation system that ensures safety, improves efficiency, improves the environment, and saves energy.
[0103] 8) A script consists of dialogue and stage directions, serving as the textual foundation for dramatic art creation and the basis for the performance of writers, directors, and actors. The language of a script includes both dialogue and stage directions, with dialogue being the primary form. Dialogue includes spoken words, monologues, and asides. Stage directions are explanatory texts that include the time and place of the scene, costumes, props, set design, and the characters' expressions, actions, entrances, and exits.
[0104] Taking PDF documents as an example, their text content is not displayed through logical paragraphs and formatting as in conventional text. Instead, each line of text is independent and displayed according to a fixed style. Therefore, when reading text content in a PDF document, only individual lines of text can be obtained, not paragraphs. Inaccurate paragraph segmentation can lead to irregular sentence truncation or incorrect splicing, making subsequent text reading and semantic analysis more difficult. To obtain more accurate text paragraphs, one related technique typically first obtains the document's page parameter information, such as the position of headers and footers, left and right margins, font and font size of text objects, and then combines this with the indentation and punctuation of text lines to parse the text position, thereby determining the area where the text paragraph is located. However, this technique, which uses page parameters and formatting analysis to determine the area where the text paragraph is located, may have positional deviations, easily identifying multiple text paragraphs as one or one text paragraph as multiple text paragraphs, resulting in low accuracy in text paragraph recognition. In addition, related technologies have proposed image recognition-based methods for identifying text paragraphs in PDF documents. Specifically, the PDF document is first converted into a document image, and then the document image is input into a pre-trained machine learning model, such as a convolutional neural network model, to identify text paragraphs. However, text image-based paragraph recognition schemes are still only based on image recognition, which leads to many conversion errors when identifying text paragraphs.
[0105] Figure 1 This is a schematic diagram illustrating the paragraph recognition results obtained using relevant technologies for text paragraph recognition. (Refer to...) Figure 1The left image shows the text paragraph layout in the original doc document. To compare the text paragraph recovery results of different existing technologies, the doc document was first converted to a PDF document, and then the text paragraphs were extracted from the PDF document. doc is short for document, a file extension that can contain text information and is a commonly used document format. The middle image shows the text paragraph layout after recovering the PDF document into a doc document using one related technology, and the right image shows the text paragraph layout after recovering the PDF document into a doc document using another related technology. The outlined parts of the middle and right images highlight the inconsistencies between the recovered paragraph line breaks and the original doc document line breaks; that is, the positions of line breaks were missed during the text paragraph recovery process. For example, in the middle image, a line break was omitted at the end of the third line. This might lead to the third and fourth lines being treated as a single text paragraph during subsequent semantic content understanding. However, since the third and fourth lines are actually different text paragraphs, representing different types of text content or having different semantic features, mistakenly merging the third and fourth lines could result in poor processing accuracy. In the image on the right, line breaks were missed at the end of the second and third lines during the paragraph recognition process. This caused the original third and fourth lines to be directly merged with the second line, forming a single text paragraph. This introduced noise into the subsequent processing of the paragraph, resulting in poor processing accuracy.
[0106] To improve the accuracy of text paragraph acquisition and thus the accuracy of text paragraph content or semantic analysis, this invention provides a text paragraph acquisition method, a text paragraph acquisition device, a computer-readable storage medium, and a computer program product. In this invention, instead of relying solely on the image of the document to be processed to determine the text paragraph position, both the image and the text are acquired simultaneously. The two are then used to correct each other, making the paragraph information corresponding to the document image more accurate. Furthermore, considering that the content and completion of text lines also affect the determination of text paragraphs, text lines are classified, and the more accurate paragraph information is used to correct the text line classification results, resulting in more accurate text line classification results. Therefore, even if there are some errors in the document image and the text, through mutual correction, more accurate text line information and text line classification information with a lower error probability can be obtained. The text lines are then aggregated based on the text line classification results to obtain text paragraphs, thus improving the overall accuracy of text paragraph acquisition.
[0107] The solutions provided in the embodiments of the present invention relate to technical fields such as data processing, artificial intelligence, and film and television production technology, and are specifically described through the following embodiments.
[0108] Figure 2 This is a schematic diagram of another implementation environment provided by an embodiment of the present invention. (Refer to...) Figure 2 The implementation environment includes a terminal 201 and a server 202, which are directly or indirectly connected via wired or wireless communication. The terminal 201 and server 202 can be nodes in a blockchain, but this embodiment does not specifically limit their presence.
[0109] Terminal 201 may include, but is not limited to, smart devices with displays such as mobile phones, computers, smart voice interaction devices, smart home appliances, vehicle terminals, and aircraft. Optionally, terminal 201 may have a document display application installed that can display text paragraphs. Optionally, terminal 201 may also have a content reading application installed that can perform character recognition or semantic recognition on text paragraphs. By running the content reading application, users can further obtain the text appearing in the text paragraphs or the semantics represented by the text paragraphs.
[0110] Terminal 201 has at least the functions of initiating requests and displaying images. For example, in response to a user's document format conversion operation, terminal 201 can send a text paragraph retrieval request to server 202, and after receiving the text paragraph returned by server 202 according to the retrieval request, it can display the text paragraph.
[0111] Server 202 can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDN), and big data and artificial intelligence platforms.
[0112] Server 202 has at least the function of extracting text paragraphs from the document to be processed. When terminal 201 needs to perform the text paragraph extraction function, it can send a text paragraph extraction request to server 202, and after receiving confirmation from server 202, it sends the document to be processed for text paragraph extraction to server 202. After receiving the document to be processed, server 202 will perform the operation of extracting text paragraphs from the document to be processed. During the process of extracting text paragraphs by server 202, the document to be processed is converted into a document image and a text image. The document image is then input into a pre-trained document paragraph detection model to obtain paragraph information from the document image, and the paragraph information is updated with the text to be processed. The pre-trained document paragraph detection model is obtained by server 202 after acquiring training samples, training labels, and the document paragraph detection model. The training samples are input into the document paragraph detection model to detect paragraph positions, and a loss value is obtained. The parameters of the document paragraph detection model are then corrected using the loss value. Next, server 202 uses regular expression matching to determine the classification results of some text lines in the text to be processed. For text lines whose classification results are uncertain, they can be input again into a pre-trained text line classification network model to predict their classification results. The pre-trained text line classification network model is obtained by server 202 after acquiring training samples, training labels, and the text line classification network model itself. The training samples are input into the text line classification network model to classify text lines, and the loss value is obtained. The parameters of the text line classification network model are then adjusted using the loss value. If the classification results of some text lines are still uncertain after the pre-trained text line classification network model's prediction, server 202 can update these uncertain classification results using updated paragraph information to obtain a relatively accurate classification update result. Finally, based on the determined classification results and the classification update result, the text lines in the text to be processed are aggregated to obtain the target text paragraph. Server 202 returns the target text paragraph to terminal 201, allowing terminal 201 to display the target text paragraph.
[0113] It should be noted that the implementation environment of this embodiment of the invention can be limited to a terminal; that is, the terminal can complete the text paragraph acquisition process in a non-network environment. For example... Figure 3As shown, specifically, in response to a user's document format conversion operation, terminal 301 converts the user-provided document to be processed, obtaining the text to be processed and the image of the document to be processed. Then, the image of the processed document is input into a pre-trained document paragraph detection model to obtain paragraph information of the processed document image, and the paragraph information is updated using the text to be processed. The pre-trained document paragraph detection model is obtained by terminal 301 after acquiring training samples, training labels, and the document paragraph detection model itself. The training samples are input into the document paragraph detection model to detect paragraph positions, and a loss value is obtained. The parameters of the document paragraph detection model are then corrected using the loss value. The training samples, training labels, and the document paragraph detection model can be pre-stored locally on the terminal. Next, terminal 301 uses regular expression matching to determine the classification results of some text lines. For text lines whose classification results are not determined, they can be input again into the pre-trained text line classification network model to predict their classification results. The pre-trained text line classification network model is obtained by terminal 301 after acquiring training samples, training labels, and the network model itself. The training samples are input into the network model for text line classification, resulting in a loss value. This loss value is then used to adjust the parameters of the text line classification network model. The training samples, training labels, and the network model can all be pre-stored locally on the terminal. If, after prediction by the pre-trained network model, the classification results for some text lines are still uncertain, terminal 301 can use updated paragraph information to update these uncertain results, obtaining a relatively accurate classification update. Then, based on the confirmed classification results and the updated classification results, the text lines in the text to be processed are aggregated to obtain the target text paragraph. Finally, terminal 301 displays the target text paragraph.
[0114] It should be noted that in various specific embodiments of the present invention, when processing data related to the characteristics of a target object (such as a user) or a set of attribute information is required, the target object's permission or consent will be obtained first. Furthermore, the collection, use, and processing of this data will comply with relevant laws, regulations, and standards of the relevant countries and regions. In addition, when embodiments of the present invention need to obtain the target object's attribute information, separate permission or consent from the target object will be obtained through pop-ups or redirection to a confirmation page. Only after obtaining the target object's separate permission or consent will the necessary target object-related data for the normal operation of the embodiments of the present invention be obtained.
[0115] Figure 3The corresponding embodiment provides a text paragraph acquisition method that can be executed in an independent computer room or on a terminal device without a network module. The terminal can acquire text paragraphs without being connected to the network, which improves convenience and expands the application scenarios of text paragraph acquisition to a certain extent.
[0116] Figure 4 This is a flowchart of a text paragraph acquisition method provided in an embodiment of the present invention. In this embodiment, a server is used as the execution subject for illustration. (Refer to...) Figure 4 The method for obtaining this paragraph includes, but is not limited to, steps 110 to 170.
[0117] Step 110: Obtain the document to be processed.
[0118] In this step, the document to be processed is the document from which text paragraphs are to be extracted. The document to be processed can be a PDF document, an electronic file format that is independent of operating system platforms. This means that on various operating systems, PDF documents can accurately reproduce every character, color, and image of the original document. The document to be processed can also be an OFD document. Similar to PDF documents, OFD documents are unaffected by terminal devices or operating systems and highly preserve the original text content. The document to be processed can also be a scanned document, typically in JPG format. JPG is a common image format, and its file extension is usually .jpg.
[0119] Step 120: Based on the document to be processed, obtain the text to be processed and the corresponding image of the document to be processed.
[0120] In this step, while extracting text from the document to be processed obtained in step 110 to obtain the text in the document to be processed, and using it as the text to be processed, the document to be processed is also converted into an image to obtain the image corresponding to the document to be processed, which is used as the image of the document to be processed.
[0121] In some possible implementations, the PDF document obtained in step 110 is a PDF document converted from this document. Therefore, in this step, text conversion methods in related technologies can be used to directly extract text from the PDF document to form the text to be processed. The principle of text conversion is to extract the text content from the PDF file by analyzing the PDF syntax. Related technologies provide tools such as pdfminer, which can extract text content from PDF files. Simultaneously, the PDF document is converted into an image to form a document image to be processed. The format of the document image to be processed can be JPG, JPEG, PNG, GIF, etc., without specific limitations here.
[0122] In some possible implementations, the document obtained in step 110 is a scanned document. Therefore, in this step, the scanned document is first converted into an image, and then the text is extracted using Optical Character Recognition (OCR) technology to form the text to be processed. However, if the obtained document to be processed is itself in image format, no further processing is required, and the document to be processed can be directly used as the image of the document to be processed.
[0123] Step 130: Obtain the paragraph information of the document to be processed based on the image of the document to be processed.
[0124] In this step, target detection is performed on the text paragraphs in the document image to be processed. By detecting the text paragraphs in the document image, the paragraph information can be obtained, so that subsequent steps can correct the paragraph information based on the text to be processed. The corrected paragraph information can then be used to correct the classification of text lines, thereby obtaining more accurate text line classification results. This helps to finally aggregate more accurate text paragraphs.
[0125] In some possible implementations, paragraph information includes paragraph coordinate information and paragraph text information. The document image to be processed is input into a pre-trained document paragraph detection model to detect paragraph information, obtaining the position coordinates corresponding to the text paragraphs. These position coordinates identify the location of the text paragraphs in the image and constitute paragraph coordinate information. Then, based on the paragraph coordinate information, the image corresponding to the text paragraphs is extracted and processed. The purpose of this is to exclude some image regions that are not text paragraphs, leaving only the image of the text paragraphs. Then, techniques such as OCR are used to extract the paragraph text from the text paragraph image. The extracted paragraph text is paragraph text information, reflecting the text content contained in the text paragraph. Paragraph coordinate information and paragraph text information together constitute paragraph information. In step 120, after obtaining the text line to be processed, the text line position information and text line content can be further obtained. The text line position information identifies the location of the text line, and the text line content records the text content of the text line. Since both the image and the text to be processed require coordinate information to identify text paragraphs or lines, and these paragraphs and lines need to be mutually corrected, the coordinate information identifying text paragraphs and the position information identifying text lines must be aligned to ensure they can find their corresponding positions and have the same reference during mutual correction. Furthermore, errors may occur during text recognition of text paragraph images, so the paragraph text information also needs to be corrected based on the text line content of the text to be processed.
[0126] In some possible implementations, the document paragraph detection model can be the CenterNet model. CenterNet is an object detection model that directly regresses and outputs the center point coordinates, width, and height of the target object during object detection. For efficiency reasons, this embodiment uses a one-stage detection model. Furthermore, since some documents have a defined text layout, such as all text lines or paragraphs arranged from top to bottom without column breaks (e.g., scripts, ordinary books), document paragraph detection can be degraded into a one-dimensional coordinate detection model. This model detects text paragraphs only at the height level; that is, it performs average pooling on the X-axis of the extracted network feature map and only detects paragraphs on the Y-axis, ultimately outputting the height coordinates of the text paragraph. Average pooling preserves background information and makes the extracted features smoother. Figure 5 This is a schematic diagram of the document paragraph detection model structure provided in this embodiment of the invention. As shown in the figure, the document paragraph detection model includes multiple downsampling convolutional layers and a head network. The downsampling convolutional layers are used for image feature extraction. The head network acquires the image features extracted by the downsampling convolutional layers, predicts the classification results, and finally outputs the Y-axis coordinates corresponding to the text paragraphs. The downsampling convolutional layers specifically include convolutional blocks C3-C5 and D3-D6. The numbers in convolutional blocks C3-C5 and D3-D6 are used to calculate the downsampling factor. For example, for convolutional block C3, the downsampling factor is 2 to the power of 3, which equals 8; for convolutional block D5, the downsampling factor is 2 to the power of 5, which equals 32. Each head takes an image with a spatial resolution of H*W*256 as input. After processing, the H*W*256 image yields four H*1*256 images. These images are then further processed to output three branches: a category of size H*1*C (where C represents the number of categories), a center point offset of size H*1*1, and an object detection bounding box of size H*1*2. Each of the three branches is optimized using a different loss function. For the category output, the classification loss function ClassificationLoss = FL(P) is used. t )=-(1-P t ) γ log(P t ) calculate the classification loss value, where P t This represents the probability of the ground truth label; γ is an empirical value, which can be 0.2 in this embodiment. To find the center point of the target, a center loss function is used. The center loss value is calculated, where t* represents the difference between the upper coordinate of the corresponding point and the upper coordinate of the GroundTruth point, and b* represents the difference between the lower coordinate of the corresponding point and the lower coordinate of the GroundTruth point. The regression objective of the center point is to make the classification more focused on the center of the class; that is, the closer to the center point, the larger the value, and the farther away from the center point, the lower the value. For the regression loss, the regression loss function is used. The regression loss value is calculated, where area_inter represents the region formed by the intersection of two detection boxes, and area_union represents the region formed by the union of two detection boxes, which correspond to the predicted box and the ground truth box, respectively. Figure 6 The diagram visually illustrates the two detection boxes and their intersection and union regions. The intersection region corresponds to the shaded area in the diagram, and the union region corresponds to the area enclosed by the bold black line. Then, based on the classification loss value, target center loss value, regression loss value, and ground truth label obtained from the three loss functions mentioned above, the parameters of the document paragraph detection model are corrected, resulting in a pre-trained document paragraph detection model.
[0127] In some possible implementations, the document paragraph detection model can be a two-stage CenterNet model. Compared to the one-stage CenterNet model, the two-stage CenterNet model acquires potential targets and their locations during the first stage, and then performs fine-grained target detection in the second stage. The two-stage CenterNet model requires multiple runs of the detection and classification process, therefore its detection speed is slower than the one-stage CenterNet model. Similar to the previous implementation, the document paragraph detection model based on the CenterNet model framework ultimately outputs the center coordinates, width, and height of the detection box corresponding to the text paragraph. Based on the center coordinates, width, and height, the detection box corresponding to the text paragraph can be determined, and the text paragraph image can then be extracted. For some text images with columns, a two-dimensional coordinate detection model is required. The model's output includes not only the height coordinates of the text paragraph but also the width coordinates.
[0128] It is understandable that the model framework structure can be adaptively adjusted for different application scenarios and detection objectives, and the training data used in the model training process will also be different. Since the essence of object detection is to find all objects in an image and determine their location and the probability of their category, other models capable of object detection can also be used in other embodiments of the present invention, such as the CornerNet model and the Cascade R-CNN model. The CornerNet model locates objects by finding the upper left and lower right corners of the object's bounding box and classifies the corners to obtain the object's category. The Cascade R-CNN model uses cascaded detection heads, using the subsequent detection head to correct the regression results of the previous detection head, thereby achieving more accurate detection. The aforementioned CornerNet model and Cascade R-CNN model are common models in the field of object detection technology. Their principles and structures can be referred to the relevant descriptions in related technologies, and will not be repeated here. Step 140: Update the paragraph information according to the text to be processed to obtain the updated paragraph information.
[0129] In this step, the paragraph information obtained in step 130 is updated based on the text to be processed obtained in step 120. It is understandable that although the document paragraph detection model in step 130 can output relatively accurate paragraph information, some errors may still exist. Updating it with the text to be processed can further correct these errors and reduce the overall error. The paragraph information includes paragraph coordinate information and paragraph text information. The text to be processed includes text line position information and text line content. Both text line position information and paragraph coordinate information can identify the position of the text or paragraph on the image page. Both paragraph text information and text line content record the text content; therefore, the two pairs of information can be mutually corrected.
[0130] In some possible implementations, the paragraph coordinate information is aligned based on the text line position information to obtain aligned paragraph coordinate information. Aligning the paragraph coordinate information enables the coordinates of the corresponding text paragraph in the document image to be found by mapping the coordinates of the text lines in the text to be processed, thereby finding the corresponding text paragraph. At the same time, the paragraph text information is corrected based on the text line content to obtain corrected paragraph text information. Then, the aligned paragraph coordinate information and the corrected paragraph text information are used together as the updated paragraph information. At this point, the paragraph information update is completed.
[0131] In some possible implementations, to improve computational efficiency, the paragraph coordinate information can be aligned using only the text line position information of the text to be processed, without modifying the paragraph text information. After aligning the paragraph coordinate information, aligned paragraph coordinate information can be obtained, and this aligned paragraph coordinate information can be used as the updated paragraph information.
[0132] Step 150: Classify the text lines in the text to be processed to obtain classification results; wherein, the classification results include undetermined classification results and determined classification results.
[0133] Because the detection of text paragraphs in related technologies focuses on document images without considering text content or semantics, the resulting text paragraphs may differ significantly from the actual content and state conveyed by the original document. Therefore, in this step, we classify text lines to extract the text content and state inherent in each line.
[0134] In some possible implementations, content classification results are obtained by classifying the text lines in the text to be processed. There are various methods for content classification; in this embodiment, regular expressions are used to match characters appearing in the text lines, and the content classification result of the text lines is obtained based on the matching results. Since the criteria for classifying text content differ in different application scenarios, a first regular expression can be preset to represent the characters to be matched. Then, during the text content classification process, the first regular expression is used to perform regular expression matching on the characters in the text lines. It is understood that when the characters in a text line successfully match the first regular expression, the text line content classification obtains a definite content classification result, which is defined as a determined content classification result; for text lines that cannot successfully match the first regular expression, their corresponding content classification result is an undetermined content classification result. Therefore, the content classification result includes determined content classification results and undetermined content classification results.
[0135] In some possible implementations, the text lines in the text to be processed are first classified by content to obtain content classification results. Then, the text lines in the text to be processed are classified by paragraph completion status to obtain paragraph completion status classification results. There are various methods for classifying paragraph completion status. In this embodiment, the current text line is determined as the text line to be classified by paragraph completion status. First, the content classification result corresponding to the current text line is obtained and the content classification result corresponding to the next text line is obtained. Then, the content classification result corresponding to the current text line and the content classification result corresponding to the next text line are compared to obtain a comparison result. If the comparison result shows that the content classification result corresponding to the current text line and the content classification result corresponding to the next text line are inconsistent, it means that the two text lines belong to different content categories. Then, they are likely to belong to different paragraphs, that is, the next text line starts a new paragraph. Therefore, the current text line is a text line in a paragraph completion state. The classification result for text lines that can be determined to be in a paragraph completion state is the determined paragraph completion status classification result. Conversely, if the comparison result shows that the content classification result of the current text line matches the content classification result of the next text line, then the two text lines may belong to the same paragraph or different paragraphs. In this case, the paragraph completion status classification result of the current text line cannot be determined definitively, and the paragraph completion status classification result of the current text line is undetermined. Since the paragraph completion status classification result is still undetermined, further judgment is required. The judgment of paragraph completion status classification can also be aided by regular expressions. The matching result of regular expressions can be used to assist in judging the paragraph completion status. Therefore, a second regular expression can be preset to represent the characters to be matched, and then the second regular expression can be used to perform regular expression matching on the characters in the text line. Understandably, when a character in a text line successfully matches the second regular expression, the paragraph completion status classification yields a definite paragraph completion status classification result, which is defined as a determined paragraph completion status classification result. For text lines that do not successfully match the second regular expression, their corresponding paragraph completion status classification result is an indeterminate paragraph completion status classification result. For text lines whose paragraph completion status classification result is still uncertain, further judgment is required.
[0136] In some possible implementations, after classifying the text content and paragraph completion status of each text line, the classification status of some text lines may remain undetermined. In this case, the classification results of the determined content and the determined paragraph completion status are designated as determined classification results, while the classification results of the undetermined content and the undetermined paragraph completion status are designated as undetermined classification results. For text lines with undetermined classification results, further classification prediction is required. In this embodiment, since the classification results of these text lines are undetermined, these text lines are referred to as unclassified text lines. Because these unclassified text lines may be difficult to classify due to insufficient text information, the unclassified text lines are concatenated with their context text lines, which are called associated text lines. After concatenation, a longer unclassified text information is obtained. Using this unclassified text information, the classification of the unclassified text lines is determined. Then, the text information to be classified is input into a pre-trained text line classification network model to perform text line classification prediction, and the target paragraph completion status classification result and status classification confidence score of the text line to be classified are obtained. Here, the target paragraph completion status classification result is the paragraph completion status classification result predicted by the text line classification network model, and the status classification confidence score is the credibility of the predicted paragraph completion status classification result. Understandably, if the confidence level of the state classification is relatively high, for example, above 0.8, then the predicted paragraph completion state classification results can be considered quite reliable. In this case, these high-confidence paragraph completion state classification results are defined as determined paragraph completion state classification results. The text lines corresponding to these determined paragraph completion state classification results are the text lines that are worth relying on, and the classification of other text lines will depend on these reliable text lines. Conversely, if the confidence level of the state classification is relatively low, for example, below 0.3, then the predicted paragraph completion state classification results can be considered unreliable. In this case, these low-confidence paragraph completion state classification results are defined as undetermined paragraph completion state classification results, and these undetermined paragraph completion state classification results need to be corrected in step 160.
[0137] In some possible implementations, the text line classification network model structure is as follows: Figure 7As shown, the model framework is the BERT model, with two fully connected layers (FC) connected to the output classification head CLS. These FC layers are used to determine the content of text lines and the completion status of text line paragraphs. As can be seen from the figure, the text context is input into the BERT model. The [CLS] flag indicates the start of the first sentence (sentence 1), and the [SEP] flag indicates the end of each sentence. Since the [CLS] flag itself has no meaning, when calculating attention, CLS will more fairly calculate its own attention to each word in the sentence. Therefore, the output of the last output layer using [CLS] represents the semantic vector classification of the entire sentence, mainly used in the final classification task. After the text context is processed by the BERT model, a semantic vector C is obtained, and the text line content and the completion status of text line paragraphs are further determined based on the semantic vector C. Therefore, after the text line classification network model predicts the text line to be classified, it can obtain the target content classification result and the paragraph completion status classification result of the target text line. The paragraph completion status classification result also includes the status classification confidence score, which can be used to evaluate the credibility of the classification result.
[0138] It should be noted that the BERT model is a common model in the field of natural language processing. Its principles and structure can be found in relevant descriptions in related technologies, and will not be elaborated here.
[0139] Step 160: Update the undetermined classification results based on the updated paragraph information to obtain the classification update results.
[0140] Based on step 150, the classification result for each line of text can be obtained. The classification result may be a determined classification result or an undetermined classification result. In this step, the undetermined classification results will be updated to obtain the updated classification result.
[0141] In some possible implementations, the text lines corresponding to the undetermined paragraph completion status classification results are first identified as the text lines to be updated. Subsequent updates will be performed around these undetermined text lines. Since the text lines to be updated are text lines within the text to be processed, after identifying which text lines are to be updated, it is necessary to find the corresponding text line positions in the document image to be processed, that is, to find the paragraph information corresponding to the text lines to be updated in the updated paragraph information. Since the text line position information and paragraph coordinate information have already been aligned in step 140, the target paragraph information corresponding to the text lines to be updated can be found, and then the undetermined paragraph completion status classification results are updated using the target paragraph information.
[0142] In some possible implementations, updating the classification result of an uncertain paragraph completion status can be achieved by determining whether the target paragraph information contains paragraph separators. If the target paragraph information contains paragraph separators, the text line to be updated can be considered the last line of a text paragraph. Therefore, its corresponding paragraph completion status classification result is updated from an uncertain paragraph completion status classification result to a completed status result. At this time, the paragraph completion status classification result of the text line becomes the confirmed paragraph completion status classification result. Simultaneously, the confirmed content classification result corresponding to the previous text line of the text line to be updated is obtained. Using the confirmed content classification result of the previous line, the content classification result corresponding to the text line to be updated is updated to obtain the content classification update result. Conversely, if the target paragraph information does not contain paragraph separators, the text line to be updated can be considered not the last line of a text paragraph. Therefore, its corresponding paragraph completion status classification result is updated from an uncertain paragraph completion status classification result to an incomplete status result. At this time, the paragraph completion status classification result of the text line also becomes the confirmed paragraph completion status classification result.
[0143] It should be noted that the "undetermined classification result" mainly corresponds to two situations. One situation is a classification result whose confidence level is lower than the preset confidence threshold after prediction by the text line classification network model in step 150. The other situation is a classification result obtained solely through regular expression matching and judgment based on the consistency of classification of adjacent text lines, without prediction by the text line classification network model in step 150. In the second situation, the number of text lines with undetermined classification results will be greater, requiring more correction work based on paragraph information.
[0144] Step 170: Based on the determined classification results and the classification update results, aggregate the text lines in the text to be processed to obtain the target text paragraph.
[0145] In this step, based on the update of the classification results of the text lines with undetermined classification results in step 160, all text lines have relatively accurate classification results. At this point, the text lines can be aggregated based on the classification results and aggregation rules to obtain the desired text paragraphs.
[0146] In some possible implementations, among all text lines, the text lines whose paragraph completion status is classified as "complete" are selected as target text lines. The text lines between these target text lines then constitute the content of the same text paragraph. Therefore, by aggregating these intermediate lines with the next text line immediately following them, a complete text paragraph can be obtained. Based on the above principle, for ease of practical operation, all text lines in the text to be processed are assigned line numbers, which can be commonly used Arabic numerals. Among all text lines, the line number corresponding to the text line whose paragraph completion status is classified as "complete" is selected as the target line number. The text lines between two adjacent target line numbers are aggregated to obtain the intermediate text paragraph. Then, the text lines corresponding to the target line numbers with larger line numbers adjacent to the intermediate text paragraph are aggregated with the intermediate text paragraph to obtain the target text paragraph.
[0147] In some possible implementations, a text segment can be obtained by aggregating text lines of the same content category and those whose paragraph completion status is incomplete, based on the classification of text line content and the classification of text line paragraph completion status. Then, the next text line after the last text line of this text segment can be aggregated into this text segment to obtain the desired text segment.
[0148] The above embodiments do not rely solely on the image of the document to be processed to determine the position of text paragraphs. Instead, they acquire both the image and the text to be processed simultaneously, using them to correct each other and making the paragraph information corresponding to the image more accurate. Furthermore, considering that the content and completion of text lines also affect the determination of text paragraphs, the text lines are classified, and the more accurate paragraph information is used to correct the text line classification results, resulting in more accurate text line classification results. Therefore, even if there are some errors in the image and text to be processed, through mutual correction, more accurate text line information and text line classification information with a lower error probability can be obtained. Then, the text lines are aggregated based on the text line classification results to obtain the target text paragraph, thus improving the accuracy of text paragraph acquisition.
[0149] It is understood that although the steps in the above flowcharts are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated in this embodiment, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the above flowcharts may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages in other steps.
[0150] Figure 8(a) is a schematic diagram of a text paragraph in the original document provided in an embodiment of the present invention. The original document is in a first format, which in this embodiment is doc format. The original document is then converted to a second format, which in this embodiment is PDF format. To test the effectiveness of the text paragraph extraction scheme provided by the present invention, the second format document is converted back to the first format document using the text paragraph extraction scheme provided by the present invention and three other related technologies. The differences between the four converted first format documents and the original document are compared. Figure 8(b) is a schematic diagram of a text paragraph obtained using the text paragraph extraction scheme provided by the present invention; Figure 8(c) is a schematic diagram of a text paragraph extracted using the first related technology; Figure 8(d) is a schematic diagram of a text paragraph extracted using the second related technology; and Figure 8(e) is a schematic diagram of a text paragraph extracted using the third related technology. The areas circled in the figures are where the extracted text paragraphs differ from the original document. It can be seen that the text paragraphs obtained using the text paragraph extraction scheme provided by the present invention are almost identical to the original text, indicating that the text paragraph extraction scheme provided by the present invention is superior to the three related technologies.
[0151] Table 1 is a comparison table of index data for paragraph acquisition based on the text paragraph acquisition method and related technologies of this invention. During the evaluation process, recall, precision, and F1 score are used to assess accuracy. Recall, precision, and F1 score are common parameters used in machine learning for evaluating model performance; their formulas and meanings can be found in relevant descriptions in related technologies and will not be elaborated here.
[0152] Table 1
[0153] Indicator Name Recall rate Accuracy F1 score Results of the first related technology 80.61 98.06 88.40 Results of the second related technology 92.75 92.40 92.27 Results of the third related technology 96.76 86.87 91.55 Results of the embodiments of the present invention 97.16 98.90 98.02
[0154] As can be seen from Table 1, among the three evaluation indicators, the text paragraph acquisition method provided by the embodiments of the present invention has the best performance, proving that the text paragraph acquisition method provided by the embodiments of the present invention can improve the accuracy of text paragraph acquisition.
[0155] The text paragraph acquisition method of this invention will be described in detail below with specific examples.
[0156] Figure 9 This is a complete flowchart illustrating a specific example of a method for extracting text paragraphs from a script document. (Refer to...) Figure 9As shown, the method for obtaining this paragraph includes, but is not limited to, steps 1010, 1110 to 1150, 1210 to 1240, 1310 to 1320, and 1410 to 1430.
[0157] Step 1010: Obtain the PDF document to be processed.
[0158] Step 1110: Obtain the image of the document to be processed.
[0159] In this step, an image of the document to be processed is generated based on the PDF document to be processed.
[0160] Step 1120: Input the document image to be processed into the paragraph detection model.
[0161] In this step, the image of the document to be processed is input into the paragraph detection model, which can obtain the paragraph coordinate information of the text paragraph. Figure 10 This example illustrates the process of obtaining training sample data for the paragraph detection model. Figure 10 As shown, the process of obtaining training sample data includes, but is not limited to, steps 1121 to 1126.
[0162] In step 1121, the script document is converted into a PDF document. Then, in step 1122, the PDF document is converted back into a document image, thus obtaining document image data. Next, in step 1123, OCR is used to extract text from the text paragraphs in the document image, obtaining text data. Then, the original text paragraph information from the script document is used to align the text data into paragraphs, i.e., step 1124. After paragraph alignment, in step 1125, the paragraph coordinates of the text paragraphs are generated, thus obtaining paragraph coordinate data. In step 1126, training sample data is generated using the document image data and the paragraph coordinate data.
[0163] The training samples for the paragraph detection model were derived from 1259 open-source TV drama scripts, totaling 52330 episodes of text files. By performing PDF conversion, image generation, OCR text conversion, and paragraph coordinate alignment on these data, the ground truth for paragraph detection data was finally generated, comprising 620,000 images and 15.69 million text paragraph targets.
[0164] Step 1130: Obtain the paragraph detection results of the document image to be processed.
[0165] In this step, the paragraph detection model can generate paragraph coordinate information corresponding to the text paragraphs.
[0166] Step 1140: OCR recognition of paragraph text.
[0167] In this step, based on the paragraph coordinate information corresponding to the text paragraph generated in step 1130, the corresponding text paragraph image can be extracted, and then the paragraph text information can be obtained by using OCR technology to recognize the paragraph text.
[0168] Step 1150: Obtain paragraph information.
[0169] In this step, paragraph information is obtained based on the paragraph coordinate information obtained in step 1130 and the paragraph text information obtained in step 1140.
[0170] Step 1210: Obtain the text to be processed.
[0171] In this step, a text conversion method is used to directly extract text from the PDF document to obtain the text to be processed, which consists of text lines.
[0172] Step 1220: Obtain the text line content classification.
[0173] In this step, the first preset regular expression is used to perform regular expression matching on the characters in the text line to obtain the content classification results. The content classification results include two main categories: determined content classification results and undetermined content classification results, as shown in the figure. The determined content classification results include the opening, description, and dialogue.
[0174] It's important to note that a scene introduction is the opening shot of a film or a scene, used to clearly establish the location. It's usually a wide-angle shot. Sometimes, the scene introduction and the coverage shot are the same, aiming to establish the relationship between all characters and space in the scene. Therefore, a scene introduction often contains fixed information, such as the scene number, setting, atmosphere, and characters. A monologue is the dialogue between characters in the play; therefore, it begins with a colon (:). Descriptions are descriptions of the environment or scenes in the script, or descriptions of characters' expressions and actions, sometimes marked with special symbols such as triangles (△).
[0175] Therefore, based on the aforementioned characteristics of the script text, a first regular expression can be constructed to match the content of the text lines. By pre-setting characters such as ":", "△", and "scene number" in the first regular expression, the classification of the text line content can be achieved.
[0176] It should be noted that different types of scripts contain different categories of content; this example only uses the opening scene, description, and dialogue as examples.
[0177] Step 1230: Obtain the classification of text line paragraph completion status.
[0178] In this step, the completion status is first determined. The content classification result for the current text line is obtained, along with the content classification result for the next text line. These two results are then compared. If the comparison result shows a discrepancy between the current and next text lines, it indicates that the two text lines belong to different content categories, and therefore likely to different paragraphs. This means the next text line has started a new paragraph, and the current text line is considered a paragraph-completed text line. The classification result for a text line that is definitively a paragraph-completed text line is the determined paragraph completion status classification result. Conversely, if the comparison result shows a match between the current and next text lines, the two text lines may belong to the same or different paragraphs. In this case, the paragraph completion status classification result for the current text line cannot be definitively determined, and is therefore considered an undetermined paragraph completion status classification result. Since the paragraph completion status classification result is still undetermined, further judgment is required. The determination of paragraph completion status can also be aided by regular expressions. The matching results of regular expressions can be used to help determine the paragraph completion status. Therefore, a second regular expression can be preset to represent the characters to be matched. Then, the second regular expression can be used to perform regular expression matching on the characters in the text line.
[0179] Based on the general rules of natural language, when a text line is not a complete text line, it will exhibit certain patterns, such as the presence of commas, humble expressions, honorifics, or personal pronouns. For example, if the text line describes "I want to tell you a secret, but you can't tell anyone else this secret, the secret is," the presence of a comma and the personal pronoun "I" will likely lead to the judgment that this text line is incomplete. Based on these patterns, the second regular expression can pre-define punctuation, humble expression, honorific, and personal pronoun libraries.
[0180] Understandably, when a character in a text line successfully matches the second regular expression, the paragraph completion status classification yields a definite paragraph completion status classification result, which is defined as a determined paragraph completion status classification result. For text lines that do not successfully match the second regular expression, their corresponding paragraph completion status classification result is an indeterminate paragraph completion status classification result. For text lines whose paragraph completion status classification result is still uncertain, further judgment is required.
[0181] Step 1240: Update the undetermined classification results using the text line classification network model.
[0182] For text lines that failed to be classified according to the preset rules in step 1230, the text line classification network model in this step can be used to further determine the classification result. The text line classification network model in this step is a pre-trained model. The training samples of the model come from 100 randomly sampled scripts. Then, 20 scenes of text data are sampled from each script. Based on the classification result judgment method in steps 1220 and 1230, these data are classified by content and paragraph completion status. Then, manual annotation is used for correction, thus obtaining the training sample data of the text line classification network model.
[0183] After training the text line classification network model using the aforementioned training sample data, a text line classification network model with satisfactory prediction accuracy can be obtained. The pre-trained text line classification network model is then used to determine the classification result.
[0184] Step 1310: Update paragraph information.
[0185] In this step, the paragraph information is updated using the text to be processed obtained in step 1210. The update mainly corrects two aspects of information: paragraph coordinate information and paragraph text information.
[0186] Step 1320: Update the undetermined classification results using the updated paragraph information.
[0187] In this step, the classification results for text lines whose classification results were still undetermined in step 1240 are corrected and reassigned using updated paragraph information. In step 1240, the paragraph completion status classification result predicted by the text line classification network model for a certain text line was "incomplete," with a classification confidence score of 0.3, which is lower than the preset confidence threshold of 0.7. Therefore, the prediction result for this text line in step 1240 is unreliable, and it is corrected using updated paragraph information. Specifically, the paragraph information corresponding to this text line is found, and it is discovered that the corresponding paragraph information includes paragraph separators, meaning that this text line is already the last line of a paragraph in the corresponding image information. Therefore, in this step, the paragraph completion status classification result of this text line is corrected from "incomplete" to "complete." It should be noted that text lines whose classification status remains uncertain after steps 1220, 1230, and 1240 are rare cases. In practice, such text lines with uncertain classification results are often the middle lines of a long paragraph. For example, character A speaks a long dialogue to character B, occupying three lines in the script document. This dialogue begins with a colon (:), so the first line can be clearly identified as dialogue. Furthermore, the presence of commas or humble expressions in the first line easily indicates that the paragraph is incomplete. However, the second line, lacking characters matching the first regular expression and belonging to the same category as the first line, makes it difficult to determine its paragraph completion status. Inputting it into the text line classification network model yields a low confidence level in the prediction results. Therefore, in such cases, it is necessary to update the paragraph completion status of text lines with uncertain classification results using updated paragraph information. Observation reveals that because these text lines are the middle lines of a relatively long paragraph, their content classification results are often consistent with those of the previous line. Therefore, in this step, assigning the content classification result of the previous text line to this text line corrects and assigns the classification result. This method yields highly accurate text line classification results.
[0188] Step 1410: Obtain the text line content category and paragraph completion status category.
[0189] Step 1420: Aggregate consecutive text lines belonging to the same content category.
[0190] In this step, based on the classification of text line content and the classification of text line paragraph completion status, aggregating text lines of the same content category with an incomplete paragraph completion status will yield a text paragraph. Then, aggregating the next text line of the last text line of this text paragraph into this text paragraph will yield the desired text paragraph.
[0191] Step 1430: Obtain the text paragraph.
[0192] The following examples illustrate the application scenarios of the embodiments of the present invention.
[0193] Scene 1
[0194] The text paragraph acquisition method provided in this embodiment of the invention can be applied to script casting. Figure 11 This is a user interface diagram of a script management system that can be used for casting. (Example) Figure 11 As shown, the text paragraphs of the script document after text segment acquisition are displayed in the text segment display area 210. In the text segment display area 210, you can see the opening sequence, description, and dialogue for this scene. The lower right area is the annotation information display area 220. In the annotation information display area 220, you can select the type of annotation information, and the corresponding type of information will be selected in the text segment display area 210. For example, if you select to display character information in the annotation information display area 220, then the character names corresponding to the character information will be selected in the text segment display area 210.
[0195] To provide script document materials for the aforementioned script management system, a large number of script documents need to be collected. These documents come in various formats. If the original documents from the authors can be obtained directly, the text information can be read and displayed directly. However, some script documents, due to their age or unknown authors, can only be obtained as scanned files or PDFs. Scanned files or PDFs cannot support the reading and recognition of specific text. In this case, it is necessary to first read the text paragraphs from these scanned files or PDFs, then display the text paragraphs in the text paragraph display area 210, and finally recognize and display the annotation information corresponding to the user-specified annotation information type.
[0196] When the user selects "role" as the type of annotation information, the user can quickly see which roles are involved in the scene from the annotation information display area 220, thus allowing for advance planning of the actors' performance times. Simultaneously, based on the reading and recognition of text within the paragraphs, the user can also obtain the age and gender information corresponding to each role. This allows for the early screening of actors who can play these roles, improving the efficiency of script casting.
[0197] Scene 2
[0198] The text paragraph acquisition method provided in this invention can be applied to film set props and scene layout. Using this method, text paragraphs can be read from scanned documents or PDF documents, and then the corresponding information can be obtained based on user needs.
[0199] like Figure 11 As shown, when the user selects "props" as the type of annotation information, the user can quickly learn from the annotation information display area 220 which props are needed for the scene, thus allowing for advance preparation. When the user selects "scenes" as the type of annotation information, the user can quickly learn from the annotation information display area 220 which scenes are involved in the scene. Furthermore, scenes and props can be matched together, allowing for the preparation of corresponding props in advance during script shooting. This not only improves the efficiency of prop and scene setup on set but also allows for the identification of which episodes or scenes require the same or similar scenes and props, enabling the reuse of scenes and props.
[0200] Reference Figure 12 This invention also discloses a text paragraph acquisition device 1200, which can implement the text paragraph acquisition method as described in the previous embodiments. The text paragraph acquisition device 1200 includes:
[0201] The target acquisition unit 1201 is used to acquire the document to be processed, the text to be processed, and the image of the document to be processed corresponding to the document to be processed.
[0202] The paragraph information acquisition unit 1202 is used to obtain the paragraph information of the document to be processed based on the image of the document to be processed;
[0203] The paragraph information update unit 1203 is used to update the paragraph information according to the text to be processed, so as to obtain the updated paragraph information;
[0204] The text line classification unit 1204 is used to classify the text lines in the text to be processed to obtain classification results; wherein, the classification results include undetermined classification results and determined classification results;
[0205] The classification result update unit 1205 is used to update the undetermined classification results based on the updated paragraph information to obtain the classification update results;
[0206] The text paragraph acquisition unit 1206 is used to aggregate the text lines in the text to be processed based on the determined classification results and the classification update results to obtain the target text paragraph.
[0207] In one embodiment, the paragraph information includes paragraph coordinate information and paragraph text information, and the paragraph information updating unit 1203 is further configured to:
[0208] Obtain the text line position information and text line content of the text to be processed;
[0209] Based on the text line position information, the paragraph coordinate information is aligned to obtain the aligned paragraph coordinate information;
[0210] Based on the content of the text lines, the paragraph text information is corrected to obtain the corrected paragraph text information;
[0211] The aligned paragraph coordinates and the corrected paragraph text information are used to determine the updated paragraph information.
[0212] In one embodiment, the text line classification unit 1204 is further configured to:
[0213] The text lines in the text to be processed are classified into content categories to obtain content classification results, which include determined content classification results and undetermined content classification results.
[0214] The text lines in the text to be processed are classified according to their paragraph completion status to obtain the paragraph completion status classification results. The paragraph completion status classification results include the paragraph completion status classification results that have been determined and the paragraph completion status classification results that have not been determined.
[0215] The determined content classification results and the determined paragraph completion status classification results are designated as determined classification results, and the undetermined content classification results and the undetermined paragraph completion status classification results are designated as undetermined classification results.
[0216] In one embodiment, the classification update result includes the paragraph completion status classification update result and the content classification update result. The classification result update unit 1205 is further used for:
[0217] The text lines corresponding to the undetermined paragraph completion status classification results are identified as the text lines to be updated.
[0218] Based on the text line to be updated and the updated paragraph information, obtain the target paragraph information corresponding to the text line to be updated;
[0219] The classification results of the undetermined paragraph completion status are updated based on the target paragraph information to obtain the paragraph completion status classification update results;
[0220] Get the determined content category result corresponding to the previous text line of the text line to be updated;
[0221] Based on the determined content classification result corresponding to the previous text line, update the content classification result corresponding to the text line to be updated to obtain the updated content classification result.
[0222] In one embodiment, the text line classification unit 1204 is further configured to:
[0223] The text lines whose classification results are not yet determined are identified as text lines to be classified.
[0224] The text line to be classified is concatenated with the associated text line to obtain the text information to be classified. The associated text line is the context text line of the text line to be classified within a preset range.
[0225] The text information to be classified is input into a pre-trained text line classification network model to perform text line classification prediction, and the target paragraph completion status classification result and status classification confidence of the text line to be classified are obtained.
[0226] When the confidence level of the status classification is lower than the preset confidence threshold, the classification result of the target paragraph completion status is determined as the classification result of the undetermined paragraph completion status.
[0227] In one embodiment, the text line classification unit 1204 is further configured to:
[0228] Get the preset first regular expression;
[0229] Based on the first regular expression, regular expression matching is performed on the characters in the text line to obtain the content classification result.
[0230] In one embodiment, the text line classification unit 1204 is further configured to:
[0231] Get the content classification result for the current text line and the content classification result for the next text line;
[0232] The content classification result corresponding to the current text line is compared with the content classification result corresponding to the next text line to obtain the comparison result;
[0233] If the comparison result shows that the content classification result of the current text line is inconsistent with the content classification result of the next text line, the paragraph completion status classification result of the current text line is determined to be a determined paragraph completion status classification result; or, if the comparison result shows that the content classification result of the current text line is consistent with the content classification result of the next text line, the paragraph completion status classification result of the current text line is determined to be an undetermined paragraph completion status classification result.
[0234] In one embodiment, when the comparison result shows that the content classification result corresponding to the current text line is consistent with the content classification result corresponding to the next text line, the text line classification unit 1204 is further configured to:
[0235] Get the preset second regular expression;
[0236] Based on the second regular expression, perform regular expression matching on the characters in the next line of text to obtain the regular expression matching result;
[0237] If the regular expression matching result is that the character in the next text line matches the second regular expression, the paragraph completion status classification result corresponding to the current text line is determined to be a determined paragraph completion status classification result; or, if the regular expression matching result is that the character in the next text line does not match the second regular expression, the paragraph completion status classification result corresponding to the current text line is determined to be an undetermined paragraph completion status classification result.
[0238] In one embodiment, the text paragraph acquisition unit 1206 is further configured to:
[0239] Obtain a pre-trained document paragraph detection model;
[0240] The document image to be processed is input into the document paragraph detection model to detect paragraph positions and obtain paragraph information.
[0241] In one embodiment, the text paragraph acquisition unit 1206 is further configured to:
[0242] Obtain training samples and training labels;
[0243] The training samples are input into the document paragraph detection model to detect paragraph positions, and the classification loss value, target center loss value and regression loss value are obtained.
[0244] The parameters of the document paragraph detection model are adjusted based on the classification loss value, target center loss value, regression loss value, and training labels.
[0245] In one embodiment, the text paragraph acquisition unit 1206 is further configured to:
[0246] Assign line numbers to all lines of text in the text to be processed;
[0247] Retrieve all target line numbers from all line numbers, where the target line number is the line number corresponding to the text line whose paragraph completion status classification result is a completion status result;
[0248] Aggregate the text lines between two adjacent target line numbers to obtain the intermediate text paragraph;
[0249] The text lines corresponding to the target line number with the larger line number value adjacent to the intermediate text paragraph are aggregated with the intermediate text paragraph to obtain the target text paragraph.
[0250] It should be noted that since the text paragraph acquisition device 1200 of this embodiment can implement the text paragraph acquisition method of the previous embodiment, the text paragraph acquisition device 1200 of this embodiment and the text paragraph acquisition method of the previous embodiment have the same technical principle and the same beneficial effect. In order to avoid repetition, it will not be described again here.
[0251] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.
[0252] Reference Figure 13 The present invention also discloses a text paragraph acquisition device, the text paragraph acquisition device 1300 comprising:
[0253] At least one processor 1301;
[0254] At least one memory 1302 is used to store at least one program;
[0255] When at least one program is executed by at least one processor 1301, the text paragraph acquisition method as described in any of the preceding embodiments is implemented.
[0256] This invention also discloses a computer-readable storage medium storing a processor-executable program, which, when executed by a processor, is used to implement the text paragraph acquisition method as described in any of the preceding embodiments.
[0257] This invention also discloses a computer program product, including a computer program or computer instructions, which are stored in a computer-readable storage medium. A processor of a computer device reads the computer program or computer instructions from the computer-readable storage medium and executes the computer program or computer instructions, causing the computer device to perform the text paragraph acquisition method as described in any of the preceding embodiments.
[0258] The terms “first,” “second,” “third,” “fourth,” etc. (if present) in the specification and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that embodiments of the invention described herein can be implemented, for example, in orders other than those illustrated or described herein. Furthermore, the terms “comprising” and “having,” and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatuses.
[0259] It should be understood that in this invention, "at least one (item)" refers to one or more, and "more than one" refers to two or more. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, "A and / or B" can represent three cases: only A exists, only B exists, and both A and B exist simultaneously, where A and B can be singular or plural. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship. "At least one (item) of the following" or similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one (item) of a, b, or c can represent: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, and c can be single or multiple.
[0260] In the several embodiments provided by this invention, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the couplings or direct couplings or communication connections shown or discussed may be indirect couplings or communication connections through some interfaces, apparatuses, or units, and may be electrical, mechanical, or other forms.
[0261] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0262] Furthermore, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0263] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0264] The step numbers in the above method embodiments are set only for ease of explanation and do not limit the order of the steps. The execution order of each step in the embodiments can be adaptively adjusted according to the understanding of those skilled in the art.
Claims
1. A method for obtaining text paragraphs, characterized in that, Includes the following steps: Get the document to be processed; Based on the document to be processed, obtain the text to be processed and the corresponding image of the document to be processed; The paragraph information of the document to be processed is obtained from the image of the document to be processed, and the paragraph information includes paragraph coordinate information and paragraph text information; Obtain the text line position information and text line content of the text to be processed; align the paragraph coordinate information according to the text line position information to obtain aligned paragraph coordinate information; correct the paragraph text information according to the text line content to obtain corrected paragraph text information. The aligned paragraph coordinate information and the corrected paragraph text information are determined as the updated paragraph information; The text lines in the text to be processed are classified according to their content to obtain content classification results, wherein the content classification results include determined content classification results and undetermined content classification results; the text lines in the text to be processed are classified according to their paragraph completion status to obtain paragraph completion status classification results, wherein the paragraph completion status classification results include determined paragraph completion status classification results and undetermined paragraph completion status classification results; the determined content classification results and the determined paragraph completion status classification results are determined as the determined classification results, and the undetermined content classification results and the undetermined paragraph completion status classification results are determined as the undetermined classification results; The undetermined classification result is updated based on the updated paragraph information to obtain the classification update result; Based on the determined classification result and the classification update result, the text lines in the text to be processed are aggregated to obtain the target text paragraph.
2. The text paragraph acquisition method according to claim 1, characterized in that, The classification update results include paragraph completion status classification update results and content classification update results; The step of updating the undetermined classification result based on the updated paragraph information to obtain the classification update result includes: The text lines corresponding to the classification results of the undetermined paragraph completion status are identified as the text lines to be updated. Based on the text line to be updated and the updated paragraph information, the target paragraph information corresponding to the text line to be updated is obtained; The classification result of the undetermined paragraph completion status is updated based on the target paragraph information to obtain the paragraph completion status classification update result; Obtain the determined content classification result corresponding to the previous text line of the text line to be updated; Based on the determined content classification result corresponding to the previous text line, the content classification result corresponding to the text line to be updated is updated to obtain the content classification update result.
3. The text paragraph acquisition method according to claim 1, characterized in that, After classifying the paragraph completion status of the text lines in the text to be processed and obtaining the paragraph completion status classification results, the process further includes: The text lines corresponding to the undetermined classification results are identified as text lines to be classified. The text line to be classified is concatenated with the associated text line to obtain the text information to be classified, wherein the associated text line is the context text line of the text line to be classified within a preset range; The text information to be classified is input into a pre-trained text line classification network model to perform text line classification prediction, and the target paragraph completion status classification result and status classification confidence of the text line to be classified are obtained. When the confidence level of the state classification is lower than the preset confidence threshold, the classification result of the target paragraph completion status is determined as the classification result of the undetermined paragraph completion status.
4. The text paragraph acquisition method according to claim 1, characterized in that, The step of classifying the text lines in the text to be processed to obtain the content classification result includes: Get the preset first regular expression; Based on the first regular expression, regular expression matching is performed on the characters in the text line to obtain the content classification result.
5. The text paragraph acquisition method according to claim 1, characterized in that, The step of classifying the paragraph completion status of text lines in the text to be processed to obtain the paragraph completion status classification result includes: Get the content classification result for the current text line and the content classification result for the next text line; The content classification result corresponding to the current text line is compared with the content classification result corresponding to the next text line to obtain a comparison result; If the comparison result is inconsistent between the content classification result corresponding to the current text line and the content classification result corresponding to the next text line, the paragraph completion status classification result corresponding to the current text line is determined to be a determined paragraph completion status classification result; or, if the comparison result is consistent between the content classification result corresponding to the current text line and the content classification result corresponding to the next text line, the paragraph completion status classification result corresponding to the current text line is determined to be an undetermined paragraph completion status classification result.
6. The text paragraph acquisition method according to claim 5, characterized in that, When the comparison result is consistent with the content classification result corresponding to the current text line and the content classification result corresponding to the next text line, the step of classifying the text lines in the text to be processed into paragraph completion status to obtain the paragraph completion status classification result further includes: Get the preset second regular expression; Based on the second regular expression, perform regular expression matching on the characters in the next text line to obtain the regular expression matching result; If the regular expression matching result is that the character in the next text line matches the second regular expression, the paragraph completion status classification result corresponding to the current text line is determined to be a determined paragraph completion status classification result; or, if the regular expression matching result is that the character in the next text line does not match the second regular expression, the paragraph completion status classification result corresponding to the current text line is determined to be an undetermined paragraph completion status classification result.
7. The text paragraph acquisition method according to claim 1, characterized in that, The step of obtaining paragraph information of the document to be processed based on the image of the document to be processed includes: Obtain a pre-trained document paragraph detection model; The document image to be processed is input into the document paragraph detection model to detect paragraph positions and obtain paragraph information.
8. The text paragraph acquisition method according to claim 7, characterized in that, The document paragraph detection model is trained through the following steps: Obtain training samples and training labels; The training samples are input into the document paragraph detection model to detect paragraph positions, and the classification loss value, target center loss value and regression loss value are obtained. The parameters of the document paragraph detection model are adjusted based on the classification loss value, the target center loss value, the regression loss value, and the training labels.
9. The text paragraph acquisition method according to claim 1, characterized in that, The step of aggregating text lines in the text to be processed based on the determined classification result and the classification update result to obtain the target text paragraph includes: Assign line numbers to all lines of text in the text to be processed; Obtain all target line numbers from all the line numbers, wherein the target line number is the line number corresponding to the text line whose paragraph completion status classification result is a completion status result; The text lines between two adjacent target line numbers are aggregated to obtain the intermediate text paragraph; The text line corresponding to the target line number with the larger line number value adjacent to the intermediate text paragraph is aggregated with the intermediate text paragraph to obtain the target text paragraph.
10. A text paragraph acquisition device, characterized in that, include: The target acquisition unit is used to acquire the document to be processed, the text to be processed, and the image of the document to be processed corresponding to the document to be processed. A paragraph information acquisition unit is used to obtain paragraph information of the document to be processed based on the image of the document to be processed. The paragraph information includes paragraph coordinate information and paragraph text information. The paragraph information update unit is used to obtain the text line position information and text line content of the text to be processed; align the paragraph coordinate information according to the text line position information to obtain aligned paragraph coordinate information; correct the paragraph text information according to the text line content to obtain corrected paragraph text information; and determine the aligned paragraph coordinate information and the corrected paragraph text information as the updated paragraph information. A text line classification unit is used to classify the text lines in the text to be processed, obtaining content classification results, wherein the content classification results include determined content classification results and undetermined content classification results; to classify the text lines in the text to be processed by paragraph completion status, obtaining paragraph completion status classification results, wherein the paragraph completion status classification results include determined paragraph completion status classification results and undetermined paragraph completion status classification results; the determined content classification results and the determined paragraph completion status classification results are determined as the determined classification results, and the undetermined content classification results and the undetermined paragraph completion status classification results are determined as the undetermined classification results; The classification result update unit is used to update the undetermined classification result based on the updated paragraph information to obtain the classification update result; The text paragraph acquisition unit is used to aggregate the text lines in the text to be processed according to the determined classification result and the classification update result to obtain the target text paragraph.
11. A text paragraph acquisition device, characterized in that, include: At least one processor; At least one memory for storing at least one program; The text paragraph acquisition method as described in any one of claims 1 to 9 is implemented when at least one of the programs is executed by at least one of the processors.
12. A computer-readable storage medium, characterized in that, It contains a processor-executable program, which, when executed by a processor, is used to implement the text paragraph acquisition method as described in any one of claims 1 to 9.
13. A computer program product, comprising a computer program or computer instructions, characterized in that, The computer program or the computer instructions are stored in a computer-readable storage medium. The processor of the computer device reads the computer program or the computer instructions from the computer-readable storage medium and executes the computer program or the computer instructions, causing the computer device to perform the text paragraph acquisition method as described in any one of claims 1 to 9.