Text category recognition method, system and device based on text style

Through a text style-based approach, using word segmentation and neural network processing, the style and content features of the text are extracted, which solves the problem of document category recognition when specific characters are not prominent or there are no prominent marks, and achieves higher recognition accuracy and efficiency.

CN114443833BActive Publication Date: 2025-09-12BEIJING INST OF TECH +2
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202110320155.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-03-25
Publication Date
2025-09-12
Estimated Expiration
2041-03-25

AI Technical Summary

Technical Problem

The existing technology is difficult to accurately identify specific categories of official documents when specific characters are not prominent or there are no prominent marks.

Method used

A text style-based method is adopted to extract the style and content features of the text through word segmentation, vector representation and neural network processing. The lexical style and other style classification networks are used to generate a text style representation constrained by content to determine whether the text belongs to the target category.

Benefits of technology

It improves the accuracy and efficiency of document category recognition when specific characters are not prominent or there are no prominent marks, and enhances data security protection capabilities.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114443833B_ABST
    Figure CN114443833B_ABST
Patent Text Reader

Abstract

An embodiment of the present invention provides a method for identifying text categories based on text style, the method comprising: performing a word segmentation operation on a text to be detected to obtain a target number of word segments, where M is a positive integer; performing vector representation on the target number of word segments to obtain a target number of feature vectors; inputting the target number of feature vectors into one or more trained style classification networks to obtain a style representation vector; inputting the target number of feature vectors into a trained content classification network to obtain a target class classification vector; and judging whether the text to be detected is a target class text based on the style representation vector and the target class classification vector. The embodiment of the present invention enables the target text category of the text to be detected to be accurately identified even when specific characters are not prominent or have no prominent signs, thereby improving the recognition efficiency and recognition accuracy of the text to be detected.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computers, and in particular to a text category recognition method, system and device based on text style. Background Art

[0002] Currently, identification of specific categories of official documents (e.g., official documents with official headers) is primarily based on characteristic characters within the document text or layout information. This identification method typically involves pre-setting key words associated with that category of document, or establishing matching rules corresponding to distinctive features (e.g., the red header mark in official documents with official headers). When a document matches one or all of the matching rules corresponding to the key words or distinctive features, it is considered a document of the specific category.

[0003] However, this recognition method cannot accurately determine whether a document of a specific category is one that has inconspicuous characters or lacks any distinctive markings. Therefore, accurately identifying a document of a specific category when the characters are inconspicuous or lack distinctive markings has become a pressing technical challenge. Summary of the Invention

[0004] The purpose of the present invention is to provide a text category recognition method, system, device and readable storage medium based on text style, which is used to solve the technical problem of low accuracy in identifying specific document categories when specific characters are not prominent or have no prominent marks.

[0005] One aspect of an embodiment of the present invention provides a text category identification method based on text style, the method comprising: performing a word segmentation operation on a text to be detected to obtain a target number of word segments; performing vector representation on the target number of word segments respectively to obtain a target number of feature vectors; inputting the target number of feature vectors into one or more trained style classification networks to obtain a style representation vector; the one or more style classification networks are used to extract style features of the text to be detected based on the target number of feature vectors, and convert the style features into the style representation vector; inputting the target number of feature vectors into a trained content classification network to obtain a target class classification vector; the content classification network is used to extract content features of the text to be detected based on the target number of feature vectors, and convert the content features into the target class classification vector; and judging whether the text to be detected is a target class text based on the style representation vector and the target class classification vector.

[0006] Preferably, the style representation vector includes a first style representation vector and a second style representation vector, the first style representation vector corresponds to the vocabulary style of the text to be detected, and the second style representation vector corresponds to other styles of the text to be detected; the one or more style classification networks include a vocabulary style classification network and other style classification networks, wherein the vocabulary style classification network is a bidirectional long short-term memory network, and the other style classification networks are unidirectional long short-term memory networks; the step of inputting the target number of feature vectors into the trained one or more style classification networks to obtain the style representation vector includes: inputting the target number of feature vectors into the bidirectional long short-term memory network according to the order of the front and back positions of the word segmentations corresponding to each feature vector in the text to be detected to obtain the first style representation vector; and inputting the target number of feature vectors into the unidirectional long short-term memory network according to the order of the front and back positions of the word segmentations corresponding to each feature vector in the text to be detected to obtain the second style representation vector.

[0007] Preferably, the one or more style classification networks and the content classification network share a fully connected classification structure, and the fully connected classification structure includes a fully connected layer and a classification layer; the step of judging whether the text to be detected is a target class text based on the style representation vector and the target class classification vector includes: concatenating the first style representation vector, the second style representation vector and the target class classification vector through an array concatenation function to obtain a target vector; and inputting the target vector into the fully connected layer and passing it through the classification layer to obtain the confidence that the text to be detected is the target class text.

[0008] Preferably, the one or more style classification networks and the content classification network share a fully connected classification structure, and the fully connected classification structure includes a fully connected layer and a classification layer; the step of judging whether the text to be detected is a target class text based on the style representation vector and the target class classification vector includes: fusing the first style representation vector, the second style representation vector and the target class classification vector through the vector mean method to obtain a target vector; wherein, in the vector mean method fusion operation, the weight of the target class classification vector is lower than the weight of the first style representation vector and the weight of the second style representation vector; and inputting the target vector into the fully connected layer and passing through the classification layer to obtain the confidence that the text to be detected is the target class text.

[0009] Preferably, the method further comprises the step of pre-training to obtain the one or more style classification networks and the content classification network: obtaining a plurality of sample texts, each sample text carrying a target class tag or other tags; the target class tag indicates that the corresponding sample text is a target class text, and the other tags indicate that the corresponding sample text is not a target class text; performing word segmentation and vectorization operations on each sample text to obtain a plurality of sample feature vectors of each sample text; inputting the plurality of sample feature vectors of each sample text into the style classification network to be trained to obtain a sample style representation vector of each sample text; the style classification network to be trained is used to train to obtain a corresponding style classification network; inputting the plurality of sample feature vectors of each sample text into the content classification network to be trained In the classification network, a sample document classification vector of each sample text is obtained; the content classification network to be trained is used to train to obtain the content classification network; sample feature fusion is performed on the sample style representation vector of each sample text and the corresponding sample document classification vector to obtain the fused feature vector of each sample text, and the sample text style representation constrained by the content of each sample text is obtained based on the fused feature vector of each sample text; and loss calculation is performed based on the sample text style representation of each sample text and the target class label or other label carried by each sample text to adjust the network parameters of the style classification network to be trained and the network parameters of the content classification network to be trained to obtain the style classification network and the content classification network.

[0010] One aspect of an embodiment of the present invention provides a text category recognition system based on text style, including: a word segmentation module, used to perform word segmentation operations on the text to be detected to obtain a target number of word segments; a representation module, used to perform vector representation on the target number of word segments to obtain a target number of feature vectors; an input module, used to input the target number of feature vectors into one or more trained style classification networks to obtain a style representation vector; an output module, used to input the target number of feature vectors into a trained content classification network to obtain a target class classification vector; and a judgment module, used to judge whether the text to be detected is a target class text based on the style representation vector and the target class classification vector.

[0011] Preferably, the style representation vector includes a first style representation vector and a second style representation vector, the first style representation vector corresponds to the vocabulary style of the text to be detected, and the second style representation vector corresponds to other styles of the text to be detected; the one or more style classification networks include a vocabulary style classification network and other style classification networks, wherein the vocabulary style classification network is a bidirectional long short-term memory network, and the other style classification networks are unidirectional long short-term memory networks; the input module is also used to: input the target number of feature vectors into the bidirectional long short-term memory network according to the order of the front and back positions of the word segmentations corresponding to each feature vector in the text to be detected, to obtain the first style representation vector; and input the target number of feature vectors into the unidirectional long short-term memory network according to the order of the front and back positions of the word segmentations corresponding to each feature vector in the text to be detected, to obtain the second style representation vector.

[0012] Preferably, the one or more style classification networks and the content classification network share a fully connected classification structure, and the fully connected classification structure includes a fully connected layer and a classification layer; the judgment module is also used to: splice the first style representation vector, the second style representation vector and the target class classification vector through an array splicing function to obtain a target vector; and input the target vector into the fully connected layer and through the classification layer to obtain the confidence that the text to be detected is the target class text.

[0013] An aspect of an embodiment of the present invention further provides a computer device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps of the above-mentioned text category recognition method based on text style are implemented.

[0014] One aspect of an embodiment of the present invention further provides a computer-readable storage medium, which stores a computer program. The computer program can be executed by at least one processor to enable the at least one processor to perform the steps of the above-mentioned text style-based text category recognition method.

[0015] The text category recognition method, system, device and computer-readable storage medium based on text style provided by the embodiment of the present invention respectively obtain the style representation vector and target class classification vector of the text to be detected through one or more style classification networks and content classification networks, and according to the style representation vector and the target class classification vector, a text style representation constrained by content can be obtained, thereby judging whether the text to be detected is a target class text. In an embodiment of the invention, a text style representation constrained by content is generated based on the general writing style, word usage habits and other information of the target class file (such as a red-headed file), and the target class file can be judged by the file of the electronic official document that hits the specified style category. The embodiment of the present invention makes it possible to accurately identify the specific official document text category of the text to be detected even when the specific characters are not prominent or there are no prominent marks, thereby improving the recognition efficiency and recognition accuracy of the text to be detected. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] Figure 1 A diagram schematically illustrates an application environment of a text category recognition method based on text style according to an embodiment of the present invention;

[0017] Figure 2 The flowchart of the text category recognition method based on text style according to the first embodiment of the present invention is schematically shown;

[0018] Figure 3 for Figure 2 Sub-step diagram of step S204;

[0019] Figure 4 for Figure 2 Sub-step diagram of step S208;

[0020] Figure 5 for Figure 2 Sub-step diagram of step S208;

[0021] Figure 6 1 is a diagram showing the training steps for obtaining a style classification network and a content classification network according to the first embodiment of the present invention;

[0022] Figure 7 FIG2 shows an overall flow chart of the first embodiment of the present invention;

[0023] Figure 8 FIG2 is a flowchart showing a detection process of a text to be detected according to the first embodiment of the present invention;

[0024] Figure 9 FIG2 shows a flow chart of model training according to embodiment 1 of the present invention;

[0025] Figure 10 A block diagram schematically shows a text category recognition system based on text style according to a second embodiment of the present invention; and

[0026] Figure 11 The following schematically shows a hardware architecture diagram of a computer device suitable for implementing a text category recognition method based on text style according to a third embodiment of the present invention. DETAILED DESCRIPTION

[0027] In order to make the purpose, technical solutions and advantages of the present invention more clearly understood, the present invention is further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.

[0028] It should be noted that the descriptions of "first", "second", etc. in the embodiments of the present invention are for descriptive purposes only and should not be understood as indicating or implying their relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" or "second" may explicitly or implicitly include at least one of such features. In addition, the technical solutions between the various embodiments can be combined with each other, but this must be based on the fact that they can be implemented by ordinary technicians in this field. When the combination of technical solutions is contradictory or cannot be implemented, it should be deemed that such a combination of technical solutions does not exist and is not within the scope of protection required by the present invention.

[0029] In the description of the present invention, it should be understood that the numerical labels before the steps do not identify the order in which the steps are executed, but are only used to facilitate the description of the present invention and to distinguish each step, and therefore should not be understood as a limitation of the present invention.

[0030] The following is an explanation of the terms involved in the present invention:

[0031] Text style: the inherent characteristic information of a text, such as the writing style, word choice, pauses, etc. (non-typesetting information).

[0032] Red-headed documents: formatted official documents of government and public institutions, usually with obvious red-headed logo, and may not have standardized format information.

[0033] Red-head mark: a distinctive mark that can identify red-head documents, including specific character strings, specific layout information, and specific graphic mark information in red or other colors.

[0034] Electronic official documents: electronic official documents of government or enterprises and institutions.

[0035] Figure 1 The following schematically shows an environmental application diagram of a text category recognition method based on text style according to an embodiment of the present invention.

[0036] In an exemplary embodiment, the text style-based text category recognition method can be applied to a computer device 2. The computer device 2 can be a PC (Personal Computer), a mobile phone, a tablet computer, a laptop computer, a virtual host, etc., or a rack server, a blade server, a tower server, or a cabinet server (including a standalone server or a server cluster consisting of multiple servers).

[0037] The computer device 2 can be connected to other computer devices 6 via the network 4 to obtain the text to be detected from the other computer devices.

[0038] In an exemplary embodiment, network 4 includes various network devices, such as routers, switches, multiplexers, hubs, modems, bridges, repeaters, firewalls, proxy devices, and / or the like. Network 4 may include physical links, such as coaxial cable links, twisted pair cable links, fiber optic links, combinations thereof, and the like. Network 4 may also include wireless links, such as cellular links, satellite links, Wi-Fi links, and the like.

[0039] In an exemplary embodiment, the other computer device 6 may be a mobile terminal such as a mobile phone or other computing devices.

[0040] The present invention is used to detect and identify documents that do not have obvious official document format features based on text style, and correctly identify whether it is an official document. For example, artificial intelligence technology is used to perform text style detection based on artificial intelligence technology on electronic official documents that do not have obvious red-headed marks. Based on the writing style, word usage habits and other information of the target class file (such as red-headed documents), a text style representation constrained by content is generated. The electronic official document files that hit the specified style category can be judged as the target class file, thereby improving the recognition ability of non-standard formats such as red-headed documents in the data security industry (including confidentiality business) and improving data leakage detection capabilities. One or more embodiments will be provided below to specifically introduce the text category recognition solution based on text style.

[0041] Example 1

[0042] Figure 2 The flowchart of the text category recognition method based on text style according to the first embodiment of the present invention is schematically shown. It should be noted that the following exemplary description is made with the computer device 2 as the execution subject, as follows:

[0043] like Figure 2 As shown, the text category identification method based on text style may include steps S200 to S206, wherein:

[0044] Step S200: Perform word segmentation on the text to be detected to obtain a target number of word segments.

[0045] The text to be detected can be official document - type text (electronic text) for enterprises and institutions.

[0046] After obtaining the text to be detected, the computer device 2 can perform word segmentation on each sentence of the text to be detected through a word segmentation tool (such as ICTCLAS word segmenter) to obtain a target number of word segments corresponding to the text to be detected.

[0047] In some embodiments, the computer device 2 can also have a pre - configured stop - word library, which includes multiple stop words (such as "in", "also", "of", "it", "for", etc.). The computer device 2 can extract multiple target word segments that do not include stop words from the multiple word segments obtained after word segmentation according to the stop - word library, and perform a deduplication operation on the multiple target word segments to obtain the target number of word segments.

[0048] Step S202: Perform vector representation on each of the target number of word segments to obtain a target number of feature vectors.

[0049] The computer device 2 can perform named - entity recognition on each word segment among the target number of word segments to obtain the multiple named entities, where each word segment corresponds to at least one named entity. The named - entity recognition (Named Entity Recognition, abbreviated as NER), also known as "proper - name recognition", is used to identify entities with specific meanings in the text, mainly including person names, place names, organization names, proper nouns, etc.

[0050] The computer device 2 can also perform vector representation on each word segment according to at least one named entity corresponding to the word segment to obtain a target number of feature vectors. Among them, in this embodiment, a pre - trained vector machine such as word2vec or BERT can be used to obtain the target number of feature vectors of the target number of word segments. Each word segment corresponds to a feature vector.

[0051] Step S204: Input the target number of feature vectors into one or more trained style classification networks to obtain a style representation vector. The one or more style classification networks are used to extract the style features of the text to be detected based on the target number of feature vectors and convert the style features into the style representation vector.

[0052] Exemplarily, each style classification network is a pre-trained classification network; each style classification network can obtain the corresponding style features of the text to be detected based on the target number of feature vectors. After obtaining the style features of the text to be detected, each style classification network can vectorize the style features to obtain the style representation vector.

[0053] In an exemplary embodiment, the style representation vector includes a first style representation vector and a second style representation vector; the one or more style classification networks include a vocabulary style classification network and another style classification network, wherein the vocabulary style classification network is a bidirectional long short-term memory network and the other style classification network is a unidirectional long short-term memory network. Figure 3 As shown, the step S204 may also include steps S300 to S302, wherein: in step S300, the target number of feature vectors are sequentially input into the bidirectional long short-term memory network to obtain the first style representation vector; and in step S302, the target number of feature vectors are sequentially input into the unidirectional long short-term memory network to obtain the second style representation vector. In this embodiment, the vocabulary style classification network is used to identify the characteristics of each segmentation itself to accurately obtain the vocabulary style in the entire text. In order to more accurately identify the vocabulary style in the text. In this embodiment, the vocabulary style classification network is a bidirectional long short-term memory network, which can accurately capture the semantics of the segmentation, thereby improving the accuracy of vocabulary style recognition. The first style representation vector is a vocabulary style representation vector. The other style classification network is used to identify other features of each segmentation (each segmentation position feature) in addition to its own features, so as to accurately obtain other styles in the entire text (such as the collocation of related words, the position where special words appear, etc.). In order to more accurately identify other styles in the text to be detected, in this embodiment, the other style classification network is a unidirectional long short-term memory network. Since the unidirectional long short-term memory network can better capture the dependency relationship between each word segmentation, it can improve the recognition accuracy of other styles (such as the position style of each word segmentation).

[0054] Step S206: Input the target number of feature vectors into the trained content classification network to obtain a target class classification vector; the content classification network is used to extract content features of the text to be detected based on the target number of feature vectors, and convert the content features into the target class classification vector.

[0055] Exemplarily, the content classification network is a pre-trained classification network; the content classification network can extract the content features of the text to be detected based on the target number of feature vectors. After obtaining the content features of the text to be detected, the content classification network can vectorize the style features to obtain the style representation vector.

[0056] In this embodiment, the content classification network may be a CNN (Convolutional Neural Networks), such as a convolution-pooling structure, which may have one or more layers depending on the data situation.

[0057] The vector matrix formed by the target number of feature vectors is convolved and pooled by CNN to obtain the target class classification vector.

[0058] Step S208 : judging whether the text to be detected is a target class text according to the style representation vector and the target class classification vector.

[0059] In an exemplary embodiment, the target text may be a red-headed document. This red-headed document includes documents with red-headed characteristics (e.g., a special mark above the main text) and documents without red-headed characteristics (e.g., official documents without a special mark above the main text and with the same layout style as ordinary documents).

[0060] The style representation vector and target class classification vector of the text to be detected are obtained respectively through one or more style classification networks and content classification networks, and whether the text to be detected is a target class text is determined based on the style representation vector and the target class classification vector. In an embodiment of the invention, a text style representation constrained by content is generated based on the writing style, word usage habits and other information of the official document, and the electronic official document file that hits the specified style category can be judged as an official document. The embodiment of the present invention makes it possible to accurately identify the specific official document text category of the text to be detected even when the specific characters are not prominent or there are no prominent marks, thereby improving the recognition efficiency and recognition accuracy of the text to be detected.

[0061] It should be noted that the embodiment of the present invention is different from classification based on specific article content, and is also different from using SVM (Support Vector Machine) machine learning algorithm. Instead, it uses a neural network algorithm for style detection (non-text content related classification). When learning text representation, it includes using paragraph vectors or document vectors as the representation of official documents and then performing neural network processing. This representation method carries more generalized language style information. In comparison, the embodiment of the present invention is based on artificial intelligence technology, which can achieve broader generalization capabilities with higher accuracy, improve the applicability of the software, and increase data security protection capabilities.

[0062] In order to further improve the recognition accuracy of target text, this embodiment provides two solutions, as follows:

[0063] First, as Figure 4 As shown, the one or more style classification networks and the content classification network share a fully connected classification structure, which includes a fully connected layer and a classification layer. Step S208 may also include steps S400 to S402, wherein: Step S400 concatenates the first style representation vector, the second style representation vector, and the target class classification vector using an array concatenation function to obtain a target vector; and Step S402 inputs the target vector into the fully connected layer and passes it through the classification layer to obtain a confidence level that the text to be detected is the target class text. The array concatenation function may be a Concat function. In this embodiment, based on the Concat function, the first style representation vector, the second style representation vector, and the target class classification vector may be concatenated to obtain the target vector. The fully connected layer is a fully connected neural network (FCN) in a deep neural network. The FCN transforms the dimension of the concatenated target vector, facilitating the classification layer (such as a sigmoid, relu, or softmax layer) to determine the category of the target vector and output a confidence score that the text to be detected is the target class text. If the confidence score is greater than a preset threshold, the text to be detected is the target class text.

[0064] Second, if Figure 5As shown, the one or more style classification networks and the content classification network share a fully connected classification structure, which includes a fully connected layer and a classification layer. Step S208 may also include steps S500 to S502, wherein: Step S500, the first style representation vector, the second style representation vector, and the target class classification vector are fused using the vector mean method to obtain a target vector; wherein, in the vector mean fusion operation, the weight of the target class classification vector is lower than the weight of the first style representation vector and the weight of the second style representation vector; Step S502, the target vector is input into the fully connected layer and passed through the classification layer to obtain the confidence that the text to be detected is the target class text. The vector mean method is a method for calculating the mean of two or more vectors. When fusing the first style representation vector, the second style representation vector, and the target class classification vector, the computer device 2 can generate the fused target vector based on the weight values ​​of each vector. The fused target vector has a vector with more feature dimensions. The FCN can transform the fused target vector to facilitate the classification layer to determine the category of the target vector and output the confidence level that the text to be detected is the target class text. If the confidence level is greater than a pre-set threshold, the text to be detected is the target class text.

[0065] In an exemplary embodiment, as Figure 6As shown, the text category recognition method based on text style also includes the steps of pre-training the one or more style classification networks to be trained and the content classification network to be trained: step S600, obtaining multiple sample texts, each sample text carries a target class tag or other tags; the target class tag indicates that the corresponding sample text is a target class text, and the other tags indicate that the corresponding sample text is not a target class text; step S602, performing word segmentation and vectorization operations on each sample text to obtain multiple sample feature vectors of each sample text; step S604, inputting the multiple sample feature vectors of each sample text into the style classification network to be trained, and obtaining a sample style representation vector of each sample text; the style classification network to be trained is used to train the corresponding style classification network; step S606, inputting the multiple sample feature vectors of each sample text into the style classification network to be trained to obtain the corresponding style classification network; The sample feature vector is input into the content classification network to be trained to obtain the sample official document classification vector of each sample text; the content classification network to be trained is used to train to obtain the content classification network; step S608, sample feature fusion is performed on the sample style representation vector of each sample text and the corresponding sample official document classification vector to obtain the fused feature vector of each sample text, and the sample text style representation constrained by the content of each sample text is obtained based on the fused feature vector of each sample text; and step S610, loss calculation is performed based on the sample text style representation of each sample text and the target class label or other label carried by each sample text to adjust the network parameters of the style classification network to be trained and the network parameters of the content classification network to be trained, so as to obtain the style classification network and the content classification network.

[0066] In the above embodiment, using official documents as the target document type, training samples consisting of official documents or similar electronic documents can be obtained for AI training to obtain a model of the specified style information of official documents. The trained model can then be used to determine whether a new unknown electronic document is an official document. This trained model can improve the efficiency and accuracy of official document recognition.

[0067] For ease of understanding, this embodiment also provides an overall flow chart of text category recognition based on text style, such as Figure 7 As shown; the detection flow chart of the text to be detected is as follows Figure 8 As shown; Model training flow chart, as Figure 9 shown.

[0068] like Figure 8 As shown, the detection process of the text to be detected can be as follows:

[0069] 1) Get the text to be detected;

[0070] 2) Represent the text to be detected in a form that can be understood by the computer;

[0071] 3) The represented text to be detected is fed into an artificial intelligence program that has been loaded with a style classification model;

[0072] 4) Feature data is fed into Figure 8 The style classification model is vectorized to obtain the feature vector;

[0073] 5) Obtaining a style representation vector based on the feature vector through a vocabulary style classification network and other style classification networks;

[0074] 6) Filtering through the content classification network based on the feature vector to obtain the document classification vector information;

[0075] 7) The vector information obtained in 5) and 6) is feature-fused and passed through a fully connected layer and a classification layer (e.g., sigmoid / relu / softmax) to obtain a confidence score.

[0076] 8) Determine whether the text to be detected is a red-headed official document based on the obtained score and a preset threshold.

[0077] like Figure 9 As shown, the model training process can be as follows:

[0078] 1) Collect a certain number of legally available electronic documents as training samples and mark whether the documents are official documents.

[0079] 2) Represent the training samples in a form that the computer can understand;

[0080] 3) Inputting the well-represented training samples into a machine learning program (broadly speaking, including narrow machine learning and artificial intelligence programs such as deep learning);

[0081] 4) Feature data is fed into Figure 8 The neural network model is vectorized to obtain the feature vector;

[0082] 5) Obtaining a style representation vector based on the feature vector through a vocabulary style classification network and other style classification networks;

[0083] 6) Filtering through the content classification network based on the feature vector to obtain the document classification vector information;

[0084] 7) The vector information obtained in steps 5) and 6) is fused through a fully connected layer to obtain a content-constrained text style representation in a larger space. The loss is calculated based on the labels in the sample, and the model approximates the results of manual annotation.

[0085] 8) Saving the approximated neural network parameters as a style classification model;

[0086] 9) Obtaining a style classification model for the type of documents represented by the training samples;

[0087] 10) Save the style classification model for future use.

[0088] Example 2

[0089] Figure 10 A block diagram schematically illustrates a text style-based text category recognition system according to a second embodiment of the present invention. This text style-based text category recognition system can be divided into one or more program modules, one or more of which are stored in a storage medium and executed by one or more processors to implement the embodiment of the present invention. A program module as referred to in this embodiment of the present invention refers to a series of computer program instruction segments that can perform specific functions. The following description will specifically introduce the functions of each program module in this embodiment.

[0090] like Figure 10 As shown, the text style-based text category recognition system 1000 may include a monitoring module 1001, a representation module 1002, an input module 1003, an output module 1004, and a judgment module 1005, wherein:

[0091] The word segmentation module 1001 is used to perform word segmentation on the text to be detected to obtain a target number of word segments, where the target number is a positive integer.

[0092] The representation module 1002 performs vector representation on each of the target number of words to obtain a feature vector of the target number.

[0093] The input module 1003 inputs the target number of feature vectors into one or more trained style classification networks to obtain a style representation vector.

[0094] The output module 1004 inputs the feature vector according to the target quantity into the trained content classification network to obtain the target class classification vector.

[0095] The judgment module 1005 judges whether the text to be detected is a target class text based on the style representation vector and the target class classification vector.

[0096] In an exemplary embodiment, the style representation vector includes a first style representation vector and a second style representation vector, the first style representation vector corresponds to the vocabulary style of the text to be detected, and the second style representation vector corresponds to other styles of the text to be detected; the one or more style classification networks include a vocabulary style classification network and other style classification networks, wherein the vocabulary style classification network is a bidirectional long short-term memory network, and the other style classification networks are unidirectional long short-term memory networks.

[0097] In an exemplary embodiment, the input module 1003 is further used to: input the target number of feature vectors into the bidirectional long short-term memory network according to the order of the front and back positions of the word segments corresponding to each feature vector in the text to be detected, so as to obtain the first style representation vector; and input the target number of feature vectors into the unidirectional long short-term memory network according to the order of the front and back positions of the word segments corresponding to each feature vector in the text to be detected, so as to obtain the second style representation vector.

[0098] In an exemplary embodiment, the one or more style classification networks and the content classification network share a fully connected classification structure, and the fully connected classification structure includes a fully connected layer and a classification layer; the judgment module 1005 is also used to: splice the first style representation vector, the second style representation vector and the target class classification vector through an array splicing function to obtain a target vector; and input the target vector into the fully connected layer and through the classification layer to obtain the confidence that the text to be detected is the target class text.

[0099] In an exemplary embodiment, the one or more style classification networks and the content classification network share a fully connected classification structure, and the fully connected classification structure includes a fully connected layer and a classification layer; the judgment module 1005 is also used to: fuse the first style representation vector, the second style representation vector and the target class classification vector through the vector mean method to obtain a target vector; wherein, in the vector mean method fusion operation, the weight of the target class classification vector is lower than the weight of the first style representation vector and the weight of the second style representation vector; the target vector is input into the fully connected layer and passes through the classification layer to obtain the confidence that the text to be detected is the target class text.

[0100] In an exemplary embodiment, the target text is red-headed text.

[0101] In an exemplary embodiment, the method further includes the step of pre-training to obtain the one or more style classification networks and the content classification network: obtaining a plurality of sample texts, each sample text carrying a target class tag or other tags; the target class tag indicates that the corresponding sample text is a target class text, and the other tags indicate that the corresponding sample text is not a target class text; performing word segmentation and vectorization operations on each sample text to obtain a plurality of sample feature vectors of each sample text; inputting the plurality of sample feature vectors of each sample text into the style classification network to be trained to obtain a sample style representation vector of each sample text; the style classification network to be trained is used to train to obtain a corresponding style classification network; inputting the plurality of sample feature vectors of each sample text into the style classification network to be trained In the content classification network, a sample official document classification vector of each sample text is obtained; the content classification network to be trained is used to train to obtain the content classification network; sample feature fusion is performed on the sample style representation vector of each sample text and the corresponding sample official document classification vector to obtain a fused feature vector of each sample text, and a sample text style representation constrained by content of each sample text is obtained based on the fused feature vector of each sample text; and loss calculation is performed based on the sample text style representation of each sample text and the target class label or other label carried by each sample text to adjust the network parameters of the style classification network to be trained and the network parameters of the content classification network to be trained to obtain the style classification network and the content classification network.

[0102] Example 3

[0103] Figure 11 The hardware architecture diagram of a computer device 2 suitable for implementing a text category recognition method based on text style according to the third embodiment of the present invention is schematically shown. In this embodiment, the computer device 2 is a device that can automatically perform numerical calculations and / or information processing according to pre-set or stored instructions. For example, it can be a smart phone, a tablet computer, a laptop computer, a desktop computer, a rack server, a blade server, a tower server or a cabinet server (including an independent server, or a server cluster composed of multiple servers), a gateway, etc. Figure 10 As shown, the computer device 2 includes at least but not limited to: a memory 1110, a processor 1120, and a network interface 1130 that can be interconnected via a system bus.

[0104] The memory 1110 includes at least one type of computer-readable storage medium, including flash memory, a hard disk, a multimedia card, a card-type memory (e.g., SD or DX memory), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic storage, a magnetic disk, an optical disk, etc. In some embodiments, the memory 1110 may be an internal storage module of the computer device 2, such as the hard disk or memory of the computer device 2. In other embodiments, the memory 1110 may also be an external storage device of the computer device 2, such as a plug-in hard disk equipped on the computer device 2, a Smart Media Card (SMC), a Secure Digital (SD) card, a Flash Card, etc. Of course, the memory 1110 may also include both the internal storage module of the computer device 2 and its external storage device. In this embodiment, the memory 1110 is generally used to store the operating system and various application software installed on the computer device 2, such as the program code of the text category recognition method based on text style. In addition, the memory 1110 can also be used to temporarily store various types of data that have been output or are to be output.

[0105] In some embodiments, the processor 1120 may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other data processing chip. The processor 1120 is generally used to control the overall operation of the computer device 2, such as performing control and processing related to data interaction or communication with the computer device 2. In this embodiment, the processor 1120 is used to execute program code stored in the memory 1110 or process data.

[0106] The network interface 1130 may include a wireless network interface or a wired network interface. The network interface 1130 is generally used to establish a communication link between the computer device 2 and other computer devices. For example, the network interface 1130 is used to connect the computer device 2 to an external terminal via a network, and to establish a data transmission channel and a communication link between the computer device 2 and the external terminal. The network can be a wireless or wired network such as an intranet, the Internet, the Global System of Mobile Communications (GSM), Wideband Code Division Multiple Access (WCDMA), a 4G network, a 5G network, Bluetooth, or Wi-Fi.

[0107] It should be pointed out that Figure 11 Only a computer device having components 1110 - 1130 is shown, but it should be understood that implementing all of the shown components is not a requirement, and more or fewer components may alternatively be implemented.

[0108] In this embodiment, the text style-based text category recognition method stored in the memory 1110 can also be divided into one or more program modules and executed by one or more processors (processor 1120 in this embodiment) to complete the embodiment of the present invention.

[0109] Example 4

[0110] The present invention also provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the steps of the text category recognition method based on text style in the embodiment are implemented.

[0111] In this embodiment, the computer-readable storage medium includes flash memory, hard disk, multimedia card, card-type memory (e.g., SD or DX memory), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, magnetic disk, optical disk, etc. In some embodiments, the computer-readable storage medium may be an internal storage unit of a computer device, such as the hard disk or memory of the computer device. In other embodiments, the computer-readable storage medium may also be an external storage device of the computer device, such as a plug-in hard disk equipped with the computer device, a Smart Media Card (SMC), a Secure Digital (SD) card, a flash memory card, etc. Of course, the computer-readable storage medium may also include both the internal storage unit of the computer device and its external storage device. In this embodiment, the computer-readable storage medium is generally used to store the operating system and various application software installed on the computer device, such as the program code of the text category recognition method based on text style in the embodiment. In addition, the computer-readable storage medium may also be used to temporarily store various types of data that have been output or are about to be output.

[0112] Obviously, those skilled in the art should understand that the various modules or steps of the above-mentioned embodiments of the present invention can be implemented using a general-purpose computing device, they can be concentrated on a single computing device, or distributed across a network composed of multiple computing devices. Alternatively, they can be implemented using program code executable by the computing device, so that they can be stored in a storage device and executed by the computing device. In some cases, the steps shown or described can be performed in a different order than herein, or they can be made into separate integrated circuit modules, or multiple modules or steps can be made into a single integrated circuit module for implementation. Thus, the embodiments of the present invention are not limited to any specific combination of hardware and software.

[0113] The above are only preferred embodiments of the present invention and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made using the contents of the present invention description and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.

Claims

1. A text category recognition method based on text style, characterized in that: include: Perform word segmentation on the text to be detected to obtain the target number of word segments; Performing vector representation on each of the target number of segmented words to obtain feature vectors of the target number; Inputting the target number of feature vectors into one or more trained style classification networks to obtain style representation vectors; the one or more style classification networks are used to extract style features of the to-be-detected text based on the target number of feature vectors and convert the style features into the style representation vectors; Inputting the target number of feature vectors into a trained content classification network to obtain a target class classification vector; the content classification network is used to extract content features of the text to be detected based on the target number of feature vectors and convert the content features into the target class classification vector; and Determining whether the text to be detected is a target class text based on the style representation vector and the target class classification vector; The one or more style classification networks and the content classification network share a fully connected classification structure, and the fully connected classification structure includes a fully connected layer and a classification layer; The step of determining whether the text to be detected is a target class text based on the style representation vector and the target class classification vector includes: splicing the first style representation vector, the second style representation vector, and the target class classification vector using an array splicing function to obtain a target vector; the first style representation vector corresponds to the vocabulary style of the text to be detected, and the second style representation vector corresponds to other styles of the text to be detected; and The target vector is input into the fully connected layer and passed through the classification layer to obtain the confidence that the text to be detected is the target class text.

2. The text category recognition method based on text style according to claim 1, characterized in that: The style representation vector includes a first style representation vector and a second style representation vector; the one or more style classification networks include a lexical style classification network and another style classification network, wherein the lexical style classification network is a bidirectional long short-term memory network, and the other style classification network is a unidirectional long short-term memory network; The step of inputting the target number of feature vectors into one or more trained style classification networks to obtain a style representation vector includes: Inputting the target number of feature vectors into the bidirectional long short-term memory network according to the order of the word segments corresponding to each feature vector in the text to be detected, to obtain the first style representation vector; and According to the front-to-back position order of the word segments corresponding to the respective feature vectors in the to-be-detected text, the target number of feature vectors are input into the unidirectional long short-term memory network to obtain the second style representation vector.

3. The text category recognition method based on text style according to claim 2, characterized in that: The one or more style classification networks and the content classification network share a fully connected classification structure, wherein the fully connected classification structure includes a fully connected layer and a classification layer; The step of determining whether the text to be detected is a target class text based on the style representation vector and the target class classification vector includes: fusing the first style representation vector, the second style representation vector, and the target class classification vector using a vector mean method to obtain a target vector; wherein, in the vector mean method fusion operation, a weight of the target class classification vector is lower than a weight of the first style representation vector and a weight of the second style representation vector; and The target vector is input into the fully connected layer and passed through the classification layer to obtain the confidence that the text to be detected is the target class text.

4. The text category recognition method based on text style according to any one of claims 1 to 3, characterized in that: The method further comprises the step of pre-training to obtain the one or more style classification networks and the content classification network: Acquire multiple sample texts, each sample text carries a target class tag or other tags; the target class tag indicates that the corresponding sample text is a target class text, and the other tags indicate that the corresponding sample text is not a target class text; Performing word segmentation and vectorization operations on each sample text to obtain multiple sample feature vectors of each sample text; Inputting the multiple sample feature vectors of each sample text into the style classification network to be trained to obtain a sample style representation vector of each sample text; the style classification network to be trained is used to train a corresponding style classification network; Inputting the plurality of sample feature vectors of each sample text into the to-be-trained content classification network to obtain a sample document classification vector of each sample text; the to-be-trained content classification network is used to train the content classification network; Performing sample feature fusion on the sample style representation vector of each sample text and the corresponding sample official document classification vector to obtain a fused feature vector of each sample text, wherein the sample feature fusion method includes a fusion method through data splicing and a fusion method through a vector mean method; and obtaining a sample text style representation constrained by content for each sample text based on the fused feature vector of each sample text; and Based on the sample text style representation of each sample text and the target class label or other label carried by each sample text, loss calculation is performed to adjust the network parameters of the style classification network to be trained and the network parameters of the content classification network to be trained to obtain the style classification network and the content classification network.

5. A text category recognition system based on text style, characterized in that: include: The word segmentation module is used to perform word segmentation on the text to be detected to obtain the target number of words; A representation module is used to perform vector representation on the target number of word segments to obtain feature vectors of the target number; An input module is configured to input the target number of feature vectors into one or more trained style classification networks to obtain style representation vectors; the one or more style classification networks are configured to extract style features of the text to be detected based on the target number of feature vectors and convert the style features into the style representation vectors; An output module is configured to input the target number of feature vectors into a trained content classification network to obtain a target class classification vector; the content classification network is configured to extract content features of the to-be-detected text based on the target number of feature vectors and convert the content features into the target class classification vector; and A judgment module, configured to judge whether the text to be detected is a target class text based on the style representation vector and the target class classification vector; The one or more style classification networks and the content classification network share a fully connected classification structure, wherein the fully connected classification structure includes a fully connected layer and a classification layer; the judgment module is further configured to: splicing the first style representation vector, the second style representation vector, and the target class classification vector using an array concatenation function to obtain a target vector; the first style representation vector corresponds to the vocabulary style of the text to be detected, and the second style representation vector corresponds to other styles of the text to be detected; and The target vector is input into the fully connected layer and passed through the classification layer to obtain the confidence that the text to be detected is the target class text.

6. The text category recognition system based on text style according to claim 5, characterized in that: The style representation vector includes a first style representation vector and a second style representation vector; the one or more style classification networks include a lexical style classification network and another style classification network, wherein the lexical style classification network is a bidirectional long short-term memory network and the other style classification network is a unidirectional long short-term memory network; the input module is further configured to: Inputting the target number of feature vectors into the bidirectional long short-term memory network according to the order of the word segments corresponding to each feature vector in the text to be detected, to obtain the first style representation vector; and According to the front-to-back position order of the word segments corresponding to the respective feature vectors in the to-be-detected text, the target number of feature vectors are input into the unidirectional long short-term memory network to obtain the second style representation vector.

7. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, it is used to implement the steps of the text category recognition method based on text style according to any one of claims 1 to 4.

8. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, and the computer program can be executed by at least one processor to enable the at least one processor to perform the steps of the text category recognition method based on text style according to any one of claims 1 to 4.

Citation Information

Patent Citations

  • Bilinear neural network false news detection method and system based on style guidance

    CN110210016A

  • Multi-style text generation method and device, equipment and readable storage medium

    CN112364602A