Metaphor identification method, system, device and storage medium
By performing data enhancement and dual-encoder processing on the target input sentence, combined with the interpretation information of metaphoric words, the problem of poor metaphor recognition in the existing technology is solved, and more accurate metaphor recognition is achieved.
Patent Information
- Application Number
- CN202311632958.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-11-30
- Publication Date
- 2024-09-13
- Estimated Expiration
- 2043-11-30
AI Technical Summary
Existing metaphor recognition methods are difficult to effectively capture the semantic nuances of sentences and the linguistic features of metaphors, resulting in unsatisfactory recognition results.
By performing data enhancement processing on the target input sentences, similar sentences are generated and spliced, combined with the interpretation information of metaphorical words, and a dual-encoder model is used to capture semantic nuances and language features to train a metaphorical word recognition model.
The accuracy and effect of metaphor recognition are improved. Through rich semantic representation and dual encoder processing, more accurate parameters are obtained, and the performance of metaphor recognition is improved.
Smart Images

Figure CN117744595B
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of natural language processing, and in particular relates to a metaphor recognition method, system, device and storage medium. Background Art
[0002] Metaphor is a common language phenomenon, which refers to using one thing to describe or express another thing, thereby producing a new meaning or effect. Metaphor is not only a rhetorical device, but also a cognitive method, which reflects human understanding and imagination of the world. Metaphor is widely used in various fields such as daily communication, literary creation, scientific exploration, etc. It can enhance the expressiveness, creativity and persuasiveness of language, and can also promote the dissemination and innovation of knowledge. Therefore, metaphor research has important theoretical and practical value. Metaphor recognition aims to give computers the ability to analyze and understand metaphors like humans. It involves the intersection of multiple disciplines such as computer science and cognitive science. It has extremely important theoretical and practical application value. If the metaphor recognition problem cannot be solved well, it will affect the understanding of semantics and the improvement of application system performance. For example, in the fields of sentiment analysis, reading comprehension, human-computer dialogue, text summarization, text generation and machine translation, metaphor understanding directly affects the accuracy of processing.
[0003] Currently, metaphor recognition mainly relies on large models and is identified through two linguistic rules, namely the metaphor identification process (MIP) and selection preference violation (SPV). The metaphor identification process calculates the similarity between the contextual meaning and the basic meaning of the metaphor target word. The selection preference violation perceives the inconsistency between the target word and its context. Although the current method uses the interpretation factor gloss of metaphorical expression. Gloss refers to the interpretation of metaphorical expression. As a supplementary explanation of the metaphor, it provides more background knowledge and semantic information to help the model understand and interpret the meaning of the metaphor and improve the metaphor recognition effect. However, the semantic interaction between the interpretation factor gloss and the target word is not fully captured, and the effect is still not ideal.
[0004] Therefore, there is currently a lack of a method that can effectively capture the semantic nuances of sentences and the linguistic features of metaphors to achieve good metaphor recognition results. Summary of the invention
[0005] Based on the above existing metaphor recognition status, the present invention provides a metaphor recognition method, system, device and storage medium to overcome at least one technical problem existing in the prior art.
[0006] To achieve the above object, the present invention provides a metaphor identification method, comprising:
[0007] Performing enhancement processing on the target input sentence so that the target input sentence generates a similar sentence, and concatenating the target input sentence with the similar sentence to obtain an enhanced input sentence; wherein the target input sentence includes a target word with a metaphorical word mark, a part-of-speech tag of the target word, and a definition of the target word;
[0008] Performing data preprocessing on the enhanced input sentence so that the length of the enhanced input sentence is a preset data length, thereby obtaining a preprocessed input sentence;
[0009] Inputting the preprocessed input sentence into a pre-built metaphor word recognition model, the metaphor word recognition model comprising a left and right encoding layer, an embedding matrix encoding layer connected to the left and right encoding layer, a vector representation extraction layer connected to the embedding matrix encoding layer, a similarity calculation representation layer connected to the vector representation extraction layer, and a linear function layer connected to the similarity calculation representation layer;
[0010] In the left and right encoding layers, the preprocessed input sentence is encoded by a left encoder and a right encoder respectively to obtain a left encoding and a right encoding respectively; wherein the left encoding includes the semantic information of the enhanced input sentence and the enhanced input sentence; and the right encoding includes the semantic information of the enhanced input sentence, the target word, the part-of-speech tag of the target word, the definition of the target word and the basic meaning of the target word;
[0011] In the embedding matrix coding layer, the left code and the right code are respectively subjected to segmentation and embedding matrix coding processing to obtain a left embedding matrix and a right embedding matrix respectively;
[0012] In the vector representation extraction layer, a meaning vector of the target word in context and a context embedding vector of the enhanced input sentence are extracted from the left embedding matrix, and a basic meaning vector of the target word, a part-of-speech tag vector of the target word, and a meaning vector of the target word are extracted from the right embedding matrix;
[0013] In the similarity calculation representation layer, the meaning vector of the target word in the context and the basic meaning vector of the target word are substituted into a preset MIP similarity calculation representation formula to obtain a MIP vector representation, and the context embedding vector of the enhanced input sentence and the meaning vector of the target word in the context are substituted into a first SPV similarity calculation representation formula to obtain a first SPV vector representation, and the interpretation vector of the target word and the meaning vector of the target word in the context are substituted into a second SPV similarity calculation representation formula to obtain a second PVV vector representation;
[0014] In the linear function layer, the MIP vector representation, the first SPV vector representation, the second SPV vector representation, and the part-of-speech tag vector of the target word are substituted into a preset metaphor prediction label formula, and the parameter values in the metaphor prediction label formula are trained based on a preset result value of the target word, and the trained parameter values are used as parameters of the metaphor word recognition model to obtain a trained metaphor word recognition model, and the metaphor word recognition model is used to perform metaphor recognition on the input sentence to be recognized.
[0015] In order to solve the above problems, the present invention further provides a metaphor identification system, the system comprising:
[0016] A data enhancement module is used to enhance the target input sentence, so that the target input sentence generates a similar sentence, and concatenates the target input sentence with the similar sentence to obtain an enhanced input sentence; wherein the target input sentence includes a target word with a metaphorical word mark, a part-of-speech tag of the target word, and a definition of the target word;
[0017] A preprocessing module, used for performing data preprocessing on the enhanced input sentence, so that the length of the enhanced input sentence is a preset data length, and obtaining a preprocessed input sentence;
[0018] A model input module, used for inputting the preprocessed input sentence into a pre-built metaphor word recognition model, wherein the metaphor word recognition model comprises a left and right coding layer, an embedding matrix coding layer connected to the left and right coding layer, a vector representation extraction layer connected to the embedding matrix coding layer, a similarity calculation representation layer connected to the vector representation extraction layer, and a linear function layer connected to the similarity calculation representation layer;
[0019] An encoding module, configured to encode the preprocessed input sentence in the left and right encoding layers respectively through a left encoder and a right encoder to obtain a left encoding and a right encoding respectively; wherein the left encoding includes the semantic information of the enhanced input sentence and the enhanced input sentence; and the right encoding includes the semantic information of the enhanced input sentence, the target word, the part-of-speech tag of the target word, the definition of the target word and the basic meaning of the target word;
[0020] A segmentation coding module, used for performing segmentation and embedding matrix coding processing on the left code and the right code in the embedding matrix coding layer, respectively, to obtain a left embedding matrix and a right embedding matrix, respectively;
[0021] An extraction module, configured to extract, in the vector representation extraction layer, a meaning vector of the target word in context and a context embedding vector of the enhanced input sentence from the left embedding matrix, and extract a basic meaning vector of the target word, a part-of-speech tag vector of the target word, and a meaning vector of the target word from the right embedding matrix;
[0022] A calculation module, used for substituting the meaning vector of the target word in the context and the basic meaning vector of the target word into a preset MIP similarity calculation expression formula in the similarity calculation expression layer to obtain a MIP vector expression, substituting the context embedding vector of the enhanced input sentence and the meaning vector of the target word in the context into a first SPV similarity calculation expression formula to obtain a first SPV vector expression, and substituting the interpretation vector of the target word and the meaning vector of the target word in the context into a second SPV similarity calculation expression formula to obtain a second PVV vector expression;
[0023] The recognition module is used to substitute the MIP vector representation, the first SPV vector representation, the second SPV vector representation, and the part-of-speech tag vector of the target word into a preset metaphor prediction label formula in the linear function layer, train the parameter values in the metaphor prediction label formula based on the preset result value of the target word, and use the trained parameter values as parameters of the metaphor word recognition model to obtain a trained metaphor word recognition model, and use the metaphor word recognition model to perform metaphor recognition on the input sentence to be recognized.
[0024] In order to solve the above problem, the present invention further provides an electronic device, the electronic device comprising:
[0025] at least one processor; and,
[0026] a memory communicatively connected to the at least one processor; wherein,
[0027] The memory stores instructions that can be executed by the at least one processor. The instructions are executed by the at least one processor to enable the at least one processor to perform the steps in the metaphor identification method as described above.
[0028] In order to solve the above problem, the present invention also provides a computer-readable storage medium, in which at least one instruction is stored. When the at least one instruction is executed by a processor in an electronic device, the above metaphor recognition method is implemented.
[0029] The metaphor recognition method, system, device and storage medium provided by the present invention perform data enhancement processing on the target data to enrich the semantic representation of sentences and target words, combine the gloss information of metaphorical words, and use a dual encoder to effectively capture the semantic nuances of sentences and the language characteristics of metaphors, thereby making the parameters in the trained metaphorical word recognition model more accurate, thereby achieving good metaphor recognition effects. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0031] Figure 1 A schematic diagram of a flow chart of a metaphor identification method provided by an embodiment of the present invention;
[0032] Figure 2 A schematic diagram of a module of a metaphor identification system provided by an embodiment of the present invention;
[0033] Figure 3 A schematic diagram of the internal structure of an electronic device for implementing a metaphor recognition method provided by an embodiment of the present invention;
[0034] Figure 4 A flowchart of a metaphor identification method provided by an embodiment of the present invention;
[0035] Figure 5 The present invention provides a calculation process of MIP similarity calculation and SPV similarity calculation according to an embodiment of the present invention.
[0036] The realization of the purpose, functional features and advantages of the present invention will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0037] It should be understood that the specific embodiments described herein are only used to explain the present invention, and are not used to limit the present invention.
[0038] Based on the above-mentioned problems existing in the prior art, the present invention mainly provides a metaphor recognition method, system, device and storage medium, whose main purpose is to solve the problem in the prior art that there is a lack of a method that can effectively capture the semantic nuances of sentences and the language features of metaphors, so as to achieve good metaphor recognition effects.
[0039] Figure 1A flowchart of a metaphor identification method provided by an embodiment of the present invention is shown in FIG. 1. The method can be executed by a system, and the system can be implemented by software and / or hardware.
[0040] Figure 1 A general description of the metaphor identification method is given. Figure 1 As shown, in this embodiment, the metaphor identification method includes steps S110 to S180.
[0041] Step S110, enhance the target input sentence so that the target input sentence generates a similar sentence, and concatenate the target input sentence with the similar sentence to obtain an enhanced input sentence; wherein the target input sentence includes a target word marked with a metaphorical word, a part-of-speech tag of the target word, and a definition of the target word.
[0042] Specifically, the target input sentence is a training data text, including a target word with a metaphorical mark. The metaphorical mark, part-of-speech tag and interpretation of the target word can be completed manually or with the help of a marking tool, and there is no special limitation on this. The part-of-speech tag refers to the part of speech of a word, for example, a verb, an adjective, a noun, etc. The interpretation refers to the explanation of the metaphorical expression. By enhancing the target input sentence to enrich the semantic representation of the target input sentence and the target word, in an optional embodiment of the present invention, T5small can be used to enhance the target input sentence. T5small has powerful language modeling and representation capabilities, and uses context information to generate coherent output to obtain richer semantic information for the sentence, thereby achieving the effect of semantic enhancement of the sentence. For the imported target input sentence, use T5small to generate each semantically enhanced sentence, connect the enhanced sentence and the target input sentence, and obtain an enhanced input sentence.
[0043] Step S120: perform data preprocessing on the enhanced input sentence so that the length of the enhanced input sentence is a preset data length, thereby obtaining a preprocessed input sentence.
[0044] Specifically, during the data preprocessing process, it is ensured that the dimensions of the vectors generated by the preprocessed input sentences, i.e., the data input to the encoder, are equal. Therefore, the data length can be preset so that the length of the data input to the encoder each time is equal, so that the length of the encoding vectors obtained subsequently is equal. The preset data length is set according to actual needs.
[0045] As an optional embodiment of the present invention, data preprocessing is performed on the enhanced input sentence so that the length of the enhanced input sentence is a preset data length, and the preprocessed input sentence is obtained, including:
[0046] The enhanced input sentence longer than the preset data length is truncated, and the enhanced input sentence shorter than the preset data length is specially marked, so that the length of the enhanced input sentence is equal to the preset data length, thereby obtaining the preprocessed input sentence.
[0047] Specifically, the text of the augmented data that exceeds the preset data length needs to be truncated, and the text that is insufficient in length is padded. Padding can be performed using special markers (such as 0) to maintain consistent dimensions. Through this preprocessing method, the input text of the encoder can be adjusted to a fixed length for different data sets. Doing so can retain the text information as much as possible and make it suitable for the encoder input.
[0048] Step S130, input the preprocessed input sentence into the pre-built metaphor word recognition model, the metaphor word recognition model includes a left and right coding layer, an embedding matrix coding layer connected to the left and right coding layers, a vector representation extraction layer connected to the embedding matrix coding layer, a similarity calculation representation layer connected to the vector representation extraction layer, and a linear function layer connected to the similarity calculation representation layer.
[0049] Specifically, the pre-built metaphor word recognition model can directly perform metaphor recognition on sentences to be recognized after training the parameters of the model by using enhanced and pre-processed input sentences, wherein the left and right encoding layers include a left encoder and a right encoder.
[0050] Step S140, in the left and right coding layers, the preprocessed input sentence is encoded by the left encoder and the right encoder respectively to obtain the left code and the right code respectively; wherein the left code includes the enhanced semantic information of the input sentence and the enhanced input sentence; the right code includes the enhanced semantic information of the input sentence, the target word, the part-of-speech tag of the target word, the definition of the target word and the basic meaning of the target word.
[0051] Specifically, the pre-processed input sentences can be encoded using the dual encoder of the RoBERTa model, where the RoBERTa model is an improved version based on the BERT model, which optimizes the BERT pre-training process and improves the performance and robustness of the model. Improvements have been made based on the BERT pre-training model: a dynamic Masking mechanism is adopted, and a new masking method is generated each time a sequence is input to the model; the Next Sentence Prediction (NSP) task is deleted; the expected scale of the pre-training process is increased, and the batch size is expanded while the step size during training is increased. Consistent with the BERT model, the RoBERTa model also uses the encoder parts of multiple bidirectional Transformer models to stack to form the main framework, which can more thoroughly capture the bidirectional relationship in the text. Among them, the left encoder specifically uses the RoBERTa left encoder; the right encoder uses the RoBERTa right encoder. After the pre-processed input sentences are encoded by the RoBERTa left encoder and the RoBERTa right encoder, the left encoding and the right encoding are obtained respectively.
[0052] As an optional embodiment of the present invention, the left encoding is expressed as: L = ([CLS], enhanced input sentence, [SEP]); wherein [CLS] is the semantic information of the enhanced input sentence; [SEP] is a separator; and / or, the right encoding is expressed as:
[0053] R=([CLS],target_word,[SEP],POS,[SEP],Glo,[SEP],basic_using,[SEP]);
[0054] Among them, [CLS] is the semantic information of the enhanced input sentence where the target word is located; target_word is the target word; [SEP] is the separator; POS is the part-of-speech tag of the target word; Glo is the definition of the target word; basic_using is the basic meaning of the target word.
[0055] Specifically, in the above-mentioned left encoding representation L, the semantic information of the enhanced input sentence refers to the semantic information of the entire concatenated input sentence, which is a built-in function in the encoder, and is generally the average value of the sum of the vectors of each word in the enhanced input sentence. The enhanced input sentence is the enhanced input sentence corresponding to [CLS]. In the right encoding, POS, Glo, and basic_using are all annotated explanations, not vectors, with position indexes on them. The position is used to lock the position of the word vector used to identify POS, Glo, and basic_using in the subsequent right embedding matrix to obtain the corresponding POS, Glo, and basic_using vector representations.
[0056] Step S150: In the embedding matrix coding layer, the left code and the right code are respectively split and embedded matrix coded to obtain a left embedding matrix and a right embedding matrix, respectively.
[0057] Specifically, by segmenting and marking the left code and the right code, the code corresponding to the overall data represented by the left and right codes is segmented into multiple tags, and replaced with ordered codes according to their respective positions to form a left embedding matrix and a right embedding matrix.
[0058] As an optional embodiment of the present invention, the left code is segmented and embedded in the matrix coding process to obtain a left embedding matrix including:
[0059] Use Byte-Pair Encoding algorithm to split the left encoding into m tokens;
[0060] Convert m tokens into corresponding m embedding vectors;
[0061] Input m embedding vectors into the RoBERTa model to obtain a left embedding matrix in which the contextual relationship is represented by m embedding vectors;
[0062] The left embedding matrix is represented as: H L =RoBERTa(L)=(h l1 ,h l2 , ..., h lm );
[0063] Among them, H L is the left embedding matrix, h lm is the mth embedding vector; d is the dimension of the hidden layer representation of the RoBERTa model; and / or,
[0064] The right code is segmented and embedded in the matrix, and the right embedding matrix is obtained, including:
[0065] Use Byte-Pair Encoding algorithm to split the right code into n tokens;
[0066] Convert n tokens into corresponding n embedding vectors;
[0067] Input n embedding vectors into the RoBERTa model to obtain the right embedding matrix in which the contextual relationship is represented by n embedding vectors;
[0068] The right embedding matrix is expressed as:
[0069] H R =RoBERTa(R)=(h r1 ,h r2 ,…,h rn );
[0070] Among them, H R is the right embedding matrix, h rn is the nth embedding vector, d is the dimension of the hidden layer representation of the RoBERTa model; the contents represented by the right embedding matrix and the left embedding matrix are unified.
[0071] Specifically, the left code L and the right code R are segmented and encoded by the Byte-Pair Encoding (BPE) algorithm. After L is segmented into m tokens and R is segmented into n tokens, these tokens will be converted into corresponding embedding vectors as the input of the RoBERTa model to obtain the context representation. The left and right embedding matrices are unified, that is, the two correspond to each other.
[0072] Step S160: In the vector representation extraction layer, the meaning vector of the target word in the context and the context embedding vector of the enhanced input sentence are extracted from the left embedding matrix, and the basic meaning vector of the target word, the part-of-speech tag vector of the target word and the interpretation vector of the target word are extracted from the right embedding matrix.
[0073] Specifically, since the left embedding matrix and the right embedding matrix represent the enhanced input sentence, the target word in the enhanced input sentence, and the matrix composed of the position vector encoding of the part-of-speech tag, interpretation and basic meaning of the target word, the corresponding word vector in the right embedding matrix can be found according to the index corresponding to the part-of-speech tag, interpretation and basic meaning of the target word, and the corresponding word vectors are combined as the vector representation corresponding to the part-of-speech tag, interpretation and basic meaning of the target word. This is a commonly used method in the prior art, so it is not elaborated on.
[0074] As an optional embodiment of the present invention, in the process of extracting the meaning vector of the target word in the context and the context embedding vector of the enhanced input sentence from the left embedding matrix,
[0075] The representation formula of the meaning vector of the target word in the context is:
[0076] Among them, h t is the meaning vector of the target word in the context, k is the number of tokens cut by the target word, t is the starting subscript of the target word, and h li is the meaning vector of the i-th token among the k tokens into which the target word is segmented; i is a variable;
[0077] The representation formula of the context embedding vector of the enhanced input sentence is:
[0078]
[0079] Among them, hc is the context embedding vector of the enhanced input sentence, m is the number of embedding vectors, i is a variable, and h li is the i-th hidden layer vector of the left embedding vector matrix.
[0080] Specifically, we can represent H from the left embedding matrix L The contextual meaning vector of the target word is obtained by using h t Indicates that if the target word is cut into k tokens by the Byte-Pair Encoding algorithm, the average value needs to be taken, where t represents the starting subscript of the target word and the left embedding matrix H L The average value of represents the contextual embedding of the enhanced input sentence, denoted as hc. From the right embedding matrix H R Extract the basic meaning vector of the target word from h b The extracted part-of-speech tag vector is represented as h pos , extract the interpretation vector and represent it as h glo vector.
[0081] Step S170: In the similarity calculation representation layer, the meaning vector of the target word in the context and the basic meaning vector of the target word are substituted into a preset MIP similarity calculation representation formula to obtain a MIP vector representation, and the context embedding vector of the enhanced input sentence and the meaning vector of the target word in the context are substituted into a first SPV similarity calculation representation formula to obtain a first SPV vector representation, and the interpretation vector of the target word and the meaning vector of the target word in the context are substituted into a second SPV similarity calculation representation formula to obtain a second PVV vector representation.
[0082] Specifically, MIP is used to compare h b (the basic meaning vector of the target word) and the contextual meaning vector h of the target word t The input vectors are projected and transformed through linear transformation to compare their semantic similarity; similarly, the context embedding vector h of the enhanced input sentence is c and the contextual meaning vector h of the target word t Perform semantic similarity judgment to obtain h SPV1 ; The gloss vector of the target word is represented by h glo and the contextual meaning vector h of the target word t Perform semantic similarity judgment to obtain h SPV2 vector.
[0083] As an optional embodiment of the present invention, the MIP similarity calculation formula is:
[0084] in,
[0085] W MIP is the weight parameter of MIP, b MIP is the bias parameter of MIP, h t is the meaning vector of the target word in the context, h b is the basic meaning vector of the target word, and T is the transpose of the matrix;
[0086] The first SPV similarity calculation formula is:
[0087]
[0088] Among them, h SPV1 is the context embedding vector h for the augmented input sentence c and the meaning vector h of the target word in the context t The vector representation result obtained by semantic similarity judgment, W SPV1 h SPV1 The weight parameter, b SPV1 h SPV1 The bias parameter of , T is the transpose of the matrix;
[0089] The second SPV similarity calculation formula is:
[0090]
[0091] Among them, h SPV2 is the target word's interpretation vector h glo and the meaning vector h of the target word in the context t The vector representation result obtained by semantic similarity judgment, W SPV2 h SPV2 The weight parameter, b SPV2 h SPV2 The bias parameter of , T is the transpose of the matrix.
[0092] Specifically, during the calculation process, a reading method [·] is used, which can select different operations according to needs, such as absolute value |·|, concatenation operation; and product *. By adjusting the weight W of the MIP MIP and bias b MIP , we can use the basic meaning vector h b and the meaning vector h of the target word in the context t Perform appropriate mapping to obtain a new representation.
[0093] Step S180: In the linear function layer, the MIP vector representation, the first SPV vector representation, the second SPV vector representation, and the part-of-speech tag vector of the target word are substituted into a preset metaphor prediction label formula; based on a preset result value of the target word, the parameter values in the metaphor prediction label formula are trained; the trained parameter values are used as parameters of the metaphor word recognition model to obtain a trained metaphor word recognition model; and the metaphor word recognition model is used to perform metaphor recognition on the input sentence to be recognized.
[0094] Specifically, in the linear function layer, for the metaphor prediction label formula, there are generally two results, one is to identify the target word as a metaphor word, and the other is to identify the target word as a non-metaphor word. Since the metaphor word in the target input sentence, that is, the target word, is known, the recognition result of the metaphor prediction label formula for the target word is also known. For example, the result of the metaphor word is set to 1, and the result of the non-metaphor word is set to 0. Then, during the training process, after the MIP vector representation, the first SPV vector representation, the second SPV vector representation, and the part-of-speech tag vector of the target word are all input into the metaphor prediction label formula, the result can be set to 1. Through this training method, the parameter value in the formula is obtained, and the parameter value is used as the parameter of the metaphor word recognition model. After that, a trained metaphor word recognition model is obtained, and the trained metaphor word recognition model can be directly used to perform metaphor recognition on the input sentence to be recognized in the training method.
[0095] As an optional embodiment of the present invention, the metaphor prediction label formula is:
[0096] y=σ(W T [h MIP ;h SPV1 ;h SPV2 ;h POS ])+b; where
[0097] W represents the weight, b represents the bias parameter, σ represents the softmax function, y represents the predicted label distribution, and h POS Represents the meaning vector of the target word, T is the transpose of the matrix, y∈(0-1).
[0098] Specifically, combined with the basic meaning vector h of the target word b and the meaning vector h of the target word in the context t The similarity h MIP , the context embedding vector h of the enhanced input sentence c and the meaning vector h of the target word in the context t The semantic similarity h between SPV1 、The target word interpretation vector h glo and the meaning vector h of the target word in the context t The semantic similarity h betweenSPV2 , part-of-speech tag vector h pos To determine whether the target word is a metaphorical word, the value of y is set to a known result, such as 1, so that after training, the weight parameters and bias parameters of MIP, the bias parameters and weight parameters of SPV, and the weight parameters and bias parameters of the metaphorical word recognition model are obtained.
[0099] like Figure 2 As shown, the present invention provides a metaphor recognition system 200, which can be installed in an electronic device. According to the functions to be implemented, the metaphor recognition system 200 may include a parameter data enhancement module 210, a preprocessing module 220, a model input module 230, a coding module 240, a segmentation coding module 250, an extraction module 260, a calculation module 270 and a recognition module 280. The unit of the present invention can also be called a module, which refers to a series of computer program segments that can be executed by an electronic device processor and can complete fixed functions, which are stored in the memory of the electronic device.
[0100] In this embodiment, the functions of each module / unit are as follows:
[0101] The data enhancement module 210 is used to enhance the target input sentence, so that the target input sentence generates a similar sentence, and concatenates the target input sentence with the similar sentence to obtain an enhanced input sentence; wherein the target input sentence includes a target word with a metaphorical word mark, a part-of-speech tag of the target word, and a definition of the target word;
[0102] A preprocessing module 220 is used to perform data preprocessing on the enhanced input sentence so that the length of the enhanced input sentence is a preset data length, thereby obtaining a preprocessed input sentence;
[0103] A model input module 230, used for inputting the preprocessed input sentence into a pre-built metaphor word recognition model, wherein the metaphor word recognition model includes a left and right coding layer, an embedding matrix coding layer connected to the left and right coding layer, a vector representation extraction layer connected to the embedding matrix coding layer, a similarity calculation representation layer connected to the vector representation extraction layer, and a linear function layer connected to the similarity calculation representation layer;
[0104] The encoding module 240 is used to encode the preprocessed input sentence in the left and right encoding layers by using a left encoder and a right encoder respectively to obtain a left encoding and a right encoding respectively; wherein the left encoding includes the enhanced semantic information of the input sentence and the enhanced input sentence; and the right encoding includes the enhanced semantic information of the input sentence, the target word, the part-of-speech tag of the target word, the definition of the target word and the basic meaning of the target word;
[0105] A segmentation coding module 250 is used to perform segmentation and embedding matrix coding processing on the left code and the right code in the embedding matrix coding layer to obtain a left embedding matrix and a right embedding matrix respectively;
[0106] An extraction module 260 is used to extract the meaning vector of the target word in the context and the context embedding vector of the enhanced input sentence from the left embedding matrix in the vector representation extraction layer, and to extract the basic meaning vector of the target word, the part-of-speech tag vector of the target word, and the interpretation vector of the target word from the right embedding matrix;
[0107] A calculation module 270 is used to substitute the meaning vector of the target word in the context and the basic meaning vector of the target word into a preset MIP similarity calculation expression formula in the similarity calculation expression layer to obtain a MIP vector expression, substitute the context embedding vector of the enhanced input sentence and the meaning vector of the target word in the context into a first SPV similarity calculation expression formula to obtain a first SPV vector expression, and substitute the interpretation vector of the target word and the meaning vector of the target word in the context into a second SPV similarity calculation expression formula to obtain a second PVV vector expression;
[0108] The recognition module 280 is used to substitute the MIP vector representation, the first SPV vector representation, the second SPV vector representation, and the part-of-speech tag vector of the target word into a preset metaphor prediction label formula in the linear function layer, train the parameter values in the metaphor prediction label formula based on the preset result value of the target word, and use the trained parameter values as parameters of the metaphor word recognition model to obtain a trained metaphor word recognition model, and use the metaphor word recognition model to perform metaphor recognition on the input sentence to be recognized.
[0109] The metaphor recognition system 200 of the present invention performs data enhancement processing on the target data to enrich the semantic representation of sentences and target words, combines the gloss information of metaphorical words, and uses a dual encoder to effectively capture the semantic nuances of sentences and the language characteristics of metaphors, thereby making the parameters in the trained metaphorical word recognition formula more accurate, thereby achieving good metaphor recognition results.
[0110] like Figure 3 As shown, the present invention provides an electronic device 3 for a metaphor recognition method.
[0111] The electronic device 3 may include a processor 30, a memory 31 and a bus, and may also include a computer program stored in the memory 31 and executable on the processor 30, such as a metaphor recognition program 32. The memory 31 may also include both an internal storage unit of the metaphor recognition system and an external storage device. The memory 31 may be used not only to store application software and various data, such as the code of the metaphor recognition program, but also to temporarily store data that has been output or is to be output.
[0112] The memory 31 includes at least one type of readable storage medium, and the readable storage medium includes a flash memory, a mobile hard disk, a multimedia card, a card-type memory (e.g., SD or DX memory, etc.), a magnetic memory, a disk, an optical disk, etc. The memory 31 may be an internal storage unit of the electronic device 3 in some embodiments, such as a mobile hard disk of the electronic device 3. The memory 31 may also be an external storage device of the electronic device 3 in other embodiments, such as a plug-in mobile hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. equipped on the electronic device 3. Further, the memory 31 may also include both an internal storage unit of the electronic device 3 and an external storage device. The memory 31 may not only be used to store application software and various types of data installed in the electronic device 3, such as metaphor recognition method code, etc., but also be used to temporarily store data that has been output or is to be output.
[0113] The processor 30 may be composed of an integrated circuit in some embodiments, for example, a single packaged integrated circuit, or a plurality of packaged integrated circuits with the same or different functions, including one or more central processing units (CPUs), microprocessors, digital processing chips, graphics processors, and combinations of various control chips, etc. The processor 30 is the control core (Control Unit) of the electronic device, and uses various interfaces and lines to connect various components of the entire electronic device, and executes or executes programs or modules (such as metaphor recognition programs, etc.) stored in the memory 31, and calls data stored in the memory 31 to execute various functions of the electronic device 3 and process data.
[0114] The bus may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. The bus is configured to realize connection and communication between the memory 31 and at least one processor 30, etc.
[0115] Figure 3 Only an electronic device with components is shown, and those skilled in the art will understand that Figure 3 The structure shown does not constitute a limitation on the electronic device 3, and may include fewer or more components than shown in the figure, or combine certain components, or arrange the components differently.
[0116] For example, although not shown, the electronic device 3 may also include a power source (such as a battery) for supplying power to each component. Preferably, the power source may be logically connected to the at least one processor 30 through a power management system, so that the power management system can realize functions such as charging management, discharging management, and power consumption management. The power source may also include any components such as one or more DC or AC power sources, recharging systems, power failure detection circuits, power converters or inverters, and power status indicators. The electronic device 3 may also include a variety of sensors, Bluetooth modules, Wi-Fi modules, etc., which will not be repeated here.
[0117] Furthermore, the electronic device 3 may also include a network interface. Optionally, the network interface may include a wired interface and / or a wireless interface (such as a WI-FI interface, a Bluetooth interface, etc.), which is generally used to establish a communication connection between the electronic device 3 and other electronic devices.
[0118] Optionally, the electronic device 3 may further include a user interface, which may be a display, an input unit (such as a keyboard), or a standard wired interface or a wireless interface. Optionally, in some embodiments, the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, and an OLED (Organic Light-Emitting Diode) touch device. The display may also be appropriately referred to as a display screen or a display unit, which is used to display information processed in the electronic device 3 and to display a visual user interface.
[0119] It should be understood that the embodiments are for illustration purposes only and the scope of the invention application is not limited by this structure.
[0120] The metaphor recognition program 32 stored in the memory 31 in the electronic device 3 is a combination of multiple instructions. When running in the processor 30, it can achieve:
[0121] Step S110, enhancing the target input sentence so that the target input sentence generates a similar sentence, and concatenating the target input sentence with the similar sentence to obtain an enhanced input sentence; wherein the target input sentence includes a target word with a metaphorical word mark, a part-of-speech tag of the target word, and a definition of the target word;
[0122] Step S120, performing data preprocessing on the enhanced input sentence so that the length of the enhanced input sentence is a preset data length, thereby obtaining a preprocessed input sentence;
[0123] Step S130, inputting the preprocessed input sentence into the pre-built metaphor word recognition model, the metaphor word recognition model comprising a left and right coding layer, an embedding matrix coding layer connected to the left and right coding layer, a vector representation extraction layer connected to the embedding matrix coding layer, a similarity calculation representation layer connected to the vector representation extraction layer, and a linear function layer connected to the similarity calculation representation layer;
[0124] Step S140: In the left and right coding layers, the pre-processed input sentence is encoded by the left encoder and the right encoder respectively to obtain a left code and a right code respectively; wherein the left code includes the enhanced semantic information of the input sentence and the enhanced input sentence; the right code includes the enhanced semantic information of the input sentence, the target word, the part-of-speech tag of the target word, the definition of the target word and the basic meaning of the target word;
[0125] Step S150: In the embedding matrix coding layer, the left code and the right code are respectively split and embedded in the matrix coding process to obtain a left embedding matrix and a right embedding matrix respectively;
[0126] Step S160, in the vector representation extraction layer, extracting the meaning vector of the target word in the context and the context embedding vector of the enhanced input sentence from the left embedding matrix, and extracting the basic meaning vector of the target word, the part-of-speech tag vector of the target word, and the interpretation vector of the target word from the right embedding matrix;
[0127] Step S170: In the similarity calculation representation layer, the meaning vector of the target word in the context and the basic meaning vector of the target word are substituted into a preset MIP similarity calculation representation formula to obtain a MIP vector representation, and the context embedding vector of the enhanced input sentence and the meaning vector of the target word in the context are substituted into a first SPV similarity calculation representation formula to obtain a first SPV vector representation, and the interpretation vector of the target word and the meaning vector of the target word in the context are substituted into a second SPV similarity calculation representation formula to obtain a second PVV vector representation;
[0128] Step S180: In the linear function layer, the MIP vector representation, the first SPV vector representation, the second SPV vector representation, and the part-of-speech tag vector of the target word are substituted into a preset metaphor prediction label formula; based on a preset result value of the target word, the parameter values in the metaphor prediction label formula are trained; the trained parameter values are used as parameters of the metaphor word recognition model to obtain a trained metaphor word recognition model; and the metaphor word recognition model is used to perform metaphor recognition on the input sentence to be recognized.
[0129] Specifically, the specific implementation method of the processor 30 for the above instructions can refer to Figure 1 The description of the relevant steps in the corresponding embodiments will not be repeated here.
[0130] Furthermore, if the module / unit integrated in the electronic device 3 is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. The computer-readable medium may include: any entity or system capable of carrying the computer program code, a recording medium, a USB flash drive, a mobile hard disk, a magnetic disk, an optical disk, a computer memory, and a read-only memory (ROM).
[0131] An embodiment of the present invention further provides a computer-readable storage medium, which may be non-volatile or volatile, and stores a computer program, which, when executed by a processor, implements:
[0132] Step S110, enhancing the target input sentence so that the target input sentence generates a similar sentence, and concatenating the target input sentence with the similar sentence to obtain an enhanced input sentence; wherein the target input sentence includes a target word with a metaphorical word mark, a part-of-speech tag of the target word, and a definition of the target word;
[0133] Step S120, performing data preprocessing on the enhanced input sentence so that the length of the enhanced input sentence is a preset data length, thereby obtaining a preprocessed input sentence;
[0134] Step S130, inputting the preprocessed input sentence into the pre-built metaphor word recognition model, the metaphor word recognition model comprising a left and right coding layer, an embedding matrix coding layer connected to the left and right coding layer, a vector representation extraction layer connected to the embedding matrix coding layer, a similarity calculation representation layer connected to the vector representation extraction layer, and a linear function layer connected to the similarity calculation representation layer;
[0135] Step S140: In the left and right coding layers, the pre-processed input sentence is encoded by the left encoder and the right encoder respectively to obtain a left code and a right code respectively; wherein the left code includes the enhanced semantic information of the input sentence and the enhanced input sentence; the right code includes the enhanced semantic information of the input sentence, the target word, the part-of-speech tag of the target word, the definition of the target word and the basic meaning of the target word;
[0136] Step S150: In the embedding matrix coding layer, the left code and the right code are respectively split and embedded in the matrix coding process to obtain a left embedding matrix and a right embedding matrix respectively;
[0137] Step S160, in the vector representation extraction layer, extracting the meaning vector of the target word in the context and the context embedding vector of the enhanced input sentence from the left embedding matrix, and extracting the basic meaning vector of the target word, the part-of-speech tag vector of the target word, and the interpretation vector of the target word from the right embedding matrix;
[0138] Step S170: In the similarity calculation representation layer, the meaning vector of the target word in the context and the basic meaning vector of the target word are substituted into a preset MIP similarity calculation representation formula to obtain a MIP vector representation, and the context embedding vector of the enhanced input sentence and the meaning vector of the target word in the context are substituted into a first SPV similarity calculation representation formula to obtain a first SPV vector representation, and the interpretation vector of the target word and the meaning vector of the target word in the context are substituted into a second SPV similarity calculation representation formula to obtain a second PVV vector representation;
[0139] Step S180: In the linear function layer, the MIP vector representation, the first SPV vector representation, the second SPV vector representation, and the part-of-speech tag vector of the target word are substituted into a preset metaphor prediction label formula; based on a preset result value of the target word, the parameter values in the metaphor prediction label formula are trained; the trained parameter values are used as parameters of the metaphor word recognition model to obtain a trained metaphor word recognition model; and the metaphor word recognition model is used to perform metaphor recognition on the input sentence to be recognized.
[0140] Specifically, the specific implementation method when the computer program is executed by the processor can refer to the description of the relevant steps in the metaphor identification method in the embodiment, which will not be repeated here.
[0141] In the several embodiments provided by the present invention, it should be understood that the disclosed devices, systems and methods can be implemented in other ways. For example, the system embodiments described above are only schematic, for example, the division of the modules is only a logical function division, and there may be other division methods in actual implementation.
[0142] The modules described as separate components may or may not be physically separated, and the components shown as modules may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0143] In addition, each functional module in each embodiment of the present invention may be integrated into one processing unit, each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of hardware plus software functional modules.
[0144] It is obvious to those skilled in the art that the present invention is not limited to the details of the above exemplary embodiments, and that the present invention can be implemented in other specific forms without departing from the spirit or essential characteristics of the present invention.
[0145] Therefore, no matter from which point of view, the embodiments should be regarded as illustrative and non-restrictive, and the scope of the present invention is limited by the appended claims rather than the above description, so it is intended that all changes falling within the meaning and scope of the equivalent elements of the claims are included in the present invention. Any attached figure mark in the claims should not be regarded as limiting the claims involved.
[0146] In addition, it is clear that the word "comprising" does not exclude other units or steps, and the singular does not exclude the plural. Multiple units or systems stated in a system claim can also be implemented by one unit or system through software or hardware. Secondary words are used to indicate names, but not to indicate any particular order.
[0147] Finally, it should be noted that the above embodiments are only used to illustrate the technical solution of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solution of the present invention can be modified or replaced by equivalents without departing from the spirit and scope of the technical solution of the present invention.
Claims
1. A metaphor identification method, characterized in that: The steps include: Performing enhancement processing on the target input sentence so that the target input sentence generates a similar sentence, and concatenating the target input sentence with the similar sentence to obtain an enhanced input sentence; wherein the target input sentence includes a target word with a metaphorical word mark, a part-of-speech tag of the target word, and a definition of the target word; Performing data preprocessing on the enhanced input sentence so that the length of the enhanced input sentence is a preset data length, thereby obtaining a preprocessed input sentence; Inputting the preprocessed input sentence into a pre-built metaphor word recognition model, the metaphor word recognition model comprising a left and right encoding layer, an embedding matrix encoding layer connected to the left and right encoding layer, a vector representation extraction layer connected to the embedding matrix encoding layer, a similarity calculation representation layer connected to the vector representation extraction layer, and a linear function layer connected to the similarity calculation representation layer; In the left and right encoding layers, the preprocessed input sentence is encoded by a left encoder and a right encoder respectively to obtain a left encoding and a right encoding respectively; wherein the left encoding includes the semantic information of the enhanced input sentence and the enhanced input sentence; and the right encoding includes the semantic information of the enhanced input sentence, the target word, the part-of-speech tag of the target word, the definition of the target word and the basic meaning of the target word; In the embedding matrix coding layer, the left code and the right code are respectively subjected to segmentation and embedding matrix coding processing to obtain a left embedding matrix and a right embedding matrix respectively; In the vector representation extraction layer, a meaning vector of the target word in context and a context embedding vector of the enhanced input sentence are extracted from the left embedding matrix, and a basic meaning vector of the target word, a part-of-speech tag vector of the target word, and a meaning vector of the target word are extracted from the right embedding matrix; In the similarity calculation representation layer, the meaning vector of the target word in the context and the basic meaning vector of the target word are substituted into a preset MIP similarity calculation representation formula to obtain a MIP vector representation, and the context embedding vector of the enhanced input sentence and the meaning vector of the target word in the context are substituted into a first SPV similarity calculation representation formula to obtain a first SPV vector representation, and the interpretation vector of the target word and the meaning vector of the target word in the context are substituted into a second SPV similarity calculation representation formula to obtain a second PVV vector representation; In the linear function layer, the MIP vector representation, the first SPV vector representation, the second SPV vector representation, and the part-of-speech tag vector of the target word are substituted into a preset metaphor prediction label formula, and the parameter values in the metaphor prediction label formula are trained based on a preset result value of the target word, and the trained parameter values are used as parameters of the metaphor word recognition model to obtain a trained metaphor word recognition model, and the metaphor word recognition model is used to perform metaphor recognition on the input sentence to be recognized.
2. The metaphor identification method according to claim 1, characterized in that: The step of performing data preprocessing on the enhanced input sentence so that the length of the enhanced input sentence is a preset data length and obtaining the preprocessed input sentence comprises: The enhanced input sentence longer than the preset data length is truncated, and the enhanced input sentence shorter than the preset data length is specially marked so that the length of the enhanced input sentence is equal to the preset data length, thereby obtaining the preprocessed input sentence.
3. The metaphor identification method according to claim 1, characterized in that: The left encoding is represented as: L=([CLS], enhanced input sentence, [SEP]); wherein [CLS] is the semantic information of the enhanced input sentence; [SEP] is a separator; and / or, The right encoding is expressed as: R=([CLS],target_word,[SEP],POS,[SEP],Glo,[SEP],basic_using,[SEP]); Among them, [CLS] is the semantic information of the enhanced input sentence where the target word is located; target_word is the target word; [SEP] is the separator; POS is the part-of-speech tag of the target word; Glo is the definition of the target word; basic_using is the basic meaning of the target word.
4. The metaphor identification method according to claim 1, characterized in that: The left code is segmented and embedded in the matrix coding process to obtain a left embedding matrix including: Using Byte-Pair Encoding algorithm to split the left encoding into m tokens; Convert the m tokens into corresponding m embedding vectors; The m embedding vectors are input into the RoBERTa model to obtain a left embedding matrix in which the contextual relationship is represented by the m embedding vectors; wherein, The left embedding matrix is expressed as: H L =RoBERTa(L)=(h l1 ,h l2 , ..., h lm ); Among them, H L is the left embedding matrix, h lm is the mth embedding vector; and / or, The right code is segmented and embedded in the matrix coding process to obtain a right embedding matrix including: Using Byte-Pair Encoding algorithm to split the right code into n tokens; Convert the n tokens into corresponding n embedding vectors; The n embedding vectors are input into the RoBERTa model to obtain a right embedding matrix in which the contextual relationship is represented by the n embedding vectors; wherein, The right embedding matrix is expressed as: H R =RoBERTa(R)=(h r1 ,h r2 ,...,h rn ); Among them, H R is the right embedding matrix, h rn is the nth embedding vector; the contents represented by the right embedding matrix and the left embedding matrix are unified.
5. The metaphor identification method according to claim 1, characterized in that: In the process of extracting the meaning vector of the target word in the context and the context embedding vector of the enhanced input sentence from the left embedding matrix, The expression formula of the meaning vector of the target word in the context is: Among them, h t is the meaning vector of the target word in the context, k is the number of tokens cut by the target word, t is the starting subscript of the target word, and h li is the i-th vector of the left embedded vector matrix; i is a variable; The representation formula of the context embedding vector of the enhanced input sentence is: Among them, h c is the context embedding vector of the enhanced input sentence, m is the number of embedding vectors, i is a variable, and h li is the i-th vector of the left embedding vector matrix.
6. The metaphor identification method according to claim 1, characterized in that: The MIP similarity calculation formula is: in, W MIP is the weight parameter of MIP, b MIP is the bias parameter of MIP, h t is the meaning vector of the target word in the context, h b is the basic meaning vector of the target word, and T is the transpose of the matrix; The first SPV similarity calculation formula is: Among them, h SPV1 is the context embedding vector h for the augmented input sentence c and the meaning vector h of the target word in the context t The vector representation result obtained by semantic similarity judgment, W SPV1 h SPV1 The weight parameter, b SPV1 h SPV1 The bias parameter of , T is the transpose of the matrix; The second SPV similarity calculation formula is: Among them, h SPV2 is the target word's interpretation vector h glo and the meaning vector h of the target word in the context t The vector representation result obtained by semantic similarity judgment, W SPV2 h SPV2 The weight parameter, b SPV2 h SPV2 The bias parameter of , T is the transpose of the matrix.
7. The metaphor identification method according to claim 6, characterized in that: The metaphor prediction label formula is: y = σ (W T [h MIP ;h SPV1 ;h SPV2 ;h POS ])+b; where W represents the weight, b represents the bias parameter, σ represents the softmax function, y represents the predicted label distribution, and h POS Represents the meaning vector of the target word, T is the transpose of the matrix, y∈(0-1).
8. A metaphor recognition system, characterized in that: The system comprises: A data enhancement module is used to enhance the target input sentence, so that the target input sentence generates a similar sentence, and concatenates the target input sentence with the similar sentence to obtain an enhanced input sentence; wherein the target input sentence includes a target word with a metaphorical word mark, a part-of-speech tag of the target word, and a definition of the target word; A preprocessing module, used for performing data preprocessing on the enhanced input sentence, so that the length of the enhanced input sentence is a preset data length, and obtaining a preprocessed input sentence; A model input module, used for inputting the preprocessed input sentence into a pre-built metaphor word recognition model, wherein the metaphor word recognition model comprises a left and right coding layer, an embedding matrix coding layer connected to the left and right coding layer, a vector representation extraction layer connected to the embedding matrix coding layer, a similarity calculation representation layer connected to the vector representation extraction layer, and a linear function layer connected to the similarity calculation representation layer; An encoding module, configured to encode the preprocessed input sentence in the left and right encoding layers respectively through a left encoder and a right encoder to obtain a left encoding and a right encoding respectively; wherein the left encoding includes the semantic information of the enhanced input sentence and the enhanced input sentence; and the right encoding includes the semantic information of the enhanced input sentence, the target word, the part-of-speech tag of the target word, the definition of the target word and the basic meaning of the target word; A segmentation coding module, used for performing segmentation and embedding matrix coding processing on the left code and the right code in the embedding matrix coding layer, respectively, to obtain a left embedding matrix and a right embedding matrix, respectively; An extraction module, configured to extract, in the vector representation extraction layer, a meaning vector of the target word in context and a context embedding vector of the enhanced input sentence from the left embedding matrix, and extract a basic meaning vector of the target word, a part-of-speech tag vector of the target word, and a meaning vector of the target word from the right embedding matrix; A calculation module, used for substituting the meaning vector of the target word in the context and the basic meaning vector of the target word into a preset MIP similarity calculation expression formula in the similarity calculation expression layer to obtain a MIP vector expression, substituting the context embedding vector of the enhanced input sentence and the meaning vector of the target word in the context into a first SPV similarity calculation expression formula to obtain a first SPV vector expression, and substituting the interpretation vector of the target word and the meaning vector of the target word in the context into a second SPV similarity calculation expression formula to obtain a second PVV vector expression; The recognition module is used to substitute the MIP vector representation, the first SPV vector representation, the second SPV vector representation, and the part-of-speech tag vector of the target word into a preset metaphor prediction label formula in the linear function layer, train the parameter values in the metaphor prediction label formula based on the preset result value of the target word, and use the trained parameter values as parameters of the metaphor word recognition model to obtain a trained metaphor word recognition model, and use the metaphor word recognition model to perform metaphor recognition on the input sentence to be recognized.
9. An electronic device, characterized in that: The electronic device comprises: at least one processor; and, a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the steps in the metaphor identification method according to any one of claims 1 to 7.
10. A computer-readable storage medium storing at least one instruction, characterized in that: When the at least one instruction is executed by a processor in an electronic device, the metaphor identification method according to any one of claims 1 to 7 is implemented.
