Method, device, readable medium and electronic device for identifying characters in text

By obtaining and combining word and related word vectors in e-books, and using pre-trained models to identify character entities in e-books, the problem of low manual annotation efficiency in the existing technology is solved, and the recognition accuracy and efficiency are improved.

CN112906380BActive Publication Date: 2024-09-27BEIJING YOUZHUJU NETWORK TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202110145123.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-02-02
Publication Date
2024-09-27
Estimated Expiration
2041-02-02

AI Technical Summary

Technical Problem

The existing technology requires manual annotation in the process of identifying characters in e-books, resulting in low processing efficiency and accuracy.

Method used

By obtaining each word and word vector in the text to be recognized, the associated word vector of each word is determined, combined into a combined vector sequence, and the pre-trained recognition model is used to automatically identify character entities in the text.

Benefits of technology

It improves the accuracy of identifying character entities, reduces the need for manual annotation, and improves processing efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112906380B
    Figure CN112906380B
Patent Text Reader

Abstract

The present disclosure relates to a method, device, readable medium and electronic device for identifying a role in a text, and relates to the field of electronic information processing technology. The method comprises: obtaining each character included in the text to be identified and a character vector corresponding to each character, determining a word vector corresponding to an associated term corresponding to each character in the text to be identified, wherein the associated term is determined according to a combination term corresponding to the character, wherein the combination term is composed of the character and a preset number of characters adjacent to the character, and the character vector corresponding to each character and the word vector corresponding to the associated term corresponding to the character are combined into a combination vector corresponding to the character to obtain a combination vector sequence corresponding to the text to be identified, wherein the combination vector sequence includes a combination vector corresponding to each character in the text to be identified, and according to the combination vector sequence and a pre-trained recognition model, determining the character entity included in the text to be identified. The present disclosure can improve the accuracy of identifying the character entity.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the technical field of electronic information processing, and in particular, to a method, device, readable medium and electronic device for identifying a role in a text. Background Art

[0002] With the continuous development of electronic information technology, people's entertainment life has become more and more abundant, and reading e-books has become a mainstream way of reading. In order to enable users to obtain the information included in the e-book through hearing when it is inconvenient to read the e-book, or to read and listen at the same time, to obtain the information included in the e-book from the two dimensions of vision and hearing, the corresponding audio is often pre-recorded for the e-book for users to listen to. In order to enrich the expressiveness of the audio, different timbres can be used to record the dialogues of different characters in the e-book during the audio recording process, so it is necessary to identify the different characters in the e-book first. Usually, each character in the e-book needs to be manually annotated, and the processing efficiency and accuracy are low. Summary of the invention

[0003] This summary is provided to introduce concepts in a brief form that will be described in detail in the detailed description below. This summary is not intended to identify key features or essential features of the claimed technical solution, nor is it intended to limit the scope of the claimed technical solution.

[0004] In a first aspect, the present disclosure provides a method for identifying a character in a text, the method comprising:

[0005] Obtain each word included in the text to be recognized and the word vector corresponding to each word;

[0006] Determine a word vector corresponding to an associated word corresponding to each character in the to-be-recognized text, wherein the associated word is determined according to a combined word corresponding to the character, and the combined word is composed of the character and a preset number of characters adjacent to the character;

[0007] Combining the character vector corresponding to each character and the word vector corresponding to the associated word corresponding to the character into a combination vector corresponding to the character, so as to obtain a combination vector sequence corresponding to the text to be recognized, wherein the combination vector sequence includes the combination vector corresponding to each character in the text to be recognized;

[0008] According to the combined vector sequence and the pre-trained recognition model, the character entities included in the text to be recognized are determined.

[0009] In a second aspect, the present disclosure provides a device for identifying a character in a text, the device comprising:

[0010] An acquisition module, used to acquire each word included in the text to be recognized and the word vector corresponding to each word;

[0011] A determination module, used to determine a word vector corresponding to an associated word corresponding to each character in the to-be-recognized text, wherein the associated word is determined according to a combination word corresponding to the character, and the combination word is composed of the character and a preset number of characters adjacent to the character;

[0012] A processing module, used for combining the character vector corresponding to each character and the word vector corresponding to the associated word corresponding to the character to form a combination vector corresponding to the character, so as to obtain a combination vector sequence corresponding to the text to be recognized, wherein the combination vector sequence includes the combination vector corresponding to each character in the text to be recognized;

[0013] The recognition module is used to determine the role entities included in the text to be recognized based on the combined vector sequence and the pre-trained recognition model.

[0014] In a third aspect, the present disclosure provides a computer-readable medium having a computer program stored thereon, which, when executed by a processing device, implements the steps of the method described in the first aspect of the present disclosure.

[0015] In a fourth aspect, the present disclosure provides an electronic device, including:

[0016] a storage device having a computer program stored thereon;

[0017] A processing device is used to execute the computer program in the storage device to implement the steps of the method described in the first aspect of the present disclosure.

[0018] Through the above technical solution, the present disclosure first obtains each character and the corresponding character vector in the text to be recognized, and then determines the word vector corresponding to the associated words corresponding to each character, wherein the associated words are determined according to the combined words corresponding to the character, and then the character vector corresponding to each character and the word vector corresponding to the corresponding associated words are combined to form the combined vector corresponding to the character, thereby obtaining a combined vector sequence corresponding to the text to be recognized, including the combined vector corresponding to each character, and finally determining the role entity included in the text to be recognized based on the combined vector sequence and the pre-trained recognition model. In the process of identifying the role entity, the present disclosure takes into account each character included in the text to be recognized, and also considers the associated words associated with each character, thereby improving the accuracy of identifying the role entity.

[0019] Other features and advantages of the present disclosure will be described in detail in the following detailed description. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] The above and other features, advantages and aspects of the embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. Throughout the drawings, the same or similar reference numerals represent the same or similar elements. It should be understood that the drawings are schematic and the originals and elements are not necessarily drawn to scale. In the drawings:

[0021] Figure 1 is a flow chart of a method for identifying a role in a text according to an exemplary embodiment;

[0022] Figure 2 is a flow chart of another method for identifying a role in a text according to an exemplary embodiment;

[0023] Figure 3 is a flow chart of another method for identifying a role in a text according to an exemplary embodiment;

[0024] Figure 4 is a flow chart of another method for identifying a role in a text according to an exemplary embodiment;

[0025] Figure 5 is a flow chart showing a training recognition model according to an exemplary embodiment;

[0026] Figure 6 is a block diagram of a device for identifying a character in a text according to an exemplary embodiment;

[0027] Figure 7 is a block diagram of another device for identifying a character in a text according to an exemplary embodiment;

[0028] Figure 8 is a block diagram of another device for identifying a character in a text according to an exemplary embodiment;

[0029] Fig. 9 is a block diagram of another device for identifying a character in a text according to an exemplary embodiment;

[0030] Fig.10 It is a block diagram of an electronic device according to an exemplary embodiment. DETAILED DESCRIPTION

[0031] Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although certain embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as being limited to the embodiments described herein, which are instead provided for a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are only for exemplary purposes and are not intended to limit the scope of protection of the present disclosure.

[0032] It should be understood that the various steps described in the method embodiments of the present disclosure may be performed in different orders and / or in parallel. In addition, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present disclosure is not limited in this respect.

[0033] The term "including" and its variations used herein are open inclusions, i.e., "including but not limited to". The term "based on" means "based at least in part on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". The relevant definitions of other terms will be given in the following description.

[0034] It should be noted that the concepts such as "first" and "second" mentioned in the present disclosure are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units.

[0035] It should be noted that the modifications of "one" and "plurality" mentioned in the present disclosure are illustrative rather than restrictive, and those skilled in the art should understand that unless otherwise clearly indicated in the context, it should be understood as "one or more".

[0036] The names of the messages or information exchanged between multiple devices in the embodiments of the present disclosure are only used for illustrative purposes and are not used to limit the scope of these messages or information.

[0037] Figure 1 is a flowchart of a method for identifying a role in a text according to an exemplary embodiment. Figure 1 As shown, the method comprises the following steps:

[0038] Step 101: Obtain each character included in the text to be recognized and the character vector corresponding to each character.

[0039] For example, first obtain the text to be recognized that may include a role entity. The text to be recognized can be, for example, one or more sentences in a text file specified by the user (which can be understood as the specified total text mentioned later), or one or more paragraphs in a text file, or one or more chapters in a text file. A text file can be, for example, an e-book, or other types of files, such as news, public account articles, blogs, etc. Then extract each word included in the text to be recognized, and the word vector corresponding to each word. For example, you can search for the word vector corresponding to each word in the pre-trained word vector table in turn, or you can use the pre-trained Word2vec model to generate the word vector corresponding to each word.

[0040] Step 102: Determine the word vectors corresponding to the associated words for each character in the text to be recognized. The associated words are determined based on the combined words corresponding to the character. The combined words are composed of the character and a preset number of adjacent characters.

[0041] Exemplarily, for each character in the text to be recognized, first determine the combined words corresponding to the character, and then determine the corresponding associated words based on the combined words corresponding to the character. Among them, the associated words can be a single word or multiple words. Finally, determine the word vectors corresponding to the associated words. For example, in the pre-trained word vector table, sequentially search for the word vectors corresponding to each associated word, or use the pre-trained Word2vec model to generate the word vectors corresponding to each associated word. Among them, the combined words corresponding to each character are composed of the character and a preset number of adjacent characters, and the combined words can be understood as the words composed of the character and its context. For example, if the preset number is two, then the combined words are the words composed of the character in the text to be recognized, the two characters before it, and the two characters after it, that is, the words composed of the character, the character before it, the two characters before it, the character after it, and the two characters after it. Correspondingly, the associated words can be understood as all the combined words. The associated words can also be understood as the words that meet the specified requirements (such as matching a preset dictionary, etc.) in the combined words. For example, if the preset number is two and the text to be recognized is: "There is still no news about big brother." For the fifth character in the text to be recognized: "brother", the corresponding combined words are: "brother" combined with "have big" to form: "have big brother", "brother" combined with "big" to form: "big brother", "brother" combined with "of" to form: "brother of", "brother" combined with "of any" to form: "brother of any", a total of four combined words. These four combined words can be used as the associated words, or the words that match the preset dictionary among these four combined words can be used as the associated words. For example, "big brother" can be used as the associated word.

[0042] Step 103: Combine the character vector corresponding to each character and the word vector corresponding to the associated word of the character to form the combined vector corresponding to the character, so as to obtain the combined vector sequence corresponding to the text to be recognized. The combined vector sequence includes the combined vectors corresponding to each character in the text to be recognized.

[0043] Step 104: Determine the role entities included in the text to be recognized according to the combined vector sequence and the pre-trained recognition model.

[0044] For example, for each character in the text to be recognized, the character vector corresponding to the character and the word vector corresponding to the associated words corresponding to the character can be combined to obtain the combined vector corresponding to the character, thereby obtaining the combined vector sequence corresponding to the text to be recognized. That is to say, the combined vector corresponding to each character includes the character vector corresponding to the character and the word vector corresponding to the associated words corresponding to the character. For example, the text to be recognized includes 20 characters, each character corresponds to a 1*100-dimensional character vector, wherein a certain character corresponds to two associated words, and each associated word corresponds to a 1*100-dimensional word vector, then the combined vector corresponding to the character is 1*300-dimensional. Finally, the combined vector sequence is input into the pre-trained recognition model to determine the role entities included in the text to be recognized according to the output of the recognition model. The role entity can be zero (that is, there is no role entity in the text to be recognized), one or more. The role entity can be, for example, the following included in the text to be recognized: a name, a title, a personal pronoun (for example: you, me, she, he, you, etc.), an anthropomorphic animal, anthropomorphic object, etc. Specifically, the recognition model can directly output the role entity, or the recognition model can output the annotation of each character in the text to be recognized, and then determine the role entity according to the annotation of each character. The recognition model uses the annotation of each character in the text to be recognized to indicate whether each character belongs to the role entity.

[0045] Among them, the recognition model can be a deep learning model obtained by pre-training with a large number of training samples. The structure can be, for example, a combination of Transformer+CRF (Conditional Random Fields in English, Chinese: Conditional Random Fields), which has higher recognition efficiency than the combination of BLSTM (Bidirectional Long Short-Term Memory in English, Chinese: Bidirectional Long Short-Term Memory Network)+CRF. For example, the combined vector sequence can be used as the input of the Transformer to obtain the feature vector output by the Transformer that can characterize the combined vector sequence, and then the feature vector can be used as the input of the CRF to obtain the annotation corresponding to each combined vector in the combined vector sequence output by the CRF, that is, the annotation of each word in the text to be recognized. Since the combined vector sequence includes both the word vector corresponding to each word and the word vector corresponding to the associated words corresponding to each word, the recognition model can learn the relationship between each word and the corresponding associated words, avoid the problem of missing words and multiple words in the character entity recognition process, and can improve the accuracy of the recognition model in annotating the character entity.

[0046] In summary, the present disclosure first obtains each character and the corresponding character vector in the text to be recognized, and then determines the word vector corresponding to the associated words corresponding to each character, wherein the associated words are determined according to the combined words corresponding to the character, and then the character vector corresponding to each character and the word vector corresponding to the corresponding associated words are combined to form the combined vector corresponding to the character, thereby obtaining a combined vector sequence corresponding to the text to be recognized, including the combined vector corresponding to each character, and finally determining the role entity included in the text to be recognized based on the combined vector sequence and the pre-trained recognition model. In the process of identifying the role entity, the present disclosure takes into account each character included in the text to be recognized, and also considers the associated words associated with each character, thereby improving the accuracy of identifying the role entity.

[0047] Figure 2 is a flowchart of another method for identifying a role in a text according to an exemplary embodiment. Figure 2 As shown, step 102 may include:

[0048] Step 1021, for each character, obtain a compound word consisting of the character and a preset number of characters adjacent to the character.

[0049] Step 1022, taking the combined words that match the preset word dictionary as the associated words corresponding to the character, and obtaining the word vector corresponding to the associated words.

[0050] For example, for each character in the text to be recognized, the combined words formed by the character and a preset number of adjacent characters can be determined first. That is to say, the combined words are formed by the character and a preset number of adjacent characters. Taking the preset number as three as an example, the combined words corresponding to the character are the words formed by the character, the three characters before it, and the three characters after it in the text to be recognized. After that, each combined word is sequentially matched with the preset word dictionary. If there is a match, the combined word is determined as the associated word corresponding to the character, and the word vector corresponding to the associated word is obtained. The associated word can be zero (that is, among the combined words corresponding to the character, none of them match the word dictionary), one, or more. If the number of associated words corresponding to the character is zero, the combined vector corresponding to the character is the character vector corresponding to the character. Among them, the word dictionary can be understood as a dictionary that has pre-collected a large number of role entities. By screening the combined words corresponding to the character through the word dictionary, a large number of meaningless interferences can be eliminated semantically, ensuring the association relationship between each character and the corresponding associated word, thereby improving the accuracy of recognizing role entities. For example, the text to be recognized is: "The weather is nice today. Miss, are you going out?" For the first character: "今" (today), since there are no three characters before it, "今" can be combined with the three characters "天" (day), "天" (day), and "气" (weather) after it to obtain the combined words: "今天" (today), "今天天" (today day), and "今天天气" (today's weather), a total of three combined words. The three combined words are sequentially matched with the word dictionary, and the matching associated word obtained is: "今天" (today).

[0051] For another example, for the eighth character "姐" (miss), "姐" can be combined with a total of six characters before and after it: "错" (wrong), "," (comma), "小" (small), "要" (want), "出" (go out), and "门" (door) to obtain the combined words: "错,小姐" (wrong, miss), ",小姐" (, miss), "小姐" (miss), "姐要" (sister want), "姐要出" (sister want to go out), and "姐要出门" (sister want to go out), a total of six combined words. The six combined words are sequentially matched with the word dictionary, and the matching associated word obtained is "小姐" (miss). It should be noted that in the above embodiments, the punctuation marks included in the text to be recognized can be treated as one character.

[0052] Figure 3 is a flowchart of another method for recognizing roles in text shown according to an exemplary embodiment, as Figure 3 shown, step 104 may include:

[0053] Step 1041, input the combined vector sequence into the recognition model to obtain the attribute label corresponding to each character in the text to be recognized output by the recognition model, and the attribute label is used to indicate whether the character belongs to the role entity.

[0054] Step 1042, determining the role entities included in the text to be recognized based on the attribute label corresponding to each character in the text to be recognized.

[0055] For example, the combination vector sequence can be first input into the recognition model to obtain the attribute label corresponding to each character in the text to be recognized output by the recognition model, and the attribute label can indicate whether the corresponding character belongs to the role entity. For example, when the attribute label output by the recognition model is 1, it means that the corresponding character belongs to the role entity, and when the attribute label output by the model is 0, it means that the corresponding character does not belong to the role entity. The recognition model can be understood as a seq2seq model, that is, the input is a combination vector sequence including the combination vector corresponding to each character in the text to be recognized, and the output is an attribute label set including the attribute label corresponding to each character in the text to be recognized. For example, the text to be recognized is: "There is still no news from Big Brother". The combination vector sequence corresponding to the text to be recognized is input into the recognition model, and the attribute label set output by the recognition model is obtained as: 00001100000, then the role entity can be determined as: "Big Brother".

[0056] In one application scenario, in addition to indicating whether the corresponding character belongs to a role entity, the attribute tag can also indicate whether the character belongs to a single-character role entity (i.e., the character corresponds to one role entity) or a multi-character role entity (i.e., the role entity includes multiple characters). In the case where the character belongs to a multi-character role entity, the position of the character in the role entity can also be indicated, that is, the attribute tag can be used to indicate that the position of the character in the role entity is the starting position, the ending position, or the middle position.

[0057] Among them, if the attribute tag indicates that the position of the word in the role entity is the starting position, it can be understood that the word is the first word of the role entity, if the attribute tag indicates that the position of the word in the role entity is the ending position, it can be understood that the word is the last word of the role entity, and if the attribute tag indicates that the position of the word in the role entity is the middle position, it can be understood that the word is any middle word of the role entity. For example, when the attribute tag is the letter O, it means that the corresponding word does not belong to the role entity, when the attribute tag is the letter S, it means that the corresponding word is a single-word role entity, when the attribute tag is the letter B, it means that the corresponding word is the starting position in a multi-word role entity, when the attribute tag is the letter M, it means that the corresponding word is the middle position in a multi-word role entity, and when the attribute tag is the letter E, it means that the corresponding word is the ending position in a multi-word role entity.

[0058] Accordingly, step 1042 may be implemented as follows:

[0059] If the attribute tag corresponding to the target word indicates that the target word belongs to the role entity, the role entity including the target word is determined according to the position of the target word indicated by the attribute tag in the role entity, and the target word is any word in the text to be recognized.

[0060] For example, if the attribute tag corresponding to the target word indicates that the target word belongs to a role entity, and it is a single-word role entity, then the target word can be directly used as a role entity. If the attribute tag corresponding to the target word indicates that the target word belongs to a role entity, and it is a multi-word role entity, then the role entity composed of the target word can be further determined according to the position of the target word indicated by the attribute tag in the role entity.

[0061] If the attribute label indicates that the position of the target word in the role entity is the starting position, then continue to determine the attribute label corresponding to each word after the target word, until the attribute label corresponding to a certain word indicates that the position of the word in the role entity is the ending position, then the word composed of the target word to the word can be regarded as a role entity. For example, the text to be recognized is: "Miss, are you going out?", and the attribute label corresponding to each word output by the recognition model is: BEOSOOOOOO, then it can be determined that the two words with attribute labels B and E form a role entity: "Miss", and the word with attribute label S forms a role entity: "You", that is, the text to be recognized includes two role entities: "Miss" and "You".

[0062] After determining the role entities included in the text to be recognized, the number of occurrences of different role entities can be counted, so that the role entity with the largest number of occurrences can be used as the main role entity in the text to be recognized. Further, the target role entity to which the dialogue sentence included in the text to be recognized belongs can be determined from among the recognized role entities. The following specifically describes how to determine the target role entity.

[0063] Figure 4 is a flowchart of another method for identifying a role in a text according to an exemplary embodiment. Figure 4 As shown, the text to be recognized includes a first text to be recognized and a second text to be recognized, the first text to be recognized corresponds to any dialogue sentence in the specified total text, and the second text to be recognized corresponds to a sentence in the specified total text whose distance with the dialogue sentence corresponding to the first text to be recognized meets a preset condition. After step 104, the method may further include:

[0064] Step 105, determining the attribute features corresponding to each role entity included in the text to be recognized, the attribute features including: a first position relationship between the role entity and the first text to be recognized, a second position relationship between the text to which the role entity belongs and the first text to be recognized, and one or more of the dialogue attributes of the text to which the role entity belongs.

[0065] For example, the text to be recognized may include a first text to be recognized and a second text to be recognized, wherein the first text to be recognized corresponds to any dialogue sentence in the specified total text, and the second text to be recognized corresponds to a sentence in the specified total text whose distance from the dialogue sentence corresponding to the first text to be recognized meets a preset condition. The specified total text includes the text corresponding to each of the multiple sentences. For example, the specified total text may be an e-book specified by the user, or a chapter or a fragment in an e-book. The multiple sentences included in the specified total text may be divided into two categories according to whether they include dialogue symbols, one of which is dialogue sentences and the other is non-dialogue sentences. The dialogue symbol is used to identify a sentence as a dialogue sentence, such as double quotation marks "" or "", which is not specifically limited in the present disclosure.

[0066] Afterwards, the text corresponding to any dialogue sentence included in the specified total text can be used as the first text to be recognized. Then determine the second text to be recognized corresponding to the first text to be recognized. In the specified total text, the distance between the sentence corresponding to the first text to be recognized and the sentence corresponding to the second text to be recognized meets the preset conditions, and the second text to be recognized can correspond to one or more sentences. It can be understood that there is an association between the first text to be recognized and the second text to be recognized, or the second text to be recognized can be understood as the context of the first text to be recognized. The sentence corresponding to the second text to be recognized can be a dialogue sentence or a non-dialogue sentence. Taking the preset condition of less than or equal to three sentences as an example, the second text to be recognized can be the text corresponding to the three sentences before and the three sentences after the first text to be recognized (a total of six sentences) in the specified total text.

[0067] For each role entity, determine the attribute features corresponding to the role entity. The attribute features can be understood as features that can reflect the relationship between the role entity and the first text to be recognized. The attribute features may, for example, include one or more of the following: the first position relationship between the role entity and the first text to be recognized, the second position relationship between the text to which the role entity belongs and the first text to be recognized, and the dialogue attribute of the text to which the role entity belongs. Among them, the first position relationship can be used to indicate whether the role entity belongs to the first text to be recognized. The second position relationship can be used to indicate that in the specified total text, the text to which the role entity belongs is located before or after the first text to be recognized. The dialogue attribute can be used to indicate whether the sentence corresponding to the text to which the role entity belongs is a dialogue sentence.

[0068] Step 106, for each role entity, the first text to be recognized, the second text to be recognized, the role entity and the attribute features corresponding to the role entity are input into a pre-trained attribution recognition model to obtain the matching degree between the role entity and the first text to be recognized output by the attribution recognition model.

[0069] Step 107: Determine the target character entity to which the dialogue sentence corresponding to the first text to be recognized belongs according to the matching degree between each character entity and the first text to be recognized.

[0070] For example, the first text to be recognized, the second text to be recognized, each character entity and the attribute features corresponding to the character entity can be used as inputs of a pre-trained attribution recognition model, and the attribution recognition model can output the matching degree between the character entity and the first text to be recognized. The matching degree can be understood as the probability value that the dialogue sentence corresponding to the first text to be recognized belongs to the character entity. Among them, the attribution recognition model can be a deep learning model pre-trained with a large number of training samples, and the structure can be, for example, a combination of BLSTM+Dense_layer+softmax. For example, the first text to be recognized and the second text to be recognized can be first converted into corresponding text feature sequences (i.e., Text Embedding), and then the role entity can be converted into corresponding word vectors, and then the text feature sequence, word vectors, and attribute features corresponding to the role entity can be spliced ​​as the input of BLSTM to obtain the feature vector output by BLSTM, which can comprehensively characterize the first text to be recognized, the second text to be recognized, each role entity, and the attribute features corresponding to the role entity, and then the feature vector is used as the input of Dense_layer, and the output of Dense_layer is used as the input of softmax to obtain the probability value of the softmax output, and finally the probability value is used as the matching degree of the role entity and the first text to be recognized. For example, the first text to be recognized includes 20 characters, the second text to be recognized includes 50 characters, and each character corresponds to a 1*300-dimensional word vector, then the first text to be recognized and the second text to be recognized are converted into corresponding text feature sequences of 70*300-dimensional vectors. The role entity corresponds to a 1*300-dimensional word vector, and the attribute feature corresponding to the role entity is a 1*11-dimensional vector. Therefore, the vector input to the attribution recognition model is a 70*(300+300+11)-dimensional vector.

[0071] Furthermore, after obtaining the degree of match between each character entity and the first text to be recognized, the target character entity to which the dialogue sentence corresponding to the first text to be recognized belongs can be determined in at least one character entity, that is, it is determined that the dialogue sentence corresponding to the first text to be recognized belongs to the target character entity (that is, it is determined that the dialogue sentence corresponding to the first text to be recognized is spoken by the target character entity). For example, the character entity with the highest degree of match can be used as the target character entity, or at least one character entity can be sorted in descending order according to the degree of match, and a specified number of character entities (for example, three) at the front are provided to the user, and the user determines the target character entity. Furthermore, after determining the target character entity, the target character entity can be used as a label and associated with the first text to be recognized, so that in the process of recording the audio corresponding to the specified total text, when recording the first text to be recognized, the target character entity can be determined according to the label of the first text to be recognized, and recorded according to the timbre pre-assigned to the target character entity.

[0072] In this way, when determining the attribution of the dialogue sentence corresponding to the first text to be recognized, in addition to the first text to be recognized itself, the second text to be recognized that is associated with the first text to be recognized is also considered, so that the attribution recognition model can learn the association between the first text to be recognized and the second text to be recognized. At the same time, the role entities and attribute features of the role entities extracted from the first text to be recognized and the second text to be recognized are combined, so that the attribution recognition model can further learn the association between each role entity and the first text to be recognized, thereby determining the target role entity to which the dialogue sentence corresponding to the first text to be recognized belongs, which can improve the recognition efficiency and accuracy of dialogue attribution.

[0073] In an application scenario, the attribute features corresponding to each role entity may include multiple features. The first position relationship may be determined based on the role entity and the first text to be recognized. The second position relationship may be determined based on the distance between the text to which the role entity belongs and the first text to be recognized. Finally, the dialogue attribute may be determined based on the text to which the role entity belongs. For example, the attribute features may include 11 features:

[0074] Feature a is used to indicate whether the role entity belongs to the first text to be recognized. If the role entity belongs to the first text to be recognized in the specified total text, feature a can be represented as 0. If the role entity does not belong to the first text to be recognized in the specified total text, if the role entity is located after the first text to be recognized, feature a can be represented as 1, and if the role entity is located before the first text to be recognized, feature a can be represented as -1.

[0075] Feature b is used to indicate whether the role entity belongs to the target paragraph. The target paragraph is the paragraph to which the first text to be recognized belongs. It can be understood as whether the role entity and the first text to be recognized belong to the same paragraph. For example, if the role entity belongs to the target paragraph, feature b can be represented as 1, and if the role entity does not belong to the target paragraph, feature b can be represented as 0.

[0076] Feature c is used to indicate the distance between the role entity and the first text to be recognized. It can be understood as the distance between the text to which the role entity belongs and the first text to be recognized, and the order of the distance between the text to which each role entity belongs and the first text to be recognized. For example, in step 104, it is determined that the text to be recognized includes four role entities, namely A, B, C, and D, and their distances from the first text to be recognized are 2 sentences, 4 sentences, 3 sentences, and 2 sentences respectively. After sorting, the order is 1, 3, 2, and 1 respectively, so the feature c corresponding to B can be expressed as 3.

[0077] Feature d is used to indicate the distance between the text to which the role entity belongs and the first text to be recognized. For example, if the distance between the text to which the role entity belongs and the first text to be recognized is 2 sentences, then feature d can be expressed as 2.

[0078] Feature e is used to indicate whether the sentence corresponding to the text to which the character entity belongs is a dialogue sentence. For example, if the sentence corresponding to the text to which the character entity belongs is a dialogue sentence, then feature e can be represented as 1; if the sentence corresponding to the text to which the character entity belongs is not a dialogue sentence, then feature e can be represented as 0.

[0079] Feature f is used to indicate whether the text to which the role entity belongs includes the first dialogue template.

[0080] Feature g is used to indicate whether the text to which the role entity belongs includes the second dialogue template.

[0081] Feature h is used to indicate whether the text to which the role entity belongs includes a third dialogue template.

[0082] For example, the first dialogue template may include templates such as "XX said:", "XX said:", "XX laughed:", etc., which indicate the start of a dialogue. The second dialogue template may include templates such as "XX said.", "XX said.", "XX laughed.", etc., which indicate the end of a dialogue. The third dialogue template may include templates such as "said", "said", "laugh", etc., which indicate possible dialogues. If the above templates are included, it can be represented as 1, and if the above templates are not included, it can be represented as 0.

[0083] Feature i is used to indicate the position of the role entity in the text to which the role entity belongs. It can be understood as the role entity's rank in the text to which it belongs. For example, a text includes three role entities, A, B, and C, from left to right. The feature i corresponding to A can be expressed as 1, the feature i corresponding to B can be expressed as 2, and the feature i corresponding to C can be expressed as 3.

[0084] Feature j is used to indicate whether a sentence before the dialogue sentence corresponding to the first text to be recognized in the specified total text is a dialogue sentence. For example, if a sentence before the dialogue sentence corresponding to the first text to be recognized is a dialogue sentence, then feature j can be represented as 1; if a sentence before the dialogue sentence corresponding to the first text to be recognized is not a dialogue sentence, then feature j can be represented as 0.

[0085] Feature k is used to indicate whether a sentence after the dialogue sentence corresponding to the first text to be recognized in the specified total text is a dialogue sentence. For example, if a sentence after the dialogue sentence corresponding to the first text to be recognized is a dialogue sentence, then feature j can be represented as 1, and if a sentence after the dialogue sentence corresponding to the first text to be recognized is not a dialogue sentence, then feature j can be represented as 0.

[0086] Figure 5 is a flowchart of a training recognition model according to an exemplary embodiment. Figure 5 As shown, the recognition model is trained in the following way:

[0087] Step A, obtaining a character vector corresponding to each training character in the training text, a word vector corresponding to a training associated word corresponding to the training character in the training text, and annotation data corresponding to the training text, wherein the training associated words are determined based on the training combination words corresponding to the training characters, the training combination words are composed of the training character and a preset number of training characters adjacent to the training character, and the annotation data includes annotated role entities included in the training text.

[0088] Step B, for each training word, the word vector corresponding to the training word and the word vector corresponding to the training associated word corresponding to the training word are combined to form a training combination vector corresponding to the training word, so as to obtain a training combination vector sequence corresponding to the training text, and the training combination vector sequence includes the training combination vector corresponding to each training word.

[0089] Step C: input the training combination vector sequence into the recognition model, and train the recognition model based on the output of the recognition model and the labeled data.

[0090] For example, to train the recognition model, it is necessary to obtain the training text and the corresponding annotation data in advance. The training text includes multiple training words. Among them, the annotation data annotates the annotated role entities included in the training text. For example, the training text is: "Miss, are you going out?", then the corresponding annotation data can be: BEOSOOOOO, and the annotated role entities are "Miss" and "You". After that, obtain the word vector corresponding to each training word and the word vector corresponding to the training associated words corresponding to the training word.

[0091] For each training character, the training combination words corresponding to the training character can be determined first, and then the corresponding training associated words can be determined based on the training combination words corresponding to the training character. The training associated words can be one word or multiple words. Finally, the word vector corresponding to the training associated words is obtained. Among them, the training combination words corresponding to each training character are composed of the training character and a preset number of training characters adjacent to the training character, and the training combination words can be understood as words composed of the training character and the context. For example, if the preset number is two, then the training combination words are the words composed of the training character in the training text, the previous two training characters and the next two training characters. Correspondingly, the training associated words can be understood as all the training combination words. The training associated words can also be understood as words in the training combination words that meet the specified requirements (for example, matching with a preset dictionary, etc.).

[0092] For each training word in the training text, the word vector corresponding to the training word and the word vector corresponding to the training associated words corresponding to the training word can be combined to obtain the training combination vector corresponding to the training word, thereby obtaining the training text corresponding to the training combination vector sequence including the training combination vector corresponding to each training word. Finally, the training combination vector sequence is input into the recognition model, and the recognition model is trained according to the output of the recognition model and the annotation data. It can be understood that the output of the recognition model is the annotation of each training word in the training text. Therefore, the difference between the annotation actually output by the recognition model and the annotation data can be used as the loss function of the recognition model. With the goal of reducing the loss function, the back propagation algorithm is used to correct the parameters of the neurons in the recognition model. The parameters of the neurons can be, for example, the weights (English: Weight) and biases (English: Bias) of the neurons. Repeat the above steps until the loss function meets the preset conditions, such as the loss function is less than the preset loss threshold.

[0093] It should be noted that the structure of the recognition model can be, for example, a combination of Transformer+CRF. Among them, Transformer can be based on a multi-head self-attention mechanism, and can learn the degree of correlation between each combination vector in the combination vector sequence. The input size of the recognition model can be 300. The number of neurons of the FFN (Feed Forward Network) included in the Transformer can be 256. The number of neurons of the preprocessing network (Pre-net) included in the Transformer can be 256. Transformer can include 8 Multi-head self-attention structures, and the number of blocks of the Encoder and Decoder included in the Transformer can be 1. The maximum length that the recognition model can process can be 150, that is, the combination vector sequence can include at most 150 combination vectors (the text to be recognized can include at most 150 words).

[0094] In summary, the present disclosure first obtains each character and the corresponding character vector in the text to be recognized, and then determines the word vector corresponding to the associated words corresponding to each character, wherein the associated words are determined according to the combined words corresponding to the character, and then the character vector corresponding to each character and the word vector corresponding to the corresponding associated words are combined to form the combined vector corresponding to the character, thereby obtaining a combined vector sequence corresponding to the text to be recognized, including the combined vector corresponding to each character, and finally determining the role entity included in the text to be recognized based on the combined vector sequence and the pre-trained recognition model. In the process of identifying the role entity, the present disclosure takes into account each character included in the text to be recognized, and also considers the associated words associated with each character, thereby improving the accuracy of identifying the role entity.

[0095] Figure 6 is a block diagram of a device for identifying a role in a text according to an exemplary embodiment. Figure 6 As shown, the apparatus 200 may include:

[0096] The acquisition module 201 is used to acquire each character included in the text to be recognized and the character vector corresponding to each character.

[0097] The determination module 202 is used to determine the word vector corresponding to the associated words corresponding to each character in the text to be recognized, and the associated words are determined according to the combined words corresponding to the character, and the combined words are composed of the character and a preset number of characters adjacent to the character.

[0098] The processing module 203 is used to combine the character vector corresponding to each character and the word vector corresponding to the associated word corresponding to the character into a combination vector corresponding to the character, so as to obtain a combination vector sequence corresponding to the text to be recognized, wherein the combination vector sequence includes the combination vector corresponding to each character in the text to be recognized.

[0099] The recognition module 204 is used to determine the role entities included in the text to be recognized according to the combined vector sequence and the pre-trained recognition model.

[0100] Figure 7 is a block diagram of another device for identifying a role in a text according to an exemplary embodiment. Figure 7 As shown, the determination module 202 includes:

[0101] The acquisition submodule 2021 is used to acquire, for each character, a compound word consisting of the character and a preset number of characters adjacent to the character.

[0102] The determination submodule 2022 is used to take the combined words that match the preset word dictionary as the associated words corresponding to the character, and obtain the word vector corresponding to the associated words.

[0103] Figure 8 is a block diagram of another device for identifying a role in a text according to an exemplary embodiment. Figure 8 As shown, the identification module 204 may include:

[0104] The recognition submodule 2041 is used to input the combined vector sequence into the recognition model to obtain the attribute label corresponding to each character in the text to be recognized output by the recognition model, and the attribute label is used to indicate whether the character belongs to the role entity.

[0105] The processing submodule 2042 is used to determine the role entities included in the text to be recognized according to the attribute label corresponding to each character in the text to be recognized.

[0106] In an application scenario, the attribute tag is also used to indicate that the position of the word in the role entity is the starting position, the ending position, or the middle position.

[0107] In another application scenario, the processing submodule 2042 may be used to:

[0108] If the attribute tag corresponding to the target word indicates that the target word belongs to the role entity, the role entity including the target word is determined according to the position of the target word indicated by the attribute tag in the role entity, and the target word is any word in the text to be recognized.

[0109] Fig. 9 is a block diagram of another device for identifying a role in a text according to an exemplary embodiment. Fig. 9As shown, the text to be recognized includes a first text to be recognized and a second text to be recognized, the first text to be recognized corresponds to any dialogue sentence in the specified total text, and the second text to be recognized corresponds to a sentence in the specified total text whose distance with the dialogue sentence corresponding to the first text to be recognized meets a preset condition. The device 200 may also include:

[0110] The attribute determination module 205 is used to determine the attribute features corresponding to each role entity included in the text to be recognized after determining the role entities included in the text to be recognized based on the combined vector sequence and the pre-trained recognition model. The attribute features include: a first position relationship between the role entity and the first text to be recognized, a second position relationship between the text to which the role entity belongs and the first text to be recognized, and one or more of the dialogue attributes of the text to which the role entity belongs.

[0111] The input module 206 is used to input the first text to be recognized, the second text to be recognized, the role entity and the attribute features corresponding to the role entity into a pre-trained attribution recognition model for each role entity, so as to obtain the matching degree between the role entity and the first text to be recognized output by the attribution recognition model.

[0112] The attribution determination module 207 is used to determine the target role entity to which the dialogue sentence corresponding to the first text to be recognized belongs according to the matching degree between each role entity and the first text to be recognized.

[0113] It should be noted that, in the above embodiment, the recognition model is trained in the following way:

[0114] Step A, obtaining a character vector corresponding to each training character in the training text, a word vector corresponding to a training associated word corresponding to the training character in the training text, and annotation data corresponding to the training text, wherein the training associated words are determined based on the training combination words corresponding to the training characters, the training combination words are composed of the training character and a preset number of training characters adjacent to the training character, and the annotation data includes annotated role entities included in the training text.

[0115] Step B, for each training word, the word vector corresponding to the training word and the word vector corresponding to the training associated word corresponding to the training word are combined to form a training combination vector corresponding to the training word, so as to obtain a training combination vector sequence corresponding to the training text, and the training combination vector sequence includes the training combination vector corresponding to each training word.

[0116] Step C: input the training combination vector sequence into the recognition model, and train the recognition model based on the output of the recognition model and the labeled data.

[0117] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.

[0118] In summary, the present disclosure first obtains each character and the corresponding character vector in the text to be recognized, and then determines the word vector corresponding to the associated words corresponding to each character, wherein the associated words are determined according to the combined words corresponding to the character, and then the character vector corresponding to each character and the word vector corresponding to the corresponding associated words are combined to form the combined vector corresponding to the character, thereby obtaining a combined vector sequence corresponding to the text to be recognized, including the combined vector corresponding to each character, and finally determining the role entity included in the text to be recognized based on the combined vector sequence and the pre-trained recognition model. In the process of identifying the role entity, the present disclosure takes into account each character included in the text to be recognized, and also considers the associated words associated with each character, thereby improving the accuracy of identifying the role entity.

[0119] Reference below Fig.10 , which shows a schematic diagram of the structure of an electronic device (e.g., the execution subject of the method for identifying a role in a text in the above embodiment) 300 suitable for implementing the embodiment of the present disclosure. The terminal device in the embodiment of the present disclosure may include, but is not limited to, mobile terminals such as mobile phones, notebook computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), vehicle-mounted terminals (e.g., vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Fig.10 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.

[0120] like Fig.10 As shown, the electronic device 300 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 301, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 302 or a program loaded from a storage device 308 into a random access memory (RAM) 303. In the RAM 303, various programs and data required for the operation of the electronic device 300 are also stored. The processing device 301, the ROM 302, and the RAM 303 are connected to each other via a bus 304. An input / output (I / O) interface 305 is also connected to the bus 304.

[0121] Typically, the following devices may be connected to the I / O interface 305: input devices 306 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; output devices 307 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; storage devices 308 including, for example, a magnetic tape, a hard disk, etc.; and communication devices 309. The communication devices 309 may allow the electronic device 300 to communicate with other devices wirelessly or by wire to exchange data. Although Fig.10The electronic device 300 is shown with various devices, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead.

[0122] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program contains program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication device 309, or installed from the storage device 308, or installed from the ROM 302. When the computer program is executed by the processing device 301, the above-mentioned functions defined in the method of the embodiment of the present disclosure are executed.

[0123] It should be noted that the computer-readable medium disclosed above may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in combination with an instruction execution system, device or device. In the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, in which a computer-readable program code is carried. This propagated data signal may take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. The computer readable signal medium may also be any computer readable medium other than a computer readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer readable medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.

[0124] In some embodiments, the terminal devices and servers may communicate using any currently known or future developed network protocol such as HTTP (HyperText Transfer Protocol), and may be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an ad hoc peer-to-peer network), as well as any currently known or future developed network.

[0125] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.

[0126] The computer-readable medium carries one or more programs. When the one or more programs are executed by the electronic device, the electronic device: obtains each character included in the text to be recognized and the character vector corresponding to each character; determines the word vector corresponding to the associated words corresponding to each character in the text to be recognized, the associated words are determined according to the combined words corresponding to the character, and the combined words are composed of the character and a preset number of characters adjacent to the character; the character vector corresponding to each character and the word vector corresponding to the associated words corresponding to the character are combined into a combined vector corresponding to the character to obtain a combined vector sequence corresponding to the text to be recognized, the combined vector sequence includes the combined vector corresponding to each character in the text to be recognized; and determines the role entity included in the text to be recognized according to the combined vector sequence and a pre-trained recognition model.

[0127] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages ​​or a combination thereof, including, but not limited to, object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0128] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0129] The modules involved in the embodiments described in the present disclosure may be implemented by software or hardware. The name of the module does not limit the module itself in some cases. For example, the acquisition module may also be described as "a module for acquiring each word and the word vector corresponding to each word".

[0130] The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), and the like.

[0131] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0132] According to one or more embodiments of the present disclosure, Example 1 provides a method for identifying roles in a text, the method comprising: obtaining each character included in the text to be identified and the character vector corresponding to each character; determining the word vector corresponding to the associated term corresponding to each character in the text to be identified, the associated term being determined based on the combined term corresponding to the character, the combined term being composed of the character and a preset number of characters adjacent to the character; combining the character vector corresponding to each character and the word vector corresponding to the associated term corresponding to the character into a combined vector corresponding to the character to obtain a combined vector sequence corresponding to the text to be identified, the combined vector sequence including the combined vector corresponding to each character in the text to be identified; determining the role entity included in the text to be identified based on the combined vector sequence and a pre-trained recognition model.

[0133] According to one or more embodiments of the present disclosure, Example 2 provides the method of Example 1, which determines the word vector corresponding to the associated term corresponding to each character in the text to be recognized, including: for each character, obtaining the combined term consisting of the character and a preset number of characters adjacent to the character; taking the combined term in the combined term that matches a preset word dictionary as the associated term corresponding to the character, and obtaining the word vector corresponding to the associated term.

[0134] According to one or more embodiments of the present disclosure, Example 3 provides the method of Example 1, which determines the role entities included in the text to be recognized based on the combined vector sequence and a pre-trained recognition model, including: inputting the combined vector sequence into the recognition model to obtain an attribute label corresponding to each character in the text to be recognized output by the recognition model, the attribute label being used to indicate whether the character belongs to the role entity; determining the role entity included in the text to be recognized based on the attribute label corresponding to each character in the text to be recognized.

[0135] According to one or more embodiments of the present disclosure, Example 4 provides the method of Example 3, wherein the attribute tag is further used to indicate that the position of the word in the role entity is a starting position, an ending position, or a middle position.

[0136] According to one or more embodiments of the present disclosure, Example 5 provides the method of Example 4, which determines the role entity included in the text to be recognized based on the attribute label corresponding to each character in the text to be recognized, including: if the attribute label corresponding to a target character indicates that the target character belongs to the role entity, determining the role entity including the target character based on the position of the target character in the role entity indicated by the attribute label, the target character being any character in the text to be recognized.

[0137] According to one or more embodiments of the present disclosure, Example 6 provides the method of Example 1, wherein the text to be recognized includes a first text to be recognized and a second text to be recognized, the first text to be recognized corresponds to any dialogue sentence in a specified total text, and the second text to be recognized corresponds to a sentence in the specified total text whose distance with the dialogue sentence corresponding to the first text to be recognized meets a preset condition; after determining the role entities included in the text to be recognized according to the combined vector sequence and the pre-trained recognition model, the method further includes: determining the attribute features corresponding to each of the role entities included in the text to be recognized, the attribute features including: one or more of a first position relationship between the role entity and the first text to be recognized, a second position relationship between the text to which the role entity belongs and the first text to be recognized, and a dialogue attribute of the text to which the role entity belongs; for each of the role entities, the first text to be recognized, the second text to be recognized, the role entity and the attribute features corresponding to the role entity are input into a pre-trained attribution recognition model to obtain a matching degree between the role entity and the first text to be recognized output by the attribution recognition model; and determining a target role entity to which the dialogue sentence corresponding to the first text to be recognized belongs according to the matching degree between each of the role entities and the first text to be recognized.

[0138] According to one or more embodiments of the present disclosure, Example 7 provides the methods of Examples 1 to 6, wherein the recognition model is trained in the following manner: obtaining a character vector corresponding to each training character in a training text, a word vector corresponding to a training associated phrase corresponding to the training character in the training text, and annotation data corresponding to the training text, wherein the training associated phrase is determined based on a training combination phrase corresponding to the training character, wherein the training combination phrase is composed of the training character and a preset number of training characters adjacent to the training character, and the annotation data includes annotation role entities included in the training text; for each training character, the character vector corresponding to the training character and the word vector corresponding to the training associated phrase corresponding to the training character are combined to form a training combination vector corresponding to the training character to obtain a training combination vector sequence corresponding to the training text, wherein the training combination vector sequence includes a training combination vector corresponding to each training character; inputting the training combination vector sequence into the recognition model, and training the recognition model based on the output of the recognition model and the annotation data.

[0139] According to one or more embodiments of the present disclosure, Example 8 provides a device for identifying roles in a text, the device comprising: an acquisition module, used to acquire each character included in the text to be identified and a character vector corresponding to each character; a determination module, used to determine the word vector corresponding to the associated term corresponding to each character in the text to be identified, the associated term is determined based on the combined term corresponding to the character, and the combined term is composed of the character and a preset number of characters adjacent to the character; a processing module, used to combine the character vector corresponding to each character and the word vector corresponding to the associated term corresponding to the character into a combined vector corresponding to the character, so as to obtain a combined vector sequence corresponding to the text to be identified, the combined vector sequence including the combined vector corresponding to each character in the text to be identified; a recognition module, used to determine the role entity included in the text to be identified based on the combined vector sequence and a pre-trained recognition model.

[0140] According to one or more embodiments of the present disclosure, Example 9 provides a computer-readable medium having a computer program stored thereon, which implements the steps of the methods described in Examples 1 to 7 when executed by a processing device.

[0141] According to one or more embodiments of the present disclosure, Example 10 provides an electronic device, comprising: a storage device on which a computer program is stored; and a processing device for executing the computer program in the storage device to implement the steps of the method described in Examples 1 to 7.

[0142] The above description is only a preferred embodiment of the present disclosure and an explanation of the technical principles used. Those skilled in the art should understand that the scope of disclosure involved in the present disclosure is not limited to the technical solutions formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above disclosed concept. For example, the above features are replaced with the technical features with similar functions disclosed in the present disclosure (but not limited to) by each other to form a technical solution.

[0143] In addition, although each operation is described in a specific order, this should not be understood as requiring these operations to be performed in the specific order shown or in a sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Similarly, although some specific implementation details are included in the above discussion, these should not be interpreted as limiting the scope of the present disclosure. Some features described in the context of a separate embodiment can also be implemented in a single embodiment in combination. On the contrary, the various features described in the context of a single embodiment can also be implemented in multiple embodiments individually or in any suitable sub-combination mode.

[0144] Although the subject matter has been described in language specific to structural features and / or method logic actions, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. On the contrary, the specific features and actions described above are merely example forms of implementing the claims. Regarding the device in the above embodiment, the specific manner in which each module performs the operation has been described in detail in the embodiment related to the method, and will not be elaborated here.

Claims

1. A method for identifying roles in a text, characterized in that: The method comprises: Obtain each word included in the text to be recognized and the word vector corresponding to each word; Determine a word vector corresponding to an associated word corresponding to each character in the to-be-recognized text, wherein the associated word is determined according to a combined word corresponding to the character, and the combined word is composed of the character and a preset number of characters adjacent to the character; Combining the character vector corresponding to each character and the word vector corresponding to the associated word corresponding to the character into a combination vector corresponding to the character, so as to obtain a combination vector sequence corresponding to the text to be recognized, wherein the combination vector sequence includes the combination vector corresponding to each character in the text to be recognized; Determining the character entities included in the text to be recognized according to the combined vector sequence and the pre-trained recognition model; The text to be recognized includes a first text to be recognized and a second text to be recognized, the first text to be recognized corresponds to any dialogue sentence in a specified total text, and the second text to be recognized corresponds to a sentence in the specified total text, the distance between which and the dialogue sentence corresponding to the first text to be recognized meets a preset condition; After determining the character entities included in the text to be recognized according to the combined vector sequence and the pre-trained recognition model, the method further includes: Determine the attribute features corresponding to each of the role entities included in the text to be recognized, wherein the attribute features include: a first position relationship between the role entity and the first text to be recognized, a second position relationship between the text to which the role entity belongs and the first text to be recognized, and one or more of a dialogue attribute of the text to which the role entity belongs; For each of the role entities, the first text to be recognized, the second text to be recognized, the role entity and the attribute features corresponding to the role entity are input into a pre-trained attribution recognition model to obtain a matching degree between the role entity and the first text to be recognized output by the attribution recognition model; According to the matching degree between each of the character entities and the first text to be recognized, the target character entity to which the dialogue sentence corresponding to the first text to be recognized belongs is determined.

2. The method according to claim 1, characterized in that The step of determining the word vector corresponding to the associated word corresponding to each character in the text to be recognized includes: For each character, obtaining the combined word consisting of the character and a preset number of characters adjacent to the character; The combined words among the combined words that match the preset word dictionary are used as the associated words corresponding to the character, and the word vectors corresponding to the associated words are obtained.

3. The method according to claim 1, characterized in that: The step of determining the character entity included in the to-be-recognized text according to the combined vector sequence and the pre-trained recognition model includes: Inputting the combined vector sequence into the recognition model to obtain an attribute label corresponding to each character in the text to be recognized output by the recognition model, wherein the attribute label is used to indicate whether the character belongs to the role entity; The role entity included in the text to be recognized is determined according to the attribute label corresponding to each character in the text to be recognized.

4. The method according to claim 3, characterized in that The attribute tag is also used to indicate whether the position of the character in the role entity is a starting position, an ending position, or a middle position.

5. The method according to claim 4, characterized in that The step of determining the role entity included in the text to be recognized according to the attribute label corresponding to each character in the text to be recognized comprises: If the attribute tag corresponding to the target word indicates that the target word belongs to the role entity, the role entity including the target word is determined according to the position of the target word in the role entity indicated by the attribute tag, and the target word is any word in the text to be recognized.

6. The method according to any one of claims 1 to 5, characterized in that The recognition model is trained in the following way: Obtaining a character vector corresponding to each training character in a training text, a word vector corresponding to a training associated word corresponding to the training character in the training text, and annotation data corresponding to the training text, wherein the training associated word is determined according to a training combination word corresponding to the training character, the training combination word is composed of the training character and a preset number of training characters adjacent to the training character, and the annotation data includes an annotation role entity included in the training text; For each training word, the word vector corresponding to the training word and the word vector corresponding to the training associated word corresponding to the training word are combined to form a training combination vector corresponding to the training word, so as to obtain a training combination vector sequence corresponding to the training text, wherein the training combination vector sequence includes the training combination vector corresponding to each training word; The training combination vector sequence is input into the recognition model, and the recognition model is trained according to the output of the recognition model and the labeled data.

7. A device for identifying characters in a text, characterized in that: The device comprises: An acquisition module, used to acquire each word included in the text to be recognized and the word vector corresponding to each word; A determination module, used to determine a word vector corresponding to an associated word corresponding to each character in the to-be-recognized text, wherein the associated word is determined according to a combination word corresponding to the character, and the combination word is composed of the character and a preset number of characters adjacent to the character; A processing module, used for combining the character vector corresponding to each character and the word vector corresponding to the associated word corresponding to the character to form a combination vector corresponding to the character, so as to obtain a combination vector sequence corresponding to the text to be recognized, wherein the combination vector sequence includes the combination vector corresponding to each character in the text to be recognized; A recognition module, used for determining the role entities included in the text to be recognized according to the combined vector sequence and a pre-trained recognition model; The text to be recognized includes a first text to be recognized and a second text to be recognized, the first text to be recognized corresponds to any dialogue sentence in a specified total text, and the second text to be recognized corresponds to a sentence in the specified total text whose distance with the dialogue sentence corresponding to the first text to be recognized meets a preset condition; the device also includes: an attribute determination module, for determining attribute features corresponding to each of the role entities included in the text to be recognized, after determining the role entities included in the text to be recognized according to the combined vector sequence and the pre-trained recognition model, wherein the attribute features include: a first position relationship between the role entity and the first text to be recognized, a second position relationship between the text to which the role entity belongs and the first text to be recognized, and a dialog attribute of the text to which the role entity belongs, or one or more thereof; An input module, for each of the role entities, inputting the first text to be recognized, the second text to be recognized, the role entity and the attribute features corresponding to the role entity into a pre-trained attribution recognition model to obtain a matching degree between the role entity and the first text to be recognized output by the attribution recognition model; The attribution determination module is used to determine the target role entity to which the dialogue sentence corresponding to the first text to be recognized belongs according to the matching degree between each role entity and the first text to be recognized.

8. A computer readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processing device, the steps of the method described in any one of claims 1 to 6 are implemented.

9. An electronic device, characterized in that: include: a storage device having a computer program stored thereon; A processing device, configured to execute the computer program in the storage device to implement the steps of the method according to any one of claims 1 to 6.