CN113268562B - Text emotion recognition method, device and equipment and storage medium - Google Patents

Text emotion recognition method, device and equipment and storage medium Download PDF

Info

Publication number
CN113268562B
CN113268562B CN202110565815.4A CN202110565815A CN113268562B CN 113268562 B CN113268562 B CN 113268562B CN 202110565815 A CN202110565815 A CN 202110565815A CN 113268562 B CN113268562 B CN 113268562B
Authority
CN
China
Prior art keywords
text
preset
network
matrix
recognized
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.)
Active
Application number
CN202110565815.4A
Other languages
Chinese (zh)
Other versions
CN113268562A (en
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.)
Ping An Technology Shenzhen Co Ltd
Original Assignee
Ping An Technology Shenzhen 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 Ping An Technology Shenzhen Co Ltd filed Critical Ping An Technology Shenzhen Co Ltd
Priority to CN202110565815.4A priority Critical patent/CN113268562B/en
Publication of CN113268562A publication Critical patent/CN113268562A/en
Application granted granted Critical
Publication of CN113268562B publication Critical patent/CN113268562B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • 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/3344Query execution using natural language analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/21Design or setup of recognition systems or techniques; Extraction of features in feature space; Blind source separation
    • G06F18/214Generating training patterns; Bootstrap methods, e.g. bagging or boosting
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/20Natural language analysis
    • G06F40/279Recognition of textual entities
    • G06F40/289Phrasal analysis, e.g. finite state techniques or chunking
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/30Semantic analysis

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Artificial Intelligence (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Computational Linguistics (AREA)
  • General Health & Medical Sciences (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Health & Medical Sciences (AREA)
  • Bioinformatics & Cheminformatics (AREA)
  • Evolutionary Computation (AREA)
  • Evolutionary Biology (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Bioinformatics & Computational Biology (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Databases & Information Systems (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention relates to artificial intelligence and provides a text emotion recognition method, a text emotion recognition device, text emotion recognition equipment and a storage medium. The method can be used for preprocessing a text to be recognized to obtain text participles and word sequences, combining the text participles in pairs to obtain element pairs, generating a text vector according to the importance of the element pairs, generating a first prediction result according to the text vector and a first preset network, generating a first text matrix according to the word sequences and the vector values of the text participles, processing the first text matrix according to preset dimensionality to obtain a second text matrix, generating a second prediction result according to the first text matrix and a second preset network, generating a third prediction result according to the second text matrix and the third preset network, and generating an emotion result according to a network weight, the first prediction result, the second prediction result and the third prediction result. The invention can accurately identify the emotion expressed by the text. In addition, the invention also relates to a block chain technology, and the emotion result can be stored in the block chain.

Description

Text emotion recognition method, device and equipment and storage medium
Technical Field
The invention relates to the technical field of artificial intelligence, in particular to a text emotion recognition method, device, equipment and storage medium.
Background
Emotion recognition is a more important field in the field of artificial intelligence, and emotion expressed by the segment of characters and user emotion can be recognized from the character description through emotion recognition. In the current text emotion recognition scheme, a single model is usually used for analyzing a text, however, the single model cannot analyze the semantics of the text information from multiple angles, so that the emotion expressed by the text information cannot be accurately recognized.
Disclosure of Invention
In view of the foregoing, it is desirable to provide a text emotion recognition method, device, apparatus and storage medium, which can accurately recognize emotion expressed by text information.
On one hand, the invention provides a text emotion recognition method, which comprises the following steps:
when a text emotion recognition request is received, acquiring a text to be recognized according to the text emotion recognition request;
preprocessing the text to be recognized to obtain text participles of the text to be recognized and word sequences of the text participles in the text to be recognized;
combining the text participles pairwise according to the word sequence to obtain an element pair, wherein the element pair comprises any two adjacent text participles;
generating a text vector of the text to be recognized according to the importance of the element pair in a preset corpus;
generating a first prediction result of the text to be recognized according to the text vector and a first preset network selected from a network library;
obtaining vector values of the text word segmentation from a preset vector table, and splicing the vector values according to the word sequence to obtain a first text matrix of the text to be recognized;
processing the first text matrix according to a preset dimension to obtain a second text matrix;
inputting the first text matrix into a second preset network to obtain a second prediction result, and inputting the second text matrix into a third preset network selected from the network library to obtain a third prediction result;
and calculating a network weight according to the first preset network, the second preset network and the third preset network, and generating an emotion result of the text to be recognized according to the network weight, the first prediction result, the second prediction result and the third prediction result.
According to a preferred embodiment of the present invention, the preprocessing the text to be recognized to obtain the text participles of the text to be recognized and the word sequence of the text participles in the text to be recognized includes:
extracting an expression packet from the text to be recognized;
determining an expression text corresponding to the expression packet from an expression library, and replacing the expression packet in the text to be recognized with the expression text to obtain a text to be processed;
cleaning preset symbols in the text to be processed to obtain a processed text;
performing word segmentation on the processed text to obtain the text word segmentation;
and determining the position of the text word in the text to be recognized to obtain the word sequence.
According to a preferred embodiment of the present invention, the generating the text vector of the text to be recognized according to the importance of the element pair in a predetermined corpus includes:
calculating the number of the element pairs in the text to be recognized, and calculating the total number of the element pairs in the preset corpus;
calculating the ratio of the number of the element pairs in the total number of the element pairs to obtain a first frequency of the element pairs;
calculating the total amount of all documents in the preset corpus, and calculating the number of the documents containing the element pairs in the preset corpus;
dividing the total amount of the documents by the number of the documents to obtain an operation result, and calculating a logarithm value of the operation result to obtain a second frequency of the element pair;
determining the importance of the element pair as a product of the first frequency and the second frequency;
and splicing the importance degrees to obtain the text vector.
According to a preferred embodiment of the present invention, the generating a first prediction result of the text to be recognized according to the text vector and a first preset network selected from a network library includes:
determining the number of a file library according to the preset corpus;
acquiring a network corresponding to the file library number from the network library as the first preset network;
inputting the text vector into the first preset network to obtain a probability value;
determining a target interval of the probability value in a preset result table according to the size of the probability value;
and acquiring a result corresponding to the target interval from the preset result table as the first prediction result.
According to a preferred embodiment of the present invention, the processing the first text matrix according to a preset dimension to obtain a second text matrix includes:
calculating the number of row vectors in the first text matrix to obtain matrix row dimensions;
detecting whether the matrix row dimension is smaller than the preset dimension;
if the matrix row dimension is smaller than the preset dimension, calculating a difference value between the preset row dimension and the matrix dimension, calculating the number of column vectors in the first text matrix to obtain a matrix column dimension, generating a sub-matrix according to the difference value and the matrix column dimension, and splicing the first text matrix and the sub-matrix to obtain the second text matrix; or
If the matrix row dimension is equal to the preset dimension, determining the first text matrix as the second text matrix; or
If the matrix row dimension is larger than the preset dimension, sequencing each row vector in the first text matrix to obtain a vector serial number, filtering the row vectors with the vector serial numbers larger than the preset dimension, and determining the filtered matrix as the second text matrix.
According to a preferred embodiment of the present invention, the inputting the second text matrix into a third preset network selected from the network library to obtain a third prediction result includes:
determining the serial number of a preset table according to the preset vector table;
selecting a network corresponding to the preset table number and the preset dimension at the same time from the network library as the third preset network;
acquiring a plurality of convolution kernels in the third preset network, wherein the convolution kernels are different in size;
respectively extracting the features of the second text matrix according to the convolution kernels to obtain a plurality of feature matrices;
compressing the plurality of feature matrices respectively based on a pooling layer in the third preset network to obtain a plurality of compressed vectors, and splicing the plurality of compressed vectors to obtain a pooling vector;
mapping the pooling vector based on a full connection layer in the third preset network to obtain a probability vector;
and determining the category corresponding to the dimension with the largest value in the probability vectors as the third prediction result.
According to a preferred embodiment of the present invention, the calculating the network weight according to the first preset network, the second preset network, and the third preset network includes:
acquiring the historical prediction accuracy of the first preset network as a first numerical value, and acquiring the historical prediction accuracy of the second preset network as a second numerical value;
acquiring historical prediction accuracy of the third preset network as a third numerical value;
calculating the sum of the first numerical value, the second numerical value and the third numerical value to obtain a total value;
and generating the network weight according to the occupation ratio of the first numerical value in the total value, the occupation ratio of the second numerical value in the total value and the occupation ratio of the third numerical value in the total value.
On the other hand, the invention also provides a text emotion recognition device, which comprises:
the acquiring unit is used for acquiring a text to be recognized according to the text emotion recognition request when the text emotion recognition request is received;
the preprocessing unit is used for preprocessing the text to be recognized to obtain text participles of the text to be recognized and word sequences of the text participles in the text to be recognized;
the combination unit is used for combining every two text participles according to the word sequence to obtain an element pair, and the element pair comprises any two adjacent text participles;
the generating unit is used for generating a text vector of the text to be recognized according to the importance of the element pair in a preset corpus;
the generating unit is further used for generating a first prediction result of the text to be recognized according to the text vector and a first preset network selected from a network library;
the splicing unit is used for acquiring vector values of the text word segmentation from a preset vector table and splicing the vector values according to the word sequence to obtain a first text matrix of the text to be recognized;
the processing unit is used for processing the first text matrix according to a preset dimension to obtain a second text matrix;
the input unit is used for inputting the first text matrix into a second preset network to obtain a second prediction result, and inputting the second text matrix into a third preset network selected from the network library to obtain a third prediction result;
the generating unit is further configured to calculate a network weight according to the first preset network, the second preset network, and the third preset network, and generate an emotion result of the text to be recognized according to the network weight, the first prediction result, the second prediction result, and the third prediction result.
In another aspect, the present invention further provides an electronic device, including:
a memory storing computer readable instructions; and
and the processor executes the computer readable instructions stored in the memory to realize the text emotion recognition method.
In another aspect, the present invention further provides a computer-readable storage medium, in which computer-readable instructions are stored, and the computer-readable instructions are executed by a processor in an electronic device to implement the text emotion recognition method.
According to the technical scheme, the text vector of the text to be recognized is generated according to the importance of the element pair in the preset corpus, since the text vector is generated by the importance of the pair of elements in the text to be recognized, therefore, the prediction accuracy of the first prediction result can be improved, the prediction efficiency of the third prediction result can be improved by processing the first text matrix through the preset dimensionality, the text to be recognized is analyzed through a plurality of networks such as the first preset network, the second preset network and the third preset network, the semantics of the text to be recognized can be analyzed in multiple directions, and then, the influence of each network on the text to be recognized can be measured through the calculated network weight, so that the emotion result of the text to be recognized can be accurately determined.
Drawings
FIG. 1 is a flow chart of a text emotion recognition method according to a preferred embodiment of the present invention.
FIG. 2 is a functional block diagram of a text emotion recognition apparatus according to a preferred embodiment of the present invention.
FIG. 3 is a schematic structural diagram of an electronic device implementing a text emotion recognition method according to a preferred embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention will be described in detail with reference to the accompanying drawings and specific embodiments.
FIG. 1 is a flowchart illustrating a text emotion recognition method according to a preferred embodiment of the present invention. The order of the steps in the flow chart may be changed and some steps may be omitted according to different needs.
The text emotion recognition method is applied to one or more electronic devices, and the electronic devices are devices capable of automatically performing numerical calculation and/or information processing according to computer readable instructions which are set or stored in advance, and hardware of the electronic devices includes, but is not limited to, a microprocessor, an Application Specific Integrated Circuit (ASIC), a Programmable Gate Array (FPGA), a Digital Signal Processor (DSP), an embedded device, and the like.
The electronic device may be any electronic product capable of performing human-computer interaction with a user, for example, a Personal computer, a tablet computer, a smart phone, a Personal Digital Assistant (PDA), a game machine, an interactive Internet Protocol Television (IPTV), a smart wearable device, and the like.
The electronic device may include a network device and/or a user device. Wherein the network device includes, but is not limited to, a single network electronic device, an electronic device group consisting of a plurality of network electronic devices, or a Cloud Computing (Cloud Computing) based Cloud consisting of a large number of hosts or network electronic devices.
The network in which the electronic device is located includes, but is not limited to: the internet, a wide area Network, a metropolitan area Network, a local area Network, a Virtual Private Network (VPN), and the like.
And S10, when the text emotion recognition request is received, acquiring the text to be recognized according to the text emotion recognition request.
In at least one embodiment of the present invention, the text emotion recognition request includes, but is not limited to: and indicating the number of the text to be recognized.
The text to be recognized refers to the text needing emotion recognition.
In at least one embodiment of the present invention, the acquiring, by the electronic device, the text to be recognized according to the text emotion recognition request includes:
analyzing the message of the text emotion recognition request to obtain data information carried by the message;
acquiring information indicating a text from the data information as a text number;
and extracting information corresponding to the text number from a preset text library to serve as the text to be identified.
Wherein the data information includes, but is not limited to: the text number, a label indicating the text, etc.
And a plurality of texts which are not subjected to emotion recognition are stored in the preset text library.
By analyzing the message, the acquisition efficiency of the data information can be improved, so that the acquisition efficiency of the text to be identified is improved, and the text to be identified can be accurately acquired through the mapping relation between the serial number and the text in the preset text library.
S11, preprocessing the text to be recognized to obtain the text participles of the text to be recognized and the word sequence of the text participles in the text to be recognized.
In at least one embodiment of the present invention, the text word segmentation refers to a vocabulary obtained by performing word segmentation on a text after performing text conversion and text cleaning on the text to be recognized.
In at least one embodiment of the present invention, the electronic device preprocesses the text to be recognized to obtain the text segmentation words of the text to be recognized and the word sequence of the text segmentation words in the text to be recognized includes:
extracting an expression packet from the text to be recognized;
determining an expression text corresponding to the expression packet from an expression library, and replacing the expression packet in the text to be recognized with the expression text to obtain a text to be processed;
cleaning preset symbols in the text to be processed to obtain a processed text;
performing word segmentation on the processed text to obtain the text word segmentation;
and determining the position of the text word in the text to be recognized to obtain the word sequence.
The expression library is stored with a plurality of expressions and Chinese meanings represented by each expression.
The preset symbol can be a special symbol, stop words and other useless words.
By replacing the expression packet with the expression text, it can be ensured that the text to be processed contains all emotion information in the text to be recognized, and by cleaning the preset characters, the recognition efficiency of the text to be recognized can be improved.
And S12, combining the text participles pairwise according to the word sequence to obtain an element pair, wherein the element pair comprises any two adjacent text participles.
In at least one embodiment of the invention, the number of words of each of the text participles in the pair of elements may be set to a value less than a configuration value, for example, the configuration value may be 4.
By setting the number of words of each text participle in the element pair, the determination efficiency of the first prediction result can be improved.
And S13, generating a text vector of the text to be recognized according to the importance of the element pair in a preset corpus.
In at least one embodiment of the present invention, the predetermined corpus stores a plurality of combinations, and each combination stores two words.
In at least one embodiment of the present invention, the generating, by the electronic device, the text vector of the text to be recognized according to the importance of the element pair in the preset corpus includes:
calculating the number of the element pairs in the text to be recognized, and calculating the total number of the element pairs in the preset corpus;
calculating the ratio of the number of the element pairs in the total number of the element pairs to obtain a first frequency of the element pairs;
calculating the total amount of all documents in the preset corpus, and calculating the number of the documents containing the element pairs in the preset corpus;
dividing the total amount of the documents by the number of the documents to obtain an operation result, and calculating a logarithm value of the operation result to obtain a second frequency of the element pair;
determining the importance of the element pair as a product of the first frequency and the second frequency;
and splicing the importance degrees to obtain the text vector.
The importance of the element pair can be accurately determined through the first frequency and the second frequency, and the text vector can be accurately generated according to the importance.
S14, generating a first prediction result of the text to be recognized according to the text vector and a first preset network selected from a network library.
In at least one embodiment of the present invention, the network library includes a plurality of trained preset networks and a generation manner corresponding to an input vector in each preset network.
The first prediction result is a result obtained by analyzing the text vector through the first preset network.
In at least one embodiment of the present invention, the generating, by the electronic device, the first prediction result of the text to be recognized according to the text vector and a first preset network selected from a network library includes:
determining the number of a file library according to the preset corpus;
acquiring a network corresponding to the file library number from the network library as the first preset network;
inputting the text vector into the first preset network to obtain a probability value;
determining a target interval of the probability value in a preset result table according to the size of the probability value;
and acquiring a result corresponding to the target interval from the preset result table as the first prediction result.
Wherein the corpus number is used to indicate the corpus to be pre-set.
The preset result table stores mapping relations of a plurality of intervals and the prediction result.
According to the embodiment, a network suitable for analyzing the text vector can be selected from the network library, so that the generation accuracy of the probability value can be improved, and the determination accuracy of the first prediction result can be improved due to the fact that a plurality of numerical values in the target interval correspond to the first prediction result through the relation between the target interval and the first prediction result.
S15, obtaining vector values of the text word segmentation from a preset vector table, and splicing the vector values according to the word sequence to obtain a first text matrix of the text to be recognized.
In at least one embodiment of the present invention, the preset vector table stores vectors corresponding to a plurality of vocabularies.
In at least one embodiment of the present invention, the obtaining, by the electronic device, the first text matrix of the text to be recognized by concatenating the vector values according to the word order includes:
taking the vector value corresponding to each text word as a row vector;
and combining the row vectors according to the word sequence to obtain the first text matrix.
And S16, processing the first text matrix according to a preset dimension to obtain a second text matrix.
In at least one embodiment of the present invention, the number of row vectors in the second text matrix is the same as the preset dimension.
In at least one embodiment of the present invention, the processing, by the electronic device, the first text matrix according to a preset dimension to obtain a second text matrix includes:
calculating the number of row vectors in the first text matrix to obtain matrix row dimensions;
detecting whether the matrix row dimension is smaller than the preset dimension;
if the matrix row dimension is smaller than the preset dimension, calculating a difference value between the preset row dimension and the matrix dimension, calculating the number of column vectors in the first text matrix to obtain a matrix column dimension, generating a sub-matrix according to the difference value and the matrix column dimension, and splicing the first text matrix and the sub-matrix to obtain the second text matrix; or
If the matrix row dimension is equal to the preset dimension, determining the first text matrix as the second text matrix; or
If the matrix row dimension is larger than the preset dimension, sequencing each row vector in the first text matrix to obtain a vector serial number, filtering the row vectors with the vector serial numbers larger than the preset dimension, and determining the filtered matrix as the second text matrix.
The second text matrix with the fixed length can be generated through the preset dimensionality, and the third preset network can analyze the text to be recognized conveniently.
Specifically, the generating, by the electronic device, a sub-matrix according to the difference and the matrix column dimension includes:
acquiring a vector preset value, wherein the vector preset value is usually set to be 0;
and generating a matrix with the row number of the difference value and the column number of the matrix row dimensionality as the sub-matrix according to the vector preset value.
And S17, inputting the first text matrix into a second preset network to obtain a second prediction result, and inputting the second text matrix into a third preset network selected from the network library to obtain a third prediction result.
In at least one embodiment of the present invention, the second predetermined network includes a predetermined number of convolutional layers, and the second prediction result is a result generated after the first text matrix is analyzed by the second predetermined network.
The third preset network is a network corresponding to the preset vector table and the preset dimension, and the third prediction result is a result generated after the second text matrix is analyzed through the third preset network.
In at least one embodiment of the present invention, the electronic device inputs the second text matrix into a third preset network selected from the network library, and obtaining a third prediction result includes:
determining the serial number of a preset table according to the preset vector table;
selecting a network corresponding to the preset table number and the preset dimension at the same time from the network library as the third preset network;
acquiring a plurality of convolution kernels in the third preset network, wherein the convolution kernels are different in size;
respectively extracting the features of the second text matrix according to the convolution kernels to obtain a plurality of feature matrices;
compressing the plurality of feature matrices respectively based on a pooling layer in the third preset network to obtain a plurality of compressed vectors, and splicing the plurality of compressed vectors to obtain a pooling vector;
mapping the pooling vector based on a full connection layer in the third preset network to obtain a probability vector;
and determining the category corresponding to the dimension with the largest value in the probability vectors as the third prediction result.
And selecting a network suitable for analyzing the second text matrix from the network library through the preset table number and the preset dimensionality, extracting feature information in the second text matrix through the multiple convolution kernels in a multi-dimensionality manner, and improving the generation accuracy of the probability vector, so that the third prediction result can be accurately determined.
And S18, calculating a network weight according to the first preset network, the second preset network and the third preset network, and generating an emotion result of the text to be recognized according to the network weight, the first prediction result, the second prediction result and the third prediction result.
It is emphasized that the emotion result can also be stored in a node of a block chain in order to further ensure the privacy and security of the emotion result.
In at least one embodiment of the present invention, the calculating, by the electronic device, a network weight according to the first preset network, the second preset network, and the third preset network includes:
acquiring the historical prediction accuracy of the first preset network as a first numerical value, and acquiring the historical prediction accuracy of the second preset network as a second numerical value;
acquiring historical prediction accuracy of the third preset network as a third numerical value;
calculating the sum of the first numerical value, the second numerical value and the third numerical value to obtain a total value;
and generating the network weight according to the occupation ratio of the first numerical value in the total value, the occupation ratio of the second numerical value in the total value and the occupation ratio of the third numerical value in the total value.
And determining the network weight value according to the historical prediction accuracy of the first preset network, the second preset network and the third preset network, so that the determination accuracy of the emotion result is improved.
In at least one embodiment of the present invention, the network weights include a first network weight of the first preset network, a second network weight of the second preset network, and a third network weight of the third preset network, and the generating, by the electronic device, the emotion result of the text to be recognized according to the network weights, the first prediction result, the second prediction result, and the third prediction result includes:
determining the same prediction result in the first prediction result, the second prediction result and the third prediction result as a target result, and determining the prediction results except the target result as characteristic results;
calculating a first result probability of the target result according to the network weight, and calculating a second result probability of the characteristic result according to the network weight;
and when the first result probability is larger than the second result probability, determining the target result as the emotion result.
For example, the first prediction result is: pleasure, the second prediction result is: frustration, the third prediction result is: pleasure, it is determined that the target outcome includes the first predicted outcome and the third predicted outcome, i.e., the target outcome is: pleasantly, since the first network weight corresponding to the first prediction result is 0.3 and the third network weight corresponding to the third prediction result is 0.4, the first result probability of the target result is 0.7, and the feature result includes the second prediction result, that is, the feature result is: frustrated, since the second network weight corresponding to the second prediction result is 0.3, the second result probability of the feature result is 0.3, and it is determined that the emotion result is: pleasure.
The first result probability and the second result probability can be accurately determined through the network weight determined by the prediction accuracy, and therefore the determination accuracy of the emotion result is improved.
In at least one embodiment of the invention, the method further comprises:
acquiring a request number of the text emotion recognition request;
generating prompt information according to the request number and the emotion result;
encrypting the prompt message by adopting a symmetric encryption technology to obtain a ciphertext;
and sending the ciphertext to the terminal equipment of the appointed contact person.
Wherein the designated contact may be a triggering user of the emotion recognition request.
Through the implementation mode, the emotion result can be sent to the designated contact person in time after the emotion result is generated.
According to the technical scheme, the text vector of the text to be recognized is generated according to the importance of the element pair in the preset corpus, since the text vector is generated by the importance of the pair of elements in the text to be recognized, therefore, the prediction accuracy of the first prediction result can be improved, the prediction efficiency of the third prediction result can be improved by processing the first text matrix through the preset dimensionality, the text to be recognized is analyzed through a plurality of networks such as the first preset network, the second preset network and the third preset network, the semantics of the text to be recognized can be analyzed in multiple directions, and then, the influence of each network on the text to be recognized can be measured through the calculated network weight, so that the emotion result of the text to be recognized can be accurately determined.
FIG. 2 is a functional block diagram of a text emotion recognition apparatus according to a preferred embodiment of the present invention. The text emotion recognition device 11 includes an acquisition unit 110, a preprocessing unit 111, a combining unit 112, a generation unit 113, a concatenation unit 114, a processing unit 115, an input unit 116, an encryption unit 117, and a transmission unit 118. The module/unit referred to herein is a series of computer readable instruction segments that can be accessed by the processor 13 and perform a fixed function and that are stored in the memory 12. In the present embodiment, the functions of the modules/units will be described in detail in the following embodiments.
When a text emotion recognition request is received, the obtaining unit 110 obtains a text to be recognized according to the text emotion recognition request.
In at least one embodiment of the present invention, the text emotion recognition request includes, but is not limited to: and indicating the number of the text to be recognized.
The text to be recognized refers to the text needing emotion recognition.
In at least one embodiment of the present invention, the obtaining unit 110 obtains the text to be recognized according to the text emotion recognition request, where the obtaining unit includes:
analyzing the message of the text emotion recognition request to obtain data information carried by the message;
acquiring information indicating a text from the data information as a text number;
and extracting information corresponding to the text number from a preset text library to serve as the text to be identified.
Wherein the data information includes, but is not limited to: the text number, a label indicating the text, etc.
And a plurality of texts which are not subjected to emotion recognition are stored in the preset text library.
By analyzing the message, the acquisition efficiency of the data information can be improved, so that the acquisition efficiency of the text to be identified is improved, and the text to be identified can be accurately acquired through the mapping relation between the serial number and the text in the preset text library.
The preprocessing unit 111 preprocesses the text to be recognized to obtain the text participles of the text to be recognized and the word sequence of the text participles in the text to be recognized.
In at least one embodiment of the present invention, the text word segmentation refers to a vocabulary obtained by performing word segmentation on a text after performing text conversion and text cleaning on the text to be recognized.
In at least one embodiment of the present invention, the preprocessing unit 111 performs preprocessing on the text to be recognized, and obtaining the text participles of the text to be recognized and the word sequence of the text participles in the text to be recognized includes:
extracting an expression packet from the text to be recognized;
determining an expression text corresponding to the expression packet from an expression library, and replacing the expression packet in the text to be recognized with the expression text to obtain a text to be processed;
cleaning preset symbols in the text to be processed to obtain a processed text;
performing word segmentation on the processed text to obtain the text word segmentation;
and determining the position of the text word in the text to be recognized to obtain the word sequence.
The expression library is stored with a plurality of expressions and Chinese meanings represented by each expression.
The preset characters can be useless words such as special symbols and stop words.
The expression package is replaced by the expression text, so that the to-be-processed text can be ensured to contain all emotion information in the to-be-recognized text, and the recognition efficiency of the to-be-recognized text can be improved by cleaning the preset characters.
The combining unit 112 combines every two of the text participles according to the word order to obtain an element pair, where the element pair includes any two adjacent text participles.
In at least one embodiment of the invention, the number of words of each of the text participles in the pair of elements may be set to a value less than a configuration value, for example, the configuration value may be 4.
By setting the number of words of each of the text participles in the element pair, the efficiency of determining the first prediction result can be improved.
The generating unit 113 generates a text vector of the text to be recognized according to the importance of the element pair in a preset corpus.
In at least one embodiment of the present invention, the predetermined corpus stores a plurality of combinations, and each combination stores two words.
In at least one embodiment of the present invention, the generating unit 113 generates the text vector of the text to be recognized according to the importance of the element pair in the corpus, including:
calculating the number of the element pairs in the text to be recognized, and calculating the total number of the element pairs in the preset corpus;
calculating the ratio of the number of the element pairs in the total number of the element pairs to obtain a first frequency of the element pairs;
calculating the total amount of all documents in the preset corpus, and calculating the number of the documents containing the element pairs in the preset corpus;
dividing the total amount of the documents by the number of the documents to obtain an operation result, and calculating a logarithm value of the operation result to obtain a second frequency of the element pair;
determining the importance of the element pair as a product of the first frequency and the second frequency;
and splicing the importance degrees to obtain the text vector.
The importance of the element pair can be accurately determined through the first frequency and the second frequency, and the text vector can be accurately generated according to the importance.
The generating unit 113 generates a first prediction result of the text to be recognized according to the text vector and a first preset network selected from a network library.
In at least one embodiment of the present invention, the network library includes a plurality of trained preset networks and a generation manner corresponding to an input vector in each preset network.
The first prediction result is a result obtained by analyzing the text vector through the first preset network.
In at least one embodiment of the present invention, the generating unit 113 generates the first prediction result of the text to be recognized according to the text vector and a first preset network selected from a network library, where the generating unit includes:
determining the number of a file library according to the preset corpus;
acquiring a network corresponding to the file library number from the network library as the first preset network;
inputting the text vector into the first preset network to obtain a probability value;
determining a target interval of the probability value in a preset result table according to the size of the probability value;
and acquiring a result corresponding to the target interval from the preset result table as the first prediction result.
Wherein the corpus number is used to indicate the corpus to be pre-set.
The preset result table stores mapping relations of a plurality of intervals and the prediction result.
According to the embodiment, a network suitable for analyzing the text vector can be selected from the network library, so that the generation accuracy of the probability value can be improved, and the determination accuracy of the first prediction result can be improved due to the fact that a plurality of numerical values in the target interval correspond to the first prediction result through the relation between the target interval and the first prediction result.
The splicing unit 114 obtains vector values of the text word segmentation from a preset vector table, and splices the vector values according to the word order to obtain a first text matrix of the text to be recognized.
In at least one embodiment of the present invention, the preset vector table stores vectors corresponding to a plurality of vocabularies.
In at least one embodiment of the present invention, the step of splicing the vector values by the splicing unit 114 according to the word order to obtain a first text matrix of the text to be recognized includes:
taking the vector value corresponding to each text word as a row vector;
and combining the row vectors according to the word sequence to obtain the first text matrix.
The processing unit 115 processes the first text matrix according to a preset dimension to obtain a second text matrix.
In at least one embodiment of the present invention, the number of row vectors in the second text matrix is the same as the preset dimension.
In at least one embodiment of the present invention, the processing unit 115 processes the first text matrix according to a preset dimension to obtain a second text matrix, where the processing unit includes:
calculating the number of row vectors in the first text matrix to obtain a matrix row dimension;
detecting whether the matrix row dimension is smaller than the preset dimension;
if the matrix row dimension is smaller than the preset dimension, calculating a difference value between the preset row dimension and the matrix dimension, calculating the number of column vectors in the first text matrix to obtain a matrix column dimension, generating a sub-matrix according to the difference value and the matrix column dimension, and splicing the first text matrix and the sub-matrix to obtain the second text matrix; or
If the matrix row dimension is equal to the preset dimension, determining the first text matrix as the second text matrix; or
If the matrix row dimension is larger than the preset dimension, sequencing each row vector in the first text matrix to obtain a vector serial number, filtering the row vectors with the vector serial numbers larger than the preset dimension, and determining the filtered matrix as the second text matrix.
And the second text matrix with the fixed length can be generated through the preset dimensionality, so that the third preset network can analyze the text to be recognized conveniently.
Specifically, the generating, by the processing unit 115, a sub-matrix according to the difference and the matrix column dimension includes:
acquiring a vector preset value, wherein the vector preset value is usually set to be 0;
and generating a matrix with the row number as the difference value and the column number as the row dimensionality of the matrix as the sub-matrix according to the vector preset value.
The input unit 116 inputs the first text matrix to a second preset network to obtain a second prediction result, and inputs the second text matrix to a third preset network selected from the network library to obtain a third prediction result.
In at least one embodiment of the present invention, the second predetermined network includes a predetermined number of convolutional layers, and the second prediction result is a result generated after the first text matrix is analyzed by the second predetermined network.
The third preset network is a network corresponding to the preset vector table and the preset dimension, and the third prediction result is a result generated after the second text matrix is analyzed through the third preset network.
In at least one embodiment of the present invention, the inputting unit 116 inputs the second text matrix into a third predetermined network selected from the network library, and obtaining a third prediction result includes:
determining the serial number of a preset table according to the preset vector table;
selecting a network corresponding to the preset table number and the preset dimension at the same time from the network library as the third preset network;
acquiring a plurality of convolution kernels in the third preset network, wherein the convolution kernels are different in size;
respectively extracting the features of the second text matrix according to the convolution kernels to obtain a plurality of feature matrices;
compressing the plurality of feature matrices respectively based on a pooling layer in the third preset network to obtain a plurality of compressed vectors, and splicing the plurality of compressed vectors to obtain a pooling vector;
mapping the pooling vector based on a full connection layer in the third preset network to obtain a probability vector;
and determining the category corresponding to the dimension with the largest value in the probability vectors as the third prediction result.
And selecting a network suitable for analyzing the second text matrix from the network library through the preset table number and the preset dimensionality, extracting characteristic information in the second text matrix through multiple dimensionalities of the convolution kernels, and improving the generation accuracy of the probability vector so as to accurately determine the third prediction result.
The generating unit 113 calculates a network weight according to the first preset network, the second preset network, and the third preset network, and generates an emotion result of the text to be recognized according to the network weight, the first prediction result, the second prediction result, and the third prediction result.
It is emphasized that the emotional result may also be stored in a node of a block chain in order to further ensure the privacy and security of the emotional result.
In at least one embodiment of the present invention, the calculating, by the generating unit 113, a network weight according to the first preset network, the second preset network, and the third preset network includes:
acquiring the historical prediction accuracy of the first preset network as a first numerical value, and acquiring the historical prediction accuracy of the second preset network as a second numerical value;
acquiring historical prediction accuracy of the third preset network as a third numerical value;
calculating the sum of the first numerical value, the second numerical value and the third numerical value to obtain a total value;
and generating the network weight according to the occupation ratio of the first numerical value in the total value, the occupation ratio of the second numerical value in the total value and the occupation ratio of the third numerical value in the total value.
And determining the network weight value according to the historical prediction accuracy of the first preset network, the second preset network and the third preset network, so that the determination accuracy of the emotion result is improved.
In at least one embodiment of the present invention, the network weights include a first network weight of the first preset network, a second network weight of the second preset network, and a third network weight of the third preset network, and the generating unit 113 generates the emotion result of the text to be recognized according to the network weights, the first prediction result, the second prediction result, and the third prediction result, where:
determining the same prediction result in the first prediction result, the second prediction result and the third prediction result as a target result, and determining the prediction results except the target result as characteristic results;
calculating a first result probability of the target result according to the network weight, and calculating a second result probability of the characteristic result according to the network weight;
and when the first result probability is larger than the second result probability, determining the target result as the emotion result.
For example, the first prediction result is: pleasure, the second prediction result is: frustration, the third prediction result is: pleasure, it is determined that the target outcome includes the first predicted outcome and the third predicted outcome, i.e., the target outcome is: pleasantly, since the first network weight corresponding to the first prediction result is 0.3 and the third network weight corresponding to the third prediction result is 0.4, the first result probability of the target result is 0.7, and the feature result includes the second prediction result, that is, the feature result is: frustrated, since the second network weight corresponding to the second prediction result is 0.3, the second result probability of the feature result is 0.3, and it is determined that the emotion result is: pleasure.
The first result probability and the second result probability can be accurately determined through the network weight determined by the prediction accuracy, and therefore the determination accuracy of the emotion result is improved.
In at least one embodiment of the present invention, the obtaining unit 110 obtains a request number of the text emotion recognition request;
the generating unit 113 generates prompt information according to the request number and the emotion result;
the encryption unit 117 encrypts the prompt message by using a symmetric encryption technology to obtain a ciphertext;
the sending unit 118 sends the ciphertext to the terminal device of the designated contact.
Wherein the designated contact may be a triggering user of the emotion recognition request.
Through the implementation mode, the emotion result can be sent to the designated contact person in time after the emotion result is generated.
According to the technical scheme, the text vector of the text to be recognized is generated according to the importance of the element pair in the preset corpus, since the text vector is generated by the importance of the pair of elements in the text to be recognized, therefore, the prediction accuracy of the first prediction result can be improved, the prediction efficiency of the third prediction result can be improved by processing the first text matrix through the preset dimensionality, the text to be recognized is analyzed through a plurality of networks such as the first preset network, the second preset network and the third preset network, the semantics of the text to be recognized can be analyzed in multiple directions, and then, the influence of each network on the text to be recognized can be measured through the calculated network weight, so that the emotion result of the text to be recognized can be accurately determined.
FIG. 3 is a schematic structural diagram of an electronic device implementing a text emotion recognition method according to a preferred embodiment of the present invention.
In one embodiment of the present invention, the electronic device 1 includes, but is not limited to, a memory 12, a processor 13, and computer readable instructions stored in the memory 12 and executable on the processor 13, such as a text emotion recognition program.
It will be appreciated by a person skilled in the art that the schematic diagram is only an example of the electronic device 1 and does not constitute a limitation of the electronic device 1, and that it may comprise more or less components than shown, or some components may be combined, or different components, e.g. the electronic device 1 may further comprise an input output device, a network access device, a bus, etc.
The Processor 13 may be a Central Processing Unit (CPU), other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic device, discrete hardware component, etc. The processor 13 is an operation core and a control center of the electronic device 1, and is connected to each part of the whole electronic device 1 by various interfaces and lines, and executes an operating system of the electronic device 1 and various installed application programs, program codes, and the like.
Illustratively, the computer readable instructions may be partitioned into one or more modules/units that are stored in the memory 12 and executed by the processor 13 to implement the present invention. The one or more modules/units may be a series of computer readable instruction segments capable of performing specific functions, which are used for describing the execution process of the computer readable instructions in the electronic device 1. For example, the computer readable instructions may be partitioned into an acquisition unit 110, a pre-processing unit 111, a combining unit 112, a generation unit 113, a splicing unit 114, a processing unit 115, an input unit 116, an encryption unit 117, and a sending unit 118.
The memory 12 may be used for storing the computer readable instructions and/or modules, and the processor 13 implements various functions of the electronic device 1 by executing or executing the computer readable instructions and/or modules stored in the memory 12 and invoking data stored in the memory 12. The memory 12 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 created according to use of the electronic device, and the like. The memory 12 may include non-volatile and volatile memories, such as: a hard disk, a memory, a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), at least one magnetic disk storage device, a Flash memory device, or other storage device.
The memory 12 may be an external memory and/or an internal memory of the electronic device 1. Further, the memory 12 may be a memory having a physical form, such as a memory stick, a TF Card (Trans-flash Card), or the like.
The integrated modules/units of the electronic device 1 may be stored in a computer-readable storage medium if they are implemented in the form of software functional units and sold or used as separate products. Based on such understanding, all or part of the flow of the method according to the above embodiments may be implemented by hardware that is configured to be instructed by computer readable instructions, which may be stored in a computer readable storage medium, and when the computer readable instructions are executed by a processor, the steps of the method embodiments may be implemented.
Wherein the computer readable instructions comprise computer readable instruction code which may be in source code form, object code form, an executable file or some intermediate form, and the like. The computer-readable medium may include: any entity or device capable of carrying said computer readable instruction code, recording medium, U-disk, removable hard disk, magnetic disk, optical disk, computer Memory, Read-Only Memory (ROM), Random Access Memory (RAM).
The block chain is a novel application mode of computer technologies such as distributed data storage, point-to-point transmission, a consensus mechanism, an encryption algorithm and the like. A block chain (Blockchain), which is essentially a decentralized database, is a series of data blocks associated by using a cryptographic method, and each data block contains information of a batch of network transactions, so as to verify the validity (anti-counterfeiting) of the information and generate a next block. The blockchain may include a blockchain underlying platform, a platform product service layer, an application service layer, and the like.
In conjunction with fig. 1, the memory 12 of the electronic device 1 stores computer-readable instructions to implement a text emotion recognition method, and the processor 13 can execute the computer-readable instructions to implement:
when a text emotion recognition request is received, acquiring a text to be recognized according to the text emotion recognition request;
preprocessing the text to be recognized to obtain text participles of the text to be recognized and word sequences of the text participles in the text to be recognized;
combining the text participles pairwise according to the word sequence to obtain an element pair, wherein the element pair comprises any two adjacent text participles;
generating a text vector of the text to be recognized according to the importance of the element pair in a preset corpus;
generating a first prediction result of the text to be recognized according to the text vector and a first preset network selected from a network library;
obtaining vector values of the text word segmentation from a preset vector table, and splicing the vector values according to the word sequence to obtain a first text matrix of the text to be recognized;
processing the first text matrix according to a preset dimension to obtain a second text matrix;
inputting the first text matrix into a second preset network to obtain a second prediction result, and inputting the second text matrix into a third preset network selected from the network library to obtain a third prediction result;
and calculating a network weight according to the first preset network, the second preset network and the third preset network, and generating an emotion result of the text to be recognized according to the network weight, the first prediction result, the second prediction result and the third prediction result.
Specifically, the processor 13 may refer to the description of the relevant steps in the embodiment corresponding to fig. 1 for a specific implementation method of the computer readable instructions, which is not described herein again.
In the embodiments provided in the present invention, it should be understood that the disclosed system, apparatus and method may be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the modules is only one logical functional division, and other divisions may be realized in practice.
The computer readable storage medium has computer readable instructions stored thereon, wherein the computer readable instructions when executed by the processor 13 are configured to implement the steps of:
when a text emotion recognition request is received, acquiring a text to be recognized according to the text emotion recognition request;
preprocessing the text to be recognized to obtain text participles of the text to be recognized and word sequences of the text participles in the text to be recognized;
combining the text participles pairwise according to the word sequence to obtain an element pair, wherein the element pair comprises any two adjacent text participles;
generating a text vector of the text to be recognized according to the importance of the element pair in a preset corpus;
generating a first prediction result of the text to be recognized according to the text vector and a first preset network selected from a network library;
obtaining vector values of the text word segmentation from a preset vector table, and splicing the vector values according to the word sequence to obtain a first text matrix of the text to be recognized;
processing the first text matrix according to a preset dimension to obtain a second text matrix;
inputting the first text matrix into a second preset network to obtain a second prediction result, and inputting the second text matrix into a third preset network selected from the network library to obtain a third prediction result;
and calculating a network weight according to the first preset network, the second preset network and the third preset network, and generating an emotion result of the text to be recognized according to the network weight, the first prediction result, the second prediction result and the third prediction result.
The modules described as separate parts may or may not be physically separate, and parts displayed as modules may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
In addition, functional modules in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, or in a form of hardware plus a software functional module.
The present embodiments are therefore to be considered in all respects as illustrative and not restrictive, the scope of the invention being indicated by the appended claims rather than by the foregoing description, and all changes which come within the meaning and range of equivalency of the claims are therefore intended to be embraced therein. Any reference signs in the claims shall not be construed as limiting the claim concerned.
Furthermore, it is obvious that the word "comprising" does not exclude other elements or steps, and the singular does not exclude the plural. A plurality of units or devices may also be implemented by one unit or device through software or hardware. The terms first, second, etc. are used to denote names, but not any particular order.
Finally, it should be noted that the above embodiments are only intended to illustrate the technical solutions of the present invention and not to limit the same, and although the present invention is described in detail with reference to the preferred embodiments, it should be understood by those skilled in the art that modifications or equivalent substitutions can be made to the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention.

Claims (9)

1. A text emotion recognition method is characterized by comprising the following steps:
when a text emotion recognition request is received, acquiring a text to be recognized according to the text emotion recognition request;
preprocessing the text to be recognized to obtain text participles of the text to be recognized and word sequences of the text participles in the text to be recognized;
combining the text participles pairwise according to the word sequence to obtain an element pair, wherein the element pair comprises any two adjacent text participles;
generating a text vector of the text to be recognized according to the importance of the element pair in a preset corpus, comprising: calculating the number of the element pairs in the text to be recognized, and calculating the total number of the element pairs in the preset corpus; calculating the ratio of the number of the element pairs in the total number of the element pairs to obtain a first frequency of the element pairs; calculating the total amount of all documents in the preset corpus, and calculating the number of the documents containing the element pairs in the preset corpus; dividing the total amount of the documents by the number of the documents to obtain an operation result, and calculating a logarithm value of the operation result to obtain a second frequency of the element pair; determining the importance of the element pair as a product of the first frequency and the second frequency; splicing the importance degrees to obtain the text vector;
generating a first prediction result of the text to be recognized according to the text vector and a first preset network selected from a network library;
obtaining vector values of the text word segmentation from a preset vector table, and splicing the vector values according to the word sequence to obtain a first text matrix of the text to be recognized;
processing the first text matrix according to a preset dimension to obtain a second text matrix;
inputting the first text matrix into a second preset network to obtain a second prediction result, and inputting the second text matrix into a third preset network selected from the network library to obtain a third prediction result;
and calculating a network weight according to the first preset network, the second preset network and the third preset network, and generating an emotion result of the text to be recognized according to the network weight, the first prediction result, the second prediction result and the third prediction result.
2. The method for emotion recognition of text according to claim 1, wherein the preprocessing the text to be recognized to obtain the text participles of the text to be recognized and the word sequences of the text participles in the text to be recognized comprises:
extracting an expression packet from the text to be recognized;
determining an expression text corresponding to the expression packet from an expression library, and replacing the expression packet in the text to be recognized with the expression text to obtain a text to be processed;
cleaning preset symbols in the text to be processed to obtain a processed text;
performing word segmentation on the processed text to obtain the text word segmentation;
and determining the position of the text word in the text to be recognized to obtain the word sequence.
3. The method for emotion recognition of text as recited in claim 1, wherein the generating of the first prediction result of the text to be recognized according to the text vector and the first predetermined network selected from the network library comprises:
determining the number of a file library according to the preset corpus;
acquiring a network corresponding to the file library number from the network library as the first preset network;
inputting the text vector into the first preset network to obtain a probability value;
determining a target interval of the probability value in a preset result table according to the size of the probability value;
and acquiring a result corresponding to the target interval from the preset result table as the first prediction result.
4. The method for recognizing text emotion according to claim 1, wherein the step of processing the first text matrix according to the preset dimension to obtain the second text matrix comprises:
calculating the number of row vectors in the first text matrix to obtain matrix row dimensions;
detecting whether the matrix row dimension is smaller than the preset dimension;
if the matrix row dimension is smaller than the preset dimension, calculating a difference value between the preset dimension and the matrix row dimension, calculating the number of column vectors in the first text matrix to obtain a matrix column dimension, generating a sub-matrix according to the difference value and the matrix column dimension, and splicing the first text matrix and the sub-matrix to obtain the second text matrix; or
If the matrix row dimension is equal to the preset dimension, determining the first text matrix as the second text matrix; or
If the matrix row dimension is larger than the preset dimension, sequencing each row vector in the first text matrix to obtain a vector serial number, filtering the row vectors with the vector serial numbers larger than the preset dimension, and determining the filtered matrix as the second text matrix.
5. The method for emotion recognition of text as recited in claim 1, wherein said inputting said second text matrix into a third predetermined network selected from said network library, and obtaining a third prediction result comprises:
determining the serial number of a preset table according to the preset vector table;
selecting a network corresponding to the preset table number and the preset dimension at the same time from the network library as the third preset network;
acquiring a plurality of convolution kernels in the third preset network, wherein the convolution kernels are different in size;
respectively extracting the features of the second text matrix according to the convolution kernels to obtain a plurality of feature matrices;
compressing the plurality of feature matrices respectively based on a pooling layer in the third preset network to obtain a plurality of compressed vectors, and splicing the plurality of compressed vectors to obtain a pooling vector;
mapping the pooling vector based on a full connection layer in the third preset network to obtain a probability vector;
and determining the category corresponding to the dimension with the largest value in the probability vectors as the third prediction result.
6. The method for emotion recognition of text according to claim 1, wherein said calculating the network weights according to the first predetermined network, the second predetermined network and the third predetermined network comprises:
acquiring the historical prediction accuracy of the first preset network as a first numerical value, and acquiring the historical prediction accuracy of the second preset network as a second numerical value;
acquiring historical prediction accuracy of the third preset network as a third numerical value;
calculating the sum of the first numerical value, the second numerical value and the third numerical value to obtain a total value;
and generating the network weight according to the occupation ratio of the first numerical value in the total value, the occupation ratio of the second numerical value in the total value and the occupation ratio of the third numerical value in the total value.
7. A text emotion recognition apparatus, characterized in that the text emotion recognition apparatus includes:
the acquiring unit is used for acquiring a text to be recognized according to the text emotion recognition request when the text emotion recognition request is received;
the preprocessing unit is used for preprocessing the text to be recognized to obtain text participles of the text to be recognized and word sequences of the text participles in the text to be recognized;
the combination unit is used for combining every two text participles according to the word sequence to obtain an element pair, and the element pair comprises any two adjacent text participles;
the generating unit is used for generating the text vector of the text to be recognized according to the importance of the element pair in a preset corpus, and comprises the following steps: calculating the number of the element pairs in the text to be recognized, and calculating the total number of the element pairs in the preset corpus; calculating the ratio of the number of the element pairs in the total number of the element pairs to obtain a first frequency of the element pairs; calculating the total amount of all documents in the preset corpus, and calculating the number of the documents containing the element pairs in the preset corpus; dividing the total amount of the documents by the number of the documents to obtain an operation result, and calculating a logarithm value of the operation result to obtain a second frequency of the element pair; determining the importance of the element pair as a product of the first frequency and the second frequency; splicing the importance degrees to obtain the text vector;
the generating unit is further used for generating a first prediction result of the text to be recognized according to the text vector and a first preset network selected from a network library;
the splicing unit is used for acquiring vector values of the text word segmentation from a preset vector table and splicing the vector values according to the word sequence to obtain a first text matrix of the text to be recognized;
the processing unit is used for processing the first text matrix according to a preset dimension to obtain a second text matrix;
the input unit is used for inputting the first text matrix into a second preset network to obtain a second prediction result, and inputting the second text matrix into a third preset network selected from the network library to obtain a third prediction result;
the generating unit is further configured to calculate a network weight according to the first preset network, the second preset network, and the third preset network, and generate an emotion result of the text to be recognized according to the network weight, the first prediction result, the second prediction result, and the third prediction result.
8. An electronic device, characterized in that the electronic device comprises:
a memory storing computer readable instructions; and
a processor executing computer readable instructions stored in the memory to implement the text emotion recognition method as claimed in any one of claims 1 to 6.
9. A computer-readable storage medium characterized by: the computer readable storage medium stores computer readable instructions, and the computer readable instructions are executed by a processor in the electronic device to realize the text emotion recognition method according to any one of claims 1 to 6.
CN202110565815.4A 2021-05-24 2021-05-24 Text emotion recognition method, device and equipment and storage medium Active CN113268562B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110565815.4A CN113268562B (en) 2021-05-24 2021-05-24 Text emotion recognition method, device and equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110565815.4A CN113268562B (en) 2021-05-24 2021-05-24 Text emotion recognition method, device and equipment and storage medium

Publications (2)

Publication Number Publication Date
CN113268562A CN113268562A (en) 2021-08-17
CN113268562B true CN113268562B (en) 2022-05-13

Family

ID=77232402

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110565815.4A Active CN113268562B (en) 2021-05-24 2021-05-24 Text emotion recognition method, device and equipment and storage medium

Country Status (1)

Country Link
CN (1) CN113268562B (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110675859A (en) * 2019-09-05 2020-01-10 华南理工大学 Multi-emotion recognition method, system, medium, and apparatus combining speech and text
CN110675858A (en) * 2019-08-29 2020-01-10 平安科技(深圳)有限公司 Terminal control method and device based on emotion recognition
CN111241828A (en) * 2020-01-10 2020-06-05 平安科技(深圳)有限公司 Intelligent emotion recognition method and device and computer readable storage medium
CN112100375A (en) * 2020-09-10 2020-12-18 清华大学 Text information generation method and device, storage medium and equipment
CN112199500A (en) * 2020-09-30 2021-01-08 北京猎豹移动科技有限公司 Emotional tendency identification method and device for comments and electronic equipment

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107168952B (en) * 2017-05-15 2021-06-04 北京百度网讯科技有限公司 Information generation method and device based on artificial intelligence
WO2021056127A1 (en) * 2019-09-23 2021-04-01 Beijing Didi Infinity Technology And Development Co., Ltd. Systems and methods for analyzing sentiment

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110675858A (en) * 2019-08-29 2020-01-10 平安科技(深圳)有限公司 Terminal control method and device based on emotion recognition
CN110675859A (en) * 2019-09-05 2020-01-10 华南理工大学 Multi-emotion recognition method, system, medium, and apparatus combining speech and text
CN111241828A (en) * 2020-01-10 2020-06-05 平安科技(深圳)有限公司 Intelligent emotion recognition method and device and computer readable storage medium
CN112100375A (en) * 2020-09-10 2020-12-18 清华大学 Text information generation method and device, storage medium and equipment
CN112199500A (en) * 2020-09-30 2021-01-08 北京猎豹移动科技有限公司 Emotional tendency identification method and device for comments and electronic equipment

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
基于NMF的Web评论情感分类方法研究;任静等;《电脑知识与技术》(第18期);第167-170页 *
基于词向量特征的文本分类模型研究;张敬谊等;《信息技术与标准化》;20170510(第05期);第71-75页 *

Also Published As

Publication number Publication date
CN113268562A (en) 2021-08-17

Similar Documents

Publication Publication Date Title
CN111694826B (en) Data enhancement method and device based on artificial intelligence, electronic equipment and medium
CN113032528B (en) Case analysis method, case analysis device, case analysis equipment and storage medium
CN112989826B (en) Test question score determining method, device, equipment and medium based on artificial intelligence
CN113656547B (en) Text matching method, device, equipment and storage medium
CN113094478B (en) Expression reply method, device, equipment and storage medium
CN113408278B (en) Intention recognition method, device, equipment and storage medium
CN111597309A (en) Similar enterprise recommendation method and device, electronic equipment and medium
CN113283675B (en) Index data analysis method, device, equipment and storage medium
CN113435196A (en) Intention recognition method, device, equipment and storage medium
CN113268597B (en) Text classification method, device, equipment and storage medium
CN114037545A (en) Client recommendation method, device, equipment and storage medium
WO2021174923A1 (en) Concept word sequence generation method, apparatus, computer device, and storage medium
CN113268562B (en) Text emotion recognition method, device and equipment and storage medium
CN112989044B (en) Text classification method, device, equipment and storage medium
CN113326365B (en) Reply sentence generation method, device, equipment and storage medium
CN113408265B (en) Semantic analysis method, device and equipment based on human-computer interaction and storage medium
CN113343700B (en) Data processing method, device, equipment and storage medium
CN114581177A (en) Product recommendation method, device, equipment and storage medium
CN114238296A (en) Product index data display method, device, equipment and storage medium
CN113283389A (en) Handwritten character quality detection method, device, equipment and storage medium
CN113420545A (en) Abstract generation method, device, equipment and storage medium
CN113468334B (en) Ciphertext emotion classification method, device, equipment and storage medium
CN113421575B (en) Voiceprint recognition method, voiceprint recognition device, voiceprint recognition equipment and storage medium
CN113420143B (en) Method, device, equipment and storage medium for generating document abstract
CN113283421B (en) Information identification method, device, equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant