A text analysis method and related device
By conducting semantic analysis and dependency tree construction on the comment text, combining semantic distance features and vector combinations, the problem of low accuracy of emotional polarity extraction in the existing technology is solved, and the extraction effect is improved.
Patent Information
- Application Number
- CN202210577374.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-25
- Publication Date
- 2025-06-27
- Estimated Expiration
- 2042-05-25
AI Technical Summary
The prior art is less accurate when extracting emotional polarity from comment texts, which affects the implementation effect of downstream applications.
By performing semantic analysis on the target text, a dependency tree is constructed, semantic distance characteristics are determined, and emotional polarity is extracted by combining aspect vector combinations and perspective vector combinations.
The accuracy of emotional polarity extracted from the comment text is improved, and the implementation effect of downstream applications related to the emotional extraction task is enhanced.
Smart Images

Figure CN115129868B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of artificial intelligence technology, and in particular, to a text analysis method and related device. Background Art
[0002] In recent years, aspect-based sentiment analysis (ABSA) has received increasing attention in the industry; as a fine-grained sentiment analysis task, ABSA aims to mine fine-grained opinion information for the things involved in the text.
[0003] The sentiment extraction task is the key in the ABSA task. The goal of this task is to extract elements such as aspects, opinions, and corresponding sentiment polarities in the review text. Among them, an aspect can be understood as the thing that the review text targets, an opinion is the view and attitude that the review text expresses towards the thing it comments on, and a sentiment polarity is the sentiment type to which the view expressed in the review text belongs, such as positive, negative, etc.
[0004] Currently, the effects achieved by the methods for performing the above sentiment extraction task in practical applications are generally not ideal, and the accuracy of the sentiment polarities extracted from the review text by many methods is relatively low; this will further affect the implementation effects of other downstream applications related to the sentiment extraction task. For example, it affects the reliability of services such as public opinion analysis services and consumer decision-making services. Summary of the Invention
[0005] Embodiments of this application provide a text analysis method and related device, which can effectively improve the accuracy of the sentiment polarities extracted from the review text, and thus contribute to improving the implementation effects of other downstream applications related to the sentiment extraction task.
[0006] In view of this, in the first aspect of this application, a text analysis method is provided, and the method includes:
[0007] Perform semantic analysis processing on the target text to obtain a dependency tree corresponding to the target text; the dependency tree includes nodes corresponding to each text unit in the target text, and the positional relationship between the nodes in the dependency tree is used to represent the semantic association relationship between the corresponding text units;
[0008] Determine the semantic distance feature of the target vector combination pair for the text units involved according to the dependency tree and the target vector combination pair; the target vector combination pair includes an aspect vector combination and an opinion vector combination, and the aspect vector combination and the opinion vector combination are generated based on the embedding vectors of at least one text unit in the target text; the semantic distance feature is used to characterize the semantic correlation between the text units involved in the aspect vector combination and the opinion vector combination respectively;
[0009] Determine the sentiment polarity of the target vector combination pair according to the aspect vector combination, the opinion vector combination, and the semantic distance feature.
[0010] The second aspect of the present application provides a text analysis device, and the device includes:
[0011] A semantic analysis module, configured to perform semantic analysis processing on a target text to obtain a dependency tree corresponding to the target text; the dependency tree includes nodes corresponding to each text unit in the target text, and the positional relationship between the nodes in the dependency tree is used to characterize the semantic association relationship between the corresponding text units;
[0012] A semantic distance determination module, configured to determine the semantic distance feature of the target vector combination pair for the text units involved according to the dependency tree and the target vector combination pair; the target vector combination pair includes an aspect vector combination and an opinion vector combination, and the aspect vector combination and the opinion vector combination are generated based on the embedding vectors of at least one text unit in the target text; the semantic distance feature is used to characterize the semantic correlation between the text units involved in the aspect vector combination and the opinion vector combination respectively;
[0013] A sentiment polarity determination module, configured to determine the sentiment polarity of the target vector combination pair according to the aspect vector combination, the opinion vector combination, and the semantic distance feature.
[0014] The third aspect of the present application provides a computer device, and the device includes a processor and a memory:
[0015] The memory is used to store a computer program;
[0016] The processor is configured to execute the steps of the text analysis method described in the first aspect above according to the computer program.
[0017] The fourth aspect of the present application provides a computer-readable storage medium, and the computer-readable storage medium is used to store a computer program, and the computer program is used to execute the steps of the text analysis method described in the first aspect above.
[0018] A fifth aspect of the present application provides a computer program product or a computer program, which includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the steps of the text analysis method described in the first aspect above.
[0019] As can be seen from the above technical solutions, the embodiments of the present application have the following advantages:
[0020] The embodiments of the present application provide a text analysis method. In this method, semantic analysis processing is first performed on a target text to be analyzed to obtain a dependency tree corresponding to the target text; the dependency tree includes nodes corresponding to each text unit in the target text, and the positional relationship between the nodes in the dependency tree can reflect the semantic association relationship between the corresponding text units; then, according to the above dependency tree and the target vector combination for the involved text units, the semantic distance feature of the target vector combination can be determined. The target vector combination includes an aspect vector combination and an opinion vector combination, and both the aspect vector combination and the opinion vector combination are generated based on the embedding vectors of at least one text unit in the target text. The semantic distance feature can reflect the semantic correlation between the text units involved in the aspect vector combination and the opinion vector combination respectively; furthermore, according to the aspect vector combination and the opinion vector combination included in the target vector combination, and the semantic distance feature of the target vector combination, the sentiment polarity of the target vector combination can be determined. When extracting the sentiment polarity based on the target vector combination, the semantic distance feature of the target vector combination is innovatively introduced; the semantic distance feature is determined based on the dependency tree obtained by performing semantic analysis processing on the target text, and it can accurately reflect the semantic correlation between the text units involved in the aspect vector combination and the opinion vector combination in the target vector combination; taking the semantic distance feature as one of the factors considered when extracting the sentiment polarity is equivalent to comprehensively considering the semantic association relationship of relevant text units in the target text when extracting the sentiment polarity, and the semantic association relationship has high reference value for extracting the sentiment polarity. Therefore, the accuracy of the extracted sentiment polarity can be effectively improved. Correspondingly, the implementation effect of other downstream applications related to the sentiment extraction task can also be improved. Description of the Drawings
[0021] Figure 1 It is a schematic diagram of the application scenario of the text analysis method provided by the embodiments of the present application;
[0022] Figure 2 It is a schematic diagram of the flow of the text analysis method provided by the embodiments of the present application;
[0023] Figure 3 A schematic diagram of an exemplary dependency tree provided by an embodiment of the present application;
[0024] Figure 4 A schematic flowchart of generating a target vector combination pair provided by an embodiment of the present application;
[0025] Figure 5 A schematic diagram of implementing the determination of word embedding vectors for each word segment in the target text provided by an embodiment of the present application;
[0026] Figure 6 A schematic flowchart of classifying a text unit vector combination provided by an embodiment of the present application;
[0027] Figure 7 A schematic diagram of an exemplary undirected graph provided by an embodiment of the present application;
[0028] Figure 8 A schematic diagram of an exemplary semantic distance mapping relationship provided by an embodiment of the present application;
[0029] Figure 9 A schematic flowchart of extracting sentiment polarity for a target vector combination pair provided by an embodiment of the present application;
[0030] Figure 10 A schematic diagram of the implementation architecture of the text analysis method provided by an embodiment of the present application;
[0031] Figure 11 A schematic diagram of the structure of the text analysis device provided by an embodiment of the present application;
[0032] Figure 12 A schematic diagram of the structure of the terminal device provided by an embodiment of the present application;
[0033] Figure 13 A schematic diagram of the structure of the server provided by an embodiment of the present application. Detailed implementation manners
[0034] In order to enable those skilled in the art to better understand the solutions of the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present application.
[0035] The terms "first", "second", "third", "fourth", etc. (if any) in the description, claims and the above-mentioned drawings of this application are used to distinguish similar objects and do not necessarily describe a specific order or sequence. It should be understood that the data used in this way can be interchanged under appropriate circumstances so that the embodiments of this application described here can be implemented in an order different from those illustrated or described here. In addition, the terms "comprising" and "having" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device that includes a series of steps or units does not necessarily have to be limited to those steps or units clearly listed, but may include other steps or units not clearly listed or inherent to these processes, methods, products or devices.
[0036] Artificial Intelligence (AI) is a theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results. In other words, artificial intelligence is a comprehensive technology in computer science. It attempts to understand the essence of intelligence and produce a new intelligent machine that can react in a way similar to human intelligence. Artificial intelligence also studies the design principles and implementation methods of various intelligent machines to enable the machines to have the functions of perception, reasoning and decision-making.
[0037] Artificial intelligence technology is an interdisciplinary subject with a wide range of fields, including both hardware-level and software-level technologies. The basic technologies of artificial intelligence generally include technologies such as sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, big data processing technology, operation / interaction systems, and mechatronics. The software technologies of artificial intelligence mainly include several major directions such as computer vision technology, speech processing technology, natural language processing technology, and machine learning / deep learning, autonomous driving, and intelligent transportation.
[0038] Natural Language Processing (NLP) is an important direction in the fields of computer science and artificial intelligence. It studies various theories and methods that can achieve effective communication between humans and computers in natural language. Natural language processing is a science that integrates linguistics, computer science, and mathematics. Therefore, the research in this field will involve natural language, that is, the language that people use in daily life, so it has a close connection with the research of linguistics. Natural language processing technology usually includes technologies such as text processing, semantic understanding, machine translation, robot question answering, and knowledge graphs.
[0039] The solution provided by the embodiments of this application relates to the natural language processing technology of artificial intelligence and is specifically described through the following embodiments:
[0040] In related technologies, the sentiment polarities extracted from review texts by methods for performing sentiment extraction tasks are generally not accurate enough. To improve the accuracy of the sentiment polarities extracted from review texts, an embodiment of the present application provides a text analysis method. In the process of extracting sentiment polarities, this method innovatively introduces the semantic relevance between relevant text units, and improves the accuracy of the extracted sentiment polarities by means of this semantic relevance.
[0041] Specifically, in the text analysis method provided by the embodiment of the present application, semantic analysis processing is first performed on the target text to be analyzed to obtain a dependency tree corresponding to the target text; the dependency tree includes nodes corresponding to each text unit in the target text, and the positional relationship between the nodes in the dependency tree can represent the semantic association relationship between the corresponding text units. Then, according to the above dependency tree and the target vector combination for the involved text units, the semantic distance feature of the target vector combination pair can be determined; the target vector combination pair here includes an aspect vector combination and an opinion vector combination, both of which are generated based on the embedding vectors of at least one text unit in the target text, and the semantic distance feature here can represent the semantic relevance between the text units involved in the aspect vector combination and the opinion vector combination respectively; furthermore, according to the aspect vector combination and the opinion vector combination included in the target vector combination pair, and the semantic distance feature of the target vector combination pair, the sentiment polarity of the target vector combination pair can be determined.
[0042] When the above text analysis method extracts sentiment polarities based on the target vector combination pair, the semantic distance feature of the target vector combination pair is innovatively introduced; this semantic distance feature is determined based on the dependency tree obtained by performing semantic analysis processing on the target text, and it can accurately reflect the semantic relevance between the text units involved in the aspect vector combination and the opinion vector combination in the target vector combination pair. Taking this semantic distance feature as one of the factors considered when extracting sentiment polarities is equivalent to comprehensively considering the semantic association relationship of relevant text units in the target text when extracting sentiment polarities, and the semantic association relationship has high reference value for extracting sentiment polarities. Therefore, it can effectively improve the accuracy of the extracted sentiment polarities. Correspondingly, the implementation effects of other downstream applications related to the sentiment extraction task can also be improved.
[0043] It should be understood that the text analysis method provided by the embodiments of the present application can be executed by a computer device with natural language processing capabilities, and the computer device can be a terminal device or a server. Among them, the terminal device includes but is not limited to mobile phones, computers, intelligent voice interaction devices, smart home appliances, vehicle-mounted terminals, aircraft, etc. The server can specifically be an application server or a Web server. In actual deployment, it can be an independent server or a cluster server or a cloud server composed of multiple physical servers.
[0044] To facilitate the understanding of the text analysis method provided by the embodiments of the present application, the following takes the execution entity of the text analysis method as a server as an example to give an exemplary introduction to the application scenario of the text analysis method.
[0045] See Figure 1 , Figure 1 which is a schematic diagram of the application scenario of the text analysis method provided by the embodiments of the present application. As Figure 1 shown, this application scenario includes a server 110 and a database 120; the server 110 can access the database 120 through a network, or the database 120 can also be integrated in the server 110. Among them, the server 110 is used to execute the method provided by the embodiments of the present application to extract the sentiment polarity for the target text to be analyzed; the database 120 is used to store the text based on which the sentiment extraction task is performed, such as the review text published by the user on the network platform, etc.
[0046] In actual application, the server 110 can retrieve the target text to be analyzed from the database 120 according to actual needs; for example, when the server 110 needs to perform public opinion analysis on a certain topic, the server 110 can retrieve the text related to the topic from the database 120 as the target text.
[0047] After the server 110 obtains the target text, it can perform semantic analysis processing on the target text to obtain the dependency tree corresponding to the target text. It should be noted that the semantic analysis processing here is a processing method for analyzing the semantic association relationship between each text unit in the text; by performing semantic analysis processing on the target text, the semantic association relationship between each text unit in the target text can be determined accordingly, such as determining the root text unit in the target text (i.e., the core text unit in the target text) and the text unit to which other non-root text units in the target text belong; according to the semantic association relationship between each text unit in the target text, the dependency tree corresponding to the target text can be constructed accordingly. The dependency tree includes nodes corresponding to each text unit in the target text, and the positional relationship between the nodes in the dependency tree reflects the semantic association relationship between the corresponding text units.
[0048] After the server 110 generates the dependency tree corresponding to the target text, it can use this dependency tree to determine the semantic distance feature for the target vector combination pair generated based on the target text. It should be noted that the target vector combination pair generated based on the target text usually includes an aspect vector combination and an opinion vector combination; among them, the aspect vector combination is a vector combination of text units classified as the aspect type, and the opinion vector combination is a vector combination of text units classified as the opinion type. These vector combinations of text units are all constructed based on the embedding vectors of at least one text unit in the target text. When the server 110 determines the semantic distance feature for the target vector combination pair, it can first determine the text units involved in the aspect vector combination and the opinion vector combination in the target vector combination pair, and determine the nodes corresponding to these text units on the dependency tree corresponding to the target text. Furthermore, according to the positional relationship of these nodes on the dependency tree, it determines the semantic distance feature of the target vector combination pair; it should be understood that since the positional relationship between the nodes on the dependency tree can reflect the semantic association relationship between the corresponding text units, therefore, the semantic distance feature of the target vector combination pair determined by the above method can also correspondingly reflect the semantic correlation between the text units involved in the aspect vector combination and the opinion vector combination in the target vector combination pair.
[0049] Furthermore, the server 110 can determine the sentiment polarity of the target vector combination pair according to the aspect vector combination and the opinion vector combination included in the target vector combination pair, and the semantic distance feature of the target vector combination pair determined by the above method. That is, in the process of extracting the sentiment polarity for the target vector combination pair, the semantic correlation between the text units involved in the aspect vector combination and the opinion vector combination in the target vector combination pair is introduced, so as to improve the accuracy of the extracted sentiment polarity.
[0050] After the server 110 determines the sentiment polarity of the target vector combination pair, it can use the text units involved in the aspect vector combination in the target vector combination pair (i.e., aspect text units), the text units involved in the opinion vector combination (i.e., opinion text units), and the extracted sentiment polarity to form a sentiment extraction triple; furthermore, based on this sentiment extraction triple, it performs related downstream application tasks, such as public opinion analysis tasks, etc.
[0051] It should be understood, Figure 1 The application scenario shown is only an example. In actual applications, the text analysis method provided in the embodiments of the present application can also be applied to other scenarios; for example, the server 110 can also obtain the target text to be analyzed in other ways (such as directly obtaining the review text published by the relevant object). No limitation is imposed on the application scenario of the text analysis method provided in the embodiments of the present application here.
[0052] The text analysis method provided by the present application will be introduced in detail below through method embodiments.
[0053] See Figure 2 , Figure 2 which is a schematic flowchart of the text analysis method provided by the embodiments of the present application. For ease of description, the following embodiments still take the server as the execution subject of the text analysis method as an example for introduction. As Figure 2 shown, the text analysis method includes the following steps:
[0054] Step 201: Perform semantic analysis processing on the target text to obtain a dependency tree corresponding to the target text; the dependency tree includes nodes corresponding to each text unit in the target text, and the positional relationship between the nodes in the dependency tree is used to represent the semantic association relationship between the corresponding text units.
[0055] In the embodiments of the present application, when the server performs an emotion extraction task for the target text, it can first perform semantic analysis processing on the target text to construct a dependency tree corresponding to the target text. The dependency tree includes nodes corresponding to each text unit in the target text, and the positional relationship between the nodes in the dependency tree can represent the semantic association relationship between the corresponding text units.
[0056] It should be noted that the target text in the embodiments of the present application can be any text used as a basis for performing an emotion extraction task. For example, the target text can be text published by an object on a social network platform (such as a review text for a certain event or topic), or it can be a review text published by an object on a shopping network platform for a certain product, or it can be text randomly crawled on the Internet, etc.; the present application does not make any restrictions on the type and source of the target text.
[0057] In practical applications, the server can obtain the above-mentioned target text from a relevant database; for example, for many network platforms, the text published by a user through the network platform is usually stored in the corresponding database. Correspondingly, the server can extract the target text to be analyzed from the database; when the server specifically extracts the target text, it can be extracted according to the downstream application faced by the emotion extraction task. For example, assuming that the downstream application faced by the emotion extraction task is to perform public opinion analysis on a certain topic, the server can extract text related to the topic from the database as the target text. Or, the server can also directly intercept the text published by the user through the network platform as the target text. The present application does not make any restrictions on the way the server obtains the target text.
[0058] It should be noted that the semantic analysis process performed on the target text is a processing method for analyzing the semantic association relationships between various text units in the target text; common semantic analysis processing methods include, but are not limited to, dependency syntactic analysis processing. By performing semantic analysis processing on the target text, the semantic association relationships between various text units in the target text can be determined, such as determining the root text unit in the target text (i.e., the core text unit that is not attached to other text units in the target text), and the text unit to which other non-root text units in the target text are attached. Furthermore, based on the semantic association relationships between various text units in the target text, a dependency tree corresponding to the target text can be constructed; the dependency tree is a tree-like structure used to represent the syntactic relationships between text units in the target text, including the nodes corresponding to each text unit in the target text, and the positional relationships between the nodes reflect the semantic association relationships between the corresponding text units. For example, assuming that the node corresponding to text unit a in the dependency tree is the parent node of the node corresponding to text unit b, then it indicates that in the target text, text unit b is used to modify text unit a, and text unit b belongs to the attached text unit of text unit a; it should be understood that in the dependency tree, the farther the distance between two nodes, the lower the semantic association degree between the text units corresponding to the two nodes, and the closer the distance between two nodes, the higher the semantic association degree between the text units corresponding to the two nodes.
[0059] It should be understood that the text units in the target text are divided according to actual needs, and the text units can be, for example, word segments, characters, phrases, etc. This application does not make any limitations on the text units here.
[0060] In a possible implementation manner, the server can perform semantic analysis processing on the target text in the following way to obtain a dependency tree corresponding to the target text: perform dependency syntactic analysis processing on the target text to determine the respective dependency relationships of various text units in the target text; the dependency relationships here are used to characterize whether the corresponding text unit corresponds to the root node of the dependency tree, and to characterize the parent text unit associated with the text unit in the target text when the text unit does not correspond to the root node; furthermore, based on the respective dependency relationships of various text units in the target text, generate a dependency tree corresponding to the target text.
[0061] Exemplarily, the server can call a dependency parsing tool (such as the Stanford CoreNLP tool, the spaCy tool, etc.) to perform dependency parsing on the target text and determine the corresponding dependency relationships of each text unit in the target text. Specifically, for each text unit in the target text, the server can determine whether it corresponds to the root node in the dependency tree, that is, determine whether it is the root text unit in the target text. The so-called root text unit is the core text unit in the target text that is not subordinate to other text units. Usually, there is only one root text unit in a text; if it is determined that the text unit is the root text unit in the target text, it can be directly used as the root node in the dependency tree; if it is determined that the text unit is not the root text unit in the target text, it is necessary to further determine the text unit to which the text unit is subordinate in the target text, and the text unit to which the text unit is subordinate can be regarded as the parent text unit of the text unit; it should be noted that in a text, if text unit a modifies text unit b, then it can be considered that text unit a is subordinate to text unit b, that is, text unit b is the parent text unit of text unit a.
[0062] After the server determines the corresponding dependency relationships of each text unit in the target text through the above method, it can construct the dependency tree corresponding to the target text according to the corresponding dependency relationships of each text unit. Specifically, the server can directly use the root text unit in the target text as the root node of the dependency tree; then, according to the dependency relationships corresponding to other non-root text units, construct the connection relationships between the corresponding nodes in the dependency tree. For example, assuming that text unit c in the target text is the parent text unit of text unit d, a connection edge can be constructed in the dependency tree from the node corresponding to text unit d to the node corresponding to text unit c.
[0063] Taking the target text "This battery has a long lifespan" as an example, the server can construct the Figure 3 dependency tree as shown. As Figure 3 shown, for the target text "This battery has a long lifespan", among them, "battery" is the root text unit, "lifespan" is the text unit subordinate to "battery", "long" is the text unit subordinate to "lifespan", "lifespan" is the text unit subordinate to "this", and "this" is the text unit subordinate to "model".
[0064] In this way, by performing dependency parsing on the target text to obtain the dependency tree corresponding to the target text, the semantic association relationship between each text unit in the target text can be determined efficiently and accurately, ensuring that the constructed dependency tree accurately reflects the semantic association degree between each text unit in the target text, which is conducive to accurately extracting the sentiment polarity accordingly in the subsequent process.
[0065] Step 202: Determine the semantic distance feature of the target vector combination pair for the involved text units according to the dependency tree and the target vector combination pair; the target vector combination pair includes an aspect vector combination and an opinion vector combination, and the aspect vector combination and the opinion vector combination are generated based on the embedding vectors of at least one text unit in the target text; the semantic distance feature is used to characterize the semantic correlation between the text units involved in the aspect vector combination and the opinion vector combination respectively.
[0066] After the server constructs the dependency tree corresponding to the target text, it can rely on this dependency tree to determine the semantic distance feature for the target vector combination pair generated based on the target text. Specifically, the server can determine the semantic distance feature of the target vector combination pair according to the dependency tree corresponding to the target text and the text units involved in the aspect vector combination and the opinion vector combination included in the target vector combination pair respectively. This semantic distance feature is used to reflect the semantic correlation between the text units involved in the aspect vector combination and the opinion vector combination included in this target vector combination pair.
[0067] It should be noted that the target vector combination pair generated based on the target text includes an aspect vector combination and an opinion vector combination. Among them, the aspect vector combination is a vector combination of text units classified as aspect types, and the opinion vector combination is a vector combination of text units classified as opinion types; the text units involved in the vector combination of text units classified as aspect types usually correspond to the aspect elements in the target text (which can also be understood as the main object in the target text, that is, the main object commented on in the target text); the text units involved in the vector combination of text units classified as opinion types usually correspond to the opinion elements in the target text (which can also be understood as the opinion attitude expressed by the target text towards the main object). In the embodiments of the present application, whether it is the vector combination of text units classified as aspect types or the vector combination of text units classified as opinion types, they are all generated based on the embedding vectors of at least one text unit in the target text.
[0068] The semantic distance feature of the target vector combination pair is determined according to the positional relationship between the nodes corresponding to the text units involved in the aspect vector combination and the opinion vector combination included in this target vector combination pair in the dependency tree; since the positional relationship between the nodes in the dependency tree can reflect the semantic association relationship between the corresponding text units, therefore, the semantic distance feature of this target vector combination pair can correspondingly reflect the semantic correlation between the text units involved in the aspect vector combination and the opinion vector combination therein.
[0069] The generation method of the above target vector combination pair will be introduced in detail below. See Figure 4 , Figure 4The flowchart for generating a target vector pair provided by an embodiment of the present application is as follows Figure 4 As shown, the process includes the following steps:
[0070] Step 401: Split the target text to obtain each text unit in the target text; determine the embedding vector of each text unit in the target text.
[0071] Before the server generates a target vector pair based on the target text, it is necessary to first split the target text to obtain each text unit in the target text. For example, the server can split the target text with word segmentation as the splitting unit to obtain each word segment in the target text; of course, the server can also split the target text based on other splitting units to obtain each text unit in the target text, and no limitation is imposed on the splitting unit based on which the target text is split here. In the embodiment of the present application, it is necessary to ensure that the text unit based on which the dependency tree corresponding to the target text is constructed corresponds to the text unit split in this step.
[0072] After the server obtains each text unit in the target text, it can further determine the embedding vector of each text unit in the target text. Exemplarily, taking the example of splitting the target text to obtain each word segment in the target text, the server can map each word segment in the target text to a corresponding sparse coding feature (such as a digital token) through a pre-constructed dictionary, and then, through a pre-trained long short-term memory network (LSTM), process the digital token of each word segment to obtain the hidden unit representation of each word segment in the target text, that is, the word embedding vector of each word segment; Figure 5 The figure shows an implementation diagram for determining the word embedding vector of each word segment in the target text. For example, for the word segments x1, x2, x3, ……, xt in the target text, the corresponding word embedding vectors are determined to be h1, h2, h3, ……, ht respectively.
[0073] It should be understood that in practical applications, in addition to determining the embedding vector of the text unit through the above LSTM structure, other model structures can also be used to determine the embedding vector of the text unit. For example, a model combining Transformer with other network structures can be used to determine the embedding vector of the text unit, or it can be replaced with other network structures (such as a convolutional neural network, a gated convolutional neural network, etc.). The present application does not impose any limitation on the method for determining the embedding vector of the text unit.
[0074] Step 402: Based on a preset text unit combination rule, generate multiple text unit vector combinations according to the respective embedding vectors of each text unit in the target text.
[0075] After the server obtains the respective embedding vectors of each text unit in the target text, it can, based on a preset text unit combination rule, combine the embedding vectors of at least one text unit in the target text to obtain a text unit vector combination; exemplarily, the server can use methods such as n-gram to combine the embedding vectors of text units at different positions in the target text to obtain a text unit vector combination, and the text unit vector combination can also be referred to as a span in the embodiments of the present application.
[0076] In a possible implementation manner, the server can generate the above text unit vector combination in the following way: for each text unit in the target text, determine the reference text unit associated with the text unit in the target text according to the text unit combination range indicated by the text unit combination rule; then, for each reference text unit, construct the text unit vector combination corresponding to the reference text unit according to the embedding vector of the text unit, the embedding vectors of the text units between the text unit and the reference text unit in the target text, the embedding vector of the reference text unit, and the distance between the text unit and the reference text unit in the target text.
[0077] Taking the text units included in the target text as x1, x2, x3, x4, ……, xt in sequence, the respective embedding vectors corresponding to these text units are h1, h2, h3, h4, ……, ht, and the text unit combination range indicated by the text unit combination rule is 1 to 3 text units as an example.
[0078] When constructing a text unit vector combination for text unit x1, a text unit vector combination involving only one text unit can be constructed first (corresponding to a text unit combination range of 1 text unit). At this time, the constructed text unit vector combination is [h1, f(1)], where h1 is the embedding vector of text unit x1 itself, and f(1) is the length representation of the constructed text unit vector combination, that is, it indicates that it only includes the embedding vectors of one text unit. Then, a text unit vector combination involving two text units can be constructed (corresponding to a text unit combination range of 2 text units). At this time, the determined reference text unit is text unit x2, and the constructed text unit vector combination is [h1, h2, f(2)], where h1 and h2 are the embedding vectors of text unit x1 and text unit x2 respectively, and f(2) is the length representation of the constructed text unit vector combination, that is, it indicates that it includes the embedding vectors of two text units. Furthermore, a text unit vector combination involving three text units can be constructed (corresponding to a text unit combination range of 3 text units). At this time, the determined reference text unit is text unit x3, and the constructed text unit vector combination is [h1, h2, h3, f(3)], where h1, h2, and h3 are the embedding vectors of text unit x1, text unit x2, and text unit x3 respectively, and f(3) is the length representation of the constructed text unit vector combination, that is, it indicates that it includes the embedding vectors of three text units.
[0079] Similarly, when constructing a text unit vector combination for text unit x2, a text unit vector combination involving only one text unit can be constructed first, that is, the text unit vector combination is [h2, f(1)], where h2 is the embedding vector of text unit x2 itself, and f(1) is the length representation of the constructed text unit vector combination. Then, a text unit vector combination involving two text units can be constructed, that is, the text unit vector combination [h2, h3, f(2)], where h2 and h3 are the embedding vectors of text unit x2 and text unit x3 respectively, and f(2) is the length representation of the constructed text unit vector combination. Furthermore, a text unit vector combination involving three text units can be constructed, that is, the text unit vector combination [h2, h3, h4, f(3)], where h2, h3, and h4 are the embedding vectors of text unit x2, text unit x3, and text unit x4 respectively, and f(3) is the length representation of the constructed text unit vector combination. And so on, the server can construct text unit vector combinations that meet the respective text unit combination ranges based on each text unit in the target text.
[0080] In this way, through the above method, the server can traverse and construct a combination of text unit vectors that meets the range of text unit combinations indicated by the text unit combination rule based on the embedding vectors of each text unit in the target text, which is conducive to more comprehensively and completely performing the sentiment extraction task based on the target text.
[0081] Step 403: Classify each of the multiple text unit vector combinations respectively, determine the text unit vector combination belonging to the aspect type as the aspect vector combination, and determine the text unit vector combination belonging to the opinion type as the opinion vector combination.
[0082] After the server constructs multiple text unit vector combinations based on the target text, it can further classify each text unit vector combination to determine whether each text unit vector combination belongs to the text unit vector combination of the aspect type (i.e., the aspect vector combination) or the text unit vector combination of the opinion type (i.e., the opinion vector combination).
[0083] In a possible implementation manner, the server can determine the probability that the text unit vector combination belongs to an invalid vector combination, the probability that it belongs to the aspect type, and the probability that it belongs to the opinion type for each text unit vector combination; then, according to the probability that the text unit vector combination belongs to an invalid vector combination, the probability that it belongs to the aspect type, and the probability that it belongs to the opinion type, determine the type to which the text unit vector combination belongs; if the text unit vector combination belongs to an invalid vector combination, discard the text unit vector combination; if the text unit vector combination belongs to the aspect type, determine it as the aspect vector combination; if the text unit vector combination belongs to the opinion type, determine it as the opinion vector combination.
[0084] Exemplarily, Figure 6 is a schematic flowchart of the classification process for the text unit vector combination provided by the embodiment of the present application. As Figure 6As shown, the server may input the combined text unit vectors obtained in step 402 into a pre-trained neural network classifier. The neural network classifier may include, for example, a two-layer fully connected neural network, a relu non-linear activation function, and a softmax layer. By analyzing and processing the input combined text unit vectors, the neural network classifier can correspondingly output the probability that the combined text unit vectors belong to an invalid vector combination, the probability of belonging to an aspect type, and the probability of belonging to an opinion type. Furthermore, the server may determine whether the combined text unit vectors belong to an invalid vector combination (i.e., the combination of text units involved neither belongs to the text unit combination of the aspect type nor belongs to the text unit combination of the opinion type), an aspect vector combination, or an opinion vector combination based on the probability that the combined text unit vectors belong to an invalid vector combination, the probability of belonging to an aspect type, and the probability of belonging to an opinion type. For the combined text unit vectors belonging to an invalid vector combination, the server may directly discard them and no longer use them for subsequent processing.
[0085] It should be understood that the structure of the neural network classifier for determining the type of the combined text unit vectors described above is only an example. In practical applications, classifiers with other structures may also be designed according to actual needs to classify the combined text unit vectors. The present application does not impose any limitations on the structure of the neural network classifier for determining the type of the combined text unit vectors.
[0086] Step 404: Construct the target vector combination pairs based on each aspect vector combination and each opinion vector combination; each target vector combination pair includes an aspect vector combination and an opinion vector combination.
[0087] After the server determines each aspect vector combination and each opinion vector combination through the above classification process, it may combine each aspect vector combination and each opinion vector combination pairwise to construct each target vector combination pair; it should be understood that each constructed target vector combination pair includes an aspect vector combination and an opinion vector combination, and at least one aspect vector combination or one opinion vector combination in different target vector combination pairs is different.
[0088] In this way, through the above method, the target vector combination pairs for performing the sentiment extraction task are constructed for the target text; on the one hand, it can ensure a relatively comprehensive coverage of the possible text unit combinations in the target text and avoid missing possible text unit combinations when performing the sentiment extraction task; on the other hand, it can also filter out invalid vector combinations that are not helpful for the sentiment extraction task during the process of constructing the target vector combination pairs, avoiding unnecessary resource waste caused by processing invalid vector combinations in the subsequent sentiment extraction task and affecting the sentiment extraction efficiency.
[0089] It should be noted that the above Figure 4 The implementation process of generating the target vector combination pair shown can be executed before constructing the corresponding dependency tree for the target text (i.e., step 201), can also be executed after step 201, or can be executed simultaneously with step 201. This application does not make any limitation on the generation timing of the target vector combination pair here.
[0090] Next, the implementation method for determining the semantic distance feature of the target vector combination pair based on the dependency tree will be introduced. The embodiments of this application provide two determination methods for the semantic distance feature of the target vector combination pair, and the following will introduce these two determination methods in detail respectively.
[0091] In the first method, the server can first construct the semantic distance mapping relationship corresponding to the target text based on the dependency tree corresponding to the target text, and then, according to this semantic distance mapping relationship, determine the semantic distance feature of the target vector combination pair. Specifically, the server can first convert the dependency tree corresponding to the target text into a corresponding undirected graph and determine the shortest distance between every two nodes in this undirected graph; then, the server can construct the semantic distance mapping relationship corresponding to the target text according to the shortest distance between every two nodes in this undirected graph and the text unit corresponding to each node in this undirected graph. This semantic distance mapping relationship can represent the semantic distance between every two text units in the target text; finally, the server can determine the semantic distance feature of the target vector combination pair according to this semantic distance mapping relationship and the text units involved in the aspect vector combination and the opinion vector combination included in the target vector combination pair.
[0092] In the embodiments of this application, the dependency tree corresponding to the target text constructed through step 201 is a directed tree structure, and there are directed connection edges between the nodes in this dependency tree, that is, the node corresponding to a certain text unit in the dependency tree will point to the node corresponding to its parent text unit. In order to make the semantic association relationship between the text units in the target text be reflected more simply and intuitively, the server can convert the dependency tree into a corresponding undirected graph, that is, cancel the direction of the connection edges in the dependency tree. The positional relationship between the nodes in this undirected graph can also represent the semantic association relationship between the corresponding text units. Taking Figure 3 the shown dependency tree as an example, this dependency tree can be converted into Figure 7 the shown undirected graph, in Figure 7In the undirected graph shown, for the text units "section" and "battery", although they appear adjacent in the target text, since the semantic relevance between them is weak, the nodes corresponding to them are far apart in the undirected graph. For the text units "life", "long", and "this", the semantic relevance between these text units and the text unit "battery" is strong, so in the undirected graph, they are closer to the node corresponding to the text unit "battery".
[0093] After the server converts the dependency tree into a corresponding undirected graph, it can determine the shortest distance between every two nodes in the undirected graph. The so-called shortest distance between two nodes can be understood as the minimum number of connecting edges required to go from one node to another. Exemplarily, for every two nodes in the undirected graph, the server can use the corresponding shortest path algorithm to calculate the shortest distance between them; for example, in a scenario where the time complexity requirement is not high, the Floyd algorithm can be used to determine the shortest distance between every two nodes in the undirected graph; or for another example, in a scenario where the time complexity requirement is high, a more efficient shortest path algorithm (such as Dijkstra's algorithm, SPFA algorithm, Bellman-Floyd algorithm, etc.) can be used to determine the shortest distance between every two nodes in the undirected graph.
[0094] Furthermore, the server can construct a semantic distance mapping relationship corresponding to the target text based on the shortest distance between every two nodes in the undirected graph and the text unit corresponding to each node. Still taking the target text "This section of battery has a long life" as an example, based on Figure 7 the undirected graph shown, the following can be constructed Figure 8 the semantic distance mapping relationship shown. This semantic distance mapping relationship includes the shortest distance in the undirected graph between the nodes corresponding to every two text units in the target text, that is, the semantic distance; for example, for the text units "this" and "section", the shortest distance between the nodes corresponding to them in the undirected graph is 1, and for the text units "this" and "battery", the shortest distance between the nodes corresponding to them in the undirected graph is 2, and so on.
[0095] After the server constructs the semantic distance mapping relationship corresponding to the above target text, it can, based on this semantic distance mapping relationship, determine the semantic distance feature for each pair of target vector combinations. Specifically, the server can construct candidate text unit pairs based on the text units involved in the aspect vector combination and the text units involved in the opinion vector combination in the pair of target vector combinations; each candidate text unit pair includes a text unit involved in the aspect vector combination and a text unit involved in the opinion vector combination; for each candidate text unit pair, the server can look up the semantic distance between the two text units included in it in the semantic distance mapping relationship as the semantic distance of this candidate text unit pair; furthermore, among the semantic distances of each candidate text unit pair, the server can determine the shortest semantic distance as the semantic distance feature of this pair of target vector combinations.
[0096] Still taking the target text "This battery has a long lifespan" as an example, in a pair of target vector combinations constructed based on this target text, it includes an aspect vector combination corresponding to "battery lifespan" and an opinion vector combination corresponding to "long". The text units involved in this aspect vector combination include "battery" and "lifespan", and the text unit involved in this opinion vector combination only includes "long". The server combines each text unit involved in this aspect vector combination with each text unit involved in this opinion vector combination pairwise, and two candidate text unit pairs can be obtained. The first candidate text unit pair includes the text units "battery" and "long", and the second candidate text unit pair includes the text units "lifespan" and "long". For the first candidate text unit pair, the server can look up in the semantic distance mapping relationship corresponding to the target text that the semantic distance between the text unit "battery" and the text unit "long" is 2, that is, determine that the semantic distance of this first candidate text unit pair is 2; for the second candidate text unit pair, the server can look up in the semantic distance mapping relationship corresponding to the target text that the semantic distance between the text unit "lifespan" and the text unit "long" is 1, that is, determine that the semantic distance of this second candidate text unit pair is 1. Furthermore, the server can determine the shortest semantic distance among the semantic distances of these two candidate text unit pairs as the semantic distance feature of this pair of target vector combinations, that is, determine that the semantic distance feature of this pair of target vector combinations is 1.
[0097] In this way, through the above method, first construct the semantic distance mapping relationship corresponding to the target text based on the undirected graph, and then further look up the semantic distance feature of each pair of target vector combinations based on this semantic distance mapping relationship, which can improve the efficiency of determining the semantic distance feature of the pair of target vector combinations and shorten the time required to determine the semantic distance feature of the pair of target vector combinations.
[0098] In the second approach, the server can directly determine the semantic distance feature for each target vector combination based on the dependency tree corresponding to the target text. Specifically, the server can first convert the dependency tree corresponding to the target text into a corresponding undirected graph; then, according to the node positions corresponding to the text units involved in the aspect vector combination and the opinion vector combination in the target vector combination pair in the undirected graph, determine the semantic distance feature of the target vector combination pair.
[0099] In this implementation, the server can use the method of converting the dependency tree into an undirected graph introduced above to convert the dependency tree corresponding to the target text into a corresponding undirected graph. When determining the semantic distance feature for a certain target vector combination pair, the server can first determine the text units involved in the direction combination vector and the opinion combination vector included in the target vector combination pair, and determine the corresponding nodes of these text units in the undirected graph; furthermore, the server can determine the semantic distance feature of the target vector combination pair according to the positional relationship of these nodes in the undirected graph.
[0100] More specifically, when the server determines the semantic distance feature for the target vector combination pair, it can construct candidate text unit pairs based on the text units involved in the aspect vector combination and the text units involved in the opinion vector combination therein. Each candidate text unit pair includes a text unit involved in the aspect vector combination and a text unit involved in the opinion vector combination; for each candidate text unit pair, the server can determine the shortest distance between the node positions corresponding to the two text units included in it in the undirected graph as the semantic distance of the candidate text unit pair; furthermore, the server can determine the shortest semantic distance among the semantic distances of each candidate text unit pair as the semantic distance feature of the target vector combination pair.
[0101] Still taking the target text "This battery has a long lifespan" as an example, in a target vector combination pair constructed based on this target text, it includes an aspect vector combination corresponding to "battery lifespan" and an opinion vector combination corresponding to "long". The text units involved in the aspect vector combination include "battery" and "lifespan", and the text unit involved in the opinion vector combination only includes "long". The server combines each text unit involved in the aspect vector combination with each text unit involved in the opinion vector combination pairwise, and two candidate text unit pairs can be obtained. The first candidate text unit pair includes the text units "battery" and "long", and the second candidate text unit pair includes the text units "lifespan" and "long".
[0102] For the first candidate text unit pair, the server can determine the nodes corresponding to the text units "battery" and "long" in the undirected graph, and use the corresponding shortest path algorithm (such as the Floyd algorithm, etc.) to calculate the shortest distance between these two nodes, that is, calculate the minimum number of connecting edges required to go from the node corresponding to the text unit "battery" to the node corresponding to the text unit "long", as the semantic distance of this first candidate text unit pair. For the second candidate text unit pair, the server can determine the nodes corresponding to the text units "life" and "long" in the undirected graph, and use the corresponding shortest path algorithm to calculate the shortest distance between these two nodes, that is, calculate the minimum number of connecting edges required to go from the node corresponding to the text unit "life" to the node corresponding to the text unit "long", as the semantic distance of this second candidate text unit pair.
[0103] Furthermore, the server can determine the shortest semantic distance among the semantic distances of these two candidate text unit pairs as the semantic distance feature of this target vector combination pair; for example, assuming that the semantic distance of the first candidate text unit pair is 2 and the semantic distance of the second candidate text unit pair is 1, then the server can determine that the semantic distance feature of this target vector combination pair is 1.
[0104] In this way, through the above method, directly based on the node positions corresponding to the text units involved in the aspect vector combination and the opinion vector combination in the target vector combination pair in the undirected graph, the semantic distance feature of this target vector combination pair can be determined, and the corresponding semantic distance feature can be determined in combination with the actually selected target vector combination pair, avoiding wasting relevant computing resources.
[0105] Step 203: Determine the sentiment polarity of the target vector combination pair according to the aspect vector combination, the opinion vector combination, and the semantic distance feature.
[0106] After the server determines the semantic distance feature of the target vector combination pair through step 202, it can determine the sentiment polarity of this target vector combination pair according to the aspect vector combination and the opinion vector combination included in this target vector combination pair, and the semantic distance feature of this target vector combination pair.
[0107] Exemplarily, the server can splice the aspect vector combination and the opinion vector combination in the target vector combination pair, and the semantic distance feature of this target vector combination pair to obtain the input data of the sentiment polarity extraction model. Furthermore, input this input data into the pre-trained sentiment polarity extraction model, and this sentiment polarity extraction model can correspondingly output the sentiment polarity of this target vector combination pair, such as positive or negative, through analyzing and processing the input data. The sentiment polarity extraction model here can be, for example, a neural network model with three or more layers.
[0108] In a possible implementation, before determining the sentiment polarity of the target vector combination pair, the server may first detect whether the aspect vector combination and the opinion vector combination included in the target vector combination pair are relevant. Then, based on the relevance detection result, it decides whether to extract the sentiment polarity for the target vector combination pair. That is, the server can determine the relevance detection result according to the aspect vector combination and the opinion vector combination included in the target vector combination pair, as well as the semantic distance feature of the target vector combination pair. If the relevance detection result indicates that the aspect vector combination and the opinion vector combination are relevant, then step 203 above is executed to determine the sentiment polarity for the target vector combination pair. If the relevance detection result indicates that the aspect vector combination and the opinion vector combination are irrelevant, then the target vector combination pair can be discarded.
[0109] Exemplarily, Figure 9 is a schematic flowchart of extracting the sentiment polarity for the target vector combination pair provided by the embodiments of the present application. As Figure 9 shown, before extracting the sentiment polarity for the target vector combination pair, the server may first splice the aspect vector combination and the opinion vector combination included in the target vector combination pair, as well as the sentiment polarity of the target vector combination pair. Then, a shallow feed-forward neural network model is used to perform binary classification on the spliced data to detect whether the aspect vector combination and the opinion vector combination included in the target vector combination pair are relevant.
[0110] If it is determined that the aspect vector combination and the opinion vector combination included in the target vector combination pair are irrelevant, then the target vector combination pair can be directly discarded without performing the sentiment polarity extraction process for the target vector combination pair. If it is determined that the aspect vector combination and the opinion vector combination included in the target vector combination pair are relevant, then the target vector combination pair can be retained, and a further sentiment polarity extraction process is performed for the target vector combination pair.
[0111] In this way, through the above method, before performing the sentiment polarity extraction process on the target vector combination, the target vector combination pair is preliminarily screened according to the aspect vector combination and the opinion vector combination included in the target vector combination pair, as well as the semantic distance feature, which can filter out a large number of irrelevant target vector combination pairs, thereby reducing the required sentiment polarity extraction process, reducing the time complexity of the sentiment polarity extraction process, and improving the sentiment polarity extraction efficiency.
[0112] Optionally, for the sentiment polarity extracted for the target vector pair by the method provided in the embodiments of the present application, the server may generate a sentiment extraction triple by using the text units involved in the aspect vector pair and the opinion vector pair included in the target vector pair, respectively, and the sentiment polarity extracted for the target vector pair. That is, the server may directly splice together the text units involved in the aspect vector pair included in the target vector pair, the text units involved in the opinion vector pair, and the sentiment polarity of the target vector pair to obtain a sentiment extraction triple. For example, assume that the target vector pair includes an aspect vector pair corresponding to the text unit combination "battery life" and an opinion vector pair corresponding to the text unit combination "long", and the sentiment polarity of the target vector pair is positive. Then, a sentiment extraction triple [battery life, long, positive] may be generated based on the target vector pair.
[0113] Alternatively, the server may also determine an associated aspect according to the text unit involved in the aspect vector pair in the target vector pair. For example, the server may determine the category to which the text unit belongs as the associated aspect according to the text unit involved in the aspect vector pair. Furthermore, the server may generate a sentiment extraction quadruple according to the associated aspect, the text units involved in the aspect vector pair and the opinion vector pair in the target vector pair, respectively, and the sentiment polarity of the target vector pair. That is, the server may directly splice together the associated aspect, the text units involved in the aspect vector pair included in the target vector pair, the text units involved in the opinion vector pair, and the sentiment polarity of the target vector pair to obtain a sentiment extraction quadruple.
[0114] It should be understood that in practical applications, based on one target text, the server may generate at least one sentiment extraction triple or at least one sentiment extraction quadruple. The present application does not make any limitation on the number of sentiment extraction triples or sentiment extraction quadruples that can be generated based on the target text. The generated sentiment extraction triples or sentiment extraction quadruples may be applied in related downstream applications. For example, they may be used to perform tasks such as public opinion analysis tasks and consumer decision-making tasks to improve the implementation effects of related downstream applications.
[0115] When the above-mentioned text analysis method extracts sentiment polarity based on the target vector combination, it innovatively introduces the semantic distance feature of the target vector combination; this semantic distance feature is determined based on the dependency tree obtained by semantic analysis and processing of the target text, and it can accurately reflect the semantic relevance between the text units involved in the aspect vector combination and the opinion vector combination in the target vector combination. Taking this semantic distance feature as one of the factors considered when extracting sentiment polarity is equivalent to comprehensively considering the semantic association relationship of relevant text units in the target text when extracting sentiment polarity, and the semantic association relationship has high reference value for extracting sentiment polarity. Therefore, it can effectively improve the accuracy of the extracted sentiment polarity. Correspondingly, it can also improve the implementation effect of other downstream applications related to the sentiment extraction task.
[0116] To facilitate a further understanding of the text analysis method provided in the embodiments of the present application, the following Figure 10 gives an overall exemplary introduction to this text analysis method. Figure 10 It is a schematic diagram of the implementation architecture of the text analysis method provided in the embodiments of the present application.
[0117] As Figure 10 shown, the implementation architecture of the text analysis method provided in the embodiments of the present application includes an input feature calculation unit 1001, a potential aspect and potential opinion mining unit 1002, a dependency tree information introduction unit 1003, and a text unit combination screening unit 1004.
[0118] Among them, the input feature calculation unit 1001 is used to calculate the input features of the sentiment extraction task. The input of this unit is the review text (i.e., the target text in the above text). This unit uses a pre-trained LSTM model to calculate the word embedding vectors of each word segment in the review text, and uses the word embedding vectors of a preset number of adjacent word segments to form a text unit vector combination (span). The output of this unit is the multiple spans obtained by combination.
[0119] Specifically, the input feature calculation unit 1001 first performs word segmentation processing on the input review text, and then maps each word segment obtained by the word segmentation processing to a digital token through a dictionary. The digital token will be converted into the corresponding word embedding vector through a pre-trained LSTM model. Subsequently, the n-gram method can be used to combine the word embedding vectors of word segments at different positions in the review text to obtain the corresponding span representation.
[0120] Among them, the potential aspect and potential opinion mining unit 1002 is used to discriminate each span output by the input feature calculation unit 1001, and divide the potential aspect span (i.e., the aspect vector combination in the above text) and the potential opinion span (i.e., the opinion vector combination in the above text).
[0121] Specifically, the potential aspect and potential opinion mining unit 1002 is used to distinguish different types of spans. For each span output by the input feature calculation unit 1001, the invalid spans are removed, and the valid spans are divided into corresponding groups (i.e., aspect types or opinion types). Exemplarily, each span output by the input feature calculation unit 1001 can be input into a neural network model classifier, which can be composed of, for example, a two-layer fully connected neural network spliced with a relu non-linear activation function and a softmax layer. The neural network model classifier can give three-dimensional scores for each span, namely, an invalid score, a potential aspect score, and a potential opinion score; correspondingly, the span will be assigned to the group with the highest score. The spans assigned to the invalid group will be deprecated, and the spans assigned to the potential aspect group and the potential opinion group will be further analyzed and processed.
[0122] Among them, the dependency tree information introduction unit 1003 is used to convert the input review text into a corresponding dependency tree, and determine the semantic distance feature between word segments based on the distance between the corresponding nodes of the word segments in the dependency tree.
[0123] The main function of the dependency tree information introduction unit 1003 is to mine available syntactic information from the input review text, so as to assist in performing the sentiment extraction task. Compared with the relative distance of text units in a sentence, the distance of text units in a dependency tree can better reflect the semantic relevance between two text units. In many cases, the semantic relevance between adjacent words in a sentence may actually be very low, and in this case, the distance between these two words in the dependency tree will be relatively far. Based on this, the embodiment of the present application uses the dependency tree information introduction unit 1003 to perform semantic analysis processing on the input review text to obtain the corresponding dependency tree of the review text, so as to introduce the semantic information that the dependency tree can reflect into the subsequent sentiment extraction task, and improve the accuracy of the extracted sentiment polarity by means of the introduced semantic information.
[0124] When the dependency tree information introduction unit 1003 is working specifically, it can first use the Stanford CoreNLP tool to perform dependency syntactic analysis on the input review text to obtain the dependency tree corresponding to the review text. Then, the dependency tree can be converted into a corresponding undirected graph, and the Floyd algorithm can be used to calculate the shortest distance between every two nodes in the undirected graph. Furthermore, according to the shortest distance between every two nodes in the undirected graph and the word segmentation corresponding to each node in the undirected graph (i.e., the correspondence between the nodes in the undirected graph and the word segmentation in the review text), the semantic distance mapping relationship corresponding to the review text can be constructed; subsequently, this semantic distance mapping relationship can be directly used to find the semantic distance features between relevant text units in the review text.
[0125] Among them, the text unit combination screening unit 1004 is used to combine the spans in the potential aspect group and the spans in the potential opinion group pairwise to obtain a number of candidate span pairs; then, for each candidate span pair, the semantic distance feature of the candidate span pair is combined to detect whether the two spans are relevant, and the candidate span pairs including relevant spans are further subjected to sentiment polarity extraction processing.
[0126] Specifically, the text unit combination screening unit 1004 can pair the spans in the potential aspect group and the spans in the potential opinion group pairwise to obtain a number of candidate span pairs. Then, using the semantic distance mapping relationship corresponding to the review text constructed by the dependency tree information introduction unit 1003, the semantic distance feature of each candidate span pair is found; specifically, the semantic distance between the text units involved in the two spans in the candidate span pair can be found in the semantic distance mapping relationship, and the shortest semantic distance found is determined as the semantic distance feature of the candidate span pair; furthermore, the two spans in the candidate span pair are concatenated with this semantic distance feature. Then, a shallow feed-forward neural network can be used to perform binary classification processing on the candidate span pairs based on the features concatenated previously to remove irrelevant candidate span pairs. For the remaining candidate span pairs, a neural network model with three or more layers can be used to calculate the sentiment polarity of the candidate span pair based on the features concatenated previously, and then, according to the text units involved in the two spans in the candidate span pair and this sentiment polarity, the required sentiment extraction triple can be constructed.
[0127] For the text analysis method described above, the present application also provides a corresponding text analysis device to enable the above text analysis method to be applied and implemented in practice.
[0128] See Figure 11 , Figure 11 which is related to the above Figure 2Schematic structural diagram of a text analysis device 1100 corresponding to the text analysis method shown. As Figure 11 shown, the text analysis device 1100 includes:
[0129] A semantic analysis module 1101, configured to perform semantic analysis processing on a target text to obtain a dependency tree corresponding to the target text; the dependency tree includes nodes corresponding to each text unit in the target text, and the positional relationship between the nodes in the dependency tree is used to represent the semantic association relationship between the corresponding text units;
[0130] A semantic distance determination module 1102, configured to determine a semantic distance feature of the target vector combination pair according to the dependency tree and the target vector combination pair of involved text units; the target vector combination pair includes an aspect vector combination and an opinion vector combination, and the aspect vector combination and the opinion vector combination are generated based on the embedding vectors of at least one text unit in the target text; the semantic distance feature is used to represent the semantic correlation between the text units involved in the aspect vector combination and the opinion vector combination respectively;
[0131] An emotional polarity determination module 1103, configured to determine the emotional polarity of the target vector combination pair according to the aspect vector combination, the opinion vector combination, and the semantic distance feature.
[0132] Optionally, the device further includes:
[0133] A vector combination pair screening module, configured to determine a correlation detection result according to the aspect vector combination, the opinion vector combination, and the semantic distance feature; if the correlation detection result indicates that the aspect vector combination and the opinion vector combination are relevant, trigger the emotional polarity determination module 1103 to execute determining the emotional polarity of the target vector combination pair according to the aspect vector combination, the opinion vector combination, and the semantic distance feature; if the correlation detection result indicates that the aspect vector combination and the opinion vector combination are irrelevant, discard the target vector combination pair.
[0134] Optionally, the semantic distance determination module 1102 is specifically configured to:
[0135] Convert the dependency tree into a corresponding undirected graph;
[0136] Determine the shortest distance between every two nodes in the undirected graph;
[0137] Construct a semantic distance mapping relationship corresponding to the target text according to the shortest distance between every two nodes in the undirected graph and the text unit corresponding to each node in the undirected graph; the semantic distance mapping relationship is used to represent the semantic distance between every two text units in the target text;
[0138] Determine the semantic distance feature of the target vector combination pair according to the semantic distance mapping relationship and the text units involved in the aspect vector combination and the opinion vector combination respectively.
[0139] Optionally, the semantic distance determination module 1102 is specifically configured to:
[0140] Construct candidate text unit pairs based on the text units involved in the aspect vector combination and the text units involved in the opinion vector combination; each candidate text unit pair includes a text unit involved in the aspect vector combination and a text unit involved in the opinion vector combination;
[0141] For each candidate text unit pair, look up the semantic distance between the two text units included in it in the semantic distance mapping relationship as the semantic distance of the candidate text unit pair;
[0142] Determine the shortest semantic distance among the semantic distances of each candidate text unit pair as the semantic distance feature of the target vector combination pair.
[0143] Optionally, the semantic distance determination module 1102 is specifically configured to:
[0144] Convert the dependency tree into a corresponding undirected graph;
[0145] Determine the semantic distance feature of the target vector combination pair according to the node positions corresponding to the text units involved in the aspect vector combination and the opinion vector combination in the undirected graph.
[0146] Optionally, the semantic distance determination module 1102 is specifically configured to:
[0147] Construct candidate text unit pairs based on the text units involved in the aspect vector combination and the text units involved in the opinion vector combination; each candidate text unit pair includes a text unit involved in the aspect vector combination and a text unit involved in the opinion vector combination;
[0148] For each candidate text unit pair, determine the shortest distance between the node positions corresponding to the two text units included in it in the undirected graph as the semantic distance of the candidate text unit pair;
[0149] Determine the shortest semantic distance among the semantic distances of each of the candidate text units as the semantic distance feature of the target vector combination pair.
[0150] Optionally, the semantic analysis module 1101 is specifically configured to:
[0151] Perform dependency syntactic analysis on the target text to determine the respective dependency relationships of the text units in the target text; the dependency relationships are used to characterize whether the corresponding text units correspond to the root node of the dependency tree, and to characterize the parent text unit associated with the text unit in the target text when the text unit does not correspond to the root node.
[0152] Generate a dependency tree corresponding to the target text according to the respective dependency relationships of the text units in the target text.
[0153] Optionally, the apparatus further includes: a vector combination pair generation module; the vector combination pair generation module includes:
[0154] A text splitting sub-module, configured to split the target text to obtain each text unit in the target text; determine the embedding vector of each text unit in the target text.
[0155] A vector combination sub-module, configured to generate a plurality of text unit vector combinations based on a preset text unit combination rule according to the embedding vectors of each text unit in the target text.
[0156] A vector combination classification sub-module, configured to perform classification processing on the plurality of text unit vector combinations respectively, determine the text unit vector combinations belonging to the aspect type as aspect vector combinations, and determine the text unit vector combinations belonging to the opinion type as opinion vector combinations.
[0157] A combination pair construction sub-module, configured to construct the target vector combination pair based on each aspect vector combination and each opinion vector combination; each target vector combination pair includes an aspect vector combination and an opinion vector combination.
[0158] Optionally, the vector combination sub-module is specifically configured to:
[0159] For each text unit in the target text, determine the reference text unit associated with the text unit in the target text according to the text unit combination range indicated by the text unit combination rule.
[0160] For each of the reference text units, construct a text unit vector combination corresponding to the reference text unit according to the embedding vector of the text unit, the embedding vectors of the text units in the target text that are between the text unit and the reference text unit, the embedding vector of the reference text unit, and the distance between the text unit and the reference text unit in the target text.
[0161] Optionally, the vector combination classification sub-module is specifically configured to:
[0162] For each of the text unit vector combinations, determine the probability that the text unit vector combination belongs to an invalid vector combination, the probability that it belongs to the aspect type, and the probability that it belongs to the opinion type;
[0163] According to the probability that the text unit vector combination belongs to an invalid vector combination, the probability that it belongs to the aspect type, and the probability that it belongs to the opinion type, determine the type to which the text unit vector combination belongs;
[0164] If the text unit vector combination belongs to the invalid vector combination, discard the text unit vector combination; if the text unit vector combination belongs to the aspect type, determine it as an aspect vector combination; if the text unit vector combination belongs to the opinion type, determine it as an opinion vector combination.
[0165] Optionally, the device further includes:
[0166] A triple generation module, configured to generate an emotion extraction triple according to the text units involved in the aspect vector combination and the opinion vector combination respectively, and the sentiment polarity.
[0167] Optionally, the device further includes:
[0168] A quadruple generation module, configured to determine an associated aspect according to the text units involved in the aspect vector combination; and generate an emotion extraction quadruple according to the associated aspect, the text units involved in the aspect vector combination and the opinion vector combination respectively, and the sentiment polarity.
[0169] When the above-mentioned text analysis device extracts the sentiment polarity based on the target vector combination, it innovatively introduces the semantic distance feature of the target vector combination; this semantic distance feature is determined based on the dependency tree obtained by performing semantic analysis processing on the target text, and it can accurately reflect the semantic relevance between the text units involved in the aspect vector combination and the opinion vector combination in the target vector combination respectively. Taking this semantic distance feature as one of the factors considered when extracting the sentiment polarity is equivalent to comprehensively considering the semantic association relationship of relevant text units in the target text when extracting the sentiment polarity, and the semantic association relationship has high reference value for extracting the sentiment polarity. Therefore, it can effectively improve the accuracy of the extracted sentiment polarity. Correspondingly, it can also improve the implementation effect for other downstream applications related to the sentiment extraction task.
[0170] The embodiment of the present application also provides a computer device for analyzing text. This computer device can specifically be a terminal device or a server. Below, the terminal device and the server provided by the embodiment of the present application will be introduced from the perspective of hardware implementation.
[0171] See Figure 12 , Figure 12 is a schematic structural diagram of the terminal device provided by the embodiment of the present application. As Figure 12 shown, for the sake of convenience of description, only the parts related to the embodiment of the present application are shown. For the specific technical details not disclosed, please refer to the method part of the embodiment of the present application. This terminal can be any terminal device including a mobile phone, a tablet computer, a personal digital assistant (PDA), a point of sales (POS), an in-vehicle computer, etc. Taking the terminal as a computer as an example:
[0172] Figure 12 shown is a block diagram of a part of the structure of a computer related to the terminal provided by the embodiment of the present application. Referring to Figure 12 , the computer includes: a radio frequency (RF) circuit 1210, a memory 1220, an input unit 1230 (including a touch panel 1231 and other input devices 1232), a display unit 1240 (including a display panel 1241), a sensor 1250, an audio circuit 1260 (which can be connected to a speaker 1261 and a microphone 1262), a wireless fidelity (WiFi) module 1270, a processor 1280, and a power supply 1290 and other components. Those skilled in the art can understand that Figure 12 the computer structure shown in
[0173] The memory 1220 can be used to store software programs and modules. The processor 1280 executes various functional applications and data processing of the computer by running the software programs and modules stored in the memory 1220. The memory 1220 may mainly include a program storage area and a data storage area. Among them, the program storage area can store an operating system, application programs required for at least one function (such as a sound playback function, an image playback function, etc.); the data storage area can store data created according to the use of the computer (such as audio data, phone book, etc.). In addition, the memory 1220 may include high-speed random access memory and may also include non-volatile memory, such as at least one magnetic disk storage device, a flash memory device, or other volatile solid-state storage devices.
[0174] The processor 1280 is the control center of the computer, connecting various parts of the entire computer through various interfaces and lines. By running or executing the software programs and / or modules stored in the memory 1220 and calling the data stored in the memory 1220, it executes various functions of the computer and processes data. Optionally, the processor 1280 may include one or more processing units; preferably, the processor 1280 may integrate an application processor and a modem processor. Among them, the application processor mainly processes the operating system, user interface, and application programs, etc., and the modem processor mainly processes wireless communication. It can be understood that the above-mentioned modem processor may not be integrated into the processor 1280.
[0175] In the embodiment of the present application, the processor 1280 included in the terminal is further configured to execute the steps of any implementation manner of the text analysis method provided in the embodiment of the present application.
[0176] See Figure 13 , Figure 13 FIG. 14 is a schematic structural diagram of a server 1300 provided in an embodiment of the present application. The server 1300 may vary greatly due to different configurations or performances, and may include one or more central processing units (CPUs) 1322 (for example, one or more processors) and a memory 1332, and one or more storage media 1330 (for example, one or more mass storage devices) for storing application programs 1342 or data 1344. Among them, the memory 1332 and the storage media 1330 may be transient storage or persistent storage. The programs stored in the storage media 1330 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations on the server. Further, the central processor 1322 may be configured to communicate with the storage media 1330 and execute a series of instruction operations in the storage media 1330 on the server 1300.
[0177] The server 1300 may further include one or more power supplies 1326, one or more wired or wireless network interfaces 1350, one or more input / output interfaces 1358, and / or one or more operating systems, such as Windows Server TM , Mac OS X TM , Unix TM , Linux TM , FreeBSD TM and so on.
[0178] The steps performed by the server in the above embodiments may be based on the Figure 13 server structure shown.
[0179] Among them, the CPU 1322 may also be used to execute the steps of any implementation manner of the text analysis method provided in the embodiments of the present application.
[0180] The embodiments of the present application further provide a computer-readable storage medium for storing a computer program, and the computer program is used to execute any implementation manner of the text analysis method described in the foregoing embodiments.
[0181] The embodiments of the present application further provide a computer program product or a computer program. The computer program product or the computer program includes computer instructions, and the computer instructions are stored in a computer-readable storage medium. The processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes any implementation manner of the text analysis method described in the foregoing embodiments.
[0182] Those skilled in the art can clearly understand that for the convenience and brevity of description, the specific working processes of the systems, devices, and units described above may refer to the corresponding processes in the foregoing method embodiments, and will not be described herein again.
[0183] In several embodiments provided by the present application, it should be understood that the disclosed systems, devices, and methods may be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the division of the units is only a logical function division, and there may be other division methods in actual implementation. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Another point is that the displayed or discussed mutual coupling or direct coupling or communication connection may be through some interfaces, and the indirect coupling or communication connection of the devices or units may be in electrical, mechanical or other forms.
[0184] The unit described as a separation component may or may not be physically separated. The component shown as a unit may or may not be a physical unit, that is, it may be located in one place or distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0185] In addition, each functional unit in various embodiments of the present application may be integrated in a processing unit, or each unit may exist physically alone, or two or more units may be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of a software functional unit.
[0186] If the above-mentioned integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art, or all or part of this technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in various embodiments of the present application. The aforementioned storage medium includes: various media that can store computer programs such as USB flash drives, mobile hard disks, read-only memories (ROM), random access memories (RAM), magnetic disks, or optical discs.
[0187] It should be understood that in the present application, "at least one (item)" means one or more, and "multiple" means two or more. "And / or" is used to describe the association relationship of associated objects and indicates that three relationships may exist. For example, "A and / or B" may mean: only A exists, only B exists, and both A and B exist at the same time. Among them, A and B can be singular or plural. The character " / " generally means that the associated objects before and after are in an "or" relationship. "At least one (one)" or a similar expression thereof refers to any combination of these items, including any combination of single item (one) or plural items (ones). For example, at least one (one) of a, b, or c may mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, and c can be single or multiple.
[0188] As described above, the above embodiments are only used to illustrate the technical solutions of the present application, rather than limiting them; although the present application has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that: they can still modify the technical solutions recorded in the foregoing embodiments, or perform equivalent replacements on some of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. A text analysis method, characterized in that, The method includes: Performing semantic analysis processing on the target text to obtain a dependency tree corresponding to the target text; the dependency tree includes nodes corresponding to respective text units in the target text, and the positional relationship between nodes in the dependency tree is used to represent the semantic association relationship between corresponding text units; Determining a semantic distance feature of the target vector combination pair according to the dependency tree and the text units involved in the target vector combination pair; the target vector combination pair includes an aspect vector combination and an opinion vector combination; the semantic distance feature is used to represent the semantic correlation between the text units involved in the aspect vector combination and the opinion vector combination respectively; Determining the sentiment polarity of the target vector combination pair according to the aspect vector combination, the opinion vector combination, and the semantic distance feature; The aspect vector combination and the opinion vector combination are obtained by the following method: Based on a preset text unit combination rule, generating a plurality of text unit vector combinations according to the embedding vectors of respective text units in the target text; For each of the text unit vector combinations, determining the probability that the text unit vector combination belongs to an invalid vector combination, the probability that it belongs to an aspect type, and the probability that it belongs to an opinion type; Determining the type to which the text unit vector combination belongs according to the probability that the text unit vector combination belongs to an invalid vector combination, the probability that it belongs to an aspect type, and the probability that it belongs to an opinion type; If the text unit vector combination belongs to the invalid vector combination, discarding the text unit vector combination; if the text unit vector combination belongs to the aspect type, determining it as the aspect vector combination; if the text unit vector combination belongs to the opinion type, determining it as the opinion vector combination.
2. The method according to claim 1, wherein The method further includes: Determining a correlation detection result according to the aspect vector combination, the opinion vector combination, and the semantic distance feature; If the correlation detection result indicates that the aspect vector combination and the opinion vector combination are relevant, then performing the step of determining the sentiment polarity of the target vector combination pair according to the aspect vector combination, the opinion vector combination, and the semantic distance feature; if the correlation detection result indicates that the aspect vector combination and the opinion vector combination are irrelevant, then discarding the target vector combination pair.
3. The method according to claim 1, wherein The step of determining the semantic distance feature of the target vector combination pair according to the dependency tree and the text units involved in the target vector combination pair includes: Converting the dependency tree into a corresponding undirected graph; Determining the shortest distance between each two nodes in the undirected graph; Constructing a semantic distance mapping relationship corresponding to the target text according to the shortest distance between each two nodes in the undirected graph and the text unit corresponding to each node in the undirected graph; the semantic distance mapping relationship is used to represent the semantic distance between each two text units in the target text; Determining the semantic distance feature of the target vector combination pair according to the semantic distance mapping relationship and the text units involved in the aspect vector combination and the opinion vector combination respectively.
4. The method according to claim 3, characterized in that, Determining the semantic distance feature of the target vector combination pair according to the semantic distance mapping relationship, and the text units involved in the aspect vector combination and the opinion vector combination respectively, includes: Constructing candidate text unit pairs based on the text units involved in the aspect vector combination and the text units involved in the opinion vector combination; each candidate text unit pair includes a text unit involved in the aspect vector combination and a text unit involved in the opinion vector combination; For each candidate text unit pair, looking up the semantic distance between the two text units included therein in the semantic distance mapping relationship as the semantic distance of the candidate text unit pair; Determining the shortest semantic distance among the semantic distances of each candidate text unit pair as the semantic distance feature of the target vector combination pair.
5. The method according to claim 1, wherein Determining the semantic distance feature of the target vector combination pair according to the dependency tree and the text units involved in the target vector combination pair, includes: Converting the dependency tree into a corresponding undirected graph; Determining the semantic distance feature of the target vector combination pair according to the node positions corresponding to the text units involved in the aspect vector combination and the opinion vector combination respectively in the undirected graph.
6. The method according to claim 5, characterized in that, Determining the semantic distance feature of the target vector combination pair according to the node positions corresponding to the text units involved in the aspect vector combination and the opinion vector combination respectively in the undirected graph, includes: Constructing candidate text unit pairs based on the text units involved in the aspect vector combination and the text units involved in the opinion vector combination; each candidate text unit pair includes a text unit involved in the aspect vector combination and a text unit involved in the opinion vector combination; For each candidate text unit pair, determining the shortest distance between the node positions corresponding to the two text units included therein in the undirected graph as the semantic distance of the candidate text unit pair; Determining the shortest semantic distance among the semantic distances of each candidate text unit pair as the semantic distance feature of the target vector combination pair.
7. The method according to claim 1, characterized in that, Performing semantic analysis processing on the target text to obtain the dependency tree corresponding to the target text, includes: Performing dependency parsing processing on the target text to determine the dependency relationship corresponding to each text unit in the target text; the dependency relationship is used to characterize whether the corresponding text unit corresponds to the root node of the dependency tree, and to characterize the parent text unit associated with the text unit in the target text in the case where the text unit does not correspond to the root node; Generating the dependency tree corresponding to the target text according to the dependency relationship corresponding to each text unit in the target text.
8. The method according to claim 1, wherein The method further includes: Performing splitting processing on the target text to obtain each text unit in the target text; determining the embedding vector corresponding to each text unit in the target text; Constructing the target vector combination pair based on each aspect vector combination and each opinion vector combination; each target vector combination pair includes an aspect vector combination and an opinion vector combination.
9. The method according to claim 1, characterized in that, Based on a preset text unit combination rule, multiple text unit vector combinations are generated according to the respective embedding vectors of each text unit in the target text, including: For each text unit in the target text, according to the text unit combination range indicated by the text unit combination rule, determine the reference text unit associated with the text unit in the target text; For each of the reference text units, according to the embedding vector of the text unit, the embedding vectors of the text units in the target text located between the text unit and the reference text unit, the embedding vector of the reference text unit, and the distance between the text unit and the reference text unit in the target text, construct the text unit vector combination corresponding to the reference text unit.
10. The method according to claim 1, wherein The method further includes: Generate an emotion extraction triple according to the text units involved in the aspect vector combination and the opinion vector combination respectively, and the emotion polarity; Alternatively, determine the associated aspect according to the text units involved in the aspect vector combination; generate an emotion extraction quadruple according to the associated aspect, the text units involved in the aspect vector combination and the opinion vector combination respectively, and the emotion polarity.
11. A text analysis device, characterized in that, The device includes: A semantic analysis module, configured to perform semantic analysis processing on the target text to obtain a dependency tree corresponding to the target text; the dependency tree includes nodes corresponding to each text unit in the target text, and the positional relationship between the nodes in the dependency tree is used to represent the semantic association relationship between the corresponding text units; A semantic distance determination module, configured to determine the semantic distance feature of the target vector combination pair according to the dependency tree and the text units involved in the target vector combination pair; the target vector combination pair includes an aspect vector combination and an opinion vector combination; the semantic distance feature is used to represent the semantic correlation between the text units involved in the aspect vector combination and the opinion vector combination respectively; An emotion polarity determination module, configured to determine the emotion polarity of the target vector combination pair according to the aspect vector combination and the opinion vector combination, and the semantic distance feature; The vector combination pair generation module includes: A vector combination sub-module, configured to generate multiple text unit vector combinations based on a preset text unit combination rule according to the respective embedding vectors of each text unit in the target text; A vector combination classification sub-module, configured to, for each of the text unit vector combinations, determine the probability that the text unit vector combination belongs to an invalid vector combination, the probability that it belongs to an aspect type, and the probability that it belongs to an opinion type; determine the type to which the text unit vector combination belongs according to the probability that the text unit vector combination belongs to an invalid vector combination, the probability that it belongs to an aspect type, and the probability that it belongs to an opinion type; if the text unit vector combination belongs to the invalid vector combination, discard the text unit vector combination; if the text unit vector combination belongs to the aspect type, determine it as an aspect vector combination; if the text unit vector combination belongs to the opinion type, determine it as an opinion vector combination.
12. The device according to claim 11, wherein The device further includes: A vector combination pair screening module, configured to determine a correlation detection result according to the aspect vector combination, the opinion vector combination, and the semantic distance feature; if the correlation detection result indicates that the aspect vector combination and the opinion vector combination are relevant, then execute determining the sentiment polarity of the target vector combination pair according to the aspect vector combination, the opinion vector combination, and the semantic distance feature; if the correlation detection result indicates that the aspect vector combination and the opinion vector combination are irrelevant, then discard the target vector combination pair.
13. The device according to claim 11, characterized in that, Specifically, the semantic distance determination module is configured to: Convert the dependency tree into a corresponding undirected graph; Determine the shortest distance between each two nodes in the undirected graph; Construct a semantic distance mapping relationship corresponding to the target text according to the shortest distance between each two nodes in the undirected graph and the text unit corresponding to each node in the undirected graph; the semantic distance mapping relationship is used to represent the semantic distance between each two text units in the target text; Determine the semantic distance feature of the target vector combination pair according to the semantic distance mapping relationship and the text units involved in the aspect vector combination and the opinion vector combination respectively.
14. The device according to claim 13, characterized in that, Specifically, the semantic distance determination module is configured to: Construct candidate text unit pairs based on the text units involved in the aspect vector combination and the text units involved in the opinion vector combination; each candidate text unit pair includes a text unit involved in the aspect vector combination and a text unit involved in the opinion vector combination; For each candidate text unit pair, look up the semantic distance between the two text units included therein in the semantic distance mapping relationship as the semantic distance of the candidate text unit pair; Determine the shortest semantic distance among the semantic distances of each candidate text unit pair as the semantic distance feature of the target vector combination pair.
15. The device according to claim 11, characterized in that, Specifically, the semantic distance determination module is configured to: Convert the dependency tree into a corresponding undirected graph; Determine the semantic distance feature of the target vector combination pair according to the node positions corresponding to the text units involved in the aspect vector combination and the opinion vector combination respectively in the undirected graph.
16. The device according to claim 15, characterized in that, Specifically, the semantic distance determination module is configured to: Construct candidate text unit pairs based on the text units involved in the aspect vector combination and the text units involved in the opinion vector combination; each candidate text unit pair includes a text unit involved in the aspect vector combination and a text unit involved in the opinion vector combination; For each candidate text unit pair, determine the shortest distance between the node positions corresponding to the two text units included therein in the undirected graph as the semantic distance of the candidate text unit pair; Determine the shortest semantic distance among the semantic distances of each candidate text unit pair as the semantic distance feature of the target vector combination pair.
17. The device according to claim 11, characterized in that, Specifically, the semantic analysis module is configured to: Perform dependency syntactic analysis on the target text to determine the respective dependency relationships of each text unit in the target text; the dependency relationships are used to characterize whether the corresponding text unit corresponds to the root node of the dependency tree, and to characterize the parent text unit associated with the text unit in the target text when the text unit does not correspond to the root node. Generate a dependency tree corresponding to the target text according to the respective dependency relationships of each text unit in the target text.
18. The device according to claim 11, characterized in that, The vector combination pair generation module further includes: A text splitting sub-module for splitting the target text to obtain each text unit in the target text; determining the embedding vector of each text unit in the target text. A combination pair construction sub-module for constructing the target vector combination pair based on each aspect vector combination and each opinion vector combination; each target vector combination pair includes an aspect vector combination and an opinion vector combination.
19. The device according to claim 11, characterized in that, The vector combination sub-module is specifically used for: For each text unit in the target text, determine the reference text unit associated with the text unit in the target text according to the text unit combination range indicated by the text unit combination rule. For each reference text unit, construct a text unit vector combination corresponding to the reference text unit according to the embedding vector of the text unit, the embedding vectors of the text units between the text unit and the reference text unit in the target text, the embedding vector of the reference text unit, and the distance between the text unit and the reference text unit in the target text.
20. The device according to claim 11, characterized in that, The device further includes: A triple generation module for generating an emotion extraction triple according to the text units involved in the aspect vector combination and the opinion vector combination, and the sentiment polarity. Or, A quadruple generation module for determining the associated aspect according to the text units involved in the aspect vector combination; generating an emotion extraction quadruple according to the associated aspect, the text units involved in the aspect vector combination and the opinion vector combination, and the sentiment polarity.
21. A computer device, characterized in that, The device includes a processor and a memory; The memory is used to store a computer program; The processor is used to execute the text analysis method according to any one of claims 1 to 10 according to the computer program.
22. A computer-readable storage medium, characterized in that, The computer-readable storage medium is used to store a computer program, and the computer program is used to execute the text analysis method according to any one of claims 1 to 10.
23. A computer program product, comprising a computer program or instructions, characterized in that, When the computer program or the instruction is executed by the processor, the text analysis method according to any one of claims 1 to 10 is implemented.
Citation Information
Patent Citations
View-level text sentiment classification system and method based on a graph convolutional neural network
CN113641820A