Semantic analysis method and device, intention recognition method and device, equipment and medium
By decomposing and comparing sememes of text, a mapping relationship between text changes and semantic changes is established, which solves the problem of difficulty in identifying semantic changes caused by text changes in the existing technology, achieves fast and accurate semantic analysis, and reduces manual intervention. dependence.
Patent Information
- Application Number
- CN202410108519.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-01-25
- Publication Date
- 2024-09-17
AI Technical Summary
Existing technology is difficult to quickly and accurately identify semantic changes caused by text changes. Especially in the process of corpus annotation and business system construction, relying on manual judgment is time-consuming and labor-intensive, and the accuracy cannot be guaranteed.
By decomposing text into seme elements, comparing seme sequences between sentences, determining text change information and semantic change information, establishing a mapping relationship between text changes and semantic changes, and using seme elements as the smallest semantic unit that reflects text semantics to achieve automatic analyze.
It achieves rapid and accurate identification of semantic changes caused by text changes, reduces dependence on manual intervention, and improves analysis efficiency and accuracy.
Smart Images

Figure CN118657152A
Abstract
Description
Technical Field
[0001] The present application relates to the field of natural language processing technology, and in particular to a semantic analysis method, intent recognition method, device, equipment and medium. Background Art
[0002] The semantics expressed by the text itself will change in the process of continuous expansion of the text, but the semantic changes caused by slight changes in the text are difficult to identify, especially in the process of corpus annotation and business system construction.
[0003] In related technologies, texts are usually analyzed manually one by one, which is not only time-consuming and labor-intensive, but also relies on human experience, and accuracy cannot be guaranteed. Therefore, how to quickly and accurately identify semantic changes caused by text changes has become one of the hot issues in the field of natural language processing technology. Summary of the invention
[0004] The purpose of the embodiments of the present application is to provide a semantic analysis method, an intent recognition method, an apparatus, a device and a medium for quickly and accurately analyzing semantic changes caused by text changes.
[0005] In order to achieve the above objectives, the present application embodiment adopts the following technical solutions:
[0006] In a first aspect, an embodiment of the present application provides a semantic analysis method, including:
[0007] Decomposing the first sentence and the second sentence into semantic components to obtain a semantic component sequence of the first sentence and a semantic component sequence of the second sentence;
[0008] Comparing the first sentence with the second sentence to obtain first text change information;
[0009] Comparing the semantic element sequence of the first sentence with the semantic element sequence of the second sentence to obtain first semantic change information;
[0010] Based on the first text change information and the first semantic change information, a first mapping relationship between text changes and semantic changes between different sentences is determined.
[0011] In a second aspect, an embodiment of the present application provides an intent recognition method, including:
[0012] Acquire a labeled sentence that has a containment relationship with an unlabeled sentence from a corpus, and determine second text change information of the unlabeled sentence relative to the labeled sentence, wherein the labeled sentence is labeled with an intent label;
[0013] Determine the second semantic change information of the unlabeled sentence relative to the labeled sentence based on the second text change information and a first mapping relationship between text changes and semantic changes between different sentences, wherein the first mapping relationship is obtained by analyzing based on the semantic analysis method described in the first aspect;
[0014] Based on the second semantic change information and the intention label of the marked sentence, the intention label of the unmarked sentence is determined.
[0015] In a third aspect, an embodiment of the present application provides a semantic analysis device, including:
[0016] A decomposition unit, configured to perform semantic component decomposition on the first sentence and the second sentence to obtain a semantic component sequence of the first sentence and a semantic component sequence of the second sentence;
[0017] A first comparison unit, used for comparing the first sentence and the second sentence to obtain first text change information;
[0018] a second comparison unit, configured to compare the semantic element sequence of the first sentence with the semantic element sequence of the second sentence to obtain first semantic change information;
[0019] The first determining unit is used to determine a first mapping relationship between text changes and semantic changes between different sentences based on the first text change information and the first semantic change information.
[0020] In a fourth aspect, an embodiment of the present application provides an intention recognition device, including:
[0021] an acquisition unit, configured to acquire a labeled sentence that has an inclusion relationship with an unlabeled sentence from a corpus, and determine second text change information of the unlabeled sentence relative to the labeled sentence, wherein the labeled sentence is labeled with an intent label;
[0022] a second determining unit, configured to determine second semantic change information of the unlabeled sentence relative to the labeled sentence based on the second text change information and a first mapping relationship between text changes and semantic changes between different sentences, wherein the first mapping relationship is obtained by analyzing based on the semantic analysis method described in the first aspect;
[0023] The third determining unit is used to determine the intention label of the unlabeled sentence based on the second semantic change information and the intention label of the labeled sentence.
[0024] In a fifth aspect, an embodiment of the present application provides an electronic device, comprising: a processor; a memory for storing instructions executable by the processor; wherein the processor is configured to execute the instructions to implement the semantic analysis method as described in the first aspect; or, the processor is configured to execute the instructions to implement the intent recognition method as described in the second aspect.
[0025] In a sixth aspect, an embodiment of the present application provides a computer-readable storage medium, which, when instructions in the storage medium are executed by a processor of an electronic device, enables the electronic device to execute the semantic analysis method as described in the first aspect; or, when instructions in the storage medium are executed by a processor of an electronic device, enables the electronic device to execute the intention analysis method as described in the second aspect.
[0026] In the seventh aspect, an embodiment of the present application provides a computer program product, which includes a non-transitory computer-readable storage medium storing a computer program, and the computer program is operable to cause a computer to execute part or all of the steps in the method described in the first aspect or the second aspect.
[0027] At least one of the above technical solutions adopted in the embodiments of the present application can achieve the following beneficial effects: by comparing the first sentence and the second sentence, the text change information between the two is determined; since the semantic element is the smallest semantic unit that reflects the semantics of the text, the change of the semantic element will cause the change of the text semantics, by comparing the semantic element sequences of these sentences, and using the differences in the semantic element sequences between these sentences, the semantic change information between these sentences can be determined; finally, by analyzing the text change information and semantic change information between the first sentence and the second sentence, the mapping relationship between the text change and the semantic change of different sentences can be analyzed. Since the entire analysis process starts from the semantic micro-level of semantic elements, it uses the objective natural law that the semantic element is the smallest semantic unit that can reflect the semantics of the text, and does not rely on human experience, so the analysis result is more accurate and more time-saving and labor-saving. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0029] Figure 1 A flowchart of a semantic analysis method provided for one embodiment of the present application;
[0030] Figure 2 A flowchart of a semantic analysis method provided for another embodiment of the present application;
[0031] Figure 3 A flowchart of an intent recognition method provided for an embodiment of the present application;
[0032] Figure 4 A flowchart of an intent recognition method provided for another embodiment of the present application;
[0033] Figure 5 A schematic diagram of the structure of a semantic analysis device provided for one embodiment of the present application;
[0034] Figure 6 A schematic diagram of the structure of an intention recognition device provided for one embodiment of the present application;
[0035] Figure 7 A schematic diagram of the structure of an electronic device provided for one embodiment of the present application. DETAILED DESCRIPTION
[0036] In order to make the purpose, technical solution and advantages of the present application clearer, the technical solution of the present application will be clearly and completely described below in combination with the specific embodiments of the present application and the corresponding drawings. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present application.
[0037] The terms "first", "second", etc. in this specification and claims are used to distinguish similar objects, and are not used to describe a particular order or precedence. It should be understood that the terms used in this way can be interchanged where appropriate so that the embodiments of the present application are implemented in a sequence other than those illustrated or described herein. In addition, "and / or" in this specification and claims means at least one of the connected objects, and the character " / " generally means that the objects associated with each other are in an "or" relationship.
[0038] Some concept descriptions:
[0039] NLP: Natural Language Processing.
[0040] Bert: The full name is Bidirectional Encoder Representation from Transformers, which is a pre-trained language representation model. It emphasizes that it no longer uses the traditional unidirectional language model or the shallow concatenation of two unidirectional language models for pre-training as in the past, but uses a new Masked Language Model (MLM) to generate deep bidirectional language representation.
[0041] TTS: text to speech, also known as speech synthesis and text-to-speech conversion.
[0042] ASR: Automatic Speech Recognition, speech recognition, also known as automatic speech recognition.
[0043] Semantic element: the smallest semantic unit that constitutes a text. It cannot be directly observed in the semantic system and belongs to the microscopic level of semantics. For example, the semantic elements of the text "sister" include [relatives] [siblings] [elder] [female]; for another example, the semantic elements of the text "brother" include [relatives] [siblings] [elder] [male].
[0044] Semantic addition: The two sentences express the same content, and the latter sentence enhances the semantics of the former sentence. For example, the latter sentence "I will repay the loan before I get off work" contains new information relative to the former sentence "I will repay the loan", and this new information enhances the semantics of the former sentence.
[0045] Semantic weakening: The two sentences express the same content, but the latter sentence weakens the semantics of the former sentence. For example, the latter sentence "If someone repays me, I will repay" adds a repayment condition to the former sentence "I will repay", which weakens the certainty of the content of the former sentence.
[0046] Semantic dissolution: The content of two sentences is the same, but the latter sentence weakens the certainty of the content of the former sentence. For example, the latter sentence "I may have to repay the loan, not sure" weakens the certainty of the repayment intention compared to the former sentence "I want to repay the loan".
[0047] Semantic deconstruction: The two sentences express contradictory contents. For example, the first sentence is "I want to repay the loan", and the second sentence is "I regret it and I will not repay the loan".
[0048] In order to quickly and accurately identify semantic changes caused by text changes, the present application has conducted a lot of research on the text expansion process and found that the reasons why semantic changes caused by slight changes in text are difficult to identify mainly include two aspects: first, because the language itself repeatedly uses limited grammatical structures to express infinite semantic functions based on limited language unit materials; second, because in the process of obtaining corpus using ASR recognition technology, many words, few words, and homophones are all common, which to a large extent produces similar text pairs (groups) with many or few words.
[0049] The present application has conducted a lot of research on the reasons for the first aspect and found that, since the semantic element is the smallest semantic unit that reflects the semantics of the text, the change of the semantic element will cause the change of the text semantics. For example, the text "brother" and "sister" have a difference in the last semantic element, and this difference makes "brother" and "sister" show obvious differences in semantics. Therefore, by comparing and analyzing the semantic elements of different texts together and finding the semantic elements that are different from each other, the semantic changes of different texts can be quickly identified.
[0050] The present application has conducted a lot of research on the second reason and found that different sentences with inclusion relationships are usually obtained by adding and / or deleting some characters on the basis of each other, so the text changes between these sentences are subtle, similar to the above-mentioned similar text pairs (groups) with more or fewer words. Therefore, by performing semantic analysis on these sentences, it is helpful to quickly and accurately identify the relationship between minor changes in the text and semantic changes.
[0051] Based on this, the embodiment of the present application provides a semantic analysis method, which determines the text change information between the first sentence and the second sentence by comparing the first sentence and the second sentence; then, by comparing the semantic element sequences of the sentences, the semantic change information between the sentences can be determined by using the differences in the semantic element sequences between the sentences; finally, by analyzing the text change information and semantic change information between the sentences, the mapping relationship between the text change and the semantic change of different sentences can be analyzed. Since the entire analysis process starts from the semantic micro-level of semantic elements, it uses the objective natural law that semantic elements are the smallest semantic units that can reflect the semantics of the text, and does not rely on human experience, so the analysis result is more accurate and saves time and effort.
[0052] The semantic analysis method provided in the embodiment of the present application can be applied to various business scenarios with semantic analysis needs. For example, in the corpus annotation scenario, based on the first mapping relationship obtained by the semantic analysis method, the corresponding precautions information is output for the annotation personnel to prompt the annotation personnel that the changes in the text of the sentence may cause what kind of semantic changes. For example, in the bad sample (badcase) analysis scenario, based on the first mapping relationship obtained by the semantic analysis method, the cause of the badcase is quickly and categorized to understand the cause of the badcase, so as to optimize the text processing model in a targeted manner. For example, in the training data expansion scenario, based on the first mapping relationship obtained by the semantic analysis method, the text in the training data set is enhanced in a targeted manner, thereby realizing the expansion of the training data set. For example, in the intent recognition scenario, based on the first mapping relationship obtained by the semantic analysis method and the intent label of the annotated sentence, the corresponding intent label is automatically annotated for the unannotated sentence.
[0053] In the intent recognition scenario, an embodiment of the present application also proposes an intent recognition method. By comparing the unlabeled sentences in the corpus with the labeled sentences with which they have an inclusion relationship, it is possible to determine what changes have occurred in the text of the unlabeled sentences relative to the labeled sentences. On this basis, combined with the first mapping relationship obtained by the above-mentioned semantic analysis method, analysis is performed to determine the semantic change information caused by this text change information; further, based on the intent label of the labeled text and the semantic change information of the unlabeled text relative to the labeled text, the intent of the unlabeled text can be quickly and accurately determined, thereby achieving automatic labeling of the unlabeled text.
[0054] It should be understood that the application of the semantic analysis method provided in the embodiment of the present application to the above-mentioned scenario is merely an exemplary description and should not be understood as a limitation on the application scenario of the method.
[0055] Secondly, the semantic analysis method and intent recognition method provided in the embodiments of the present application can be executed by an electronic device, specifically by software in the electronic device. The electronic device can be a terminal device, such as a smart phone, a tablet computer, a laptop computer, a desktop computer, an intelligent voice interaction device, a smart home appliance, a smart watch, a vehicle terminal, an aircraft, etc.; or, the electronic device can also be a server, such as an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides cloud computing services.
[0056] The technical solutions provided by various embodiments of the present application are described in detail below in conjunction with the accompanying drawings.
[0057] See also Figure 1 , is a flowchart of a semantic analysis method provided by an embodiment of the present application, and the method may include the following steps:
[0058] S102, performing semantic component decomposition on the first sentence and the second sentence to obtain a semantic component sequence of the first sentence and a semantic component sequence of the second sentence.
[0059] There is a containment relationship between the first sentence and the second sentence. The containment relationship means that one sentence contains all the characters of another sentence, that is, one sentence is obtained by adding and / or deleting some characters on the basis of another sentence. For example, the first sentence is obtained by adding and / or deleting some characters on the basis of the second sentence. The containment relationship includes a complete containment relationship and an extension relationship. The complete containment relationship means that one sentence is completely contained by another sentence, that is, the shorter sentence overlaps with a part of the longer sentence continuously, such as the sentence "What's wrong and who are you" completely contains the sentence "What's wrong", and the continuous overlapping part of the two is "What's wrong". The extension relationship means that a sentence generates a new sentence by adding vocabulary, such as the sentence "I want to repay the loan in advance" adds the words "now" and "next" to obtain the new sentence "I will now repay the loan in advance", and there is an extension relationship between the two sentences.
[0060] The first statement and the second statement can be any two statements in N statements, where N is an integer greater than 1, and the N statements have an inclusion relationship. For the N statements, any one of the N statements is obtained by adding and / or deleting some characters from other statements other than itself. The N statements all have corresponding text labels, such as intent labels. An example of N statements and their text labels is shown below:
[0061] text: yes label: yes
[0062] text: I will pay it back today label: I promise to pay it back
[0063] text: I have money in my card label: I have money in my card
[0064] text: What happened label: Ask about the caller's intention
[0065] text: What's wrong? What do you want to do? label: Not in a good mood
[0066] S104: Compare the first sentence and the second sentence to obtain first text change information.
[0067] The first text change information indicates what changes have occurred in the text of the first sentence relative to the second sentence. As an example, the first text change information may include but is not limited to the characters that have changed in the first sentence relative to the second sentence and the type of character change. The character change type includes but is not limited to: adding characters, deleting characters, changing characters, etc. For example, the first text change information between statement 1 and statement 2 includes: the characters that have changed in statement 1 relative to statement 2 and the type of character change, and the characters that have changed in statement 2 relative to statement 1 and the type of character change.
[0068] As another example, the first text change information may also include the semantic sequence of characters that have changed in the first sentence relative to the second sentence. For example, if sentence 1 adds the word "older brother" relative to sentence 2, the first text change information includes the semantic sequence of the word [relative][compatriot][older][male].
[0069] In the case where the first statement and the second statement originate from any two statements among N statements, in order to compare the N statements more systematically, the N statements may be sorted according to a preset order, such as ascending order, descending order, etc., and the statements in the N statements may be compared in sequence according to the sorting result to obtain the first text change information.
[0070] In one embodiment, the above S104 includes the following steps: arranging the N sentences in ascending order according to the length; traversing the N sentences according to the arrangement result, each time a sentence is traversed, the sentence currently traversed is used as the first sentence, the sentence before the sentence currently traversed in the arrangement order is used as the second sentence, and the first sentence is compared with the second sentence to obtain the first text change information between the N sentences. The length of the sentence refers to the number of characters contained in the sentence.
[0071] For example, after arranging N statements in ascending order of length, the sorted N statements are traversed; if the current traversal reaches the i-th (i≥2) statement, the i-th statement is taken as the first statement, the first i-1 statements are taken as the second statement, the first statement is compared with the second statement, and the first text change information of the i-th statement relative to each of the first i-1 statements is obtained; then, the traversal continues to the next statement.
[0072] Since the N statements are in an inclusion relationship, through this implementation, we can start from the shortest statement and gradually analyze which characters are modified in each statement relative to the shorter statements, making the analysis process more organized and avoiding omissions, which helps to accurately analyze the semantic changes caused by the modification of these characters.
[0073] The embodiment of the present application shows an implementation method of the above S104. Of course, it should be understood that the above S104 can also be implemented in other ways, which can be selected according to actual needs, and the embodiment of the present application does not limit this. For example, the N statements are not sorted, and one statement is taken from the N statements each time as the first statement, and the other N-1 statements are taken as the second statement, and the first statement is compared with the second statement to obtain the first text change information of the statement relative to the other N-1 statements, and so on.
[0074] S106, comparing the semantic component sequence of the first sentence with the semantic component sequence of the second sentence to obtain first semantic change information.
[0075] Each statement has a corresponding sememe sequence, which includes multiple sememes arranged in order. The sememe sequence of each statement is obtained by decomposing the statement into sememes. As an example, for each statement, the statement is input into a pre-trained sememe decomposition model for sememe decomposition to obtain the sememe sequence of each word in the statement. Then, according to the order of the words in the statement, the sememe sequences of these words are concatenated to obtain the sememe sequence of the statement, which can also be called the word sememe sequence and is used to represent the semantics of the words in the statement.
[0076] As another example, considering that in addition to the words in the statement, the sentence pattern and text labels of the statement (such as intention labels, sentiment labels, named entity labels, etc.) also affect the semantics of the statement. In order to more comprehensively analyze the first semantic change information between the first statement and the second statement, for each statement, the sememe sequence of the statement not only includes the word sememe sequence of the statement, but also includes the sentence pattern sememe sequence and the label sememe sequence of the statement.
[0077] Among them, the sentence pattern sememe sequence represents the sentence pattern of the statement, and the sentence pattern sememe sequence is obtained by decomposing the keyword representing the sentence pattern in the statement into sememes. For example, in the statement "I was pushed to the last row", the keyword that can represent the sentence pattern is "was", and the sememe sequence obtained by decomposing this keyword into sememes is the sentence pattern sememe sequence of this statement. Another example is that in the statement "I pushed him to the last row", the keyword that can represent the sentence pattern is "pushed", and the sememe sequence obtained by decomposing this keyword into sememes is the sentence pattern sememe sequence of this statement.
[0078] The label sememe sequence represents the semantics of the text label of the statement, and the label sememe sequence is obtained by decomposing the text label of the statement into sememes. For example, the intention label of the statement "I want to pay back the money" is "pay back the money", and decomposing this intention label into sememes can obtain the label sememe sequence [return][others][money]. Another example is that the sentiment label of the statement "I'm very angry with you like this" is "angry", and decomposing this sentiment label into sememes can obtain the label sememe sequence [emotion][negative][unpleasant].
[0079] The first semantic change information is used to represent the semantic change situation of the first statement relative to the second statement. Since sememes are the smallest semantic units reflecting text semantics, changes in sememes will cause changes in text semantics. By comparing the sememe sequence of the first statement and the sememe sequence of the second statement and finding the different sememes from them, it is possible to quickly identify what semantic changes have occurred between the first statement and the second statement and obtain the first semantic change information.
[0080] As an example, the first semantic change information may include the first semantic element change information of the first sentence relative to the second sentence, which may specifically include, for example, but not limited to, the first semantic element that changes in the first sentence relative to the second sentence and the semantic element change type. Semantic element change types include, but are not limited to: semantic element increase, semantic element reduction, semantic element ablation, semantic element deconstruction, semantic element merging, etc. Semantic element ablation refers to the semantic consistency expressed by two semantic elements, and the latter semantic element weakens the semantic certainty of the former semantic element. Semantic element deconstruction refers to the semantic contradiction expressed by two semantic elements. Semantic element merging refers to the two semantic elements having the same superordinate semantic element, and the two semantic elements are replaced by the superordinate semantic element.
[0081] The first semantic change information may be determined in various ways. In one embodiment, the above S106 includes the following steps:
[0082] S161, comparing the semantic element sequence of the first sentence with the semantic element sequence of the second sentence to obtain first semantic element change information of the first sentence relative to the second sentence.
[0083] The first semantic element change information includes the first semantic element that has changed in the first sentence relative to the second sentence and the semantic element change type. For example, the semantic element sequence of the first sentence "mother" is [female][blood relative][elder generation][maternal], and the semantic element sequence of the second sentence "uncle" is [male][blood relative][elder generation][maternal], then the first semantic element that has changed in the first sentence relative to the second sentence includes [male], and its corresponding semantic element change type is semantic element deconstruction.
[0084] Since the words in a sentence, the sentence pattern and the text label of a sentence will all have an impact on the semantics of the sentence, in order to more comprehensively reflect the first semantic element change information between the first sentence and the second sentence, as an example, the above S161 may include: concatenating the word semantic element sequence of the first sentence, the sentence pattern semantic element sequence of the first sentence and the label semantic element sequence of the first sentence to obtain the target semantic element sequence of the first sentence; concatenating the word semantic element sequence of the second sentence, the sentence pattern semantic element sequence of the second sentence and the label semantic element sequence of the second sentence to obtain the target semantic element sequence of the second sentence; comparing the target semantic element sequence of the first sentence with the target semantic element sequence of the second sentence to obtain the first semantic element and semantic element change type that has changed in the first sentence relative to the second sentence.
[0085] In practical applications, the three semantic element sequences of a sentence can be spliced in various ways. In one way, the three semantic element sequences can be horizontally spliced using separators to obtain the target semantic element sequence of the sentence. For example, the word semantic element sequence of sentence 1 is [semantic element 1][semantic element 2][semantic element 3], the sentence semantic element sequence is [semantic element 4], and the label semantic element sequence is [semantic element 2][semantic element 3]. Then the target semantic element sequence obtained after splicing is [semantic element 1][semantic element 2][semantic element 3][SEP][semantic element 4][SEP][semantic element 2][semantic element 3].
[0086] In another way, in order to better reflect the relationship between the three semantic element sequences and to accurately analyze the impact of sentence text changes on text labels, an equation can be established between the sentence word semantic element sequence, sentence pattern semantic element sequence and label semantic element sequence, and the equation can be used as the target semantic element sequence.
[0087] For example, the word semantic morpheme sequence of sentence 1 is [semane 1][semane 2][semane 3], the sentence semantic morpheme sequence is [semane 4], and the label semantic morpheme sequence is [semane 2][semane 3]. Then the target semantic morpheme sequence obtained according to this method is [semane 1][semane 2][semane 3] + [semane 4] - [semane 1] - [semane 4] = [semane 2][semane 3].
[0088] In actual applications, each time after the semantic element sequence of the first sentence and the semantic element sequence of the second sentence are compared, the first text change information and the first semantic element change information between the first sentence and the second sentence are visually displayed, for example, the shorter sentence between the first sentence and the second sentence is written into the first line of the list, the first text change information of the longer sentence relative to the shorter sentence is written into the second line of the list, the first semantic element change information of the longer sentence relative to the shorter sentence is written into the third line of the list, and the list is output so that relevant personnel can quickly understand the text changes and character changes between the first sentence and the second sentence.
[0089] S162 determines first semantic change information based on the first semantic element change information.
[0090] As an example, the first semantic element change information may be used as the first semantic change information.
[0091] As another example, based on the semantics represented by the first semantic element and the semantic element change type, it is also possible to determine what kind of semantic changes have occurred between the first sentence and the second sentence, such as semantic increase, semantic weakening, semantic ablation, semantic structure, etc., to obtain the first semantic change information. For example, taking the first sentence "mother" and the second sentence "uncle" as an example, the first semantic element that has changed in the second sentence relative to the first sentence is [male], and the semantic element change type is semantic element deconstruction, then it can be determined that the second sentence has undergone semantic deconstruction relative to the first sentence.
[0092] The embodiment of the present application shows some implementation methods of the above S106. Of course, it should be understood that the above S106 can also be implemented in other ways, and the embodiment of the present application does not limit this.
[0093] S108: Determine a first mapping relationship between text changes and semantic changes between different sentences based on the first text change information and the first semantic change information.
[0094] Since the first text change information reflects the text change between the first sentence and the second sentence, and the first semantic change information reflects the semantic change caused by the text change between the first sentence and the second sentence, by performing association analysis on the first text change information and the first semantic change information, a first mapping relationship between text changes and semantic changes between different sentences can be obtained, that is, what kind of semantic changes will be caused by text changes between different texts.
[0095] In one embodiment, the first text change information is used as the first training sample, and the first semantic change information is used as the label of the first training sample; model training is performed based on the first training sample and the label of the first training sample to obtain a semantic change analysis model for representing the first mapping relationship.
[0096] As an example, when the first text change information includes characters that have changed in the first sentence relative to the second sentence and the type of character change, the first training sample and its label are as follows:
[0097] Text: The character that changes = the character change type
[0098] label: first semantic change information
[0099] For example, sentence 1 adds the word "older brother" compared to sentence 2, and the first semantic change information includes the newly added semantic element sequence [relatives][siblings][elder][male], then the first training sample and its label are as follows:
[0100] Text: Brother = add
[0101] label: [relatives][siblings][elderly][male] = add
[0102] Among them, add means the addition of semantic elements.
[0103] As another example, in the case where the first text change information includes a semantic sequence of characters in which the first sentence has changed relative to the second sentence, the first training sample and its label are as follows:
[0104] Text: Sequence of semantic elements of the characters that have changed
[0105] label: first semantic change information
[0106] For example, the semantic sequence of the newly added words in sentence 1 relative to sentence 2 is [semantic element 1] [semantic element 2] [semantic element 3], and the first semantic change information includes: newly added [semantic element 2], reduced [semantic element 3], and semantic element ablation between [semantic element 2] and [semantic element 3]. In this case, the first training sample and its label are as follows:
[0107] Text: [Semantic 1][Semantic 2][Semantic 3]
[0108] label: {[semantic element 1]&[semantic element 2]=add,[semantic element 1]&[semantic element 3]=delete1,[semantic element 2]&[semantic element 3]=whitesemantic element 2}
[0109] Among them, add means the addition of a semantic element, delete means the reduction of a semantic element, and white means the disappearance of a semantic element.
[0110] In this embodiment, the first text change information and the first semantic change information between the first sentence and the second sentence are learned by using deep learning technology, so that the first mapping relationship between the text change and the semantic change between different sentences can be quickly determined, and the implementation process is simple. In this way, it is only necessary to input the text change information between any two sentences into the trained semantic analysis model to quickly and accurately determine the semantic change information between the two sentences. In practical applications, training can be performed on the basis of various language models commonly used in the field, such as the Bert model, etc., which is not limited in the embodiments of the present application.
[0111] The embodiment of the present application shows some implementation methods of the above S108. Of course, it should be understood that the above S108 can also be obtained by analyzing using other commonly used association analysis methods in the art, and the embodiment of the present application does not limit this.
[0112] In practical applications, the first sentence and the second sentence are obtained from a corpus, and the two belong to the same language. The corpus contains a large number of sentences. By grouping the sentences in the corpus, the sentences with a containment relationship are divided into the same group, thereby obtaining at least one group, selecting the first sentence and the second sentence from each group, and executing the above S102 to S106 based on the first sentence and the second sentence, to obtain the first text change information and the first semantic change information between the sentences in each group; finally, the first text change information and the first semantic change information between the sentences in all groups are analyzed comprehensively, and the first mapping relationship between the text change and the semantic change of different sentences can be accurately determined.
[0113] In addition, if the corpus contains sentences in multiple languages, the above S102 to S108 may be executed for each sentence in each language to obtain a first mapping relationship between text changes and semantic changes between different sentences in the language.
[0114] The semantic analysis method provided in the embodiment of the present application determines the text change information between the first sentence and the second sentence by comparing the two sentences; since the semantic element is the smallest semantic unit that reflects the semantics of the text, the change of the semantic element will cause the change of the text semantics, and by comparing the semantic element sequences of these sentences and utilizing the differences in the semantic element sequences between these sentences, the semantic change information between these sentences can be determined; finally, by analyzing the text change information and semantic change information between the first sentence and the second sentence, the mapping relationship between the text change and the semantic change of different sentences can be analyzed. Since the entire analysis process starts from the semantic micro-level of the semantic element, it utilizes the objective natural law that the semantic element is the smallest semantic unit that can reflect the semantics of the text, and does not rely on human experience, so the analysis result is more accurate and more time-saving and labor-saving.
[0115] In another embodiment of the present application, in order to realize the visualization display of the first semantic change information between the first sentence and the second sentence, after the above S106, the semantic analysis method provided in the embodiment of the present application may also include: creating corresponding nodes for the first sentence and the second sentence; creating connecting edges between the nodes corresponding to the first sentence and the nodes corresponding to the second sentence, and using the first semantic change information between the first sentence and the second sentence as the edge attribute of the connecting edge; based on the created nodes, the connecting edges between the created nodes, and the edge attributes of the connecting edges, a semantic change map is generated. In practical applications, the semantic change map can adopt various types of maps, such as directed acyclic graphs, etc., which are not limited in the embodiment of the present application.
[0116] In this embodiment, by visually displaying the first semantic change information in the form of a graph, relevant personnel can quickly obtain the semantic changes between different sentences from the graph, so as to perform business processing more targetedly. For example, in a corpus annotation scenario, the semantic change graph helps annotation personnel understand precautions, such as what kind of semantic changes may be caused by changes in the text of a sentence. For another example, in a bad sample analysis scenario, the semantic change graph helps analysts quickly and categorize the causes of bad samples so as to optimize the text processing model in a targeted manner. For another example, in a training data expansion scenario, the semantic change graph helps trainers to enhance the text in the training data set in a targeted manner, thereby expanding the training data set.
[0117] Considering that the semantic changes of sentences will also lead to changes in the text labels of sentences, such changes are also difficult to identify and require manual judgment and analysis one by one, which is also time-consuming and labor-intensive, and the accuracy cannot be guaranteed. Based on this, in order to quickly and accurately obtain the changes in text labels caused by the semantic changes of sentences, so as to better provide data support for downstream businesses, such as Figure 2 As shown, after the above S106, the semantic analysis method provided by the embodiment of the present application may further include the following steps:
[0118] S110, determining a second mapping relationship between semantic changes and text label changes between different sentences based on the first semantic change information, the text label of the first sentence, and the text label of the second sentence.
[0119] In one embodiment, the above S110 includes the following steps: Step A1, concatenating the first semantic change information and the text label of one of the sentences as the second training sample, and using the text label of another text as the label of the second training sample; Step A2, performing model training based on the second training sample and the label of the second training sample to obtain a label prediction model for representing the second mapping relationship.
[0120] In this way, it is only necessary to input the semantic change information of the unlabeled sentence relative to the labeled sentence and the text label of the labeled sentence into the label prediction model, and the unlabeled sentence can be quickly and automatically labeled with the corresponding text label. In practical applications, training can be performed based on various language models commonly used in the field, such as the Bert model, etc., and the embodiments of the present application are not limited to this.
[0121] For example, the first semantic change information of sentence 2 relative to sentence 1 includes adding [semane 2] and [semane 3], deleting [semane 3], the text label of sentence 1 is intent A, and the text label of sentence 2 is intent B. Then the second training sample and its label are as follows:
[0122] text:Intent A[SEP]add[semite 1]index1 add[semite 2]index2 delete[semite 3]index3
[0123] label: Intent B
[0124] Among them, [SEP] is a separator, add means adding a semantic element, delete means reducing a semantic element, and index1 to index3 represent index numbers.
[0125] In another embodiment, in order to more accurately analyze the text label change caused by the semantic change of the sentence, the first semantic change information includes the first semantic element change information of the first sentence relative to the second sentence. Accordingly, the above S110 includes the following steps:
[0126] Step B1: concatenate the first semantic element change information with the text label of the first sentence and add the concatenated information to the sample set as the second training sample, and use the text label of the second sentence as the label of the second training sample.
[0127] The specific implementation of step B1 is similar to that of the above-mentioned step A1 and will not be described in detail.
[0128] Step B2, concatenating the word semantic morpheme sequence of the first sentence and the sentence pattern semantic morpheme sequence of the first sentence, and comparing them with the label semantic morpheme sequence of the first sentence to obtain second semantic morpheme change information.
[0129] The second semantic element change information may include semantic elements that have changed in the label semantic element sequence compared to the spliced semantic element sequence and the semantic element change type. The second semantic element change information may reflect which semantic elements of the sentence word semantic element sequence and sentence form semantic element sequence have changed from core semantic elements to edge semantic elements, and which semantic elements have changed from edge semantic elements to core semantic elements, etc., compared to the label semantic element sequence.
[0130] For example, the word semantic morpheme sequence of sentence 1 is [semantic 1][semantic 2][semantic 3], the sentence semantic morpheme sequence is [semantic 4], and the label semantic morpheme sequence is [semantic 2][semantic 3]. The semantic morpheme sequence [semantic 1][semantic 2][semantic 3][semantic 4] obtained by concatenating the word semantic morpheme sequence and the sentence semantic morpheme sequence is compared with the label semantic morpheme sequence to obtain the second semantic morpheme [semantic 1] and [semantic 4] that have changed compared to the label semantic morpheme sequence, and the semantic change type of [semantic 1] and the semantic change type of [semantic 4] are both semantic reduction.
[0131] Step B3: concatenate the second semantic element change information with the text label of the first sentence and add the concatenated information to the sample set as a third training sample, and use the text label of the first sentence as the label of the third training sample.
[0132] For example, taking the second semantic component change information of the above sentence 1 as an example, the text label of sentence 1 is intention A, then the third training sample and its label that can be obtained are as follows:
[0133] text:Intent A[SEP]delete[semester 1]index1 delete[semester 4]index4
[0134] label: Intent A
[0135] Step B4, concatenating the word semantic morpheme sequence of the second sentence and the sentence pattern semantic morpheme sequence of the second sentence, and comparing them with the label semantic morpheme sequence of the second sentence to obtain third semantic morpheme change information.
[0136] The specific implementation of step B4 is similar to that of the above-mentioned step B2 and will not be described in detail.
[0137] Step B5: concatenate the third semantic element change information with the text label of the second sentence and add the concatenated information to the sample set as a fourth training sample, and use the text label of the second sentence as the label of the fourth training sample.
[0138] Among them, the specific implementation of step B5 is similar to the specific implementation of the above-mentioned step B3 and will not be repeated here.
[0139] Step B6: Perform model training based on the training samples in the sample set and the labels of the training samples to obtain a label prediction model for representing the second mapping relationship.
[0140] In practical applications, training can be performed based on various language models commonly used in the art, such as the Bert model, etc., and the embodiments of the present application are not limited to this.
[0141] In this embodiment, by using deep learning technology to learn the first text change information between different sentences and the text labels before and after the change, the second mapping relationship between the semantic change between different sentences and the text label change can be quickly determined, and the implementation process is simple. In this way, it is only necessary to input the semantic change information of the unlabeled sentence relative to the labeled sentence and the text label of the labeled sentence into the label prediction model, and the corresponding text label can be automatically labeled for the unlabeled sentence.
[0142] The embodiment of the present application shows some implementation methods of the above S110. Of course, it should be understood that the above S110 can also be obtained by analyzing using other commonly used correlation analysis methods in the art, and the embodiment of the present application does not limit this.
[0143] The semantic analysis method provided in this embodiment can also analyze the second mapping relationship between the semantic changes of different sentences and the text label changes by analyzing the first semantic change information between the first sentence and the second sentence and the text labels before and after the change. Since the entire analysis process starts from the semantic micro-level of the semantic element, it uses the objective natural law that the semantic element is the smallest semantic unit that can reflect the semantics of the text, and does not rely on human experience, so the analysis result is more accurate and saves time and effort.
[0144] The present application also provides an intent recognition method, which automatically labels the unlabeled sentences with corresponding intent tags based on the first mapping relationship obtained by the semantic analysis method. Figure 3 , is a flow chart of an intention recognition method provided by an embodiment of the present application, the method comprising the following steps:
[0145] S302: Acquire a marked sentence that has an inclusion relationship with the unmarked sentence from the corpus, and determine second text change information of the unmarked sentence relative to the marked sentence.
[0146] The labeled sentence is labeled with an intent label. The existence of a containment relationship between the unlabeled sentence and the labeled sentence means that the unlabeled sentence contains all the characters of the labeled sentence, or the labeled sentence contains all the characters of the unlabeled sentence. For example, the unlabeled sentence is obtained by adding and / or deleting some characters from the labeled sentence.
[0147] S304: Determine second semantic change information of the unlabeled sentence relative to the labeled sentence based on the second text change information and the first mapping relationship between the text change and the semantic change between different sentences.
[0148] The first mapping relationship is obtained by analyzing the semantic analysis method provided in the embodiment of the present application.
[0149] As an example, when the first mapping relationship is a semantic analysis model, the second semantic change information can be obtained by inputting the second text change information into the semantic analysis model.
[0150] S306: Determine the intention label of the unlabeled sentence based on the second semantic change information and the intention label of the labeled sentence.
[0151] In one embodiment, the intention label of the marked sentence is modified based on the second semantic change information to obtain the intention label of the unmarked sentence. For example, the second semantic change information includes: adding [semantic element 1], reducing [semantic element 2], and the label semantic element sequence of the intention label of the marked sentence is [semantic element 2] [semantic element 3] [semantic element 4]. The label semantic element sequence is modified based on the second semantic change information to obtain the label semantic element sequence [semantic element 1] [semantic element 3] [semantic element 4], and then the label semantic element sequence is converted into text to obtain the intention label of the unmarked sentence.
[0152] In another embodiment, in order to quickly and accurately label the unlabeled sentences with the corresponding intent labels, Figure 4 As shown, the above S306 includes the following steps: determining the label change information of the unlabeled sentence relative to the labeled sentence based on the second semantic change information and the second mapping relationship between the semantic change information and the intention label between different sentences; determining the intention label of the unlabeled sentence based on the label change information and the intention label of the labeled sentence.
[0153] The second mapping relationship is determined based on the first semantic change information between the annotated sentences in the corpus and the intention labels of the annotated sentences, for example, by the above Figure 2 In the illustrated embodiment, S110 is determined.
[0154] As an example, when the second mapping relationship is a label prediction model, the second semantic change information and the intention label of the labeled sentence are concatenated and input into the label prediction model to obtain the intention label of the unlabeled sentence.
[0155] The embodiment of the present application shows some implementation methods of the above S306. Of course, it should be understood that the above S306 can also be implemented in other ways, and the embodiment of the present application does not limit this.
[0156] The intention recognition method provided in the embodiment of the present application can determine what changes have occurred in the text of the unlabeled sentences relative to the labeled sentences by comparing the unlabeled sentences in the corpus with the labeled sentences with which they have an inclusion relationship. On this basis, combined with the first mapping relationship obtained by the above-mentioned semantic analysis method, analysis can be performed to determine the semantic change information caused by this text change information; further, based on the intention labels of the labeled sentences and the semantic change information of the unlabeled sentences relative to the labeled sentences, the intention of the unlabeled sentences can be quickly and accurately determined, thereby realizing automatic labeling of the unlabeled sentences.
[0157] The above is a description of a specific embodiment of the specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0158] Based on the same inventive concept, the present application embodiment also provides a semantic analysis device. Figure 5 , is a structural diagram of a semantic analysis device 500 provided in one embodiment of the present application, the device 500 includes: a decomposition unit 510, a first comparison unit 520, a second comparison unit 530 and a first determination unit 540.
[0159] The decomposition unit 510 is used to perform semantic component decomposition on the first sentence and the second sentence to obtain a semantic component sequence of the first sentence and a semantic component sequence of the second sentence.
[0160] The first comparing unit 520 is used to compare the first sentence and the second sentence to obtain first text change information.
[0161] The second comparison unit 530 is used to compare the semantic component sequence of the first sentence with the semantic component sequence of the second sentence to obtain first semantic change information.
[0162] The first determining unit 540 is configured to determine a first mapping relationship between text changes and semantic changes between different sentences based on the first text change information and the first semantic change information.
[0163] In another embodiment, the second comparison unit is specifically used for:
[0164] Comparing the semantic element sequence of the first sentence with the semantic element sequence of the second sentence to obtain first semantic element change information of the first sentence relative to the second sentence, wherein the first semantic element change information includes the first semantic element changed in the first sentence relative to the second sentence and the semantic element change type;
[0165] The first semantic change information is determined based on the first semantic change information.
[0166] In another embodiment, the semantic element sequence of each sentence includes a word semantic element sequence, a sentence pattern semantic element sequence and a label semantic element sequence representing the sentence, wherein the word semantic element sequence represents the semantics of words in the sentence, the sentence pattern semantic element sequence represents the sentence pattern of the sentence, and the label semantic element sequence represents the semantics of the text label of the sentence;
[0167] The second comparison unit compares the semantic element sequence of the first sentence with the semantic element sequence of the second sentence in the following manner to obtain the first semantic element change information of the first sentence relative to the second sentence:
[0168] splicing the word semantic morpheme sequence, sentence pattern semantic morpheme sequence and label semantic morpheme sequence of the first sentence to obtain a target semantic morpheme sequence of the first sentence;
[0169] splicing the word semantic morpheme sequence, sentence pattern semantic morpheme sequence and label semantic morpheme sequence of the second sentence to obtain a target semantic morpheme sequence of the second sentence;
[0170] The target semantic element sequence of the first sentence is compared with the target semantic element sequence of the second sentence to obtain the first semantic element and semantic element change type of the first sentence that has changed relative to the second sentence.
[0171] In another embodiment, the first statement and the second statement are any two statements among N statements;
[0172] The first comparison unit is specifically used for:
[0173] Arrange the N statements in ascending order according to their length;
[0174] The N statements are traversed according to the arrangement result. Each time a statement is traversed, the currently traversed statement is taken as the first statement, and the statement that is arranged before the currently traversed statement is taken as the second statement. The first statement is compared with the second statement to obtain the first text change information.
[0175] In another embodiment, the first determining unit is specifically configured to:
[0176] Using the first text change information as a first training sample, and using the first semantic change information as a label of the first training sample;
[0177] Model training is performed based on the first training sample and the label of the first training sample to obtain a semantic change analysis model for representing the first mapping relationship.
[0178] In another embodiment, the semantic analysis device 500 further includes:
[0179] a creating unit, configured to create corresponding nodes for the first sentence and the second sentence after the second comparing unit obtains the first semantic change information;
[0180] The creation unit is further configured to create a connection edge between a node corresponding to the first statement and a node corresponding to the second statement, and use the first semantic change information as an edge attribute of the connection edge;
[0181] A generating unit is used to generate a semantic change graph based on the created nodes, the connecting edges between the created nodes, and the edge attributes of the connecting edges.
[0182] In another embodiment, the first determining unit is further configured to:
[0183] After the second comparison unit obtains the first semantic change information, a second mapping relationship between semantic changes and text label changes between different sentences is determined based on the first semantic change information, the text label of the first sentence, and the text label of the second sentence.
[0184] In another embodiment, the first semantic change information includes first semantic element change information of the first sentence relative to the second sentence;
[0185] The semantic element sequence of each sentence includes a word semantic element sequence, a sentence pattern semantic element sequence and a label semantic element sequence representing the sentence, wherein the word semantic element sequence represents the semantics of the words in the sentence, the sentence pattern semantic element sequence represents the sentence pattern of the sentence, and the label semantic element sequence represents the semantics of the text label of the sentence;
[0186] The first determining unit determines the second mapping relationship between the semantic changes and the text label changes between different sentences in the following manner:
[0187] The first semantic element change information and the text label of the first sentence are concatenated and added to the sample set as a second training sample, and the text label of the second sentence is used as a label of the second training sample;
[0188] The word semantic morpheme sequence of the first sentence and the sentence semantic morpheme sequence of the first sentence are concatenated and compared with the label semantic morpheme sequence of the first sentence to obtain second semantic morpheme change information, and the second semantic morpheme change information is concatenated with the text label of the first sentence as a third training sample and added to the sample set, and the text label of the first sentence is used as the label of the third training sample;
[0189] The word semantic morpheme sequence of the second sentence and the sentence semantic morpheme sequence of the second sentence are concatenated and compared with the label semantic morpheme sequence of the second sentence to obtain third semantic morpheme change information, and the third semantic morpheme change information is concatenated with the text label of the second sentence as a fourth training sample and added to the sample set, and the text label of the second sentence is used as the label of the fourth training sample;
[0190] Model training is performed based on the training samples in the sample set and the labels of the training samples to obtain a label prediction model for representing the second mapping relationship.
[0191] In another embodiment, the first sentence and the second sentence are obtained from a corpus, and the first sentence is obtained by adding and / or deleting some characters from the second sentence.
[0192] Obviously, the semantic analysis device provided in the embodiment of the present application can be used as the above Figure 1 The execution subject of the semantic analysis method shown in FIG. Figure 1 The functions realized are as follows. Since the principles are the same, they will not be described in detail.
[0193] Based on the same inventive concept, the present application embodiment also provides an intention recognition device. Figure 6 , is a structural diagram of an intention recognition device 600 provided in an embodiment of the present application, and the device 600 includes: an acquisition unit 610, a second determination unit 620 and a third determination unit 630.
[0194] The acquisition unit 610 is used to acquire a marked sentence that has an inclusion relationship with an unmarked sentence from a corpus, and determine second text change information of the unmarked sentence relative to the marked sentence, wherein the marked sentence is marked with an intent label.
[0195] The second determination unit 620 is used to determine the second semantic change information of the unlabeled sentence relative to the labeled sentence based on the second text change information and the first mapping relationship between text changes and semantic changes between different sentences, wherein the first mapping relationship is obtained by analyzing based on the semantic analysis method provided in an embodiment of the present application.
[0196] The third determining unit 630 is configured to determine the intention label of the unlabeled sentence based on the second semantic change information and the intention label of the labeled sentence.
[0197] In another embodiment, the third determining unit is specifically configured to:
[0198] Determining label change information of the unlabeled sentence relative to the labeled sentence based on the second semantic change information and a second mapping relationship between semantic change information and intent labels between different sentences, wherein the second mapping relationship is determined based on first semantic change information between labeled sentences in the corpus and the intent labels of the labeled sentences;
[0199] Based on the label change information and the intention label of the labeled sentence, the intention label of the unlabeled sentence is determined.
[0200] Obviously, the intention recognition device provided in the embodiment of the present application can be used as the above Figure 3 The execution subject of the intention recognition analysis method shown in the figure can realize the intention recognition device in Figure 3 The functions realized are as follows. Since the principles are the same, they will not be described in detail.
[0201] Figure 7 This is a schematic diagram of the structure of an electronic device according to an embodiment of the present application. Figure 7 At the hardware level, the electronic device includes a processor, and optionally also includes an internal bus, a network interface, and a memory. The memory may include a memory, such as a high-speed random access memory (RAM), and may also include a non-volatile memory (non-volatile memory), such as at least one disk storage. Of course, the electronic device may also include hardware required for other services.
[0202] The processor, network interface and memory can be interconnected through an internal bus, which can be an ISA (Industry Standard Architecture) bus, a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 7 Only one bidirectional arrow is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0203] The memory is used to store the program. Specifically, the program may include a program code, and the program code includes a computer operation instruction. The memory may include a memory and a non-volatile memory, and provides instructions and data to the processor.
[0204] The processor reads the corresponding computer program from the non-volatile memory into the memory and then runs it, forming a semantic analysis device at the logical level. The processor executes the program stored in the memory and is specifically used to perform the following operations:
[0205] Performing semantic component decomposition on the first sentence and the second sentence to obtain a semantic component sequence of the first sentence and a semantic component sequence of the second sentence;
[0206] Comparing the first sentence with the second sentence to obtain first text change information;
[0207] Comparing the semantic element sequence of the first sentence with the semantic element sequence of the second sentence to obtain first semantic change information;
[0208] Based on the first text change information and the first semantic change information, a first mapping relationship between text changes and semantic changes between different sentences is determined.
[0209] Alternatively, the processor reads the corresponding computer program from the non-volatile memory into the memory and then runs it, forming an intention recognition device at the logical level. The processor executes the program stored in the memory and is specifically used to perform the following operations:
[0210] Acquire a labeled sentence that has a containment relationship with an unlabeled sentence from a corpus, and determine second text change information of the unlabeled sentence relative to the labeled sentence, wherein the labeled sentence is labeled with an intent label;
[0211] Determine the second semantic change information of the unlabeled sentence relative to the labeled sentence based on the second text change information and the first mapping relationship between text changes and semantic changes between different sentences, wherein the first mapping relationship is obtained by analyzing the semantic analysis method provided in the embodiment of the present application;
[0212] Based on the second semantic change information and the intention label of the marked sentence, the intention label of the unmarked sentence is determined.
[0213] The above application Figure 1 The method performed by the semantic analysis device disclosed in the embodiment shown or the above-mentioned application Figure 3The method performed by the intention recognition device disclosed in the illustrated embodiment can be applied to a processor or implemented by a processor. The processor may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by an integrated logic circuit of hardware in the processor or an instruction in software form. The above processor may be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present application can be implemented or executed. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in the embodiments of the present application can be directly embodied as a hardware decoding processor for execution, or a combination of hardware and software modules in the decoding processor for execution. The software module can be located in a storage medium mature in the art such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory, and the processor reads the information in the memory and completes the steps of the above method in combination with its hardware.
[0214] The electronic device may also perform Figure 1 The method and the semantic analysis device are implemented in Figure 1 , Figure 2 Alternatively, the electronic device may also perform the functions of the embodiments shown. Figure 3 The method and the intention recognition device are implemented in Figure 3 , Figure 4 The functions of the illustrated embodiment will not be described in detail in the embodiments of the present application.
[0215] Of course, in addition to software implementation methods, the electronic device of the present application does not exclude other implementation methods, such as logic devices or a combination of software and hardware, etc. That is to say, the execution subject of the following processing flow is not limited to each logic unit, but can also be hardware or logic devices.
[0216] The embodiment of the present application also provides a computer-readable storage medium, which stores one or more programs, wherein the one or more programs include instructions, which, when executed by a portable electronic device including a plurality of application programs, enable the portable electronic device to execute Figure 1 The method of the embodiment shown is specifically used to perform the following operations:
[0217] Decomposing the first sentence and the second sentence into semantic components to obtain a semantic component sequence of the first sentence and a semantic component sequence of the second sentence;
[0218] Comparing the first sentence with the second sentence to obtain first text change information;
[0219] Comparing the semantic element sequence of the first sentence with the semantic element sequence of the second sentence to obtain first semantic change information;
[0220] Based on the first text change information and the first semantic change information, a first mapping relationship between text changes and semantic changes between different sentences is determined.
[0221] Alternatively, when the instruction is executed by a portable electronic device including a plurality of application programs, the portable electronic device can execute Figure 3 The method of the embodiment shown is specifically used to perform the following operations:
[0222] Acquire a labeled sentence that has a containment relationship with an unlabeled sentence from a corpus, and determine second text change information of the unlabeled sentence relative to the labeled sentence, wherein the labeled sentence is labeled with an intent label;
[0223] Determine the second semantic change information of the unlabeled sentence relative to the labeled sentence based on the second text change information and the first mapping relationship between text changes and semantic changes between different sentences, wherein the first mapping relationship is obtained by analyzing the semantic analysis method provided in the embodiment of the present application;
[0224] Based on the second semantic change information and the intention label of the marked sentence, the intention label of the unmarked sentence is determined.
[0225] An embodiment of the present application also provides a computer program product, which includes a non-transitory computer-readable storage medium storing a computer program, and the computer program is operable to cause a computer to execute part or all of the steps in the semantic analysis method or intent recognition method provided in the embodiment of the present application.
[0226] In short, the above description is only a preferred embodiment of the present application and is not intended to limit the protection scope of the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.
[0227] The systems, devices, modules or units described in the above embodiments may be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer. Specifically, the computer may be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
[0228] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0229] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0230] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
Claims
1. A semantic analysis method, characterized in that: include: Performing semantic component decomposition on the first sentence and the second sentence to obtain a semantic component sequence of the first sentence and a semantic component sequence of the second sentence; Comparing the first sentence with the second sentence to obtain first text change information; Comparing the semantic element sequence of the first sentence with the semantic element sequence of the second sentence to obtain first semantic change information; Based on the first text change information and the first semantic change information, a first mapping relationship between text changes and semantic changes between different sentences is determined.
2. The method according to claim 1, characterized in that The comparing the semantic element sequence of the first sentence with the semantic element sequence of the second sentence to obtain the first semantic change information includes: Comparing the semantic element sequence of the first sentence with the semantic element sequence of the second sentence to obtain first semantic element change information of the first sentence relative to the second sentence, wherein the first semantic element change information includes the first semantic element changed in the first sentence relative to the second sentence and the semantic element change type; The first semantic change information is determined based on the first semantic change information.
3. The method according to claim 2, characterized in that The semantic element sequence of each sentence includes a word semantic element sequence, a sentence pattern semantic element sequence and a label semantic element sequence representing the sentence, wherein the word semantic element sequence represents the semantics of the words in the sentence, the sentence pattern semantic element sequence represents the sentence pattern of the sentence, and the label semantic element sequence represents the semantics of the text label of the sentence; The comparing the semantic element sequence of the first sentence with the semantic element sequence of the second sentence to obtain the first semantic element change information of the first sentence relative to the second sentence includes: splicing the word semantic morpheme sequence, sentence pattern semantic morpheme sequence and label semantic morpheme sequence of the first sentence to obtain a target semantic morpheme sequence of the first sentence; splicing the word semantic morpheme sequence, sentence pattern semantic morpheme sequence and label semantic morpheme sequence of the second sentence to obtain a target semantic morpheme sequence of the second sentence; The target semantic element sequence of the first sentence is compared with the target semantic element sequence of the second sentence to obtain the first semantic element and semantic element change type of the first sentence that has changed relative to the second sentence.
4. The method according to claim 1, characterized in that The first statement and the second statement are any two statements among N statements; The comparing the first sentence and the second sentence to obtain first text change information includes: Arrange the N statements in ascending order according to their length; The N statements are traversed according to the arrangement result. Each time a statement is traversed, the currently traversed statement is taken as the first statement, and the statement that is arranged before the currently traversed statement is taken as the second statement. The first statement is compared with the second statement to obtain the first text change information.
5. The method according to claim 1, characterized in that The determining, based on the first text change information and the first semantic change information, a first mapping relationship between text changes and semantic changes between different sentences includes: Using the first text change information as a first training sample, and using the first semantic change information as a label of the first training sample; Model training is performed based on the first training sample and the label of the first training sample to obtain a semantic change analysis model for representing the first mapping relationship.
6. The method according to claim 1, characterized in that After comparing the semantic element sequence of the first sentence with the semantic element sequence of the second sentence to obtain first semantic change information, the method further includes: Creating corresponding nodes for the first statement and the second statement; Creating a connection edge between a node corresponding to the first statement and a node corresponding to the second statement, and using the first semantic change information as an edge attribute of the connection edge; A semantic change graph is generated based on the created nodes, the connecting edges between the created nodes, and the edge attributes of the connecting edges.
7. The method according to claim 1, characterized in that After comparing the semantic element sequence of the first sentence with the semantic element sequence of the second sentence to obtain first semantic change information, the method further includes: Based on the first semantic change information, the text label of the first sentence, and the text label of the second sentence, a second mapping relationship between semantic changes and text label changes between different sentences is determined.
8. The method according to claim 7, characterized in that The first semantic change information includes first semantic element change information of the first sentence relative to the second sentence; The semantic element sequence of each sentence includes a word semantic element sequence, a sentence pattern semantic element sequence and a label semantic element sequence representing the sentence, wherein the word semantic element sequence represents the semantics of the words in the sentence, the sentence pattern semantic element sequence represents the sentence pattern of the sentence, and the label semantic element sequence represents the semantics of the text label of the sentence; The determining, based on the first semantic change information, the text label of the first sentence, and the text label of the second sentence, a second mapping relationship between semantic changes and text label changes between different sentences includes: The first semantic element change information and the text label of the first sentence are concatenated and added to the sample set as a second training sample, and the text label of the second sentence is used as a label of the second training sample; The word semantic morpheme sequence of the first sentence and the sentence semantic morpheme sequence of the first sentence are concatenated and compared with the label semantic morpheme sequence of the first sentence to obtain second semantic morpheme change information, and the second semantic morpheme change information is concatenated with the text label of the first sentence as a third training sample and added to the sample set, and the text label of the first sentence is used as the label of the third training sample; The word semantic morpheme sequence of the second sentence and the sentence semantic morpheme sequence of the second sentence are concatenated and compared with the label semantic morpheme sequence of the second sentence to obtain third semantic morpheme change information, and the third semantic morpheme change information is concatenated with the text label of the second sentence as a fourth training sample and added to the sample set, and the text label of the second sentence is used as the label of the fourth training sample; Model training is performed based on the training samples in the sample set and the labels of the training samples to obtain a label prediction model for representing the second mapping relationship.
9. The method according to claim 1, characterized in that: The first sentence and the second sentence are obtained from a corpus, and the first sentence is obtained by adding and / or deleting some characters from the second sentence.
10. A method for intention recognition, characterized in that: include: Acquire a labeled sentence that has a containment relationship with an unlabeled sentence from a corpus, and determine second text change information of the unlabeled sentence relative to the labeled sentence, wherein the labeled sentence is labeled with an intent label; Determine the second semantic change information of the unlabeled sentence relative to the labeled sentence based on the second text change information and a first mapping relationship between text changes and semantic changes between different sentences, wherein the first mapping relationship is obtained by analyzing the semantic analysis method according to any one of claims 1 to 9; Based on the second semantic change information and the intention label of the marked sentence, the intention label of the unmarked sentence is determined.
11. The method according to claim 10, characterized in that The determining the intention label of the unlabeled sentence based on the second semantic change information and the intention label of the labeled sentence includes: Determining label change information of the unlabeled sentence relative to the labeled sentence based on the second semantic change information and a second mapping relationship between semantic change information and intent labels between different sentences, wherein the second mapping relationship is determined based on first semantic change information between labeled sentences in the corpus and the intent labels of the labeled sentences; Based on the label change information and the intention label of the labeled sentence, the intention label of the unlabeled sentence is determined.
12. A semantic analysis device, characterized in that: include: A decomposition unit, configured to perform semantic component decomposition on the first sentence and the second sentence to obtain a semantic component sequence of the first sentence and a semantic component sequence of the second sentence; A first comparison unit, used for comparing the first sentence and the second sentence to obtain first text change information; a second comparison unit, configured to compare the semantic element sequence of the first sentence with the semantic element sequence of the second sentence to obtain first semantic change information; The first determining unit is used to determine a first mapping relationship between text changes and semantic changes between different sentences based on the first text change information and the first semantic change information.
13. An intention recognition device, characterized in that: include: an acquisition unit, configured to acquire a labeled sentence that has an inclusion relationship with an unlabeled sentence from a corpus, and determine second text change information of the unlabeled sentence relative to the labeled sentence, wherein the labeled sentence is labeled with an intent label; a second determining unit, configured to determine second semantic change information of the unlabeled sentence relative to the labeled sentence based on the second text change information and a first mapping relationship between text changes and semantic changes between different sentences, wherein the first mapping relationship is obtained by analyzing the semantic analysis method according to any one of claims 1 to 9; The third determining unit is used to determine the intention label of the unlabeled sentence based on the second semantic change information and the intention label of the labeled sentence.
14. An electronic device, characterized in that: include: processor; a memory for storing instructions executable by the processor; The processor is configured to execute the instructions to implement the semantic analysis method as described in any one of claims 1 to 9; or, the processor is configured to execute the instructions to implement the intention recognition method as described in any one of claims 10 to 11.
15. A computer-readable storage medium, characterized in that: When the instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the semantic analysis method as described in any one of claims 1 to 9; or, when the instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the intention analysis method as described in any one of claims 10 to 11.
16. A computer program product, characterized in that The computer program product comprises a non-transitory computer-readable storage medium storing a computer program, wherein the computer program is operable to cause a computer to execute part or all of the steps in the method according to any one of claims 1 to 9 or any one of claims 10 to 11.
