Text processing method, text processing device, electronic device and computer readable storage medium
Through word segmentation processing and timing and context algorithm processing of text data, feature joint vectors are generated, which solves the problem of inaccurate determination of entity object evaluation tendency in text data in the prior art, and realizes more accurate emotional tendency analysis.
Patent Information
- Application Number
- CN202010246091.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-03-31
- Publication Date
- 2025-01-07
- Estimated Expiration
- 2040-03-31
AI Technical Summary
The prior art is not accurate enough when determining the evaluation tendency of entity objects contained in text data, especially when complex text sentences are involved, it is not possible to accurately reflect the true emotions or evaluation of the text on the entity object.
A text processing method is adopted to generate word vectors by word segmentation on text data, and combined with time-series-based algorithms and context-based algorithms to obtain timing features and context features, perform feature joint processing, and generate feature joint vectors to calculate entities. The evaluation results of the subject.
By combining timing and context information, the evaluation tendency of text data on entity objects can be calculated more accurately, and the judgment accuracy is improved.
Smart Images

Figure CN113468876B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of text processing, and in particular to a text processing method, a text processing device, an electronic device and a computer-readable storage medium containing text data of an entity object. Background Art
[0002] With the development of intelligent technology, people are no longer satisfied with machines only recognizing the content of text (sentences), but hope that machines can be more intelligent, for example, they can understand the emotions expressed in the text. Especially for sentences involving physical objects, such sentences can often express the speaker's evaluation or emotion about the physical objects involved in the sentence, for example, whether it is positive, negative, or neutral. This helps machines understand the emotions or tendencies of human users towards physical objects, thereby providing users with more targeted services.
[0003] Therefore, in the prior art, there has been a method of analyzing the entire sentence to determine the emotional tendency expressed by the sentence as a whole, thereby using it as the evaluation or emotional tendency of the entity object involved in the sentence. However, in most cases, the text sentences involving entity objects are often complex and contain more text. Therefore, the existing analysis scheme cannot accurately reflect the true evaluation or emotion that the text sentence wants to express about the entity object because it is based on the judgment of the entire sentence. Summary of the invention
[0004] Embodiments of the present invention provide a text processing method, a text processing device, an electronic device, and a computer-readable storage medium to solve the defect of inaccurate evaluation tendency determination of entity objects contained in text data in the prior art.
[0005] To achieve the above object, an embodiment of the present invention provides a text processing method, comprising:
[0006] Acquire first text data, wherein the first text data includes at least one entity object;
[0007] Performing word segmentation processing on the first text data to generate a word vector for each word of the first text data;
[0008] Performing time-series-based algorithm processing and context-based algorithm processing on the word vector to obtain a first result including time-series features of the entity object in the first text data and a second result including context features of the entity object in the first text data;
[0009] Performing feature joint processing on the first result and the second result to generate a feature joint vector;
[0010] An evaluation result of the entity object is calculated according to the feature joint vector, wherein the evaluation result identifies an evaluation tendency of the first text data with respect to the entity object.
[0011] The present application provides a text processing device, including:
[0012] An input layer, used to obtain first text data, wherein the first text data contains at least one entity object;
[0013] A preprocessing layer, configured to perform word segmentation processing on the first text data to generate a word vector for each word of the first text data;
[0014] A time series algorithm processing layer, used for performing time series-based algorithm processing on the word vector to obtain a first result including the time series features of the entity object in the first text data;
[0015] A context algorithm processing layer, used for performing context-based algorithm processing on the word vector to obtain a second result including context features of the entity object in the first text data;
[0016] A vector merging layer, used for performing feature joint processing on the first result and the second result to generate a feature joint vector;
[0017] The output layer is used to calculate the evaluation result of the entity object according to the feature joint vector, wherein the evaluation result identifies the evaluation tendency of the first text data for the entity object.
[0018] An embodiment of the present application provides an electronic device, including:
[0019] Memory, used to store programs;
[0020] The processor is used to run the program stored in the memory, and when the program is run, the following text processing method is executed, including:
[0021] Acquire first text data, wherein the first text data includes at least one entity object;
[0022] Performing word segmentation processing on the first text data to generate a word vector for each word of the first text data;
[0023] Performing time-series-based algorithm processing and context-based algorithm processing on the word vector to obtain a first result including time-series features of the entity object in the first text data and a second result including context features of the entity object in the first text data;
[0024] Performing feature joint processing on the first result and the second result to generate a feature joint vector;
[0025] An evaluation result of the entity object is calculated according to the feature joint vector, wherein the evaluation result identifies an evaluation tendency of the first text data with respect to the entity object.
[0026] The embodiment of the present application provides a computer-readable storage medium, on which a computer program executable by a processor is stored, wherein when the program is executed by the processor, the following text processing method is implemented, including:
[0027] Acquire first text data, wherein the first text data includes at least one entity object;
[0028] Performing word segmentation processing on the first text data to generate a word vector for each word of the first text data;
[0029] Performing time-series-based algorithm processing and context-based algorithm processing on the word vector to obtain a first result including time-series features of the entity object in the first text data and a second result including context features of the entity object in the first text data;
[0030] Performing feature joint processing on the first result and the second result to generate a feature joint vector;
[0031] An evaluation result of the entity object is calculated according to the feature joint vector, wherein the evaluation result identifies an evaluation tendency of the first text data with respect to the entity object.
[0032] The text processing method, text processing device, electronic device and computer-readable storage medium provided by the embodiments of the present invention process text data containing entity objects by combining time-series-based algorithm processing and context-based algorithm processing, thereby obtaining an evaluation feature vector for the entity object that considers the time sequence of word vectors in the text data and an evaluation feature vector for the entity object that uses each word in the text data as context, thereby being able to calculate the evaluation tendency of the text data for the entity object based on the feature vector containing this information, so that the obtained evaluation tendency is more accurate.
[0033] The above description is only an overview of the technical solution of the present invention. In order to more clearly understand the technical means of the present invention, it can be implemented according to the contents of the specification. In order to make the above and other purposes, features and advantages of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] Various other advantages and benefits will become apparent to those of ordinary skill in the art by reading the detailed description of the preferred embodiments below. The accompanying drawings are only for the purpose of illustrating the preferred embodiments and are not to be considered as limiting the present application. Also, the same reference symbols are used throughout the accompanying drawings to represent the same components. In the accompanying drawings:
[0035] Figure 1 A schematic diagram of a text processing scenario according to an embodiment of the present application;
[0036] Figure 2 A flowchart of a text processing method according to an embodiment of the present application;
[0037] Figure 3A and Figure 3B A flowchart of a text processing method according to an embodiment of the present application;
[0038] Figure 4 is a schematic diagram of a text processing device according to one embodiment of the present application; and
[0039] Figure 5 It is a schematic diagram of an electronic device according to one embodiment of the present application. DETAILED DESCRIPTION
[0040] The exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided to enable a more thorough understanding of the present disclosure and to fully convey the scope of the present disclosure to those skilled in the art.
[0041] With the development of intelligent technology, people are no longer satisfied with machines only recognizing the content of text (sentences), but hope that machines can be more intelligent, for example, they can understand the emotions expressed in the text. Especially for sentences involving physical objects, such sentences can often express the speaker's evaluation or emotion about the physical objects involved in the sentence, for example, whether it is positive, negative, or neutral. This helps machines understand the emotions or tendencies of human users towards physical objects, thereby providing users with more targeted services.
[0042] Therefore, in the prior art, there has been a method of analyzing the entire sentence to determine the emotional tendency expressed by the sentence as a whole, thereby using it as the evaluation or emotional tendency of the entity object involved in the sentence. However, in most cases, the text sentences involving entity objects are often complex and contain more text. Therefore, the existing analysis scheme cannot accurately reflect the true evaluation or emotion that the text sentence wants to express about the entity object because it is based on the judgment of the entire sentence.
[0043] The text processing method, text processing device, and electronic device provided by the embodiments of the present disclosure can be applied to scenarios where text data containing physical objects is processed.
[0044] For example, Figure 1 FIG. 1 is a schematic diagram of a text processing scenario according to an embodiment of the present application. Figure 1 As shown in , the text processing method according to the embodiment of the present application can be run in various processing systems, and can also be run on cloud servers to which various processing systems are connected. Figure 1 In the text processing apparatus 100, the text data 111 may be obtained from various text data sources 101, or the user may input the text data 111 into the text processing apparatus 100. In the embodiment of the present application, the text data source 101 may be a web page or a database storing various text data, and the user may input the text data 111 in various ways, for example, the user may input the text data 111 into the text processing apparatus 100 through the user's mobile terminal, or the text processing apparatus 100 may automatically obtain various text data 111 from the user's input in a manner negotiated with the user after obtaining the user's authorization.
[0045] In the embodiment of the present application, the text data 111 input into the text processing device 100 includes at least one entity object. For example, the input text data 111 may be "Girls like cosmetics", wherein cosmetics may be an entity object in the embodiment of the present application, and the text processing method of the embodiment of the present application can determine the evaluation tendency expressed by the text data for the entity object. For example, the text expresses a positive evaluation tendency for the entity object "cosmetics", for example, like. In some cases, the text data contains more than one entity object, for example, the input text data 111 is "Girls like cosmetics more than electronic products. In the text data 111, two entity objects are included, namely cosmetics and electronic products. According to the embodiment of the present application, there is no limit to the number of entity objects included in the text data 111, and it can be determined according to actual conditions.
[0046] like Figure 1As shown in , after the text data 111 is input into the text processing device 100, it is segmented by the preprocessing layer in the text processing device 100. In the embodiment of the present application, the word embedding process (WE, WordEmbedding) can be used to convert each word in the text data 111 into a word vector 112, so that it can be further processed in the subsequent algorithm processing layer. In particular, in the embodiment of the present application, the word embedding process with sentiment tendency (SSWE, Sentiment Specific Word Embedding) can be further used to convert the input text data 111 into a word vector, so that the word vector 112 with sentiment information can be obtained, which can better reflect the sentiment tendency of the words in the text data 111. For example, in the above example, that is, when the input text data 111 is "Girls like cosmetics better than electronic products", it can be converted into five word vectors "girls", "like", "cosmetics", "better" and "electronic products". In the embodiment of the present application, on the basis of the word vector, it can be further divided into the left part of the entity object and the right part of the entity object according to the specific entity object in the text data 111. For example, in the above example, the word vector of the text data 111 can be divided into the first part ("girls", "like", "cosmetics") and the second part ("cosmetics", "better than" and "electronic products") for the entity object "cosmetics". In the subsequent algorithm processing, the two parts can be calculated separately.
[0047] In this embodiment, after obtaining the first part and the second part of the word vector containing the entity object, they can be respectively input into two algorithm processing layers for different calculation processing. For example, in an embodiment of the present application, the first part and the second part can be input into the timing algorithm processing layer 104 to perform timing-based algorithm processing, such as LSTM algorithm, on the first part and the second part respectively, so as to obtain an evaluation feature vector containing the evaluation contribution of the words before or after the current word to the entity object. In an embodiment of the present application, the first part and the second part can be input into the context algorithm processing layer 105 to perform context-based algorithm processing, such as convolutional neural network processing, on the first part, the second part and the third part containing all vectors respectively, so as to obtain the evaluation contribution information of each word vector to the entity object.
[0048] Afterwards, the calculation results of the two algorithm processing layers with different focuses can be combined for feature calculation in the vector merging layer 106 to obtain a feature vector for the entity object, and input into the output layer 107 for final calculation to obtain the evaluation classification result of the text data 111 for the entity object "cosmetics". For example, the softmax function can be used in the output layer 107 to perform probability calculation, thereby obtaining the probability that the entity object "cosmetics" belongs to different evaluation results, and finally determining the evaluation tendency of the entity object "cosmetics".
[0049] Therefore, through the scheme of the embodiment of the present application, text data containing entity objects can be processed by combining time-series-based algorithm processing and context-based algorithm processing, and an evaluation feature vector for the entity object that considers the time sequence of word vectors in the text data and an evaluation feature vector for the entity object that uses each word in the text data as context are obtained. This allows the evaluation tendency of the text data for the entity object to be calculated based on the feature vector containing this information, making the obtained evaluation tendency more accurate.
[0050] Next reference Figures 2 to 5 A text processing method, a text processing device, an electronic device, and a computer-readable storage medium according to embodiments of the present application are described in detail.
[0051] Figure 2 FIG. 1 is a flow chart of a text processing method according to an embodiment of the present application. Figure 2 As shown in, according to an embodiment of the present application, the text processing method of the present application may include:
[0052] S201: Acquire first text data.
[0053] In an embodiment of the present application, text data can be obtained from various text data sources as the first text data, and the first text data targeted by the embodiment of the present application can contain at least one entity object. For example, "Girls like cosmetics", where cosmetics can be an entity object in the embodiment of the present application, so that the text processing method disclosed in the embodiment of the present application can be used to determine the evaluation tendency expressed by the first text data for the entity object. For example, the text expresses a positive evaluation tendency for the entity object "cosmetics", for example, like. In some cases, the entity object contained in the text data may be more than one, for example, the first text data may be "Girls like cosmetics better than electronic products". In the text data 111, two entity objects are included, namely cosmetics and electronic products. According to the embodiment of the present application, the number of entity objects included in the text data 111 is not limited, and can be determined according to actual conditions.
[0054] S202: Perform word segmentation processing on the first text data to generate a word vector for each word of the first text data.
[0055] After obtaining the first text data containing the entity object in step S201, the first text data may be segmented, ie, vectorized, to generate word vectors for each word included in the first text data.
[0056] In the embodiment of the present application, the word embedding process can be used to convert each word in the first text data into a word vector, so that it can be further processed in the subsequent algorithm processing layer. In particular, in the embodiment of the present application, the word embedding process with sentiment tendency can be used to convert the input first text data into a word vector, so that the word vector with sentiment information can be obtained, which can better reflect the sentiment tendency of the words in the text data.
[0057] For instance, in the above example, the first text data may be "Girls prefer cosmetics over electronic products", so it may be converted into five word vectors "girls", "like", "cosmetics", "better" and "electronic products" using word embedding processing, so as to facilitate calculation of these word vectors in subsequent steps.
[0058] S203, performing time-based algorithm processing and context-based algorithm processing on the word vector to obtain a first result containing the time-based features of the entity object in the first text data and a second result containing the contextual features of the entity object in the first text data.
[0059] In an embodiment of the present application, after obtaining the word vectors of the first text data in step S202, these word vectors can be subjected to calculation processing with different focuses and pertinences in step S203. For example, these word vectors can be calculated using a time-series-based algorithm, such as LSTM, to obtain an evaluation feature vector that considers the evaluation contribution of the words before or after each word in the first text data to the entity object in different time sequences. In parallel with the time-series-based algorithm processing, in step S203, each input word vector can be subjected to context-based algorithm processing, such as convolutional neural network calculation, to obtain the evaluation contribution of each word in the first text data to the entity object.
[0060] S204: Perform feature joint processing on the first result and the second result to generate a feature joint vector.
[0061] In the embodiment of the present application, after obtaining the first result and the second result by two algorithms with different focuses in step S203, the calculation results of the two algorithm processing layers with different focuses can be combined to obtain a feature vector for the entity object in step S204. That is, the feature vectors obtained by calculating the first text data by different algorithms are combined, so that the feature vectors of different algorithms are associated together to form a feature combination vector for the specified entity object.
[0062] S205: Calculate an evaluation result of the entity object according to the feature joint vector.
[0063] In an embodiment of the present application, the results of different algorithms can be unified through the feature joint processing in step S204, so that such a feature joint vector can be calculated in step S205, and the obtained evaluation result identifies the evaluation tendency of the first text data for the entity object.
[0064] In the embodiment of the present application, the evaluation tendency can be an evaluation classified into various evaluation degrees, for example, evaluations such as "good", "bad" and "neutral", or "like", "dislike" and "neutral", or it can be a classification of further dimensions of positive and negative evaluations in the above evaluations, for example, "especially good" and "good", "especially bad" and "bad", "especially like" and "like", "especially dislike" and "dislike", etc. There is no special limitation on this in the present application. As long as the evaluation tendency of the first text data for the entity object can be distinguished.
[0065] Therefore, through the scheme of the embodiment of the present application, text data containing entity objects can be processed by combining time-series-based algorithm processing and context-based algorithm processing, and an evaluation feature vector for the entity object that considers the time sequence of word vectors in the text data and an evaluation feature vector for the entity object that uses each word in the text data as context are obtained. This allows the evaluation tendency of the text data for the entity object to be calculated based on the feature vector containing this information, making the obtained evaluation tendency more accurate.
[0066] Figure 3A and Figure 3B FIG. 1 is a flow chart of a text processing method according to an embodiment of the present application. Figure 3A As shown in, according to an embodiment of the present application, the text processing method of the present application may include:
[0067] S301: Acquire first text data.
[0068] In an embodiment of the present application, text data can be obtained from various text data sources as the first text data, and the first text data targeted by the embodiment of the present application can contain at least one entity object. For example, "Girls like cosmetics", where cosmetics can be an entity object in the embodiment of the present application, so that the text processing method disclosed in the embodiment of the present application can be used to determine the evaluation tendency expressed by the first text data for the entity object. For example, the text expresses a positive evaluation tendency for the entity object "cosmetics", for example, like. In some cases, the entity object contained in the text data may be more than one, for example, the first text data may be "Girls like cosmetics better than electronic products". In the text data 111, two entity objects are included, namely cosmetics and electronic products. According to the embodiment of the present application, the number of entity objects included in the text data 111 is not limited, and can be determined according to actual conditions.
[0069] S302: Perform word segmentation processing on the first text data to generate a word vector for each word of the first text data.
[0070] After obtaining the first text data containing the entity object in step S301, the first text data may be segmented, ie, vectorized, to generate word vectors for each word included in the first text data.
[0071] In the embodiment of the present application, the word embedding process can be used to convert each word in the first text data into a word vector, so that it can be further processed in the subsequent algorithm processing layer. In particular, in the embodiment of the present application, the word embedding process with sentiment tendency can be used to convert the input first text data into a word vector, so that the word vector with sentiment information can be obtained, which can better reflect the sentiment tendency of the words in the text data.
[0072] For instance, in the above example, the first text data may be "Girls prefer cosmetics over electronic products", so it may be converted into five word vectors "girls", "like", "cosmetics", "better" and "electronic products" using word embedding processing, so as to facilitate calculation of these word vectors in subsequent steps.
[0073] S3031, dividing the word vector into a first word vector group and a second word vector group based on the position of the entity object in the first text data.
[0074] In the embodiment of the present application, since it is necessary to calculate the evaluation tendency of the first text data for the included entity object, the word vector obtained in step S302 can be divided into two parts according to the position of the entity object in the first text data on the basis of obtaining the included word vector. For example, the first word vector group can include the word vector corresponding to the entity object and the word vectors of all words located on the left side of the entity object, and the second word vector group includes the word vector corresponding to the entity object and the word vectors of all words located on the right side of the entity object.
[0075] For example, when the first text data mentioned above is "Girls like cosmetics better than electronic products", for the entity object "cosmetics", the first word vector group may include the three word vectors "girls", "like", and "cosmetics", and the second word vector group may include the three word vectors "cosmetics", "better" and "electronic products".
[0076] S3032, performing forward LTSM calculation and reverse LTSM calculation on all word vectors of the first text data respectively to obtain a forward time series vector and a reverse time series vector of each word of the first text data.
[0077] In this step, a time-based algorithm may be used to calculate the word vector of the first text data. For example, LTSM may be used to calculate an evaluation feature vector containing evaluation contribution information of the word vector before or after the current word vector. For example, the forward time-series feature vector of each word may contain evaluation contribution information of all words that are located before the word in time sequence, and the reverse time-series feature vector of each word may contain evaluation contribution information of all words that are located after the word in time sequence.
[0078] For example, in an embodiment of the present application, during the forward time series calculation, the word vector of the first word "girl" in the first text data can be calculated first to obtain an evaluation feature vector result that takes the word vector into consideration. Next, the word vector "like" is calculated. In this calculation, not only the word vector but also the evaluation feature vector result of the word vector "girl" located before the word is considered, thereby obtaining an evaluation feature vector result that takes into consideration not only the word vector "like" but also the calculation result of the word vector "girl", and so on, until the feature vector result of the word vector of the last word "electronic product" is calculated.
[0079] Similar to the above calculation process, reverse LSTM calculation can be further performed, that is, the word vector of the last word "electronic products" is first calculated to obtain the evaluation feature vector result considering the word vector, and then the word vector of the second to last word "better than" is calculated. In this calculation, not only the word vector of the current word "better than" but also the evaluation feature vector result of the word vector of the last word "electronic products" after the word is considered, thereby obtaining a feature vector result that considers not only the word vector "electronic products" but also the feature vector of the word vector "better than", and so on, until the evaluation feature vector result of the first word vector "girl" is calculated.
[0080] Therefore, through step S3032, the evaluation feature vector results of each word vector calculated in the forward time sequence and the evaluation feature vector results of each word vector calculated in the reverse time sequence can be obtained.
[0081] S3033, calculating the first result according to all forward time series feature vectors corresponding to the first word vector group and all reverse time series feature vectors corresponding to the second word vector group.
[0082] Although in step S3032, the feature vector results of each word vector calculated in forward time sequence and reverse time sequence are obtained for all five word vectors "girls", "like", "cosmetics", "better than" and "electronic products", respectively, in this embodiment of the application, only the feature vector results corresponding to the first word vector group, that is, the word vector containing the entity object "cosmetics" and all the words on its left, are needed, that is, the feature vector calculated in forward time sequence, that is, the forward time sequence vector and the feature vector results corresponding to the second word vector group, that is, the word vector containing the entity object "cosmetics" and all the words on its right, that is, the feature vector calculated in reverse time sequence, that is, the reverse time sequence vector.
[0083] For example, in this step, the forward time series vectors corresponding to the word vectors "girls", "like", and "cosmetics" calculated in the forward time series and the reverse time series vectors corresponding to the word vectors "cosmetics", "better than", and "electronic products" calculated in the reverse time series can be used to respectively calculate the time series calculation results corresponding to the first word vector group and the time series calculation results corresponding to the second word vector group, thereby obtaining the evaluation contribution vectors of the two text parts on both sides of the entity object "cosmetics" considering the word vector time series for the entity object. In an embodiment of the present application, such two evaluation contribution vectors can constitute the first result.
[0084] In addition, in the time-series-based calculation process shown in the above steps S3031-S3033, the evaluation feature vector results of each word vector in the forward and reverse time sequences can be considered as described above, and in actual applications, the evaluation contribution of each word in the text data to the entity object is different, that is, the importance of the evaluation tendency for calculating the entity object is different. Therefore, in the embodiment of the present application, an attention mechanism can be further introduced to further determine the importance of the word.
[0085] For example, Figure 3B As shown, after step S3032, the following steps may be further included:
[0086] S3034, perform attention calculation processing on each forward time series vector corresponding to the first word vector group and each reverse time series vector corresponding to the second word vector group to generate attention data for each forward time series vector and attention data for each reverse time series vector.
[0087] In an embodiment of the present application, the attention data of each time series vector can be calculated to obtain the attention weight information between the corresponding word and other words, such as adjacent words, that is, the importance or correlation of the current word to other words.
[0088] For example, among the word vectors "girls", "like", and "cosmetics" included in the first word vector group, the correlation between "like" and "cosmetics" may be higher than the correlation between "girls" and "cosmetics". Therefore, using the result of step S3034, it can be identified that the word vector "like" has a higher contribution or importance to the word vector "cosmetics" of the entity object. Therefore, in subsequent calculation processing, the word vector "like" can be given a greater weight.
[0089] S3035. Based on the attention data, the forward time series vector corresponding to the first word vector group and the reverse time series vector corresponding to the second word vector group are superimposed respectively to obtain the first attention feature vector and the second attention feature vector of the entity object in the first word vector group and the second word vector group.
[0090] As described above, the time series vectors of the first word vector group and the second word vector group can be superimposed based on the attention data. In the superimposed calculation, the time series vectors of different word vectors are given different attention weights based on the attention data. This can more accurately reflect the contribution of each word to the evaluation tendency of the entity object, making the calculation of the evaluation result of the entity object more accurate.
[0091] S3036, output the first attention feature vector and the second attention feature vector as the first result.
[0092] Therefore, by introducing the attention mechanism, it is possible to further consider the importance of each word vector in the first text data to the entity object, that is, the attention weight, to calculate the feature vectors of the first word vector group and the second word vector group, so that the calculated feature vectors more accurately reflect the evaluation tendency of each word vector in the first word vector group and the second word vector group for the entity object.
[0093] S3041, dividing the word vector into a first word vector group and a second word vector group based on the position of the entity object in the first text data.
[0094] In the embodiment of the present application, since it is necessary to calculate the evaluation tendency of the first text data for the included entity object, the word vector obtained in step S302 can be divided into two parts according to the position of the entity object in the first text data on the basis of obtaining the included word vector. For example, the first word vector group can include the word vector corresponding to the entity object and the word vectors of all words located on the left side of the entity object, and the second word vector group includes the word vector corresponding to the entity object and the word vectors of all words located on the right side of the entity object.
[0095] For example, when the first text data mentioned above is "Girls like cosmetics better than electronic products", for the entity object "cosmetics", the first word vector group may include the three word vectors "girls", "like", and "cosmetics", and the second word vector group may include the three word vectors "cosmetics", "better" and "electronic products".
[0096] S3042, perform convolutional neural network calculation on the first word vector group, the second word vector group and the word vectors of the first text data respectively to obtain the first feature vector group, the second feature vector group and the third feature vector group of the word vectors of the first word vector group, the second word vector group and the first text data.
[0097] In the embodiment of the present application, a context-based algorithm may be used to calculate the word vectors of the first text data. For example, a convolutional neural network may be used to process the word vectors in the first word vector group, the word vectors in the second word vector group, and all the word vectors of the first text data to obtain a feature vector containing the contextual relationship between the three groups of word vectors and the entity object.
[0098] S3043, performing pooling processing on the feature vectors of the first feature vector group, the second feature vector group and the third feature vector group, respectively, to obtain a first convolution result vector, a second convolution result vector and a third convolution result vector corresponding to the first word vector group, the second word vector group and the first text data, respectively.
[0099] S3044, output the first convolution result vector, the second convolution result vector and the third convolution result vector as the second result.
[0100] In an embodiment of the present application, steps S3031-S3033 of the algorithm processing based on the time series and steps S3041-S3044 of the algorithm processing based on the context can be performed in parallel. For example, the word vector of the first text data can be processed by these two algorithms at the same time, or the two algorithms can be processed one after another. For example, the steps of the algorithm processing based on the time series can be performed first, or the steps of the algorithm processing based on the context can be performed first. The order of the two algorithm processing is not limited in this application and can be determined according to actual conditions.
[0101] S305: Perform feature joint processing on the first result and the second result to generate a feature joint vector.
[0102] In the embodiment of the present application, after obtaining the first result and the second result by two algorithms with different focuses in the above steps, the calculation results of the two algorithm processing layers with different focuses can be combined to obtain a feature vector for the entity object in step S305. That is, the feature vectors obtained by calculating the first text data by different algorithms are combined, so that the feature vectors of different algorithms are associated together to form a feature joint vector for the specified entity object.
[0103] S306: Perform abstract calculation on the feature joint vector to obtain at least one abstract feature vector that identifies the evaluation of the text data on the entity object.
[0104] S307: Calculate the evaluation result of the text data for the entity object according to the abstract feature vector.
[0105] In the embodiment of the present application, the evaluation result of the entity object can be calculated according to the abstract feature vector through various processes. For example, the evaluation result of the entity object can be calculated using the Softmax function.
[0106] In the embodiment of the present application, the evaluation tendency can be an evaluation classified into various evaluation degrees, for example, evaluations such as "good", "bad" and "neutral", or "like", "dislike" and "neutral", or it can be a classification of further dimensions of positive and negative evaluations in the above evaluations, for example, "especially good" and "good", "especially bad" and "bad", "especially like" and "like", "especially dislike" and "dislike", etc. There is no special limitation on this in the present application. As long as the evaluation tendency of the first text data for the entity object can be distinguished.
[0107] Therefore, through the scheme of the embodiment of the present application, text data containing entity objects can be processed by combining time-series-based algorithm processing and context-based algorithm processing, and an evaluation feature vector for the entity object that considers the time sequence of word vectors in the text data and an evaluation feature vector for the entity object that uses each word in the text data as context are obtained. This allows the evaluation tendency of the text data for the entity object to be calculated based on the feature vector containing this information, making the obtained evaluation tendency more accurate.
[0108] Figure 4 FIG. 1 is a schematic diagram of a text processing device according to an embodiment of the present application. Figure 2 , Figure 3A and Figure 3B The method steps shown. Figure 4 As shown, the text processing device of the embodiment of the present application includes an input layer 401, a preprocessing layer 402, a timing algorithm processing layer 403, a context algorithm processing layer 404, a vector merging layer 405 and an output layer 406.
[0109] like Figure 4 As shown in , the input layer 401 can be used to obtain first text data, wherein the first text data contains at least one entity object.
[0110] In an embodiment of the present application, text data can be obtained from various text data sources as the first text data, and the first text data targeted by the embodiment of the present application can contain at least one entity object. For example, "Girls like cosmetics", where cosmetics can be an entity object in the embodiment of the present application, so that the text processing method disclosed in the embodiment of the present application can be used to determine the evaluation tendency expressed by the first text data for the entity object. For example, the text expresses a positive evaluation tendency for the entity object "cosmetics", for example, like. In some cases, the entity object contained in the text data may be more than one, for example, the first text data may be "Girls like cosmetics better than electronic products". In the text data 111, two entity objects are included, namely cosmetics and electronic products. According to the embodiment of the present application, the number of entity objects included in the text data 111 is not limited, and can be determined according to actual conditions.
[0111] The preprocessing layer 402 may be used to perform word segmentation processing on the first text data to generate a word vector for each word of the first text data.
[0112] In the embodiment of the present application, each word in the first text data can be converted into a word vector by using word embedding processing in the preprocessing layer 402, so that it can be further processed in the subsequent algorithm processing layer. In particular, in the embodiment of the present application, the word embedding processing with sentiment tendency can be used to convert the input first text data into a word vector, so that a word vector with sentiment information can be obtained, which can better reflect the sentiment tendency of the words in the text data.
[0113] For example, in the above example, the first text data may be "Girls like cosmetics better than electronic products", so it can be converted into five word vectors "girls", "like", "cosmetics", "better" and "electronic products" using word embedding processing in the preprocessing layer 402, so as to facilitate the calculation of these word vectors in subsequent steps.
[0114] The time series algorithm processing layer 403 can be used to perform time series-based algorithm processing on the word vector to obtain a first result that identifies the time series features of the entity object in the first text data.
[0115] The context algorithm processing layer 404 may be used to perform context-based algorithm processing on the word vector to obtain a second result that identifies context features of the entity object in the first text data.
[0116] In an embodiment of the present application, for each word vector of the first text data obtained by the preprocessing layer 402, these word vectors can be subjected to calculation processing with different focuses and pertinences in the timing algorithm processing layer 403 and the context algorithm processing layer 404. For example, in the timing algorithm processing layer 403, these word vectors can be calculated using, for example, LSTM to obtain the evaluation contribution of each word in the first text data to the entity object at each moment. In parallel with the timing-based algorithm processing, context-based algorithm processing, such as convolutional neural network calculation, can be performed on each word vector in the context algorithm processing layer 404 to obtain the evaluation contribution of each word in the first text data to the entity object.
[0117] For example, in the time series algorithm processing layer 403, the word vectors can be divided into a first word vector group and a second word vector group based on the position of the entity object in the first text data.
[0118] In the embodiment of the present application, since it is necessary to calculate the evaluation tendency of the first text data for the included entity object, the word vector obtained in the preprocessing layer 402 can be divided into two parts according to the position of the entity object in the first text data on the basis of obtaining the included word vector. For example, the first word vector group can include the word vector corresponding to the entity object and the word vectors of all words located on the left side of the entity object, and the second word vector group includes the word vector corresponding to the entity object and the word vectors of all words located on the right side of the entity object.
[0119] For example, when the first text data mentioned above is "Girls like cosmetics better than electronic products", for the entity object "cosmetics", the first word vector group may include the three word vectors "girls", "like", and "cosmetics", and the second word vector group may include the three word vectors "cosmetics", "better" and "electronic products".
[0120] Next, the time series algorithm processing layer 403 may perform forward LTSM calculation and reverse LTSM calculation on all word vectors of the first text data respectively to obtain a forward time series feature vector and a reverse time series feature vector of each word of the first text data.
[0121] In this process, a time-series-based algorithm may be used to calculate the word vectors of the first text data. For example, LTSM may be used to calculate the evaluation contribution of each word vector at different time sequences. For example, the forward time sequence feature vector of each word may include the evaluation contribution information of all words that are located before the word in time sequence, and the reverse time sequence feature vector of each word may include the evaluation contribution information of all words that are located after the word in time sequence.
[0122] For example, in an embodiment of the present application, during the forward time series calculation, the word vector of the first word "girl" in the first text data can be calculated first to obtain an evaluation feature vector result that takes the word vector into consideration. Next, the word vector "like" is calculated. In this calculation, not only the word vector but also the evaluation feature vector result of the word vector "girl" located before the word is considered, thereby obtaining an evaluation feature vector result that takes into consideration not only the word vector "like" but also the calculation result of the word vector "girl", and so on, until the feature vector result of the word vector of the last word "electronic product" is calculated.
[0123] Similar to the above calculation process, reverse LSTM calculation can be further performed, that is, the word vector of the last word "electronic products" is first calculated to obtain the evaluation feature vector result considering the word vector, and then the word vector of the second to last word "better than" is calculated. In this calculation, not only the word vector of the current word "better than" but also the evaluation feature vector result of the word vector of the last word "electronic products" after the word is considered, thereby obtaining a feature vector result that considers not only the word vector "electronic products" but also the feature vector of the word vector "better than", and so on, until the evaluation feature vector result of the first word vector "girl" is calculated.
[0124] Therefore, through the above processing, the evaluation feature vector results of each word vector calculated in the forward time sequence and the evaluation feature vector results of each word vector calculated in the reverse time sequence can be obtained.
[0125] Next, the time series algorithm processing layer 403 can calculate the first result according to all forward time series vectors corresponding to the first word vector group and all reverse time series vectors corresponding to the second word vector group.
[0126] For example, although in the above processing, the evaluation feature vector results of each word vector calculated in forward time sequence and reverse time sequence for all five word vectors "girls", "like", "cosmetics", "better than" and "electronic products" were obtained, but in the embodiment of the present application, only the feature vector results corresponding to the first word vector group, that is, the word vector containing the entity object "cosmetics" and all the words on its left, are needed, that is, the feature vector calculated in forward time sequence, that is, the forward time sequence vector and the feature vector results corresponding to the second word vector group, that is, the word vector containing the entity object "cosmetics" and all the words on its right, that is, the feature vector calculated in reverse time sequence, that is, the reverse time sequence vector.
[0127] For example, the time series calculation results corresponding to the first word vector group and the time series calculation results corresponding to the second word vector group can be calculated respectively according to the forward time series vectors corresponding to the word vectors "girls", "like", and "cosmetics" calculated in the forward time series and the reverse time series vectors corresponding to the word vectors "cosmetics", "better than", and "electronic products" calculated in the reverse time series, so as to obtain the evaluation contribution vectors of the two text parts on both sides of the entity object "cosmetics" considering the word vector time series for the entity object. In the embodiment of the present application, such two evaluation contribution vectors can constitute the first result.
[0128] In addition, in the time series algorithm processing layer 403, the evaluation feature vector results of each word vector in the forward and reverse time series can be considered as described above. In practical applications, the evaluation contribution of each word in the first text data to the entity object is different, that is, the importance of the evaluation tendency for calculating the entity object is different. Therefore, in the embodiment of the present application, an attention mechanism can be further introduced to further consider the importance of the word.
[0129] For example, the following processing can be further performed in the time series algorithm processing layer 403: attention calculation processing is performed on each forward time series vector corresponding to the first word vector group and each reverse time series vector corresponding to the second word vector group to generate attention data for each forward time series vector and attention data for each reverse time series vector.
[0130] In an embodiment of the present application, the attention data of each time series vector can be calculated to obtain the attention weight information between the corresponding word and other words, such as adjacent words, that is, the importance or correlation of the current word to other words.
[0131] For example, among the word vectors "girls", "like", and "cosmetics" included in the first word vector group, the correlation between "like" and "cosmetics" may be higher than the correlation between "girls" and "cosmetics". Therefore, using the result of step S3034, it can be identified that the word vector "like" has a higher contribution or importance to the word vector "cosmetics" of the entity object. Therefore, in subsequent calculation processing, the word vector "like" can be given a greater weight.
[0132] Next, in the time series algorithm processing layer 403, based on the attention data, the forward time series vector corresponding to the first word vector group and the reverse time series vector corresponding to the second word vector group can be superimposed respectively to obtain the first attention feature vector and the second attention feature vector of the entity object in the first word vector group and the second word vector group.
[0133] As described above, the time series vectors of the first word vector group and the second word vector group can be superimposed based on the attention data. In the superimposed calculation, the time series vectors of different word vectors are given different attention weights based on the attention data. This can more accurately reflect the contribution of each word to the evaluation tendency of the entity object, making the calculation of the evaluation result of the entity object more accurate.
[0134] Finally, the temporal algorithm processing layer 403 may output the first attention feature vector and the second attention feature vector as the first result.
[0135] Therefore, by introducing the attention mechanism, it is possible to further consider the importance of each word vector in the first text data to the entity object, that is, the attention weight, to calculate the feature vectors of the first word vector group and the second word vector group, so that the calculated feature vectors more accurately reflect the evaluation tendency of each word vector in the first word vector group and the second word vector group for the entity object.
[0136] In the context algorithm processing layer 404, the word vectors may be divided into a first word vector group and a second word vector group based on the position of the entity object in the first text data.
[0137] In the embodiment of the present application, since it is necessary to calculate the evaluation tendency of the first text data for the included entity object, the word vector obtained in the preprocessing layer 402 can be divided into two parts according to the position of the entity object in the first text data on the basis of obtaining the included word vector. For example, the first word vector group can include the word vector corresponding to the entity object and the word vectors of all words located on the left side of the entity object, and the second word vector group includes the word vector corresponding to the entity object and the word vectors of all words located on the right side of the entity object.
[0138] For example, when the first text data mentioned above is "Girls like cosmetics better than electronic products", for the entity object "cosmetics", the first word vector group may include the three word vectors "girls", "like", and "cosmetics", and the second word vector group may include the three word vectors "cosmetics", "better" and "electronic products".
[0139] Afterwards, the context algorithm processing layer 404 can perform convolutional neural network calculations on the first word vector group, the second word vector group and the word vectors of the first text data, respectively, to obtain the first feature vector group, the second feature vector group and the third feature vector group of the word vectors of the first word vector group, the second word vector group and the first text data.
[0140] In the embodiment of the present application, a context-based algorithm may be used to calculate the word vectors of the first text data. For example, a convolutional neural network may be used to process the word vectors in the first word vector group, the word vectors in the second word vector group, and all the word vectors of the first text data to obtain a feature vector containing the contextual relationship between the three groups of word vectors and the entity object.
[0141] Afterwards, the context algorithm processing layer 404 can respectively perform pooling processing on the feature vectors of the first feature vector group, the second feature vector group and the third feature vector group to obtain the first convolution result vector, the second convolution result vector and the third convolution result vector corresponding to the first word vector group, the second word vector group and the first text data respectively, and output the first convolution result vector, the second convolution result vector and the third convolution result vector as the second result.
[0142] In the embodiment of the present application, the algorithm processing based on timing in the timing algorithm processing layer 403 and the algorithm processing based on context in the context algorithm processing layer 404 can be performed in parallel or sequentially. For example, the step of the algorithm processing based on timing can be performed first, or the step of the algorithm processing based on context can be performed first. The order of the two algorithm processing is not limited in the present application and can be determined according to actual conditions.
[0143] The vector merging layer 405 may be used to perform feature joint processing on the first result and the second result to generate a feature joint vector.
[0144] The output layer 406 may be used to calculate the evaluation result of the entity object according to the feature joint vector.
[0145] In an embodiment of the present application, the results of different algorithms can be unified through feature joint processing in the vector merging layer 405, so that such a feature joint vector can be calculated in the output layer 406, and the obtained evaluation result identifies the evaluation tendency of the first text data for the entity object.
[0146] In the embodiment of the present application, the evaluation tendency can be an evaluation classified into various evaluation degrees, for example, evaluations such as "good", "bad" and "neutral", or "like", "dislike" and "neutral", or it can be a classification of further dimensions of positive and negative evaluations in the above evaluations, for example, "especially good" and "good", "especially bad" and "bad", "especially like" and "like", "especially dislike" and "dislike", etc. There is no special limitation on this in the present application. As long as the evaluation tendency of the first text data for the entity object can be distinguished.
[0147] Therefore, through the scheme of the embodiment of the present application, text data containing entity objects can be processed by combining time-series-based algorithm processing and context-based algorithm processing, and an evaluation feature vector for the entity object that considers the time sequence of word vectors in the text data and an evaluation feature vector for the entity object that uses each word in the text data as context are obtained. This allows the evaluation tendency of the text data for the entity object to be calculated based on the feature vector containing this information, making the obtained evaluation tendency more accurate.
[0148] The internal functions and structure of the text processing device are described above. The device can be implemented as an electronic device. Figure 5 Schematic diagram of an electronic device according to one embodiment of the present application. Figure 5 As shown, the electronic device includes a memory 51 and a processor 52 .
[0149] The memory 51 is used to store programs. In addition to the above programs, the memory 51 can also be configured to store various other data to support operations on the electronic device. Examples of such data include instructions for any application or method operating on the electronic device, contact data, phone book data, messages, pictures, videos, etc.
[0150] The memory 51 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.
[0151] The processor 52 is not limited to a central processing unit (CPU), but may also be a processing chip such as a graphics processing unit (GPU), a field programmable gate array (FPGA), an embedded neural network processor (NPU) or an artificial intelligence (AI) chip. The processor 52 is coupled to the memory 51 and executes a program stored in the memory 51. When the program is run, any of the above-mentioned text processing methods is executed.
[0152] Further, if Figure 5 As shown, the electronic device may also include: a communication component 53, a power component 54, an audio component 55, a display 56 and other components. Figure 5 Only some components are shown schematically, which does not mean that the electronic device only includes Figure 5 Components shown.
[0153] The communication component 53 is configured to facilitate wired or wireless communication between the electronic device and other devices. The electronic device can access a wireless network based on a communication standard, such as WiFi, 3G, 4G or 5G, or a combination thereof. In an exemplary embodiment, the communication component 53 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 53 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.
[0154] The power supply component 54 provides power to various components of the electronic device. The power supply component 54 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to the electronic device.
[0155] The audio component 55 is configured to output and / or input audio signals. For example, the audio component 75 includes a microphone (MIC), and when the electronic device is in an operating mode, such as a call mode, a recording mode, and a voice recognition mode, the microphone is configured to receive an external audio signal. The received audio signal can be further stored in the memory 51 or sent via the communication component 53. In some embodiments, the audio component 55 also includes a speaker for outputting audio signals.
[0156] The display 56 includes a screen, which may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from a user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundary of a touch or slide action, but also detect the duration and pressure associated with the touch or slide operation.
[0157] Those skilled in the art can understand that all or part of the steps of implementing the above-mentioned method embodiments can be completed by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, the steps of the above-mentioned method embodiments are executed; and the aforementioned storage medium includes: ROM, RAM, disk or optical disk and other media that can store program codes.
[0158] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. A text processing method, comprising: Acquire first text data, wherein the first text data includes at least one entity object; Performing word segmentation processing on the first text data to generate a word vector for each word of the first text data; The word vector is subjected to a time-series-based algorithm processing and a context-based algorithm processing to obtain a first result including the time-series features of the entity object in the first text data and a second result including the context features of the entity object in the first text data; wherein the word vector is divided into a first word vector group and a second word vector group, the first word vector group includes the word vector corresponding to the entity object and the word vectors of all words located on the left side of the entity object, and the second word vector group includes the word vector corresponding to the entity object and the word vectors of all words located on the right side of the entity object; in the time-series-based algorithm processing, according to the first The first result is calculated based on all the forward time series feature vectors corresponding to the word vector group and all the reverse time series feature vectors corresponding to the second word vector group; the first result is calculated based on all the forward time series feature vectors corresponding to the first word vector group and all the reverse time series feature vectors corresponding to the second word vector group, including: performing attention calculation processing on the forward time series vector and the reverse time series vector to obtain the corresponding attention data respectively, and superimposing the forward time series vector and the reverse time series vector respectively based on the corresponding attention data to obtain the first attention feature vector and the second attention feature vector of the entity object in the first word vector group and the second word vector group, and outputting the first attention feature vector and the second attention feature vector as the first result; performing feature joint processing on the first result and the second result to generate a feature joint vector; An evaluation result of the entity object is calculated according to the feature joint vector, wherein the evaluation result identifies an evaluation tendency of the first text data with respect to the entity object.
2. The text processing method according to claim 1, wherein: The timing-based algorithm processing includes: Dividing the word vector into a first word vector group and a second word vector group based on the position of the entity object in the first text data, wherein the first word vector group includes the word vector corresponding to the entity object and the word vectors of all words located on the left side of the entity object, and the second word vector group includes the word vector corresponding to the entity object and the word vectors of all words located on the right side of the entity object; Performing forward LTSM calculation and reverse LTSM calculation on all word vectors of the first text data respectively, so as to obtain a forward time sequence feature vector and a reverse time sequence feature vector of each word of the first text data, wherein the forward time sequence feature vector of each word includes evaluation contribution information of all words that are located before the word in time sequence, and the reverse time sequence feature vector of each word includes evaluation contribution information of all words that are located after the word in time sequence; and The first result is calculated based on all forward temporal feature vectors corresponding to the first word vector group and all reverse temporal feature vectors corresponding to the second word vector group.
3. The text processing method according to claim 1, wherein: The context-based algorithm processing includes: Dividing the word vector into a first word vector group and a second word vector group based on the position of the entity object in the first text data, wherein the first word vector group includes the word vector corresponding to the entity object and the word vectors of all words located on the left side of the entity object, and the second word vector group includes the word vector corresponding to the entity object and the word vectors of all words located on the right side of the entity object; Perform convolutional neural network calculations on the first word vector group, the second word vector group, and the word vectors of the first text data, respectively, to obtain a first feature vector group, a second feature vector group, and a third feature vector group of the first word vector group, the second word vector group, and the word vectors of the first text data, wherein the feature vectors in the first feature vector group correspond to the word vectors in the first word vector group, respectively, and include the contextual relationship of the word vectors in the first word vector group to the feature object, the feature vectors in the second feature vector group correspond to the word vectors in the second word vector group, respectively, and include the contextual relationship of the word vectors in the second word vector group to the feature object, and the feature vectors in the third feature vector group correspond to the word vectors of the text data, respectively, and include the contextual relationship of the word vectors of the text data to the feature object; Performing pooling processing on the feature vectors of the first feature vector group, the second feature vector group, and the third feature vector group, respectively, to obtain a first convolution result vector, a second convolution result vector, and a third convolution result vector corresponding to the first word vector group, the second word vector group, and the first text data, respectively; The first convolution result vector, the second convolution result vector and the third convolution result vector are output as the second result.
4. The text processing method according to claim 3, wherein: The pooling process comprises: An average value of the eigenvectors in the first eigenvector group, and an average value of the eigenvectors in the second eigenvector group and the third eigenvector group are calculated as the first convolution result vector, the second convolution result vector, and the third convolution result vector, respectively.
5. The text processing method according to claim 3, wherein: The pooling process comprises: The maximum value of the eigenvectors in the first eigenvector group, the maximum value of the eigenvectors in the second eigenvector group, and the maximum value of the eigenvectors in the third eigenvector group are respectively calculated as the second result.
6. The text processing method according to claim 1, wherein: The word segmentation processing includes word embedding processing.
7. The text processing method according to claim 6, wherein: The word embedding process is a word embedding process with sentiment tendency.
8. The text processing method according to claim 1, wherein: The calculating the evaluation result of the entity object according to the feature joint vector comprises: Performing abstract calculation on the feature joint vector to obtain at least one abstract feature vector identifying the evaluation of the text data on the entity object; An evaluation result of the text data for the entity object is calculated according to the abstract feature vector.
9. The text processing method according to claim 1, wherein: The performing attention calculation processing on the forward time series vector and the reverse time series vector to obtain the corresponding attention data respectively, and superimposing the forward time series vector and the reverse time series vector respectively based on the corresponding attention data, and taking the superimposed results as the first result includes: Performing attention calculation processing on each forward time series vector corresponding to the first word vector group and each reverse time series vector corresponding to the second word vector group to generate attention data of each forward time series feature vector and attention data of each reverse time series feature vector; Based on the attention data of the forward time series feature vector and the attention data of each reverse time series feature vector, the forward time series feature vector corresponding to the first word vector group and the reverse time series feature vector corresponding to the second word vector group are superimposed to obtain the first attention feature vector and the second attention feature vector of the entity object in the first word vector group and the second word vector group; The first attention feature vector and the second attention feature vector are output as the first result.
10. A text processing device, comprising: An input layer, used to obtain first text data, wherein the first text data contains at least one entity object; A preprocessing layer, configured to perform word segmentation processing on the first text data to generate a word vector for each word of the first text data; A time series algorithm processing layer, used for performing time series-based algorithm processing on the word vector to obtain a first result containing the time series features of the entity object in the first text data; wherein the word vector is divided into a first word vector group and a second word vector group, the first word vector group includes the word vector corresponding to the entity object and the word vectors of all words located on the left side of the entity object, and the second word vector group includes the word vector corresponding to the entity object and the word vectors of all words located on the right side of the entity object; in the time series-based algorithm processing, the first result is calculated according to all forward time series feature vectors corresponding to the first word vector group and all reverse time series feature vectors corresponding to the second word vector group; the calculation of the first result according to all forward time series feature vectors corresponding to the first word vector group and all reverse time series feature vectors corresponding to the second word vector group includes: performing attention calculation processing on the forward time series vector and the reverse time series vector to obtain the corresponding attention data respectively, and superimposing the forward time series vector and the reverse time series vector respectively based on the corresponding attention data to obtain the first attention feature vector and the second attention feature vector of the entity object in the first word vector group and the second word vector group, Outputting the first attention feature vector and the second attention feature vector as the first result; A context algorithm processing layer, used for performing context-based algorithm processing on the word vector to obtain a second result including context features of the entity object in the first text data; A vector merging layer, used for performing feature joint processing on the first result and the second result to generate a feature joint vector; The output layer is used to calculate the evaluation result of the entity object according to the feature joint vector, wherein the evaluation result identifies the evaluation tendency of the first text data for the entity object.
11. The text processing device according to claim 10, wherein: The timing algorithm layer is further used for: Dividing the word vector into a first word vector group and a second word vector group based on the position of the entity object in the first text data, wherein the first word vector group includes the word vector corresponding to the entity object and the word vectors of all words located on the left side of the entity object, and the second word vector group includes the word vector corresponding to the entity object and the word vectors of all words located on the right side of the entity object; Performing forward LTSM calculation and reverse LTSM calculation on all word vectors of the first text data respectively, so as to obtain a forward time sequence feature vector and a reverse time sequence feature vector of each word of the first text data, wherein the forward time sequence feature vector of each word includes evaluation contribution information of all words that are located before the word in time sequence, and the reverse time sequence feature vector of each word includes evaluation contribution information of all words that are located after the word in time sequence; and The first result is calculated based on all forward temporal feature vectors corresponding to the first word vector group and all reverse temporal feature vectors corresponding to the second word vector group.
12. The text processing device according to claim 10, wherein: The context algorithm processing layer is further used for: Dividing the word vector into a first word vector group and a second word vector group based on the position of the entity object in the first text data, wherein the first word vector group includes the word vector corresponding to the entity object and the word vectors of all words located on the left side of the entity object, and the second word vector group includes the word vector corresponding to the entity object and the word vectors of all words located on the right side of the entity object; Perform convolutional neural network calculations on the first word vector group, the second word vector group, and the word vectors of the first text data, respectively, to obtain a first feature vector group, a second feature vector group, and a third feature vector group of the first word vector group, the second word vector group, and the word vectors of the first text data, wherein the feature vectors in the first feature vector group correspond to the word vectors in the first word vector group, respectively, and include the contextual relationship of the word vectors in the first word vector group to the entity object, the feature vectors in the second feature vector group correspond to the word vectors in the second word vector group, respectively, and include the contextual relationship of the word vectors in the second word vector group to the entity object, and the feature vectors in the third feature vector group correspond to the word vectors of the text data, respectively, and include the contextual relationship of the word vectors of the text data to the entity object; Performing pooling processing on the feature vectors of the first feature vector group, the second feature vector group, and the third feature vector group, respectively, to obtain a first convolution result vector, a second convolution result vector, and a third convolution result vector corresponding to the first word vector group, the second word vector group, and the first text data, respectively; The first convolution result vector, the second convolution result vector and the third convolution result vector are output as the second result.
13. The text processing device according to claim 12, wherein: The pooling process comprises: An average value of the eigenvectors in the first eigenvector group, and an average value of the eigenvectors in the second eigenvector group and the third eigenvector group are calculated as the first convolution result vector, the second convolution result vector, and the third convolution result vector, respectively.
14. The text processing device according to claim 12, wherein: The pooling process comprises: The maximum value of the eigenvectors in the first eigenvector group, the maximum value of the eigenvectors in the second eigenvector group, and the maximum value of the eigenvectors in the third eigenvector group are respectively calculated as the second result.
15. The text processing device according to claim 10, wherein: The preprocessing layer is further used to perform word embedding processing on the first text data to generate a word vector for each word of the first text data.
16. The text processing device according to claim 15, wherein: The word embedding process is a word embedding process with sentiment tendency.
17. The text processing device according to claim 10, wherein: The output layer is further used to: Performing abstract calculation on the feature joint vector to obtain at least one abstract feature vector identifying the evaluation of the text data on the entity object; An evaluation result of the text data for the entity object is calculated according to the abstract feature vector.
18. The text processing device according to claim 10, wherein: The calculating the first result according to all forward temporal feature vectors corresponding to the first word vector group and all reverse temporal feature vectors corresponding to the second word vector group includes: Performing attention calculation processing on each forward time series vector corresponding to the first word vector group and each reverse time series vector corresponding to the second word vector group to generate attention data of each forward time series feature vector and attention data of each reverse time series feature vector; Based on the attention data of the forward time series feature vector and the attention data of each reverse time series feature vector, the forward time series feature vector corresponding to the first word vector group and the reverse time series feature vector corresponding to the second word vector group are superimposed to obtain the first attention feature vector and the second attention feature vector of the entity object in the first word vector group and the second word vector group; The first attention feature vector and the second attention feature vector are output as the first result.
19. An electronic device, wherein: include: Memory, used to store programs; A processor is used to run the program stored in the memory, and the program executes the text processing method as claimed in any one of claims 1 to 9 when it is run.
20. A computer-readable storage medium having stored thereon a computer program executable by a processor, wherein: When the program is executed by a processor, the text processing method according to any one of claims 1 to 9 is implemented.
Citation Information
Patent Citations
Emotion analysis method and system, computer terminal and storage medium
CN110705300A
Emotion analysis method and device, computer readable medium and electronic equipment
CN110826327A