WO2020199600A1 - Sentiment polarity analysis method and related device - Google Patents

Sentiment polarity analysis method and related device Download PDF

Info

Publication number
WO2020199600A1
WO2020199600A1 PCT/CN2019/118447 CN2019118447W WO2020199600A1 WO 2020199600 A1 WO2020199600 A1 WO 2020199600A1 CN 2019118447 W CN2019118447 W CN 2019118447W WO 2020199600 A1 WO2020199600 A1 WO 2020199600A1
Authority
WO
WIPO (PCT)
Prior art keywords
neural network
network model
word vector
polarity
tag
Prior art date
Application number
PCT/CN2019/118447
Other languages
French (fr)
Chinese (zh)
Inventor
王健宗
贾雪丽
Original Assignee
平安科技(深圳)有限公司
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 平安科技(深圳)有限公司 filed Critical 平安科技(深圳)有限公司
Publication of WO2020199600A1 publication Critical patent/WO2020199600A1/en

Links

Images

Classifications

    • 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
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks

Definitions

  • This application relates to the field of electronic technology, and in particular to an emotional polarity analysis method and related devices.
  • Emotional polarity analysis is a common application of natural language processing methods, especially in classification methods that aim to extract the emotional content of text.
  • sentiment polarity analysis can be seen as a way to quantify qualitative data using some sentiment score indicators.
  • emotions are largely subjective, there are already many useful practices for quantitative emotion analysis, such as companies analyzing consumer feedback on products, or detecting bad reviews in online reviews.
  • the simplest sentiment analysis method is to use the positive and negative attributes of words to determine. Each word in the sentence has a score, optimistic words are scored +1, and pessimistic words are scored -1. Then we add up the scores of all words in the sentence to get a final emotional total score.
  • this method has many limitations. The most important point is that it ignores contextual information. For example, in this simple model, because “not” has a score of -1 and "good” has a score of +1, the phrase “not good” will be classified as a neutral phrase. But "not good” is usually negative.
  • Another common method is to treat the text as a "bag of words". We see each text as a 1xN vector, where N represents the number of text vocabulary.
  • Each column in the vector is a word, and its corresponding value is the frequency of the word.
  • bag of bag of words can be coded as [2,2,1].
  • machine learning classification algorithms such as Logis regression or support vector machines
  • the embodiments of the present application provide an emotional polarity analysis method and related devices, which facilitate the analysis of the emotional polarity of the target sentence paragraph, thereby helping the user to quickly obtain the emotional polarity represented by the target sentence paragraph.
  • an embodiment of the present application provides an emotional polarity analysis method, applied to an electronic device, and the method includes:
  • Each word vector in the first word vector set is input to the second neural network model to obtain an output label associated with the first word vector set, and the output label is a label in a preset label set, so Each label in the preset label set is used to indicate an emotional polarity;
  • the emotional polarity of the target sentence paragraph is determined according to the output tag.
  • an embodiment of the present application provides an emotional polarity analysis device, which is applied to an electronic device.
  • the emotional polarity analysis device includes a detection unit, a processing unit, and a determination unit, wherein,
  • the detection unit is configured to obtain multiple words of the target sentence paragraph when an emotion polarity analysis operation for the target sentence paragraph is detected;
  • the processing unit is configured to input the multiple words into a first neural network model to obtain a first word vector set corresponding to the multiple words, wherein the first neural network model is used to generate word vectors Related model sets, and determine the word vector of the target vocabulary according to the target vocabulary in the plurality of vocabularies and vocabulary adjacent to the target vocabulary, and each word vector in the first word vector set is used for Indicates the context information of the corresponding vocabulary;
  • the processing unit is further configured to input each word vector in the first word vector set into a second neural network model to obtain an output label associated with the first word vector set, and the output label is a preset Tags in the tag set of, each tag in the preset tag set is used to indicate an emotional polarity;
  • the determining unit is configured to determine the emotional polarity of the target sentence paragraph according to the output tag.
  • embodiments of the present application provide an electronic device, including a processor, a memory, a communication interface, and one or more programs, wherein the one or more programs are stored in the memory and configured to be processed by the above
  • the above-mentioned program includes instructions for executing the steps in any method of the first aspect of the embodiments of the present application.
  • an embodiment of the present application provides a computer-readable storage medium, wherein the foregoing computer-readable storage medium stores a computer program for electronic data exchange, wherein the foregoing computer program enables a computer to execute In one aspect, some or all of the steps described in any method.
  • embodiments of the present application provide a computer program product, wherein the computer program product includes a non-transitory computer-readable storage medium storing a computer program, and the computer program is operable to cause a computer to execute For example, some or all of the steps described in any method of the first aspect.
  • the computer program product may be a software installation package.
  • the electronic device can first obtain the word vector set corresponding to each sentence through the first neural network model when performing emotional polarity analysis on the target sentence paragraph, and then through the second neural network model.
  • the network model obtains the sentiment polarity corresponding to each sentence, and whether the sentiment polarity analysis is performed to analyze a vocabulary separately, and also combines the context corresponding to the vocabulary, which helps to improve the accuracy of sentiment polarity analysis and helps users Quickly get the result of sentiment polarity analysis of the target sentence paragraph.
  • FIG. 1A is a schematic flowchart of an emotional polarity analysis method provided by an embodiment of the present application
  • FIG. 1B is a schematic diagram of the processing flow of a neural network model provided by an embodiment of the present application.
  • FIG. 2 is a schematic flowchart of another emotion polarity analysis method provided by an embodiment of the present application.
  • FIG. 3 is a schematic flowchart of another emotion polarity analysis method provided by an embodiment of the present application.
  • FIG. 4 is a schematic structural diagram of an electronic device provided by an embodiment of the present application.
  • Fig. 5 is a block diagram of functional units of an emotional polarity analysis device provided by an embodiment of the present application.
  • FIG. 1A is a schematic flow chart of an emotional polarity analysis method provided by an embodiment of the present application, which is applied to an electronic device.
  • the emotional polarity analysis method includes:
  • S101 The electronic device acquires multiple vocabulary of the target sentence paragraph when detecting the emotion polarity analysis operation for the target sentence paragraph.
  • the sentiment polarity analysis method in this application is suitable for a variety of application scenarios, for example, the sentiment polarity analysis of Taobao product reviews, the sentiment polarity analysis of Weibo comments, and the sentiment polarity analysis of opinion letters for enterprises.
  • the sentiment polarity analysis operation for the target sentence paragraph is detected, multiple words of the target sentence paragraph are obtained.
  • the target sentence paragraph may contain one sentence or multiple sentences.
  • the target paragraph includes multiple sentences, First determine the emotional polarity corresponding to each sentence in turn, and then determine the emotional polarity of the target sentence paragraph.
  • the electronic device inputs the multiple words into a first neural network model to obtain a first word vector set corresponding to the multiple words, wherein the first neural network model is a correlation used to generate word vectors Model set, and determine the word vector of the target vocabulary according to the target vocabulary in the plurality of vocabularies and vocabulary adjacent to the target vocabulary, each word vector in the first word vector set is used to indicate The context information of the corresponding vocabulary.
  • the first neural network model is a correlation used to generate word vectors Model set, and determine the word vector of the target vocabulary according to the target vocabulary in the plurality of vocabularies and vocabulary adjacent to the target vocabulary, each word vector in the first word vector set is used to indicate The context information of the corresponding vocabulary.
  • each word vector includes the corresponding The contextual information of the vocabulary. For example, when a sentence is “Student Xiao Ming’s test score is not very outstanding”, the emotional polarity corresponding to the word “outstanding” is positive, but the sentence is actually negative. Therefore, The word vector corresponding to "prominent” also includes the context information of the word, so that after each vocabulary is converted into a word vector, it is helpful to be more prepared to judge the emotional polarity corresponding to each vocabulary.
  • the electronic device inputs each word vector in the first word vector set into a second neural network model to obtain an output label associated with the first word vector set, where the output label is a preset label
  • the tags in the set, and each tag in the preset tag set is used to indicate an emotional polarity.
  • an output label associated with the first word vector set can be obtained, and the output label is used to indicate the emotional polarity represented by the target sentence paragraph. This will help Taobao sellers quickly count the number of positive reviews and negative reviews in a large number of user reviews, eliminating the need to read and understand each review.
  • S104 The electronic device determines the emotional polarity of the target sentence paragraph according to the output tag.
  • multiple word vectors corresponding to the target sentence paragraph are obtained through the first neural network model, and then output labels corresponding to the target sentence paragraphs are obtained according to the multiple word vectors through the second neural network model, and the sentiment of the target sentence paragraph can be determined according to the output labels polarity.
  • the word vector can be used to indicate the context information of the corresponding vocabulary
  • the emotional polarity of the target sentence paragraph can be determined more accurately through the first neural network model and the second neural network model.
  • the first neural network model and the second neural network model are used. Before the neural network model, it is necessary to train the first neural network model and the second neural network model by using a large number of sentences representing positive emotions and a large number of sentences representing negative emotions. The parameters of is adjusted so that the first output label can be output by the input sentence representing positive emotion, and the second output label can be output by the input sentence representing negative emotion.
  • the electronic device can first obtain the word vector set corresponding to each sentence through the first neural network model when performing emotional polarity analysis on the target sentence paragraph, and then through the second neural network model.
  • the network model obtains the sentiment polarity corresponding to each sentence, and whether the sentiment polarity analysis is performed to analyze a vocabulary separately, and also combines the context corresponding to the vocabulary, which helps to improve the accuracy of sentiment polarity analysis and helps users Quickly get the result of sentiment polarity analysis of the target sentence paragraph.
  • the inputting the multiple words into the first neural network model to obtain the first word vector set corresponding to the multiple words includes: obtaining multiple sentences of the target paragraph; Each sentence in the multiple sentences is split, and the part of speech of the multiple words obtained after the splitting is determined; a plurality of words whose part of speech is a preset part of speech are selected and input into the first neural network model.
  • the target sentence paragraph when the target sentence paragraph has multiple paragraph sentences, first determine the multiple sentences that make up the target sentence paragraph, and then split each sentence.
  • the split sentence consists of multiple words. These words may include nouns, Part of speech vocabulary such as verbs, adjectives, adverbs, prepositions, pronouns, etc., select the words whose part of speech is the preset part of speech among the multiple vocabularies obtained after splitting.
  • the target paragraph sentence is the evaluation of a Taobao buyer.
  • the words can be two-character words, three-character words, etc.
  • the part of speech of the vocabulary obtained after splitting is judged, so that multiple words whose part of speech is the preset part of speech are selected and input into the first neural network model, and the prepositions and conjunctions that cannot be judged for emotional polarity are removed.
  • Such vocabulary, or emoticons or special characters doped in sentences help simplify vocabulary composition and improve processing efficiency.
  • the first neural network model is the Word2vecc neural network model
  • the inputting the multiple words into the first neural network model to obtain the first word vector set corresponding to the multiple words includes : Convert the multiple vocabularies into one-hot vectors by encoding the multiple vocabularies, the one-hot vectors corresponding to the multiple vocabularies form a second word vector set; combine the second word vector set Each one-hot vector of is sequentially input to the Word2vecc neural network model to obtain the first set of word vectors.
  • Word2vecc is a group of related models used to generate word vectors. These models are shallow and two-layer neural networks that are used to train to reconstruct the text of linguistic words. By determining the polarity of a word, it is also necessary to determine the words adjacent to the word. Under the assumption of the word bag model in Word2vecc, the order of the words is not important. After the training is completed, the Word2vecc model can be used to map each word to a vector, which can be used to represent the relationship between word-to-word, and this vector is the hidden layer of the neural network. In addition, word vectors have good semantic characteristics and are a common way to express word features.
  • each dimension of the word vector represents a feature with a certain semantic and grammatical interpretation. Therefore, each dimension of the word vector can be called a word feature.
  • the word vector has many forms, such as one-hot vector.
  • the one-hot vector is used as the input of Word2vecc, and the low-dimensional word vector is trained through Word2vecc.
  • Word2vec is a way to obtain the second word vector set.
  • the word vector obtained through this way contains possible contextual information. In sentiment analysis Can more accurately recognize the emotion of the text.
  • the input is a word vector, for example, a word can be converted into a one-hot vector.
  • a one-hot vector means a vector is used to represent a word, and there are N words in this corpus. The dimension of this vector is 1*N, only The element at the corresponding position is 1, and the elements at other positions are all 0.
  • the output is the vector of the context word of the input word. The elements in the vector are between 0-1, and the one-hot vector that should have appeared takes the cross-entropy as the loss function, and uses backpropagation to train the first A neural network, and the weight matrix of the first neural network.
  • the first neural network model After the first neural network model is trained, input the one-hot vector of a vocabulary, and the context word probability of the corresponding vocabulary will be output. At the same time, the first neural network model contains a hidden layer neural network, which trains the input weights. Matrix. Each row of the weight matrix corresponds to the word vector of the word at the corresponding position. After the first neural network model obtains the first word vector set, it is used as the input of the second neural network model.
  • the first neural network model can be the Word2vec neural network model. After the target sentence paragraph is split into multiple words, it is first transformed into a second word vector set, and then the first neural network model is used to obtain the first The word vector set, because the word vector in the first word vector set contains possible contextual information, the emotion expressed in the target sentence paragraph can be more accurately identified in sentiment analysis.
  • the second neural network model is an SVM neural network model.
  • the second neural network model can be a support vector machine (Support Vector Machine, SVM) model.
  • SVM Support Vector Machine
  • the SVM model is used to implement sentiment classification and is obtained through the Word2vec neural network model
  • the word vector is used as input and the output is label, which means that the target sentence paragraph is 0 or 1, respectively representing whether the emotional polarity of the target sentence paragraph is positive or negative.
  • the training set of SVM is the word vector representation of a paragraph. To train the SVM model on the training set, the emotional polarity of a paragraph can be judged through the trained model. Therefore, the second neural network model can be the SVM model.
  • the words need to be converted into one-hot vectors, and then the second word vector set is obtained through the Word2vecc neural network model.
  • Each word in the second word vector set The vector includes the corresponding context information.
  • the sentiment polarity can be judged through the output label, which is conducive to more accurately inferring the sentiment polarity of the target sentence paragraph .
  • the method further includes: displaying the emotional polarity in a preset display area of the target sentence paragraph.
  • the obtained emotional polarity can be displayed in the preset display area of the target sentence paragraph.
  • the preset display area may be located on the left, right, upper side of the target sentence paragraph. Positions such as the lower side, or the display area on the top of the target sentence paragraph, can be set by the user.
  • a visual display interface is formed, so that the user can quickly obtain the emotional polarity expressed by the target sentence paragraph, which is beneficial to Taobao sellers, etc. Quickly determine the positive and negative reviews of multiple user reviews.
  • the displaying the emotional polarity in the preset display area of the target sentence paragraph includes: when it is detected that the emotional polarity is a positive emotion, displaying in a first color; Or, when an emotion with a negative emotion polarity is detected, the second color is used for display.
  • the emotional polarity of the target sentence paragraph is positive or negative, and then different emotional polarities can be displayed differentiated. For example, when it is detected that the emotional polarity of a certain evaluation is positive, that is, the evaluation is favorable, it will be displayed in green. When the emotional polarity of a certain evaluation is negative, that is, the evaluation is negative, it will be displayed in red. The display is performed so that the user can quickly determine whether the Taobao evaluation is a good or bad evaluation.
  • FIG. 2 is a schematic flowchart of an emotional polarity analysis method provided by an embodiment of the present application, which is applied to an electronic device. As shown in the figure, this sentiment polarity analysis method includes:
  • S201 The electronic device acquires multiple vocabulary of the target sentence paragraph when detecting the emotion polarity analysis operation for the target sentence paragraph.
  • S202 The electronic device converts the multiple vocabularies into one-hot vectors by encoding the multiple vocabularies, and the one-hot vectors corresponding to the multiple vocabularies form a second word vector set.
  • the electronic device inputs each one-hot vector in the second word vector set into the Word2vecc neural network model in turn to obtain the first word vector set, and each one-hot vector in the first word vector set
  • a word vector is used to indicate the context information of the corresponding vocabulary.
  • S204 The electronic device inputs each word vector in the first word vector set into a second neural network model to obtain an output label associated with the first word vector set.
  • S205 The electronic device determines the emotional polarity of the target sentence paragraph according to the output tag.
  • the electronic device can first obtain the word vector set corresponding to each sentence through the first neural network model when performing emotional polarity analysis on the target sentence paragraph, and then through the second neural network model.
  • the network model obtains the sentiment polarity corresponding to each sentence, and whether the sentiment polarity analysis is performed to analyze a vocabulary separately, and also combines the context corresponding to the vocabulary, which helps to improve the accuracy of sentiment polarity analysis and helps users Quickly get the result of sentiment polarity analysis of the target sentence paragraph.
  • the first neural network model can be the Word2vec neural network model. After the target sentence paragraph is split into multiple words, it is first transformed into a second word vector set, and then the first word vector set is obtained through the first neural network model. Since the word vectors in the first word vector set contain possible contextual information, the emotion expressed in the target sentence paragraph can be more accurately identified in sentiment analysis.
  • FIG. 3 is a schematic flowchart of an emotional polarity analysis method provided by an embodiment of the present application, which is applied to an electronic device. As shown in the figure, this sentiment polarity analysis method includes:
  • S301 The electronic device acquires multiple vocabulary of the target sentence paragraph when detecting the emotion polarity analysis operation for the target sentence paragraph.
  • the electronic device converts the multiple vocabularies into one-hot vectors by encoding the multiple vocabularies, and the one-hot vectors corresponding to the multiple vocabularies form a second word vector set.
  • the electronic device inputs each one-hot vector in the second word vector set into the Word2vecc neural network model in turn to obtain the first word vector set, wherein, in the first word vector set Each word vector of is used to indicate the context information of the corresponding word.
  • S304 The electronic device inputs each word vector in the first word vector set into a second neural network model to obtain an output label associated with the first word vector set.
  • S305 The electronic device determines the emotional polarity of the target sentence paragraph according to the output tag.
  • S306 The electronic device displays the emotional polarity in a preset display area of the target sentence paragraph.
  • the electronic device can first obtain the word vector set corresponding to each sentence through the first neural network model when performing emotional polarity analysis on the target sentence paragraph, and then through the second neural network model.
  • the network model obtains the sentiment polarity corresponding to each sentence, and whether the sentiment polarity analysis is performed to analyze a vocabulary separately, and also combines the context corresponding to the vocabulary, which helps to improve the accuracy of sentiment polarity analysis and helps users Quickly get the result of sentiment polarity analysis of the target sentence paragraph.
  • the first neural network model can be the Word2vec neural network model. After the target sentence paragraph is split into multiple words, it is first transformed into a second word vector set, and then the first word vector set is obtained through the first neural network model. Since the word vectors in the first word vector set contain possible contextual information, the emotion expressed in the target sentence paragraph can be more accurately identified in sentiment analysis.
  • a visual display interface is formed, so that the user can quickly obtain the emotional polarity expressed by the target sentence paragraph, so that Taobao sellers can quickly determine the amount of emotion. Positive and negative reviews in user reviews.
  • FIG. 4 is a schematic structural diagram of an electronic device 400 provided by an embodiment of the present application.
  • the electronic device 400 has one or Multiple application programs and operating systems.
  • the electronic device 400 includes a processor 410, a memory 420, a communication interface 430, and one or more programs 421, wherein the one or more programs 421 are stored in the In the memory 420 and configured to be executed by the processor 410, the one or more programs 421 include instructions for executing the following steps;
  • Each word vector in the first word vector set is input to the second neural network model to obtain an output label associated with the first word vector set, and the output label is a label in a preset label set, so Each label in the preset label set is used to indicate an emotional polarity;
  • the emotional polarity of the target sentence paragraph is determined according to the output tag.
  • the electronic device can first obtain the word vector set corresponding to each sentence through the first neural network model when performing emotional polarity analysis on the target sentence paragraph, and then through the second neural network model.
  • the network model obtains the sentiment polarity corresponding to each sentence, and whether the sentiment polarity analysis is performed to analyze a vocabulary separately, and also combines the context corresponding to the vocabulary, which helps to improve the accuracy of sentiment polarity analysis and helps users Quickly get the result of sentiment polarity analysis of the target sentence paragraph.
  • the instructions in the program are specifically used to perform the following operations : Obtain multiple sentences of the target paragraph; split each sentence in the multiple sentences, and determine the part of speech of the multiple words obtained after the split; select multiple words whose part of speech is preset Input the first neural network model.
  • the first neural network model is the Word2vecc neural network model; in terms of inputting the multiple words into the first neural network model to obtain the first word vector set corresponding to the multiple words,
  • the instructions in the program are specifically used to perform the following operations: the multiple words are converted into one-hot vectors by encoding the multiple words, and the one-hot vectors corresponding to the multiple words form a second word vector Set; each one-hot vector in the second word vector set is sequentially input into the Word2vecc neural network model to obtain the first word vector set.
  • the second neural network model is an SVM neural network model.
  • the output tag includes a first tag and a second tag
  • the instructions in the program are specifically used to execute The following operations: when it is detected that the output tag is the first tag, determine that the emotion polarity corresponding to the target sentence paragraph is a positive emotion; or, when it is detected that the output tag is the second tag , It is determined that the emotion polarity corresponding to the target sentence paragraph is a negative emotion.
  • the instructions in the program are specifically used to perform the following operations: in the preset display area of the target sentence paragraph Show the emotional polarity.
  • the instructions in the program are specifically used to perform the following operations: after detecting that the emotional polarity is positive In the case of emotion, the first color is used for display; or, when the emotion with the negative emotion polarity is detected, the second color is used for display, and the first color is different from the second color.
  • the electronic device includes hardware structures and/or software modules corresponding to each function.
  • the present application can be implemented in the form of hardware or a combination of hardware and computer software. Whether a certain function is executed by hardware or computer software-driven hardware depends on the specific application and design constraint conditions of the technical solution. Professionals and technicians can use different methods for each specific application to implement the described functions, but such implementation should not be considered beyond the scope of this application.
  • the embodiment of the present application may divide the electronic device into functional units according to the method example.
  • each functional unit may be divided corresponding to each function, or two or more functions may be integrated into one processing unit.
  • the integrated unit can be implemented in the form of hardware or software functional unit. It should be noted that the division of units in the embodiments of the present application is illustrative, and is only a logical function division, and there may be other division methods in actual implementation.
  • the emotion polarity analysis device 500 shown in FIG. 5 is applied to the electronic device.
  • the emotion polarity analysis device includes a detection unit 501, a processing unit 502, and a determination unit 503, wherein,
  • the detection unit 501 is configured to acquire multiple vocabulary of the target sentence paragraph when the emotion polarity analysis operation for the target sentence paragraph is detected;
  • the processing unit 502 is configured to input the plurality of words into a first neural network model to obtain a first set of word vectors corresponding to the plurality of words, wherein the first neural network model is used to generate word vectors And determine the word vector of the target vocabulary according to the target vocabulary in the multiple vocabularies and vocabulary adjacent to the target vocabulary, and each word vector in the first word vector set is used To indicate the contextual information of the corresponding vocabulary;
  • the processing unit 502 is further configured to input each word vector in the first word vector set into a second neural network model to obtain an output label associated with the first word vector set, and the output label is a pre- Tags in the set of tags, each tag in the preset tag set is used to indicate an emotional polarity;
  • the determining unit 503 is configured to determine the emotional polarity of the target sentence paragraph according to the output tag.
  • the electronic device can first obtain the word vector set corresponding to each sentence through the first neural network model when performing emotional polarity analysis on the target sentence paragraph, and then through the second neural network model.
  • the network model obtains the sentiment polarity corresponding to each sentence, and whether the sentiment polarity analysis is performed to analyze a vocabulary separately, and also combines the context corresponding to the vocabulary, which helps to improve the accuracy of sentiment polarity analysis and helps users Quickly get the result of sentiment polarity analysis of the target sentence paragraph.
  • the processing unit 503 is further configured to: obtain the Multiple sentences of the target paragraph; and used to split each of the multiple sentences, and determine the part of speech of the multiple words obtained after the split; and used to select multiple parts of speech as the preset part of speech Vocabulary and input the first neural network model.
  • the first neural network model is the Word2vecc neural network model
  • the first neural network model is the Word2vecc neural network model
  • the multiple words are input into the first neural network model to obtain Regarding the first word vector set corresponding to the multiple words
  • the processing unit 503 is specifically configured to: convert the multiple words into one-hot vectors by encoding the multiple words, and the multiple words The corresponding one-hot vectors form a second word vector set; and are used to input each one-hot vector in the second word vector set into the Word2vecc neural network model in turn to obtain the first word vector set.
  • the second neural network model is an SVM neural network model.
  • the processing unit 503 is specifically configured to: When it is detected that the output tag is the first tag, it is determined that the emotional polarity corresponding to the target sentence paragraph is a positive emotion; or, when it is detected that the output tag is the second tag, it is determined that the The emotion polarity corresponding to the target sentence paragraph is negative emotion.
  • the processing unit 503 is specifically configured to: display the emotion in a preset display area of the target sentence paragraph polarity.
  • the processing unit 503 is specifically configured to: when detecting that the emotion polarity is a positive emotion, use The first color is used for display; or, when the negative emotion of the emotional polarity is detected, the second color is used for display, and the first color is different from the second color.
  • An embodiment of the present application also provides a computer storage medium, wherein the computer storage medium stores a computer program for electronic data exchange, and the computer program enables a computer to execute part or all of the steps of any method as recorded in the above method embodiment ,
  • the aforementioned computer includes electronic equipment.
  • the embodiments of the present application also provide a computer program product.
  • the above-mentioned computer program product includes a non-transitory computer-readable storage medium storing a computer program.
  • the above-mentioned computer program is operable to cause a computer to execute any of the methods described in the above-mentioned method embodiments. Part or all of the steps of the method.
  • the computer program product may be a software installation package, and the above-mentioned computer includes electronic equipment.
  • the disclosed device may be implemented in other ways.
  • the device embodiments described above are only illustrative.
  • the division of the above-mentioned units is only a logical function division, and there may be other divisions in actual implementation, for example, multiple units or components can be combined or integrated. To another system, or some features can be ignored, or not implemented.
  • the displayed or discussed mutual coupling or direct coupling or communication connection may be indirect coupling or communication connection through some interfaces, devices or units, and may be in electrical or other forms.
  • the units described above as separate components may or may not be physically separate, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the objectives of the solutions of the embodiments.
  • each unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units may be integrated into one unit.
  • the above-mentioned integrated unit can be implemented in the form of hardware or software functional unit.
  • the above integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer readable memory.
  • the technical solution of the present application essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a memory, A number of instructions are included to enable a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the foregoing methods of the various embodiments of the present application.
  • the aforementioned memory includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, magnetic disk or optical disk and other various media that can store program codes.
  • the program can be stored in a computer-readable memory, and the memory can include: flash disk , Read-only memory (English: Read-Only Memory, abbreviation: ROM), random access device (English: Random Access Memory, abbreviation: RAM), magnetic disk or optical disc, etc.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Health & Medical Sciences (AREA)
  • Health & Medical Sciences (AREA)
  • Artificial Intelligence (AREA)
  • General Physics & Mathematics (AREA)
  • Computational Linguistics (AREA)
  • General Engineering & Computer Science (AREA)
  • Biomedical Technology (AREA)
  • Evolutionary Computation (AREA)
  • Molecular Biology (AREA)
  • Computing Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Biophysics (AREA)
  • Mathematical Physics (AREA)
  • Software Systems (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Machine Translation (AREA)

Abstract

A sentiment polarity analysis method and a related device, applicable in an electronic device (400), comprising: when a coded text-containing target sentence is detected, setting the target sentence as a first input and inputting to a target neural network model; acquiring a first sample sentence from a database, setting the first sample sentence as a second input and inputting to the target neural network model; acquiring an output result of the target neural network, the output result being produced when the target neural network processes the first input and the second input, when the output result is detected to be a first result, determining the first sample sentence as a target sample sentence; extracting a sentiment identifier of the target sample sentence, and determining, on the basis of the sentiment identifier, the sentiment that the target sentence represents. The present solution favors the accurate and rapid determination of the sentiment expressed by a coded text-containing sentence.

Description

情感极性分析方法及相关装置Emotion polarity analysis method and related device
本申请要求于2019年04月03日提交中国专利局、申请号为201910267765.4、申请名称为“情感极性分析方法及相关装置”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims the priority of a Chinese patent application filed with the Chinese Patent Office, the application number is 201910267765.4, and the application name is "Affective Polarity Analysis Method and Related Devices" on April 3, 2019. The entire content is incorporated into this application by reference. in.
技术领域Technical field
本申请涉及电子技术领域,尤其涉及一种情感极性分析方法及相关装置。This application relates to the field of electronic technology, and in particular to an emotional polarity analysis method and related devices.
背景技术Background technique
情感极性分析是一种常见的自然语言处理方法的应用,特别是在以提取文本的情感内容为目标的分类方法中。通过这种方式,情感极性分析可以被视为利用一些情感得分指标来量化定性数据的方法。尽管情绪在很大程度上是主观的,但是情感量化分析已经有很多有用的实践,比如企业分析消费者对产品的反馈信息,或者检测在线评论中的差评信息。Emotional polarity analysis is a common application of natural language processing methods, especially in classification methods that aim to extract the emotional content of text. In this way, sentiment polarity analysis can be seen as a way to quantify qualitative data using some sentiment score indicators. Although emotions are largely subjective, there are already many useful practices for quantitative emotion analysis, such as companies analyzing consumer feedback on products, or detecting bad reviews in online reviews.
其中,最简单的情感分析方法是利用词语的正负属性来判定。句子中的每个单词都有一个得分,乐观的单词得分为+1,悲观的单词则为-1。然后我们对句子中所有单词得分进行加总求和得到一个最终的情感总分。很明显,这种方法有许多局限之处,最重要的一点在于它忽略了上下文的信息。例如,在这个简易模型中,因为“not”的得分为-1,而“good”的得分为+1,所以词组“not good”将被归类到中性词组中。但是“not good”通常是消极的。另外一个常见的方法是将文本视为一个“词袋”。我们将每个文本看出一个1xN的向量,其中N表示文本词汇的数量。该向量中每一列都是一个单词,其对应的值为该单词出现的频数。例如,词组“bag of bag of words”可以被编码为[2,2,1]。这些数据可以被应用到机器学习分类算法中(比如罗吉斯回归或者支持向量机),从而预测未知数据的情感状况。需要注意的是,这种有监督学习的方法要求利用已知情感状况的数据作为训练集。虽然这个方法改进了之前的模型,但是它仍然忽略了上下文的信息和数据集的规模情况。Among them, the simplest sentiment analysis method is to use the positive and negative attributes of words to determine. Each word in the sentence has a score, optimistic words are scored +1, and pessimistic words are scored -1. Then we add up the scores of all words in the sentence to get a final emotional total score. Obviously, this method has many limitations. The most important point is that it ignores contextual information. For example, in this simple model, because "not" has a score of -1 and "good" has a score of +1, the phrase "not good" will be classified as a neutral phrase. But "not good" is usually negative. Another common method is to treat the text as a "bag of words". We see each text as a 1xN vector, where N represents the number of text vocabulary. Each column in the vector is a word, and its corresponding value is the frequency of the word. For example, the phrase "bag of bag of words" can be coded as [2,2,1]. These data can be applied to machine learning classification algorithms (such as Logis regression or support vector machines) to predict the emotional state of unknown data. It should be noted that this supervised learning method requires the use of data with known emotional conditions as a training set. Although this method improves the previous model, it still ignores the context information and the size of the data set.
发明内容Summary of the invention
本申请实施例提供一种情感极性分析方法及相关装置,有利于通过对目标语句段落进行情感极性分析,从而帮助用户迅速的获取目标语句段落所表示的情感极性。The embodiments of the present application provide an emotional polarity analysis method and related devices, which facilitate the analysis of the emotional polarity of the target sentence paragraph, thereby helping the user to quickly obtain the emotional polarity represented by the target sentence paragraph.
第一方面,本申请实施例提供一种情感极性分析方法,应用于电子设备,所述方法包 括:In the first aspect, an embodiment of the present application provides an emotional polarity analysis method, applied to an electronic device, and the method includes:
在检测到针对目标语句段落的情感极性分析操作时,获取所述目标语句段落的多个词汇;When the sentiment polarity analysis operation for the target sentence paragraph is detected, acquiring multiple words of the target sentence paragraph;
将所述多个词汇输入第一神经网络模型,得到所述多个词汇对应的第一词向量集合,其中,所述第一神经网络模型为用于产生词向量的相关模型集合,并根据所述多个词汇中的目标词汇以及所述目标词汇相邻位置的词汇来确定所述目标词汇的词向量,所述第一词向量集合中的每个词向量用于指示对应词汇的上下文信息;Input the multiple vocabularies into a first neural network model to obtain a first set of word vectors corresponding to the multiple vocabularies, where the first neural network model is a set of related models used to generate word vectors and is based on Stating a target vocabulary in a plurality of vocabulary and vocabulary adjacent to the target vocabulary to determine a word vector of the target vocabulary, and each word vector in the first word vector set is used to indicate context information of a corresponding vocabulary;
将所述第一词向量集合中的每个词向量输入第二神经网络模型,得到和所述第一词向量集合关联的输出标签,所述输出标签为预设的标签集合中的标签,所述预设的标签集合中的每个标签用于指示一种情感极性;Each word vector in the first word vector set is input to the second neural network model to obtain an output label associated with the first word vector set, and the output label is a label in a preset label set, so Each label in the preset label set is used to indicate an emotional polarity;
根据所述输出标签确定所述目标语句段落的情感极性。The emotional polarity of the target sentence paragraph is determined according to the output tag.
第二方面,本申请实施例提供一种情感极性分析装置,应用于电子设备,所述情感极性分析装置包括检测单元、处理单元和确定单元,其中,In a second aspect, an embodiment of the present application provides an emotional polarity analysis device, which is applied to an electronic device. The emotional polarity analysis device includes a detection unit, a processing unit, and a determination unit, wherein,
所述检测单元,用于在检测到针对目标语句段落的情感极性分析操作时,获取所述目标语句段落的多个词汇;The detection unit is configured to obtain multiple words of the target sentence paragraph when an emotion polarity analysis operation for the target sentence paragraph is detected;
所述处理单元,用于将所述多个词汇输入第一神经网络模型,得到所述多个词汇对应的第一词向量集合,其中,所述第一神经网络模型为用于产生词向量的相关模型集合,并根据所述多个词汇中的目标词汇以及所述目标词汇相邻位置的词汇来确定所述目标词汇的词向量,所述第一词向量集合中的每个词向量用于指示对应词汇的上下文信息;The processing unit is configured to input the multiple words into a first neural network model to obtain a first word vector set corresponding to the multiple words, wherein the first neural network model is used to generate word vectors Related model sets, and determine the word vector of the target vocabulary according to the target vocabulary in the plurality of vocabularies and vocabulary adjacent to the target vocabulary, and each word vector in the first word vector set is used for Indicates the context information of the corresponding vocabulary;
所述处理单元,还用于将所述第一词向量集合中的每个词向量输入第二神经网络模型,得到和所述第一词向量集合关联的输出标签,所述输出标签为预设的标签集合中的标签,所述预设的标签集合中的每个标签用于指示一种情感极性;The processing unit is further configured to input each word vector in the first word vector set into a second neural network model to obtain an output label associated with the first word vector set, and the output label is a preset Tags in the tag set of, each tag in the preset tag set is used to indicate an emotional polarity;
所述确定单元,用于根据所述输出标签确定所述目标语句段落的情感极性。The determining unit is configured to determine the emotional polarity of the target sentence paragraph according to the output tag.
第三方面,本申请实施例提供一种电子设备,包括处理器、存储器、通信接口以及一个或多个程序,其中,上述一个或多个程序被存储在上述存储器中,并且被配置由上述处理器执行,上述程序包括用于执行本申请实施例第一方面任一方法中的步骤的指令。In a third aspect, embodiments of the present application provide an electronic device, including a processor, a memory, a communication interface, and one or more programs, wherein the one or more programs are stored in the memory and configured to be processed by the above The above-mentioned program includes instructions for executing the steps in any method of the first aspect of the embodiments of the present application.
第四方面,本申请实施例提供了一种计算机可读存储介质,其中,上述计算机可读存储介质存储用于电子数据交换的计算机程序,其中,上述计算机程序使得计算机执行如本申请实施例第一方面任一方法中所描述的部分或全部步骤。In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the foregoing computer-readable storage medium stores a computer program for electronic data exchange, wherein the foregoing computer program enables a computer to execute In one aspect, some or all of the steps described in any method.
第五方面,本申请实施例提供了一种计算机程序产品,其中,上述计算机程序产品包括存储了计算机程序的非瞬时性计算机可读存储介质,上述计算机程序可操作来使计算机执行如本申请实施例第一方面任一方法中所描述的部分或全部步骤。该计算机程序产品可以为一个软件安装包。In a fifth aspect, embodiments of the present application provide a computer program product, wherein the computer program product includes a non-transitory computer-readable storage medium storing a computer program, and the computer program is operable to cause a computer to execute For example, some or all of the steps described in any method of the first aspect. The computer program product may be a software installation package.
可以看出,在本申请实施例中,由于电子设备可以通过在对目标语句段落进行情感极性分析时,先通过第一神经网络模型得到每个语句对应的词向量集合,再通过第二神经网络模型得到每个语句对应的情感极性,在进行情感极性分析是不是单独对一个词汇进行分析,还结合了该词汇对应的上下文,从而有利于提高情感极性分析的准确性,帮助用户迅速得到目标语句段落的情感极性分析结果。It can be seen that in the embodiment of the present application, the electronic device can first obtain the word vector set corresponding to each sentence through the first neural network model when performing emotional polarity analysis on the target sentence paragraph, and then through the second neural network model. The network model obtains the sentiment polarity corresponding to each sentence, and whether the sentiment polarity analysis is performed to analyze a vocabulary separately, and also combines the context corresponding to the vocabulary, which helps to improve the accuracy of sentiment polarity analysis and helps users Quickly get the result of sentiment polarity analysis of the target sentence paragraph.
附图说明Description of the drawings
为了更清楚地说明本申请实施例或背景技术中的技术方案,下面将对本申请实施例或背景技术中所需要使用的附图进行说明。In order to more clearly illustrate the technical solutions in the embodiments of the present application or the background art, the following will describe the drawings that need to be used in the embodiments of the present application or the background art.
图1A是本申请实施例提供的一种情感极性分析方法的流程示意图;FIG. 1A is a schematic flowchart of an emotional polarity analysis method provided by an embodiment of the present application;
图1B是本申请实施例提供的一种神经网路模型的处理流程示意图;FIG. 1B is a schematic diagram of the processing flow of a neural network model provided by an embodiment of the present application;
图2是本申请实施例提供的另一种情感极性分析方法的流程示意图;2 is a schematic flowchart of another emotion polarity analysis method provided by an embodiment of the present application;
图3是本申请实施例提供的另一种情感极性分析方法的流程示意图;3 is a schematic flowchart of another emotion polarity analysis method provided by an embodiment of the present application;
图4是本申请实施例提供的一种电子设备的结构示意图;4 is a schematic structural diagram of an electronic device provided by an embodiment of the present application;
图5是本申请实施例提供的一种情感极性分析装置的功能单元组成框图。Fig. 5 is a block diagram of functional units of an emotional polarity analysis device provided by an embodiment of the present application.
具体实施方式detailed description
为了使本技术领域的人员更好地理解本申请方案,下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本申请一部分的实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都应当属于本申请保护的范围。In order to enable those skilled in the art to better understand the solution of the application, the technical solutions in the embodiments of the application will be clearly and completely described below in conjunction with the drawings in the embodiments of the application. Obviously, the described embodiments are only It is a part of the embodiments of this application, not all the embodiments. Based on the embodiments in this application, all other embodiments obtained by those of ordinary skill in the art without creative work should fall within the protection scope of this application.
以下分别进行详细说明。Detailed descriptions are given below.
本申请的说明书和权利要求书及所述附图中的术语“第一”、“第二”、“第三”和“第四”等是用于区别不同对象,而不是用于描述特定顺序。此外,术语“包括”和“具有”以及它们任何变形,意图在于覆盖不排他的包含。例如包含了一系列步骤或单元的过程、方法、系 统、产品或设备没有限定于已列出的步骤或单元,而是可选地还包括没有列出的步骤或单元,或可选地还包括对于这些过程、方法、产品或设备固有的其它步骤或单元。The terms "first", "second", "third" and "fourth" in the description and claims of the application and the drawings are used to distinguish different objects, rather than describing a specific order . In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or device that includes a series of steps or units is not limited to the listed steps or units, but optionally includes unlisted steps or units, or optionally also includes Other steps or units inherent to these processes, methods, products or equipment.
在本文中提及“实施例”意味着,结合实施例描述的特定特征、结构或特性可以包含在本申请的至少一个实施例中。在说明书中的各个位置出现该短语并不一定均是指相同的实施例,也不是与其它实施例互斥的独立的或备选的实施例。本领域技术人员显式地和隐式地理解的是,本文所描述的实施例可以与其它实施例相结合。Reference to "embodiments" herein means that a specific feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various places in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment mutually exclusive with other embodiments. Those skilled in the art clearly and implicitly understand that the embodiments described herein can be combined with other embodiments.
下面对本申请实施例进行详细介绍。The following describes the embodiments of the present application in detail.
请参阅图1A,图1A是本申请实施例提供了一种情感极性分析方法的流程示意图,应用于电子设备,本情感极性分析方法包括:Please refer to FIG. 1A. FIG. 1A is a schematic flow chart of an emotional polarity analysis method provided by an embodiment of the present application, which is applied to an electronic device. The emotional polarity analysis method includes:
S101,所述电子设备在检测到针对目标语句段落的情感极性分析操作时,获取所述目标语句段落的多个词汇。S101: The electronic device acquires multiple vocabulary of the target sentence paragraph when detecting the emotion polarity analysis operation for the target sentence paragraph.
其中,本申请中的情感极性分析方法适用于多种应用场景下,例如,淘宝商品评论情感极性分析,微博评论的情感极性分析,针对企业的意见信的情感极性分析。在检测到用户针对目标语句段落的情感极性分析操作时,获取目标语句段落的多个词汇,目标语句段落可能包含一个语句,也可以包含多个语句,在目标段落包括多个语句时,可先依次确定每个语句对应的情感极性,在确定目标语句段落的情感极性。Among them, the sentiment polarity analysis method in this application is suitable for a variety of application scenarios, for example, the sentiment polarity analysis of Taobao product reviews, the sentiment polarity analysis of Weibo comments, and the sentiment polarity analysis of opinion letters for enterprises. When the user's sentiment polarity analysis operation for the target sentence paragraph is detected, multiple words of the target sentence paragraph are obtained. The target sentence paragraph may contain one sentence or multiple sentences. When the target paragraph includes multiple sentences, First determine the emotional polarity corresponding to each sentence in turn, and then determine the emotional polarity of the target sentence paragraph.
S102,所述电子设备将所述多个词汇输入第一神经网络模型,得到所述多个词汇对应的第一词向量集合,其中,所述第一神经网络模型为用于产生词向量的相关模型集合,并根据所述多个词汇中的目标词汇以及所述目标词汇相邻位置的词汇来确定所述目标词汇的词向量,所述第一词向量集合中的每个词向量用于指示对应词汇的上下文信息。S102. The electronic device inputs the multiple words into a first neural network model to obtain a first word vector set corresponding to the multiple words, wherein the first neural network model is a correlation used to generate word vectors Model set, and determine the word vector of the target vocabulary according to the target vocabulary in the plurality of vocabularies and vocabulary adjacent to the target vocabulary, each word vector in the first word vector set is used to indicate The context information of the corresponding vocabulary.
其中,将目标语句段落中的每个语句进行拆分后,得到多个词汇,将所述多个词汇输入第一神经网络模型得到对应的第一词向量集合,并且,每一个词向量包括对应词汇的上下文信息,例如,当某个语句为“小明同学这次的考试成绩不是很突出”,词汇“突出”对应的情感极性是积极的,但是这句话实际上是消极的,因此,“突出”对应的词向量还包括该词的上下文信息,从而将每个词汇转化为词向量后,有利于更准备的判断每个词汇对应的情感极性。Wherein, after splitting each sentence in the target sentence paragraph, multiple words are obtained, and the multiple words are input into the first neural network model to obtain the corresponding first word vector set, and each word vector includes the corresponding The contextual information of the vocabulary. For example, when a sentence is “Student Xiao Ming’s test score is not very outstanding”, the emotional polarity corresponding to the word “outstanding” is positive, but the sentence is actually negative. Therefore, The word vector corresponding to "prominent" also includes the context information of the word, so that after each vocabulary is converted into a word vector, it is helpful to be more prepared to judge the emotional polarity corresponding to each vocabulary.
S103,所述电子设备将所述第一词向量集合中的每个词向量输入第二神经网络模型,得到和所述第一词向量集合关联的输出标签,所述输出标签为预设的标签集合中的标签,所述预设的标签集合中的每个标签用于指示一种情感极性。S103. The electronic device inputs each word vector in the first word vector set into a second neural network model to obtain an output label associated with the first word vector set, where the output label is a preset label The tags in the set, and each tag in the preset tag set is used to indicate an emotional polarity.
其中,将第一词向量集合中的每个词向量输入第二神经网络模型后,可以得到和第一词向量集合关联的输出标签,该输出标签用于指示目标语句段落代表的情感极性,从而有利于淘宝卖家迅速统计出大量用户评论中的好评数量和差评数量,省去了一个评论一个评论的去阅读理解。Among them, after each word vector in the first word vector set is input into the second neural network model, an output label associated with the first word vector set can be obtained, and the output label is used to indicate the emotional polarity represented by the target sentence paragraph. This will help Taobao sellers quickly count the number of positive reviews and negative reviews in a large number of user reviews, eliminating the need to read and understand each review.
S104,所述电子设备根据所述输出标签确定所述目标语句段落的情感极性。S104: The electronic device determines the emotional polarity of the target sentence paragraph according to the output tag.
其中,通过第一神经网络模型得到目标语句段落对应的多个词向量,再通过第二神经网络模型根据多个词向量得到目标语句段落对应的输出标签,根据输出标签可确定目标语句段落的情感极性。由于词向量可用于指示对应词汇的上下文信息,因此通过第一神经网络模型和第二神经网络模型可更准确的确定目标语句段落的情感极性,此外,在使用第一神经网络模型和第二神经网络模型之前,需要先使用大量表示积极情感的语句和大量表示消极情感的语句对第一神经网络模型和第二神经网络模型进行训练,通过对第一神经网络模型和第二神经网络模型中的参数进行调整,使得输入表示积极情感的语句可以输出第一输出标签,输入表示消极情感的语句可以输出第二输出标签。Among them, multiple word vectors corresponding to the target sentence paragraph are obtained through the first neural network model, and then output labels corresponding to the target sentence paragraphs are obtained according to the multiple word vectors through the second neural network model, and the sentiment of the target sentence paragraph can be determined according to the output labels polarity. Since the word vector can be used to indicate the context information of the corresponding vocabulary, the emotional polarity of the target sentence paragraph can be determined more accurately through the first neural network model and the second neural network model. In addition, the first neural network model and the second neural network model are used. Before the neural network model, it is necessary to train the first neural network model and the second neural network model by using a large number of sentences representing positive emotions and a large number of sentences representing negative emotions. The parameters of is adjusted so that the first output label can be output by the input sentence representing positive emotion, and the second output label can be output by the input sentence representing negative emotion.
可以看出,在本申请实施例中,由于电子设备可以通过在对目标语句段落进行情感极性分析时,先通过第一神经网络模型得到每个语句对应的词向量集合,再通过第二神经网络模型得到每个语句对应的情感极性,在进行情感极性分析是不是单独对一个词汇进行分析,还结合了该词汇对应的上下文,从而有利于提高情感极性分析的准确性,帮助用户迅速得到目标语句段落的情感极性分析结果。It can be seen that in the embodiment of the present application, the electronic device can first obtain the word vector set corresponding to each sentence through the first neural network model when performing emotional polarity analysis on the target sentence paragraph, and then through the second neural network model. The network model obtains the sentiment polarity corresponding to each sentence, and whether the sentiment polarity analysis is performed to analyze a vocabulary separately, and also combines the context corresponding to the vocabulary, which helps to improve the accuracy of sentiment polarity analysis and helps users Quickly get the result of sentiment polarity analysis of the target sentence paragraph.
在一个可能的示例中,所述将所述多个词汇输入第一神经网络模型,得到所述多个词汇对应的第一词向量集合,包括:获取所述目标段落的多个语句;将所述多个语句中的每个语句进行拆分,并确定拆分后得到的多个词汇的词性;选取词性为预设词性的多个词汇并输入所述第一神经网络模型。In a possible example, the inputting the multiple words into the first neural network model to obtain the first word vector set corresponding to the multiple words includes: obtaining multiple sentences of the target paragraph; Each sentence in the multiple sentences is split, and the part of speech of the multiple words obtained after the splitting is determined; a plurality of words whose part of speech is a preset part of speech are selected and input into the first neural network model.
其中,当目标语句段落有多个段落语句时,先确定组成目标语句段落的多语句,再将每个语句进行拆分,拆分后的语句由多个词汇组成,这些词汇中可能包括名词、动词、形容词、副词、介词、代词等词性的词汇,选取拆分后得到的多个词汇中词性为预设词性的词汇。例如,目标段落语句为一个淘宝买家的评价,在获取目标段落语句中的多个词汇,其中词汇可以是两个字的词汇,三个字的词汇等,通过选取预设词性的词汇,可省略其中的连词或者介词,如“的”、“地”以及标点符号,有利于更准确的确定买家的评价是褒义评价还是贬义评价,Among them, when the target sentence paragraph has multiple paragraph sentences, first determine the multiple sentences that make up the target sentence paragraph, and then split each sentence. The split sentence consists of multiple words. These words may include nouns, Part of speech vocabulary such as verbs, adjectives, adverbs, prepositions, pronouns, etc., select the words whose part of speech is the preset part of speech among the multiple vocabularies obtained after splitting. For example, the target paragraph sentence is the evaluation of a Taobao buyer. When obtaining multiple words in the target paragraph sentence, the words can be two-character words, three-character words, etc. By selecting preset words of speech, you can Omitting conjunctions or prepositions, such as "的", "地" and punctuation marks, will help to more accurately determine whether the buyer's evaluation is a commendatory evaluation or a derogatory evaluation.
可见,本示例中,对拆分后得到的词汇的词性进行判断,从而选取词性为预设词性的多个词汇并输入所述第一神经网络模型,去掉不能判断出情感极性的介词、连词等词汇,或者语句中掺杂的表情符号,特殊字符,有利于简化词汇组成,提高处理效率。It can be seen that in this example, the part of speech of the vocabulary obtained after splitting is judged, so that multiple words whose part of speech is the preset part of speech are selected and input into the first neural network model, and the prepositions and conjunctions that cannot be judged for emotional polarity are removed Such vocabulary, or emoticons or special characters doped in sentences, help simplify vocabulary composition and improve processing efficiency.
在一个可能的示例中,所述第一神经网络模型为Word2vecc神经网络模型;所述将所述多个词汇输入第一神经网络模型,得到所述多个词汇对应的第一词向量集合,包括:通过对所述多个词汇进行编码将所述多个词汇转换成one-hot向量,所述多个词汇对应的one-hot向量组成第二词向量集合;将所述第二词向量集合中的每个one-hot向量依次输入所述Word2vecc神经网络模型,得到所述第一词向量集合。In a possible example, the first neural network model is the Word2vecc neural network model; the inputting the multiple words into the first neural network model to obtain the first word vector set corresponding to the multiple words includes : Convert the multiple vocabularies into one-hot vectors by encoding the multiple vocabularies, the one-hot vectors corresponding to the multiple vocabularies form a second word vector set; combine the second word vector set Each one-hot vector of is sequentially input to the Word2vecc neural network model to obtain the first set of word vectors.
其中,Word2vecc是一群用来产生词向量的相关模型,这些模型为浅而双层的神经网络,用来训练以重新构建语言学之词的文本。通过确定一个词的极性,还需确定该词相邻位置的词,在Word2vecc中词袋模型假设下,词的顺序是不重要的。训练完成之后,Word2vecc模型可用来映射每个词到一个向量,可用来表示词对词之间的关系,该向量为神经网络隐藏层。此外,词向量具有良好的语义特性,是表示词语特征的常用方式。词向量每一维的值代表一个具有一定的语义和语法上解释的特征,所以,可以将词向量的每一维称为一个词语特征。词向量具有多种形式,例如one-hot向量,将one-hot向量作为Word2vecc的输入,通过Word2vecc训练低维词向量就可以了。Among them, Word2vecc is a group of related models used to generate word vectors. These models are shallow and two-layer neural networks that are used to train to reconstruct the text of linguistic words. By determining the polarity of a word, it is also necessary to determine the words adjacent to the word. Under the assumption of the word bag model in Word2vecc, the order of the words is not important. After the training is completed, the Word2vecc model can be used to map each word to a vector, which can be used to represent the relationship between word-to-word, and this vector is the hidden layer of the neural network. In addition, word vectors have good semantic characteristics and are a common way to express word features. The value of each dimension of the word vector represents a feature with a certain semantic and grammatical interpretation. Therefore, each dimension of the word vector can be called a word feature. The word vector has many forms, such as one-hot vector. The one-hot vector is used as the input of Word2vecc, and the low-dimensional word vector is trained through Word2vecc.
其中,Word2vec的输入也是词向量,因此,需要先通过编码的方式将多个词汇转换成one-hot向量,从而得到第二词向量集合,将第二词向量集合中的每个词汇对应的one-hot向量依次输入到Word2vec神经网络模型后,得到第一词向量集合,Word2vec是获取第二词向量集合的途径,通过这种途径获得的词向量里面包含了上下文可能的信息,在情感分析中能更准确的识别文本情感。Among them, the input of Word2vec is also a word vector. Therefore, it is necessary to first convert multiple words into one-hot vectors by encoding to obtain the second word vector set, and each word in the second word vector set corresponds to one -After the hot vector is input into the Word2vec neural network model in turn, the first word vector set is obtained. Word2vec is a way to obtain the second word vector set. The word vector obtained through this way contains possible contextual information. In sentiment analysis Can more accurately recognize the emotion of the text.
其中,在Word2vec神经网络模型的输入层,输入的是词向量,例如可以将一个词转化为one-hot向量。在训练Word2vec神经网络模型时,输入是一个one-hot向量,one-hot向量是指用一个向量来表示一个词语,加入在这个语料库中有N个词汇,这个向量的维度是1*N,只有对应位置的元素为1,其他位置的元素都为0。此外,输出的是输入单词的上下文单词的向量,向量里的元素都是在0-1之间,和原本应该出现的one-hot向量取交叉熵作为损失函数,用反向传播的方式训练第一神经网络,以及第一神经网络的权重矩阵。Among them, in the input layer of the Word2vec neural network model, the input is a word vector, for example, a word can be converted into a one-hot vector. When training the Word2vec neural network model, the input is a one-hot vector, a one-hot vector means a vector is used to represent a word, and there are N words in this corpus. The dimension of this vector is 1*N, only The element at the corresponding position is 1, and the elements at other positions are all 0. In addition, the output is the vector of the context word of the input word. The elements in the vector are between 0-1, and the one-hot vector that should have appeared takes the cross-entropy as the loss function, and uses backpropagation to train the first A neural network, and the weight matrix of the first neural network.
其中,在训练好第一神经网络模型后,输入一个词汇的one-hot向量,会输出对应词汇的上下文单词概率,同时,第一神经网络模型包含一个隐层的神经网络,训练的是输入权 重矩阵,权重矩阵的每一行对应着对应位置的单词的词向量,通多第一神经网络模型得到第一词向量集合后,作为第二神经网络模型的输入。Among them, after the first neural network model is trained, input the one-hot vector of a vocabulary, and the context word probability of the corresponding vocabulary will be output. At the same time, the first neural network model contains a hidden layer neural network, which trains the input weights. Matrix. Each row of the weight matrix corresponds to the word vector of the word at the corresponding position. After the first neural network model obtains the first word vector set, it is used as the input of the second neural network model.
可见,本示例中,第一神经网络模型可以为Word2vec神经网络模型,在将目标语句段落拆分为多个词汇后,先转化为第二词向量集合,再通过第一神经网络模型得到第一词向量集合,由于第一词向量集合中的词向量里面包含了上下文可能的信息,在情感分析中能更准确地识别目标语句段落所述表达的情感。It can be seen that in this example, the first neural network model can be the Word2vec neural network model. After the target sentence paragraph is split into multiple words, it is first transformed into a second word vector set, and then the first neural network model is used to obtain the first The word vector set, because the word vector in the first word vector set contains possible contextual information, the emotion expressed in the target sentence paragraph can be more accurately identified in sentiment analysis.
在一个可能的示例中,所述第二神经网络模型为SVM神经网络模型。In a possible example, the second neural network model is an SVM neural network model.
其中,在第一神经网络模型为Word2vecc神经网络模型时,第二神经网络模型可以是支持向量机(Support Vector Machine,SVM)模型,SVM模型是用来实现情感分类的,通过Word2vec神经网络模型得到了词向量作为输入,输出是标签,就是指目标语句段落是0或者1,分别代表这目标语句段落的情感极性是积极地还是消极的,SVM的训练集是一段话的词向量表示,通过训练集来训练SVM模型,就可以通过训练后的模型来判断一段话的情感极性,因此,第二神经网络模型可以为SVM模型。Among them, when the first neural network model is the Word2vecc neural network model, the second neural network model can be a support vector machine (Support Vector Machine, SVM) model. The SVM model is used to implement sentiment classification and is obtained through the Word2vec neural network model The word vector is used as input and the output is label, which means that the target sentence paragraph is 0 or 1, respectively representing whether the emotional polarity of the target sentence paragraph is positive or negative. The training set of SVM is the word vector representation of a paragraph. To train the SVM model on the training set, the emotional polarity of a paragraph can be judged through the trained model. Therefore, the second neural network model can be the SVM model.
可见,本示例中,在将多个词汇输入Word2vecc神经网络模型之前,需要将词汇转化为one-hot向量,然后通过Word2vecc神经网络模型得到第二词向量集合,第二词向量集合中每个词向量包括对应的上下文信息,将第一词向量集合中的每个词向量输入SVM神经网络模型后通过得到的输出标签可判断情感极性,有利于更准确的推断出目标语句段落的情感极性。It can be seen that in this example, before inputting multiple words into the Word2vecc neural network model, the words need to be converted into one-hot vectors, and then the second word vector set is obtained through the Word2vecc neural network model. Each word in the second word vector set The vector includes the corresponding context information. After each word vector in the first word vector set is input into the SVM neural network model, the sentiment polarity can be judged through the output label, which is conducive to more accurately inferring the sentiment polarity of the target sentence paragraph .
在一个可能的示例中,所述输出标签包括第一标签和第二标签;所述根据所述输出标签确定所述目标语句段落的情感极性,包括:在检测到所述输出标签为所述第一标签时,确定所述目标语句段落对应的情感极性为积极的情感;或者,在检测到所述输出标签为所述第二标签时,确定所述目标语句段落对应的情感极性为消极的情感。In a possible example, the output tag includes a first tag and a second tag; the determining the emotional polarity of the target sentence paragraph according to the output tag includes: detecting that the output tag is the In the case of the first tag, determine that the emotional polarity corresponding to the target sentence paragraph is a positive emotion; or, when it is detected that the output tag is the second tag, determine that the emotional polarity corresponding to the target sentence paragraph is Negative emotions.
可见,本示例中,将第一词向量集合中的每个词向量输入第二神经网络模型后,得到和第一词向量集合关联的输出标签,通过输出标签,可确定目标语句段落的情感极性。It can be seen that in this example, after each word vector in the first word vector set is input to the second neural network model, the output label associated with the first word vector set is obtained. Through the output label, the emotional extreme of the target sentence paragraph can be determined. Sex.
在一个可能的示例中,所述根据所述输出标签确定所述目标语句段落的情感极性之后,所述方法还包括:在所述目标语句段落的预设显示区域显示所述情感极性。In a possible example, after determining the emotional polarity of the target sentence paragraph according to the output tag, the method further includes: displaying the emotional polarity in a preset display area of the target sentence paragraph.
其中,在得到目标语句段落的情感极性之后,可在目标语句段落的预设显示区域显示得到的情感极性,预设的显示区域可以位于目标语句段落的左侧、右侧、上侧、下侧等位置,或者置顶于目标语句段落的显示区域,可由用户自行进行设定。Among them, after the emotional polarity of the target sentence paragraph is obtained, the obtained emotional polarity can be displayed in the preset display area of the target sentence paragraph. The preset display area may be located on the left, right, upper side of the target sentence paragraph. Positions such as the lower side, or the display area on the top of the target sentence paragraph, can be set by the user.
可见,本示例中,通过在预设的显示区域显示目标语句段落的情感极性,形成可视化的显示界面,使得用户可快速获取到目标语句段落所表达的情感极性,从而利于淘宝卖家等可以迅速判断出多个用户评价中的好评和差评。It can be seen that in this example, by displaying the emotional polarity of the target sentence paragraph in the preset display area, a visual display interface is formed, so that the user can quickly obtain the emotional polarity expressed by the target sentence paragraph, which is beneficial to Taobao sellers, etc. Quickly determine the positive and negative reviews of multiple user reviews.
在一个可能的示例中,所述在所述目标语句段落的预设显示区域显示所述情感极性,包括:在检测到所述情感极性为积极的情感时,使用第一颜色进行显示;或者,在检测到所述情感极性为消极的情感时,使用第二颜色进行显示。In a possible example, the displaying the emotional polarity in the preset display area of the target sentence paragraph includes: when it is detected that the emotional polarity is a positive emotion, displaying in a first color; Or, when an emotion with a negative emotion polarity is detected, the second color is used for display.
其中,通过输出标签,可确定目标语句段落的情感极性是积极地还是消极的,再对不同的情感极性进行差异化显示。例如,当检测出某个评价的情感极性是积极的,即该评价是好评,则用绿色进行显示,当某个评价的情感极性是消极的,即该评价是差评,则用红色进行显示,从而,用户可迅速判断是淘宝评价是好评还是差评。Among them, by outputting tags, it can be determined whether the emotional polarity of the target sentence paragraph is positive or negative, and then different emotional polarities can be displayed differentiated. For example, when it is detected that the emotional polarity of a certain evaluation is positive, that is, the evaluation is favorable, it will be displayed in green. When the emotional polarity of a certain evaluation is negative, that is, the evaluation is negative, it will be displayed in red. The display is performed so that the user can quickly determine whether the Taobao evaluation is a good or bad evaluation.
可见,本示例中,在预设显示区域显示目标语句段落的情感极性时,若在检测到所述情感极性为积极的情感时,使用第一颜色进行显示,在检测到所述情感极性为消极的情感时,使用第二颜色进行显示,所述第一颜色不同于所述第二颜色,通过差异化显示不同的情感极性,有利于用户迅速做出判断。It can be seen that in this example, when the emotional polarity of the target sentence paragraph is displayed in the preset display area, if the emotional polarity is detected as a positive emotion, the first color is used for display, and the emotional polarity is detected. When sex is a negative emotion, a second color is used for display, and the first color is different from the second color, and different emotional polarities are displayed differentially, which is helpful for users to quickly make judgments.
与所述图1A所示的实施例一致的,请参阅图2,图2是本申请实施例提供的一种情感极性分析方法的流程示意图,应用于电子设备。如图所示,本情感极性分析方法包括:Consistent with the embodiment shown in FIG. 1A, please refer to FIG. 2. FIG. 2 is a schematic flowchart of an emotional polarity analysis method provided by an embodiment of the present application, which is applied to an electronic device. As shown in the figure, this sentiment polarity analysis method includes:
S201,所述电子设备在检测到针对目标语句段落的情感极性分析操作时,获取所述目标语句段落的多个词汇。S201: The electronic device acquires multiple vocabulary of the target sentence paragraph when detecting the emotion polarity analysis operation for the target sentence paragraph.
S202,所述电子设备通过对所述多个词汇进行编码将所述多个词汇转换成one-hot向量,所述多个词汇对应的one-hot向量组成第二词向量集合。S202: The electronic device converts the multiple vocabularies into one-hot vectors by encoding the multiple vocabularies, and the one-hot vectors corresponding to the multiple vocabularies form a second word vector set.
S203,所述电子设备将所述第二词向量集合中的每个one-hot向量依次输入所述Word2vecc神经网络模型,得到所述第一词向量集合,所述第一词向量集合中的每个词向量用于指示对应词汇的上下文信息。S203. The electronic device inputs each one-hot vector in the second word vector set into the Word2vecc neural network model in turn to obtain the first word vector set, and each one-hot vector in the first word vector set A word vector is used to indicate the context information of the corresponding vocabulary.
S204,所述电子设备将所述第一词向量集合中的每个词向量输入第二神经网络模型,得到和所述第一词向量集合关联的输出标签。S204: The electronic device inputs each word vector in the first word vector set into a second neural network model to obtain an output label associated with the first word vector set.
S205,所述电子设备根据所述输出标签确定所述目标语句段落的情感极性。S205: The electronic device determines the emotional polarity of the target sentence paragraph according to the output tag.
可以看出,在本申请实施例中,由于电子设备可以通过在对目标语句段落进行情感极性分析时,先通过第一神经网络模型得到每个语句对应的词向量集合,再通过第二神经网 络模型得到每个语句对应的情感极性,在进行情感极性分析是不是单独对一个词汇进行分析,还结合了该词汇对应的上下文,从而有利于提高情感极性分析的准确性,帮助用户迅速得到目标语句段落的情感极性分析结果。It can be seen that in the embodiment of the present application, the electronic device can first obtain the word vector set corresponding to each sentence through the first neural network model when performing emotional polarity analysis on the target sentence paragraph, and then through the second neural network model. The network model obtains the sentiment polarity corresponding to each sentence, and whether the sentiment polarity analysis is performed to analyze a vocabulary separately, and also combines the context corresponding to the vocabulary, which helps to improve the accuracy of sentiment polarity analysis and helps users Quickly get the result of sentiment polarity analysis of the target sentence paragraph.
此外,第一神经网络模型可以为Word2vec神经网络模型,在将目标语句段落拆分为多个词汇后,先转化为第二词向量集合,再通过第一神经网络模型得到第一词向量集合,由于第一词向量集合中的词向量里面包含了上下文可能的信息,在情感分析中能更准确地识别目标语句段落所述表达的情感。In addition, the first neural network model can be the Word2vec neural network model. After the target sentence paragraph is split into multiple words, it is first transformed into a second word vector set, and then the first word vector set is obtained through the first neural network model. Since the word vectors in the first word vector set contain possible contextual information, the emotion expressed in the target sentence paragraph can be more accurately identified in sentiment analysis.
与所述图1A、图2所示的实施例一致的,请参阅图3,图3是本申请实施例提供的一种情感极性分析方法的流程示意图,应用于电子设备。如图所示,本情感极性分析方法包括:Consistent with the embodiments shown in FIG. 1A and FIG. 2, please refer to FIG. 3. FIG. 3 is a schematic flowchart of an emotional polarity analysis method provided by an embodiment of the present application, which is applied to an electronic device. As shown in the figure, this sentiment polarity analysis method includes:
S301,所述电子设备在检测到针对目标语句段落的情感极性分析操作时,获取所述目标语句段落的多个词汇。S301: The electronic device acquires multiple vocabulary of the target sentence paragraph when detecting the emotion polarity analysis operation for the target sentence paragraph.
S302,所述电子设备通过对所述多个词汇进行编码将所述多个词汇转换成one-hot向量,所述多个词汇对应的one-hot向量组成第二词向量集合。S302. The electronic device converts the multiple vocabularies into one-hot vectors by encoding the multiple vocabularies, and the one-hot vectors corresponding to the multiple vocabularies form a second word vector set.
S303,所述电子设备将所述第二词向量集合中的每个one-hot向量依次输入所述Word2vecc神经网络模型,得到所述第一词向量集合,其中,所述第一词向量集合中的每个词向量用于指示对应词汇的上下文信息。S303. The electronic device inputs each one-hot vector in the second word vector set into the Word2vecc neural network model in turn to obtain the first word vector set, wherein, in the first word vector set Each word vector of is used to indicate the context information of the corresponding word.
S304,所述电子设备将所述第一词向量集合中的每个词向量输入第二神经网络模型,得到和所述第一词向量集合关联的输出标签。S304: The electronic device inputs each word vector in the first word vector set into a second neural network model to obtain an output label associated with the first word vector set.
S305,所述电子设备根据所述输出标签确定所述目标语句段落的情感极性。S305: The electronic device determines the emotional polarity of the target sentence paragraph according to the output tag.
S306,所述电子设备在所述目标语句段落的预设显示区域显示所述情感极性。S306: The electronic device displays the emotional polarity in a preset display area of the target sentence paragraph.
可以看出,在本申请实施例中,由于电子设备可以通过在对目标语句段落进行情感极性分析时,先通过第一神经网络模型得到每个语句对应的词向量集合,再通过第二神经网络模型得到每个语句对应的情感极性,在进行情感极性分析是不是单独对一个词汇进行分析,还结合了该词汇对应的上下文,从而有利于提高情感极性分析的准确性,帮助用户迅速得到目标语句段落的情感极性分析结果。It can be seen that in the embodiment of the present application, the electronic device can first obtain the word vector set corresponding to each sentence through the first neural network model when performing emotional polarity analysis on the target sentence paragraph, and then through the second neural network model. The network model obtains the sentiment polarity corresponding to each sentence, and whether the sentiment polarity analysis is performed to analyze a vocabulary separately, and also combines the context corresponding to the vocabulary, which helps to improve the accuracy of sentiment polarity analysis and helps users Quickly get the result of sentiment polarity analysis of the target sentence paragraph.
此外,第一神经网络模型可以为Word2vec神经网络模型,在将目标语句段落拆分为多个词汇后,先转化为第二词向量集合,再通过第一神经网络模型得到第一词向量集合,由 于第一词向量集合中的词向量里面包含了上下文可能的信息,在情感分析中能更准确地识别目标语句段落所述表达的情感。In addition, the first neural network model can be the Word2vec neural network model. After the target sentence paragraph is split into multiple words, it is first transformed into a second word vector set, and then the first word vector set is obtained through the first neural network model. Since the word vectors in the first word vector set contain possible contextual information, the emotion expressed in the target sentence paragraph can be more accurately identified in sentiment analysis.
此外,通过在预设的显示区域显示目标语句段落的情感极性,形成可视化的显示界面,使得用户可快速获取到目标语句段落所表达的情感极性,从而利于淘宝卖家等可以迅速判断出多个用户评价中的好评和差评。In addition, by displaying the emotional polarity of the target sentence paragraph in the preset display area, a visual display interface is formed, so that the user can quickly obtain the emotional polarity expressed by the target sentence paragraph, so that Taobao sellers can quickly determine the amount of emotion. Positive and negative reviews in user reviews.
与所述图1A、图2、图3所示的实施例一致的,请参阅图4,图4是本申请实施例提供的一种电子设备400的结构示意图,该电子设备400运行有一个或多个应用程序和操作系统,如图所示,该电子设备400包括处理器410、存储器420、通信接口430以及一个或多个程序421,其中,所述一个或多个程序421被存储在所述存储器420中,并且被配置由所述处理器410执行,所述一个或多个程序421包括用于执行以下步骤的指令;Consistent with the embodiments shown in FIG. 1A, FIG. 2, and FIG. 3, please refer to FIG. 4. FIG. 4 is a schematic structural diagram of an electronic device 400 provided by an embodiment of the present application. The electronic device 400 has one or Multiple application programs and operating systems. As shown in the figure, the electronic device 400 includes a processor 410, a memory 420, a communication interface 430, and one or more programs 421, wherein the one or more programs 421 are stored in the In the memory 420 and configured to be executed by the processor 410, the one or more programs 421 include instructions for executing the following steps;
在检测到针对目标语句段落的情感极性分析操作时,获取所述目标语句段落的多个词汇;When the sentiment polarity analysis operation for the target sentence paragraph is detected, acquiring multiple words of the target sentence paragraph;
将所述多个词汇输入第一神经网络模型,得到所述多个词汇对应的第一词向量集合,其中,所述第一神经网络模型为用于产生词向量的相关模型集合,并根据所述多个词汇中的目标词汇以及所述目标词汇相邻位置的词汇来确定所述目标词汇的词向量,所述第一词向量集合中的每个词向量用于指示对应词汇的上下文信息;Input the multiple vocabularies into a first neural network model to obtain a first set of word vectors corresponding to the multiple vocabularies, where the first neural network model is a set of related models used to generate word vectors and is based on Stating a target vocabulary in a plurality of vocabulary and vocabulary adjacent to the target vocabulary to determine a word vector of the target vocabulary, and each word vector in the first word vector set is used to indicate context information of a corresponding vocabulary;
将所述第一词向量集合中的每个词向量输入第二神经网络模型,得到和所述第一词向量集合关联的输出标签,所述输出标签为预设的标签集合中的标签,所述预设的标签集合中的每个标签用于指示一种情感极性;Each word vector in the first word vector set is input to the second neural network model to obtain an output label associated with the first word vector set, and the output label is a label in a preset label set, so Each label in the preset label set is used to indicate an emotional polarity;
根据所述输出标签确定所述目标语句段落的情感极性。The emotional polarity of the target sentence paragraph is determined according to the output tag.
可以看出,在本申请实施例中,由于电子设备可以通过在对目标语句段落进行情感极性分析时,先通过第一神经网络模型得到每个语句对应的词向量集合,再通过第二神经网络模型得到每个语句对应的情感极性,在进行情感极性分析是不是单独对一个词汇进行分析,还结合了该词汇对应的上下文,从而有利于提高情感极性分析的准确性,帮助用户迅速得到目标语句段落的情感极性分析结果。It can be seen that in the embodiment of the present application, the electronic device can first obtain the word vector set corresponding to each sentence through the first neural network model when performing emotional polarity analysis on the target sentence paragraph, and then through the second neural network model. The network model obtains the sentiment polarity corresponding to each sentence, and whether the sentiment polarity analysis is performed to analyze a vocabulary separately, and also combines the context corresponding to the vocabulary, which helps to improve the accuracy of sentiment polarity analysis and helps users Quickly get the result of sentiment polarity analysis of the target sentence paragraph.
在一个可能的示例中,在所述将所述多个词汇输入第一神经网络模型,得到所述多个词汇对应的第一词向量集合方面,所述程序中的指令具体用于执行以下操作:获取所述目标段落的多个语句;将所述多个语句中的每个语句进行拆分,并确定拆分后得到的多个词 汇的词性;选取词性为预设词性的多个词汇并输入所述第一神经网络模型。In a possible example, in terms of inputting the plurality of words into the first neural network model to obtain the first word vector set corresponding to the plurality of words, the instructions in the program are specifically used to perform the following operations : Obtain multiple sentences of the target paragraph; split each sentence in the multiple sentences, and determine the part of speech of the multiple words obtained after the split; select multiple words whose part of speech is preset Input the first neural network model.
在一个可能的示例中,所述第一神经网络模型为Word2vecc神经网络模型;在将所述多个词汇输入第一神经网络模型,得到所述多个词汇对应的第一词向量集合方面,所述程序中的指令具体用于执行以下操作:通过对所述多个词汇进行编码将所述多个词汇转换成one-hot向量,所述多个词汇对应的one-hot向量组成第二词向量集合;将所述第二词向量集合中的每个one-hot向量依次输入所述Word2vecc神经网络模型,得到所述第一词向量集合。In a possible example, the first neural network model is the Word2vecc neural network model; in terms of inputting the multiple words into the first neural network model to obtain the first word vector set corresponding to the multiple words, The instructions in the program are specifically used to perform the following operations: the multiple words are converted into one-hot vectors by encoding the multiple words, and the one-hot vectors corresponding to the multiple words form a second word vector Set; each one-hot vector in the second word vector set is sequentially input into the Word2vecc neural network model to obtain the first word vector set.
在一个可能的示例中,所述第二神经网络模型为SVM神经网络模型。In a possible example, the second neural network model is an SVM neural network model.
在一个可能的示例中,在所述输出标签包括第一标签和第二标签;所述根据所述输出标签确定所述目标语句段落的情感极性方面,所述程序中的指令具体用于执行以下操作:在检测到所述输出标签为所述第一标签时,确定所述目标语句段落对应的情感极性为积极的情感;或者,在检测到所述输出标签为所述第二标签时,确定所述目标语句段落对应的情感极性为消极的情感。In a possible example, where the output tag includes a first tag and a second tag; in terms of determining the emotional polarity of the target sentence paragraph according to the output tag, the instructions in the program are specifically used to execute The following operations: when it is detected that the output tag is the first tag, determine that the emotion polarity corresponding to the target sentence paragraph is a positive emotion; or, when it is detected that the output tag is the second tag , It is determined that the emotion polarity corresponding to the target sentence paragraph is a negative emotion.
在一个可能的示例中,所述根据所述输出标签确定所述目标语句段落的情感极性之后,所述程序中的指令具体用于执行以下操作:在所述目标语句段落的预设显示区域显示所述情感极性。In a possible example, after the emotional polarity of the target sentence paragraph is determined according to the output tag, the instructions in the program are specifically used to perform the following operations: in the preset display area of the target sentence paragraph Show the emotional polarity.
在一个可能的示例中,在所述目标语句段落的预设显示区域显示所述情感极性方面,所述程序中的指令具体用于执行以下操作:在检测到所述情感极性为积极的情感时,使用第一颜色进行显示;或者,在检测到所述情感极性为消极的情感时,使用第二颜色进行显示,所述第一颜色不同于所述第二颜色。In a possible example, in terms of displaying the emotional polarity in the preset display area of the target sentence paragraph, the instructions in the program are specifically used to perform the following operations: after detecting that the emotional polarity is positive In the case of emotion, the first color is used for display; or, when the emotion with the negative emotion polarity is detected, the second color is used for display, and the first color is different from the second color.
上述实施例主要从方法侧执行过程的角度对本申请实施例的方案进行了介绍。可以理解的是,电子设备为了实现上述功能,其包含了执行各个功能相应的硬件结构和/或软件模块。本领域技术人员应该很容易意识到,结合本文中所公开的实施例描述的各示例的单元及算法步骤,本申请能够以硬件或硬件和计算机软件的结合形式来实现。某个功能究竟以硬件还是计算机软件驱动硬件的方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用使用不同方法来实现所描述的功能,但是这种实现不应认为超出本申请的范围。The foregoing embodiment mainly introduces the solution of the embodiment of the present application from the perspective of the execution process on the method side. It can be understood that, in order to implement the above-mentioned functions, the electronic device includes hardware structures and/or software modules corresponding to each function. Those skilled in the art should easily realize that in combination with the units and algorithm steps of the examples described in the embodiments disclosed herein, the present application can be implemented in the form of hardware or a combination of hardware and computer software. Whether a certain function is executed by hardware or computer software-driven hardware depends on the specific application and design constraint conditions of the technical solution. Professionals and technicians can use different methods for each specific application to implement the described functions, but such implementation should not be considered beyond the scope of this application.
本申请实施例可以根据所述方法示例对电子设备进行功能单元的划分,例如,可以对应各个功能划分各个功能单元,也可以将两个或两个以上的功能集成在一个处理单元中。 所述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。需要说明的是,本申请实施例中对单元的划分是示意性的,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式。The embodiment of the present application may divide the electronic device into functional units according to the method example. For example, each functional unit may be divided corresponding to each function, or two or more functions may be integrated into one processing unit. The integrated unit can be implemented in the form of hardware or software functional unit. It should be noted that the division of units in the embodiments of the present application is illustrative, and is only a logical function division, and there may be other division methods in actual implementation.
下面为本发明装置实施例,本发明装置实施例用于执行本发明方法实施例所实现的方法。如图5所示的情感极性分析装置500,应用于该电子设备,所述情感极性分析装置包括检测单元501、处理单元502和确定单元503,其中,The following are device embodiments of the present invention, and the device embodiments of the present invention are used to execute the methods implemented in the method embodiments of the present invention. The emotion polarity analysis device 500 shown in FIG. 5 is applied to the electronic device. The emotion polarity analysis device includes a detection unit 501, a processing unit 502, and a determination unit 503, wherein,
所述检测单元501,用于在检测到针对目标语句段落的情感极性分析操作时,获取所述目标语句段落的多个词汇;The detection unit 501 is configured to acquire multiple vocabulary of the target sentence paragraph when the emotion polarity analysis operation for the target sentence paragraph is detected;
所述处理单元502,用于将所述多个词汇输入第一神经网络模型,得到所述多个词汇对应的第一词向量集合,其中,所述第一神经网络模型为用于产生词向量的相关模型集合,并根据所述多个词汇中的目标词汇以及所述目标词汇相邻位置的词汇来确定所述目标词汇的词向量,所述第一词向量集合中的每个词向量用于指示对应词汇的上下文信息;The processing unit 502 is configured to input the plurality of words into a first neural network model to obtain a first set of word vectors corresponding to the plurality of words, wherein the first neural network model is used to generate word vectors And determine the word vector of the target vocabulary according to the target vocabulary in the multiple vocabularies and vocabulary adjacent to the target vocabulary, and each word vector in the first word vector set is used To indicate the contextual information of the corresponding vocabulary;
所述处理单元502,还用于将所述第一词向量集合中的每个词向量输入第二神经网络模型,得到和所述第一词向量集合关联的输出标签,所述输出标签为预设的标签集合中的标签,所述预设的标签集合中的每个标签用于指示一种情感极性;The processing unit 502 is further configured to input each word vector in the first word vector set into a second neural network model to obtain an output label associated with the first word vector set, and the output label is a pre- Tags in the set of tags, each tag in the preset tag set is used to indicate an emotional polarity;
所述确定单元503,用于根据所述输出标签确定所述目标语句段落的情感极性。The determining unit 503 is configured to determine the emotional polarity of the target sentence paragraph according to the output tag.
可以看出,在本申请实施例中,由于电子设备可以通过在对目标语句段落进行情感极性分析时,先通过第一神经网络模型得到每个语句对应的词向量集合,再通过第二神经网络模型得到每个语句对应的情感极性,在进行情感极性分析是不是单独对一个词汇进行分析,还结合了该词汇对应的上下文,从而有利于提高情感极性分析的准确性,帮助用户迅速得到目标语句段落的情感极性分析结果。It can be seen that in the embodiment of the present application, the electronic device can first obtain the word vector set corresponding to each sentence through the first neural network model when performing emotional polarity analysis on the target sentence paragraph, and then through the second neural network model. The network model obtains the sentiment polarity corresponding to each sentence, and whether the sentiment polarity analysis is performed to analyze a vocabulary separately, and also combines the context corresponding to the vocabulary, which helps to improve the accuracy of sentiment polarity analysis and helps users Quickly get the result of sentiment polarity analysis of the target sentence paragraph.
在一个可能的示例中,在所述将所述多个词汇输入第一神经网络模型,得到所述多个词汇对应的第一词向量集合方面,所述处理单元503还用于:获取所述目标段落的多个语句;以及用于将所述多个语句中的每个语句进行拆分,并确定拆分后得到的多个词汇的词性;以及用于选取词性为预设词性的多个词汇并输入所述第一神经网络模型。In a possible example, in the aspect of inputting the multiple words into the first neural network model to obtain the first word vector set corresponding to the multiple words, the processing unit 503 is further configured to: obtain the Multiple sentences of the target paragraph; and used to split each of the multiple sentences, and determine the part of speech of the multiple words obtained after the split; and used to select multiple parts of speech as the preset part of speech Vocabulary and input the first neural network model.
在一个可能的示例中,所述第一神经网络模型为Word2vecc神经网络模型;在所述第一神经网络模型为Word2vecc神经网络模型;所述将所述多个词汇输入第一神经网络模型,得到所述多个词汇对应的第一词向量集合方面,所述处理单元503具体用于:通过对所述多个词汇进行编码将所述多个词汇转换成one-hot向量,所述多个词汇对应的one-hot向量 组成第二词向量集合;以及用于将所述第二词向量集合中的每个one-hot向量依次输入所述Word2vecc神经网络模型,得到所述第一词向量集合。In a possible example, the first neural network model is the Word2vecc neural network model; the first neural network model is the Word2vecc neural network model; and the multiple words are input into the first neural network model to obtain Regarding the first word vector set corresponding to the multiple words, the processing unit 503 is specifically configured to: convert the multiple words into one-hot vectors by encoding the multiple words, and the multiple words The corresponding one-hot vectors form a second word vector set; and are used to input each one-hot vector in the second word vector set into the Word2vecc neural network model in turn to obtain the first word vector set.
在一个可能的示例中,所述第二神经网络模型为SVM神经网络模型。In a possible example, the second neural network model is an SVM neural network model.
在一个可能的示例中,在所述输出标签包括第一标签和第二标签;所述根据所述输出标签确定所述目标语句段落的情感极性方面,所述处理单元503具体用于:在检测到所述输出标签为所述第一标签时,确定所述目标语句段落对应的情感极性为积极的情感;或者,在检测到所述输出标签为所述第二标签时,确定所述目标语句段落对应的情感极性为消极的情感。In a possible example, where the output tags include a first tag and a second tag; in terms of determining the emotional polarity of the target sentence paragraph according to the output tags, the processing unit 503 is specifically configured to: When it is detected that the output tag is the first tag, it is determined that the emotional polarity corresponding to the target sentence paragraph is a positive emotion; or, when it is detected that the output tag is the second tag, it is determined that the The emotion polarity corresponding to the target sentence paragraph is negative emotion.
在一个可能的示例中,所述根据所述输出标签确定所述目标语句段落的情感极性之后,所述处理单元503具体用于:在所述目标语句段落的预设显示区域显示所述情感极性。In a possible example, after the emotion polarity of the target sentence paragraph is determined according to the output tag, the processing unit 503 is specifically configured to: display the emotion in a preset display area of the target sentence paragraph polarity.
在一个可能的示例中,在所述目标语句段落的预设显示区域显示所述情感极性方面,所述处理单元503具体用于:在检测到所述情感极性为积极的情感时,使用第一颜色进行显示;或者,在检测到所述情感极性为消极的情感时,使用第二颜色进行显示,所述第一颜色不同于所述第二颜色。In a possible example, in terms of displaying the emotion polarity in the preset display area of the target sentence paragraph, the processing unit 503 is specifically configured to: when detecting that the emotion polarity is a positive emotion, use The first color is used for display; or, when the negative emotion of the emotional polarity is detected, the second color is used for display, and the first color is different from the second color.
本申请实施例还提供一种计算机存储介质,其中,该计算机存储介质存储用于电子数据交换的计算机程序,该计算机程序使得计算机执行如上述方法实施例中记载的任一方法的部分或全部步骤,上述计算机包括电子设备。An embodiment of the present application also provides a computer storage medium, wherein the computer storage medium stores a computer program for electronic data exchange, and the computer program enables a computer to execute part or all of the steps of any method as recorded in the above method embodiment , The aforementioned computer includes electronic equipment.
本申请实施例还提供一种计算机程序产品,上述计算机程序产品包括存储了计算机程序的非瞬时性计算机可读存储介质,上述计算机程序可操作来使计算机执行如上述方法实施例中记载的任一方法的部分或全部步骤。该计算机程序产品可以为一个软件安装包,上述计算机包括电子设备。The embodiments of the present application also provide a computer program product. The above-mentioned computer program product includes a non-transitory computer-readable storage medium storing a computer program. The above-mentioned computer program is operable to cause a computer to execute any of the methods described in the above-mentioned method embodiments. Part or all of the steps of the method. The computer program product may be a software installation package, and the above-mentioned computer includes electronic equipment.
需要说明的是,对于前述的各方法实施例,为了简单描述,故将其都表述为一系列的动作组合,但是本领域技术人员应该知悉,本申请并不受所描述的动作顺序的限制,因为依据本申请,某些步骤可以采用其他顺序或者同时进行。其次,本领域技术人员也应该知悉,说明书中所描述的实施例均属于优选实施例,所涉及的动作和模块并不一定是本申请所必须的。It should be noted that for the foregoing method embodiments, for the sake of simple description, they are all expressed as a series of action combinations, but those skilled in the art should know that this application is not limited by the described sequence of actions. Because according to this application, some steps can be performed in other order or simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by this application.
在上述实施例中,对各个实施例的描述都各有侧重,某个实施例中没有详述的部分,可以参见其他实施例的相关描述。In the above-mentioned embodiments, the description of each embodiment has its own focus. For parts that are not described in detail in an embodiment, reference may be made to related descriptions of other embodiments.
在本申请所提供的几个实施例中,应该理解到,所揭露的装置,可通过其它的方式实 现。例如,以上所描述的装置实施例仅仅是示意性的,例如上述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性或其它的形式。In the several embodiments provided in this application, it should be understood that the disclosed device may be implemented in other ways. For example, the device embodiments described above are only illustrative. For example, the division of the above-mentioned units is only a logical function division, and there may be other divisions in actual implementation, for example, multiple units or components can be combined or integrated. To another system, or some features can be ignored, or not implemented. In addition, the displayed or discussed mutual coupling or direct coupling or communication connection may be indirect coupling or communication connection through some interfaces, devices or units, and may be in electrical or other forms.
上述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。The units described above as separate components may or may not be physically separate, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the objectives of the solutions of the embodiments.
另外,在本申请各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。In addition, the functional units in each embodiment of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units may be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or software functional unit.
上述集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储器中。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全部或部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储器中,包括若干指令用以使得一台计算机设备(可为个人计算机、服务器或者网络设备等)执行本申请各个实施例上述方法的全部或部分步骤。而前述的存储器包括:U盘、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,Random Access Memory)、移动硬盘、磁碟或者光盘等各种可以存储程序代码的介质。If the above integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer readable memory. Based on this understanding, the technical solution of the present application essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a memory, A number of instructions are included to enable a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the foregoing methods of the various embodiments of the present application. The aforementioned memory includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, magnetic disk or optical disk and other various media that can store program codes.
本领域普通技术人员可以理解上述实施例的各种方法中的全部或部分步骤是可以通过程序来指令相关的硬件来完成,该程序可以存储于一计算机可读存储器中,存储器可以包括:闪存盘、只读存储器(英文:Read-Only Memory,简称:ROM)、随机存取器(英文:Random Access Memory,简称:RAM)、磁盘或光盘等。Those of ordinary skill in the art can understand that all or part of the steps in the various methods of the above-mentioned embodiments can be completed by instructing relevant hardware through a program. The program can be stored in a computer-readable memory, and the memory can include: flash disk , Read-only memory (English: Read-Only Memory, abbreviation: ROM), random access device (English: Random Access Memory, abbreviation: RAM), magnetic disk or optical disc, etc.
以上对本申请实施例进行了详细介绍,本文中应用了具体个例对本申请的原理及实施方式进行了阐述,以上实施例的说明只是用于帮助理解本申请的方法及其核心思想;同时,对于本领域的一般技术人员,依据本申请的思想,在具体实施方式及应用范围上均会有改变之处,综上所述,本说明书内容不应理解为对本申请的限制。The embodiments of the application are described in detail above, and specific examples are used in this article to illustrate the principles and implementation of the application. The descriptions of the above examples are only used to help understand the methods and core ideas of the application; A person of ordinary skill in the art, based on the idea of the present application, will have changes in the specific implementation and the scope of application. In summary, the content of this specification should not be construed as a limitation of the present application.

Claims (20)

  1. 一种情感极性分析方法,其特征在于,应用于电子设备,所述方法包括:An emotional polarity analysis method, characterized in that it is applied to an electronic device, and the method includes:
    在检测到针对目标语句段落的情感极性分析操作时,获取所述目标语句段落的多个词汇;When the sentiment polarity analysis operation for the target sentence paragraph is detected, acquiring multiple words of the target sentence paragraph;
    将所述多个词汇输入第一神经网络模型,得到所述多个词汇对应的第一词向量集合,其中,所述第一神经网络模型为用于产生词向量的相关模型集合,并根据所述多个词汇中的目标词汇以及所述目标词汇相邻位置的词汇来确定所述目标词汇的词向量,所述第一词向量集合中的每个词向量用于指示对应词汇的上下文信息;Input the multiple vocabularies into a first neural network model to obtain a first set of word vectors corresponding to the multiple vocabularies, where the first neural network model is a set of related models used to generate word vectors and is based on Stating a target vocabulary in a plurality of vocabulary and vocabulary adjacent to the target vocabulary to determine a word vector of the target vocabulary, and each word vector in the first word vector set is used to indicate context information of a corresponding vocabulary;
    将所述第一词向量集合中的每个词向量输入第二神经网络模型,得到和所述第一词向量集合关联的输出标签,所述输出标签为预设的标签集合中的标签,所述预设的标签集合中的每个标签用于指示一种情感极性;Each word vector in the first word vector set is input to the second neural network model to obtain an output label associated with the first word vector set, and the output label is a label in a preset label set, so Each label in the preset label set is used to indicate an emotional polarity;
    根据所述输出标签确定所述目标语句段落的情感极性。The emotional polarity of the target sentence paragraph is determined according to the output tag.
  2. 如权利要求1所述的方法,其特征在于,所述将所述多个词汇输入第一神经网络模型,得到所述多个词汇对应的第一词向量集合,包括:The method according to claim 1, wherein said inputting said plurality of words into a first neural network model to obtain a first set of word vectors corresponding to said plurality of words comprises:
    获取所述目标段落的多个语句;Acquiring multiple sentences of the target paragraph;
    将所述多个语句中的每个语句进行拆分,并确定拆分后得到的多个词汇的词性;Split each sentence in the plurality of sentences, and determine the part of speech of the plurality of words obtained after the split;
    选取词性为预设词性的多个词汇并输入所述第一神经网络模型。A plurality of words whose part of speech is a preset part of speech are selected and input into the first neural network model.
  3. 如权利要求1或2所述的方法,其特征在于,所述第一神经网络模型为Word2vecc神经网络模型;所述将所述多个词汇输入第一神经网络模型,得到所述多个词汇对应的第一词向量集合,包括:The method of claim 1 or 2, wherein the first neural network model is a Word2vecc neural network model; and the multiple words are input into the first neural network model to obtain the corresponding words The first word vector set includes:
    通过对所述多个词汇进行编码将所述多个词汇转换成one-hot向量,所述多个词汇对应的one-hot向量组成第二词向量集合;Converting the multiple vocabularies into one-hot vectors by encoding the multiple vocabularies, and one-hot vectors corresponding to the multiple vocabularies form a second word vector set;
    将所述第二词向量集合中的每个one-hot向量依次输入所述Word2vecc神经网络模型,得到所述第一词向量集合。Each one-hot vector in the second word vector set is sequentially input into the Word2vecc neural network model to obtain the first word vector set.
  4. 如权利要求1-3任一项所述的方法,其特征在于,所述第二神经网络模型为SVM神经网络模型。The method according to any one of claims 1 to 3, wherein the second neural network model is an SVM neural network model.
  5. 如权利要求1所述的方法,其特征在于,所述输出标签包括第一标签和第二标签;所述根据所述输出标签确定所述目标语句段落的情感极性,包括:The method of claim 1, wherein the output tag includes a first tag and a second tag; and the determining the emotional polarity of the target sentence paragraph according to the output tag includes:
    在检测到所述输出标签为所述第一标签时,确定所述目标语句段落对应的情感极性为 积极的情感;或者,When it is detected that the output tag is the first tag, it is determined that the emotion polarity corresponding to the target sentence paragraph is a positive emotion; or,
    在检测到所述输出标签为所述第二标签时,确定所述目标语句段落对应的情感极性为消极的情感。When it is detected that the output tag is the second tag, it is determined that the emotion polarity corresponding to the target sentence paragraph is a negative emotion.
  6. 如权利要求1-5任一项所述的方法,其特征在于,所述根据所述输出标签确定所述目标语句段落的情感极性之后,所述方法还包括:5. The method according to any one of claims 1 to 5, wherein after the determining the emotional polarity of the target sentence paragraph according to the output label, the method further comprises:
    在所述目标语句段落的预设显示区域显示所述情感极性。The emotional polarity is displayed in the preset display area of the target sentence paragraph.
  7. 如权利要求6所述的方法,其特征在于,所述在所述目标语句段落的预设显示区域显示所述情感极性,包括:7. The method of claim 6, wherein the displaying the emotional polarity in the preset display area of the target sentence paragraph comprises:
    在检测到所述情感极性为积极的情感时,使用第一颜色进行显示;或者,When detecting that the emotion polarity is a positive emotion, use the first color for display; or,
    在检测到所述情感极性为消极的情感时,使用第二颜色进行显示,所述第一颜色不同于所述第二颜色。When the negative emotion of the emotion polarity is detected, a second color is used for display, and the first color is different from the second color.
  8. 一种情感极性分析装置,其特征在于,应用于电子设备,所述情感极性分析装置包括检测单元、处理单元和确定单元,其中,An emotion polarity analysis device, characterized in that it is applied to electronic equipment, the emotion polarity analysis device includes a detection unit, a processing unit, and a determination unit, wherein:
    所述检测单元,用于在检测到针对目标语句段落的情感极性分析操作时,获取所述目标语句段落的多个词汇;The detection unit is configured to obtain multiple words of the target sentence paragraph when an emotion polarity analysis operation for the target sentence paragraph is detected;
    所述处理单元,用于将所述多个词汇输入第一神经网络模型,得到所述多个词汇对应的第一词向量集合,其中,所述第一神经网络模型为用于产生词向量的相关模型集合,并根据所述多个词汇中的目标词汇以及所述目标词汇相邻位置的词汇来确定所述目标词汇的词向量,所述第一词向量集合中的每个词向量用于指示对应词汇的上下文信息;The processing unit is configured to input the multiple words into a first neural network model to obtain a first word vector set corresponding to the multiple words, wherein the first neural network model is used to generate word vectors Related model sets, and determine the word vector of the target vocabulary according to the target vocabulary in the plurality of vocabularies and vocabulary adjacent to the target vocabulary, and each word vector in the first word vector set is used for Indicates the context information of the corresponding vocabulary;
    所述处理单元,还用于将所述第一词向量集合中的每个词向量输入第二神经网络模型,得到和所述第一词向量集合关联的输出标签,所述输出标签为预设的标签集合中的标签,所述预设的标签集合中的每个标签用于指示一种情感极性;The processing unit is further configured to input each word vector in the first word vector set into a second neural network model to obtain an output label associated with the first word vector set, and the output label is a preset Tags in the tag set of, each tag in the preset tag set is used to indicate an emotional polarity;
    所述确定单元,用于根据所述输出标签确定所述目标语句段落的情感极性。The determining unit is configured to determine the emotional polarity of the target sentence paragraph according to the output tag.
  9. 根据权利要求8所述的情感极性分析装置,其特征在于,在所述将所述多个词汇输入第一神经网络模型,得到所述多个词汇对应的第一词向量集合方面,所述处理单元具体用于:获取所述目标段落的多个语句;以及用于将所述多个语句中的每个语句进行拆分,并确定拆分后得到的多个词汇的词性;以及用于选取词性为预设词性的多个词汇并输入所述第一神经网络模型。The emotion polarity analysis device according to claim 8, wherein, in the aspect of inputting the plurality of words into the first neural network model to obtain the first word vector set corresponding to the plurality of words, the The processing unit is specifically used for: obtaining multiple sentences of the target paragraph; and for splitting each sentence of the multiple sentences, and determining the parts of speech of the multiple words obtained after splitting; and A plurality of words whose part of speech is a preset part of speech are selected and input into the first neural network model.
  10. 根据权利要求8或9所述的情感极性分析装置,其特征在于,所述第一神经网络 模型为Word2vecc神经网络模型;在所述将所述多个词汇输入第一神经网络模型,得到所述多个词汇对应的第一词向量集合方面,所述处理单元具体用于:通过对所述多个词汇进行编码将所述多个词汇转换成one-hot向量,所述多个词汇对应的one-hot向量组成第二词向量集合;以及用于将所述第二词向量集合中的每个one-hot向量依次输入所述Word2vecc神经网络模型,得到所述第一词向量集合。The emotion polarity analysis device according to claim 8 or 9, wherein the first neural network model is a Word2vecc neural network model; in the inputting the plurality of words into the first neural network model, the result Regarding the first set of word vectors corresponding to multiple words, the processing unit is specifically configured to: convert the multiple words into one-hot vectors by encoding the multiple words, and the multiple words corresponding to the The one-hot vector forms a second word vector set; and is used to input each one-hot vector in the second word vector set into the Word2vecc neural network model in turn to obtain the first word vector set.
  11. 根据权利要求8-10任一项所述的情感极性分析装置,其特征在于,所述第二神经网络模型为SVM神经网络模型。The emotional polarity analysis device according to any one of claims 8-10, wherein the second neural network model is an SVM neural network model.
  12. 根据权利要求8所述的情感极性分析装置,其特征在于,所述输出标签包括第一标签和第二标签在所述根据所述输出标签确定所述目标语句段落的情感极性方面,所述确定单元具体用于:在检测到所述输出标签为所述第一标签时,确定所述目标语句段落对应的情感极性为积极的情感;或者,以及用于在检测到所述输出标签为所述第二标签时,确定所述目标语句段落对应的情感极性为消极的情感。8. The emotion polarity analysis device according to claim 8, wherein the output tag includes a first tag and a second tag. In terms of determining the emotion polarity of the target sentence paragraph according to the output tag, The determining unit is specifically configured to: when detecting that the output tag is the first tag, determine that the emotion polarity corresponding to the target sentence paragraph is a positive emotion; or, when the output tag is detected When it is the second tag, it is determined that the emotion polarity corresponding to the target sentence paragraph is a negative emotion.
  13. 根据权利要求8-12任一项所述的情感极性分析装置,其特征在于,所述根据所述输出标签确定所述目标语句段落的情感极性之后,所述处理单元还用于在所述目标语句段落的预设显示区域显示所述情感极性。The emotional polarity analysis device according to any one of claims 8-12, wherein after the emotional polarity of the target sentence paragraph is determined according to the output tag, the processing unit is further configured to The preset display area of the target sentence paragraph displays the emotional polarity.
  14. 根据权利要求13所述的情感极性分析装置,其特征在于,在所述在所述目标语句段落的预设显示区域显示所述情感极性方面,所述处理单元具体用于:在检测到所述情感极性为积极的情感时,使用第一颜色进行显示;或者,在检测到所述情感极性为消极的情感时,使用第二颜色进行显示,所述第一颜色不同于所述第二颜色。The emotion polarity analysis device according to claim 13, wherein in the aspect of displaying the emotion polarity in the preset display area of the target sentence paragraph, the processing unit is specifically configured to: When the emotional polarity is a positive emotion, the first color is used for display; or when the emotional polarity is negative, the second color is used for display, and the first color is different from the The second color.
  15. 一种电子设备,其特征在于,包括处理器和存储器,所述处理器和存储器相互连接,其中,所述存储器用于存储计算机程序,所述计算机程序包括程序指令,所述处理器被配置用于调用所述程序指令,执行以下步骤:An electronic device, characterized by comprising a processor and a memory, the processor and the memory are connected to each other, wherein the memory is used to store a computer program, the computer program includes program instructions, and the processor is configured to To call the program instructions, perform the following steps:
    在检测到针对目标语句段落的情感极性分析操作时,获取所述目标语句段落的多个词汇;When the sentiment polarity analysis operation for the target sentence paragraph is detected, acquiring multiple words of the target sentence paragraph;
    将所述多个词汇输入第一神经网络模型,得到所述多个词汇对应的第一词向量集合,所述第一词向量集合中的每个词向量用于指示对应词汇的上下文信息;Inputting the plurality of words into the first neural network model to obtain a first word vector set corresponding to the plurality of words, and each word vector in the first word vector set is used to indicate context information of the corresponding word;
    将所述第一词向量集合中的每个词向量输入第二神经网络模型,得到和所述第一词向量集合关联的输出标签;Input each word vector in the first word vector set into a second neural network model to obtain an output label associated with the first word vector set;
    根据所述输出标签确定所述目标语句段落的情感极性。The emotional polarity of the target sentence paragraph is determined according to the output tag.
  16. 根据权利要求15所述的电子设备,其特征在于,所述处理器调用所述程序指令执行所述将所述多个词汇输入第一神经网络模型,得到所述多个词汇对应的第一词向量集合时,具体执行以下步骤:The electronic device according to claim 15, wherein the processor calls the program instructions to execute the input of the plurality of words into the first neural network model to obtain the first word corresponding to the plurality of words When vector collection, perform the following steps:
    获取所述目标段落的多个语句;Acquiring multiple sentences of the target paragraph;
    将所述多个语句中的每个语句进行拆分,并确定拆分后得到的多个词汇的词性;Split each sentence in the plurality of sentences, and determine the part of speech of the plurality of words obtained after the split;
    选取词性为预设词性的多个词汇并输入所述第一神经网络模型。A plurality of words whose part of speech is a preset part of speech are selected and input into the first neural network model.
  17. 根据权利要求15或16所述的电子设备,其特征在于,所述第一神经网络模型为Word2vecc神经网络模型;所述处理器调用所述程序指令执行所述将所述多个词汇输入第一神经网络模型,得到所述多个词汇对应的第一词向量集合时,具体执行以下步骤:The electronic device according to claim 15 or 16, wherein the first neural network model is a Word2vecc neural network model; the processor calls the program instructions to execute the input of the multiple words into the first When the neural network model obtains the first word vector set corresponding to the multiple words, the following steps are specifically performed:
    通过对所述多个词汇进行编码将所述多个词汇转换成one-hot向量,所述多个词汇对应的one-hot向量组成第二词向量集合;Converting the multiple vocabularies into one-hot vectors by encoding the multiple vocabularies, and one-hot vectors corresponding to the multiple vocabularies form a second word vector set;
    将所述第二词向量集合中的每个one-hot向量依次输入所述Word2vecc神经网络模型,得到所述第一词向量集合。Each one-hot vector in the second word vector set is sequentially input into the Word2vecc neural network model to obtain the first word vector set.
  18. 根据权利要求15-17任一项所述的电子设备,其特征在于,所述第二神经网络模型为SVM神经网络模型。The electronic device according to any one of claims 15-17, wherein the second neural network model is an SVM neural network model.
  19. 根据权利要求15所述的电子设备,其特征在于,所述输出标签包括第一标签和第二标签;所述处理器调用所述程序指令执行所述根据所述输出标签确定所述目标语句段落的情感极性时,具体执行以下步骤:The electronic device according to claim 15, wherein the output tag includes a first tag and a second tag; the processor calls the program instructions to execute the determination of the target sentence paragraph based on the output tag In the case of emotional polarity, perform the following steps:
    在检测到所述输出标签为所述第一标签时,确定所述目标语句段落对应的情感极性为积极的情感;或者,When it is detected that the output tag is the first tag, it is determined that the emotion polarity corresponding to the target sentence paragraph is a positive emotion; or,
    在检测到所述输出标签为所述第二标签时,确定所述目标语句段落对应的情感极性为消极的情感。When it is detected that the output tag is the second tag, it is determined that the emotion polarity corresponding to the target sentence paragraph is a negative emotion.
  20. 一种计算机可读存储介质,其特征在于,所述计算机可读存储介质存储有计算机程序,所述计算机程序包括程序指令,所述程序指令当被处理器执行时使所述处理器执行如权利要求1-7任一项所述的方法。A computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and the computer program includes program instructions that, when executed by a processor, cause the processor to execute The method of any one of 1-7 is required.
PCT/CN2019/118447 2019-04-03 2019-11-14 Sentiment polarity analysis method and related device WO2020199600A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201910267765.4 2019-04-03
CN201910267765.4A CN110083829A (en) 2019-04-03 2019-04-03 Feeling polarities analysis method and relevant apparatus

Publications (1)

Publication Number Publication Date
WO2020199600A1 true WO2020199600A1 (en) 2020-10-08

Family

ID=67414214

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2019/118447 WO2020199600A1 (en) 2019-04-03 2019-11-14 Sentiment polarity analysis method and related device

Country Status (2)

Country Link
CN (1) CN110083829A (en)
WO (1) WO2020199600A1 (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US11366965B1 (en) * 2021-10-29 2022-06-21 Jouf University Sentiment analysis using bag-of-phrases for Arabic text dialects
CN116069832A (en) * 2023-04-07 2023-05-05 微网优联科技(成都)有限公司 Data mining method and device and electronic equipment

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110083829A (en) * 2019-04-03 2019-08-02 平安科技(深圳)有限公司 Feeling polarities analysis method and relevant apparatus
WO2021022521A1 (en) * 2019-08-07 2021-02-11 华为技术有限公司 Method for processing data, and method and device for training neural network model
CN112784575B (en) * 2019-10-22 2023-06-30 北京四维图新科技股份有限公司 Sentence processing method and device
CN111666761B (en) * 2020-05-13 2022-12-09 北京大学 Fine-grained emotion analysis model training method and device
CN111767740A (en) * 2020-06-23 2020-10-13 北京字节跳动网络技术有限公司 Sound effect adding method and device, storage medium and electronic equipment

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108984724A (en) * 2018-07-10 2018-12-11 凯尔博特信息科技(昆山)有限公司 It indicates to improve particular community emotional semantic classification accuracy rate method using higher-dimension
CN109213861A (en) * 2018-08-01 2019-01-15 上海电力学院 In conjunction with the tourism evaluation sensibility classification method of At_GRU neural network and sentiment dictionary
US10181333B2 (en) * 2017-04-04 2019-01-15 International Business Machines Corporation Intelligent truthfulness indicator association
CN109408823A (en) * 2018-10-31 2019-03-01 华南师范大学 A kind of specific objective sentiment analysis method based on multi-channel model
CN110083829A (en) * 2019-04-03 2019-08-02 平安科技(深圳)有限公司 Feeling polarities analysis method and relevant apparatus

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109408809A (en) * 2018-09-25 2019-03-01 天津大学 A kind of sentiment analysis method for automobile product comment based on term vector

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10181333B2 (en) * 2017-04-04 2019-01-15 International Business Machines Corporation Intelligent truthfulness indicator association
CN108984724A (en) * 2018-07-10 2018-12-11 凯尔博特信息科技(昆山)有限公司 It indicates to improve particular community emotional semantic classification accuracy rate method using higher-dimension
CN109213861A (en) * 2018-08-01 2019-01-15 上海电力学院 In conjunction with the tourism evaluation sensibility classification method of At_GRU neural network and sentiment dictionary
CN109408823A (en) * 2018-10-31 2019-03-01 华南师范大学 A kind of specific objective sentiment analysis method based on multi-channel model
CN110083829A (en) * 2019-04-03 2019-08-02 平安科技(深圳)有限公司 Feeling polarities analysis method and relevant apparatus

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US11366965B1 (en) * 2021-10-29 2022-06-21 Jouf University Sentiment analysis using bag-of-phrases for Arabic text dialects
CN116069832A (en) * 2023-04-07 2023-05-05 微网优联科技(成都)有限公司 Data mining method and device and electronic equipment
CN116069832B (en) * 2023-04-07 2023-06-06 微网优联科技(成都)有限公司 Data mining method and device and electronic equipment

Also Published As

Publication number Publication date
CN110083829A (en) 2019-08-02

Similar Documents

Publication Publication Date Title
WO2020199600A1 (en) Sentiment polarity analysis method and related device
CN108647205B (en) Fine-grained emotion analysis model construction method and device and readable storage medium
Gries et al. Using regressions to explore deviations between corpus data and a standard/target: Two suggestions
CN106796594B (en) Generating high-level questions from sentences
US9208144B1 (en) Crowd-sourced automated vocabulary learning system
JP2019504413A (en) System and method for proposing emoji
US20140351228A1 (en) Dialog system, redundant message removal method and redundant message removal program
KR20160026892A (en) Non-factoid question-and-answer system and method
CN111930792B (en) Labeling method and device for data resources, storage medium and electronic equipment
WO2021218028A1 (en) Artificial intelligence-based interview content refining method, apparatus and device, and medium
CN110825867B (en) Similar text recommendation method and device, electronic equipment and storage medium
CN110287405B (en) Emotion analysis method, emotion analysis device and storage medium
TW201403354A (en) System and method using data reduction approach and nonlinear algorithm to construct Chinese readability model
CN111177351A (en) Method, device and system for acquiring natural language expression intention based on rule
Eika et al. Assessing the reading level of web texts for WCAG2. 0 compliance—can it be done automatically?
CN111241397A (en) Content recommendation method and device and computing equipment
CN111160041A (en) Semantic understanding method and device, electronic equipment and storage medium
CN110610003A (en) Method and system for assisting text annotation
CN107734123A (en) A kind of contact sequencing method and device
CN110969005A (en) Method and device for determining similarity between entity corpora
CN113505786A (en) Test question photographing and judging method and device and electronic equipment
CN112559711A (en) Synonymous text prompting method and device and electronic equipment
WO2020199590A1 (en) Mood detection analysis method and related device
Sudiro et al. Aspect Based Sentiment Analysis with Combination Feature Extraction LDA and Word2vec
Wang et al. Word intuition agreement among Chinese speakers: a Mechanical Turk-based study

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 19923187

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 19923187

Country of ref document: EP

Kind code of ref document: A1