Text recognition method and device, electronic equipment, and storage medium
By constructing a text semantic extraction method based on BERT and EDC sub-models, and combining multi-task collaborative learning and rule correction dictionary, the problem of low accuracy and efficiency in identifying regional information in news texts was solved, achieving efficient and accurate regional information extraction.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- CHINA MOBILE (SUZHOU) SOFTWARE TECH CO LTD
- Filing Date
- 2021-06-24
- Publication Date
- 2026-05-22
AI Technical Summary
Existing information extraction methods suffer from problems such as missing information, long processing time, regional completion errors, and inaccurate identification of multi-regional information when processing long texts, especially in news texts, resulting in low information extraction accuracy.
A text semantic extraction model is constructed using BERT and EDC sub-models. By extracting semantic features from local text information and optimizing the global model of the conditional random field, combined with multi-task collaborative learning and a rule correction dictionary, the model can accurately identify and complete regional information.
It improved the accuracy of identifying regional information in news texts, reduced information loss, and improved identification efficiency. Furthermore, it corrected regional completion errors through multi-task collaborative learning and rule correction.
Smart Images

Figure CN115526176B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of natural language processing technology, and in particular to a text recognition method and apparatus, electronic device, and storage medium. Background Technology
[0002] Natural Language Processing (NLP) is a subfield of artificial intelligence. Among the many research directions in NLP, Information Extraction (IE) has always been a popular research topic. Information extraction refers to identifying and extracting information such as time and location from a text. This allows for timely monitoring of relevant events (mainly negative events), enabling timely public opinion monitoring and user alerts, which is crucial for both governments and businesses.
[0003] Currently, most commonly used models for information extraction are based on Long Short-Term Memory (LSTM), such as the Bilstm-CRF and Bert-Bilstm-CRF models. These models truncate or extract summary information from long texts to reduce the length of the model's input, and then extract information based on sequence labeling models. However, because truncating or extracting summary information from long texts can lead to information loss, the extracted information is relatively one-sided, affecting the accuracy of information extraction. Summary of the Invention
[0004] In view of this, embodiments of this application provide a text recognition method, apparatus, device, and storage medium.
[0005] This application provides a text recognition method, the method comprising:
[0006] Obtain the text to be recognized;
[0007] By using a text semantic extraction model, multiple local text information and semantic features between the multiple local text information are extracted from the text to be identified, and a text semantic vector is obtained.
[0008] The semantic vector of the text is processed to obtain the target text in the text to be identified.
[0009] Based on the above embodiments, this application also provides a text recognition device, which includes: an acquisition module, an extraction module, and a recognition module, wherein...
[0010] The acquisition module is used to acquire the text to be recognized;
[0011] The extraction module is used to extract multiple local text information and semantic features of the multiple local text information from the text to be identified through a text semantic extraction model, so as to obtain a text semantic vector.
[0012] The recognition module is used to perform recognition processing on the text semantic vector to obtain the target text in the text to be recognized.
[0013] Based on the above embodiments, this application also provides an electronic device, which includes a processor and a memory for storing a computer program capable of running on the processor;
[0014] When the processor runs the computer program, it executes the steps of the method described in the above embodiments.
[0015] Based on the above embodiments, this application also provides a computer-readable storage medium storing a computer program thereon, the computer program being executed by a processor to implement the steps of the method described in the above embodiments.
[0016] The text recognition method provided in this application involves acquiring the text to be recognized; using a text semantic extraction model to extract multiple local text information and semantic features between these local text information to obtain a text semantic vector; and performing recognition processing on the text semantic vector to obtain the target text within the text to be recognized. Thus, by constructing a text semantic extraction model, the contextual relationships of the truncated text to be recognized are made more coherent, avoiding information loss caused by long text truncation or extraction of summary information, and improving the accuracy of information extraction. Attached Figure Description
[0017] Figure 1 A flowchart illustrating a text recognition method provided in an embodiment of this application;
[0018] Figure 2 A flowchart illustrating another text recognition method provided in an embodiment of this application;
[0019] Figure 3 This is a schematic diagram of the structure of a BERT sub-model in a text recognition method provided in an embodiment of this application;
[0020] Figure 4 This is a schematic diagram of the structure of the EDC sub-model in a text recognition method provided in an embodiment of this application;
[0021] Figure 5 A flowchart illustrating multi-task collaborative learning in a text recognition method provided in this application embodiment;
[0022] Figure 6This is a schematic diagram of the structure of a text recognition device provided in an embodiment of this application;
[0023] Figure 7 A schematic diagram of the electronic device provided in the embodiments of this application. Detailed Implementation
[0024] In order to gain a more detailed understanding of the features and technical content of the embodiments of this application, the implementation of the embodiments of this application will be described in detail below with reference to the accompanying drawings. The accompanying drawings are for reference and illustration only and are not intended to limit the embodiments of this application.
[0025] Unless otherwise defined, all technical and scientific terms used in the embodiments of this application have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used in the embodiments of this application is for the purpose of describing the embodiments of this application only and is not intended to limit this application.
[0026] As is well known, information extraction (IE) has always been a popular research topic among the many research directions in Natural Language Processing (NLP). Location extraction is a fundamental task of information extraction, aiming to extract relevant geographical information about the occurrence of events from textual information. It has become an indispensable step in many NLP applications.
[0027] This application aims to identify place name information from news texts and determine the location of corresponding events, thereby accurately identifying the location of news events. By identifying the geographical information of events based on news texts, the location of events (mainly negative events) can be promptly ascertained, facilitating effective public opinion monitoring.
[0028] Most of the recognition methods proposed in related technologies are based on Long Short-Term Memory (LSTM), such as the Bilstm-CRF model and the Bert-Bilstm-CRF model. Their drawback is that the longer the news text, the longer the time required for sequential decoding. Therefore, how to quickly extract relevant regional information from long texts is a major problem currently faced by these proposed recognition methods. Furthermore, since the regional information appearing in news texts may be incomplete—for example, "Jieshou" could refer to "Jieshou Town, Yangzhou City, Jiangsu Province" or "Jieshou City, Fuyang City, Anhui Province"—accurate regional completion is the second problem faced by news regional extraction tasks. Finally, there may be multiple pieces of regional information extracted from news texts; how to determine the relevant regional information from these multiple pieces of information is the third problem faced by regional extraction tasks.
[0029] To address the above problems, the related technologies currently generally have the following solutions:
[0030] Regarding the problem of how to quickly extract the regional information related to news events from long texts, the commonly used methods in related technologies are such as the Bilstm-CRF model and the Bert-Bilstm-CRF model. The principle is to adopt corresponding strategies to reduce the length of the model input. For example, long texts are intercepted or summary information is extracted from long news texts, and then regional information is extracted based on the sequence labeling model. Its disadvantage is that the truncation or summary method of long news texts will cause the loss of regional information in the news text, resulting in relatively one-sided regional information obtained finally. At the same time, due to the particularity of LSTM, the entire model can only be serialized during training and prediction, and cannot be accelerated in parallel. Coupled with finally selecting the global optimal solution based on CRF, the overall time consumption of the model is relatively long.
[0031] Regarding the problem of how to perform regional completion, the commonly used implementation methods in related technologies currently are all to introduce an external regional dictionary and perform regional completion based on the maximum matching algorithm (Maximum Matching) or other algorithms. Its disadvantage is that the regional completion method introduced based on the external regional dictionary is simple and crude. When a certain regional word appears multiple times in the provinces, cities, counties, and streets involved in the external regional dictionary, it is easy to have the situation of incorrect regional completion. For example, "Zhongshan Road" is completed as "Zhongshan City, Guangdong Province", and "Wenquan" is completed as "Wenquan County, Bortala Prefecture, Xinjiang Uygur Autonomous Region", etc. Although the above regional completion methods can perform regional completion, they introduce the problem of incorrect regional completion.
[0032] Regarding the problem of how to extract the regional information related to news events from multiple regional information, the common and simple method in related technologies currently is to directly calculate the frequency of occurrence of the regional word in the news text, and directly use the regional word with a higher frequency of occurrence in the news text as the main regional word of the event. Its disadvantage is that when introducing the problem of how to quickly extract the regional information related to news events from long texts, it has been stated that the commonly used method currently is to intercept long texts or extract summary information from long news texts. This method damages the word frequency information of regional words in the news text to a certain extent. In addition, the main regional word should be an optimal result under the comprehensive consideration of various factors, while this method ignores other information related to the main regional word, such as location information. Generally, the probability of the main regional word appearing in the front of the news text is relatively large. Therefore, this method of determining the main regional word is simple and crude and prone to misjudgment.
[0033] To solve the above problems existing in the related technologies, the embodiments of the present application provide a text recognition method, as Figure 1 shown, this method may include the following steps:
[0034] S101. Obtain the text to be recognized.
[0035] Here, the text to be recognized can be the preprocessed version of the input text. Correspondingly, before obtaining the text to be recognized, the input text needs to be preprocessed. The input text can be news text, microblog text, blog text, user comments, etc., obtained directly from the internet. After preprocessing the input text, redundant spaces and / or distracting fields are removed, and part-of-speech tagging is performed on the input text after removing redundant spaces and / or distracting fields. The resulting text to be recognized can then be directly input into the model for information extraction.
[0036] S102. Using a text semantic extraction model, extract multiple local text information and semantic features from the text to be identified, and obtain a text semantic vector.
[0037] Here, after obtaining the text to be recognized, it needs to be encoded to enhance its contextual relationships. First, a text semantic extraction model is used to extract multiple local textual information and their corresponding semantic features from the text to enhance its contextual relationships. Here, local textual information can be Chinese words and / or characters formed after part-of-speech tagging. The semantic features of local textual information can be the possible contextual relationships between adjacent Chinese words and / or characters. By tagging the text with parts of speech and extracting the contextual relationships between the tagged Chinese words and characters, a text semantic vector containing rich semantic information can be obtained. Then, by performing recognition processing on this text semantic vector, the target text can be extracted from the text to be recognized.
[0038] It should be noted that part-of-speech tagging can be performed using either the BIO or BIOES mode. In BIO mode, B stands for Begin, indicating the start of the tagged word; I stands for Inside, indicating the interior of the tagged word; and O stands for Outside, indicating the exterior of the tagged word. In BIOES mode, B stands for Begin, indicating the start of the tagged word; I stands for Inside, indicating the interior of the tagged word; O stands for Outside, indicating the exterior of the tagged word; E stands for End, indicating the end of the tagged word; and S stands for Singleton, indicating a single-character word.
[0039] S103. Perform recognition processing on the text semantic vector to obtain the target text in the text to be recognized.
[0040] Here, after obtaining the text semantic vectors containing rich semantic features, it is necessary to perform recognition processing on the text semantic vectors. This recognition processing uses a conditional random field model for global optimization, considering the adjacency relationships between different labels in the labeled text semantic vectors, extracting the category features of the text semantic vectors, thereby obtaining the optimal prediction results, and then extracting the target text from the text to be recognized.
[0041] Therefore, the text recognition method provided in this application obtains the text to be recognized; utilizes a text semantic extraction model to extract multiple local text information and semantic features between these local text information to obtain a text semantic vector; and performs recognition processing on the text semantic vector to obtain the target text in the text to be recognized. Thus, by constructing a text semantic extraction model, the contextual relationships of the truncated text to be recognized are made closer, avoiding information loss caused by truncating long texts or extracting summary information from long texts, thereby improving the accuracy of recognition.
[0042] Based on the above embodiments, the text semantic extraction model in S102 may include: a Bidirectional Encoder Representations from Transformers (BERT) sub-model and an Enhanced Dilated Convolution (EDC) sub-model;
[0043] Correspondingly, in S102, a text semantic extraction model is used to extract multiple local text information from the text to be identified, as well as the semantic features between these local text information, to obtain a text semantic vector. This can be achieved through the following steps:
[0044] S1021. Extract multiple local text information from the text to be identified, as well as the semantic features between multiple local text information, through the BERT sub-model to obtain a sequence vector containing semantic features.
[0045] S1022. Local semantic features are extracted from the sequence vector using the EDC sub-model to obtain the text semantic vector.
[0046] Here, text semantic extraction models can include: BERT sub-model and EDC sub-model.
[0047] It should be noted that by extracting multiple local text information from the text to be identified, as well as the semantic features between multiple local text information, through the BERT sub-model, a sequence vector with rich semantic features can be obtained. Then, the sequence vector is input into the EDC sub-model for local feature extraction, which can further obtain a text semantic vector with rich semantic features.
[0048] The BERT sub-model here is a pre-trained model that can be used for various tasks in the field of natural language processing, such as text classification, summarization, and machine translation. It can also be used to generate sequence vectors. Related techniques generally use Word2Vec to generate sequence vectors, but its drawback is that the generated sequence vectors are static and lack contextual information, resulting in identical sequence vector values for words in different texts. In contrast, the sequence vectors obtained through the BERT pre-trained model are dynamic, capable of generating different sequence vectors based on the contextual information of words in different texts. This overcomes the shortcomings of Word2Vec, resulting in sequence vectors with rich semantic features.
[0049] The EDC sub-model is an optimized version of the traditional dilated convolution model. By grouping network layers and performing convolution based on a continuously increasing dilation rate, it can further improve the problem of local information loss during model training.
[0050] Based on the above embodiments, in S1021, multiple local text information and semantic features between multiple local text information are extracted from the text to be identified through the BERT sub-model to obtain a sequence vector containing semantic features. This can be achieved through the following steps:
[0051] S1021a. Extract multiple local text information of the text to be identified through the BERT sub-model to obtain the text sequence;
[0052] S1021b: Randomly select a portion of words in the text sequence for semantic feature representation to obtain a semantic feature sequence;
[0053] S1021c: Extract features from the semantic feature sequence to obtain a sequence vector.
[0054] Specifically, firstly, the BERT sub-model extracts multiple local text information and semantic features between these local text information from the text to be recognized. Then, the BERT sub-model performs part-of-speech tagging on the text to be recognized. Here, part-of-speech tagging can be performed by setting a maximum sequence length according to the requirements of the BERT sub-model, and padding the input sequence according to this parameter to ensure that the lengths of the input and output sequences are consistent. After obtaining the text sequence through part-of-speech tagging, semantic feature representations are randomly applied to some words in the text sequence to obtain a semantic feature sequence. A classification tag is added to the beginning of the semantic feature sequence, and separator tags are added between sentences. The semantic feature sequence with the added classification and separator tags is then input into a bidirectional transformation network structure for feature extraction, resulting in a sequence vector containing rich semantic features. Next, the sequence vector containing rich semantic features is input into the self-attention module. The most important encoding unit is the self-attention module, which includes a multi-head attention mechanism. To prevent overfitting, the results from different self-attention modules obtained by the multi-head attention mechanism are concatenated to obtain the final output sequence vector.
[0055] It's important to note that the core of the BERT pre-trained model is the Transformer network structure. The Transformer models a text using a self-attention mechanism to achieve semantic enhancement. Furthermore, the Transformer expands the representation subspace of the attention units through a multi-head attention mechanism, thereby capturing semantic information from different aspects of the text. Here, the final output sequence vector is obtained by concatenating the different attention results obtained from the multi-head attention mechanism. Finally, the Transformer improves the parameter degradation problem by introducing a residual neural network and normalization constraints. By extracting multiple local textual information from the text to be recognized through the BERT sub-model, a sequence vector with rich semantic features can be obtained. This sequence vector is then input into the EDC sub-model for local feature extraction, further yielding a text semantic vector with rich semantic features.
[0056] Based on the above embodiments, in S1022, local semantic features are extracted from the sequence vector using the EDC sub-model to obtain the text semantic vector, which can be achieved through the following steps:
[0057] S1022a. Extract features from the sequence vector using the EDC sub-model to obtain the target feature vector;
[0058] S1022b: Extract classification features from sequence vectors using an enhanced dilated convolutional submodel to obtain classification feature vectors;
[0059] S1022c: The target feature vector and the classification feature vector are concatenated to obtain the text semantic vector.
[0060] Specifically, the text recognition method proposed in this application has been optimized at both the model level and the post-processing level, further improving the recognition effect of target text in news texts. At the model level, based on the introduction of the EDC sub-model, a multi-task collaborative learning approach (introducing classification learning tasks for collaborative cooperation) is adopted, which greatly improves the speed and effect of target text recognition.
[0061] Here, we briefly explain the proposed multi-task collaborative learning approach. Its main idea is to divide the target extraction task and classification task into primary and secondary tasks. The feature vectors generated by the secondary tasks are used to enhance the feature vectors of the primary task. The feature vectors of the primary and secondary tasks share weights through a deep reuse layer. This deep reuse layer simultaneously incorporates the semantic vectors from both the target extraction and classification tasks to improve the extraction effect of the target text. Furthermore, the multi-task collaborative learning model can further improve the efficiency of the target extraction task. The classification task determines whether the target text exists within the text content, which is equivalent to a preliminary judgment on the presence or absence of the target text for the target extraction task.
[0062] It should be noted that the EDC sub-model is mainly designed to expand the receptive field of view. The main implementation method is to add a continuously increasing dilation rate on top of the classic dilated convolutional neural network. When performing convolution operations, the data in the middle of the dilation width is skipped, and the size of the convolution kernel remains unchanged. In this way, the same size convolution kernel can obtain a wider input matrix data, thus increasing the receptive field of the convolution kernel.
[0063] The EDC sub-model addresses the shortcomings of dilated convolutional neural networks in long text processing, namely their inability to learn long-term dependencies, thus improving recognition efficiency while maintaining recognition accuracy. Furthermore, to optimize the problems of local information loss and weak long-range information correlation in traditional dilated convolutional neural network models, a certain number of network layers are grouped and convolved based on a continuously increasing dilation rate. This allows for the acquisition of contextual information from a broader range, collecting more inconsistent local information and overcoming the limitations of traditional models.
[0064] By using the EDC sub-model, local semantic features are extracted from the sequence vectors output by the BERT sub-model, resulting in text semantic vectors with tighter contextual information. This leads to more accurate target text recognition by the CRF model. Simultaneously, during local feature extraction, a new learning task—predicting whether the news text contains the target text—is introduced. These two tasks are jointly learned, utilizing the syntactic and semantic information learned from binary classification to assist in target text extraction. Specifically, a deep shared neural network layer simultaneously acquires semantic vectors containing both extraction and classification tasks, sharing their weight information. This synergistic effect significantly improves the efficiency and effectiveness of target text recognition.
[0065] Based on the above embodiments, the text semantic vector recognition process in S103 to obtain the target text in the text to be recognized can be achieved through the following steps:
[0066] S1031. Predict the label sequence of the text semantic vector using the Conditional Random Fields (CRF) model to determine the predicted label sequence corresponding to the text to be identified.
[0067] S1032. Determine the target text based on the predicted label sequence.
[0068] Here, the target extraction task ultimately performs global optimization based on the CRF model, predicting the label sequence of the text semantic vector to determine the predicted label sequence corresponding to the text to be identified. By considering the adjacency relationship between labels (e.g., B-loc cannot be followed by E-loc, only I-loc, etc.), the globally optimal prediction result is obtained, and the target label in the prediction result is identified to obtain the target text.
[0069] Based on the above embodiments, determining the target text in S1032 based on the predicted label sequence can be achieved through the following steps:
[0070] S1032a. Score the predicted label sequence and take the predicted label sequence with the highest score as the output label sequence;
[0071] S1032b: Obtain the target label from the output label sequence to get the target text.
[0072] Here, the predicted label sequence can be filtered by scoring it. CRF calculates the score by mapping the text semantic vector to the predicted label sequence using a label transition score, and the sequence with the highest score is taken as the optimal predicted label sequence. After obtaining the scores of all predicted label sequences, the predicted label sequence with the highest score is taken as the output label sequence. Then, the target label in the output label sequence is identified, thus identifying the target text.
[0073] Based on the above embodiments, obtaining the text to be recognized in S101 can be achieved through the following steps:
[0074] S1011. Obtain the input text;
[0075] S1012. Perform preprocessing operations on the input text to obtain the text to be recognized; the preprocessing operations include: removing redundant spaces and / or interfering fields from the input text; and performing part-of-speech tagging on the input text after removing redundant spaces and / or interfering fields.
[0076] Here, the text to be identified can be obtained by preprocessing the acquired input text. Specifically, preprocessing can include text cleaning and text truncation. Text cleaning can include: replacing tabs / newline characters with spaces and removing redundant spaces, Uniform Resource Locators (URLs), and interfering fields (such as "Beijing Time") from the text. This is generally achieved through regularization. Text cleaning can also include: removing stop words based on a stop word list. Text truncation can be achieved by splitting the cleaned text into different tokens, generally through tokenization. Specifically, in this embodiment, after truncation, only the first 512 tokens are retained. Here, retaining only the first 512 tokens can cover 99% of the text containing entities, achieving the best results.
[0077] It can be seen that for the text recognition method provided by the embodiments of this application, by obtaining the text to be recognized, and using the BERT sub-model in the text semantic extraction model to extract multiple local text information from the text to be recognized, a sequence vector with rich semantic features can be obtained. Then, the sequence vector is input into the EDC sub-model for local feature extraction, and further a text semantic vector with rich semantic features can be obtained. Finally, the text semantic vector is recognized to obtain the target text in the text to be recognized. In this way, by constructing a text semantic extraction model including the BERT sub-model and the EDC sub-model, using the BERT sub-model to extract multiple local text information from the text to be recognized, a sequence vector with rich semantic features can be obtained. Then, the sequence vector is input into the EDC sub-model for local feature extraction, and further a text semantic vector with rich semantic features can be obtained, making the context relationship of the truncated text to be recognized closer, avoiding information loss caused by long text truncation or extracting summary information for long text, and improving the recognition accuracy. At the same time, when performing local feature extraction, by introducing a new learning task, that is, predicting whether there is a target text in the news text, and jointly learning these two tasks, using the syntactic and semantic information learned by binary classification to assist in extracting the target text of the news text, that is, through a deep shared neural network layer, obtaining semantic vectors including the extraction task and the classification task at the same time, sharing their weight information, and using the collaborative cooperation of the two, greatly improving the recognition efficiency and effect of the target text.
[0078] Based on the above embodiments, the method may further include the following steps:
[0079] S104. If there is information loss in the target text, perform a completion process on the target text based on a preset dictionary and a rule correction dictionary to obtain the target text after the completion process; the preset dictionary is used to store known similar texts of the same type as the target text; the rule correction dictionary is used to store the rule information corresponding to the similar texts.
[0080] Here, when performing completion based on the preset dictionary and the rule correction dictionary, the maximum matching algorithm is generally used for completion. For example, when the target text is "Zhongshan Road" and "Wenquan", when performing completion based on the maximum matching algorithm, "Zhongshan Road" may be completed as "Zhongshan City, Guangdong Province", and "Wenquan" may be completed as "Wenquan County, Bortala Prefecture, Xinjiang Uygur Autonomous Region", etc., resulting in completion errors. For the completion errors, the embodiments of this application correct the completion errors through the rule information pre-configured in the rule correction dictionary. It should be noted that the preset dictionary and the rule correction dictionary can be dynamically expanded.
[0081] Specifically, rules such as "Nanchang County: Nanchang County, Nanchang City, Jiangxi Province" can be directly added to the dictionary. Once "Nanchang County" appears in the model's prediction results, it will be automatically completed as "Nanchang County, Nanchang City, Jiangxi Province". The completion process is flexible and convenient, alleviating the completion error problem caused by the preset dictionary and the maximum matching method. In addition, the preset dictionary and the rule correction dictionary can be dynamically expanded in real time to further improve the accuracy of completion.
[0082] Based on the above embodiments, the method may include multiple target texts, and may further include the following steps:
[0083] S105. Determine the word frequency information and position information of each target text in multiple target texts; the word frequency information is used to represent the number of times the target text appears in the text to be identified; the position information is used to represent the position of the first appearance of the target text in the text to be identified;
[0084] S106. Determine the weight information of each target text based on word frequency information and location information;
[0085] S107. Based on the weight information, sort the multiple target texts to obtain the sorted target texts.
[0086] Here, after completion processing, there may be multiple target texts. It is necessary to determine the most suitable target text from these multiple texts. This is achieved through the following steps:
[0087] First, the word frequency and position information of each target text are calculated. The word frequency information represents the number of times the target text appears in the text to be identified. When calculating the position information, the position of the first occurrence of the target text is used as the position information.
[0088] Next, the word frequency information and position information are converted into weight information. For word frequency information, a non-linear transformation count / (count+1) is used to obtain word frequency weight information. For position information, prior knowledge is used, and prior knowledge considers the importance as: title (5) > beginning / end (3) > body (1) to obtain position weight information.
[0089] Specifically, word frequency information can be used as word frequency weight information after nonlinear transformation; while positional weight information is obtained by constructing a weight matrix. For example, if the weight of target text i is 5 and the weight of target text j is 3, then the weight matrix A = (a ij ) n×n Chinese: a ij =5 / 3, where n is the total number of target texts; by determining each target text, the weight corresponding to that target text can be determined; correspondingly, a can be determined. i1 a i2 …a ij …ain Similarly, we can determine the weight matrix A, find the principal eigenvector of matrix A, and the value of each dimension of the principal eigenvector is the position information of the target text.
[0090] Finally, the final result was calculated based on the weight information. Experimental results showed that importance (positional information) > importance (word frequency information), and multiple target texts were ranked according to the corresponding weight information.
[0091] Thus, in determining the most suitable target text during post-processing, in addition to utilizing the word frequency information of the target text, the positional information of the target text is further introduced, and a weight matrix is constructed by employing a "pairwise comparison method." Finally, the word frequency weight information and positional weight information of the target text are combined to effectively calculate the weights of all target texts, and they are ranked according to their importance. The target text with the highest importance is selected as the most suitable target text.
[0092] Here, a rule-based and statistical target text recognition method is introduced, simultaneously considering the impact of word frequency information and location information on target text recognition. The word frequency information of the target text is directly transformed into word frequency features through a nonlinear transformation, while the location weights are obtained by constructing a weight matrix using a "pairwise comparison method." Combining the word frequency features and location features leads to more effective target text recognition.
[0093] Therefore, the text recognition method provided in this application obtains the text to be recognized; utilizes a text semantic extraction model to extract multiple local text information and semantic features between these local text information to obtain a text semantic vector; and performs recognition processing on the text semantic vector to obtain the target text in the text to be recognized. Thus, by constructing a text semantic extraction model, the contextual relationships of the truncated text to be recognized are made closer, avoiding information loss caused by long text truncation or extracting summary information from long texts, thereby improving the accuracy of recognition. Simultaneously, during local feature extraction, a new learning task is introduced—predicting whether the news text contains the target text. These two tasks are jointly learned, and the syntactic and semantic information learned through binary classification assists in the extraction of the target text from the news text. That is, through a deep shared neural network layer, semantic vectors containing both the extraction and classification tasks are simultaneously obtained, sharing their weight information. The synergistic effect of these two tasks greatly improves the efficiency and effectiveness of target text recognition.
[0094] Based on the above embodiments, this application also provides a text recognition method, such as... Figure 2 As shown, the method includes:
[0095] S201. Obtain the input text, preprocess the input text to obtain the text to be recognized;
[0096] Here, the input text can be news text, microblog text, blog text, user comments, etc., obtained directly from the internet. The text to be recognized can be the text obtained after preprocessing the input text. Correspondingly, before obtaining the text to be recognized, the obtained input text needs to be preprocessed. Preprocessing can include text cleaning and text truncation. Text cleaning can include: replacing tabs / newline characters with spaces, removing redundant spaces from the text, removing Uniform Resource Locators (URLs) and interfering fields (such as "Beijing Time") from the text, etc. It is generally achieved through regular expressions (Normalization). Text cleaning can also include: removing stop words according to a stop word list. Text truncation can be the splitting of the cleaned text into different tokens, generally achieved through tokenization. Specifically, in this embodiment, after truncation, only the first 512 tokens are retained. After preprocessing the input text, the obtained text to be recognized can be directly input into the model for target text extraction.
[0097] S202. Extract multiple local text information from the text to be identified using the BERT sub-model to obtain the text sequence;
[0098] S203. Randomly select a portion of words in the text sequence for semantic feature representation to obtain a semantic feature sequence;
[0099] S204. Perform local feature extraction on the semantic feature sequence to obtain the sequence vector.
[0100] Here, the BERT sub-model is a pre-trained model that can be used for various tasks in the field of natural language processing, such as text classification, summarization, and machine translation. It can also be used to generate sequence vectors. Related techniques generally use Word2Vec to generate sequence vectors, but its shortcoming is that the generated sequence vectors are static and lack contextual information, resulting in the same value for each word in different texts. In contrast, the sequence vectors obtained through the BERT pre-trained model are dynamic, capable of generating different sequence vectors based on the contextual information of words in different texts. This overcomes the shortcomings of Word2Vec, resulting in sequence vectors with rich semantic features.
[0101] Specifically, firstly, multiple local text information from the text to be recognized is extracted using a BERT sub-model. This extraction can be achieved by setting a maximum sequence length according to the requirements of the BERT sub-model and padding the input sequence to ensure consistency between the input and output sequences. Next, a text sequence is obtained through part-of-speech tagging, and then semantic features are randomly applied to some words in the text sequence to obtain a semantic feature sequence. A classification marker is added to the beginning of the semantic feature sequence, and separator markers are added between sentences. The semantic feature sequence with the added classification and separator markers is then input into a bidirectional transformation network structure for feature extraction, resulting in a sequence vector rich in semantic features. Finally, the sequence vector rich in semantic features is input into a self-attention module, which includes a multi-head attention mechanism. To prevent overfitting, the results from different self-attention modules obtained by the multi-head attention mechanism are concatenated to obtain the final output sequence vector.
[0102] It should be noted that the core of the BERT pre-trained model is the Transformer structure, whose internal structure is as follows: Figure 3 As shown, the Transformer models a piece of text using a self-attention mechanism to achieve semantic enhancement. The calculation method is as follows:
[0103]
[0104] Where Attention(·) is the normalized value of the Attention score of the sequence vector, Q, K, and V represent the query vector, key vector, and value vector, respectively, and d k Let Q represent the dimension of the key vector, and let Q, K, and T represent the relationships between the input sequence vectors. Through the above calculation method, the representation of each word contains contextual information.
[0105] Furthermore, the Transformer expands the representation subspace of attention units through a multi-head attention mechanism, thereby capturing semantic information from different aspects. Here, the final output sequence vector is obtained by concatenating the different attention results obtained from the multi-head attention mechanism, and the calculation method is as follows:
[0106] MultiHead(Q,K,V)=Concat(head1,...,head k W O (2-2)
[0107] head i =Attention(QW i Q ,KW iK VW i V (2-3)
[0108] Where MultiHead(·) is the final output sequence vector, head h Let W be the Attention value obtained from the h-th projection, where h is the number of projections. o For the additional weight matrix, Concat(·) concatenates the vectors, W i Q To train the weight matrix W for the Q vector i K To train the weight matrix W for the K vectors i V The weight matrix is trained for vector V.
[0109] Finally, Transformer improves the parameter degradation problem by introducing residual neural networks and normalization constraints. The specific calculation method is shown below:
[0110]
[0111] FFN=max(0,xW1+b1)W2+b2 (2-5)
[0112] Here, α and β are the parameters that need to be learned, and μ and σ represent the mean and variance of the input layer.
[0113] It should be noted that by extracting multiple local text information from the text to be identified through the BERT sub-model, a sequence vector with rich semantic features can be obtained. Then, by inputting the sequence vector into the EDC sub-model for local feature extraction, a text semantic vector with rich semantic features can be obtained.
[0114] S205. Extract features from the sequence vector using the EDC sub-model to obtain the target feature vector.
[0115] S206. Extract classification features from the sequence vector using the EDC sub-model to obtain the classification feature vector.
[0116] S207. The target feature vector and the classification feature vector are concatenated to obtain the text semantic vector.
[0117] Here, the EDC sub-model is briefly explained, such as Figure 4As shown, the EDC sub-model is mainly designed to expand the receptive field of view. The main implementation method is to add a continuously increasing dilation rate on top of the classic dilated convolutional neural network. When performing convolution operations, the data in the middle of the dilation width is skipped, and the size of the convolution kernel remains unchanged. In this way, the same size convolution kernel can obtain a wider input matrix data, thus increasing the receptive field of the convolution kernel.
[0118] The EDC sub-model addresses the shortcomings of dilated convolutional neural networks (DCNNs) in long text processing, namely their inability to learn long-term dependencies, thus improving recognition efficiency while maintaining recognition accuracy. Furthermore, to optimize the issues of local information loss and weak long-range information correlation in traditional DCNN models, a certain number of network layers are grouped and convolved with continuously increasing dilation rates. This allows for the acquisition of contextual information from a broader range, gathering more inconsistent local information and overcoming the limitations of traditional models.
[0119] Specifically, the text recognition method proposed in this application has been optimized at both the model level and the post-processing level, further improving the recognition effect of target text in news texts. At the model level, based on the introduction of the EDC sub-model, a multi-task collaborative learning approach (introducing classification learning tasks for collaborative cooperation) is adopted, which greatly improves the speed and effect of target text recognition.
[0120] Here, we briefly explain the proposed multi-task collaborative learning approach. Its main idea is to divide the target extraction task and classification task into primary and secondary tasks, respectively. The feature vectors generated by the secondary tasks are used to enhance the feature vectors of the primary task. The feature vectors of the primary and secondary tasks share weights through a deep reuse layer. This deep reuse layer simultaneously incorporates the semantic vectors from both the target extraction and classification tasks to improve the extraction effect of the target text. Furthermore, the multi-task collaborative learning model can further improve the efficiency of the target extraction task. The classification task determines whether the target text exists within the text content, which is equivalent to a preliminary judgment on the presence or absence of the target text for the target extraction task. The specific implementation process is as follows: Figure 5 As shown.
[0121] First, we define the target extraction task as the primary task and the classification task as the secondary task. The calculation methods for the output vectors of the primary and secondary tasks are as follows:
[0122] h main =Bert-EDC main (T input (2-6)
[0123] h aux =Bert-EDC aux (Tinput (2-7)
[0124] Among them, h main The main task output vector represents the text vector representation generated after the main task input text is encoded by the Bert-EDC model. aux The auxiliary task output vector represents the vector representation of the auxiliary task input text after it has been encoded by the Bert-EDC model. It should be noted that the main task input text and the auxiliary task input text in the above formula are the same, both being T. input .
[0125] Next, the main task output vector h main and auxiliary task output vector h aux The connection is made through a hidden layer, and the calculation method is as follows:
[0126]
[0127] in, This represents the vector output of the hidden layer. This indicates a vector concatenation operation.
[0128] Finally, the loss function for the entire model is defined as a weighted linear fusion of the main task loss function and the auxiliary task loss function:
[0129] loss All =l(loss main )+(1-λ)(loss aux (2-9)
[0130] In the above formula, λ is the weight parameter, and loss main The loss function for the main task, loss aux The loss function is used for the auxiliary task. The entire model uses the Root Mean Square Propagation (RMSprop) algorithm as the optimization function. All matrix and vector parameters in the entire model are based on... The parameters within the range are initialized, where parameters r and c represent the rows and columns of the matrix, respectively.
[0131] By using the EDC sub-model, local semantic features are extracted from the sequence vectors output by the BERT sub-model, resulting in text semantic vectors with tighter contextual information. This leads to more accurate target text recognition by the CRF model. Simultaneously, during local feature extraction, a new learning task—predicting whether the news text contains the target text—is introduced. These two tasks are jointly learned, utilizing the syntactic and semantic information learned from binary classification to assist in target text extraction. Specifically, a deep shared neural network layer simultaneously acquires semantic vectors containing both extraction and classification tasks, sharing their weight information. This synergistic effect significantly improves the efficiency and effectiveness of target text recognition.
[0132] S208. Predict the label sequence of the text semantic vector using the CRF model to determine the predicted label sequence corresponding to the text to be identified.
[0133] S209. Score the predicted label sequence and take the predicted label sequence with the highest score as the output label sequence.
[0134] S210. Obtain the target label from the output label sequence to get the target text.
[0135] Here, the target extraction task ultimately performs global optimization based on the CRF model, predicting the label sequence of the text semantic vector, extracting the category features of the text semantic vector, and determining the predicted label sequence corresponding to the text to be identified. The globally optimal prediction result is obtained by considering the adjacency relationship between labels (e.g., B-loc cannot be followed by E-loc, only I-loc, etc.). Assume the given text semantic vector is x = (x1, x2, x3, ..., x...). n The labels corresponding to the text semantic vectors are y = (y1, y2, y3, ..., y4). n After local feature extraction by the EDC sub-model, the final result is calculated as follows:
[0136] p i =W s h (t) +b s (2-10)
[0137] Where p i h represents the score of the i-th label corresponding to the text semantic vector. (t) W represents the output vector of the EDC sub-model at time t. s Indicates the label transfer score, b s This indicates the bias amount.
[0138] Based on the predicted label sequences described above, further filtering is needed to obtain the optimal sequence. This filtering can be achieved by scoring the predicted label sequences. CRF calculates the score by mapping the text semantic vector to the predicted label sequence using a label transition score. The sequence with the highest score is taken as the optimal predicted label sequence. The calculation method is as follows:
[0139]
[0140] Where W represents the transformation matrix, W i,j Indicates the label transfer score. This indicates the y-th character. i The score of each label.
[0141] W minimizes the error between the predicted label sequence and the true label sequence based on the maximum conditional likelihood estimation method, and is calculated as follows:
[0142]
[0143]
[0144] Where L represents the loss function, a represents the logarithmic base used, λ is the optimization parameter, θ is the distribution parameter, and P is the probability of the original sequence corresponding to the predicted sequence.
[0145] After obtaining the scores of all predicted label sequences, the predicted label sequence with the highest score is taken as the output label sequence. Then, the target label in the output label sequence is identified, thus identifying the target text.
[0146] Therefore, the text recognition method provided in this application obtains the text to be recognized; utilizes a text semantic extraction model to extract multiple local text information and semantic features between these local text information to obtain a text semantic vector; and performs recognition processing on the text semantic vector to obtain the target text in the text to be recognized. Thus, by constructing a text semantic extraction model, the contextual relationships of the truncated text to be recognized are made closer, avoiding information loss caused by long text truncation or extracting summary information from long texts, thereby improving the accuracy of recognition. Simultaneously, during local feature extraction, a new learning task is introduced—predicting whether the news text contains the target text. These two tasks are jointly learned, and the syntactic and semantic information learned through binary classification assists in the extraction of the target text from the news text. That is, through a deep shared neural network layer, semantic vectors containing both the extraction and classification tasks are simultaneously obtained, sharing their weight information. The synergistic effect of these two tasks greatly improves the efficiency and effectiveness of target text recognition.
[0147] S211. If there is information missing in the target text, the target text is complemented based on a preset dictionary and a rule correction dictionary to obtain the complemented target text. The preset dictionary is used to store known similar texts of the same type as the target text. The rule correction dictionary is used to store the rule information corresponding to the similar texts.
[0148] Here, when complementing based on the preset dictionary and the rule correction dictionary, the maximum matching algorithm is generally used for complementing. For example, when the target texts are "Zhongshan Road" and "Wenquan", when complementing based on the maximum matching algorithm, "Zhongshan Road" may be complemented to "Zhongshan City, Guangdong Province", and "Wenquan" may be complemented to "Wenquan County, Bortala Autonomous Prefecture, Xinjiang Uygur Autonomous Region", etc., resulting in complementing errors. For the complementing errors, the embodiments of the present application correct the complementing errors through the rule information preconfigured in the rule correction dictionary. It should be noted that the preset dictionary and the rule correction dictionary can be dynamically expanded.
[0149] Specifically, rules like "Nanchang County: Nanchang County, Nanchang City, Jiangxi Province" can be directly added to the dictionary. Once "Nanchang County" appears in the result predicted by the model, it is automatically complemented to "Nanchang County, Nanchang City, Jiangxi Province". The complementing process is flexible and convenient, alleviating the problem of complementing errors brought by the preset dictionary and the maximum matching method. In addition, the preset dictionary and the rule correction dictionary can be dynamically expanded in real time, further improving the accuracy of complementing.
[0150] S212. Determine the word frequency information and position information of each target text among the multiple target texts. The word frequency information is used to represent the number of times the target text appears in the text to be recognized. The position information is used to represent the position where the target text first appears in the text to be recognized.
[0151] S213. Determine the weight information of each target text based on the word frequency information and the position information.
[0152] S214. Sort the multiple target texts based on the weight information to obtain the sorted target text.
[0153] Here, after the complementing process, there may be multiple target texts, and the most suitable target text needs to be determined from the multiple target texts. This is mainly achieved through the following steps:
[0154] First, count the word frequency information and position information of each target text. The word frequency information is used to represent the number of times the target text appears in the text to be recognized. When counting the position information, the position where the target text first appears is used as the position information.
[0155] Next, word frequency information and position information are converted into weight information. For word frequency information, a non-linear transformation is used to obtain word frequency weight information. For position information, prior knowledge is used, and prior knowledge considers the importance as follows: title (5) > beginning / end of text (3) > body text (1) to obtain position weight information.
[0156] Specifically, word frequency information can be used as word frequency weight information after nonlinear transformation; while positional weight information is obtained by constructing a weight matrix. For example, if the weight of target text i is 5 and the weight of target text j is 3, then the weight matrix A = (a ij ) n×n Chinese: a ij =5 / 3, where n is the total number of target texts; by determining each target text, the weight corresponding to that target text can be determined; correspondingly, a can be determined. i1 a i2 …a ij …a in Similarly, we can determine the weight matrix A, find the principal eigenvector of matrix A, and the value of each dimension of the principal eigenvector is the position information of the target text.
[0157] Finally, the final result was calculated based on the weight information. Experimental results showed that importance (positional information) > importance (word frequency information), and multiple target texts were ranked according to the corresponding weight information.
[0158] Thus, in determining the most suitable target text during post-processing, in addition to utilizing the word frequency information of the target text, the positional information of the target text is further introduced, and a weight matrix is constructed by employing a "pairwise comparison method." Finally, the word frequency weight information and positional weight information of the target text are combined to effectively calculate the weights of all target texts, and they are ranked according to their importance. The target text with the highest importance is selected as the most suitable target text.
[0159] Here, a rule-based and statistical target text recognition method is introduced, simultaneously considering the impact of word frequency information and location information on target text recognition. The word frequency information of the target text is directly transformed into word frequency features through a nonlinear transformation, while the location weights are obtained by constructing a weight matrix using a "pairwise comparison method." Combining the word frequency features and location features leads to more effective target text recognition.
[0160] Therefore, the text recognition method provided in this application obtains the text to be recognized; utilizes a text semantic extraction model to extract multiple local text information and semantic features between these local text information to obtain a text semantic vector; and performs recognition processing on the text semantic vector to obtain the target text in the text to be recognized. Thus, by constructing a text semantic extraction model, the contextual relationships of the truncated text to be recognized are made closer, avoiding information loss caused by long text truncation or extracting summary information from long texts, thereby improving the accuracy of recognition. Simultaneously, during local feature extraction, a new learning task is introduced—predicting whether the news text contains the target text. These two tasks are jointly learned, and the syntactic and semantic information learned through binary classification assists in the extraction of the target text from the news text. That is, through a deep shared neural network layer, semantic vectors containing both the extraction and classification tasks are simultaneously obtained, sharing their weight information. The synergistic effect of these two tasks greatly improves the efficiency and effectiveness of target text recognition.
[0161] Based on the above embodiments, this application also provides a text recognition device 60, such as... Figure 6 As shown, the device 60 may include: an acquisition module 61, an extraction module 62, and an identification module 63, wherein,
[0162] Module 61 is used to acquire the text to be recognized;
[0163] Extraction module 62 is used to extract multiple local text information and semantic features of multiple local text information from the text to be identified through a text semantic extraction model, so as to obtain a text semantic vector;
[0164] The recognition module 63 is used to perform recognition processing on the text semantic vector to obtain the target text in the text to be recognized.
[0165] Based on the above embodiments, the text semantic extraction model may include: a bidirectional transformational coding representation sub-model and an enhanced dilated convolution sub-model;
[0166] The extraction module may further include: a first extraction submodule 621 and a second extraction submodule 622, wherein,
[0167] The first extraction submodule 621 is used to extract multiple local text information in the text to be identified, as well as the semantic features between the multiple local text information, through a bidirectional conversion coding representation submodel, to obtain a sequence vector containing semantic features;
[0168] The second extraction submodule 622 is used to extract local semantic features from the sequence vector using an enhanced dilated convolution submodel to obtain the text semantic vector.
[0169] Based on the above embodiments, the first extraction submodule 621 may further include: a first text extraction subunit 621a, a first feature representation subunit 621b, and a first feature extraction subunit 621c, wherein,
[0170] The first text extraction subunit 621a is used to extract the multiple local text information in the text to be identified through the bidirectional transformation coding representation submodel to obtain a text sequence;
[0171] The first feature representation subunit 621b is used to randomly select a portion of words in the text sequence for semantic feature representation to obtain a semantic feature sequence;
[0172] The first feature extraction subunit 621c is used to extract features from the semantic feature sequence to obtain the sequence vector.
[0173] Based on the above embodiments, the second extraction submodule 622 may further include: a second feature extraction subunit 622a, a classification feature extraction subunit 622b, and a splicing subunit 622c.
[0174] The second feature extraction subunit 622a is used to extract features from the sequence vector using the enhanced dilated convolution submodel to obtain the target feature vector;
[0175] The classification feature extraction subunit 622b is used to extract classification features from the sequence vector through the enhanced dilated convolution sub-model to obtain a classification feature vector;
[0176] The splicing subunit 622c is used to splice the target feature vector and the classification feature vector to obtain the text semantic vector.
[0177] Based on the above embodiments, the identification module 63 may further include: a prediction submodule 631, a scoring submodule 632, and an acquisition submodule 633, wherein,
[0178] The prediction submodule 631 is used to predict the label sequence of the text semantic vector using a conditional random field model to determine the predicted label sequence corresponding to the text to be identified; the conditional random field model is used to extract the category features of the text semantic vector.
[0179] The scoring submodule 632 is used to score the predicted label sequence and take the predicted label sequence with the highest score as the output label sequence.
[0180] The acquisition submodule 633 is used to acquire the target tag in the output tag sequence to obtain the target text.
[0181] Based on the above embodiments, the device 60 may further include: a completion module 64, used to complete the target text based on a preset dictionary and a rule correction dictionary if the target text has missing information, to obtain the completed target text; wherein, the preset dictionary is used to store known texts of the same type as the target text; and the rule correction dictionary is used to store rule information corresponding to the texts of the same type.
[0182] Based on the above embodiments, the device 60 may further include: a sorting module 65, configured to determine the word frequency information and position information of each target text among a plurality of target texts; the word frequency information is used to characterize the number of times the target text appears in the text to be identified; the position information is used to characterize the position of the first appearance of the target text in the text to be identified; the weight information of each target text is determined based on the word frequency information and the position information; and the plurality of target texts are sorted based on the weight information to obtain the sorted target text.
[0183] The descriptions of the above device embodiments are similar to those of the above method embodiments, and have similar beneficial effects. For technical details not disclosed in the device embodiments of this application, please refer to the descriptions of the method embodiments of this application for understanding.
[0184] Based on the above embodiments, this application also provides an electronic device corresponding to a database configuration method; Figure 7 This is a schematic diagram of the hardware composition structure of the electronic device according to an embodiment of this application, such as... Figure 7 As shown, the electronic device proposed in this application embodiment may include a processor 71 and a memory 72 storing processor-executable instructions;
[0185] The processor 71 and the memory 72 are connected via a bus 73;
[0186] When the processor 71 runs the computer program stored in the memory 72, it can execute the following instructions:
[0187] Obtain the text to be recognized;
[0188] By using a text semantic extraction model, multiple local text information and semantic features between the multiple local text information are extracted from the text to be identified, and a text semantic vector is obtained.
[0189] The semantic vector of the text is processed to obtain the target text in the text to be identified.
[0190] In the embodiments provided in this application, the processor 71 can be at least one of the following: Application-Specific Integrated Circuit (ASIC), Digital Signal Processor (DSP), Digital Signal Processing Device (DSPD), Programmable Logic Device (PLD), Field-Programmable Gate Array (FPGA), Central Processing Unit (CPU), and controller. It is understood that for different devices, the electronic device used to implement the above-mentioned processor function can also be other types, and the embodiments in this application do not specifically limit it.
[0191] In practical applications, memory 72 can be volatile memory, such as RAM; or non-volatile memory, such as ROM, flash memory, hard disk drive (HDD) or solid-state drive (SSD); or a combination of the above types of memory, and provide instructions and data to processor 71.
[0192] This application also provides a computer storage medium, specifically a computer-readable storage medium. Computer instructions are stored thereon. When the computer storage medium is located in an electronic device, these computer instructions, when executed by a processor, implement any step of the text recognition method described in this application.
[0193] The aforementioned computer storage media / memory can be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), magnetic random access memory (FRAM), flash memory, magnetic surface memory, optical disc, or compact disc read-only memory (CD-ROM), etc.; or it can be various terminals that include one or any combination of the above-mentioned memories, such as mobile phones, computers, tablet devices, personal digital assistants, etc.
[0194] It should be understood that the terms "an embodiment," "an embodiment," "an embodiment of this application," "the foregoing embodiments," or "some embodiments" mentioned throughout the specification mean that the target features, structures, or characteristics related to the embodiment are included in at least one embodiment of this application. Therefore, the phrases "an embodiment," "an embodiment," "an embodiment of this application," "the foregoing embodiments," or "some embodiments" appearing throughout the specification do not necessarily refer to the same embodiment. Furthermore, these target features, structures, or characteristics can be combined in any suitable manner in one or more embodiments. It should be understood that in the various embodiments of this application, the sequence numbers of the above-described processes do not imply a sequential order of execution; the execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application. The sequence numbers of the above-described embodiments of this application are merely descriptive and do not represent the superiority or inferiority of the embodiments.
[0195] Unless otherwise specified, any step in the embodiments of this application performed by the detection device may be executed by the processor of the detection device. Unless otherwise specified, the embodiments of this application do not limit the order in which the detection device performs the following steps. Furthermore, the methods used to process data in different embodiments may be the same or different methods. It should also be noted that any step in the embodiments of this application can be executed independently by the detection device; that is, when the detection device performs any step in the above embodiments, it may not depend on the execution of other steps.
[0196] In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are merely illustrative. For example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods, such as: multiple units or components can be combined, or integrated into another system, or some features can be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the various components shown or discussed can be through some interfaces, and the indirect coupling or communication connection between devices or units can be electrical, mechanical, or other forms.
[0197] The units described above as separate components may or may not be physically separate. The components shown as units may or may not be physical units. They may be located in one place or distributed across multiple network units. Some or all of the units may be selected to achieve the purpose of this embodiment according to actual needs.
[0198] In addition, each functional unit in the various embodiments of this application can be integrated into one processing unit, or each unit can be a separate unit, or two or more units can be integrated into one unit; the integrated unit can be implemented in hardware or in the form of hardware plus software functional units.
[0199] The methods disclosed in the several method embodiments provided in this application can be arbitrarily combined without conflict to obtain new method embodiments.
[0200] The features disclosed in the several product embodiments provided in this application can be arbitrarily combined without conflict to obtain new product embodiments.
[0201] The features disclosed in the several method or device embodiments provided in this application can be arbitrarily combined without conflict to obtain new method or device embodiments.
[0202] Those skilled in the art will understand that all or part of the steps of the above method embodiments can be implemented by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it performs the steps of the above method embodiments. The aforementioned storage medium includes various media that can store program code, such as mobile storage devices, read-only memory (ROM), magnetic disks, or optical disks.
[0203] Alternatively, if the integrated units described above are implemented as software functional units and sold or used as independent products, they can also be stored in a computer-readable storage medium. Based on this understanding, the technical solutions of the embodiments of this application, or the parts that contribute to related technologies, 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, testing equipment, or network device, etc.) to execute all or part of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as mobile storage devices, ROMs, magnetic disks, or optical disks.
[0204] In the embodiments of this application, descriptions of the same steps and content in different embodiments can be referred to each other. In the embodiments of this application, the term "and" does not affect the order of steps.
[0205] The above description is merely an embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A text recognition method, characterized in that, The method includes: Obtain the text to be recognized; The bidirectional transformation coding representation submodel extracts multiple local text information from the text to be identified, as well as the semantic features between the multiple local text information, to obtain a sequence vector containing semantic features; The sequence vector is subjected to local semantic feature extraction by an enhanced dilated convolutional model to obtain a text semantic vector; the text semantic vector is subjected to label sequence prediction by a conditional random field model to determine the predicted label sequence corresponding to the text to be identified. Based on the predicted label sequence, the target text in the text to be identified is determined.
2. The method according to claim 1, characterized in that, The step of extracting multiple local text information from the text to be identified, as well as the semantic features between the multiple local text information, through a bidirectional transformation coding representation sub-model to obtain a sequence vector containing semantic features includes: The multiple local text information in the text to be identified is extracted by a bidirectional transformation coding representation submodel to obtain a text sequence; Randomly select a portion of words from the text sequence for semantic feature representation to obtain a semantic feature sequence; Feature extraction is performed on the semantic feature sequence to obtain the sequence vector.
3. The method according to claim 1, characterized in that, The step of extracting local semantic features from the sequence vector using an enhanced dilated convolutional submodel to obtain the text semantic vector includes: The target feature vector is obtained by extracting features from the sequence vector using an enhanced dilated convolutional submodel. The enhanced dilated convolutional submodel is used to extract classification features from the sequence vector to obtain a classification feature vector; The target feature vector and the classification feature vector are concatenated to obtain the text semantic vector.
4. The method according to any one of claims 1-3, characterized in that, The step of determining the target text in the text to be identified based on the predicted label sequence includes: The predicted label sequences are scored, and the predicted label sequence with the highest score is taken as the output label sequence; Obtain the target label from the output label sequence to obtain the target text in the text to be identified.
5. The method according to any one of claims 1-3, characterized in that, The method further includes: If the target text has missing information, the target text is completed based on a preset dictionary and a rule correction dictionary to obtain the completed target text. The preset dictionary is used to store known texts of the same type as the target text; the rule correction dictionary is used to store rule information corresponding to the texts of the same type.
6. The method according to any one of claims 1-3, characterized in that, The number of target texts is multiple, and the method further includes: The word frequency information and position information of each target text in a plurality of target texts are determined; the word frequency information is used to characterize the number of times the target text appears in the text to be identified; the position information is used to characterize the position of the first appearance of the target text in the text to be identified; The weight information of each target text is determined based on the word frequency information and the location information; The multiple target texts are sorted based on the weight information to obtain the sorted target texts.
7. A text recognition device, characterized in that, The device includes: an acquisition module, an extraction module, and an identification module, wherein... The acquisition module is used to acquire the text to be recognized; The extraction module is used to extract multiple local text information from the text to be identified, as well as the semantic features between the multiple local text information, through a bidirectional transformation coding representation sub-model to obtain a sequence vector containing semantic features; and to extract local semantic features from the sequence vector through an enhanced dilated convolution sub-model to obtain a text semantic vector. The recognition module is used to predict the label sequence of the text semantic vector using a conditional random field model, and determine the predicted label sequence corresponding to the text to be recognized; based on the predicted label sequence, determine the target text in the text to be recognized.
8. An electronic device, characterized in that, The electronic device includes a processor and a memory for storing computer programs that can run on the processor; When the processor is used to run the computer program, it performs the steps of the method according to any one of claims 1 to 6.
9. A computer-readable storage medium having a computer program stored thereon, the computer program being executed by a processor to implement the steps of the method according to any one of claims 1 to 6.