CN111539212A - Text information processing method and device, storage medium and electronic equipment - Google Patents

Text information processing method and device, storage medium and electronic equipment Download PDF

Info

Publication number
CN111539212A
CN111539212A CN202010286959.1A CN202010286959A CN111539212A CN 111539212 A CN111539212 A CN 111539212A CN 202010286959 A CN202010286959 A CN 202010286959A CN 111539212 A CN111539212 A CN 111539212A
Authority
CN
China
Prior art keywords
text information
text
emotion
determining
vector
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202010286959.1A
Other languages
Chinese (zh)
Inventor
刘澍
刘智静
周宇超
康斌
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Tencent Technology Wuhan Co Ltd
Original Assignee
Tencent Technology Wuhan Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Tencent Technology Wuhan Co Ltd filed Critical Tencent Technology Wuhan Co Ltd
Priority to CN202010286959.1A priority Critical patent/CN111539212A/en
Publication of CN111539212A publication Critical patent/CN111539212A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/30Semantic analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/33Querying
    • G06F16/3331Query processing
    • G06F16/334Query execution
    • G06F16/3346Query execution using probabilistic model
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/35Clustering; Classification
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V20/00Scenes; Scene-specific elements
    • G06V20/40Scenes; Scene-specific elements in video content
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V30/00Character recognition; Recognising digital ink; Document-oriented image-based pattern recognition
    • G06V30/40Document-oriented image-based pattern recognition
    • G06V30/41Analysis of document content
    • G06V30/413Classification of content, e.g. text, photographs or tables
    • GPHYSICS
    • G10MUSICAL INSTRUMENTS; ACOUSTICS
    • G10LSPEECH ANALYSIS TECHNIQUES OR SPEECH SYNTHESIS; SPEECH RECOGNITION; SPEECH OR VOICE PROCESSING TECHNIQUES; SPEECH OR AUDIO CODING OR DECODING
    • G10L15/00Speech recognition
    • G10L15/26Speech to text systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V30/00Character recognition; Recognising digital ink; Document-oriented image-based pattern recognition
    • G06V30/10Character recognition

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • Computational Linguistics (AREA)
  • Multimedia (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Health & Medical Sciences (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Artificial Intelligence (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • General Health & Medical Sciences (AREA)
  • Probability & Statistics with Applications (AREA)
  • Human Computer Interaction (AREA)
  • Acoustics & Sound (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The embodiment of the application discloses a text information processing method and device, a storage medium and electronic equipment. The text information processing method comprises the following steps: when the text information has the emotion words, carrying out quantitative processing on the emotion words in the text information according to a preset rule, and determining the target emotion type of the text information according to a quantitative processing result; when the emotional words do not exist in the text information, detecting the text length of the text information; if the text length is smaller than or equal to a preset value, determining the probability of the text information corresponding to a plurality of different sample emotion categories according to the sentence vector of the text information, and determining the target emotion category of the text information from the plurality of different sample emotion categories according to the probability; and if the text length is larger than the preset value, determining the target emotion category of the text information according to the embedded vector of the specified type of the text information. In the scheme, the text information is processed according to the logic architecture with the complexity of calculation from easy to difficult, and the processing speed and the processing effect of the text information are improved.

Description

Text information processing method and device, storage medium and electronic equipment
Technical Field
The present application relates to the field of information processing technologies, and in particular, to a text information processing method and apparatus, a storage medium, and an electronic device.
Background
With the development of the internet and the mobile communication network, and with the rapid development of the processing capability and the storage capability of the electronic device, a large number of application programs are rapidly spread and used, and especially, the application programs can be used for users to release media information such as texts, pictures, sounds or videos.
The text sentiment analysis is also called opinion mining, tendency analysis and the like, and particularly relates to a process for analyzing, processing, inducing and reasoning subjective texts with sentiment colors. A great deal of user-participated valuable review information for such things as people, events, products, etc. is generated on the internet. The comment information expresses various emotional colors and emotional tendencies of people, such as happiness, anger, grief, music and criticism, praise and the like. Therefore, by performing emotion analysis on the media information, the analysis result can provide a high reference value for decision making in application scenes such as information auditing, user portrait portrayal, content recommendation and the like.
Disclosure of Invention
The embodiment of the application provides a text information processing method and device, a storage medium and electronic equipment, which can improve the processing speed and the processing effect of text information.
The embodiment of the application provides a text information processing method, which comprises the following steps:
acquiring text information to be processed;
when the text information has emotion words, carrying out quantitative processing on the emotion words in the text information according to a preset rule, and determining the target emotion type of the text information according to a quantitative processing result;
when the emotional words do not exist in the text information, detecting the text length of the text information;
if the text length is smaller than or equal to a preset value, determining the probability of the text information corresponding to a plurality of different sample emotion categories according to the sentence vector of the text information, and determining the target emotion category of the text information from the plurality of different sample emotion categories according to the probability;
and if the text length is larger than the preset value, determining the target emotion category of the text information according to the embedded vector of the type specified by the text information, wherein the embedded vectors of different types are obtained based on the characteristics of the text information on different dimensions and the correlation among the characteristics.
Correspondingly, an embodiment of the present application further provides a text information processing apparatus, including:
the acquisition unit is used for acquiring text information to be processed;
a first determining unit, configured to determine, when a target candidate text matching the text information exists in a candidate text set, an emotion category corresponding to the target candidate text as a target emotion category of the text information;
the length detection unit is used for detecting the text length of the text information when a target candidate text matched with the text information does not exist in the candidate text set;
the second determining unit is used for determining the probability of the text information corresponding to a plurality of different sample emotion categories according to the sentence vector of the text information if the text length is smaller than or equal to a preset value, and determining the target emotion category of the text information from the plurality of different sample emotion categories according to the probability;
and the third determining unit is used for determining the target emotion category of the text information according to the embedded vector of the type specified by the text information if the text length is larger than the preset value, wherein the embedded vectors of different types are obtained based on the characteristics of the text information in different dimensions and the correlation among the characteristics.
Correspondingly, the embodiment of the application also provides a computer-readable storage medium, and the storage medium stores a plurality of instructions, and the instructions are suitable for being loaded by a processor to execute the text information processing method.
Correspondingly, the embodiment of the present application further provides an electronic device, which includes a memory, a processor and a computer program stored in the memory and executable on the processor, and the processor implements the text information processing method as described above when executing the program.
In the embodiment of the application, when the text information has the emotion words, the emotion words in the text information are quantized according to a preset rule, and the target emotion category of the text information is determined according to a quantization processing result; when the emotional words do not exist in the text information, detecting the text length of the text information; if the text length is smaller than or equal to a preset value, determining the probability of the text information corresponding to a plurality of different sample emotion categories according to the sentence vector of the text information, and determining the target emotion category of the text information from the plurality of different sample emotion categories according to the probability; and if the text length is larger than the preset value, determining the target emotion category of the text information according to the embedded vector of the specified type of the text information. In the scheme, the text information is processed according to the logic architecture with the complexity of calculation from easy to difficult, and the processing speed and the processing effect of the text information are improved.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the description of the embodiments are briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.
Fig. 1 is a schematic flowchart of a text information processing method according to an embodiment of the present application.
Fig. 2 is a schematic structural diagram of a TF-ID model provided in an embodiment of the present application.
Fig. 3 is a schematic structural diagram of a Text CNN model provided in an embodiment of the present application.
Fig. 4 is a schematic structural diagram of the BERT model provided in the embodiment of the present application.
Fig. 5 is a schematic diagram of a model online deployment process provided in an embodiment of the present application.
FIG. 6 is a schematic diagram of a model architecture of text emotion analysis provided in an embodiment of the present application.
Fig. 7 is a schematic structural diagram of a text information processing apparatus according to an embodiment of the present application.
Fig. 8 is a schematic structural diagram of an electronic device provided in an embodiment of the present application.
Fig. 9 is a schematic structural diagram of a server according to an embodiment of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
The embodiment of the application provides a text information processing method and device, a storage medium and electronic equipment. The text information processing device can be integrated into an electronic device having a storage unit and a microprocessor and having an arithmetic capability, such as a tablet pc (personal computer) or a mobile phone.
Artificial Intelligence (AI) is a theory, method, technique and application system that uses a digital computer or a machine controlled by a digital computer to simulate, extend and expand human Intelligence, to obtain knowledge and to use the knowledge to obtain the best results, so that the machine has the functions of perception, reasoning and decision making.
Natural Language Processing (NLP) is an important direction in the fields of computer science and artificial intelligence. It studies various theories and methods that enable efficient communication between humans and computers using natural language. Natural language processing is a science integrating linguistics, computer science and mathematics. Therefore, the research in this field will involve natural language, i.e. the language that people use everyday, so it is closely related to the research of linguistics. Natural language processing techniques typically include text processing, semantic understanding, and the like.
In the scheme, a large number of natural language processing technologies are adopted to understand and classify the text information and analyze the emotion expressed in the text information. According to the characteristics of different text processing algorithms or models, different text information is intelligently matched with a proper algorithm or model, and the text information is analyzed and processed in a targeted manner, so that the purpose of intelligently processing the text is achieved.
The following are detailed below. The numbers in the following examples are not intended to limit the order of preference of the examples. Referring to fig. 1, fig. 1 is a schematic flow chart of a text information processing method according to an embodiment of the present application. The specific flow of the text information processing method may be as follows:
101. and acquiring text information to be processed.
The text information may include different levels of text such as words, sentences, paragraphs, chapters, and the like. The text information may be obtained in real time or from a predetermined database.
Taking real-time acquisition as an example, when the content input by the user through the electronic device is text content, the text content can be directly acquired as text information to be processed.
When the input content is image content, the characters in the picture can be identified and extracted by utilizing an image identification technology, and the extracted characters are used as text information; or identifying the meaning expressed by the picture, and generating corresponding character expression according to the identified meaning so as to obtain text information.
When the input content is video content, the video content can be divided into image frames, characters in the images are identified through an image identification technology, and the extracted characters are used as text information; or identifying the meaning expressed by the picture, and generating corresponding character expression according to the identified meaning so as to obtain text information.
When the input content is voice, the voice can be converted into text content by using a voice recognition technology, so that text information is obtained.
102. When the text information has the emotion words, the emotion words in the text information are quantized according to a preset rule, and the target emotion category of the text information is determined according to the quantization processing result.
In this embodiment, the target emotion categories may include: positive (i.e., positive), negative (negative), and neutral. Specifically, to analyze whether a sentence is positive or negative, the simplest and most basic method is to find the emotional words in the sentence. The emotion words refer to words expressing emotion, which can be roughly classified into the following types: "happy", "angry", "sade", "happy", "tired", "terrorist", "scare", "hate", "frighten", "thinking", "quiet", "calm", "disappointing" and "excited". Positive emotion words such as: praise, good, magnificent, negative emotion words such as: bad, rotten, bad.
In the embodiment of the application, the emotional words are quantized, namely, the degree of the emotion on the expressed emotion is converted into a physical quantity which can be measured by using a numerical value. Specifically, modifiers or specific punctuations in the text for the emotion word may be digitized, and the emotion value of the emotion word in the text is determined according to the digitized value, so as to realize quantization of the emotion word. Modifiers may include words of degree (e.g., "very," "extremely," "normal"), negatives (e.g., "no"), punctuation of the degree (e.g., an exclamation point), and the like. Different values are given to different modifiers in advance, and corresponding calculation rules are formulated, so that the modifiers or specific punctuations of the emotional words can be digitized, and the emotional values obtained after the digitization are used as the quantitative processing results of the emotional words. In the embodiment, the target emotion category of the text information can be determined by performing quantization processing on the emotion words in the text information through the emotion dictionary. The specific algorithm equipment of the emotion dictionary can be as follows:
the first step is as follows: reading a text, and separating sentences of the text;
the second step is that: searching for emotion words for clauses, recording whether the emotion words are positive or negative, and positions;
the third step: searching the degree words before the emotion words, and stopping searching when the degree words are found; setting a weight value for the degree word, and multiplying the weight value by an emotion value;
the fourth step: searching negative words before the emotional words, and searching complete negative words, if the number of the negative words is an odd number, multiplying the negative words by-1, and if the negative words is an even number, multiplying the negative words by 1;
the fifth step: judging whether the end of the clause has an exclamation mark, if so, searching for an emotional word forward, and if so, obtaining a corresponding emotional value of + 2;
and a sixth step: calculating the emotion values of all the clauses of one comment, and recording the emotion values by using an array;
the seventh step: calculating and recording the emotion values of all comments;
eighth step: and calculating the positive emotion mean, the negative emotion mean, the positive emotion variance and the negative emotion variance of each comment by sentence division.
For example, the sentence "your practice leaves me very unsatisfied! ", where the positive emotion word is" happy ", the level word is" very ", the negative word is" not ", and a particular punctuation mark"! ", no negative emotion words. Assuming that the weighting value of "very" is set to 80%, it can be calculated that the positive emotion value of the sentence is 0, the negative emotion value is-2.8, and-2.8 is the result of the quantization process of the emotion words in the sentence, and it can be determined that the emotion classification of the text information is negative.
In some embodiments, before performing quantization processing on emotion words in the text information according to a preset rule, the following process may be further included:
(11) detecting the text information based on a sample word set, wherein the sample word set comprises sample words belonging to the same emotion category;
(12) when the text information is detected to have the content matched with the sample word set, determining the emotion category corresponding to the sample word set as the target category of the text information.
Specifically, the text may be matched with a sample word set corresponding to a blacklist word bank, a meaningless text rule, and the like according to a preset matching rule to match the corresponding sample word.
In some embodiments, before detecting the text information based on the sample word set, further comprising:
detecting the text information based on a preset text library;
and when a preset text which is the same as the text information exists in the preset text library, determining the emotion category associated with the preset text as the target emotion category of the text information.
Specifically, taking a media comment as an example, since a media website often has a user posting behavior, a latest analyzed comment can be stored in a preset text library, and a repeated comment is filtered by taking the comment in the preset text library as a reference, so as to reduce the prediction pressure of a subsequent model.
103. And when the emotional words do not exist in the text information, detecting the text length of the text information.
When the emotion words do not exist in the text information, the simple emotion dictionary representation mode cannot meet the requirement of processing the text information. At the moment, the emotion of the text information needs to be analyzed in a more intelligent mode. Because the text information has different lengths, if a complicated algorithm is adopted to analyze the text new information with shorter length, resources are wasted; if a simple algorithm is used to perform emotion analysis on a long text, a lot of useful information may be lost. Therefore, different algorithm models can be adopted for processing according to different text lengths, so that the purpose of saving resources is achieved while the accuracy is improved.
In specific implementation, when the text length of the text information is detected, single characters in the text information and connection relations among the characters can be detected specifically, and then the text length of the text is determined according to the connection relations among the characters.
104. And if the text length is less than or equal to a preset value, determining the probability of the text information corresponding to a plurality of different sample emotion categories according to the sentence vector of the text information, and determining the target emotion category of the text information from the plurality of different sample emotion categories according to the probability.
The preset value can be set according to actual requirements. If the text length is less than or equal to the predetermined value, it can be considered as a short text corpus, such as a phrase, a sentence, or several sentences. Specifically, a sentence or phrase may be extracted from the text information, and the extracted sentence or phrase may be converted into a numerical tensor to obtain a vector representation of the extracted sentence or phrase, i.e., a sentence vector (sensor vector). In extracting sentences or phrases, the text may be divided according to the positions of separators (e.g., punctuation marks, spaces, etc.) in the text information to extract individual sentences or phrases therefrom. It should be noted that a phrase can also be considered as a sentence with a shorter length. In this embodiment, when generating the vector representation of the sentence, first, a word segmentation process may be performed on each extracted sentence, then the vector representation of each word in the sentence is generated based on the word segmentation result, and finally, the vector representations of all the words in the sentence are added and averaged, and the obtained vector is used as the final vector representation of the sentence.
In the embodiment, because the short text is used, the distance between words in the text is short, and the position of the short text cannot have too large difference, so that the word group in the text is mainly concerned, and preprocessing operations such as punctuation removal, fine-grained stub (jieba) word segmentation, emoji emoticon removal and the like can be directly performed on the text without considering the correlation between the words. Then, a TF-IDF (term frequency-inverse text word frequency index) model can be adopted to score each word in the text according to the TF-IDF, and then the word vectors of each word in the text are weighted and averaged according to the score to obtain the final vector representation as the sentence vector of the text.
Due to the text structure characteristics of the short text corpus, the word group in the text is mainly concerned when the semantics are understood, so that the sample sentence vector with higher similarity can be matched based on the sentence vector expression of the text. That is, in some embodiments, when determining, according to a sentence vector of text information, probabilities of corresponding text information belonging to a plurality of different sample emotion categories, and determining, according to the probabilities, a target emotion category of the text information from the plurality of different sample emotion categories, the following process may be specifically included:
(21) calculating the similarity between the sentence vector and each sample sentence vector in the sample sentence vector set;
(22) determining a preset number of target sample sentence vectors from the sample sentence vector set according to the sequence of similarity from large to small;
(23) determining weighting information of sample emotion categories corresponding to each target sample sentence vector according to the similarity value;
(24) based on the weighting information, carrying out weighting processing on the sample emotion types corresponding to the target sample sentence vectors;
(25) and determining the target emotion type of the text information according to the weighting processing result.
Referring to fig. 2, the short text to be tested is converted into a sentence vector through the TF-IDF model, and a plurality of most similar sentences are selected from the pre-training corpus, so as to obtain "similarity" between the short text to be tested and the selected sentence and "emotion label" of the selected sentence (refer to label 1 and label 2 … … label n in fig. 2), and filter out sentences with too low similarity. And (3) weighting the first N (such as the first 10) sentences with higher similarity obtained by filtering by using the emotion labels with the similarity as the probability to obtain the final category probability.
For example, the test sentence "true happy today". The corpus training comprises: "happy" and emotion labeled positive, "true nausea" and emotion labeled negative, "true stick" and emotion labeled positive. Suppose that the similarity of the test short text and the three training corpora is 0.5, 0.2 and 0, respectively, and the sentences with lower similarity, namely 'true nausea' and 'your true bar', are filtered. The final prediction result of "true happy today" is: positive 0.5, negative 0, neutral 0, 1 after probabilistic: 0: 0. then, the predicted emotion type of the short text to be detected under the TF-IDF model can be predicted to be 'forward'.
In some embodiments, after determining the probability of the text information corresponding to the text information belonging to the plurality of different sample emotion categories according to the sentence vector of the text information, and determining the target emotion category of the text information from the plurality of different sample emotion categories according to the probability, a first association between the determined target emotion category and the text information may be established, and the preset text base may be updated based on the first association. After the preset text base is updated, if the linguistic data matched with the text information exists in the subsequent use process, the linguistic data can be directly matched with the text information, so that the corresponding emotion label is obtained, and the operation resources of the electronic equipment are saved.
105. And if the text length is larger than a preset value, determining the target emotion category of the text information according to the embedded vector of the type specified by the text information, wherein the embedded vectors of different types are obtained based on the characteristics of the text information on different dimensions and the correlation among the characteristics.
Specifically, if the text length is greater than the preset value, the text can be regarded as a long text corpus. The dimensions of the text information may include dimensions of text content, locations of words in the text, text classification, and so on. For example, in the text content dimension, word embedding vectors (word embedding) of the text can be obtained based on the correlation between the text content features and words in the content; in the dimension of the position of each word in the text, a position embedding vector (position embedding) of the text can be obtained based on the position features of the word or phrase in the text. The word embedding vector is a vector representation of each word or phrase in the text, which is mapped on a real number field; the position embedding vector is a vector representation that the position of each word or phrase in the text is mapped on a real number field.
In some embodiments, specifying the type of embedded vector includes: the words are embedded into the vectors. The word embedding vector is obtained by weighting vector representation of each word or phrase in the text, which is mapped on a real number domain, according to correlation between words. Determining the target emotion type of the text information according to the embedded vector of the specified type of the text information, and specifically performing convolution processing on the word embedded vector; and performing pooling processing on the word embedding vector after the convolution processing to convert the word embedding vector into a sentence embedding vector, and determining the target emotion category of the text information according to the sentence embedding vector.
Referring to fig. 3, fig. 3 is a multi-sensing layer Text CNN model provided in this embodiment. In specific implementation, the text can be preprocessed, in particular, jieba word segmentation can be used for carrying out word segmentation on the text, punctuations in the text are reserved, words with the word frequency smaller than 2 in a word list are discarded, characters of all expression packets are extracted, and words obtained by word segmentation are converted into vector representation by word embedding proposed by AILab. In this embodiment, the multi-sensing-layer Text CNN model may include an input layer, a convolutional layer, a pooling layer, a full-link layer, a half-full-link layer, a sensing layer, and an output layer.
Referring to fig. 3, the input layer is used to input word embedding vectors (e.g., w1, w2, w3 … … wn); the convolutional layer is mainly used for feature extraction of an input word embedding vector, and may be a single convolutional layer with a convolutional kernel number of 200, a convolutional size of [3,4,5], and a sentence padding (which refers to a space between an attribute definition element frame and element content) size of 4. The Pooling layer (also called a sampling layer) is used to combine the convolved word-embedding vectors output by the convolutional layer into sentence-embedding vectors. The fully-connected layer can map the learned features to a sample mark space, which mainly plays a role of a classifier in the whole convolutional neural network, and each node of the fully-connected layer is connected with all nodes output by the previous layer (such as a pooling layer), wherein one node of the fully-connected layer is called one neuron in the fully-connected layer, and the number of the neurons in the fully-connected layer can be determined according to the requirements of practical application. For example, in the text detection model, the numbers of neurons of the full-link layers may be set to 512, or may be set to 128, and so on. Optionally, in the fully-connected layer, a non-linear factor may also be added by adding an activation function, for example, an activation function sigmoid (S-type function) may be added. And finally, adding the outputs of the two previous layers (namely the full connecting layer and the half full connecting layer) through the sensing layer to obtain the final emotion label.
For the multi-perception-layer Text CNN model, the prediction speed is high, and the model can be selected when a calling party needs to sacrifice some accuracy rate to greatly improve the response speed. If the Text such as the barrage is predicted in a scene of watching a video online, the real-time property needs to be emphasized, and at this time, the multi-perception-layer Text CNN can be selected to perform emotion prediction on the Text.
In some embodiments, for a given text message, its input representation is constructed by summing the embeddings of the corresponding target words, segments, and locations. That is, the type of embedded vector specified in the present embodiment includes: word embedding vectors, position embedding vectors, and segment embedding vectors (segment embedding). The word embedding vector is a vector representation of each word or phrase in the text, which is mapped on a real number field; the position embedding vector is a vector representation that the position of each word or phrase in the text is mapped on a real number field; the segment embedding vector is a vector representation that is used for distinguishing the belonged sentence of each sentence in the sentence pair when the text contains the sentence pair, and is mapped on a real number domain, for example, used for distinguishing the question and the answer in a question-answer scenario.
In the embodiment, word segmentation processing needs to be performed on text information in advance to obtain a corresponding word set, vector representation of the word set is generated, and a word embedding vector is obtained; and determining a text sequence of the text information, and generating a vector representation of the position of each word according to the position of each word in the text sequence to obtain a position embedding vector. In specific implementation, before generating vector representation of the word set, the expression packet in the text information can be detected, characters in the expression packet are extracted for word segmentation, the word set is updated based on the obtained words, and words with word frequency smaller than preset word frequency in the updated word set are deleted to remove useless words.
When the target emotion type of the text information is determined according to the embedded vector of the type specified by the text information, encoding processing can be specifically carried out on the word embedded vector on the basis of the position embedded vector and the segment embedded vector; converting the word embedding vector after the coding processing into a sentence embedding vector; and determining the target emotion category of the text information according to the sentence embedding vector.
Fig. 4 is a schematic diagram of the architecture of the BERT model provided in this embodiment. Wherein the input may include: word embedding vectors (e.g., w1, y1 in fig. 4), position embedding vectors (e.g., 1, 2, … … k +1 … … n in fig. 4), segment embedding vectors. The coding layer is formed by stacking a plurality of (e.g. 6) identical transform structures, each of which comprises two layers. The first layer is a multi-headed self-attentive layer and the second layer is a fully-connected layer. The multi-head self-attention layer is formed by combining a plurality of attention units, and the basic structure of each attention unit is an attention layer calculated through dot products. The fully-connected layer is independent for each input unit, and consists of two sets of linear transforms and one set of nonlinear transforms ReLU. The pooling layer can be used for converting the word hidden layer embedded vector into a sentence hidden layer embedded vector sensing layer, the sentence hidden layer embedded vector can be used as input, and the emotion classification label of the text is output.
Regarding segment-embedded vectors, because of the prediction task of the next sentence in BERT, there are two sentences concatenated, the upper sentence having the upper sentence segment-embedded vector and the lower sentence having the lower sentence segment-embedded vector, i.e., a and B in fig. 4. In addition, the tail of the sentence is added with an [ SEP ] end symbol, and the beginning of the two-sentence splicing is added with a [ CLS ] separator.
For the BERT model, the large-scale pre-training model is convenient to migrate, is suitable for scenes with high requirements on accuracy, and can greatly improve the accuracy of the prediction result of the model.
Specifically, in this embodiment, the "multi-sensing layer Text CNN" may be combined with the "BERT + firing + sensing layer" to integrate prediction. That is, in some embodiments, the specified type of embedded vector includes: word embedding vectors, position embedding vectors, and segment embedding vectors. When determining the target emotion category of the text information according to the embedded vector of the specified type of the text information, the following process may be specifically included:
performing convolution processing on the word embedding vector, and converting the word embedding vector after the convolution processing into a first sentence embedding vector;
performing encoding processing on the word embedding vector based on the position embedding vector and the segment embedding vector, and converting the word embedding vector after the encoding processing into a second sentence embedding vector;
determining a first probability that the text information corresponds to a plurality of different sample emotion categories according to the first sentence embedding vector, and determining a second probability that the text information corresponds to a plurality of different sample emotion categories according to the second sentence embedding vector; and determining the target emotion category of the text information according to the first probability and the second probability.
Specifically, the 'multi-sensing-layer Text CNN' can be integrated with 'BERT + Pooling + sensing layer' to form an integral model, wherein the two submodels are predicted in parallel, and the final emotion prediction label is obtained after the results respectively predicted by the two submodels are summarized and weighted. Wherein the weighting information may be set based on the actual prediction accuracy of the model.
In an embodiment, when determining the emotion category of the target text according to the first probability and the second probability, the first probability and the second probability corresponding to each sample emotion category may be respectively determined, then the determined first probability and the determined second probability are subjected to mean processing to obtain the target probability corresponding to each sample emotion category, and then the target emotion category determined as the text information with the maximum target probability value is selected from the multiple sample emotion categories.
In some embodiments, after determining the target emotion category of the text information according to the embedded vector of the type specified by the text information, a second association relationship between the determined target emotion category and the text information may also be established, and the preset text base may be updated based on the second association relationship. After the preset text base is updated, if the linguistic data matched with the text information exists in the subsequent using process, the linguistic data can be directly matched with the text information, and therefore the corresponding emotion label is obtained.
According to the text information processing method provided by the embodiment of the application, when the text information has the emotion words, the target emotion type of the text information is determined through the emotion dictionary model; when the emotional words do not exist in the text information, detecting the text length of the text information; if the text is a short text, determining the probability of the text information corresponding to a plurality of different sample emotion categories according to the sentence vector of the text information, and determining the target emotion category of the text information from the plurality of different sample emotion categories according to the probability; and if the text information is a long text, determining the target emotion type of the text information according to the embedded vector of the type specified by the text information. In the scheme, the text information is processed according to the logic architecture with the complexity of calculation from easy to difficult, and the processing speed and the processing effect of the text information are improved.
Referring to fig. 5 and fig. 6, fig. 5 is a schematic diagram of a model online deployment process provided by an embodiment of the present application; FIG. 6 is a schematic diagram of a model architecture of text emotion analysis provided in an embodiment of the present application.
Taking the emotion tag prediction task of online text as an example, a real-time request may be sent from multiple clients to access a server concurrently when a GPU (Graphics processing unit) service is deployed, but the GPU is not suitable for concurrent use. Therefore, in this embodiment, referring to fig. 5, when deploying an online service, an instantaneous concurrent request may be first packaged into a batch (batch) format at a service end, and then, using a GPU, after obtaining a prediction result of the whole batch, the GPU is further divided into a single result and distributed to a response of each request. In this process, two global variables need to be maintained: a global queue (queue) temporarily stores the request service and a global orderedduct temporarily stores the split single result. The producer receives the request and stores the data into the Queue by using a multi-producer single-consumer model, then the returned result of the request is searched by the OrderedDict in a polling mode, the consumer packs the data in the Queue into batch, and the batch enters the GPU model to obtain the result, and then the result is stored into the OrderedDict in a splitting mode.
Referring to FIG. 6, the system receives a caller request through multiple processes. Each process works as follows: the cache is first found in the Remote Dictionary service (redis), and if hit, the result is returned directly (if the caller explicitly does not use the cache in the request, the process continues). If the emotion is not hit in the cache, emotion prediction is performed by using a rule model (such as a blacklist filter model and a regular matching model). In prediction using the rule model, if a hit occurs, the prediction result is directly returned, and if the miss occurs, emotion prediction using the CPU model (i.e., emotion dictionary score model) is performed.
If the CPU model is used for hitting, the result is directly returned. If not, when the text to be tested is short text corpus, using the TF-IDF model to carry out emotion prediction, splitting and storing a prediction result in a result hash table, correlating the text to be tested and the prediction result, caching the text to be tested and the prediction result into redis, and then returning the result to the calling party. When the Text to be predicted is a long Text corpus, the Text to be predicted is added into a GPU processing queue, the GPU process carries out emotion prediction on the Text through an integrated GPU model (namely a multi-sensing-layer Text CNN + BERT classification model, and the Text CNN model and the BERT model can be referred to), searches a prediction result in an output result hash table, correlates the Text to be predicted with the prediction result and then caches the Text to be predicted in redis, and then returns the result to a calling party.
The following will describe a text emotion analysis method in the present embodiment, taking a task of analyzing a video bullet screen of a video as an example.
Firstly, the server can obtain a barrage text set in the video A, wherein the barrage text set comprises a barrage text A, a barrage text B and a barrage text C,
then, the server can detect whether a text matched with the bullet screen text in the bullet screen text set exists in the local database, when the server detects that the text matched with the bullet screen text A exists in the local database, an analysis result of the bullet screen text A is generated, then the server respectively performs text matching on the bullet screen text B and the bullet screen text C based on a preset rule model, the text matching can comprise blacklist text base matching, meaningless text rule matching and the like, and when the server detects that the bullet screen text B belongs to the text in the blacklist text base, the analysis result of the bullet screen text B is generated; and then, analyzing the emotion words of the bullet screen text C, when the emotion words exist in the bullet screen text C, carrying out quantitative processing on the emotion words in the bullet screen text C according to a preset rule, and determining the target emotion category of the bullet screen text C according to a quantitative processing result.
And when the emotional words do not exist in the bullet screen text C, detecting the text length of the bullet screen text C.
And if the bullet screen text C is smaller than or equal to the preset text length, determining the probability of the bullet screen text C corresponding to a plurality of different sample emotion categories according to the sentence vector of the bullet screen text C, and determining the determined target emotion category from the plurality of different sample emotion categories according to the probability.
And if the determined length is larger than the preset text length, determining the target emotion category of the bullet screen text C according to the embedded vector of the specified type of the bullet screen text C.
And finally, adding the bullet screen text C into the local database to update the data of the local database.
The model architecture for text emotion analysis provided by the embodiment includes the steps of model training, testing, feedback, deployment and the like. During model training, a long Text is adopted to train a multi-perception layer Text CNN framework in combination with a BERT + Pooling + perception layer framework, a short Text is used to train a TF-IDF model, and different prediction models are subjected to similar integration. In addition, the detailed information of the wrong sentences can be returned, the wrong sentences predicted by the model are distinguished according to the probability, the error degree of the Bad Case is quantized, the Bad Case (error example) can be recalled conveniently, and the mechanism for extracting the Bad Case is perfected.
When online prediction is carried out, firstly, the method sequentially uses \35881, uses an expurrenous vocabulary to filter \35881, and uses simple rules to filter neutral comments. For short reviews, unsupervised tf-idf was used for matching label prediction; the remaining sentences are predicted using the "multi-sensing layer TextCN" in combination with the "BERT + Pooling + sensing layer" integration. When in online deployment, a method of 'multi-process + service Batch + asynchronous thread pool' is used, and resources of a CPU and a GPU are utilized to the maximum extent, so that the prediction result and the prediction speed both achieve a good effect.
The scheme provides a full-automatic video intelligent adjusting method, whether the video is too bright or too dark can be automatically identified, an automatic adjusting scheme is given, the classified scene where the video is located is automatically identified, an optimizing scheme of the corresponding scene is given, manual adjustment of a user is not needed, and the text information processing efficiency is improved.
In order to better implement the text information processing method provided by the embodiment of the present application, an embodiment of the present application further provides a device based on the text information processing method. The terms are the same as those in the text information processing method, and specific implementation details can be referred to the description in the method embodiment.
Referring to fig. 7, fig. 7 is a schematic structural diagram of a text information processing apparatus according to an embodiment of the present disclosure, where the processing apparatus may include an obtaining unit 301, a first determining unit 302, a length detecting unit 303, a second determining unit 304, and a third determining unit 305, which may specifically be as follows:
an acquiring unit 301, configured to acquire text information to be processed;
a first determining unit 302, configured to, when an emotion word exists in the text information, perform quantization processing on the emotion word in the text information according to a preset rule, and determine a target emotion category of the text information according to a quantization processing result;
a length detection unit 303, configured to detect a text length of the text information when there is no emotion word in the text information;
a second determining unit 304, configured to determine, according to the sentence vector of the text information, probabilities that the text information corresponds to multiple different sample emotion categories if the text length is smaller than or equal to a preset value, and determine, according to the probabilities, a target emotion category of the text information from the multiple different sample emotion categories;
a third determining unit 305, configured to determine a target emotion category of the text information according to an embedded vector of a type specified by the text information if the text length is greater than the preset value, where different types of embedded vectors are obtained based on features of the text information in different dimensions and correlations between the features.
In some embodiments, the specified type of embedded vector comprises: word embedding vectors; when determining the target emotion category of the text information according to the embedded vector of the type specified by the text information, the third determining unit 304 may be configured to:
performing convolution processing on the word embedding vector;
converting the word embedding vector after convolution processing into a sentence embedding vector;
and determining the target emotion category of the text information according to the sentence embedding vector.
In some embodiments, the specified type of embedded vector comprises: word embedding vectors, position embedding vectors, and segment embedding vectors. When determining the target emotion category of the text information according to the embedded vector of the type specified by the text information, the third determining unit 304 may be configured to:
encoding the word embedding vector based on the position embedding vector and the segment embedding vector;
converting the word embedding vector after the coding processing into a sentence embedding vector;
and determining the target emotion category of the text information according to the sentence embedding vector.
In some embodiments, specifying the type of embedded vector includes: word embedding vectors, position embedding vectors and segment embedding vectors;
when determining the target emotion category of the text information according to the embedded vector of the type specified by the text information, the third determining unit 304 may be configured to:
performing convolution processing on the word embedding vector, and converting the word embedding vector after the convolution processing into a first sentence embedding vector;
the word embedding vector is coded based on the position embedding vector and the segment embedding vector, and the word embedding vector after the coding processing is converted into a second sentence embedding vector;
determining a first probability that the text information corresponds to a plurality of different sample emotion classes according to the first sentence embedding vector, and determining a second probability that the text information corresponds to the plurality of different sample emotion classes according to the second sentence embedding vector;
and determining the target emotion category of the text information according to the first probability and the second probability.
In some embodiments, when determining the emotion classification of the target text according to the first probability and the second probability, the third determining unit 304 may be configured to:
respectively determining a first probability and a second probability corresponding to each sample emotion category;
carrying out mean processing on the first probability and the second probability to obtain a target probability corresponding to each sample emotion category;
and selecting the target emotion category with the maximum target probability value from the plurality of sample emotion categories to be determined as the target emotion category of the text information.
In some embodiments, the text processing apparatus may further include:
the first generating unit is used for carrying out word segmentation processing on the text information to obtain a corresponding word set, generating vector representation of the word set and obtaining a word embedding vector;
and the second generating unit is used for determining a text sequence of the text information, generating a vector representation of each word position according to the position of each word in the text sequence, and obtaining a position embedding vector.
In some embodiments, before generating the vector representation of the set of words, may further include:
the length detection unit is used for detecting the emotion packets in the text information;
the extraction unit is used for extracting characters in the expression package;
the word segmentation unit is used for performing word segmentation processing on the characters and updating the word set based on the obtained words;
and the deleting unit is used for deleting the words with the word frequency smaller than the preset word frequency in the updated word set.
In some embodiments, the second determination unit may be configured to:
calculating the similarity between the sentence vector and each sample sentence vector in the sample sentence vector set;
determining a preset number of target sample sentence vectors from the sample sentence vector set according to the sequence of similarity from large to small;
determining weighting information of sample emotion categories corresponding to each target sample sentence vector according to the similarity value;
based on the weighting information, carrying out weighting processing on the sample emotion types corresponding to the target sample sentence vectors;
and determining the target emotion type of the text information according to the weighting processing result.
In some embodiments, the text information processing apparatus may further include:
the word set detection unit is used for detecting the text information based on a sample word set before quantization processing is carried out on the emotion words in the text information according to a preset rule, wherein the sample word set comprises sample words belonging to the same emotion category;
when the text information is detected to have the content matched with the sample word set, determining the emotion category corresponding to the sample word set as the target category of the text information.
In some embodiments, the text information processing apparatus further includes:
the text detection unit is used for detecting the text information based on a preset text library before detecting the text information based on the sample word set;
and when a preset text which is the same as the text information exists in the preset text library, determining the emotion category associated with the preset text as the target emotion category of the text information.
In some embodiments, the text information processing apparatus may further include:
the first association unit is used for establishing a first association relation between the determined target emotion category and the text information after determining the probability of the text information corresponding to the text information belonging to a plurality of different sample emotion categories according to the sentence vector of the text information and determining the target emotion category of the text information from the plurality of different sample emotion categories according to the probability;
and the first updating unit is used for updating the preset text library based on the first incidence relation.
In some embodiments, the text updating unit 300 may further include:
the second association unit is used for establishing a second association relation between the determined target emotion category and the text information after the target emotion category of the text information is determined according to the embedded vector of the text information specified type;
and the second updating unit is used for updating the preset text library based on the second incidence relation.
According to the text information processing device provided by the embodiment of the application, when emotion words exist in text information to be processed, the emotion words in the text information are quantized according to a preset rule, and the target emotion category of the text information is determined according to a quantization processing result; when the emotional words do not exist in the text information, detecting the text length of the text information; if the text length is smaller than or equal to a preset value, determining the probability of the text information corresponding to a plurality of different sample emotion categories according to the sentence vector of the text information, and determining the target emotion category of the text information from the plurality of different sample emotion categories according to the probability; and if the text length is larger than the preset value, determining the target emotion category of the text information according to the embedded vector of the specified type of the text information. In the scheme, the text information is processed according to the logic architecture with the complexity of calculation from easy to difficult, and the processing speed and the processing effect of the text information are improved.
The embodiment of the application further provides an electronic device, and the electronic device can be terminal devices such as a smart phone and a tablet computer. As shown in fig. 8, the electronic device may include Radio Frequency (RF) circuitry 601, memory 602 including one or more computer-readable storage media, input unit 603, display unit 604, sensor 605, audio circuitry 606, Wireless Fidelity (WiFi) module 607, processor 608 including one or more processing cores, and power supply 609. Those skilled in the art will appreciate that the electronic device configuration shown in fig. 8 does not constitute a limitation of the electronic device and may include more or fewer components than those shown, or some components may be combined, or a different arrangement of components. Wherein:
the RF circuit 601 may be used for receiving and transmitting signals during a message transmission or communication process, and in particular, for receiving downlink messages from a base station and then processing the received downlink messages by one or more processors 608; in addition, data relating to uplink is transmitted to the base station. In general, the RF circuit 601 includes, but is not limited to, an antenna, at least one Amplifier, a tuner, one or more oscillators, a Subscriber Identity Module (SIM) card, a transceiver, a coupler, a Low Noise Amplifier (LNA), a duplexer, and the like. In addition, the RF circuit 601 may also communicate with networks and other devices via wireless communications. The wireless communication may use any communication standard or protocol, including but not limited to Global System for Mobile communications (GSM), General Packet Radio Service (GPRS), Code Division Multiple Access (CDMA), Wideband Code Division Multiple Access (WCDMA), Long Term Evolution (LTE), email, Short Message Service (SMS), and the like.
The memory 602 may be used to store software programs and modules, and the processor 608 executes various functional applications and data processing by operating the software programs and modules stored in the memory 602. The memory 602 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application program required by at least one function (such as a sound playing function, an image playing function, etc.), and the like; the storage data area may store data (such as audio data, a phonebook, etc.) created according to the use of the electronic device, and the like. Further, the memory 602 may include high speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other volatile solid state storage device. Accordingly, the memory 602 may also include a memory controller to provide the processor 608 and the input unit 603 access to the memory 602.
The input unit 603 may be used to receive input numeric or character information and generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function control. In particular, in one particular embodiment, input unit 603 may include a touch-sensitive surface as well as other input devices. The touch-sensitive surface, also referred to as a touch display screen or a touch pad, may collect touch operations by a user (e.g., operations by a user on or near the touch-sensitive surface using a finger, a stylus, or any other suitable object or attachment) thereon or nearby, and drive the corresponding connection device according to a predetermined program. Alternatively, the touch sensitive surface may comprise two parts, a touch detection means and a touch controller. The touch detection device detects the touch direction of a user, detects a signal brought by touch operation and transmits the signal to the touch controller; the touch controller receives touch information from the touch sensing device, converts the touch information into touch point coordinates, sends the touch point coordinates to the processor 608, and can receive and execute commands sent by the processor 608. In addition, touch sensitive surfaces may be implemented using various types of resistive, capacitive, infrared, and surface acoustic waves. The input unit 603 may include other input devices in addition to the touch-sensitive surface. In particular, other input devices may include, but are not limited to, one or more of a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a trackball, a mouse, a joystick, and the like.
The display unit 604 may be used to display information input by or provided to a user and various graphical user interfaces of the electronic device, which may be made up of graphics, text, icons, video, and any combination thereof. The display unit 604 may include a display panel, and optionally, the display panel may be configured in the form of a Liquid Crystal Display (LCD), an Organic Light-Emitting Diode (OLED), or the like. Further, the touch-sensitive surface may overlay the display panel, and when a touch operation is detected on or near the touch-sensitive surface, the touch operation is transmitted to the processor 608 to determine the type of touch event, and the processor 608 then provides a corresponding visual output on the display panel according to the type of touch event. Although in FIG. 8 the touch sensitive surface and the display panel are two separate components to implement input and output functions, in some embodiments the touch sensitive surface may be integrated with the display panel to implement input and output functions.
The electronic device may also include at least one sensor 605, such as a light sensor, motion sensor, and other sensors. In particular, the light sensor may include an ambient light sensor that may adjust the brightness of the display panel according to the brightness of ambient light, and a proximity sensor that may turn off the display panel and/or the backlight when the electronic device is moved to the ear. As one of the motion sensors, the gravity acceleration sensor can detect the magnitude of acceleration in each direction (generally, three axes), can detect the magnitude and direction of gravity when the mobile phone is stationary, and can be used for applications of recognizing the posture of the mobile phone (such as horizontal and vertical screen switching, related games, magnetometer posture calibration), vibration recognition related functions (such as pedometer and tapping), and the like; as for other sensors such as a gyroscope, a barometer, a hygrometer, a thermometer, and an infrared sensor, which may be further configured to the electronic device, detailed descriptions thereof are omitted.
Audio circuitry 606, a speaker, and a microphone may provide an audio interface between a user and the electronic device. The audio circuit 606 may transmit the electrical signal converted from the received audio data to a speaker, and convert the electrical signal into a sound signal for output; on the other hand, the microphone converts the collected sound signal into an electrical signal, which is received by the audio circuit 606 and converted into audio data, which is then processed by the audio data output processor 608, and then passed through the RF circuit 601 to be sent to, for example, another electronic device, or output to the memory 602 for further processing. The audio circuitry 606 may also include an earbud jack to provide communication of a peripheral headset with the electronic device.
WiFi belongs to short-distance wireless transmission technology, and the electronic device can help the user send and receive e-mail, browse web pages, access streaming media, etc. through the WiFi module 607, and it provides wireless broadband internet access for the user. Although fig. 8 shows the WiFi module 607, it is understood that it does not belong to the essential constitution of the electronic device, and may be omitted entirely as needed within the scope not changing the essence of the invention.
The processor 608 is a control center of the electronic device, connects various parts of the entire mobile phone by using various interfaces and lines, and performs various functions of the electronic device and processes data by operating or executing software programs and/or modules stored in the memory 602 and calling data stored in the memory 602, thereby performing overall monitoring of the mobile phone. Optionally, processor 608 may include one or more processing cores; preferably, the processor 608 may integrate an application processor, which primarily handles operating systems, user interfaces, applications, etc., and a modem processor, which primarily handles wireless communications. It will be appreciated that the modem processor described above may not be integrated into the processor 608.
The electronic device also includes a power supply 609 (e.g., a battery) for powering the various components, which may preferably be logically coupled to the processor 608 via a power management system, such that the power management system may manage charging, discharging, and power consumption. The power supply 609 may also include any component of one or more dc or ac power sources, recharging systems, power failure detection circuitry, power converters or inverters, power status indicators, and the like.
Although not shown, the electronic device may further include a camera, a bluetooth module, and the like, which are not described in detail herein. Specifically, in this embodiment, the processor 608 in the electronic device loads an executable file corresponding to a process of one or more application programs into the memory 602 according to the following instructions, and the processor 608 runs the application programs stored in the memory 602, so as to implement various functions:
acquiring text information to be processed; when the text information has emotion words, carrying out quantitative processing on the emotion words in the text information according to a preset rule, and determining the target emotion type of the text information according to a quantitative processing result; when the emotional words do not exist in the text information, detecting the text length of the text information; if the text length is smaller than or equal to a preset value, determining the probability of the text information corresponding to a plurality of different sample emotion categories according to the sentence vector of the text information, and determining the target emotion category of the text information from the plurality of different sample emotion categories according to the probability; and if the text length is larger than the preset value, determining the target emotion category of the text information according to the embedded vector of the type specified by the text information, wherein the embedded vectors of different types are obtained based on the characteristics of the text information on different dimensions and the correlation among the characteristics.
The electronic device provided by the embodiment of the application can process the text information according to the logic architecture with the complexity of calculation from easy to difficult, and improves the processing speed and the processing effect of the text information.
The embodiment of the application also provides a server, and the server can be specifically an application server. As shown in fig. 9, the server may include Radio Frequency (RF) circuitry 701, memory 702 including one or more computer-readable storage media, a processor 704 including one or more processing cores, and a power supply 703. Those skilled in the art will appreciate that the server architecture shown in FIG. 9 does not constitute a limitation on the servers, and may include more or fewer components than shown, or some components in combination, or a different arrangement of components. Wherein:
the RF circuit 701 may be used for receiving and transmitting signals during information transmission and reception or during a call, and in particular, receives downlink information from a base station and then sends the received downlink information to the one or more processors 704 for processing; in addition, data relating to uplink is transmitted to the base station. In general, the RF circuitry 701 includes, but is not limited to, an antenna, at least one Amplifier, a tuner, one or more oscillators, a Subscriber Identity Module (SIM) card, a transceiver, a coupler, a Low Noise Amplifier (LNA), a duplexer, and the like. In addition, RF circuit 701 may also communicate with networks and other devices via wireless communications. The wireless communication may use any communication standard or protocol, including but not limited to Global System for Mobile communications (GSM), General Packet Radio Service (GPRS), Code Division Multiple Access (CDMA), Wideband Code Division Multiple Access (WCDMA), Long Term Evolution (LTE), email, Short Message Service (SMS), and the like.
The memory 702 may be used to store software programs and modules, and the processor 704 executes various functional applications and data processing by operating the software programs and modules stored in the memory 702. The memory 702 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application program required by at least one function (such as a sound playing function, an image playing function, etc.), and the like; the storage data area may store data (such as audio data, a phonebook, etc.) created according to the use of the server, and the like. Further, the memory 702 may include high speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other volatile solid state storage device. Accordingly, the memory 702 may also include a memory controller to provide the processor 704 and the input unit 703 access to the memory 702.
The processor 704 is the control center of the server, connects the various parts of the entire handset using various interfaces and lines, and performs various functions of the server and processes data by running or executing software programs and/or modules stored in the memory 702 and calling data stored in the memory 702, thereby performing overall monitoring of the handset. Optionally, processor 704 may include one or more processing cores; preferably, the processor 704 may integrate an application processor, which primarily handles operating systems, user interfaces, applications, etc., and a modem processor, which primarily handles wireless communications. It will be appreciated that the modem processor described above may not be integrated into processor 704.
The server also includes a power supply 703 (e.g., a battery) for powering the various components, which may preferably be logically connected to the processor 704 via a power management system to manage charging, discharging, and power consumption management functions via the power management system. The power supply 703 may also include any component including one or more of a dc or ac power source, a recharging system, a power failure detection circuit, a power converter or inverter, a power status indicator, and the like.
Specifically, in this embodiment, the processor 704 in the server loads the executable file corresponding to the process of one or more application programs into the memory 702 according to the following instructions, and the processor 704 runs the application programs stored in the memory 702, thereby implementing various functions:
acquiring text information to be processed; when the text information has emotion words, carrying out quantitative processing on the emotion words in the text information according to a preset rule, and determining the target emotion type of the text information according to a quantitative processing result; when the emotional words do not exist in the text information, detecting the text length of the text information; if the text length is smaller than or equal to a preset value, determining the probability of the text information corresponding to a plurality of different sample emotion categories according to the sentence vector of the text information, and determining the target emotion category of the text information from the plurality of different sample emotion categories according to the probability; and if the text length is larger than the preset value, determining the target emotion category of the text information according to the embedded vector of the type specified by the text information, wherein the embedded vectors of different types are obtained based on the characteristics of the text information on different dimensions and the correlation among the characteristics.
The server provided by the embodiment of the application can process the text information according to the logic architecture with the complexity of calculation from easy to difficult, and the processing speed and the processing effect of the text information are improved.
It will be understood by those skilled in the art that all or part of the steps of the methods of the above embodiments may be performed by instructions or by associated hardware controlled by the instructions, which may be stored in a computer readable storage medium and loaded and executed by a processor.
To this end, embodiments of the present application provide a computer-readable storage medium, in which a plurality of instructions are stored, and the instructions can be loaded by a processor to execute the steps in any one of the text information processing methods provided by the embodiments of the present application. For example, the instructions may perform the steps of:
acquiring text information to be processed; when the text information has emotion words, carrying out quantitative processing on the emotion words in the text information according to a preset rule, and determining the target emotion type of the text information according to a quantitative processing result; when the emotional words do not exist in the text information, detecting the text length of the text information; if the text length is smaller than or equal to a preset value, determining the probability of the text information corresponding to a plurality of different sample emotion categories according to the sentence vector of the text information, and determining the target emotion category of the text information from the plurality of different sample emotion categories according to the probability; and if the text length is larger than the preset value, determining the target emotion category of the text information according to the embedded vector of the type specified by the text information, wherein the embedded vectors of different types are obtained based on the characteristics of the text information on different dimensions and the correlation among the characteristics.
The above operations can be implemented in the foregoing embodiments, and are not described in detail herein.
Wherein the storage medium may include: read Only Memory (ROM), Random Access Memory (RAM), magnetic or optical disks, and the like.
Since the instructions stored in the storage medium can execute the steps in any text information processing method provided in the embodiments of the present application, the beneficial effects that can be achieved by any text information processing method provided in the embodiments of the present application can be achieved, which are detailed in the foregoing embodiments and will not be described again here.
The text information processing method, the text information processing apparatus, the storage medium, and the electronic device provided in the embodiments of the present application are described in detail above, and a specific example is applied in the text to explain the principle and the implementation of the present application, and the description of the embodiments above is only used to help understanding the method and the core idea of the present application; meanwhile, for those skilled in the art, according to the idea of the present application, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present application.

Claims (15)

1. A text information processing method, comprising:
acquiring text information to be processed;
when the text information has emotion words, carrying out quantitative processing on the emotion words in the text information according to a preset rule, and determining the target emotion type of the text information according to a quantitative processing result;
when the emotional words do not exist in the text information, detecting the text length of the text information;
if the text length is smaller than or equal to a preset value, determining the probability of the text information corresponding to a plurality of different sample emotion categories according to the sentence vector of the text information, and determining the target emotion category of the text information from the plurality of different sample emotion categories according to the probability;
and if the text length is larger than the preset value, determining the target emotion category of the text information according to the embedded vector of the type specified by the text information, wherein the embedded vectors of different types are obtained based on the characteristics of the text information on different dimensions and the correlation among the characteristics.
2. The text information processing method according to claim 1, wherein the specified type of the embedded vector includes: word embedding vectors;
the determining the target emotion category of the text information according to the embedded vector of the specified type of the text information comprises the following steps:
performing convolution processing on the word embedding vector;
converting the word embedding vector after convolution processing into a sentence embedding vector;
and determining the target emotion category of the text information according to the sentence embedding vector.
3. The text information processing method according to claim 1, wherein the specified type of the embedded vector includes: word embedding vectors, position embedding vectors and segment embedding vectors;
the determining the target emotion category of the text information according to the embedded vector of the specified type of the text information comprises the following steps:
encoding the word embedding vector based on the position embedding vector and the segment embedding vector;
converting the word embedding vector after the coding processing into a sentence embedding vector;
and determining the target emotion category of the text information according to the sentence embedding vector.
4. The text information processing method according to claim 1, wherein the specified type of the embedded vector includes: word embedding vectors, position embedding vectors and segment embedding vectors;
the determining the target emotion category of the text information according to the embedded vector of the specified type of the text information comprises the following steps:
performing convolution processing on the word embedding vector, and converting the word embedding vector after the convolution processing into a first sentence embedding vector;
the word embedding vector is coded based on the position embedding vector and the segment embedding vector, and the word embedding vector after the coding processing is converted into a second sentence embedding vector;
determining a first probability that the text information corresponds to a plurality of different sample emotion classes according to the first sentence embedding vector, and determining a second probability that the text information corresponds to the plurality of different sample emotion classes according to the second sentence embedding vector;
and determining the target emotion category of the text information according to the first probability and the second probability.
5. The method of claim 4, wherein determining the emotion classification of the target text according to the first probability and the second probability comprises:
respectively determining a first probability and a second probability corresponding to each sample emotion category;
carrying out mean processing on the first probability and the second probability to obtain a target probability corresponding to each sample emotion category;
and selecting the target emotion category with the maximum target probability value from the plurality of sample emotion categories to be determined as the target emotion category of the text information.
6. The text information processing method according to claim 4, further comprising:
performing word segmentation processing on the text information to obtain a corresponding word set, generating vector representation of the word set, and obtaining a word embedding vector;
and determining a text sequence of the text information, and generating a vector representation of the position of each word according to the position of each word in the text sequence to obtain a position embedded vector.
7. The method of claim 5, further comprising, prior to generating the vector representation of the set of words:
detecting an emoticon in the text message;
extracting characters in the expression packet;
performing word segmentation processing on the characters, and updating the word set based on the obtained words;
and deleting the words with the word frequency smaller than the preset word frequency in the updated word set.
8. The method of claim 1, wherein determining the probability that the sentence vector of the text message corresponds to different sample emotion categories according to the sentence vector of the text message, and determining the target emotion category of the text message from the different sample emotion categories according to the probability comprises:
calculating the similarity between the sentence vector and each sample sentence vector in the sample sentence vector set;
determining a preset number of target sample sentence vectors from the sample sentence vector set according to the sequence of similarity from large to small;
determining weighting information of sample emotion categories corresponding to each target sample sentence vector according to the similarity value;
based on the weighting information, carrying out weighting processing on the sample emotion types corresponding to the target sample sentence vectors;
and determining the target emotion type of the text information according to the weighting processing result.
9. The information processing method according to any one of claims 1 to 8, further comprising, before quantizing emotion words in the text information according to a preset rule:
detecting the text information based on a sample word set, wherein the sample word set comprises sample words belonging to the same emotion category;
when the text information is detected to have the content matched with the sample word set, determining the emotion category corresponding to the sample word set as the target category of the text information.
10. The information processing method according to claim 9, prior to detecting the text information based on the sample word set, further comprising:
detecting the text information based on a preset text library;
and when a preset text which is the same as the text information exists in the preset text library, determining the emotion category associated with the preset text as the target emotion category of the text information.
11. The information processing method of claim 10, wherein after determining probabilities of the textual information corresponding to the different sample emotion categories from the sentence vector of the textual information, and determining the target emotion category of the textual information from the different sample emotion categories based on the probabilities, further comprising:
establishing a first association relation between the determined target emotion category and the text information;
and updating the preset text library based on the first incidence relation.
12. The information processing method of claim 10, further comprising, after determining the target emotion classification of the text information from the embedded vector of the type specified by the text information:
establishing a second association relation between the determined target emotion category and the text information;
and updating the preset text library based on the second incidence relation.
13. A text information processing apparatus characterized by comprising:
the acquisition unit is used for acquiring text information to be processed;
a first determining unit, configured to determine, when a target candidate text matching the text information exists in a candidate text set, an emotion category corresponding to the target candidate text as a target emotion category of the text information;
the length detection unit is used for detecting the text length of the text information when a target candidate text matched with the text information does not exist in the candidate text set;
the second determining unit is used for determining the probability of the text information corresponding to a plurality of different sample emotion categories according to the sentence vector of the text information if the text length is smaller than or equal to a preset value, and determining the target emotion category of the text information from the plurality of different sample emotion categories according to the probability;
and the third determining unit is used for determining the target emotion category of the text information according to the embedded vector of the type specified by the text information if the text length is larger than the preset value, wherein the embedded vectors of different types are obtained based on the characteristics of the text information in different dimensions and the correlation among the characteristics.
14. A computer-readable storage medium storing a plurality of instructions adapted to be loaded by a processor to perform the information processing method according to any one of claims 1 to 12.
15. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, characterized in that the processor implements the information processing method according to any one of claims 1 to 12 when executing the program.
CN202010286959.1A 2020-04-13 2020-04-13 Text information processing method and device, storage medium and electronic equipment Pending CN111539212A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010286959.1A CN111539212A (en) 2020-04-13 2020-04-13 Text information processing method and device, storage medium and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010286959.1A CN111539212A (en) 2020-04-13 2020-04-13 Text information processing method and device, storage medium and electronic equipment

Publications (1)

Publication Number Publication Date
CN111539212A true CN111539212A (en) 2020-08-14

Family

ID=71978650

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010286959.1A Pending CN111539212A (en) 2020-04-13 2020-04-13 Text information processing method and device, storage medium and electronic equipment

Country Status (1)

Country Link
CN (1) CN111539212A (en)

Cited By (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112035634A (en) * 2020-08-28 2020-12-04 康键信息技术(深圳)有限公司 Text emotion detection method, device and equipment and storage medium
CN113011171A (en) * 2021-03-05 2021-06-22 北京市博汇科技股份有限公司 Bert-based illegal text recognition algorithm and device
CN113255368A (en) * 2021-06-07 2021-08-13 中国平安人寿保险股份有限公司 Method and device for emotion analysis of text data and related equipment
CN113763932A (en) * 2021-05-13 2021-12-07 腾讯科技(深圳)有限公司 Voice processing method and device, computer equipment and storage medium
CN114153967A (en) * 2021-09-10 2022-03-08 时趣互动(北京)科技有限公司 Public opinion classification optimization method for long text
CN114841161A (en) * 2022-05-20 2022-08-02 中国工商银行股份有限公司 Event element extraction method, device, equipment, storage medium and program product
WO2022252638A1 (en) * 2021-05-31 2022-12-08 平安科技(深圳)有限公司 Text matching method and apparatus, computer device and readable storage medium
CN115547313A (en) * 2022-09-20 2022-12-30 海南大学 Method for controlling sudden stop of running vehicle based on voice of driver
CN116089602A (en) * 2021-11-04 2023-05-09 腾讯科技(深圳)有限公司 Information processing method, apparatus, electronic device, storage medium, and program product

Cited By (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112035634A (en) * 2020-08-28 2020-12-04 康键信息技术(深圳)有限公司 Text emotion detection method, device and equipment and storage medium
CN113011171A (en) * 2021-03-05 2021-06-22 北京市博汇科技股份有限公司 Bert-based illegal text recognition algorithm and device
CN113763932A (en) * 2021-05-13 2021-12-07 腾讯科技(深圳)有限公司 Voice processing method and device, computer equipment and storage medium
CN113763932B (en) * 2021-05-13 2024-02-13 腾讯科技(深圳)有限公司 Speech processing method, device, computer equipment and storage medium
WO2022252638A1 (en) * 2021-05-31 2022-12-08 平安科技(深圳)有限公司 Text matching method and apparatus, computer device and readable storage medium
CN113255368A (en) * 2021-06-07 2021-08-13 中国平安人寿保险股份有限公司 Method and device for emotion analysis of text data and related equipment
CN114153967A (en) * 2021-09-10 2022-03-08 时趣互动(北京)科技有限公司 Public opinion classification optimization method for long text
CN114153967B (en) * 2021-09-10 2024-07-23 时趣互动(北京)科技有限公司 Public opinion classification optimization method for long text
CN116089602A (en) * 2021-11-04 2023-05-09 腾讯科技(深圳)有限公司 Information processing method, apparatus, electronic device, storage medium, and program product
CN116089602B (en) * 2021-11-04 2024-05-03 腾讯科技(深圳)有限公司 Information processing method, apparatus, electronic device, storage medium, and program product
CN114841161A (en) * 2022-05-20 2022-08-02 中国工商银行股份有限公司 Event element extraction method, device, equipment, storage medium and program product
CN115547313A (en) * 2022-09-20 2022-12-30 海南大学 Method for controlling sudden stop of running vehicle based on voice of driver

Similar Documents

Publication Publication Date Title
CN111539212A (en) Text information processing method and device, storage medium and electronic equipment
CN109145303B (en) Named entity recognition method, device, medium and equipment
KR102288249B1 (en) Information processing method, terminal, and computer storage medium
CN110598046B (en) Artificial intelligence-based identification method and related device for title party
CN111931501B (en) Text mining method based on artificial intelligence, related device and equipment
EP3611663A1 (en) Image recognition method, terminal and storage medium
CN110570840B (en) Intelligent device awakening method and device based on artificial intelligence
CN112069309B (en) Information acquisition method, information acquisition device, computer equipment and storage medium
CN113821589B (en) Text label determining method and device, computer equipment and storage medium
CN111597804B (en) Method and related device for training entity recognition model
KR102355152B1 (en) Method for searching content and electronic device thereof
CN112749252B (en) Text matching method and related device based on artificial intelligence
CN111651604B (en) Emotion classification method and related device based on artificial intelligence
CN113761122A (en) Event extraction method, related device, equipment and storage medium
CN113392644A (en) Model training method, text information processing method, system, device and storage medium
CN114357278A (en) Topic recommendation method, device and equipment
CN114817478A (en) Text-based question and answer method and device, computer equipment and storage medium
CN113822038A (en) Abstract generation method and related device
CN112328783A (en) Abstract determining method and related device
CN114970562A (en) Semantic understanding method, device, medium and equipment
CN111723783B (en) Content identification method and related device
CN113569043A (en) Text category determination method and related device
CN113763929A (en) Voice evaluation method and device, electronic equipment and storage medium
CN113505596A (en) Topic switching marking method and device and computer equipment
CN114840563A (en) Method, device, equipment and storage medium for generating field description information

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
REG Reference to a national code

Ref country code: HK

Ref legal event code: DE

Ref document number: 40027355

Country of ref document: HK

SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination