CN108733644B - A kind of text emotion analysis method, computer readable storage medium and terminal device - Google Patents

A kind of text emotion analysis method, computer readable storage medium and terminal device Download PDF

Info

Publication number
CN108733644B
CN108733644B CN201810309676.7A CN201810309676A CN108733644B CN 108733644 B CN108733644 B CN 108733644B CN 201810309676 A CN201810309676 A CN 201810309676A CN 108733644 B CN108733644 B CN 108733644B
Authority
CN
China
Prior art keywords
vector
text
participle
input
affective style
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
CN201810309676.7A
Other languages
Chinese (zh)
Other versions
CN108733644A (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 CN201810309676.7A priority Critical patent/CN108733644B/en
Priority to PCT/CN2018/093344 priority patent/WO2019196208A1/en
Publication of CN108733644A publication Critical patent/CN108733644A/en
Application granted granted Critical
Publication of CN108733644B publication Critical patent/CN108733644B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/20Natural language analysis
    • G06F40/205Parsing
    • G06F40/216Parsing using statistical methods
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/20Natural language analysis
    • G06F40/205Parsing
    • G06F40/211Syntactic parsing, e.g. based on context-free grammar [CFG] or unification grammars
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/20Natural language analysis
    • G06F40/237Lexical tools
    • G06F40/247Thesauruses; Synonyms
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/20Natural language analysis
    • G06F40/279Recognition of textual entities
    • G06F40/284Lexical analysis, e.g. tokenisation or collocates
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/30Semantic analysis

Abstract

The invention belongs to field of computer technology more particularly to a kind of text emotion analysis methods, computer readable storage medium and terminal device.The method carries out word cutting processing to statement text to be analyzed, obtains each participle for constituting the statement text;Search the column vector of each participle respectively in preset term vector database, and by the Column vector groups of each participle at input matrix, wherein, each column of the input matrix correspond to a column vector, and the term vector database is the database for recording the corresponding relationship between word and column vector;The emotion main body that a participle corresponding with preset analysis object is analyzed as text emotion is chosen from the statement text;The input matrix and input vector are input in preset text emotion analysis neural network model, affective style of the emotion main body in the statement text is obtained, the input vector is the column vector of the emotion main body.

Description

A kind of text emotion analysis method, computer readable storage medium and terminal device
Technical field
The invention belongs to field of computer technology more particularly to a kind of text emotion analysis methods, computer-readable storage Medium and terminal device.
Background technique
Text emotion analysis refers to that text is divided into front or negative by the meaning according to expressed by text and emotion information The technology of two or more affective styles.Current text emotion analysis method mainly counts in text and represents different emotions Adjectival quantity, and to this carry out a quantitative analysis, this method to only include single emotional main body statement text into Accuracy rate is higher when row sentiment analysis, but when carrying out sentiment analysis to the statement text comprising multiple emotion main bodys, is then difficult to Reflect the mixed feeling of multiple emotion main bodys, for example, a certain statement text is " company A sales achievement substantially surmounts B company ", In, two emotion main bodys, respectively " company A " and " B company ", for emotion main body " company A ", the sentence are contained altogether Text should be positive emotion type, but for emotion main body " B company ", which is but negative affective style, And the obtained analysis of current text emotion analysis method is the result is that unrelated with emotion main body, can only obtain one it is unique The affective style of emotion main body is not distinguished.
Summary of the invention
In view of this, the embodiment of the invention provides a kind of text emotion analysis method, computer readable storage medium and Terminal device is difficult to reflect the mixed feeling of multiple emotion main bodys with the text emotion analysis method for solving the problems, such as current.
The first aspect of the embodiment of the present invention provides a kind of text emotion analysis method, may include:
Word cutting processing is carried out to statement text to be analyzed, obtains each participle for constituting the statement text;
Search the column vector of each participle respectively in preset term vector database, and by each participle Column vector groups are at input matrix, wherein each column of the input matrix correspond to a column vector, the term vector database The database of corresponding relationship between record word and column vector;
Choose what a participle corresponding with preset analysis object was analyzed as text emotion from the statement text Emotion main body;
The input matrix and input vector are input in preset text emotion analysis neural network model, institute is obtained Affective style of the emotion main body in the statement text is stated, the input vector is the column vector of the emotion main body.
The second aspect of the embodiment of the present invention provides a kind of computer readable storage medium, the computer-readable storage Media storage has computer-readable instruction, and the computer-readable instruction realizes following steps when being executed by processor:
Word cutting processing is carried out to statement text to be analyzed, obtains each participle for constituting the statement text;
Search the column vector of each participle respectively in preset term vector database, and by each participle Column vector groups are at input matrix, wherein each column of the input matrix correspond to a column vector, the term vector database The database of corresponding relationship between record word and column vector;
Choose what a participle corresponding with preset analysis object was analyzed as text emotion from the statement text Emotion main body;
The input matrix and input vector are input in preset text emotion analysis neural network model, institute is obtained Affective style of the emotion main body in the statement text is stated, the input vector is the column vector of the emotion main body.
The third aspect of the embodiment of the present invention provides a kind of text emotion analysing terminal equipment, including memory, processing Device and storage in the memory and the computer-readable instruction that can run on the processor, the processor execution Following steps are realized when the computer-readable instruction:
Word cutting processing is carried out to statement text to be analyzed, obtains each participle for constituting the statement text;
Search the column vector of each participle respectively in preset term vector database, and by each participle Column vector groups are at input matrix, wherein each column of the input matrix correspond to a column vector, the term vector database The database of corresponding relationship between record word and column vector;
Choose what a participle corresponding with preset analysis object was analyzed as text emotion from the statement text Emotion main body;
The input matrix and input vector are input in preset text emotion analysis neural network model, institute is obtained Affective style of the emotion main body in the statement text is stated, the input vector is the column vector of the emotion main body.
Existing beneficial effect is the embodiment of the present invention compared with prior art: the embodiment of the present invention is first to be analyzed Statement text carries out word cutting processing, each participle for constituting the statement text is obtained, then in preset term vector database The middle column vector for searching each participle respectively, and by the Column vector groups of each participle at input matrix, then from described The emotion main body that a participle corresponding with preset analysis object is analyzed as text emotion is chosen in statement text, finally will The input matrix and input vector are input in preset text emotion analysis neural network model, obtain the emotion main body Affective style in the statement text.Compared with prior art, in addition to considering whole sentence text in the embodiment of the present invention This is outer, and also by the column vector of emotion main body as an individually input, by the processing of neural network model, what is obtained is Emotion main body has also been selected as the final feelings of influence by affective style of the emotion main body in the statement text Feel a decision condition of type, in this way, when carrying out sentiment analysis to the statement text comprising multiple emotion main bodys, by right The selection of different emotion main bodys, available corresponding affective style, admirably reflects answering for multiple emotion main bodys Miscellaneous emotion.
Detailed description of the invention
It to describe the technical solutions in the embodiments of the present invention more clearly, below will be to embodiment or description of the prior art Needed in attached drawing be briefly described, it should be apparent that, the accompanying drawings in the following description is only of the invention some Embodiment for those of ordinary skill in the art without any creative labor, can also be according to these Attached drawing obtains other attached drawings.
Fig. 1 is a kind of one embodiment flow chart of text emotion analysis method in the embodiment of the present invention;
Fig. 2 is the schematic flow diagram for searching the column vector currently segmented in the embodiment of the present invention in term vector database;
Fig. 3 is the exemplary flow of the data handling procedure of text sentiment analysis neural network model in the embodiment of the present invention Figure;
Fig. 4 is the schematic flow diagram of the training process of text sentiment analysis neural network model in the embodiment of the present invention;
Fig. 5 is a kind of one embodiment structure chart of text emotion analytical equipment in the embodiment of the present invention;
Fig. 6 is a kind of schematic block diagram of text emotion analysing terminal equipment in the embodiment of the present invention.
Specific embodiment
In order to make the invention's purpose, features and advantages of the invention more obvious and easy to understand, below in conjunction with the present invention Attached drawing in embodiment, technical scheme in the embodiment of the invention is clearly and completely described, it is clear that disclosed below Embodiment be only a part of the embodiment of the present invention, and not all embodiment.Based on the embodiments of the present invention, this field Those of ordinary skill's all other embodiment obtained without making creative work, belongs to protection of the present invention Range.
Referring to Fig. 1, a kind of one embodiment of text emotion analysis method may include: in the embodiment of the present invention
Step S101 carries out word cutting processing to statement text to be analyzed, obtains each point that constitutes the statement text Word.
Word cutting processing, which refers to, is cut into individual word one by one namely each participle for a statement text, In the present embodiment, cutting can be carried out to statement text according to universaling dictionary, guaranteeing the word separated all is normal vocabulary, such as word Language does not separate individual character then in dictionary.When front-rear direction can be at word, such as " praying to Gods for blessing ", it can be according to the big of statistics word frequency Small division, as " it is required that " " it is required that/mind " is separated if word frequency height, " want/pray to Gods for blessing " is separated if " praying to Gods for blessing " word frequency height.
After splitting out each participle, if considering binary combination word, then neighbouring word combination of two can be increased " celebration meeting ", " conference is smooth ", the binary combinations word such as " smoothly closing ".It preferably, can also be further according to word frequency to these Binary combination word is screened.Specifically, the frequency threshold for presetting a screening obtains what each binary combination word occurred Frequency retains the binary combination word if the frequency that some binary combination word occurs is greater than or equal to the frequency threshold, if some The frequency that binary combination word occurs is less than the frequency threshold, then weeds out the binary combination word, namely be regarded as two independences Unitary word.If the frequency threshold that we set as 5, rejects all frequency of occurrence in 5 binary combination words below.
Step S102 searches the column vector of each participle respectively in preset term vector database.
The term vector database is the database for recording the corresponding relationship between word and column vector.The column vector can To be the corresponding term vector according to obtained by word2vec model training word.This is indicated according to the contextual information of word The probability that word occurs.Each vocabulary is first shown as a 0-1 vector still according to the thought of word2vec by the training of term vector (one-hot) form, then word2vec model training is carried out with term vector, n-th of word, neural network are predicted with n-1 word The pilot process obtained after model prediction is as term vector.Specifically, as " celebrations " one-hot vector assume be set to [1,0, 0,0 ... ..., 0], the one-hot vector of " conference " is [0,1,0,0 ... ..., 0], the one-hot vector of " smooth " for [0,0, 1,0 ... ..., 0], predict that the vector [0,0,0,1 ... ..., 0] of " closing ", model can generate the coefficient square of hidden layer by training Battle array W, the product of the one-hot vector sum coefficient matrix of each word are the term vector of the word, and last form will be analogous to " celebrating Wish [- 0.28,0.34, -0.02 ... ..., 0.92] " such a multi-C vector.
In the present embodiment, the term vector database can be K grades of tree-shaped fragment storage organizations, then step S102 can be with Include the steps that as shown in Figure 2:
Step S1021 carries out Hash operation to current participle using multiple mutually independent hash functions.
The current participle is any one of participle.
Specifically, Hash fortune can be carried out to current participle using K mutually independent hash functions respectively according to the following formula It calculates:
HashKeyk=HASHk(BasicWord)
Wherein, BasicWord is the current participle, HASHkFor the hash function of serial number k, HashKeykIt is obtained for operation The cryptographic Hash of the serial number k arrived, 1≤k≤K, K are the integer greater than 1.
Step S1022 calculates the serial number of storage fragment at different levels belonging to the current participle.
Specifically, the serial number of the storage fragment of kth grade belonging to the current participle can be calculated according to the following formula:
Wherein, MaxHashKeykFor hash function HASHkMaximum value, FragNumkFor the storage point of kth grade subtree The number of piece, Ceil are the function that rounds up, and Floor is downward bracket function, and WordRoute is the number in record storage path Group, WordRoute [k-1] are the serial number of kth grade fragment belonging to the current participle, and are k-th yuan of WordRoute Element.
Step S1023 searches the column vector currently segmented under the store path of record.
Specifically, i.e., the column vector currently segmented is searched under the store path that array WordRoute is recorded.Example Such as, if array WordRoute=[1,2,1,3,5], then store path are as follows: storage fragment-> 2nd of the 1st grade of subtree serial number 1 The storage of storage fragment-> 3rd level subtree serial number 1 storage fragment-> 4th grade subtree serial number 3 of grade subtree serial number 2 The storage fragment of fragment-> 5th grade subtree serial number 5 searches the column vector currently segmented under the store path.
Step S103, by the Column vector groups of each participle at input matrix.
Wherein, each column of the input matrix correspond to a column vector, i.e., the Column vector groups of first participle are at institute Show the first row of input matrix, secondary series ... ... of the Column vector groups of second participle at shown input matrix, n-th participle Column vector groups at shown input matrix Nth column.N is the number of the participle.
Step S104 chooses a participle corresponding with preset analysis object from the statement text and is used as text feelings Feel the emotion main body of analysis.
For example, a certain statement text is " company A sales achievement substantially surmounts B company ", wherein there are two emotion main bodys altogether It is available, respectively " company A " and " B company ", if current emotion class for wanting analysis " company A " in the statement text Type, i.e., the described analysis object are " company A ", then choose the emotion main body that " company A " is analyzed as text emotion, if current want The affective style of " B company " in the statement text is analyzed, i.e., the described analysis object is " B company ", then chooses " B company " work For the emotion main body of text emotion analysis.
The input matrix and input vector are input to preset text emotion and analyze neural network model by step S105 In, obtain affective style of the emotion main body in the statement text.
The input vector is the column vector of the emotion main body.
The data handling procedure of the text emotion analysis neural network model may include step as shown in Figure 3:
Step S1051 calculates the coupling vector between the input matrix and the input vector.
Specifically, the coupling vector between the input matrix and the input vector can be calculated according to the following formula:
CoupVec=(CoupFactor1,CoupFactor2,......,CoupFactorn,......, CoupFactorN)T,
Wherein, 1≤n≤N, N are the columns of the input matrix, and T is transposition symbol,
WordVecnFor the input matrix n-th column, MainVec be the input vector, WeightMatrix, WeightMatrix ' is preset weight matrix,CoupVec is the coupling vector.
Step S1052 calculates the composite vector of the statement text.
Specifically, the composite vector of the statement text can be calculated according to the following formula:
CompVec=WordMatrix*CoupVec,
Wherein, CompVec is the composite vector, and WordMatrix is the input matrix,
And WordMatrix=(WordVec1,WordVec2,......,WordVecn,......,WordVecN)。
Step S1053 calculates separately the probability value of each affective style.
Specifically, the probability value of each affective style can be calculated separately according to the following formula:
Wherein, 1≤m≤M, M are the number of affective style, WeightMatrixmFor preset and m-th of affective style pair The weight matrix answered, ProbmFor the probability value of m-th of affective style.
Specific affective style classification can be arranged according to the actual situation, for example, can be classified as positive emotion type and Two class of negative emotion type can also be classified as positive emotion type, negative emotion type and neutral affective style three classes, also It can be classified as more types.
The maximum affective style of probability value is determined as the emotion main body in the statement text by step S1054 Affective style.
Preferably, the training process of the text emotion analysis neural network model may include step as shown in Figure 4:
Step S401 chooses the training sample of preset number.
Each sample includes an input matrix, an input vector and an anticipated output affective style.
Preferably, training sample can be chosen in pairs in the form of training sample pair, each training sample is to including two The input matrix of training sample, two training samples of same training sample centering is identical, is each point of same statement text The input vector of matrix composed by the column vector of word, two training samples of same training sample centering is different, respectively together The column vector of two different emotions main bodys of one statement text, the anticipated output of two training samples of same training sample centering Affective style is different, and one is front affective style, another is negative affective style.
Step S402, by each training sample be separately input in text emotion analysis neural network model into Row processing.
Specific treatment process is similar with step S105, specifically can refer to the explanation in step S105, details are not described herein.
Step S403 calculates the global error of epicycle training.
Specifically, the global error of epicycle training can be calculated according to the following formula:
Wherein, CalcProbl,mFor probability value of m-th of affective style in first of training sample, ExpProbl,mIt is Expected probability value of the m affective style in first of training sample,
AndExpSeq is the anticipated output affective style of first of training sample Serial number, 1≤l≤L, L be the training sample number, 1≤m≤M, M be affective style number, ln be natural logrithm letter Number, LOSSlFor the training error of first of training sample, LOSS is the global error.
Step S404, judges whether the global error is less than preset error threshold.
If the global error is greater than or equal to the error threshold, S405 is thened follow the steps, if the global error is small In the error threshold, S406 is thened follow the steps.
Step S405 is adjusted the parameter of text emotion analysis neural network model.
The parameter specifically adjusted may include above-mentioned WeightMatrix, WeightMatrix ', WeightMatrixm Etc. parameters.After completing parameter adjustment, S402 is returned to step, until the global error is less than the error threshold Only.
Step S405 terminates training.
When the global error is less than the error threshold, that is, the text emotion analysis neural network model is illustrated Reached expected analysis precision, the training process to it can be terminated at this time, carries out actual text emotion analysis using it.
In conclusion the embodiment of the present invention carries out word cutting processing to statement text to be analyzed first, obtain described in composition Then each participle of statement text searches the column vector of each participle respectively in preset term vector database, and By the Column vector groups of each participle at input matrix, then one and preset analysis object are chosen from the statement text It is corresponding to segment the emotion main body analyzed as text emotion, finally the input matrix and input vector are input to preset Text emotion is analyzed in neural network model, and affective style of the emotion main body in the statement text is obtained.With it is existing Technology is compared, in the embodiment of the present invention other than considering whole statement text, also by the column vector of emotion main body as one A individual input, by the processing of neural network model, what is obtained is feelings of the emotion main body in the statement text Type is felt, also i.e. by a decision condition for being selected as the final affective style of influence for emotion main body, in this way, to packet When statement text containing multiple emotion main bodys carries out sentiment analysis, by the selection to different emotion main bodys, it is available with Corresponding affective style, admirably reflect the mixed feeling of multiple emotion main bodys.
It should be understood that the size of the serial number of each step is not meant that the order of the execution order in above-described embodiment, each process Execution sequence should be determined by its function and internal logic, the implementation process without coping with the embodiment of the present invention constitutes any limit It is fixed.
Corresponding to a kind of text emotion analysis method described in foregoing embodiments, Fig. 5 shows offer of the embodiment of the present invention A kind of text emotion analytical equipment one embodiment structure chart.
In the present embodiment, a kind of text emotion analytical equipment may include:
Text word cutting module 501 obtains constituting the sentence text for carrying out word cutting processing to statement text to be analyzed This each participle;
Column vector searching module 502, for searching the column of each participle respectively in preset term vector database Vector, the term vector database are the database for recording the corresponding relationship between word and column vector;
Input matrix comprising modules 503, for by the Column vector groups of each participle at input matrix, wherein it is described Each column of input matrix correspond to a column vector;
Emotion main body chooses module 504, corresponding with preset analysis object for choosing one from the statement text The emotion main body analyzed as text emotion of participle;
Text emotion analysis module 505, for the input matrix and input vector to be input to preset text emotion It analyzes in neural network model, obtains affective style of the emotion main body in the statement text, the input vector is The column vector of the emotion main body.
Further, the text emotion analysis module may include:
Vector calculation unit is coupled, for calculating the coupling between the input matrix and the input vector according to the following formula Vector:
CoupVec=(CoupFactor1,CoupFactor2,......,CoupFactorn,......, CoupFactorN)T,
Wherein, 1≤n≤N, N are the columns of the input matrix, and T is transposition symbol,
WordVecnFor the input matrix n-th column, MainVec be the input vector, WeightMatrix, WeightMatrix ' is preset weight matrix,CoupVec is the coupling vector;
Composite vector computing unit, for calculating the composite vector of the statement text according to the following formula:
CompVec=WordMatrix*CoupVec,
Wherein, CompVec is the composite vector, and WordMatrix is the input matrix, and WordMatrix= (WordVec1,WordVec2,......,WordVecn,......,WordVecN);
Affective style probability value computing unit, for calculating separately the probability value of each affective style according to the following formula:
Wherein, 1≤m≤M, M are the number of affective style, WeightMatrixmFor preset and m-th of affective style pair The weight matrix answered, ProbmFor the probability value of m-th of affective style;
Affective style determination unit, for the maximum affective style of probability value to be determined as the emotion main body in institute's predicate Affective style in sentence text.
Further, the text emotion analytical equipment can also include:
Training sample chooses module, for choosing the training sample of preset number, each sample include an input matrix, One input vector and an anticipated output affective style;
Global error computing module analyzes nerve for each training sample to be separately input to the text emotion It is handled in network model, and calculates the global error of epicycle training according to the following formula:
Wherein, CalcProbl,mFor probability value of m-th of affective style in first of training sample, ExpProbl,mIt is Expected probability value of the m affective style in first of training sample, andExpSeq For the serial number of the anticipated output affective style of first of training sample, 1≤l≤L, L are the number of the training sample, 1≤m≤ M, M are the number of affective style, and ln is natural logrithm function, LOSSlFor the training error of first of training sample, LOSS is institute State global error;
Parameter adjustment module, if being greater than or equal to preset error threshold for the global error, to the text The parameter of sentiment analysis neural network model is adjusted;
Terminate training module, if being less than the error threshold for the global error, terminates to train.
Further, the training sample selection module may include:
First selection unit chooses training sample for the form with training sample pair in pairs, and each training sample is to packet Two training samples are included, the input matrix of two training samples of same training sample centering is identical, is same statement text The input vector of matrix composed by the column vector of each participle, two training samples of same training sample centering is different, point Not Wei same statement text two different emotions main bodys column vector, two training samples of same training sample centering it is pre- Phase exports affective style difference, and one is front affective style, another is negative affective style.
Further, the column vector searching module may include:
Hash operation unit, for being carried out respectively using K mutually independent hash functions to current participle according to the following formula Hash operation, the current participle is any one of participle:
HashKeyk=HASHk(BasicWord)
Wherein, BasicWord is the current participle, HASHkFor the hash function of serial number k, HashKeykIt is obtained for operation The cryptographic Hash of the serial number k arrived, 1≤k≤K, K are the integer greater than 1;
Fragment serial number computing unit is stored, for calculating the storage fragment of kth grade belonging to the current participle according to the following formula Serial number:
Wherein, MaxHashKeykFor hash function HASHkMaximum value, FragNumkFor the storage point of kth grade subtree The number of piece, Ceil are the function that rounds up, and Floor is downward bracket function, and WordRoute is the number in record storage path Group, WordRoute [k-1] are the serial number of kth grade fragment belonging to the current participle, and are k-th yuan of WordRoute Element;
Column vector searching unit, for searching the current participle under the store path that array WordRoute is recorded Column vector.
It is apparent to those skilled in the art that for convenience and simplicity of description, the device of foregoing description, The specific work process of module and unit, can refer to corresponding processes in the foregoing method embodiment, and details are not described herein.
In the above-described embodiments, it all emphasizes particularly on different fields to the description of each embodiment, is not described in detail or remembers in some embodiment The part of load may refer to the associated description of other embodiments.
Fig. 6 shows a kind of schematic block diagram of text emotion analysing terminal equipment provided in an embodiment of the present invention, in order to just In explanation, only parts related to embodiments of the present invention are shown.
In the present embodiment, the text emotion analysing terminal equipment 6 can be mobile phone, tablet computer, desktop and calculate Machine, notebook, palm PC and cloud server etc. calculate equipment.Text sentiment analysis terminal device 6 can include: processor 60, memory 61 and it is stored in the computer-readable instruction that can be run in the memory 61 and on the processor 60 62, such as execute the computer-readable instruction of above-mentioned text emotion analysis method.The processor 60 executes the computer The step in above-mentioned each text emotion analysis method embodiment, such as step S101 shown in FIG. 1 are realized when readable instruction 62 To S105.Alternatively, the processor 60 realizes each mould in above-mentioned each Installation practice when executing the computer-readable instruction 62 Block/unit function, such as the function of module 501 to 505 shown in Fig. 5.
Illustratively, the computer-readable instruction 62 can be divided into one or more module/units, one Or multiple module/units are stored in the memory 61, and are executed by the processor 60, to complete the present invention.Institute Stating one or more module/units can be the series of computation machine readable instruction section that can complete specific function, the instruction segment For describing implementation procedure of the computer-readable instruction 62 in the text emotion analysing terminal equipment 6.
The processor 60 can be central processing unit (Central Processing Unit, CPU), can also be Other general processors, digital signal processor (Digital Signal Processor, DSP), specific integrated circuit (Application Specific Integrated Circuit, ASIC), field programmable gate array (Field- Programmable Gate Array, FPGA) either other programmable logic device, discrete gate or transistor logic, Discrete hardware components etc..General processor can be microprocessor or the processor is also possible to any conventional processor Deng.
The memory 61 can be the internal storage unit of the text emotion analysing terminal equipment 6, such as text feelings Feel the hard disk or memory of analysing terminal equipment 6.The memory 61 is also possible to the outer of the text emotion analysing terminal equipment 6 The plug-in type hard disk being equipped in portion's storage equipment, such as the text emotion analysing terminal equipment 6, intelligent memory card (Smart Media Card, SMC), secure digital (Secure Digital, SD) card, flash card (Flash Card) etc..Further, The memory 61 can also both including the text emotion analysing terminal equipment 6 internal storage unit and also including external storage Equipment.The memory 61 is for storing needed for the computer-readable instruction and the text emotion analysing terminal equipment 6 Other instruction and datas.The memory 61 can be also used for temporarily storing the data that has exported or will export.
The functional units in various embodiments of the present invention may be integrated into one processing unit, is also possible to each Unit physically exists alone, and can also be integrated in one unit with two or more units.Above-mentioned integrated unit both may be used To use formal implementation of hardware, can also realize in the form of software functional units.
If the integrated unit is realized in the form of SFU software functional unit and sells or use as independent product When, it can store in a computer readable storage medium.Based on this understanding, technical solution of the present invention substantially or Person says that all or part of the part that contributes to existing technology or the technical solution can body in the form of software products Reveal and, which is stored in a storage medium, including several computer-readable instructions are used so that one Platform computer equipment (can be personal computer, server or the network equipment etc.) executes described in each embodiment of the present invention The all or part of the steps of method.And storage medium above-mentioned includes: USB flash disk, mobile hard disk, read-only memory (ROM, Read- Only Memory), random access memory (RAM, Random Access Memory), magnetic or disk etc. are various can be with Store the medium of computer-readable instruction.
Embodiment described above is merely illustrative of the technical solution of the present invention, rather than its limitations;Although referring to aforementioned reality Applying example, invention is explained in detail, those skilled in the art should understand that: it still can be to aforementioned each Technical solution documented by embodiment is modified or equivalent replacement of some of the technical features;And these are modified Or replacement, the spirit and scope for technical solution of various embodiments of the present invention that it does not separate the essence of the corresponding technical solution.

Claims (8)

1. a kind of text emotion analysis method characterized by comprising
Word cutting processing is carried out to statement text to be analyzed, obtains each participle for constituting the statement text;
Search the column vector of each participle respectively in preset term vector database, and by the column of each participle to Amount composition input matrix, wherein each column of the input matrix correspond to a column vector, and the term vector database is note Record the database of the corresponding relationship between word and column vector;
The emotion that a participle corresponding with preset analysis object is analyzed as text emotion is chosen from the statement text Main body;
The input matrix and input vector are input in preset text emotion analysis neural network model, the feelings are obtained Feel affective style of the main body in the statement text, the input vector is the column vector of the emotion main body;
The data handling procedure of text emotion analysis neural network model includes:
The coupling vector between the input matrix and the input vector is calculated according to the following formula:
CoupVec=(CoupFactor1,CoupFactor2,......,CoupFactorn,......,CoupFactorN)T,
Wherein, 1≤n≤N, N are the columns of the input matrix, and T is transposition symbol,
WordVecnFor the input matrix n-th column, MainVec be the input vector, WeightMatrix, WeightMatrix ' is preset weight matrix,CoupVec is the coupling vector;
The composite vector of the statement text is calculated according to the following formula:
CompVec=WordMatrix*CoupVec,
Wherein, CompVec is the composite vector, and WordMatrix is the input matrix,
And WordMatrix=(WordVec1,WordVec2,......,WordVecn,......,WordVecN);
The probability value of each affective style is calculated separately according to the following formula:
Wherein, 1≤m≤M, M are the number of affective style, WeightMatrixmIt is preset corresponding with m-th of affective style Weight matrix, ProbmFor the probability value of m-th of affective style;
The maximum affective style of probability value is determined as affective style of the emotion main body in the statement text.
2. text emotion analysis method according to claim 1, which is characterized in that the text emotion analyzes neural network The training process of model includes:
The training sample of preset number is chosen, each sample includes that an input matrix, an input vector and an expection are defeated Affective style out;
Each training sample is separately input to handle in the text emotion analysis neural network model, and according to Following formula calculates the global error of epicycle training:
Wherein, CalcProbl,mFor probability value of m-th of affective style in first of training sample, ExpProbl,mIt is m-th Expected probability value of the affective style in first of training sample,
AndExpSeq is the sequence of the anticipated output affective style of first of training sample Number, 1≤l≤L, L are the number of the training sample, and 1≤m≤M, M are the number of affective style, and ln is natural logrithm function, LOSSlFor the training error of first of training sample, LOSS is the global error;
If the global error is greater than or equal to preset error threshold, to text emotion analysis neural network model Parameter is adjusted, and is returned to execute and described each training sample is separately input to the text emotion is analyzed nerve net The step of being handled in network model, until the global error is less than the error threshold;
If the global error is less than the error threshold, terminate to train.
3. text emotion analysis method according to claim 2, which is characterized in that the training sample for choosing preset number Originally include:
Training sample is chosen in pairs in the form of training sample pair, and each training sample is to including two training samples, same instruction The input matrix for practicing two training samples of sample centering is identical, is made of the column vector of each participle of same statement text Matrix, the input vectors of two training samples of same training sample centering is different, two of respectively same statement text The anticipated output affective style of the column vector of different emotions main body, two training samples of same training sample centering is different, and one A is front affective style, another is negative affective style.
4. text emotion analysis method according to any one of claim 1 to 3, which is characterized in that the term vector number It is K grades of tree-shaped fragment storage organizations, the column for searching each participle respectively in preset term vector database according to library Vector includes:
Hash operation, the current participle are carried out to current participle using K mutually independent hash functions respectively according to the following formula For any one of participle:
HashKeyk=HASHk(BasicWord)
Wherein, BasicWord is the current participle, HASHkFor the hash function of serial number k, HashKeykIt is obtained for operation The cryptographic Hash of serial number k, 1≤k≤K, K are the integer greater than 1;
The serial number of the storage fragment of kth grade belonging to the current participle is calculated according to the following formula:
Wherein, MaxHashKeykFor hash function HASHkMaximum value, FragNumkFor the storage fragment of kth grade subtree Number, Ceil are the function that rounds up, and Floor is downward bracket function, and WordRoute is the array in record storage path, WordRoute [k-1] is the serial number of kth grade fragment belonging to the current participle, and is k-th of element of WordRoute;
The column vector currently segmented is searched under the store path that array WordRoute is recorded.
5. a kind of computer readable storage medium, the computer-readable recording medium storage has computer-readable instruction, special Sign is that the computer-readable instruction realizes text feelings according to any one of claims 1 to 4 when being executed by processor The step of feeling analysis method.
6. a kind of text emotion analysing terminal equipment, including memory, processor and storage are in the memory and can be The computer-readable instruction run on the processor, which is characterized in that the processor executes the computer-readable instruction Shi Shixian following steps:
Word cutting processing is carried out to statement text to be analyzed, obtains each participle for constituting the statement text;
Search the column vector of each participle respectively in preset term vector database, and by the column of each participle to Amount composition input matrix, wherein each column of the input matrix correspond to a column vector, and the term vector database is note Record the database of the corresponding relationship between word and column vector;
The emotion that a participle corresponding with preset analysis object is analyzed as text emotion is chosen from the statement text Main body;
The input matrix and input vector are input in preset text emotion analysis neural network model, the feelings are obtained Feel affective style of the main body in the statement text, the input vector is the column vector of the emotion main body;
The data handling procedure of text emotion analysis neural network model includes:
The coupling vector between the input matrix and the input vector is calculated according to the following formula:
CoupVec=(CoupFactor1,CoupFactor2,......,CoupFactorn,......,CoupFactorN)T,
Wherein, 1≤n≤N, N are the columns of the input matrix, and T is transposition symbol,
WordVecnFor the input matrix n-th column, MainVec be the input vector, WeightMatrix, WeightMatrix ' is preset weight matrix,CoupVec is the coupling vector;
The composite vector of the statement text is calculated according to the following formula:
CompVec=WordMatrix*CoupVec,
Wherein, CompVec is the composite vector, and WordMatrix is the input matrix, and WordMatrix= (WordVec1,WordVec2,......,WordVecn,......,WordVecN);
The probability value of each affective style is calculated separately according to the following formula:
Wherein, 1≤m≤M, M are the number of affective style, WeightMatrixmIt is preset corresponding with m-th of affective style Weight matrix, ProbmFor the probability value of m-th of affective style;
The maximum affective style of probability value is determined as affective style of the emotion main body in the statement text.
7. text emotion analysing terminal equipment according to claim 6, which is characterized in that the text emotion analysis nerve The training process of network model includes:
The training sample of preset number is chosen, each sample includes that an input matrix, an input vector and an expection are defeated Affective style out;
Each training sample is separately input to handle in the text emotion analysis neural network model, and according to Following formula calculates the global error of epicycle training:
Wherein, CalcProbl,mFor probability value of m-th of affective style in first of training sample, ExpProbl,mIt is m-th Expected probability value of the affective style in first of training sample,
AndExpSeq is the sequence of the anticipated output affective style of first of training sample Number, 1≤l≤L, L are the number of the training sample, and 1≤m≤M, M are the number of affective style, and ln is natural logrithm function, LOSSlFor the training error of first of training sample, LOSS is the global error;
If the global error is greater than or equal to preset error threshold, to text emotion analysis neural network model Parameter is adjusted, and is returned to execute and described each training sample is separately input to the text emotion is analyzed nerve net The step of being handled in network model, until the global error is less than the error threshold;
If the global error is less than the error threshold, terminate to train.
8. the text emotion analysing terminal equipment according to any one of claim 6 to 7, which is characterized in that institute's predicate to Amount database is K grades of tree-shaped fragment storage organizations, described to search each participle respectively in preset term vector database Column vector include:
Hash operation, the current participle are carried out to current participle using K mutually independent hash functions respectively according to the following formula For any one of participle:
HashKeyk=HASHk(BasicWord)
Wherein, BasicWord is the current participle, HASHkFor the hash function of serial number k, HashKeykIt is obtained for operation The cryptographic Hash of serial number k, 1≤k≤K, K are the integer greater than 1;
The serial number of the storage fragment of kth grade belonging to the current participle is calculated according to the following formula:
Wherein, MaxHashKeykFor hash function HASHkMaximum value, FragNumkFor the storage fragment of kth grade subtree Number, Ceil are the function that rounds up, and Floor is downward bracket function, and WordRoute is the array in record storage path, WordRoute [k-1] is the serial number of kth grade fragment belonging to the current participle, and is k-th of element of WordRoute;
The column vector currently segmented is searched under the store path that array WordRoute is recorded.
CN201810309676.7A 2018-04-09 2018-04-09 A kind of text emotion analysis method, computer readable storage medium and terminal device Active CN108733644B (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN201810309676.7A CN108733644B (en) 2018-04-09 2018-04-09 A kind of text emotion analysis method, computer readable storage medium and terminal device
PCT/CN2018/093344 WO2019196208A1 (en) 2018-04-09 2018-06-28 Text sentiment analysis method, readable storage medium, terminal device, and apparatus

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810309676.7A CN108733644B (en) 2018-04-09 2018-04-09 A kind of text emotion analysis method, computer readable storage medium and terminal device

Publications (2)

Publication Number Publication Date
CN108733644A CN108733644A (en) 2018-11-02
CN108733644B true CN108733644B (en) 2019-07-19

Family

ID=63941208

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810309676.7A Active CN108733644B (en) 2018-04-09 2018-04-09 A kind of text emotion analysis method, computer readable storage medium and terminal device

Country Status (2)

Country Link
CN (1) CN108733644B (en)
WO (1) WO2019196208A1 (en)

Families Citing this family (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110390002A (en) * 2019-06-18 2019-10-29 深圳壹账通智能科技有限公司 Call resource allocation method, device, computer readable storage medium and server
CN112445898A (en) * 2019-08-16 2021-03-05 阿里巴巴集团控股有限公司 Dialogue emotion analysis method and device, storage medium and processor
CN110717022A (en) * 2019-09-18 2020-01-21 平安科技(深圳)有限公司 Robot dialogue generation method and device, readable storage medium and robot
EP3839763A1 (en) 2019-12-16 2021-06-23 Tata Consultancy Services Limited System and method to quantify subject-specific sentiment
CN111191438B (en) * 2019-12-30 2023-03-21 北京百分点科技集团股份有限公司 Emotion analysis method and device and electronic equipment
CN112214576B (en) * 2020-09-10 2024-02-06 深圳价值在线信息科技股份有限公司 Public opinion analysis method, public opinion analysis device, terminal equipment and computer readable storage medium
CN112818681B (en) * 2020-12-31 2023-11-10 北京知因智慧科技有限公司 Text emotion analysis method and system and electronic equipment

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106469145A (en) * 2016-09-30 2017-03-01 中科鼎富(北京)科技发展有限公司 Text emotion analysis method and device
CN106844330B (en) * 2016-11-15 2018-04-20 平安科技(深圳)有限公司 The analysis method and device of article emotion
CN106776581B (en) * 2017-02-21 2020-01-24 浙江工商大学 Subjective text emotion analysis method based on deep learning
CN107066449B (en) * 2017-05-09 2021-01-26 北京京东尚科信息技术有限公司 Information pushing method and device

Also Published As

Publication number Publication date
CN108733644A (en) 2018-11-02
WO2019196208A1 (en) 2019-10-17

Similar Documents

Publication Publication Date Title
CN108733644B (en) A kind of text emotion analysis method, computer readable storage medium and terminal device
US10311454B2 (en) Customer interaction and experience system using emotional-semantic computing
CN109783817B (en) Text semantic similarity calculation model based on deep reinforcement learning
CN111444320B (en) Text retrieval method and device, computer equipment and storage medium
CN111222305B (en) Information structuring method and device
CN108363790A (en) For the method, apparatus, equipment and storage medium to being assessed
CN108073568A (en) keyword extracting method and device
CN103365997B (en) A kind of opining mining method based on integrated study
CN106202032A (en) A kind of sentiment analysis method towards microblogging short text and system thereof
CN105022754B (en) Object classification method and device based on social network
JP2021504789A (en) ESG-based corporate evaluation execution device and its operation method
CN110874439B (en) Recommendation method based on comment information
CN108108347B (en) Dialogue mode analysis system and method
CN106997341A (en) A kind of innovation scheme matching process, device, server and system
CN110297893A (en) Natural language question-answering method, device, computer installation and storage medium
Lee et al. Protein family classification with neural networks
CN106445915A (en) New word discovery method and device
CN109977225A (en) The analysis of public opinion method and device
CN111428490A (en) Reference resolution weak supervised learning method using language model
CN114996464B (en) Text grading method and device using ordered information
CN109344246A (en) A kind of electric questionnaire generation method, computer readable storage medium and terminal device
CN111259147A (en) Sentence-level emotion prediction method and system based on adaptive attention mechanism
CN104537280A (en) Protein interactive relationship identification method based on text relationship similarity
CN110377706B (en) Search sentence mining method and device based on deep learning
CN112307048A (en) Semantic matching model training method, matching 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