Text extraction method and device, computer, storage medium and program product
Through the two-way long and short-term memory network-conditional random field model, the problem of low text data extraction efficiency in power field operations is solved, and more efficient key data extraction is achieved.
Patent Information
- Application Number
- CN202411311011.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-19
- Publication Date
- 2025-01-07
AI Technical Summary
The extraction efficiency of key data of large amounts of text data in power field operations is low, which brings difficulties to safety management.
The two-way long and short-term memory network-conditional random field model is used to extract the basic text data and label the text data with the highest probability output through the model.
It improves the efficiency of critical data extraction of large amounts of text data, and enhances the accuracy and reliability of data extraction.
Smart Images

Figure CN119272110A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of data extraction, and in particular to a text extraction method, device, computer, storage medium and program product. Background Art
[0002] As the volume of power grid business continues to increase, the number of power equipment, construction personnel, and text records is also increasing, which brings great difficulties to the safety management of on-site construction operations. How to effectively extract key data from a large amount of text data is an urgent problem to be solved in current power field operations. Summary of the invention
[0003] The embodiments of the present application provide a text extraction method, device, computer, storage medium and program product, which perform feature extraction and label processing on basic text data, and then input the data into a bidirectional long short-term memory network-conditional random field model to extract the text data with the highest probability of model output, thereby improving the efficiency of key data extraction from large amounts of text data.
[0004] In a first aspect, an embodiment of the present application provides a text extraction method, the method comprising:
[0005] Extract features from basic sample data to obtain multiple sample feature data;
[0006] Performing label processing on sample feature data of different categories among the multiple sample feature data to obtain multiple sample feature data labels;
[0007] Determine the output probability of different sample feature data labels among the multiple sample feature data labels according to the bidirectional long short-term memory network-conditional random field model;
[0008] Extract the text corresponding to the sample feature data label with the maximum output probability from the basic sample data.
[0009] In a second aspect, an embodiment of the present application provides a text extraction device, the device comprising:
[0010] A feature extraction module is used to extract features from basic sample data to obtain multiple sample feature data;
[0011] A label processing module, used to perform label processing on sample feature data of different categories in the plurality of sample feature data to obtain a plurality of sample feature data labels;
[0012] A determination module, used to determine the output probability of different sample feature data labels among the multiple sample feature data labels according to a bidirectional long short-term memory network-conditional random field model;
[0013] The text extraction module is used to extract the text corresponding to the sample feature data label with the maximum output probability in the basic sample data.
[0014] In a third aspect, an embodiment of the present application provides a computer, including:
[0015] A memory, a processor, and a text extraction program stored in the memory and executable on the processor, wherein the text extraction program is configured to implement part or all of the steps described in any method in the first aspect.
[0016] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, on which a text extraction program is stored. When the text extraction program is executed by a processor, some or all of the steps described in any method in the first aspect are implemented.
[0017] In a fifth aspect, an embodiment of the present application provides a computer program product, wherein the computer program product includes a computer program, and the computer program is operable to cause a computer to execute some or all of the steps described in any method of the first aspect of the embodiment of the present application. The computer program product can be a software installation package.
[0018] By implementing the embodiment of the present application, the server of the text extraction system first performs feature extraction on the basic sample data to obtain multiple sample feature data; then performs label processing on the sample feature data of different categories in the multiple sample feature data to obtain multiple sample feature data labels; then determines the output probability of different sample feature data labels in the multiple sample feature data labels according to the bidirectional long short-term memory network-conditional random field model; finally, extracts the text corresponding to the sample feature data label with the largest output probability in the basic sample data. By performing feature extraction and label processing on the basic text data, and then inputting the bidirectional long short-term memory network-conditional random field model, the text data with the highest output probability of the model is extracted, which is conducive to improving the efficiency of key data extraction for a large amount of text data. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the background technology, the drawings required for use in the embodiments of the present application or the background technology will be described below.
[0020] Figure 1 It is a schematic diagram of the architecture of a text extraction system provided in an embodiment of the present application;
[0021] Figure 2 is a flowchart of a text extraction method provided in an embodiment of the present application;
[0022] Figure 3It is a schematic diagram of the architecture of a bidirectional long short-term memory network-conditional random field model provided in an embodiment of the present application;
[0023] Figure 4 is a structural schematic diagram of a text extraction device provided in an embodiment of the present application;
[0024] Figure 5 It is a structural diagram of a computer provided in an embodiment of the present application. DETAILED DESCRIPTION
[0025] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. According to the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of this application.
[0026] The terms "first", "second", "third", etc. in the specification, claims and drawings of this application are used to distinguish different objects, rather than to describe a specific order. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but optionally includes steps or units that are not listed, or optionally includes other steps or units inherent to these processes, methods, products or devices.
[0027] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0028] As the volume of power grid business continues to increase, the number of power equipment, construction personnel, and text records is also increasing, which brings great difficulties to the safety management of on-site construction operations. How to effectively extract key data from a large amount of text data is an urgent problem to be solved in current power field operations.
[0029] In view of the above problems, the embodiments of the present application provide a text extraction method, device, equipment, storage medium and program product. The server of the text extraction system first performs feature extraction on the basic sample data to obtain multiple sample feature data; then performs label processing on the sample feature data of different categories in the multiple sample feature data to obtain multiple sample feature data labels; then determines the output probability of different sample feature data labels in the multiple sample feature data labels according to the bidirectional long short-term memory network-conditional random field model; finally, extracts the text corresponding to the sample feature data label with the largest output probability in the basic sample data. By performing feature extraction and label processing on the basic text data, and then inputting the bidirectional long short-term memory network-conditional random field model, the text data with the highest output probability of the model is extracted, which is conducive to improving the efficiency of key data extraction for a large amount of text data.
[0030] The text extraction method, apparatus, device, storage medium and program product provided in the embodiments of the present application can be applied to Figure 1 In the text extraction system shown in Figure 1 , Figure 1 1 is a schematic diagram of the architecture of a text extraction system provided in an embodiment of the present application. The text extraction system 100 includes a terminal 101 and a server 102. The terminal 101 can communicate with the server 102 through a network. The terminal 101 refers to a device used by a user, such as a smart phone, a computer, etc. In this solution, the terminal 101 provides an interface for the user to interact with the text extraction system 100. The terminal 101, as a user interface, is responsible for receiving the results returned from the server 102 and displaying them to the user or other systems. Through the terminal 101, the user can interact with the text extraction system 100, including inputting the original basic sample data, viewing the output results, etc. In addition, after the text extraction system 100 determines the output probability, the terminal 101 will extract the text corresponding to the sample feature data label corresponding to the maximum output probability from the basic sample data, and display it to the user.
[0031] Server 102 refers to a remote computer used to process a large number of computing tasks and store data. In this solution, server 102 is responsible for feature extraction of basic sample data and transmitting the processed multiple sample feature data to the terminal. Server 102 is also used to undertake model training tasks, using a bidirectional long short-term memory network-conditional random field (BiLSTM-CRF) model to label sample feature data of different categories and determine the output probability. It also saves the trained model parameters and performs reasoning operations when necessary, calculates the output probability based on the input sample feature data, and provides the final result. In addition, server 102 is responsible for storing and managing all relevant data to ensure the stability and security of the system.
[0032] Based on this, the present application provides a text extraction method, device, equipment, storage medium and program product, and the present application is described in detail below in conjunction with the accompanying drawings.
[0033] See also Figure 2 , Figure 2 is a flowchart of a text extraction method provided in an embodiment of the present application. Figure 2 As shown, the method comprises the following steps:
[0034] In a possible implementation, before extracting features from the basic sample data to obtain a plurality of sample feature data, the method further includes:
[0035] The collected sample data is preprocessed to obtain basic sample data, wherein the preprocessing includes removing characteristic characters, segmenting words, and removing stop words.
[0036] Among them, the full on-site data of a municipal power supply bureau in the past year can be selected as the basic sample data. The sample includes personnel files, construction plans, equipment ledger records, and work file data, and is efficiently integrated through the big data platform.
[0037] Specifically, the sample data collection includes: 1) obtaining basic text records of personnel files, including user file records such as user age, position, and years of work experience; 2) obtaining text records related to construction plans, such as data records of construction personnel, construction units, construction sites, etc.; 3) obtaining text data related to equipment ledger records, such as equipment number, equipment service life, equipment installation location, etc.; 4) obtaining operation text records, such as operation type, operation time, operation site, and other record data.
[0038] Among them, the collected sample data are all text data, and the preprocessing operations on the text data may include removing special characters, word segmentation, removing stop words, converting to lowercase, stemming or normalizing, removing numbers, cleaning HTML tags and special symbols, entity standardization, deleting extra blank symbols and spaces at the end of the line, and one or more of spelling error correction, among which spelling error correction refers to detecting and correcting common spelling errors in the text as needed, and the spelling error correction operation can be completed using an automatic error correction algorithm or a rule-based / statistical method.
[0039] Exemplarily, when preprocessing the collected sample data, first remove special characters in the text, such as punctuation marks, URL links, HTML tags, etc., then split the text into units of words or characters, divide long sentences into discrete words, and then remove common words without practical meaning and importance, such as "de", "le", "shi", etc. Usually, a predefined stop word list is used to filter these words. Finally, remove redundant whitespace characters such as spaces and tab characters in the text, and remove possible spaces or tab characters at the end of the line to obtain the basic sample data.
[0040] It can be seen that in this example, through the preprocessing operation, the text data can be converted into a unified format, which helps to clean the sample data, remove noise and interference information such as special characters, punctuation marks, and HTML tags, and contributes to improving the accuracy of subsequent processing and analysis.
[0041] S201, perform feature extraction on the basic sample data to obtain multiple sample feature data.
[0042] Among them, feature extraction refers to extracting discriminative, representative, and descriptive features from the original data for subsequent data analysis, pattern recognition, or machine learning tasks. Feature extraction techniques are used in many fields, such as computer vision, natural language processing, etc.
[0043] Specifically, feature extraction includes the following methods:
[0044] Statistical-based methods: including statistics such as mean, variance, and standard deviation, which can reflect the central tendency and dispersion degree of the data. Fourier transform: converts the signal to the frequency domain and can capture information on different frequency components. Wavelet transform: through multi-scale decomposition and reconstruction of the signal, better local information in time-frequency can be obtained. Principal component analysis (PCA): projects high-dimensional data into a low-dimensional space through linear transformation and retains the principal components with the largest variance to reduce the dimension. Independent component analysis (ICA): assumes that the observed signal is a linear mixture of mutually independent source signals and estimates the source signals without prior knowledge. Local binary pattern (LBP): used for image texture description, compares the gray values of pixels with the gray value of the central pixel in the local neighborhood, and generates binary coding to represent texture information. Convolutional neural network (CNN) feature extraction: uses structures such as convolutional layers and pooling layers to learn abstract features from images.
[0045] Exemplarily, use the bag of words model to perform feature extraction from text data. The bag of words model represents the text as a fixed-length vector, where each dimension represents a word, and the value in the vector represents the frequency or weight of the word's appearance in the text. The following are the steps for performing feature extraction using the bag of words model:
[0046] Collect a corpus: First, you need to build a corpus containing a large number of text samples, which can be news articles, social media posts, etc. Tokenization: For each document, split it into individual words or tokens. This can be done by separating them by spaces, using natural language processing tools (such as NLTK), or other tokenization techniques. Build a vocabulary: Build a vocabulary based on the unique words that appear in all documents. Removing stop words (such as "the", "and", etc.) and words that appear with low frequency can help improve feature quality. Feature encoding: For each document, count the frequency of each word in the document and map it to the corresponding position in the vector in a predefined order. Other encoding methods such as TF-IDF can be selected to weight certain importance. Normalization: Perform normalization operations on the generated feature vectors, such as L2 norm normalization, to ensure that different samples have similar scales.
[0047] S202, performing label processing on sample feature data of different categories in the plurality of sample feature data to obtain a plurality of sample feature data labels.
[0048] Among them, the method for labeling sample feature data in this scheme is the BIO method. In addition, the methods for labeling sample feature data can be the following: Label Encoding: Map each category label to an integer value, such as using 0, 1, 2, etc. to represent different categories. This encoding method is suitable for binary classification and multi-classification problems with order relationships. One-Hot Encoding: Convert each category label into a vector consisting of 0 and 1. Only one element at each position is 1, indicating that the current sample belongs to the category corresponding to the position. One-hot encoding is suitable for unordered classification problems. Tree-based Encoding: By constructing models such as decision trees or random forests, the category labels are converted into numerical features corresponding to their correlation quality measures. This method can capture the similarities and differences between different categories.
[0049] In a possible implementation, the performing label processing on the sample feature data of different categories in the plurality of sample feature data to obtain a plurality of sample feature data labels includes:
[0050] A target tag set is defined according to task requirements, wherein the target tag set includes labels corresponding to sample feature data of different categories; labels of the multiple sample feature data are determined according to the target tag set and the multiple sample feature data to obtain multiple sample feature data labels.
[0051] Among them, the target tag set defines the labels corresponding to sample feature data of different categories. For example, the label corresponding to the sample feature data of the person name category is PER (person), the label corresponding to the sample feature data of the place name type is LOC (location), and the label corresponding to the sample feature data of the organization name type is ORG (organization).
[0052] Exemplarily, the target tag set is defined as follows:
[0053] Person name (PER), place name (LOC), organization name (ORG), now there is a sample feature data as follows:
[0054] Original text: Zhang San and Li Si now work in Beijing. According to the target tag set and the BIO method, the label of the sample feature data is determined: Expected label: B-PER, O, B-PER, O, B-LOC, O. Specifically, Zhang San and Li Si are labeled as "B-PER", indicating that this is a person name entity and this is the beginning of the entity. And, now, in are both labeled as "O", indicating that they do not belong to any named entity. Beijing is labeled as "B-LOC", indicating that this is a place name and this is the beginning of the entity. Work is labeled as "O" because it also does not belong to any named entity.
[0055] It can be seen that in this example, by specifying corresponding labels for different categories of sample feature data, we can train the model to identify specific types of entities or other target objects, which is conducive to improving the efficiency of extracting key data from large amounts of text data.
[0056] In a possible implementation, before determining the output probabilities of different sample feature data labels among the multiple sample feature data labels according to the bidirectional long short-term memory network-conditional random field model, the method further includes:
[0057] Construct an initial network model including a bidirectional long short-term memory network layer and a conditional random field layer; initialize multiple parameters in the initial network model; obtain a predicted output probability based on a training data set and the initial network model; update multiple parameters in the initial network model based on the true output probability of the training data set, the predicted output probability and the target loss function to obtain a bidirectional long short-term memory network-conditional random field model.
[0058] Among them, before model training, the basic architecture of the network model is first constructed. The initial network model includes a bidirectional long short-term memory network layer (BiLSTM) and a conditional random field layer (CRF). Specifically, the bidirectional long short-term memory network layer is a variant of a recurrent neural network. By introducing LSTM units in both forward and backward directions in the model, context information can be captured and the entire input sequence can be modeled. The forward LSTM starts processing from the beginning of the sequence, while the backward LSTM starts processing from the end of the sequence. Global context information that is beneficial to the current tag prediction can be obtained at each time step. The conditional random field layer is a statistical modeling method used to label or classify sequence data. In the sequence labeling task, CRF can help solve the conversion problem between labels and improve the prediction accuracy through global constraints. The CRF layer calculates the probability distribution between different categories based on the feature representation output by BiLSTM, and uses a dynamic programming algorithm to find the optimal path as the final prediction result.
[0059] The specific process of model training is as follows: data preparation, divide the data set into training set and validation set. When dividing the training set and validation set, the training set and validation set can be obtained in a ratio of 3:1. The training set is used to learn model parameters, and the validation set is used to evaluate model performance and tune hyperparameters; initialize the network model, build an initial network model including BiLSTM and CRF layers, and initialize the parameters therein; forward propagation, for each sample feature data, calculate its predicted output probability in the BiLSTM-CRF model through the forward propagation algorithm; target loss calculation, use the true output probability and the predicted output probability and the target loss function to calculate the loss value; back propagation, use the back propagation algorithm to update multiple parameters in the initial network model according to the loss value; parameter tuning and performance evaluation, after each training cycle, use the validation set to evaluate the model and calculate the performance indicators. Select the best hyperparameter configuration or stop training early based on the performance on the validation set to avoid overfitting. Repeat the iterative steps until the set stop condition is reached (such as reaching the maximum number of iterations or the performance on the validation set is no longer improved); complete the model training and save the various parameters of the model training.
[0060] It can be seen that in this example, combining the bidirectional long short-term memory network layer and the conditional random field layer to build and train the network model is conducive to fully mining context information in the sequence labeling task and significantly improving the prediction accuracy. At the same time, by using the training data set and the target loss function to perform back propagation optimization on multiple parameters in the initial network model, the parameters can be gradually adjusted to minimize the loss function, so that the model can adapt to the task requirements and improve the model generalization ability.
[0061] S203, determining the output probabilities of different sample feature data labels among the multiple sample feature data labels according to the bidirectional long short-term memory network-conditional random field model.
[0062] In a possible implementation, determining the output probabilities of different sample feature data labels among the multiple sample feature data labels according to the bidirectional long short-term memory network-conditional random field model includes:
[0063] A first output is obtained based on the multiple sample feature data labels and the bidirectional long short-term memory network layer in the bidirectional long short-term memory network-conditional random field model; the first output is used as the input of the conditional random field layer in the bidirectional long short-term memory network-conditional random field model to obtain a second output, wherein the second output is the output probability of different sample feature data labels among the multiple sample feature data labels.
[0064] Among them, see Figure 3 , Figure 3 is a schematic diagram of the architecture of a bidirectional long short-term memory network-conditional random field model provided in an embodiment of the present application, such as Figure 3 As shown, the bidirectional long short-term memory network-conditional random field model includes a bidirectional long short-term memory network layer and a conditional random field layer. The bidirectional long short-term memory network layer includes a word embedding layer, a forward long short-term memory network layer, a backward long short-term memory network layer and a fully connected linear layer.
[0065] Wherein, obtaining a first output according to the plurality of sample feature data labels and the bidirectional long short-term memory network layer in the bidirectional long short-term memory network-conditional random field model includes:
[0066] Obtain a first product of a sample feature data label and a word embedding network, the first product being the output of the word embedding layer; obtain a first result of a forward long short-term memory network calculation on the first product and a hidden state at a previous time step, the first result being the output of the forward long short-term memory network layer; obtain a second result of a backward long short-term memory network calculation on the first product and a hidden state at a previous time step, the second result being the output of the backward long short-term memory network layer; obtain a second product of a first weight and the first result; obtain a third product of a second weight and the second result; obtain a first sum of the second product, the third product and a bias value, the first sum being the first output.
[0067] Specifically, the calculation formulas for each architecture layer are as follows:
[0068] Word Embedding Layer: x n = k*x;
[0069] Forward long short-term memory network layer: htf = LSTM (x n ,ht-1);
[0070] Backward long short-term memory network layer: htb = LSTM (x n ,ht-1);
[0071] Fully connected linear layer: yt = w1*htf+w2*htb+by;
[0072] Among them, x n It is based on the output of the word embedding layer, k is the word embedding layer network, x represents the word input, htf is the output result of the forward long short-term memory network layer, lstm() represents the network calculation of the forward long short-term memory network layer, ht-1 is the hidden state of the previous time step, htb is the output result of the backward long short-term memory network layer, yt is the output result of the bidirectional long short-term memory network, w1 is the first weight preset by the user, w2 is the second weight preset by the user, and by is the bias value.
[0073] It can be seen that in this example, by using multiple network layers, hidden states, and weight adjustment techniques, the model's ability to express input data can be enhanced, thereby improving prediction accuracy. At the same time, by multiplying the first result and the second result by the first weight and the second weight respectively, and adding the bias value, and comprehensively considering the bidirectional calculation results and the output of the additional weight adjustment, the model can determine the contribution of different features to the prediction probability.
[0074] In a possible implementation, the conditional random field layer includes a transmission probability function and a feature transfer function, and the first output is used as an input of the conditional random field layer in the bidirectional long short-term memory network-conditional random field model to obtain the second output, including:
[0075] A label probability calculation function is obtained according to the emission probability function and the feature transfer function; and a second output is obtained according to the first output and the label probability calculation function.
[0076] Specifically, the emission probability function is used to calculate the emission probability of the label corresponding to each time step under a given observation sequence. The transition feature function is used to calculate the transition feature score or transition probability between different labels between two adjacent time steps, indicating the possibility or correlation from one state to another.
[0077] For example,
[0078] Among them, the label probability calculation function is as follows:
[0079]
[0080] Among them, x is the word input, that is, the observation sequence input, and y is the output of the bidirectional long short-term memory network layer, that is, the emission probability of the corresponding label at each time step under a given observation sequence input.
[0081] Where Z(x) is defined as:
[0082] Z(x)=Σ y′ exp(score(x,y′));
[0083] The score function in the formula is as follows, where Emit corresponds to the emission probability and Trans corresponds to the transition probability:
[0084] score(x,y)=∑ i Emit(x i ,y i )+Trans(y i-1 ,y i );
[0085] Among them, x i Corresponding to the word input at the current time step, y i The output of the bidirectional long short-term memory network layer corresponding to the current time step, y i-1 The output of the bidirectional LSTM layer corresponding to the previous time step.
[0086] In one example, the loss function of the initial model when the maximum likelihood method is trained can be obtained according to the above multiple functions. The loss function is as follows:
[0087] -log p(y|x)=-score(x,y)+log Z(x);
[0088] S204: extracting text corresponding to the sample feature data label with the highest output probability from the basic sample data.
[0089] For example, the original text is Zhang San and Li Si now work in Beijing. According to the task requirements, each character or word can be used as basic sample data. The following basic sample data are obtained through word segmentation: ["Zhang San"], ["and"], ["Li Si"], ["now"], ["in"], ["Beijing"], ["work"]; label processing is performed using the training set, and each sample feature data is labeled ["B-PER"], ["O"], ["B-PER"], ["O"], ["O"], ["B-LOC"], ["O"] according to the existing name and place name information; the basic sample data is input into the bidirectional long short-term memory network-conditional random field model, and the model will calculate the output probability of different categories at each position. Output probability: [0.9, 0.1], [0.6, 0.4], [0.8, 0.2], [0.7, 0.3], [0.7, 0.3], [0.2, 0.8], [0.95, 0.05]. For the basic sample data at each position, when selecting the category corresponding to the maximum output probability, the corresponding text can be extracted. Extraction results: ["Zhang San"], [], ["Li Si"], [], ["Beijing"], [].
[0090] It can be seen that in this example, by performing feature extraction and label processing on the basic text data, and then inputting the bidirectional long short-term memory network-conditional random field model, the text data with the highest probability of model output is extracted, which is beneficial to improving the efficiency of key data extraction for large amounts of text data.
[0091] In a possible implementation, the method further includes:
[0092] After detecting that the text corresponding to the sample feature data label with the highest output probability is extracted from the basic sample data, a first prompt message is sent, wherein the first prompt message is used to inform the user that the text extraction is completed.
[0093] The first prompt information is sent to the user via email, text message, mobile application push notification, online platform message, and phone notification, and the first prompt information may be text information or graphic information.
[0094] The user may set the sending channel or method of the first prompt message in advance. For example, the user may set that when the text extraction is completed, the first prompt message is sent via SMS, and the first prompt message is a plain text message.
[0095] For example, suppose the user specifies in the settings that the mobile phone number to receive the text extraction completion prompt is X. Then, when the text extraction system detects the sample feature data label corresponding to the maximum output probability in the basic sample data, it can send the following plain text message as the first prompt information: "Hello! Text extraction is completed." This plain text message will be sent to the user via the mobile phone number X preset by the user. After receiving the message, the user will know that the text extraction task has been successfully completed, and can further view related results or perform other operations.
[0096] It can be seen that in this example, by sending detailed first prompt information to the user, the user can quickly obtain confirmation about the completion of the text extraction task. The user experience is enhanced through the real-time feedback mechanism.
[0097] See also Figure 4 , Figure 4 is a structural diagram of a text extraction device provided in an embodiment of the present application, such as Figure 4 As shown, the text extraction device 400 includes:
[0098] The feature extraction module 401 is used to extract features from the basic sample data to obtain a plurality of sample feature data;
[0099] The label processing module 402 is used to perform label processing on the sample feature data of different categories in the plurality of sample feature data to obtain a plurality of sample feature data labels;
[0100] A determination module 403 is used to determine the output probability of different sample feature data labels among the multiple sample feature data labels according to a bidirectional long short-term memory network-conditional random field model;
[0101] The text extraction module 404 is used to extract the text corresponding to the sample feature data label with the maximum output probability in the basic sample data.
[0102] In one possible implementation, in terms of labeling different categories of sample feature data among the multiple sample feature data, the label processing module 402 is specifically used to: define a target labeling set according to task requirements, wherein the target labeling set includes labels corresponding to different categories of sample feature data; determine labels of the multiple sample feature data according to the target labeling set and the multiple sample feature data, to obtain multiple sample feature data labels.
[0103] In one possible implementation, before determining the output probabilities of different sample feature data labels among the multiple sample feature data labels according to the bidirectional long short-term memory network-conditional random field model, the determination module 403 is also used to: construct an initial network model including a bidirectional long short-term memory network layer and a conditional random field layer; initialize multiple parameters in the initial network model; obtain predicted output probability according to the training data set and the initial network model; update multiple parameters in the initial network model according to the actual output probability of the training data set, the predicted output probability and the target loss function to obtain a bidirectional long short-term memory network-conditional random field model.
[0104] In one possible implementation, in terms of determining the output probabilities of different sample feature data labels among the multiple sample feature data labels according to the bidirectional long short-term memory network-conditional random field model, the determination module 403 is specifically used to: obtain a first output according to the multiple sample feature data labels and the bidirectional long short-term memory network layer in the bidirectional long short-term memory network-conditional random field model; use the first output as the input of the conditional random field layer in the bidirectional long short-term memory network-conditional random field model to obtain a second output, and the second output is the output probability of different sample feature data labels among the multiple sample feature data labels.
[0105] In a possible implementation, the bidirectional long short-term memory network layer includes a word embedding layer, a forward long short-term memory network layer, a backward long short-term memory network layer and a fully connected linear layer. In terms of obtaining a first output according to the multiple sample feature data labels and the bidirectional long short-term memory network layer in the bidirectional long short-term memory network-conditional random field model, the determination module 403 is specifically used to: obtain a first product of the sample feature data label and the word embedding network, the first product is the output of the word embedding layer; obtain a first result of performing a forward long short-term memory network calculation on the first product and the hidden state of the previous time step, the first result is the output of the forward long short-term memory network layer; obtain a second result of performing a backward long short-term memory network calculation on the first product and the hidden state of the previous time step, the second result is the output of the backward long short-term memory network layer; obtain a second product of a first weight and the first result; obtain a third product of a second weight and the second result; obtain a first sum of the second product, the third product and a bias value, the first sum being the first output.
[0106] In one possible implementation, the conditional random field layer includes a transmission probability function and a feature transfer function. In terms of using the first output as the input of the conditional random field layer in the bidirectional long short-term memory network-conditional random field model to obtain the second output, the determination module 403 is specifically used to: obtain a label probability calculation function based on the transmission probability function and the feature transfer function; and obtain the second output based on the first output and the label probability calculation function.
[0107] In a possible implementation, before extracting features from basic sample data, the feature extraction module 401 is further used to: perform preprocessing operations on the collected sample data to obtain basic sample data, wherein the preprocessing operations include removing feature characters, segmenting words, and removing stop words.
[0108] It is worth noting that the specific functional implementation of the text extraction device 400 is shown in the above Figure 1 The description of the text extraction method shown in the figure, for example, the feature extraction module 401 is used to implement the relevant content of executing S201, the label processing module 402 is used to implement the relevant content of executing S202, the determination module 403 is used to implement the relevant content of executing S203, and the text extraction module 404 is used to implement the relevant content of executing S204. Each unit or module in the text extraction device 400 can be respectively or completely merged into one or more other units or modules to form, or one (some) of the units or modules can also be further divided into multiple smaller units or modules in function to form, which can achieve the same operation without affecting the realization of the technical effect of the embodiment of the present invention. The above-mentioned units or modules are divided according to logical functions. In practical applications, the function of one unit (or module) is realized by multiple units (or modules), or the function of multiple units (or modules) is realized by one unit (or module).
[0109] According to the description of the above method embodiment and related device embodiment, please refer to Figure 5 , Figure 5 It is a schematic diagram of the structure of a computer 500 provided in an embodiment of the present application. Figure 5 The computer 500 shown includes a processor 501, a memory 502, a communication interface 503 and a bus 504. The processor 501, the memory 502 and the communication interface 503 are connected to each other through the bus 504.
[0110] Optionally, the memory 502 is a ROM, a static storage device, a dynamic storage device or a RAM.
[0111] The memory 502 can store executable program codes. When the executable program codes stored in the memory 502 are executed by the processor 501, the processor 501 and the communication interface 503 are used to execute Figure 2 The various steps of the text extraction method of the illustrated embodiment.
[0112] The processor 501 adopts a general-purpose CPU, a microprocessor, an application-specific integrated circuit ASIC, a GPU or one or more integrated circuits to execute relevant programs to perform the text extraction method of the method embodiment of the present application.
[0113] The processor 501 can also be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the text extraction method of the present application can be completed by the hardware integrated logic circuit in the processor 501 or the instruction in the form of software. Optionally, the processor 501 is a general-purpose processor, DSP, ASIC, FPGA or other programmable logic device, discrete gate or transistor logic device, discrete hardware component. The processor can implement or execute the various methods, steps and logic block diagrams disclosed in the embodiments of the present application. The general-purpose processor is a microprocessor or the processor is any conventional processor, etc. The steps of the method disclosed in the embodiment of the present application can be directly embodied as a hardware decoding processor to execute, or a combination of hardware and software modules in the decoding processor to execute. The optional software module is located in a random access memory, a flash memory, a read-only memory, a programmable read-only memory or an electrically erasable programmable memory, a register or other mature storage medium in the art. The storage medium is located in the memory 502, and the processor 501 reads the information in the memory 502, and combines its hardware to complete the functions required to be executed by the modules included in the text extraction device 400 of the embodiment of the present application, or executes the text extraction method of the method embodiment of the present application.
[0114] The communication interface 503 uses a transceiver or other related device such as, but not limited to, a transceiver.
[0115] Bus 504 may include a path for transmitting information between various components of computer 500 (eg, memory 502 , processor 501 , communication interface 503 ).
[0116] It should be noted that although Figure 5 The computer 500 shown only shows a memory, a processor, and a communication interface, but in the specific implementation process, those skilled in the art should understand that the computer 500 also includes other devices necessary for normal operation. At the same time, according to specific needs, those skilled in the art should understand that the computer 500 may also include hardware devices for implementing other additional functions. In addition, those skilled in the art should understand that the computer 500 may also only include the devices necessary to implement the embodiments of the present application, and does not necessarily include Figure 5 All devices shown in .
[0117] An embodiment of the present application provides a computer-readable storage medium, in which a computer program for electronic data exchange is stored. The computer program includes execution instructions, and the execution instructions are used to execute part or all of the steps of any one of the text extraction methods recorded in the above-mentioned text extraction method embodiments. The above-mentioned computer includes an electronic terminal device.
[0118] An embodiment of the present application provides a computer program product, wherein the computer program product includes a computer program, and the computer program can be operated to enable a computer to perform part or all of the steps of any text extraction method recorded in the above method embodiments. The computer program product can be a software installation package.
[0119] It should be noted that, for the sake of simplicity, the embodiments of any of the aforementioned text extraction methods are all described as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the order of the actions described, because according to the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily required by the present application.
[0120] The above is a detailed introduction to the embodiments of the present application. Specific examples are used in this article to illustrate the principles and implementation methods of a text extraction method, device, equipment, storage medium and program product of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea; at the same time, for a general technician in this field, based on the idea of a text extraction method, device, equipment, storage medium and program product of the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
[0121] The present application is described with reference to the flowcharts and / or block diagrams of the methods, hardware products, and computer program products of the embodiments of the present application. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of the processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0122] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 The memory may include: a flash drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0123] Although the present application is described herein in conjunction with various embodiments, in the process of implementing the claimed application, those skilled in the art may understand and implement other variations of the disclosed embodiments by viewing the drawings, the disclosure, and the appended claims. In the claims, the word "comprising" does not exclude other components or steps, and "a" or "one" does not exclude multiple situations. Certain measures are recorded in different dependent claims, but this does not mean that these measures cannot be combined to produce good results.
[0124] A person skilled in the art can understand that all or part of the steps in the various methods of the method embodiments of any of the above-mentioned text extraction methods can be completed by instructing related hardware through a program, and the program can be stored in a computer-readable memory, and the memory can include: a flash drive, a read-only memory (English: Read-Only Memory, abbreviated as: ROM), a random access memory (English: Random Access Memory, abbreviated as: RAM), a disk or an optical disk, etc.
[0125] It can be understood that any product that is controlled or configured to execute the processing method of the flowchart described in an embodiment of a text extraction method of the present application, such as the device and computer program product of the above flowchart, falls within the scope of the related products described in the present application.
[0126] Obviously, those skilled in the art can make various changes and modifications to the text extraction method, device, equipment, storage medium and program product provided by the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.
Claims
1. A text extraction method, characterized in that: The method comprises: Extract features from basic sample data to obtain multiple sample feature data; Performing label processing on sample feature data of different categories among the multiple sample feature data to obtain multiple sample feature data labels; Determine the output probability of different sample feature data labels among the multiple sample feature data labels according to the bidirectional long short-term memory network-conditional random field model; Extract the text corresponding to the sample feature data label with the maximum output probability from the basic sample data.
2. The method according to claim 1, characterized in that The labeling process is performed on the sample feature data of different categories in the plurality of sample feature data to obtain a plurality of sample feature data labels, including: Defining a target tag set according to task requirements, wherein the target tag set includes labels corresponding to sample feature data of different categories; The labels of the plurality of sample feature data are determined according to the target tag set and the plurality of sample feature data to obtain a plurality of sample feature data labels.
3. The method according to claim 1, characterized in that Before determining the output probabilities of different sample feature data labels among the multiple sample feature data labels according to the bidirectional long short-term memory network-conditional random field model, the method further includes: Construct an initial network model including a bidirectional long short-term memory network layer and a conditional random field layer; Initializing multiple parameters in the initial network model; Obtaining a predicted output probability according to the training data set and the initial network model; According to the true output probability of the training data set, the predicted output probability and the target loss function, multiple parameters in the initial network model are updated to obtain a bidirectional long short-term memory network-conditional random field model.
4. The method according to claim 3, characterized in that The step of determining the output probabilities of different sample feature data labels among the multiple sample feature data labels according to the bidirectional long short-term memory network-conditional random field model includes: Obtain a first output according to the multiple sample feature data labels and the bidirectional long short-term memory network layer in the bidirectional long short-term memory network-conditional random field model; The first output is used as an input of a conditional random field layer in the bidirectional long short-term memory network-conditional random field model to obtain a second output, where the second output is the output probability of different sample feature data labels among the multiple sample feature data labels.
5. The method according to claim 4, characterized in that The bidirectional long short-term memory network layer includes a word embedding layer, a forward long short-term memory network layer, a backward long short-term memory network layer and a fully connected linear layer, and the first output is obtained according to the plurality of sample feature data labels and the bidirectional long short-term memory network layer in the bidirectional long short-term memory network-conditional random field model, including: Obtaining a first product of the sample feature data label and the word embedding network, wherein the first product is the output of the word embedding layer; Obtaining a first result of performing a forward long short-term memory network calculation on the first product and the hidden state of the previous time step, wherein the first result is an output of a forward long short-term memory network layer; Obtaining a second result of performing a backward long short-term memory network calculation on the first product and the hidden state of the previous time step, wherein the second result is an output of the backward long short-term memory network layer; Obtaining a second product of the first weight and the first result; Obtaining a third product of the second weight and the second result; A first sum value of the second product, the third product, and an offset value is obtained, where the first sum value is a first output.
6. The method according to claim 4, characterized in that The conditional random field layer includes a transmission probability function and a feature transfer function, and the first output is used as an input of the conditional random field layer in the bidirectional long short-term memory network-conditional random field model to obtain a second output, including: The label probability calculation function is obtained according to the emission probability function and the feature transfer function; The second output is obtained according to the first output and the label probability calculation function.
7. The method according to any one of claims 1 to 6, characterized in that: Before extracting features from the basic sample data, the method further includes: The collected sample data is preprocessed to obtain basic sample data, wherein the preprocessing includes removing characteristic characters, segmenting words, and removing stop words.
8. A text extraction device, characterized in that: The device comprises: A feature extraction module is used to extract features from basic sample data to obtain multiple sample feature data; A label processing module, used to perform label processing on sample feature data of different categories in the plurality of sample feature data to obtain a plurality of sample feature data labels; A determination module, used to determine the output probability of different sample feature data labels among the multiple sample feature data labels according to a bidirectional long short-term memory network-conditional random field model; The text extraction module is used to extract the text corresponding to the sample feature data label with the maximum output probability in the basic sample data.
9. A computer, characterized in that: The computer comprises: A memory, a processor, and an executable program code stored in the memory and executable on the processor, wherein the processor executes the steps of the text extraction method according to any one of claims 1 to 7 when executing the executable program code.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a text extraction program, wherein the text extraction program includes execution instructions, and the execution instructions are used to execute the steps of the text extraction method according to any one of claims 1 to 7.
