Text processing method, device, computer equipment and storage medium
By performing word vector representation, semantic feature and temporal feature extraction on the text and calculating the attention weight, the problem of low accuracy of abnormal text detection in the existing technology is solved, and more accurate abnormal text detection is achieved.
Patent Information
- Application Number
- CN202211410457.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-11
- Publication Date
- 2025-09-09
- Estimated Expiration
- 2042-11-11
AI Technical Summary
Existing abnormal text detection methods have low accuracy and cannot effectively identify abnormal text, resulting in threats to information security.
By obtaining the word vector representation of the text to be processed, semantic feature extraction and temporal feature extraction are performed, the attention weight of the word temporal feature is calculated, and the word attention feature is obtained by weighting with the attention weight to perform abnormal text detection.
Improves the accuracy of abnormal text detection and ensures information security.
Smart Images

Figure CN115859176B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of Internet technology, and in particular to a text processing method, apparatus, computer equipment, storage medium, and computer program product. Background Art
[0002] With the development of Internet technology, users can publish any information on the Internet, such as communication information, videos, pictures, text, etc. To maintain information security, it is often necessary to detect anomalies in information on the Internet. For example, detecting abnormal text can prevent information leakage or the spread of false information caused by abnormal text, which could threaten information security.
[0003] The existing abnormal text detection method performs abnormal text detection on text based on empirical rules, which has the problem of low accuracy in abnormal text detection. Summary of the Invention
[0004] Based on this, it is necessary to provide an information processing method, apparatus, computer equipment, computer-readable storage medium and computer program product that can improve the accuracy of detecting the emotional state of information in order to address the above technical problems.
[0005] In a first aspect, the present application provides a text processing method. The method comprises:
[0006] Obtain the text to be processed, perform word vector representation based on the text to be processed, and obtain the word representation vectors;
[0007] Semantic feature extraction is performed based on the representation vectors of each word to obtain the semantic features of each word, and temporal feature extraction is performed according to the word sequence of the text to be processed and the semantic features of each word to obtain the temporal features of each word;
[0008] Calculate the attention weight corresponding to each word's temporal feature, and use the attention weight to weight each word's temporal feature to obtain each word's attention feature;
[0009] Abnormal text detection is performed based on the attention features of each word to obtain the probability of abnormal text corresponding to the text to be processed.
[0010] In a second aspect, the present application further provides a text processing device. The device comprises:
[0011] The vector representation module is used to obtain the text to be processed, perform word vector representation based on the text to be processed, and obtain the representation vectors of each word;
[0012] The feature extraction module is used to extract semantic features based on the representation vectors of each word to obtain the semantic features of each word, and to extract temporal features according to the word sequence of the text to be processed and the semantic features of each word to obtain the temporal features of each word;
[0013] The attention module is used to calculate the attention weight corresponding to each word's temporal feature, and use the attention weight to weight each word's temporal feature to obtain each word's attention feature;
[0014] The detection module is used to detect abnormal text based on the attention features of each word and obtain the possibility of abnormal text corresponding to the text to be processed.
[0015] In a third aspect, the present application further provides a computer device. The computer device includes a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are performed:
[0016] Obtain the text to be processed, perform word vector representation based on the text to be processed, and obtain the word representation vectors;
[0017] Semantic feature extraction is performed based on the representation vectors of each word to obtain the semantic features of each word, and temporal feature extraction is performed according to the word sequence of the text to be processed and the semantic features of each word to obtain the temporal features of each word;
[0018] Calculate the attention weight corresponding to each word's temporal feature, and use the attention weight to weight each word's temporal feature to obtain each word's attention feature;
[0019] Abnormal text detection is performed based on the attention features of each word to obtain the probability of abnormal text corresponding to the text to be processed.
[0020] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the following steps:
[0021] Obtain the text to be processed, perform word vector representation based on the text to be processed, and obtain the word representation vectors;
[0022] Semantic feature extraction is performed based on the representation vectors of each word to obtain the semantic features of each word, and temporal feature extraction is performed according to the word sequence of the text to be processed and the semantic features of each word to obtain the temporal features of each word;
[0023] Calculate the attention weight corresponding to each word's temporal feature, and use the attention weight to weight each word's temporal feature to obtain each word's attention feature;
[0024] Abnormal text detection is performed based on the attention features of each word to obtain the probability of abnormal text corresponding to the text to be processed.
[0025] In a fifth aspect, the present application further provides a computer program product. The computer program product includes a computer program that, when executed by a processor, implements the following steps:
[0026] Obtain the text to be processed, perform word vector representation based on the text to be processed, and obtain the word representation vectors;
[0027] Semantic feature extraction is performed based on the representation vectors of each word to obtain the semantic features of each word, and temporal feature extraction is performed according to the word sequence of the text to be processed and the semantic features of each word to obtain the temporal features of each word;
[0028] Calculate the attention weight corresponding to each word's temporal feature, and use the attention weight to weight each word's temporal feature to obtain each word's attention feature;
[0029] Abnormal text detection is performed based on the attention features of each word to obtain the probability of abnormal text corresponding to the text to be processed.
[0030] The above-described text processing method, apparatus, computer device, storage medium, and computer program product extract semantic features from each word representation vector to obtain semantic features for each word. Sequential features are then extracted based on the word sequence of the text to be processed and the semantic features of each word to obtain temporal features for each word, thereby improving the accuracy of the temporal features. Attention weights corresponding to each temporal feature are then calculated and weighted according to the attention weights to obtain attention features for each word. The importance of each attention feature is then determined. Furthermore, the attention features of each word are used to detect abnormal text, resulting in more accurate detection results and thus improving the accuracy of abnormal text detection. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] Figure 1 A diagram showing an application environment of a text processing method in one embodiment;
[0032] Figure 2 1 is a flowchart of a text processing method according to an embodiment;
[0033] Figure 3 A schematic diagram of a process for obtaining text to be processed in one embodiment;
[0034] Figure 4 A schematic diagram of a process for abnormal text processing in one embodiment;
[0035] Figure 5 1 is a flow chart of abnormal text detection in one embodiment;
[0036] Figure 6 Schematic diagram of the structure of an abnormal text detection model in one embodiment;
[0037] Figure 7 is a structural block diagram of a text processing device in one embodiment;
[0038] Figure 8 is a diagram of the internal structure of a computer device in one embodiment;
[0039] Figure 9 FIG. 4 is a diagram showing the internal structure of a computer device in another embodiment. DETAILED DESCRIPTION
[0040] In order to make the purpose, technical solutions and advantages of this application more clear, the following further describes this application in detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain this application and are not intended to limit this application.
[0041] The text processing method provided in the embodiment of the present application can be applied to Figure 1 In the application environment shown. Among them, the terminal 102 communicates with the server 104 through the network. The data storage system can store the data that the server 104 needs to process. The data storage system can be integrated on the server 104, or it can be placed on the cloud or other network servers. The server 104 obtains the text to be processed through the terminal 102, performs word vector representation based on the text to be processed, and obtains each word representation vector; the server 104 extracts semantic features based on each word representation vector to obtain each word semantic feature, and extracts time series features according to the word sequence of the text to be processed and each word semantic feature to obtain each word time series feature; the server 104 calculates the attention weight corresponding to each word time series feature, and uses the attention weight to weight each word time series feature to obtain each word attention feature; the server 104 performs abnormal text detection based on each word attention feature to obtain the possibility of abnormal text corresponding to the text to be processed. Among them, the terminal 102 can be but is not limited to various personal computers, laptops, smart phones, tablet computers, etc. The server 104 can be implemented as an independent server or a server cluster consisting of multiple servers.
[0042] In one embodiment, Figure 2 As shown, a text processing method is provided, which is applied to Figure 1 The following steps are used as an example to illustrate the server in the example:
[0043] Step 202: Obtain the text to be processed, perform word vector representation based on the text to be processed, and obtain each word representation vector.
[0044] The "text to be processed" refers to the text to be detected for anomalies. Word vector representation refers to the process of converting text data into vectors. A word representation vector refers to the vector representing the word in the text to be processed.
[0045] Specifically, in response to the keyword search instruction sent by the terminal, the server accesses various websites through various pre-set website addresses, searches each website based on the keywords carried in the keyword search instruction, obtains search web page results corresponding to each website, and obtains the search web page content corresponding to each website as the text to be processed. The server can also search various pre-stored texts based on the keywords carried in the keyword search instruction and select the text containing the keywords as the text to be processed. The server can also obtain the text to be processed through the terminal.
[0046] The server then obtains a pre-set vector conversion algorithm, inputs the text to be processed into the vector conversion algorithm for word vector representation, and obtains the word representation vector corresponding to each word in the text to be processed.
[0047] Step 204 : semantic feature extraction is performed based on each word representation vector to obtain the semantic feature of each word, and temporal feature extraction is performed according to the word sequence of the text to be processed and the semantic feature of each word to obtain the temporal feature of each word.
[0048] Among them, word semantic features refer to features that characterize the semantic properties of words. Word sequence refers to the semantic order between words in the text to be processed. Word temporal features refer to features that characterize the word order and semantic properties of words.
[0049] Specifically, the server can input each word representation vector into a pre-trained semantic feature extraction network, and extract the word semantic features corresponding to each word representation vector through the network. The server then extracts the word sequence of each word based on the text to be processed, that is, the word sequence corresponding to each word semantic feature. The server can then obtain a pre-trained relationship extraction network, input each word semantic feature and the word sequence corresponding to each word semantic feature into the relationship extraction network, and extract the dependency relationship between each word semantic feature through the relationship extraction network. The dependency relationship refers to the combination relationship between each word that represents semantics, including the dependency relationship between long-distance words. The deep learning network outputs the temporal features of each word based on the dependency relationship between each word representation vector.
[0050] Step 206: Calculate the attention weight corresponding to each word temporal feature, and use the attention weight to weight each word temporal feature to obtain each word attention feature.
[0051] The attention weight refers to the importance of each word temporal feature, and the word attention feature refers to the word temporal feature after attention weighting.
[0052] Specifically, the server uses pre-set attention weight calculation parameters to calculate the attention weight corresponding to each word timing feature, and then uses the attention weight corresponding to each word timing feature to weight the corresponding word timing features respectively to obtain each word attention feature.
[0053] Step 208: perform abnormal text detection based on the attention features of each word to obtain the abnormal text possibility corresponding to the text to be processed.
[0054] The abnormal text possibility refers to the possibility that the text to be processed is an abnormal text.
[0055] Specifically, the server inputs the attention features of each word into a pre-set deep learning network to detect abnormal text and obtain the possibility of abnormal text corresponding to the text to be processed.
[0056] When the server detects that the likelihood of abnormal text exceeds a preset abnormality threshold, it determines that the text to be processed is abnormal text. The server can pre-set at least two abnormality thresholds and classify the abnormality levels accordingly. For example, when the server detects that the likelihood of abnormal text exceeds the first preset abnormality threshold, it determines that the text to be processed is a first-level abnormal text. When the server detects that the likelihood of abnormal text exceeds the second preset abnormality threshold, it determines that the text to be processed is a second-level abnormal text. The higher the level, the more serious the abnormality.
[0057] In the above-mentioned text processing method, apparatus, computer device, storage medium, and computer program product, semantic features are extracted from each word representation vector to obtain each word's semantic features. Sequential features are extracted based on the word sequence of the text to be processed and the semantic features of each word to obtain each word's temporal features, thereby improving the accuracy of the word's temporal features. Attention weights corresponding to each word's temporal features are then calculated and weighted according to the attention weights to obtain each word's attention features. The importance of each word's attention features is then determined. The attention features of each word are then used to make the results of abnormal text detection more accurate, thereby improving the accuracy of abnormal text detection.
[0058] In one embodiment, before step 202, obtaining the text to be processed, the process further includes:
[0059] In response to a text search request that carries a keyword, obtaining a communication interface corresponding to each information source;
[0060] Based on the communication interface corresponding to each information source, use the keyword to search each information source respectively to obtain the keyword search information corresponding to each information source;
[0061] The information to be processed is obtained by searching for keywords corresponding to each information source.
[0062] A text search request refers to a request to search for text to be processed. A keyword refers to a term used to search for text to be processed. An information source refers to a collection of information used for text search. Keyword search information refers to information found in an information source based on a keyword search.
[0063] Specifically, the server obtains the communication interfaces corresponding to each pre-set information source, integrates and processes the communication interfaces corresponding to each information source, obtains a communication interface set, and stores it. The server then responds to the text search request sent by the terminal and obtains the communication interfaces corresponding to each information source in the communication interface set. The server accesses each information source through the communication interface corresponding to each information source, and then searches each information source based on the keywords carried in the text search request, obtaining keyword search information returned by each information source based on the keywords. The text data in the keyword search information corresponding to each information source is extracted to obtain the text to be processed. The keyword search information also includes images. The server can recognize and extract the text in the image to obtain the image text corresponding to the image, and use the image text as the text to be processed.
[0064] In one specific embodiment, the information source may be the World Wide Web (WWW). The server uses Mashup technology to obtain the APIs (Application Programming Interfaces) of various websites, aggregates the APIs of each website, and obtains an API set. The server then invokes a search program based on the keywords in the text search request to search across various websites. Each website returns web pages based on the keyword search, i.e., keyword search information. The server collects data from the content of each web page and stores the collected data in the form of an HTML (Hypertext Markup Language) document, obtaining the text to be processed.
[0065] In a specific embodiment, Figure 3 As shown, a schematic diagram of a process for obtaining text to be processed is provided. In response to a text search request, the server accesses each designated website through its API and searches for keywords, such as forums, blogs, and news websites. The server then collects the searched web page information from each designated website, aggregates the web page information from each designated website using a mashup algorithm, and stores the aggregated web page information in a database of text to be processed.
[0066] In this embodiment, the communication interfaces corresponding to the various information sources are grouped together to obtain a communication interface set, so that the communication interface set can be used to quickly connect to a designated information source for information acquisition, thereby improving the acquisition efficiency of the files to be processed.
[0067] In one embodiment, step 202, word vector representation is performed based on the text to be processed to obtain each word representation vector, including:
[0068] Performing standardization processing on the text to be processed to obtain a standard text to be processed;
[0069] Filtering interference fields in the standard text to be processed to obtain filtered text to be processed;
[0070] Perform word vector representation based on the filtered text to be processed to obtain each word representation vector.
[0071] Standardization refers to the process of standardizing text formats. Standardized text to be processed refers to text with a uniform format. Noise fields refer to fields without semantic meaning. Filtered text to be processed refers to text after noise fields have been filtered out.
[0072] Specifically, the server standardizes the text to be processed according to preset format requirements, for example, standardizing the capitalization of English letters and simplifying traditional Chinese characters in the text to be processed, thereby obtaining a representation of the text to be processed. The server then imports a noise vocabulary and filters the text to be processed based on the various noise fields in the noise vocabulary. The noise fields in the text to be processed are filtered out to obtain the filtered text to be processed. Noise words can be stop words, meaningless functional words, such as "and" and "generally."
[0073] The server can then input the filtered text to be processed into a pre-trained Word2Vec model (word embeddings, word vector model) for vector conversion. The structure of the Word2Vec model is a three-layer shallow neural network, including an input layer, a hidden layer, and an output layer. Among them, the hidden layer does not contain an activation function, and the dimensions of the input layer and the output layer are the same. The Word2Vec model outputs the word representation vector corresponding to each word in the filtered text to be processed. The word representation vector can be a high-dimensional vector. The server then establishes a mapping relationship based on each word in the text to be processed and its corresponding word representation vector and generates a word vector mapping table. The server can also directly obtain a pre-stored word vector mapping table and search for the corresponding word representation vector in the word vector mapping table based on each word in the filtered text to be processed.
[0074] In this embodiment, each word representation vector is obtained by preprocessing the text to be processed, so that subsequent word representation vectors meet the data requirements of abnormal text detection, thereby improving the accuracy of abnormal text detection.
[0075] In one embodiment, Figure 4As shown, a flowchart of abnormal text processing is provided; in step 208, after obtaining the abnormal text possibility corresponding to the text to be processed, the following is also included:
[0076] Step 402: When the probability of detecting abnormal text exceeds a preset abnormal probability threshold, the text to be processed is determined to be abnormal text;
[0077] Step 404: Generate an abnormality alert and abnormal text clustering confirmation information based on the abnormal text, and send the abnormality alert and abnormal text clustering confirmation information to the management terminal;
[0078] Step 406: receiving a confirmation result corresponding to the abnormal text clustering confirmation information, clustering associated words in the text to be processed based on the cluster center word, and obtaining a target associated word corresponding to the cluster center word;
[0079] Step 408: Use the target associated word as the abnormal text clustering result, and return the abnormal text clustering result to the management terminal.
[0080] Among them, the preset abnormality possibility threshold refers to the pre-set abnormality possibility threshold, which is used to determine whether the text to be processed is abnormal text. The abnormal alarm refers to the alarm generated when abnormal text is detected. The abnormal text clustering confirmation information refers to the confirmation information sent to the terminal when abnormal text is detected to confirm whether abnormal text clustering is performed. Abnormal text clustering refers to the search and aggregation of related words based on the cluster center word in the text to be processed, which can represent the retrieval of high-frequency events. The cluster center word refers to the word that represents the current hot event in the text to be detected, which is used for rapid identification of abnormal text. The target associated word refers to the word associated with the cluster center word.
[0081] Specifically, when the server detects that the abnormal text exceeds a preset abnormality probability threshold, it determines that the text to be processed is abnormal text and generates an abnormality alert and abnormal text cluster confirmation information based on the abnormal text determination result. The server sends the abnormal text cluster confirmation information to the management terminal for display and waits for the confirmation result corresponding to the abnormal text cluster confirmation information.
[0082] When the server receives confirmation from the management terminal that abnormal text clustering has been performed, it uses the keyword as the cluster center word. The server may also count the frequency of occurrence of each word in the text to be processed and use the word with the highest frequency as the cluster center word, or use the word with a frequency that reaches a preset frequency threshold as the cluster center word. The server clusters the associated words in the text to be processed based on the cluster center word, and obtains target associated words corresponding to the cluster center word, with at least two target associated words. The server then uses the target associated words as the abnormal text clustering result and sends it to the association terminal.
[0083] In this embodiment, an abnormal alarm and abnormal text clustering confirmation information are generated based on the abnormal text. When the confirmation result corresponding to the abnormal text clustering confirmation information is received, the associated words are clustered in the text to be processed according to the cluster center word, the target associated words corresponding to the cluster center word are obtained and the abnormal text clustering result is generated, so that the management terminal processes the abnormal text clustering result, thereby improving the management efficiency of the abnormal text.
[0084] In one embodiment, step 306, clustering associated words in the text to be processed based on the cluster center word to obtain target associated words corresponding to the cluster center word includes:
[0085] Perform word vector representation based on the cluster center word to obtain the cluster center word representation vector;
[0086] Calculate the vector distance between the cluster center word representation vector and each word representation vector respectively, and determine the associated word representation vector in each word representation vector based on the vector distance;
[0087] The target associated word is obtained based on the associated word representation vector.
[0088] The cluster center word representation vector refers to the vector data obtained after the cluster center word undergoes vector conversion.
[0089] Specifically, the server performs word vector representation on the cluster center word to obtain the cluster center word representation vector. The server can also directly obtain the word vector representation corresponding to the keyword in each word representation vector and use it as the cluster center word representation vector.
[0090] The server then calculates the vector distance between the cluster center word representation vector and each word representation vector, and determines the word representation vector whose vector distance is less than a preset vector distance threshold as the associated word representation vector. Then, the target associated word corresponding to the associated word representation vector is obtained according to the word vector mapping table.
[0091] In one specific embodiment, the server can use the TF-IDF (term frequency–inverse document frequency, a statistical method) algorithm to calculate the frequency and weight of each word in the text to be processed, and output the keywords corresponding to the text to be processed, that is, the cluster center words. The server obtains the cluster center word representation vector from each word representation vector. The server then uses the cluster center word representation vector as the initial cluster center for each word representation vector in the text to be processed. The initial cluster centers can be at least two, and different initial cluster centers represent different clusters.
[0092] The server can use the K-means algorithm to calculate the vector distance between each word representation vector and the initial cluster center, and classify each word representation vector into the class containing the initial cluster center closest to the word representation vector based on the vector distance, completing the adjustment of the class containing the initial cluster center. The adjusted new class calculates the new cluster center and determines whether the clustering criteria have converged. If the clustering criteria have converged or there is no change between two adjacent cluster centers, it indicates that the class containing the cluster center has been adjusted and the associated word representation vectors corresponding to each cluster center are obtained. If the clustering criteria have not converged or there is a change between two adjacent cluster centers, the class containing the cluster center is adjusted based on the vector clustering of each word representation vector until the clustering criteria converges or there is no change between two adjacent cluster centers. The server then obtains the various categories output by the K-means algorithm and the associated word representation vectors corresponding to each category.
[0093] In this embodiment, by calculating the vector distance between the cluster center word representation vector and each word representation vector, the associated word representation vector is determined in each word representation vector based on the vector distance, thereby improving the clustering accuracy of the associated words.
[0094] In one embodiment, after obtaining the probability of abnormal text corresponding to the text to be processed in step 208, the following steps are further included:
[0095] Obtaining preset alarm words, and performing word matching in the text to be processed based on the preset alarm words;
[0096] When a text alarm word that matches a preset alarm word is detected in the text to be processed, a text alarm is generated based on the text alarm word;
[0097] Send text alerts to management terminals.
[0098] Preset alarm words refer to pre-set sensitive words. Text alerts refer to alerts generated when an alarm word is detected. Text alarm words refer to words in the text to be processed that are identical to the preset alarm words.
[0099] Specifically, the server obtains preset alarm words and performs word matching in the text to be processed based on the preset alarm words. When it is detected that there is a text alarm word in the text to be processed that matches the preset alarm word, it indicates that sensitive information exists in the processed text. A text alarm is generated based on the text alarm word and sent to the management terminal.
[0100] In this embodiment, by setting preset alarm words and performing word matching in the text to be processed based on the preset alarm words, it is possible to quickly detect whether the text alarm words exist, thereby improving the monitoring efficiency of sensitive information in the text to be processed.
[0101] In a specific embodiment, Figure 5The server obtains keywords in the text search request, searches for relevant web pages on various designated websites based on the keywords, obtains information about each web page, and stores the information about each web page in a database of text to be processed.
[0102] The server pre-processes the data of each web page information to obtain the text to be processed. The text to be processed is then input into the abnormal text detection model for abnormal text detection to obtain the abnormal text probability corresponding to the text to be processed.
[0103] In a specific embodiment, Figure 6 The following figure shows the structure of an abnormal text detection model. The abnormal text detection model includes an input layer, a CNN-LSTM model (a spatiotemporal network), an attention layer, an activation layer, and a fully connected layer. The server inputs the word representation vectors after data preprocessing into the abnormal text detection model, specifically into the convolutional layer of the CNN-LSTM network. The convolutional layer extracts semantic features from each word representation vector and outputs the semantic features of each word. These semantic features can be high-level abstract features hidden in the text data, such as the gender implied by a name.
[0104] Then, the semantic features of each word output by the convolutional neural network are input into the LSTM hidden layer (long short-term memory network) in the CNN-LSTM network. The dependency relationship between the semantic features of each word is extracted through the long short-term memory network, and the temporal features of each word are extracted based on the dependency relationship, and the temporal features of each word are output.
[0105] Then, the temporal features of each word output by the long short-term memory network are input into the attention layer, the weights corresponding to the temporal features of each word are calculated and weighted, and the attention features of each word are output. Each word attention feature is input into the activation layer and the fully connected layer in turn, and the possibility of abnormal text corresponding to the text to be processed is output through the fully connected layer.
[0106] It should be understood that, although the various steps in the flowcharts involved in the various embodiments described above are displayed in sequence according to the instructions of the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and these steps can be executed in other orders. Moreover, at least a portion of the steps in the flowcharts involved in the various embodiments described above can include multiple steps or multiple stages, and these steps or stages are not necessarily executed and completed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a portion of steps or stages in other steps.
[0107] Based on the same inventive concept, embodiments of the present application also provide a text processing device for implementing the aforementioned text processing method. The implementation solution provided by this device is similar to the implementation solution described in the aforementioned method. Therefore, the specific limitations of one or more text processing device embodiments provided below can be found in the above-mentioned limitations of the text processing method and will not be further elaborated here.
[0108] In one embodiment, Figure 7 As shown, a text processing device 700 is provided, comprising: a vector representation module 702, a feature extraction module 704, an attention module 706 and a detection module 708, wherein:
[0109] A vector representation module 702 is used to obtain a text to be processed, perform word vector representation based on the text to be processed, and obtain each word representation vector;
[0110] The feature extraction module 704 is used to extract semantic features based on the representation vectors of each word to obtain the semantic features of each word, and to extract temporal features according to the word sequence of the text to be processed and the semantic features of each word to obtain the temporal features of each word;
[0111] Attention module 706, used to calculate the attention weight corresponding to each word temporal feature, and use the attention weight to weight each word temporal feature to obtain each word attention feature;
[0112] The detection module 708 is used to detect abnormal text based on the attention features of each word and obtain the abnormal text possibility corresponding to the text to be processed.
[0113] In one embodiment, the text processing apparatus 700 further includes:
[0114] The text search unit is used to respond to a text search request that carries keywords and obtain the communication interface corresponding to each information source; based on the communication interface corresponding to each information source, use keywords to search each information source separately to obtain keyword search information corresponding to each information source; based on the keyword search information corresponding to each information source, obtain the text to be processed.
[0115] In one embodiment, the vector representation module 702 includes:
[0116] The preprocessing unit is used to perform standardization processing based on the text to be processed to obtain a standard text to be processed; filter the interference fields in the standard text to be processed to obtain a filtered text to be processed; and perform word vector representation based on the filtered text to be processed to obtain each word representation vector.
[0117] In one embodiment, the text processing apparatus 700 further includes:
[0118] The text clustering unit is used to determine that the text to be processed is abnormal text when the possibility of detecting abnormal text exceeds a preset abnormal possibility threshold; generate an abnormal alarm and abnormal text clustering confirmation information based on the abnormal text, and send the abnormal alarm and abnormal text clustering confirmation information to the management terminal; receive the confirmation result corresponding to the abnormal text clustering confirmation information, cluster the associated words in the text to be processed based on the cluster center word, and obtain the target associated words corresponding to the cluster center word; use the target associated words as the abnormal text clustering result, and return the abnormal text clustering result to the management terminal.
[0119] In one embodiment, the text processing apparatus 700 further includes:
[0120] The clustering unit is used to perform word vector representation based on the cluster center word to obtain the cluster center word representation vector; calculate the vector distance between the cluster center word representation vector and each word representation vector respectively, and determine the associated word representation vector in each word representation vector based on the vector distance; and obtain the target associated word based on the associated word representation vector.
[0121] In one embodiment, the text processing apparatus 700 further includes:
[0122] The alarm unit is used to obtain a preset alarm word and perform word matching in the text to be processed based on the preset alarm word; when a text alarm word that matches the preset alarm word is detected in the text to be processed, a text alarm is generated based on the text alarm word; and the text alarm is sent to the management terminal.
[0123] Each module in the above-mentioned text processing device can be implemented in whole or in part through software, hardware, or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in the computer device in the form of software, so that the processor can call and execute the corresponding operations of each module.
[0124] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Figure 8As shown. The computer device includes a processor, a memory, an input / output interface (Input / Output, abbreviated as I / O) and a communication interface. The processor, memory and input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and computer program in the non-volatile storage medium. The database of the computer device is used to store text to be processed. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a text processing method is implemented.
[0125] In one embodiment, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as follows: Figure 9 As shown. The computer device includes a processor, a memory, an input / output interface, a communication interface, a display unit and an input device. The processor, the memory and the input / output interface are connected via a system bus, and the communication interface, the display unit and the input device are connected to the system bus via the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner can be implemented through WIFI, a mobile cellular network, NFC (near field communication) or other technologies. When the computer program is executed by the processor, a text processing method is implemented. The display unit of the computer device is used to form a visually visible image, and can be a display screen, a projection device or a virtual reality imaging device. The display screen can be a liquid crystal display screen or an electronic ink display screen. The input device of the computer device can be a touch layer covering the display screen, or a button, trackball or touchpad set on the computer device casing, or an external keyboard, touchpad or mouse, etc.
[0126] Those skilled in the art will understand that Figure 8-9The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different component arrangement.
[0127] In one embodiment, a computer device is further provided, including a memory and a processor. The memory stores a computer program, and the processor implements the steps in the above method embodiments when executing the computer program.
[0128] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments are implemented.
[0129] In one embodiment, a computer program product is provided, including a computer program, which implements the steps in the above method embodiments when executed by a processor.
[0130] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of relevant countries and regions.
[0131] Those skilled in the art will appreciate that all or part of the processes in the above-mentioned embodiment methods can be implemented by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, database or other media used in the embodiments provided in this application may include at least one of non-volatile and volatile memory. Non-volatile memory may include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory may include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in the various embodiments provided herein may include at least one of a relational database and a non-relational database. Non-relational databases may include, but are not limited to, distributed databases based on blockchains. The processor involved in the various embodiments provided herein may be, but are not limited to, a general-purpose processor, a central processing unit, a graphics processing unit, a digital signal processor, a programmable logic unit, a data processing logic unit based on quantum computing, and the like.
[0132] The technical features of the above embodiments can be combined arbitrarily. In order to make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0133] The above-described embodiments merely represent several implementation methods of the present application. While the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the present application. It should be noted that a person of ordinary skill in the art may make various modifications and improvements without departing from the spirit of the present application, and these modifications and improvements fall within the scope of protection of the present application. Therefore, the scope of protection of the present application shall be determined by the appended claims.
Claims
1. A text processing method, characterized in that: The method comprises: Obtaining a text to be processed, performing word vector representation based on the text to be processed, and obtaining each word representation vector; Performing semantic feature extraction based on the representation vectors of each word to obtain semantic features of each word, and performing temporal feature extraction according to the word sequence of the text to be processed and the semantic features of each word to obtain temporal features of each word; Calculating the attention weight corresponding to each word temporal feature, and using the attention weight to weight each word temporal feature to obtain each word attention feature; Abnormal text detection is performed based on the attention features of each word to obtain the possibility of abnormal text corresponding to the text to be processed.
2. The method according to claim 1, characterized in that Before obtaining the text to be processed, the method further includes: In response to a text search request, the text search request carries a keyword, obtaining a communication interface corresponding to each information source; Based on the communication interface corresponding to each information source, the keyword is used to search each information source respectively to obtain keyword search information corresponding to each information source; The text to be processed is obtained based on keyword search information corresponding to each information source.
3. The method according to claim 1, characterized in that The word vector representation is performed based on the text to be processed to obtain each word representation vector, including: Performing standardization processing on the text to be processed to obtain a standard text to be processed; Filtering interference fields in the standard text to be processed to obtain filtered text to be processed; Word vector representation is performed based on the filtered text to be processed to obtain the respective word representation vectors.
4. The method according to claim 1, wherein After obtaining the possibility of abnormal text corresponding to the text to be processed, the method further includes: When it is detected that the possibility of the abnormal text exceeds a preset abnormal possibility threshold, determining that the text to be processed is an abnormal text; generating an abnormality alarm and abnormal text clustering confirmation information based on the abnormal text, and sending the abnormality alarm and the abnormal text clustering confirmation information to a management terminal; receiving a confirmation result corresponding to the abnormal text clustering confirmation information, clustering associated words in the to-be-processed text based on the cluster center word, and obtaining a target associated word corresponding to the cluster center word; The target associated words are used as abnormal text clustering results, and the abnormal text clustering results are returned to the management terminal.
5. The method according to claim 4, characterized in that The step of clustering associated words in the to-be-processed text based on the cluster center word to obtain target associated words corresponding to the cluster center word includes: Performing word vector representation based on the cluster center word to obtain a cluster center word representation vector; respectively calculating vector distances between the cluster center word representation vector and each word representation vector, and determining associated word representation vectors in each word representation vector based on the vector distances; The target associated word is obtained based on the associated word representation vector.
6. The method according to claim 1, characterized in that After obtaining the possibility of abnormal text corresponding to the text to be processed, the method further includes: Acquire a preset alarm word, and perform word matching in the text to be processed based on the preset alarm word; When detecting that a text alarm word that matches the preset alarm word exists in the text to be processed, generating a text alarm based on the text alarm word; The text alert is sent to a management terminal.
7. A text processing device, characterized in that: The device comprises: A vector representation module is used to obtain a text to be processed, perform word vector representation based on the text to be processed, and obtain each word representation vector; A feature extraction module is used to extract semantic features based on the representation vectors of each word to obtain semantic features of each word, and to extract temporal features according to the word sequence of the text to be processed and the semantic features of each word to obtain temporal features of each word; An attention module is used to calculate the attention weight corresponding to each word temporal feature, and use the attention weight to weight each word temporal feature to obtain the attention feature of each word; The detection module is used to detect abnormal text based on the attention features of each word and obtain the possibility of abnormal text corresponding to the text to be processed.
8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
10. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
Citation Information
Patent Citations
Sequence labeling method and device and computer equipment
CN111985229A
General text information extraction method and apparatus, computer device and storage medium
WO2020119075A1