WO2024087297A1 - 文本情感分析方法、装置、电子设备及存储介质 - Google Patents

文本情感分析方法、装置、电子设备及存储介质 Download PDF

Info

Publication number
WO2024087297A1
WO2024087297A1 PCT/CN2022/134576 CN2022134576W WO2024087297A1 WO 2024087297 A1 WO2024087297 A1 WO 2024087297A1 CN 2022134576 W CN2022134576 W CN 2022134576W WO 2024087297 A1 WO2024087297 A1 WO 2024087297A1
Authority
WO
WIPO (PCT)
Prior art keywords
vector
text
analyzed
information
feature information
Prior art date
Application number
PCT/CN2022/134576
Other languages
English (en)
French (fr)
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 WO2024087297A1 publication Critical patent/WO2024087297A1/zh

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/289Phrasal analysis, e.g. finite state techniques or chunking
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/20Natural language analysis
    • G06F40/205Parsing
    • G06F40/216Parsing using statistical methods
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/30Semantic analysis

Definitions

  • the present application relates to the technical field of natural language processing, for example, to a text sentiment analysis method, device, electronic device and storage medium.
  • sentiment analysis on text information, such as sentiment analysis on user comment text information, it is easy to obtain the public's views on an event or a product.
  • the present application provides a text sentiment analysis method, device, electronic device and storage medium to solve the problem that the analysis of sentiment information corresponding to the text is not accurate enough and the analysis efficiency is low.
  • the present application embodiment provides a text sentiment analysis method, including:
  • the present application also provides a text sentiment analysis device, including:
  • a feature information determination module configured to obtain a text to be analyzed, and determine first feature information to be used and second feature information to be used corresponding to the text to be analyzed, wherein the first feature information to be used is context feature information, and the second feature information to be used is syntactic feature information;
  • an embedding vector determination module configured to determine a first embedding vector corresponding to the first feature information to be used, and to determine a second embedding vector corresponding to the second feature information to be used;
  • a latent vector determination module configured to determine a latent vector to be used corresponding to the text to be analyzed
  • the sentiment information determination module is configured to determine the sentiment information corresponding to the text to be analyzed based on the first embedding vector, the second embedding vector and the latent vector to be used.
  • the present application also provides an electronic device, including:
  • the memory stores a computer program that can be executed by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the text sentiment analysis method described in any embodiment of the present application.
  • An embodiment of the present application also provides a computer-readable storage medium, which stores computer instructions, and the computer instructions are used to enable a processor to implement the text sentiment analysis method described in any embodiment of the present application when executed.
  • FIG1 is a flow chart of a text sentiment analysis method provided according to Embodiment 1 of the present application.
  • FIG2 is a schematic diagram of a model of a text sentiment analysis method provided according to Embodiment 2 of the present application.
  • FIG3 is a schematic diagram of the structure of a text sentiment analysis device provided according to Embodiment 3 of the present application.
  • FIG4 is a schematic diagram of the structure of an electronic device that implements the text sentiment analysis method of an embodiment of the present application.
  • Sentiment analysis of text content is very practical in many scenarios, such as determining the user's preference for a movie through movie review information, or understanding the user's evaluation of restaurant dishes or services through user comment information, or understanding the user's evaluation of electronic products through user feedback information, etc., so as to better understand user needs based on user feedback information and corresponding sentiment information to improve related products.
  • Figure 1 is a flow chart of a text sentiment analysis method provided in Example 1 of the present application. This embodiment can be applied to situations where a text sentiment tendency analysis is required quickly and accurately.
  • the method can be executed by a text sentiment analysis device.
  • the text sentiment analysis device can be implemented in the form of hardware and/or software.
  • the text sentiment analysis device can be configured in a computing device that can execute the text sentiment analysis method.
  • the method includes the following steps.
  • S110 Acquire a text to be analyzed, and determine first feature information to be used and second feature information to be used corresponding to the text to be analyzed.
  • the text to be analyzed can be understood as text information that needs to be subjected to sentiment analysis, such as user comment information in the comment area, film review information, book review information, and any text information with sentiment tendencies.
  • sentiment analysis can be performed on the text to be analyzed through a dual-channel attention mechanism.
  • the so-called dual-channel attention mechanism includes an attention mechanism for sentiment analysis of the text to be analyzed based on contextual features, and an attention mechanism for sentiment analysis of the text to be analyzed based on syntactic knowledge.
  • the first feature information to be used can be understood as context feature information corresponding to the text to be analyzed, obtained based on the context feature attention mechanism.
  • the second feature information to be used can be understood as syntactic feature information obtained by analyzing the text to be analyzed based on the syntactic knowledge attention mechanism.
  • the context feature information and syntactic knowledge feature information of the text to be analyzed may be analyzed simultaneously to obtain first feature information to be used and second feature information to be used corresponding to the text to be analyzed.
  • determining the first feature information to be used and the second feature information to be used corresponding to the text to be analyzed includes: determining a dependency syntax tree corresponding to the text to be analyzed; obtaining the first feature information to be used corresponding to the text to be analyzed based on the context feature dependency relationship between at least two word segments in the dependency syntax tree; and obtaining the second feature information to be used corresponding to the text to be analyzed based on the syntactic dependency relationship between at least two word segments in the dependency syntax tree.
  • the text to be analyzed includes at least two word segments
  • the dependency syntactic tree can be understood as a relationship diagram containing context feature information and syntactic feature information of the text to be analyzed, that is, the dependency syntactic tree is constructed based on the context features and syntactic features between at least two word segments.
  • a dependency syntax tree corresponding to the text to be analyzed is constructed to obtain first feature information to be used and second feature information to be used corresponding to the text to be analyzed according to context feature dependencies and syntax dependencies in the dependency syntax tree.
  • the text to be analyzed is "This mushroom seafood soup is great".
  • the r words before the word “soup” and the r words after the word “soup” can be selected.
  • the first feature information to be used corresponding to "soup” is "seafood” and "very”, which is the first feature information to be used in the text to be analyzed.
  • this text to be analyzed it can be determined based on the syntactic knowledge features that, relative to the word “soup", “this” is a qualifier, “mushroom” and “seafood” are descriptive words, “great” is a modifier, and the word “very” is used to characterize the degree of “great” and has no direct association with the word “soup”.
  • the second feature information to be used corresponding to the text to be analyzed can be obtained, that is, the second feature information to be used is information used to characterize the syntactic knowledge of the text to be analyzed.
  • S120 Determine a first embedding vector corresponding to the first feature information to be used, and determine a second embedding vector corresponding to the second feature information to be used.
  • the first embedded vector is a vector obtained by vectorizing the first feature information to be used.
  • the second embedded vector is a vector obtained by vectorizing the second feature information to be used.
  • determining the first embedding vector corresponding to the first feature information to be used includes: mapping the first feature information to be used based on a first embedding function to obtain the first mapping information to be used; determining the first position information of the first mapping information to be used in the context feature embedding matrix, and determining the first embedding vector corresponding to the first mapping information to be used based on the matrix element corresponding to the first position information.
  • the first embedding function can be understood as a function that maps the first feature information to be used to obtain the corresponding first mapping information to be used. By vectorizing the first mapping information to be used, a first embedding vector can be obtained.
  • the context feature embedding matrix can be understood as a pre-constructed information matrix containing a large number of word segments.
  • the context feature embedding matrix contains 20,000 word segments, and multiple word segments are located in different rows of the matrix, and each matrix row corresponds to a unique vector value.
  • multiple word segments in the text to be analyzed are segmented respectively, taking the current word segment as an example, where the current word segment can be used as the first feature information to be used, and according to the matrix row corresponding to the current word segment in the context embedding matrix, that is, the first position information, a unique vector value corresponding to the current word segment can be obtained, that is, a matrix element corresponding to the first position, and the matrix element is determined as the first embedding vector.
  • determining a second embedding vector corresponding to second feature information to be used includes: mapping the second feature information to be used based on a second embedding function to obtain second mapping information to be used; determining second position information of the second mapping information to be used in the syntactic feature embedding matrix, and determining a second embedding vector corresponding to the second mapping information to be used based on the matrix elements corresponding to the second position information.
  • the second embedding function can be understood as a function that maps the second feature information to be used to obtain the corresponding second mapping information to be used. By vectorizing the second mapping information to be used, a second embedding vector can be obtained.
  • the syntactic feature embedding matrix can be understood as a pre-constructed information matrix containing a large amount of syntactic knowledge, such as the syntactic relationship between noun phrases, subjects, modifiers, and degree adverbs.
  • the syntactic feature embedding matrix contains 500 syntactic knowledge, and multiple word segments are located in different rows of the matrix, and each matrix row corresponds to a unique vector value.
  • multiple word segments in the text to be analyzed are segmented respectively, taking the current word segment as an example, wherein the current word segment can be used as the second feature information to be used, and according to the matrix row corresponding to the current word segment in the syntactic embedding matrix, that is, the second position information, a unique vector value corresponding to the current word segment can be obtained, that is, a matrix element corresponding to the second position, and the matrix element is determined as the second embedding vector.
  • the latent vector to be used is a vector obtained after vectorizing the text to be analyzed based on a language representation model based on a bidirectional encoder representation from transformer (Bidirectional Encoder Representations from Transformer, BERT).
  • determining the latent vector to be used corresponding to the text to be analyzed includes: encoding the text to be analyzed based on a language representation model to obtain a word segmentation vector to be used corresponding to each word in the text to be analyzed; concatenating multiple word segmentation vectors to be used to obtain a latent vector to be used corresponding to the text to be analyzed.
  • the word segmentation to be used can be understood as multiple word segmentations in the text to be analyzed.
  • the word segmentation vector to be used is the latent vector corresponding to each word segmentation.
  • the latent vector to be used is the latent vector obtained after concatenating multiple word segmentation vectors to be used.
  • the text to be analyzed is input into the BERT model, and each word to be used in the text to be analyzed is encoded based on the BERT model, so that the word vector to be used corresponding to each word to be used can be obtained.
  • Input into the model use the standard encoding method of the BERT model to encode each word to be used in the matrix, and output the context vector representation corresponding to each word, that is, the word vector to be used corresponding to each word.
  • the word vector to be used of the i-th word x i is recorded as h i
  • the text to be analyzed The corresponding latent vector to be used can be expressed as:
  • n represents the number of segmented words to be used
  • h 1 ... hn represents the latent vector to be used
  • x represents the segmented words to be used in the text to be analyzed.
  • S140 Determine the sentiment information corresponding to the text to be analyzed according to the first embedding vector, the second embedding vector and the latent vector to be used.
  • the first embedding vector includes the context feature information corresponding to the text to be analyzed
  • the second embedding vector includes the syntactic feature information corresponding to the text to be analyzed
  • the latent vector to be used includes the emotional feature information corresponding to the text to be analyzed. Based on this, the emotional information corresponding to the text to be analyzed can be determined according to the first embedding vector, the second embedding vector and the latent vector to be used.
  • the sentiment information corresponding to the text to be analyzed is determined according to the first embedding vector, the second embedding vector and the latent vector to be used, including: determining a first weight corresponding to the first embedding vector according to the first embedding vector and the latent vector to be used; determining a second weight corresponding to the second embedding vector according to the second embedding vector and the latent vector to be used; determining the sentiment information corresponding to the text to be analyzed according to the first embedding vector, the first weight, the second embedding vector and the second weight.
  • the first weight corresponding to the first embedding vector and the second weight corresponding to the second embedding vector can be determined by analyzing the influence of context features and grammatical features in sentiment analysis.
  • the first weight can be determined by the following formula:
  • in represents the first weight
  • exp represents the exponential function with the natural constant e as the base
  • e represents the first embedding vector
  • hi represents the word segmentation vector to be used
  • j represents the summed number
  • 2r represents the number of word segmentations associated with the word to be used.
  • the second weight can be determined by the following formula:
  • in represents the second weight
  • exp represents the exponential function with the natural constant e as the base
  • e represents the second embedding vector
  • hi represents the word segmentation vector to be used
  • k represents the summed number
  • mi represents the number of word segmentations associated with the word to be used.
  • the first embedding vector may be a vector corresponding to each word segment to be used in the text to be analyzed
  • the second embedding vector is a vector corresponding to each word segment to be used in the text to be analyzed.
  • the context feature vector corresponding to the text to be analyzed is obtained by concatenating multiple first embedding vectors, and the grammatical feature vector corresponding to the text to be analyzed is obtained based on multiple second embedding vectors. That is to say, in this technical solution, the sentiment information corresponding to each word segment to be used can be obtained by processing each word segment to be used separately.
  • the sentiment information corresponding to the text to be analyzed is determined, including: based on the first embedding vector and the first weight, a first vector to be spliced is obtained, and based on the second embedding vector and the second weight, a second vector to be spliced is obtained; the first vector to be spliced and the second vector to be spliced are spliced to obtain a target vector; the target vector is input into a pre-constructed decoder to perform sentiment analysis on the target vector based on the decoder to determine the sentiment information corresponding to the text to be analyzed.
  • the first vector to be spliced can be understood as a vector obtained by multiplying the first embedding vector and the first weight
  • the second vector to be spliced can be understood as a vector obtained by multiplying the second embedding vector and the second weight
  • the target vector can be understood as a vector obtained by splicing the first vector to be spliced and the second vector to be spliced.
  • the first vector to be spliced and the second vector to be spliced corresponding to word segment 1 in the text to be analyzed are spliced to obtain the target vector corresponding to word segment 1.
  • the first vector to be concatenated can be obtained based on the following formula:
  • the second splicing vector can be obtained based on the following formula:
  • the target vector can be obtained based on the following formula:
  • a i represents the target vector, represents the first vector to be concatenated, represents the second vector to be concatenated, It indicates that the first vector to be spliced and the second vector to be spliced are spliced.
  • the target vector corresponding to the text to be analyzed can be obtained by concatenating each target vector.
  • the target vector corresponding to the text to be analyzed is input into the fully connected layer for processing, and the processed vector is input into the pre-built decoder, such as the softmax decoder, to obtain the label corresponding to each word, so as to output the aspect word predicted by the model and the sentiment polarity of the aspect word according to the meaning of the label of each word.
  • the final output result includes the sentiment information corresponding to these 10 segmented words, and the sentiment information can be expressed as "positive” or "negative”.
  • This setting can analyze the sentiment information of each segmented word in the text to be analyzed, with finer granularity, which can better help the sentiment analysis of the text to be analyzed.
  • This technical solution uses a dual-channel attention mechanism to analyze the text to be analyzed, and can analyze the contextual features and syntactic features of the text to be analyzed at the same time, which is faster. By performing sentiment analysis on each word in the text to be analyzed, the sentiment information corresponding to the text to be analyzed is made more accurate.
  • the technical solution of this embodiment obtains the text to be analyzed, and determines the first feature information to be used and the second feature information to be used corresponding to the text to be analyzed.
  • the context feature information and syntactic feature information corresponding to each word segment in the text to be analyzed can be determined.
  • the first embedding vector is determined based on the context feature embedding matrix
  • the second embedding vector is determined based on the syntactic feature embedding matrix.
  • the latent vector to be used corresponding to the text to be analyzed and at the same time, obtain the latent vector to be used corresponding to the text to be analyzed based on the BERT model, so as to determine the emotional information corresponding to the text to be analyzed according to the first embedding vector, the second embedding vector and the latent vector to be used.
  • the first weight of the first embedding vector and the second weight of the second embedding vector are automatically determined, so as to determine the emotional information corresponding to the text to be analyzed based on the first embedding vector, the second embedding vector and the latent vector to be used.
  • the model structure for analyzing the sentiment information of the text to be analyzed in the technical solution is shown in Figure 2, wherein the examples of context features and syntactic knowledge features on the right side of the model are given using "soup" as an example.
  • the text to be analyzed is usually a text containing at least two segmented words, but when performing sentiment analysis on the text to be analyzed, sentiment analysis is performed separately on each segmented word in the text to be analyzed. In other words, if the text to be analyzed contains 10 segmented words, the number of sentiment information finally obtained is 10, corresponding one-to-one to each segmented word.
  • the basic framework of sequence labeling is adopted, and each word segment in the text to be analyzed is assigned a label.
  • the label of the aspect word consists of two parts, the first part indicates the position of the aspect word among all aspect words, and the second part indicates the emotional polarity corresponding to the aspect word.
  • POS can be used to represent positive emotions
  • NEG can be used to represent negative emotions.
  • the text to be analyzed is "This mushroom seafood soup is great", where “mushroom” is at the beginning of the aspect word “mushroom seafood soup”, then the label of the first part is B, its emotional polarity is positive emotion, and the label of the second part is "POS"; similarly, “seafood” is at the beginning of “mushroom seafood soup”, then its first part label is I, its emotional polarity is positive emotion, and the label of the second part is "POS"; and "this” does not belong to any aspect word, so its label is "O”.
  • a standard encoding and decoding architecture is adopted, wherein the encoder adopts the BERT model and the decoder adopts the softmax decoder.
  • the text to be analyzed is analyzed based on the dual-channel attention mechanism.
  • this technical solution simultaneously analyzes the text to be analyzed through the context channel attention mechanism and the syntactic knowledge feature channel attention mechanism to obtain the sentiment information corresponding to the text to be analyzed.
  • dependency syntactic analysis tools to construct a dependency syntactic tree corresponding to the text to be analyzed Where xi represents the i-th word. For each word segment xi in the analyzed text, its context features are extracted, and its syntactic knowledge feature information is extracted through the dependency syntax tree.
  • the first r words and the last r words of the participle i.e., xir , ..., xi-1 , xi +1 , ..., xi +r
  • a total of 2r words constitute the context features of xi i.e., the first feature information to be used
  • Ci [ ci,1 , ...ci ,j ...ci ,2r ].
  • r can be selected as 1, but the value of r can be set according to the actual situation, and can also be set to other natural numbers.
  • syntactic knowledge features corresponding to each participle are extracted (i.e., the second feature information to be used). All participles that have a dependency syntactic relationship with xi , as well as the dependency syntactic relationship type between the participle and xi , can be selected, and the participle and the dependency syntactic relationship type can be concatenated to form syntactic knowledge feature information, denoted as Where mi represents the number of syntactic knowledge associated with xi .
  • the first feature information to be used c i,j is mapped into a context feature embedding vector
  • a vocabulary containing all context features i.e., context feature embedding matrix
  • each context feature is assigned a serial number (i.e., the first mapping information).
  • the vector corresponding to the row number of the context feature corresponding to the serial number is extracted from the context feature embedding matrix (the number of rows of the matrix is equal to the number of words in the vocabulary) as the embedding of the context feature (i.e., the first embedding vector).
  • the syntactic knowledge s i,k is mapped to the syntactic knowledge embedding vector
  • a vocabulary containing all syntactic knowledge features i.e., the syntactic feature embedding matrix
  • each syntactic knowledge feature is assigned a serial number (i.e., the second mapping information).
  • the vector corresponding to the row number of the syntactic feature embedding matrix corresponding to the serial number is extracted from the syntactic feature embedding matrix (the number of rows of the matrix is equal to the number of words in the vocabulary) as the embedding of the syntactic feature embedding matrix (i.e., the second embedding vector).
  • the BERT model it is also necessary to use the BERT model to encode the text to be analyzed and obtain the hidden vector corresponding to each word segment (that is, the word segment vector to be used). Input the standard BERT model, use the BERT standard encoding method to encode each word in the sentence, and output the corresponding latent vector. Among them, the latent vector of the i-th word x i is recorded as h i . It can be obtained using the following formula:
  • n represents the number of segmented words to be used
  • h n represents the segmented word vector to be used
  • h 1 ... hn represents the latent vector to be used
  • x represents the segmented word to be used in the text to be analyzed.
  • the first weight corresponding to the first embedding vector is determined based on the following formula:
  • in represents the first weight
  • exp represents the exponential function with the natural constant e as the base
  • e represents the first embedding vector
  • hi represents the word segmentation vector to be used
  • j represents the summed number
  • 2r represents the number of word segmentations associated with the word to be used.
  • a first vector to be spliced is obtained.
  • the first vector to be spliced can be obtained based on the following formula:
  • a second weight corresponding to the second embedding vector is determined based on the following formula:
  • in represents the second weight
  • exp represents the exponential function with the natural constant e as the base
  • e represents the second embedding vector
  • hi represents the word segmentation vector to be used
  • k represents the summed number
  • mi represents the number of word segmentations associated with the word to be used.
  • a second vector to be spliced is obtained.
  • the second vector to be spliced can be obtained based on the following formula:
  • the target vector can be obtained based on the first vector to be spliced and the second vector to be spliced.
  • the target vector can be determined by the following formula:
  • a i represents the target vector, represents the first vector to be concatenated, represents the second vector to be concatenated, It indicates that the first vector to be spliced and the second vector to be spliced are spliced.
  • the target vector corresponding to the text to be analyzed can be obtained by concatenating each target vector.
  • the target vector corresponding to the text to be analyzed is input into the fully connected layer for processing, and the processed vector is input into the pre-built decoder, such as the softmax decoder, to obtain the label corresponding to each word, so as to output the aspect word predicted by the model and the sentiment polarity of the aspect word according to the meaning of the label of each word.
  • the final output result includes the sentiment information corresponding to these 10 segmented words, and the sentiment information can be expressed as "positive” or "negative”.
  • This setting can analyze the sentiment information of each segmented word in the text to be analyzed, with finer granularity, which can better help the sentiment analysis of the text to be analyzed.
  • the technical solution of this embodiment obtains the text to be analyzed, and determines the first feature information to be used and the second feature information to be used corresponding to the text to be analyzed.
  • the context feature information and syntactic feature information corresponding to each word segment in the text to be analyzed can be determined.
  • Fig. 3 is a schematic diagram of the structure of a text sentiment analysis device provided in Embodiment 3 of the present application. As shown in Fig. 3, the device includes: a feature information determination module 210, an embedding vector determination module 220, a latent vector determination module 230 and a sentiment information determination module 240.
  • the feature information determination module 210 is configured to obtain the text to be analyzed, and determine the first feature information to be used and the second feature information to be used corresponding to the text to be analyzed, wherein the first feature information to be used is the context feature information, and the second feature information to be used is the syntactic feature information;
  • the embedding vector determination module 220 is configured to determine a first embedding vector corresponding to the first feature information to be used, and determine a second embedding vector corresponding to the second feature information to be used;
  • a latent vector determination module 230 configured to determine a latent vector to be used corresponding to the text to be analyzed
  • the sentiment information determination module 240 is configured to determine the sentiment information corresponding to the text to be analyzed based on the first embedding vector, the second embedding vector and the latent vector to be used.
  • the technical solution of this embodiment obtains the text to be analyzed, and determines the first feature information to be used and the second feature information to be used corresponding to the text to be analyzed.
  • the context feature information and syntactic feature information corresponding to each word segment in the text to be analyzed can be determined.
  • the first embedding vector corresponding to the first feature information to be used is determined, and the second embedding vector corresponding to the second feature information to be used is determined.
  • the first embedding vector is determined based on the context feature embedding matrix, and the second embedding vector is determined based on the syntactic feature embedding matrix.
  • the latent vector to be used corresponding to the text to be analyzed is determined.
  • the latent vector to be used corresponding to the text to be analyzed is obtained based on the BERT model, so as to determine the emotional information corresponding to the text to be analyzed according to the first embedding vector, the second embedding vector and the latent vector to be used.
  • the first weight of the first embedding vector and the second weight of the second embedding vector are automatically determined, so as to determine the emotional information corresponding to the text to be analyzed based on the first embedding vector, the second embedding vector and the latent vector to be used.
  • the feature information determination module 210 includes: a syntax tree determination unit, configured to determine a dependency syntax tree corresponding to the text to be analyzed; wherein the text to be analyzed includes at least two participles, and the dependency syntax tree is constructed based on context features and syntax features between the at least two participles;
  • a first feature information to be used determining unit is configured to obtain first feature information to be used corresponding to the text to be analyzed based on a context feature dependency relationship between at least two word segments in a dependency syntax tree;
  • the second feature information to be used determining unit is configured to obtain the second feature information to be used corresponding to the text to be analyzed based on the syntactic dependency relationship between at least two word segments in the dependency syntax tree.
  • the embedding vector determination module 220 includes: a first mapping information to be used determination unit, configured to perform mapping processing on the first feature information to be used based on a first embedding function to obtain first mapping information to be used;
  • the first embedding vector determining unit is configured to determine the first position information of the first mapping information to be used in the context feature embedding matrix, and determine the first embedding vector corresponding to the first mapping information to be used according to the matrix element corresponding to the first position information.
  • the embedding vector determination module 220 further includes: a second mapping information to be used determination unit, configured to perform mapping processing on the second feature information to be used based on a second embedding function to obtain second mapping information to be used;
  • the second embedding vector determination unit is configured to determine the second position information of the second mapping information to be used in the syntactic feature embedding matrix, and determine the second embedding vector corresponding to the second mapping information to be used according to the matrix element corresponding to the second position information.
  • the latent vector determination module 230 includes: a word segmentation component determination unit, which is configured to encode the text to be analyzed based on the language representation model to obtain a word segmentation vector to be used corresponding to each word in the text to be analyzed;
  • the latent vector determination unit is configured to concatenate multiple word segmentation vectors to be used to obtain a latent vector to be used corresponding to the text to be analyzed.
  • the emotion information determination module 240 includes: a first weight determination unit, configured to determine a first weight corresponding to the first embedding vector according to the first embedding vector and the latent vector to be used;
  • a second weight determination unit configured to determine a second weight corresponding to the second embedding vector according to the second embedding vector and the latent vector to be used;
  • the sentiment information determination unit is configured to determine the sentiment information corresponding to the text to be analyzed based on the first embedding vector, the first weight, the second embedding vector and the second weight.
  • the emotion information determination unit includes: a splicing vector determination subunit, configured to obtain a first vector to be spliced based on the first embedding vector and the first weight, and to obtain a second vector to be spliced based on the second embedding vector and the second weight;
  • a target vector determination subunit is configured to perform splicing processing on the first vector to be spliced and the second vector to be spliced to obtain a target vector;
  • the emotional information sub-determination unit is configured to input the target vector into a pre-built decoder to perform emotional analysis on the target vector based on the decoder to determine the emotional information corresponding to the text to be analyzed.
  • the text sentiment analysis device provided in the embodiments of the present application can execute the text sentiment analysis method provided in any embodiment of the present application, and has the corresponding functional modules and effects of the execution method.
  • Fig. 4 shows a schematic diagram of the structure of an electronic device 10 of an embodiment of the present application.
  • the electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workbenches, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers.
  • the electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices.
  • the components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present application described and/or required herein.
  • the electronic device 10 includes at least one processor 11, and a memory connected to the at least one processor 11, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., wherein the memory stores a computer program that can be executed by at least one processor, and the processor 11 can perform a variety of appropriate actions and processes according to the computer program stored in the ROM 12 or the computer program loaded from the storage unit 18 to the RAM 13.
  • the RAM 13 a variety of programs and data required for the operation of the electronic device 10 can also be stored.
  • the processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14.
  • the input/output (I/O) interface 15 is also connected to the bus 14.
  • a number of components in the electronic device 10 are connected to the I/O interface 15, including: an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a disk, an optical disk, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc.
  • the communication unit 19 allows the electronic device 10 to exchange information/data with other devices through a computer network such as the Internet and/or various telecommunication networks.
  • the processor 11 may be a variety of general and/or special processing components with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), a variety of dedicated artificial intelligence (AI) computing chips, a variety of processors running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc.
  • the processor 11 performs the multiple methods and processes described above, such as a text sentiment analysis method.
  • the text sentiment analysis method may be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 18.
  • a computer-readable storage medium such as a storage unit 18.
  • part or all of the computer program may be loaded and/or installed on the electronic device 10 via the ROM 12 and/or the communication unit 19.
  • the processor 11 may be configured to perform the text sentiment analysis method in any other appropriate manner (e.g., by means of firmware).
  • Various embodiments of the systems and techniques described above herein may be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard parts (ASSPs), system on chip systems (SOCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and/or combinations thereof.
  • FPGAs field programmable gate arrays
  • ASICs application specific integrated circuits
  • ASSPs application specific standard parts
  • SOCs system on chip systems
  • CPLDs complex programmable logic devices
  • These various embodiments may include: being implemented in one or more computer programs that are executable and/or interpreted on a programmable system including at least one programmable processor that may be a special purpose or general purpose programmable processor that may receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
  • a programmable processor that may be a special purpose or general purpose programmable processor that may receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
  • the computer program for implementing the text sentiment analysis method of the present application can be written in any combination of one or more programming languages. These computer programs can be provided to a processor of a general-purpose computer, a special-purpose computer or other programmable data processing device, so that when the computer program is executed by the processor, the functions/operations specified in the flowchart and/or block diagram are implemented.
  • the computer program can be executed entirely on the machine, partially on the machine, partially on the machine as a stand-alone software package and partially on a remote machine, or entirely on a remote machine or server.
  • a computer readable storage medium may be a tangible medium that may contain or store a computer program for use by or in conjunction with an instruction execution system, device, or apparatus.
  • a computer readable storage medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or device, or any suitable combination of the foregoing.
  • a computer readable storage medium may be a machine readable signal medium.
  • a machine readable storage medium includes an electrical connection based on one or more lines, a portable computer disk, a hard disk, a RAM, a ROM, an Erasable Programmable Read-Only Memory (EPROM), a flash memory, an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
  • the storage medium may be a non-transitory storage medium.
  • the systems and techniques described herein may be implemented on an electronic device having: a display device (e.g., a cathode ray tube (CRT) or a liquid crystal display (LCD) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device.
  • a display device e.g., a cathode ray tube (CRT) or a liquid crystal display (LCD) monitor
  • a keyboard and pointing device e.g., a mouse or trackball
  • Other types of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).
  • the systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components.
  • the components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: Local Area Network (LAN), Wide Area Network (WAN), blockchain network, and the Internet.
  • a computing system may include a client and a server.
  • the client and the server are generally remote from each other and usually interact through a communication network.
  • the client and server relationship is generated by computer programs running on the respective computers and having a client-server relationship with each other.
  • the server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and virtual private servers (VPS) services.
  • VPN virtual private servers

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Health & Medical Sciences (AREA)
  • Artificial Intelligence (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Computational Linguistics (AREA)
  • General Health & Medical Sciences (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Probability & Statistics with Applications (AREA)
  • Machine Translation (AREA)

Abstract

本申请提供了一种文本情感分析方法、装置、电子设备及存储介质,其中,该文本情感分析方法包括:获取待分析文本,并确定所述待分析文本所对应的第一待使用特征信息和第二待使用特征信息;确定与所述第一待使用特征信息所对应的第一嵌入向量,并确定与所述第二待使用特征信息相对应的第二嵌入向量;确定所述待分析文本所对应的待使用隐向量;根据所述第一嵌入向量、所述第二嵌入向量和所述待使用隐向量,确定所述待分析文本所对应的情感信息。

Description

文本情感分析方法、装置、电子设备及存储介质
本申请要求在2022年10月27日提交中国专利局、申请号为202211340090.X的中国专利申请的优先权,该申请的全部内容通过引用结合在本申请中。
技术领域
本申请涉及自然语言处理技术领域,例如涉及一种文本情感分析方法、装置、电子设备及存储介质。
背景技术
通过对文本信息进行情感分析,如,对用户评论文本信息进行情感分析,容易获取大众对一个事件或一个产品的看法。
对文本情感分析大多是采用先提取方面词,再预测情感极性的管道方法,其步骤复杂而且存在方面词提取错误导致的错误扩散现象。而少部分采用联合方法,但这种方法只能局限于使用高效的编码器,而没有考虑使用更高级的模型框架和利用额外的知识来帮助提升模型的性能。
发明内容
本申请提供了一种文本情感分析方法、装置、电子设备及存储介质,以解决对文本所对应的情感信息分析不够准确,且分析效率较低的问题。
本申请实施例提供了一种文本情感分析方法,包括:
获取待分析文本,并确定所述待分析文本所对应的第一待使用特征信息和第二待使用特征信息,其中,所述第一待使用特征信息为上下文特征信息,所述第二待使用特征信息为句法特征信息;
确定与所述第一待使用特征信息所对应的第一嵌入向量,并确定与所述第二待使用特征信息相对应的第二嵌入向量;
确定所述待分析文本所对应的待使用隐向量;
根据所述第一嵌入向量、所述第二嵌入向量和所述待使用隐向量,确定所述待分析文本所对应的情感信息。
本申请实施例还提供了一种文本情感分析装置,包括:
特征信息确定模块,设置为获取待分析文本,并确定所述待分析文本所对应的第一待使用特征信息和第二待使用特征信息,其中,所述第一待使用特征 信息为上下文特征信息,所述第二待使用特征信息为句法特征信息;
嵌入向量确定模块,设置为确定与所述第一待使用特征信息所对应的第一嵌入向量,并确定与所述第二待使用特征信息相对应的第二嵌入向量;
隐向量确定模块,设置为确定所述待分析文本所对应的待使用隐向量;
情感信息确定模块,设置为根据所述第一嵌入向量、所述第二嵌入向量和所述待使用隐向量,确定所述待分析文本所对应的情感信息。
本申请实施例还提供了一种电子设备,包括:
至少一个处理器;以及
与所述至少一个处理器通信连接的存储器;其中,
所述存储器存储有可被所述至少一个处理器执行的计算机程序,所述计算机程序被所述至少一个处理器执行,以使所述至少一个处理器能够执行本申请任一实施例所述的文本情感分析方法。
本申请实施例还提供了一种计算机可读存储介质,所述计算机可读存储介质存储有计算机指令,所述计算机指令用于使处理器执行时实现本申请任一实施例所述的文本情感分析方法。
附图说明
图1是根据本申请实施例一提供的一种文本情感分析方法的流程图;
图2是根据本申请实施例二提供的一种文本情感分析方法的模型示意图;
图3是根据本申请实施例三提供的一种文本情感分析装置的结构示意图;
图4是实现本申请实施例的文本情感分析方法的电子设备的结构示意图。
具体实施方式
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行描述,所描述的实施例仅仅是本申请一部分的实施例。
本申请的说明书和权利要求书及上述附图中的术语“第一”、“第二”等是用于区别类似的对象,而不必用于描述特定的顺序或先后次序。这样使用的数据在适当情况下可以互换,以便这里描述的本申请的实施例能够以除了在这里图示或描述的那些以外的顺序实施。
在对本技术方案进行阐述之前,先对本技术方案的应用场景进行简单介绍,以便理解本技术方案。对于文本内容进行情感分析在多用场景下都非常 实用,如,通过影评信息确定用户对电影的喜爱程度、或者通过用户评论信息了解用户对餐厅菜品或者服务的评价、或者是通过用户反馈信息了解用户对于电子产品的评价等,以基于用户的反馈信息以及相应的情感信息,更加了解用户需求以对相关产品进行改进。
实施例一
图1为本申请实施例一提供的一种文本情感分析方法的流程图,本实施例可适用于快速准确的对文本进行情感倾向的分析的情况,该方法可以由文本情感分析装置来执行,该文本情感分析装置可以采用硬件和/或软件的形式实现,该文本情感分析装置可配置于可执行文本情感分析方法的计算设备中。
如图1所示,该方法包括以下步骤。
S110、获取待分析文本,并确定待分析文本所对应的第一待使用特征信息和第二待使用特征信息。
待分析文本可以理解为需要进行情感分析的文本信息,如,可以为评论区的用户评论信息、影评信息、书评信息以及任何具有情感倾向的文本信息。在本技术方案中,可以通过双通道注意力机制对待分析文本进行情感分析,所谓双通道注意力机制包括基于上下文特征对待分析文本进行情感分析的注意力机制,以及基于句法知识对待分析文本进行情感分析的注意力机制。第一待使用特征信息可以理解为基于上下文特征注意力机制,得到的与待分析文本相对应的上下文特征信息。第二待使用特征信息可以理解为基于句法知识注意力机制对待分析文本进行分析,得到的句法特征信息。
在对待分析文本进行情感分析时,可以同时对待分析文本的上下文特征信息以及句法知识特征信息进行分析,以得到待分析文本相对应的第一待使用特征信息和第二待使用特征信息。
可选的,确定待分析文本所对应的第一待使用特征信息和第二待使用特征信息,包括:确定与待分析文本相对应的依存句法树;基于依存句法树中,至少两个分词之间的上下文特征依赖关系,得到与待分析文本相对应的第一待使用特征信息;基于依存句法树中,至少两个分词之间的句法依赖关系,得到与待分析文本相对应的第二待使用特征信息。
在本技术方案中,待分析文本中包括至少两个分词,依存句法树可以理解为包含待分析文本的上下文特征信息和句法特征信息的关系图,也就是说,依存句法树为基于至少两个分词之间的上下文特征和句法特征进行构建的。
构建与待分析文本相对应的依存句法树,以根据依存句法树中的上下文特征依赖关系,以及句法依赖关系,分别得到与待分析文本相对应的第一待使用 特征信息和第二待使用特征信息。
示例性地,待分析文本为“这个蘑菇海鲜汤很棒”,以其中的“汤”字为例,可以选取“汤”字前面的r个词,以及后面的r个词,如当r=1时,与“汤”相对应的第一待使用特征信息为“海鲜”和“很”,为待分析文本的第一待使用特征信息。同时,在这个待分析文本中,根据句法知识特征可以确定,相对于“汤”字,“这个”为限定词,“蘑菇”和“海鲜”为描述性词语,“棒”为修饰词,而“很”字用于表征“棒”的程度,与“汤”字无直接关联。根据待分析文本中每个分词与“汤”字之间的句法知识,可以得到与待分析文本相对应的第二待使用特征信息,即,第二待使用特征信息为用于表征待分析文本的句法知识的信息。
S120、确定与第一待使用特征信息所对应的第一嵌入向量,并确定与第二待使用特征信息相对应的第二嵌入向量。
第一嵌入向量为对第一待使用特征信息进行向量化处理后得到的向量。第二嵌入向量为对第二待使用特征信息进行向量化处理后得到的向量。
在本技术方案中,确定与第一待使用特征信息所对应的第一嵌入向量,包括:基于第一嵌入函数,将第一待使用特征信息进行映射处理,得到第一待使用映射信息;确定第一待使用映射信息,在上下文特征嵌入矩阵中的第一位置信息,并根据第一位置信息所对应的矩阵元素,确定第一待使用映射信息所对应的第一嵌入向量。
第一嵌入函数可以理解为将第一待使用特征信息进行映射处理,得到相应的第一待使用映射信息的函数。通过对第一待使用映射信息进行向量化处理,则可以得到第一嵌入向量。上下文特征嵌入矩阵可以理解为预先构建的包含大量分词的信息矩阵。
示例性地,上下文特征嵌入矩阵中包含2万个分词,多个分词分别位于矩阵的不同行,每个矩阵行对应唯一的向量值。基于第一嵌入函数,对待分析文本中的多个分词分别进行分词,以当前分词为例,其中,当前分词可以作为第一待使用特征信息,根据当前分词在上下文嵌入矩阵中所对应的矩阵行,即第一位置信息,可以得到与当前分词相对应的唯一向量值,即与第一位置相对应的矩阵元素,并将该矩阵元素确定为第一嵌入向量。
可选的,确定与第二待使用特征信息相对应的第二嵌入向量,包括:基于第二嵌入函数,将第二待使用特征信息进行映射处理,得到第二待使用映射信息;确定第二待使用映射信息,在句法特征嵌入矩阵中的第二位置信息,并根据第二位置信息所对应的矩阵元素,确定第二待使用映射信息所对应的第二嵌 入向量。
第二嵌入函数可以理解为将第二待使用特征信息进行映射处理,得到相应的第二待使用映射信息的函数。通过对第二待使用映射信息进行向量化处理,则可以得到第二嵌入向量。句法特征嵌入矩阵可以理解为预先构建的包含大量句法知识的信息矩阵,如,可以包括名词短语、主语、修饰语以及程度副词的句法关系等。
示例性地,句法特征嵌入矩阵中包含500个句法知识,多个分词分别位于矩阵的不同行,每个矩阵行对应唯一的向量值。基于第二嵌入函数,对待分析文本中的多个分词分别进行分词,以当前分词为例,其中,当前分词可以作为第二待使用特征信息,根据当前分词在句法嵌入矩阵中所对应的矩阵行,即第二位置信息,可以得到与当前分词相对应的唯一向量值,即与第二位置相对应的矩阵元素,并将该矩阵元素确定为第二嵌入向量。
S130、确定待分析文本所对应的待使用隐向量。
在本技术方案中,待使用隐向量为基于语言表征模型基于变换器的双向编码器表示(Bidirectional Encoder Representations from Transformer,BERT)对待分析文本进行向量化处理后,得到的向量。
在实际应用中,确定待分析文本所对应的待使用隐向量,包括:基于语言表征模型,对待分析文本进行编码,得到与待分析文本中每个分词相对应的待使用分词向量;将多个待使用分词向量进行拼接处理,得到与待分析文本相对应的待使用隐向量。
待使用分词可以理解为待分析文本中的多个分词。待使用分词向量即为与每个分词相对应的隐向量。待使用隐向量为基于多个待使用分词向量进行拼接处理后,得到的隐向量。
将待分析文本输入BERT模型中,并基于BERT模型对待分析文本中的每个待使用分词进行编码,可以得到与每个待使用分词相对应的待使用分词向量,示例性地,将
Figure PCTCN2022134576-appb-000001
输入该模型中,采用BERT模型的标准编码方式对矩阵中每个待使用分词进行编码,输出每个分词所对应的上下文向量表征,即为与每个分词相对应的待使用分词向量。其中,将第i个分词x i的待使用分词向量记为h i,则待分析文本
Figure PCTCN2022134576-appb-000002
所对应的待使用隐向量即可以表示为:
h 1…h n=BERT(x 1x 2…x n)
其中,n表示待使用分词的数量,h 1…h n表示待使用隐向量,x表示待分析文本中的待使用分词。
S140、根据第一嵌入向量、第二嵌入向量和待使用隐向量,确定待分析文本所对应的情感信息。
在本技术方案中,经过上述内容对待分析文本进行处理后,在第一嵌入向量中包括与待分析文本相对应的上下文特征信息,在第二嵌入向量中包括与待分析文本相对应的句法特征信息,同时,在待使用隐向量中包含与待分析文本相对应的情感特征信息。基于此,根据第一嵌入向量、第二嵌入向量和待使用隐向量,可以确定待分析文本所对应的情感信息。
可选的,根据第一嵌入向量、第二嵌入向量和待使用隐向量,确定待分析文本所对应的情感信息,包括:根据第一嵌入向量和待使用隐向量,确定第一嵌入向量所对应的第一权重;根据第二嵌入向量和待使用隐向量,确定第二嵌入向量所对应的第二权重;根据第一嵌入向量、第一权重、第二嵌入向量和第二权重,确定待分析文本所对应的情感信息。
在本技术方案中,可以通过分析上下文特征和语法特征在情感分析中的影响程度,以确定与第一嵌入向量相对应的第一权重,以及与第二嵌入向量相对应的第二权重。
可以通过以下公式确定第一权重:
Figure PCTCN2022134576-appb-000003
其中,
Figure PCTCN2022134576-appb-000004
表示第一权重,exp表示以自然常数e为底的指数函数,
Figure PCTCN2022134576-appb-000005
表示第一嵌入向量,h i表示待使用分词向量,j表示加和个数,2r表示与待使用分词相关联的分词数量。
可以通过以下公式确定第二权重:
Figure PCTCN2022134576-appb-000006
其中,
Figure PCTCN2022134576-appb-000007
表示第二权重,exp表示以自然常数e为底的指数函数,
Figure PCTCN2022134576-appb-000008
表示 第二嵌入向量,h i表示待使用分词向量,k表示加和个数,m i表示与待使用分词相关联的分词数量。
在本技术方案中,第一嵌入向量可以是针对待分析文本中的每个待使用分词所对应的向量,相应的,第二嵌入向量为针对待分析文本中的每个待使用分词所对应的向量。而与待分析文本相对应的上下文特征向量为基于多个第一嵌入向量拼接得到的,与待分析文本相对应的语法特征向量为基于多个第二嵌入向量得到的。也就是说,在本技术方案中是通过对每个待使用分词分别进行处理后,可以得到与每个待使用分词相对应的情感信息。
根据第一嵌入向量、第一权重、第二嵌入向量和第二权重,确定待分析文本所对应的情感信息,包括:基于第一嵌入向量和第一权重,得到第一待拼接向量,并基于第二嵌入向量和第二权重,得到第二待拼接向量;将第一待拼接向量和第二待拼接向量进行拼接处理,得到目标向量;将目标向量输入预先构建的解码器,以基于解码器对目标向量进行情感分析,以确定待分析文本所对应的情感信息。
第一待拼接向量可以理解为基于第一嵌入向量和第一权重相乘得到的向量,第二待拼接向量可以理解为基于第二嵌入向量和第二权重相乘得到的向量。目标向量可以理解为对第一待拼接向量和第二待拼接向量拼接得到的向量。例如,将待分析文本中的分词1所对应的第一待拼接向量和第二待拼接向量进行拼接,得到与分词1相对应的目标向量。
第一待拼接向量可以基于以下公式得到:
Figure PCTCN2022134576-appb-000009
其中,
Figure PCTCN2022134576-appb-000010
表示第一待拼接向量,
Figure PCTCN2022134576-appb-000011
表示第一权重,
Figure PCTCN2022134576-appb-000012
表示第一嵌入向量,j表示加和个数,2r表示与待使用分词相关联的分词数量,·表示两个向量的内积。
第二拼接向量可以基于以下公式得到:
Figure PCTCN2022134576-appb-000013
其中,
Figure PCTCN2022134576-appb-000014
表示第二待拼接向量,
Figure PCTCN2022134576-appb-000015
表示第二权重,
Figure PCTCN2022134576-appb-000016
表示第二嵌入向量,k表示加和个数,m i表示与待使用分词相关联的分词数量,·表示两个向量的内积。
基于以下公式可以得到目标向量:
Figure PCTCN2022134576-appb-000017
其中,a i表示目标向量,
Figure PCTCN2022134576-appb-000018
表示第一待拼接向量,
Figure PCTCN2022134576-appb-000019
表示第二待拼接向量,
Figure PCTCN2022134576-appb-000020
表示将第一待拼接向量和第二待拼接向量进行拼接处理。
在确定待分析文本中的每个分词相对应的目标向量后,基于每个目标向量进行拼接处理,可以得到与待分析文本相对应的目标向量。将与待分析文本相对应的目标向量输入全连接层进行处理,以将处理后的向量输入预先构建的解码器中,如,送入softmax解码器,即可得到与每个分词相对应的标签,以根据每个分词的标签的含义,输出模型预测的方面词以及方面词的情感极性。
也就是说,若在待分析文本中包含10个分词,在最后的输出结果中,即包括与这个10个分词相对应的情感信息,情感信息可以用“积极”或“消极”进行表示。这样设置,可以对待分析文本中的每个分词分别进行情感信息的分析,颗粒度更细,可以更好的帮助对待分析文本的情感分析。
本技术方案,通过双通道注意力机制对待分析文本进行分析,可以同时对待分析文本的上下文特征和句法特征进行分析,更加快速,且通过对待分析文本中的每个分词进行情感分析,使得到的待分析文本所对应的情感信息更加准确。
本实施例的技术方案,获取待分析文本,并确定待分析文本所对应的第一待使用特征信息和第二待使用特征信息,通过构建与待分析文本相对应的依存句法树,可以确定待分析文本中每个分词所对应的上下文特征信息和句法特征信息。确定与第一待使用特征信息所对应的第一嵌入向量,并确定与第二待使用特征信息相对应的第二嵌入向量,基于上下文特征嵌入矩阵确定第一嵌入向量,基于句法特征嵌入矩阵确定第二嵌入向量。确定待分析文本所对应的待使用隐向量,同时,基于BERT模型得到与待分析文本相对应的待使用隐向量,以根据第一嵌入向量、第二嵌入向量和待使用隐向量,确定待分析文本所对应 的情感信息。根据上下文特征和句法特征随待分析文本情感信息的影响程度,自动确定第一嵌入向量的第一权重,第二嵌入向量的第二权重,以基于第一嵌入向量、第二嵌入向量和待使用隐向量,确定待分析文本所对应的情感信息。解决了对文本所对应的情感信息分析不够准确,且分析效率较低的问题,达到了快速准确的对文本进行情感信息的分析的效果。
实施例二
在一个例子中,本技术方案中对待分析文本进行情感信息的分析的模型结构如图2所示,其中,模型中的右侧的上下文特征与句法知识特征的例子均以“汤”为例给出。在本技术方案中,待分析文本通常为包含至少两个分词的文本,但是在对待分析文本进行情感分析时,是通过对待分析文本中的每个分词分别进行情感分析。也就是说,若在待分析文本中包含10个分词,则最终得到的情感信息的数量为10个,与每个分词一一对应。
在图2的模型中,采用了序列标注的基本框架,待分析文本中的每个分词被赋予一个标签。其中,方面词的标签由两部分组成,第一部分表示该方面词在所有方面词中的位置,第二部分表示该方面词所对应的情感极性,可以用“POS”表示积极情感,用“NEG”表示消极情感。示例性地,待分析文本为“这个蘑菇海鲜汤很棒”,其中,“蘑菇”在方面词“蘑菇海鲜汤”中位于开始,则其第一部分的标签为B,其情感极性为积极情感,则第二部分标签为“POS”;相类似的,“海鲜”在“蘑菇海鲜汤”中位于开始,则其第一部分标签为I,其情感极性为积极情感,则第二部分标签为“POS”;而“这个”并不属于任何方面词,则其标签为“O”。
另外,在本技术方案中,采用了标准的编码解码架构,其中,编码器采用BERT模型,解码器采用softmax解码器。在本技术方案中,基于双通道注意力机制对待分析文本进行分析,在一实施例中,本技术方案通过上下文通道注意力机制和句法知识特征通道注意力机制,同时对待分析文本进行分析,以得到与待分析文本相对应的情感信息。
采用依存句法分析工具构建与待分析文本相对应的依存句法树得到
Figure PCTCN2022134576-appb-000021
其中,x i表示第i个词。对待分析文本中的每个分词x i,提取其上下文特征,并通过依存句法树提取其句法知识特征信息。
示例性地,在提取每个分词的上下文特征时,可以选取该分词前r个词以及后r个词(即,x i-r,…,x i-1,x i+1,…,x i+r),共计2r个词组成x i的 上下文特征(即,第一待使用特征信息),记为C i=[c i,1,…c i,j…c i,2r]。其中,在本技术方案中,r可以选取为1,但r的取值可以根据实际情况进行设置,也可以设置为其他自然数。同时,提取每个分词所对应的句法知识特征(即,第二待使用特征信息)。可以选取所有与x i存在依存句法关系的分词,以及该分词与x i之间的依存句法关系类型,并把该分词与依存句法关系类型拼接,形成句法知识特征信息,记为
Figure PCTCN2022134576-appb-000022
其中m i表示与x i关联的句法知识的个数。
以x i=“汤”为例,与“汤”有关的词有“这个”、“蘑菇”、“海鲜”、“棒”,他们与“汤”之间的依存句法关系类型依次为“det”,“compound”,“compound”,“nsubj”,所以最后得到的句法知识为S 4=[这个-det,蘑菇-compound,海鲜-compound,棒-nsubj]。其中,det表示限定词,compound表示复合标识符,nsubj表示名词主语。
通过第一嵌入函数,将第一待使用特征信息c i,j映射为上下文特征嵌入向量
Figure PCTCN2022134576-appb-000023
可以预先构建一个包含所有上下文特征的词表(即,上下文特征嵌入矩阵),并赋予每个上下文特征一个序号(即,第一映射信息),接下来,从上下文特征嵌入矩阵(该矩阵的行数等于词表中词的个数)中,提取上下文特征对应序号的行数所对应的向量,作为上下文特征的嵌入(即,第一嵌入向量)。
通过第二嵌入函数,将句法知识s i,k映射为句法知识嵌入向量
Figure PCTCN2022134576-appb-000024
可以预先构建一个包含所有句法知识特征的词表(即,句法特征嵌入矩阵),并赋予每个句法知识特征一个序号(即,第二映射信息),接下来,从句法特征嵌入矩阵(该矩阵的行数等于词表中词的个数)中,提取句法特征嵌入矩 阵对应序号的行数所对应的向量,作为句法特征嵌入矩阵的嵌入(即,第二嵌入向量)。
还需要使用BERT模型对待分析文本进行编码,得到每个分词所对应的隐向量(即,待使用分词向量)。即,把句子
Figure PCTCN2022134576-appb-000025
输入标准的BERT模型,采用BERT标准的编码方式,对句子中的每个词进行编码,输出相应的隐向量。其中,第i个词x i的隐向量记为h i。可以采用以下公式得到:
h 1…h n=BERT(x 1x 2…x n)
其中,n表示待使用分词的数量,h n表示待使用分词向量,h 1…h n表示待使用隐向量,x表示待分析文本中的待使用分词。
基于以下公式确定与第一嵌入向量相对应的第一权重:
Figure PCTCN2022134576-appb-000026
其中,
Figure PCTCN2022134576-appb-000027
表示第一权重,exp表示以自然常数e为底的指数函数,
Figure PCTCN2022134576-appb-000028
表示第一嵌入向量,h i表示待使用分词向量,j表示加和个数,2r表示与待使用分词相关联的分词数量。
基于第一嵌入向量和第一权重,得到第一待拼接向量。其中,第一待拼接向量可以基于以下公式得到:
Figure PCTCN2022134576-appb-000029
其中,
Figure PCTCN2022134576-appb-000030
表示第一待拼接向量,
Figure PCTCN2022134576-appb-000031
表示第一权重,
Figure PCTCN2022134576-appb-000032
表示第一嵌入向量,j表示加和个数,2r表示与待使用分词相关联的分词数量,·表示两个向量的内积。
相类似地,基于以下公式确定与第二嵌入向量相对应的第二权重:
Figure PCTCN2022134576-appb-000033
其中,
Figure PCTCN2022134576-appb-000034
表示第二权重,exp表示以自然常数e为底的指数函数,
Figure PCTCN2022134576-appb-000035
表示第二嵌入向量,h i表示待使用分词向量,k表示加和个数,m i表示与待使用分词相关联的分词数量。
基于第二嵌入向量和第二权重,得到第二待拼接向量。其中,第二待拼接向量可以基于以下公式得到:
Figure PCTCN2022134576-appb-000036
其中,
Figure PCTCN2022134576-appb-000037
表示第二待拼接向量,
Figure PCTCN2022134576-appb-000038
表示第二权重,
Figure PCTCN2022134576-appb-000039
表示第二嵌入向量,k表示加和个数,m i表示与待使用分词相关联的分词数量,·表示两个向量的内积。
基于第一待拼接向量和第二待拼接向量可以得到目标向量,目标向量可以通过以下公式确定:
Figure PCTCN2022134576-appb-000040
其中,a i表示目标向量,
Figure PCTCN2022134576-appb-000041
表示第一待拼接向量,
Figure PCTCN2022134576-appb-000042
表示第二待拼接向量,
Figure PCTCN2022134576-appb-000043
表示将第一待拼接向量和第二待拼接向量进行拼接处理。
在确定待分析文本中的每个分词相对应的目标向量后,基于每个目标向量进行拼接处理,可以得到与待分析文本相对应的目标向量。将与待分析文本相对应的目标向量输入全连接层进行处理,以将处理后的向量输入预先构建的解码器中,如,送入softmax解码器,即可得到与每个分词相对应的标签,以根据每个分词的标签的含义,输出模型预测的方面词以及该方面词的情感极性。
也就是说,若在待分析文本中包含10个分词,在最后的输出结果中,即包括与这个10个分词相对应的情感信息,情感信息可以用“积极”或“消极”进行表示。这样设置,可以对待分析文本中的每个分词分别进行情感信息的分析,颗粒度更细,可以更好的帮助对待分析文本的情感分析。
本实施例的技术方案,获取待分析文本,并确定待分析文本所对应的第一待使用特征信息和第二待使用特征信息,通过构建与待分析文本相对应的依存句法树,可以确定待分析文本中每个分词所对应的上下文特征信息和句法特征信息。确定与第一待使用特征信息所对应的第一嵌入向量,并确定与第二待使用特征信息相对应的第二嵌入向量,分别基于上下文特征嵌入矩阵确定第一嵌入向量,基于句法特征嵌入矩阵确定第二嵌入向量。确定待分析文本所对应的待使用隐向量,同时,基于BERT模型得到与待分析文本相对应的待使用隐向量,以根据第一嵌入向量、第二嵌入向量和待使用隐向量,确定待分析文本所对应的情感信息。根据上下文特征和句法特征随待分析文本情感信息的影响程度,自动确定第一嵌入向量的第一权重,第二嵌入向量的第二权重,以基于第一嵌入向量、第二嵌入向量和待使用隐向量,确定待分析文本所对应的情感信息。解决了对文本所对应的情感信息分析不够准确,且分析效率较低的问题,达到了快速准确的对文本进行情感信息的分析的效果。
实施例三
图3为本申请实施例三提供的一种文本情感分析装置的结构示意图。如图3所示,该装置包括:特征信息确定模块210、嵌入向量确定模块220、隐向量确定模块230和情感信息确定模块240。
特征信息确定模块210,设置为获取待分析文本,并确定待分析文本所对应的第一待使用特征信息和第二待使用特征信息,其中,第一待使用特征信息为上下文特征信息,第二待使用特征信息为句法特征信息;
嵌入向量确定模块220,设置为确定与第一待使用特征信息所对应的第一嵌入向量,并确定与第二待使用特征信息相对应的第二嵌入向量;
隐向量确定模块230,设置为确定待分析文本所对应的待使用隐向量;
情感信息确定模块240,设置为根据第一嵌入向量、第二嵌入向量和待使用隐向量,确定待分析文本所对应的情感信息。
本实施例的技术方案,获取待分析文本,并确定待分析文本所对应的第一待使用特征信息和第二待使用特征信息,通过构建与待分析文本相对应的依存句法树,可以确定待分析文本中每个分词所对应的上下文特征信息和句法特征 信息。确定与第一待使用特征信息所对应的第一嵌入向量,并确定与第二待使用特征信息相对应的第二嵌入向量,分别基于上下文特征嵌入矩阵确定第一嵌入向量,基于句法特征嵌入矩阵确定第二嵌入向量。确定待分析文本所对应的待使用隐向量,同时,基于BERT模型得到与待分析文本相对应的待使用隐向量,以根据第一嵌入向量、第二嵌入向量和待使用隐向量,确定待分析文本所对应的情感信息。根据上下文特征和句法特征随待分析文本情感信息的影响程度,自动确定第一嵌入向量的第一权重,第二嵌入向量的第二权重,以基于第一嵌入向量、第二嵌入向量和待使用隐向量,确定待分析文本所对应的情感信息。解决了对文本所对应的情感信息分析不够准确,且分析效率较低的问题,达到了快速准确的对文本进行情感信息的分析的效果。
可选的,特征信息确定模块210,包括:句法树确定单元,设置为确定与待分析文本相对应的依存句法树;其中,待分析文本中包括至少两个分词,依存句法树为基于至少两个分词之间的上下文特征和句法特征进行构建的;
第一待使用特征信息确定单元,设置为基于依存句法树中,至少两个分词之间的上下文特征依赖关系,得到与待分析文本相对应的第一待使用特征信息;
第二待使用特征信息确定单元,设置为基于依存句法树中,至少两个分词之间的句法依赖关系,得到与待分析文本相对应的第二待使用特征信息。
可选的,嵌入向量确定模块220,包括:第一待使用映射信息确定单元,设置为基于第一嵌入函数,将第一待使用特征信息进行映射处理,得到第一待使用映射信息;
第一嵌入向量确定单元,设置为确定第一待使用映射信息,在上下文特征嵌入矩阵中的第一位置信息,并根据第一位置信息所对应的矩阵元素,确定第一待使用映射信息所对应的第一嵌入向量。
可选的,嵌入向量确定模块220,还包括:第二待使用映射信息确定单元,设置为基于第二嵌入函数,将第二待使用特征信息进行映射处理,得到第二待使用映射信息;
第二嵌入向量确定单元,设置为确定第二待使用映射信息,在句法特征嵌入矩阵中的第二位置信息,并根据第二位置信息所对应的矩阵元素,确定第二待使用映射信息所对应的第二嵌入向量。
可选的,隐向量确定模块230包括:分词分量确定单元,设置为基于语言表征模型,对待分析文本进行编码,得到与待分析文本中每个分词相对应的待使用分词向量;
隐向量确定单元,设置为将多个待使用分词向量进行拼接处理,得到与待 分析文本相对应的待使用隐向量。
可选的,情感信息确定模块240,包括:第一权重确定单元,设置为根据第一嵌入向量和待使用隐向量,确定第一嵌入向量所对应的第一权重;
第二权重确定单元,设置为根据第二嵌入向量和待使用隐向量,确定第二嵌入向量所对应的第二权重;
情感信息确定单元,设置为根据第一嵌入向量、第一权重、第二嵌入向量和第二权重,确定待分析文本所对应的情感信息。
可选的,情感信息确定单元,包括:拼接向量确定子单元,设置为基于第一嵌入向量和第一权重,得到第一待拼接向量,并基于第二嵌入向量和第二权重,得到第二待拼接向量;
目标向量确定子单元,设置为将第一待拼接向量和第二待拼接向量进行拼接处理,得到目标向量;
情感信息子确定单元,设置为将目标向量输入预先构建的解码器,以基于解码器对目标向量进行情感分析,以确定待分析文本所对应的情感信息。
本申请实施例所提供的文本情感分析装置可执行本申请任意实施例所提供的文本情感分析方法,具备执行方法相应的功能模块和效果。
实施例四
图4示出了本申请的实施例的电子设备10的结构示意图。电子设备旨在表示多种形式的数字计算机,诸如,膝上型计算机、台式计算机、工作台、个人数字助理、服务器、刀片式服务器、大型计算机、和其它适合的计算机。电子设备还可以表示多种形式的移动装置,诸如,个人数字处理、蜂窝电话、智能电话、可穿戴设备(如头盔、眼镜、手表等)和其它类似的计算装置。本文所示的部件、它们的连接和关系、以及它们的功能仅仅作为示例,并且不意在限制本文中描述的和/或者要求的本申请的实现。
如图4所示,电子设备10包括至少一个处理器11,以及与至少一个处理器11通信连接的存储器,如只读存储器(Read-Only Memory,ROM)12、随机访问存储器(Random Access Memory,RAM)13等,其中,存储器存储有可被至少一个处理器执行的计算机程序,处理器11可以根据存储在ROM12中的计算机程序或者从存储单元18加载到RAM13中的计算机程序,来执行多种适当的动作和处理。在RAM 13中,还可存储电子设备10操作所需的多种程序和数据。处理器11、ROM 12以及RAM 13通过总线14彼 此相连。输入/输出(Input/Output,I/O)接口15也连接至总线14。
电子设备10中的多个部件连接至I/O接口15,包括:输入单元16,例如键盘、鼠标等;输出单元17,例如多种类型的显示器、扬声器等;存储单元18,例如磁盘、光盘等;以及通信单元19,例如网卡、调制解调器、无线通信收发机等。通信单元19允许电子设备10通过诸如因特网的计算机网络和/或多种电信网络与其他设备交换信息/数据。
处理器11可以是多种具有处理和计算能力的通用和/或专用处理组件。处理器11的一些示例包括但不限于中央处理单元(Central Processing Unit,CPU)、图形处理单元(Graphics Processing Unit,GPU)、多种专用的人工智能(Artificial Intelligence,AI)计算芯片、多种运行机器学习模型算法的处理器、数字信号处理器(Digital Signal Processor,DSP)、以及任何适当的处理器、控制器、微控制器等。处理器11执行上文所描述的多个方法和处理,例如文本情感分析方法。
在一些实施例中,文本情感分析方法可被实现为计算机程序,其被有形地包含于计算机可读存储介质,例如存储单元18。在一些实施例中,计算机程序的部分或者全部可以经由ROM 12和/或通信单元19而被载入和/或安装到电子设备10上。当计算机程序加载到RAM 13并由处理器11执行时,可以执行上文描述的文本情感分析方法的一个或多个步骤。备选地,在其他实施例中,处理器11可以通过其他任何适当的方式(例如,借助于固件)而被配置为执行文本情感分析方法。
本文中以上描述的系统和技术的多种实施方式可以在数字电子电路系统、集成电路系统、场可编程门阵列(Field Programmable Gate Array,FPGA)、专用集成电路(Application Specific Integrated Circuit,ASIC)、专用标准产品(Application Specific Standard Parts,ASSP)、芯片上系统的系统(System on Chip,SOC)、复杂可编程逻辑设备(Complex Programmable Logic Device,CPLD)、计算机硬件、固件、软件、和/或它们的组合中实现。这些多种实施方式可以包括:实施在一个或者多个计算机程序中,该一个或者多个计算机程序可在包括至少一个可编程处理器的可编程系统上执行和/或解释,该可编程处理器可以是专用或者通用可编程处理器,可以从存储系统、至少一个输入装置、和至少一个输出装置接收数据和指令,并且将数据和指令传输至该存储系统、该至少一个输入装置、和该至少一个输出装置。
用于实施本申请的文本情感分析方法的计算机程序可以采用一个或多个编程语言的任何组合来编写。这些计算机程序可以提供给通用计算机、专用计算机或其他可编程数据处理装置的处理器,使得计算机程序当由处理器执 行时使流程图和/或框图中所规定的功能/操作被实施。计算机程序可以完全在机器上执行、部分地在机器上执行,作为独立软件包部分地在机器上执行且部分地在远程机器上执行或完全在远程机器或服务器上执行。
在本申请的上下文中,计算机可读存储介质可以是有形的介质,其可以包含或存储以供指令执行系统、装置或设备使用或与指令执行系统、装置或设备结合地使用的计算机程序。计算机可读存储介质可以包括但不限于电子的、磁性的、光学的、电磁的、红外的、或半导体系统、装置或设备,或者上述内容的任何合适组合。备选地,计算机可读存储介质可以是机器可读信号介质。机器可读存储介质包括基于一个或多个线的电气连接、便携式计算机盘、硬盘、RAM、ROM、可擦除可编程只读存储器(Erasable Programmable Read-Only Memory,EPROM)、快闪存储器、光纤、便捷式紧凑盘只读存储器(Compact Disc Read Only Memory,CD-ROM)、光学储存设备、磁储存设备、或上述内容的任何合适组合。存储介质可以是非暂态(non-transitory)存储介质。
为了提供与用户的交互,可以在电子设备上实施此处描述的系统和技术,该电子设备具有:用于向用户显示信息的显示装置(例如,阴极射线管(Cathode Ray Tube,CRT)或者液晶显示器(Liquid Crystal Display,LCD)监视器);以及键盘和指向装置(例如,鼠标或者轨迹球),用户可以通过该键盘和该指向装置来将输入提供给电子设备。其它种类的装置还可以用于提供与用户的交互;例如,提供给用户的反馈可以是任何形式的传感反馈(例如,视觉反馈、听觉反馈、或者触觉反馈);并且可以用任何形式(包括声输入、语音输入或者、触觉输入)来接收来自用户的输入。
可以将此处描述的系统和技术实施在包括后台部件的计算系统(例如,作为数据服务器)、或者包括中间件部件的计算系统(例如,应用服务器)、或者包括前端部件的计算系统(例如,具有图形用户界面或者网络浏览器的用户计算机,用户可以通过该图形用户界面或者该网络浏览器来与此处描述的系统和技术的实施方式交互)、或者包括这种后台部件、中间件部件、或者前端部件的任何组合的计算系统中。可以通过任何形式或者介质的数字数据通信(例如,通信网络)来将系统的部件相互连接。通信网络的示例包括:局域网(Local Area Network,LAN)、广域网(Wide Area Network,WAN)、区块链网络和互联网。
计算系统可以包括客户端和服务器。客户端和服务器一般远离彼此并且通常通过通信网络进行交互。通过在相应的计算机上运行并且彼此具有客户端-服务器关系的计算机程序来产生客户端和服务器的关系。服务器可以是云 服务器,又称为云计算服务器或云主机,是云计算服务体系中的一项主机产品,以解决了传统物理主机与虚拟专用服务器(Virtual Private Server,VPS)服务中,存在的管理难度大,业务扩展性弱的缺陷。
可以使用上面所示的多种形式的流程,重新排序、增加或删除步骤。例如,本申请中记载的多个步骤可以并行地执行也可以顺序地执行也可以不同的次序执行,只要能够实现本申请的技术方案所期望的结果,本文在此不进行限制。
上述实施方式,并不构成对本申请保护范围的限制。根据设计要求和其他因素,可以进行多种修改、组合、子组合和替代。

Claims (10)

  1. 一种文本情感分析方法,包括:
    获取待分析文本,并确定所述待分析文本所对应的第一待使用特征信息和第二待使用特征信息,其中,所述第一待使用特征信息为上下文特征信息,所述第二待使用特征信息为句法特征信息;
    确定与所述第一待使用特征信息所对应的第一嵌入向量,并确定与所述第二待使用特征信息相对应的第二嵌入向量;
    确定所述待分析文本所对应的待使用隐向量;
    根据所述第一嵌入向量、所述第二嵌入向量和所述待使用隐向量,确定所述待分析文本所对应的情感信息。
  2. 根据权利要求1所述的方法,其中,所述确定所述待分析文本所对应的第一待使用特征信息和第二待使用特征信息,包括:
    确定与所述待分析文本相对应的依存句法树,其中,所述待分析文本中包括至少两个分词,所述依存句法树为基于所述至少两个分词之间的上下文特征和句法特征进行构建的;
    基于所述依存句法树中,所述至少两个分词之间的上下文特征依赖关系,得到与所述待分析文本相对应的第一待使用特征信息;
    基于所述依存句法树中,所述至少两个分词之间的句法依赖关系,得到与所述待分析文本相对应的第二待使用特征信息。
  3. 根据权利要求1所述的方法,其中,所述确定与所述第一待使用特征信息所对应的第一嵌入向量,包括:
    基于第一嵌入函数,将所述第一待使用特征信息进行映射处理,得到第一待使用映射信息;
    确定所述第一待使用映射信息,在上下文特征嵌入矩阵中的第一位置信息,并根据所述第一位置信息所对应的矩阵元素,确定所述第一待使用映射信息所对应的第一嵌入向量。
  4. 根据权利要求1所述的方法,其中,所述确定与所述第二待使用特征信息相对应的第二嵌入向量,包括:
    基于第二嵌入函数,将所述第二待使用特征信息进行映射处理,得到第二待使用映射信息;
    确定所述第二待使用映射信息,在句法特征嵌入矩阵中的第二位置信息,并根据所述第二位置信息所对应的矩阵元素,确定所述第二待使用映射信息所 对应的第二嵌入向量。
  5. 根据权利要求1所述的方法,其中,所述确定所述待分析文本所对应的待使用隐向量,包括:
    基于语言表征模型,对所述待分析文本进行编码,得到与所述待分析文本中每个分词相对应的待使用分词向量;
    将多个待使用分词向量进行拼接处理,得到与所述待分析文本相对应的待使用隐向量。
  6. 根据权利要求1所述的方法,其中,所述根据所述第一嵌入向量、所述第二嵌入向量和所述待使用隐向量,确定所述待分析文本所对应的情感信息,包括:
    根据所述第一嵌入向量和所述待使用隐向量,确定所述第一嵌入向量所对应的第一权重;
    根据所述第二嵌入向量和所述待使用隐向量,确定所述第二嵌入向量所对应的第二权重;
    根据所述第一嵌入向量、所述第一权重、所述第二嵌入向量和所述第二权重,确定所述待分析文本所对应的情感信息。
  7. 根据权利要求6所述的方法,其中,所述根据所述第一嵌入向量、所述第一权重、所述第二嵌入向量和所述第二权重,确定所述待分析文本所对应的情感信息,包括:
    基于所述第一嵌入向量和所述第一权重,得到第一待拼接向量,并基于所述第二嵌入向量和所述第二权重,得到第二待拼接向量;
    将所述第一待拼接向量和所述第二待拼接向量进行拼接处理,得到目标向量;
    将所述目标向量输入预先构建的解码器,以基于所述解码器对所述目标向量进行情感分析,以确定所述待分析文本所对应的情感信息。
  8. 一种文本情感分析装置,包括:
    特征信息确定模块,设置为获取待分析文本,并确定所述待分析文本所对应的第一待使用特征信息和第二待使用特征信息,其中,所述第一待使用特征信息为上下文特征信息,所述第二待使用特征信息为句法特征信息;
    嵌入向量确定模块,设置为确定与所述第一待使用特征信息所对应的第一嵌入向量,并确定与所述第二待使用特征信息相对应的第二嵌入向量;
    隐向量确定模块,设置为确定所述待分析文本所对应的待使用隐向量;
    情感信息确定模块,设置为根据所述第一嵌入向量、所述第二嵌入向量和所述待使用隐向量,确定所述待分析文本所对应的情感信息。
  9. 一种电子设备,包括:
    至少一个处理器;以及
    与所述至少一个处理器通信连接的存储器;其中,
    所述存储器存储有可被所述至少一个处理器执行的计算机程序,所述计算机程序被所述至少一个处理器执行,以使所述至少一个处理器能够执行权利要求1-7中任一项所述的文本情感分析方法。
  10. 一种计算机可读存储介质,其中,所述计算机可读存储介质存储有计算机指令,所述计算机指令用于使处理器执行时实现权利要求1-7中任一项所述的文本情感分析方法。
PCT/CN2022/134576 2022-10-27 2022-11-28 文本情感分析方法、装置、电子设备及存储介质 WO2024087297A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202211340090.X 2022-10-27
CN202211340090.XA CN115510860A (zh) 2022-10-27 2022-10-27 一种文本情感分析方法、装置、电子设备及存储介质

Publications (1)

Publication Number Publication Date
WO2024087297A1 true WO2024087297A1 (zh) 2024-05-02

Family

ID=84512623

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/134576 WO2024087297A1 (zh) 2022-10-27 2022-11-28 文本情感分析方法、装置、电子设备及存储介质

Country Status (2)

Country Link
CN (1) CN115510860A (zh)
WO (1) WO2024087297A1 (zh)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115841119B (zh) * 2023-02-21 2023-06-16 中国科学技术大学 一种基于图结构的情绪原因提取方法

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20150286627A1 (en) * 2014-04-03 2015-10-08 Adobe Systems Incorporated Contextual sentiment text analysis
CN109933795A (zh) * 2019-03-19 2019-06-25 上海交通大学 基于上下文-情感词向量的文本情感分析系统
CN110955750A (zh) * 2019-11-11 2020-04-03 北京三快在线科技有限公司 评论区域和情感极性的联合识别方法、装置、电子设备
CN112001185A (zh) * 2020-08-26 2020-11-27 重庆理工大学 一种结合中文句法和图卷积神经网络的情感分类方法
CN113065331A (zh) * 2021-04-15 2021-07-02 上海金融期货信息技术有限公司 基于实体上下文判别的实体情感识别方法和系统

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20150286627A1 (en) * 2014-04-03 2015-10-08 Adobe Systems Incorporated Contextual sentiment text analysis
CN109933795A (zh) * 2019-03-19 2019-06-25 上海交通大学 基于上下文-情感词向量的文本情感分析系统
CN110955750A (zh) * 2019-11-11 2020-04-03 北京三快在线科技有限公司 评论区域和情感极性的联合识别方法、装置、电子设备
CN112001185A (zh) * 2020-08-26 2020-11-27 重庆理工大学 一种结合中文句法和图卷积神经网络的情感分类方法
CN113065331A (zh) * 2021-04-15 2021-07-02 上海金融期货信息技术有限公司 基于实体上下文判别的实体情感识别方法和系统

Also Published As

Publication number Publication date
CN115510860A (zh) 2022-12-23

Similar Documents

Publication Publication Date Title
JP7228662B2 (ja) イベント抽出方法、装置、電子機器及び記憶媒体
WO2022237013A1 (zh) 基于实体关系联合抽取的法律知识图谱构建方法及设备
WO2019214145A1 (zh) 文本情绪分析方法、装置及存储介质
WO2020119075A1 (zh) 通用文本信息提取方法、装置、计算机设备和存储介质
US8886515B2 (en) Systems and methods for enhancing machine translation post edit review processes
US20210312139A1 (en) Method and apparatus of generating semantic feature, method and apparatus of training model, electronic device, and storage medium
US9575965B2 (en) Translation assessment based on computer-generated subjective translation quality score
JP7301922B2 (ja) 意味検索方法、装置、電子機器、記憶媒体およびコンピュータプログラム
US20220318275A1 (en) Search method, electronic device and storage medium
US9766868B2 (en) Dynamic source code generation
KR102636493B1 (ko) 의료 데이터 검증 방법, 장치 및 전자 기기
US9619209B1 (en) Dynamic source code generation
US11170183B2 (en) Language entity identification
JP7254925B2 (ja) 改良されたデータマッチングのためのデータレコードの字訳
CN111488742B (zh) 用于翻译的方法和装置
US20230005283A1 (en) Information extraction method and apparatus, electronic device and readable storage medium
WO2023280106A1 (zh) 信息获取方法、装置、设备及介质
CN110287405A (zh) 情感分析的方法、装置和存储介质
WO2024087297A1 (zh) 文本情感分析方法、装置、电子设备及存储介质
JP2023015215A (ja) テキスト情報の抽出方法、装置、電子機器及び記憶媒体
US11645452B2 (en) Performance characteristics of cartridge artifacts over text pattern constructs
TW201905734A (zh) 語意分析裝置、方法及其電腦程式產品
WO2014169857A1 (zh) 数据处理装置、数据处理方法以及电子设备
JP7242797B2 (ja) 語句処理方法、機器及び記憶媒体
WO2018214956A1 (zh) 机器翻译方法、装置及存储介质

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: 22963276

Country of ref document: EP

Kind code of ref document: A1