Text processing method and device, electronic equipment and storage medium
By analyzing the character name extraction method in the story text and evaluating the importance of candidate names with multiple factors, the problems of accuracy and efficiency in the existing technology are solved, and efficient and accurate core protagonist recognition is achieved.
Patent Information
- Application Number
- CN202510467973.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-14
- Publication Date
- 2025-07-29
AI Technical Summary
When extracting the core protagonists in story texts, the existing technology has low accuracy and efficiency, making it difficult to meet the real-time and accuracy requirements in the fields of digital publishing, content recommendation, and literary data mining.
By obtaining story text, character name extraction is performed, and the candidate name is determined based on the number of occurrences of candidate names, position distribution scores, social centrality and emotional fluctuations correlation degree, and the target name is selected based on the importance.
It improves the recognition accuracy and efficiency of the core protagonists, and can quickly grasp the key points in massive texts and improve user experience.
Smart Images

Figure CN120387451A_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of AI (Artificial Intelligence), specifically to the fields of NLP (Natural Language Processing), intelligent retrieval, etc., and particularly relates to a text processing method, apparatus, electronic device, and storage medium. Background Art
[0002] The core protagonist in a story is the key to driving the plot development and connecting the story context. Accurately extracting the information of the core protagonist can enable users to quickly grasp the story context, reduce interference from invalid information, and thus provide users with high-quality reading guidance. Summary of the Invention
[0003] This disclosure provides a text processing method, apparatus, electronic device, and storage medium.
[0004] According to one aspect of this disclosure, there is provided a text processing method, including:
[0005] Obtain a story text to be processed;
[0006] Extract character names from the story text to obtain candidate names;
[0007] Determine the importance level of the candidate names based on at least one of the number of occurrences of the candidate names in the story text, the position distribution score, the social centrality, and the degree of correlation between the candidate names and the emotional fluctuations in the story text;
[0008] Select target names from the candidate names based on the importance level.
[0009] According to another aspect of this disclosure, there is provided a text processing apparatus, including:
[0010] A text acquisition module, configured to obtain a story text to be processed;
[0011] A name extraction module, configured to extract character names from the story text to obtain candidate names;
[0012] A first determination module, configured to determine the importance level of the candidate names based on at least one of the number of occurrences of the candidate names in the story text, the position distribution score, the social centrality, and the degree of correlation between the candidate names and the emotional fluctuations in the story text;
[0013] A selection module, configured to select target names from the candidate names based on the importance level.
[0014] According to another aspect of the present disclosure, there is provided an electronic device, including:
[0015] at least one processor; and
[0016] a memory communicatively connected to the at least one processor; wherein,
[0017] the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute the text processing method proposed in the above aspect of the present disclosure.
[0018] According to yet another aspect of the present disclosure, there is provided a non-transitory computer-readable storage medium storing computer instructions for causing a computer to execute the text processing method proposed in the above aspect of the present disclosure.
[0019] According to still another aspect of the present disclosure, there is provided a computer program product including a computer program which, when executed by a processor, implements the text processing method proposed in the above aspect of the present disclosure.
[0020] It should be understood that the content described in this part is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it used to limit the scope of the present disclosure. Other features of the present disclosure will become readily apparent from the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] The drawings are used to better understand the solution and do not constitute a limitation to the present disclosure. Among them:
[0022] Figure 1 is a flowchart of a text processing method provided according to an embodiment of the present disclosure;
[0023] Figure 2 is a flowchart of a text processing method provided according to another embodiment of the present disclosure;
[0024] Figure 3 is a flowchart of a text processing method provided according to another embodiment of the present disclosure;
[0025] Figure 4 is a flowchart of a text processing method provided according to another embodiment of the present disclosure;
[0026] Figure 5 is a flowchart of a text processing method provided according to another embodiment of the present disclosure;
[0027] Figure 6 is a structural diagram of a text processing device provided according to an embodiment of the present disclosure;
[0028] Figure 7It is a block diagram of an electronic device for implementing the text processing method of the embodiments of the present disclosure. Detailed implementation manners
[0029] The following describes exemplary embodiments of the present disclosure with reference to the accompanying drawings. Various details of the embodiments of the present disclosure are included to facilitate understanding, and they should be considered merely exemplary. Therefore, those of ordinary skill in the art should recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. Similarly, descriptions of well-known functions and structures are omitted below for clarity and conciseness.
[0030] In related technologies, when processing story texts to extract core protagonists, it is often only possible to rely on simple word frequency statistics or basic entity recognition, which easily misses key characters or misidentifies minor characters.
[0031] In addition, traditional solutions not only have a slow processing speed, but also have great limitations in terms of accuracy, and it is difficult to meet the dual requirements of real-time performance and accuracy in fields such as digital publishing, content recommendation, and literary data mining.
[0032] Therefore, in view of at least one of the above problems, the present disclosure proposes a text processing method, apparatus, electronic device, and storage medium. Among them, the present disclosure can be applied to digital reading platforms, intelligent retrieval systems, and literary research tools to help users quickly grasp the key points in a large amount of text, improve the system response speed and user experience.
[0033] The following describes the text processing method, apparatus, electronic device, and storage medium of the embodiments of the present disclosure with reference to the accompanying drawings.
[0034] Figure 1 It is a schematic flowchart of a text processing method according to an embodiment of the present disclosure.
[0035] In the embodiments of the present disclosure, the text processing method is configured in a text processing apparatus as an example. The text processing apparatus can be applied to any electronic device so that the electronic device can perform text processing functions.
[0036] Among them, the electronic device can be any device with computing capabilities, such as a personal computer, a mobile terminal, a server, etc. The mobile terminal can be a hardware device with various operating systems, touch screens, and / or display screens, such as a mobile phone, a tablet computer, a personal digital assistant, a wearable device, etc.
[0037] As Figure 1 shown, the text processing method may include the following steps S101 to S104:
[0038] Step S101, obtain the story text to be processed.
[0039] Among them, the story text includes but is not limited to novel text, drama text, and biographical text of figures.
[0040] Among them, the text format of the story text can be any e-book format, including but not limited to: EPUB (Electronic Publication), MOBI (Mobipocket eBook Format), TXT (Plain Text File), PDF (Portable Document Format).
[0041] Step S102, extract the character names from the story text to obtain candidate names.
[0042] Among them, in order to improve the accuracy and efficiency of character name extraction, before extracting the character names from the story text, the format of the story text can be converted first to avoid character garbling. Exemplarily, an e-book parsing tool can be used to convert the story text into UTF-8 (8-bit Unicode Transformation Format).
[0043] Among them, in order to ensure that the data is clean and the format is unified during subsequent analysis, before extracting the character names from the story text, the story text can be tokenized, cleaned (such as removing stop words and meaningless symbols, etc.), and standardized. Among them, when tokenizing, conversations, quotation marks, dashes, etc. can be recognized to avoid incorrect tokenization; when cleaning, a general stop word list for NLP tasks or a predefined stop word list for story text can be used to remove meaningless or low-value words.
[0044] Among them, the general stop word list can be extended to obtain a predefined stop word list for story text. Exemplarily, the extended words include but are not limited to: said, thought, suddenly, oh, haha, looked, thought, heard, Chapter One, Volume Two.
[0045] Among them, the character names can be extracted from the story text through a NER (Named Entity Recognition) model to obtain multiple candidate names; or a predefined name dictionary such as "Hundred Family Surnames" can be combined to extract the character names from the story text.
[0046] It should be noted that after extracting the character names, ordinary nouns that are misrecognized can be eliminated by combining part-of-speech tagging (POS tagging) and the text context, as well as low-frequency words that appear less than a set number of times in the story text (such as names that appear only 1-2 times), and cross-verify whether they conform to the structure of personal names.
[0047] Step S103: Determine the importance of a candidate name based on at least one of the number of occurrences of the candidate name in the story text, the position distribution score, the social centrality, and the degree of correlation between the candidate name and the emotional fluctuations in the story text.
[0048] Among them, the position distribution score is used to indicate the distribution of the candidate name in the story text, such as the degree of dispersion or concentration; the social centrality is used to indicate the importance of the candidate name in the story social network corresponding to the story text; the importance of the candidate name refers to the importance of the candidate name in the story text.
[0049] As an example, for any candidate name, obtain the number of occurrences of the candidate name, the position distribution score, the social centrality, and the degree of correlation, and then determine its importance based on the foregoing parameters.
[0050] In the embodiments of the present disclosure, the number of occurrences of a candidate name in the story text can intuitively reflect its exposure; the position distribution score can reflect the degree of dispersion or concentration of the candidate name in the story text; the social centrality can reflect whether the character is in a core position in the story social network; and the degree of correlation with emotional fluctuations can reveal the degree of its impact on the emotional fluctuations of the plot. By synthesizing these factors, the importance of the candidate name can be evaluated more accurately and comprehensively, thereby providing a strong basis for the extraction of the target name, that is, the core character.
[0051] As an example, the number of occurrences, the position distribution score, the social centrality, and the degree of correlation corresponding to the candidate name can be input into an importance prediction model to obtain the importance output by the importance prediction model.
[0052] Step S104: Select a target name from the candidate names based on the importance.
[0053] Among them, a target name with an importance greater than or equal to an importance threshold can be selected from the candidate names based on the importance. Among them, the number of target names can be one or more.
[0054] After extracting the target names, the corresponding character relationship network and role types of each target name can be output. Among them, the character relationship network can include other names that have a direct association with the target name, as well as the number of times the target name and other names co-occur in the story text. It should be noted that the number of co-occurrences can indicate the degree of closeness of the relationship between the two; the role types can include the protagonist (such as the male protagonist, female protagonist), important supporting roles, etc.
[0055] Among them, after extracting the target names, the corresponding number of occurrences, position distribution score, social centrality, and degree of relevance of the target names can also be output.
[0056] In the text processing method of the embodiments of the present disclosure, the number of occurrences of the candidate name in the story text can intuitively reflect its frequency of occurrence; the position distribution score can reflect the degree of dispersion or concentration of the candidate name in the story text; the social centrality can reflect whether the role is in a core position in the story social network; and the degree of relevance to the emotional fluctuation can reveal the degree of its impact on the emotional fluctuation of the plot. Therefore, by comprehensively considering these parameters, the importance of the candidate name can be evaluated more accurately and comprehensively, thereby providing a strong basis for the extraction of the target name and improving the recognition accuracy and efficiency of the core role.
[0057] It should be noted that in the technical solution of the present disclosure, the processing of collecting, storing, using, processing, transmitting, providing, and disclosing the user's personal information involved is carried out on the premise of obtaining the user's consent, and all comply with the provisions of relevant laws and regulations and do not violate public order and good customs.
[0058] The story text includes multiple text units. To clearly illustrate how to determine the social centrality of the candidate name in the character co-occurrence network in any embodiment of the present disclosure, the present disclosure also proposes a text processing method.
[0059] Figure 2 It is a schematic flowchart of the text processing method provided by another embodiment of the present disclosure.
[0060] As Figure 2 shown, the text processing method may include the following steps S201 to S203:
[0061] Step S201, obtain multiple candidate names that co-occur in any text unit.
[0062] Among them, the text units in the story text can be obtained by dividing the text based on a set window. Each time the window slides, a text unit is obtained.
[0063] Among them, the text units in the story text can also be obtained by dividing the text according to sentences, conversations, or paragraphs. Each sentence corresponds to a text unit, or each round of conversation corresponds to a text unit, or one or more paragraphs correspond to a text unit.
[0064] It should be noted that when dividing the text, if the text units are obtained based on different division levels such as sentences, conversations, and paragraphs, then the text units obtained based on sentence division are actually included in the text units obtained based on paragraph division. This means that if multiple candidate names appear within the same sentence, these names will also be counted at the paragraph level to which the sentence belongs. To avoid double counting, for the candidate names that have already been counted as co-occurring in a smaller text unit (such as the sentence level), they will not be counted again when performing statistics on larger text units (such as the paragraph level).
[0065] Step S202: Based on multiple candidate names that co-occur in any text unit, construct a role co-occurrence network.
[0066] Among them, the role co-occurrence network can be an undirected graph or an undirected weighted graph. The nodes in the role co-occurrence network identify the candidate names, and the connection edges between the nodes represent the co-occurrence relationship of the candidate names corresponding to the nodes in the same text unit.
[0067] In any embodiment of the present disclosure, for multiple candidate names that co-occur in any text unit, any two candidate names among the multiple candidate names are used as two network nodes. Among them, there is a connection edge between the two network nodes; according to the co-occurrence times of any two candidate names in multiple text units, the weight of the connection edge is determined; based on the determined network nodes and the weights of the connection edges between the network nodes, a role co-occurrence network is constructed.
[0068] Among them, for multiple candidate names that co-occur in any text unit, the multiple candidate names can be combined pairwise to obtain at least one name pair; the two candidate names in any name pair are used as two network nodes, the two network nodes are connected, and based on the co-occurrence times of the two candidate names in the name pair in all text units, the weight of the node connection edge is determined. Repeat the above steps to traverse the multiple candidate names that co-occur in each text unit.
[0069] It should be noted that during the process of constructing the role co-occurrence network, alias recognition can be performed to fuse the network nodes corresponding to the same candidate name, and to fuse the network nodes corresponding to the candidate names corresponding to the same role and the aliases.
[0070] In summary, converting candidate names into nodes can clearly display the complex relationships between roles in a topological structure. Determining the connection edge weights based on the co-occurrence coefficient can visually present the degree of association tightness between roles in numerical form. On this basis, by constructing a role co-occurrence network, the role relationships in the story text are transformed into a computable and observable graphical model, which helps to quickly and accurately determine the social centrality of candidate names in the role co-occurrence network.
[0071] In any embodiment of the present disclosure, the number of co-occurrences of the two candidate names in the name pair in all text units is directly used as the weight of the node connection edge.
[0072] In any embodiment of the present disclosure, the text unit is any one of the following: dialogue type unit, adjacent sentence type unit, paragraph type unit. Among them, the dialogue type unit refers to the text unit composed of the dialogue content corresponding to the same round of dialogue, the adjacent sentence type unit refers to the text unit composed of two or more adjacent sentences, and the paragraph type unit refers to the text unit composed of one or more paragraphs of content.
[0073] Each type of text unit corresponds to a frequency weight. Exemplarily, the frequency weight corresponding to the dialogue type text unit is a, the frequency weight corresponding to the adjacent sentence type text unit is b, and the frequency weight corresponding to the paragraph type text unit is c. Wherein, a > b > c.
[0074] In any embodiment of the present disclosure, obtain the number of co-occurrences of any two candidate names in any type of text unit; determine the weight of the connection edge according to the number of co-occurrences of any two candidate names in at least one type of text unit and the frequency weight corresponding to at least one type.
[0075] Exemplarily, for candidate name M and candidate name N, the number of co-occurrences of M and N in the dialogue type text unit is A, the number of co-occurrences of M and N in the adjacent sentence type text unit is B, and the number of co-occurrences of M and N in the paragraph type text unit is C. Then the weight of the corresponding connection edge is A * a + B * b + C * c.
[0076] Therefore, the types of text units where the two co-occurring candidate names are located are different, and the degree of association tightness reflected is also different. Therefore, by combining the number of co-occurrences of the two candidate names in each type of text unit and the frequency weight corresponding to the text unit type to determine the connection edge weight, the connection edge weight can more accurately reflect the degree of association tightness between the two candidate names.
[0077] Step S203, for any candidate name in the role co-occurrence network, determine the social centrality of the candidate name in the role co-occurrence network based on the target centrality index.
[0078] In any one of the embodiments of the present disclosure, the target centrality index includes at least one of the following: degree centrality index; betweenness centrality index; PageRank index.
[0079] Among them, the degree centrality index is used to indicate how many different events the name appears in, the betweenness centrality index is used to determine whether the role corresponding to the name is a bridge for the plot development, and the PageRank index is used to measure the influence of the role corresponding to the name. Thus, calculating the social centrality based on the target centrality index can accurately evaluate the influence of the role, and then accurately locate the core role.
[0080] As an example, the target centrality index includes the degree centrality index, the betweenness centrality index, and the PageRank index.
[0081] In any one of the embodiments of the present disclosure, the target centrality index includes multiple centrality indices; for any centrality index included in the target centrality index, based on the role co-occurrence network, determine the index value of the candidate name under the centrality index; perform weighted fusion on the index values of the candidate name under multiple centrality indices to obtain the social centrality.
[0082] Among them, the weights corresponding to each centrality index can be preset.
[0083] A single centrality index has limitations. Performing weighted fusion on the index values of different centrality indices can comprehensively consider various factors such as degree centrality and betweenness centrality, balance the influences of different indices, make the social centrality evaluation result more comprehensive and accurate, and more accurately reflect the importance of the candidate name in the role co-occurrence network.
[0084] The text processing method of the embodiments of the present disclosure can deeply analyze the social centrality of the candidate name in the story social network by constructing a role co-occurrence network and combining the target centrality index, so that the social centrality can accurately reflect whether the role is in the core position in the story social network.
[0085] To clearly illustrate how to determine the correlation degree between the candidate name and the emotional fluctuations in the story text in any one of the embodiments of the present disclosure, the present disclosure also proposes a text processing method.
[0086] Figure 3 It is a schematic flowchart of the text processing method provided according to another embodiment of the present disclosure.
[0087] As Figure 3 shown, the text processing method may include the following steps S301 to S304:
[0088] Step S301: Perform sentiment analysis on the story text to obtain target chapters with emotional fluctuations greater than the set fluctuation threshold.
[0089] Among them, by performing sentiment analysis on the story text, the emotional fluctuation analysis value corresponding to any chapter in the story text can be obtained. The emotional fluctuation analysis value is used to indicate the degree of emotional fluctuation. Exemplarily, the larger the emotional fluctuation analysis value, the more intense the emotional fluctuation can be described.
[0090] Among them, based on the emotional fluctuation analysis value, target chapters with emotional fluctuations greater than the set fluctuation threshold can be screened out.
[0091] In addition, by performing sentiment analysis on the story text, the emotional category analysis value corresponding to any chapter in the story text can also be obtained. The emotional category analysis value is used to indicate the emotional category corresponding to the story text. Exemplarily, the emotional category includes comedy and tragedy, and the value range of the emotional category analysis value can be [-1, 1], where a positive number represents comedy and a negative number represents tragedy.
[0092] Step S302: Determine the first importance degree of the candidate name in the target chapter based on the number of occurrences of the candidate name in the target chapter.
[0093] As an example, the number of occurrences of the candidate name in the target chapter can be mapped and transformed to obtain the above first importance degree.
[0094] In any one of the embodiments of the present disclosure, obtain the inverse document frequency of the candidate name in the story text library; based on the number of occurrences of the candidate name in the target chapter and the inverse document frequency, determine the first importance degree.
[0095] Among them, based on the number of occurrences of the candidate name in the target chapter, determine the term frequency (TF) of the candidate name in the target chapter; based on the number of story texts containing the candidate name in the story text library and the total number of story texts in the story text library, determine the inverse document frequency (IDF); calculate the product TF-IDF of the term frequency and the inverse document frequency, and based on TF-IDF, determine the first importance degree.
[0096] In summary, the inverse document frequency can measure the discrimination and rarity of the candidate name. Combining the number of occurrences of the candidate name in the target chapter and the inverse document frequency to calculate the first importance degree can achieve the dynamic balance of local high-frequency features and global rare features. High-frequency core names obtain prominent weights due to the double addition of the number of occurrences and the inverse document frequency, while low-discrimination names are effectively filtered due to the suppression of the inverse document frequency, thereby improving the recognition accuracy of core character names.
[0097] Step S303: Determine the second importance level of the candidate name in the target chapter based on the number of occurrences of the candidate name in the target syntactic function in the target chapter.
[0098] In any one embodiment of the present disclosure, the target syntactic function includes at least one of the following: subject; object; modifier. Among them, the modifier includes, but is not limited to, adjective modifiers and adverb modifiers.
[0099] If the candidate name frequently appears as the subject, it indicates that it actively initiates many actions and is crucial for the plot progression; if the candidate name appears as the object more often, it means that it is mostly the affected object and has weak dominance; if the candidate name often appears as a modifier, it may indicate that it is more about describing a specific attribute or feature of the corresponding role rather than directly driving the plot development. Therefore, by analyzing the number of occurrences of the candidate name in different syntactic functions, it is possible to further determine whether the role corresponding to the candidate name is the dominant role in the target chapter, which is beneficial to improving the accuracy of target name extraction.
[0100] In any one embodiment of the present disclosure, the target syntactic function includes multiple syntactic functions; based on the weights corresponding to the multiple syntactic functions, the number of occurrences of the candidate name in the target syntactic function in the target chapter is weighted and fused to obtain the second importance level.
[0101] Among them, the weight corresponding to the subject is greater than the weight corresponding to the object, and the weight corresponding to the object is greater than the weight corresponding to the modifier.
[0102] In summary, weights are assigned to different syntactic functions to weight and fuse the number of occurrences of the candidate name in each target syntactic function, comprehensively considering the differences in aspects such as the manifestation of role dominance and plot promotion of each syntactic function, making the evaluation result more objective and accurate.
[0103] Step S304: Determine the degree of correlation between the candidate name and the emotional fluctuations in the story text based on the first importance level and / or the second importance level.
[0104] As an example, based on the set weights, the first importance level and the second importance level can be weighted and fused to obtain the degree of correlation between the candidate name and the emotional fluctuations in the story text.
[0105] The text processing method of the embodiment of the present disclosure performs sentiment analysis on the story text, and can accurately locate the target chapter with significant sentiment fluctuations; determines the first importance of the candidate name based on the number of occurrences of the candidate name in the target chapter, and can use the number of occurrences as a quantitative standard to intuitively present the activity level of the candidate name in the target chapter; determines the second importance of the candidate name based on the number of occurrences of the candidate name under the target syntactic function in the target chapter, and can evaluate the importance of the candidate name from a grammatical level through syntactic function analysis, making the importance evaluation result more three-dimensional and comprehensive; determines the correlation between the candidate name and the sentiment fluctuation in the story text based on the first importance and / or the second importance, and can accurately judge the correlation between the candidate name and the sentiment fluctuation based on the evaluation result of at least one aspect of the importance, thereby improving the accuracy of the analysis.
[0106] In order to clearly illustrate how the position distribution score is determined in any embodiment of the present disclosure, the present disclosure also proposes a text processing method.
[0107] Figure 4 It is a flowchart of a text processing method provided according to another embodiment of the present disclosure.
[0108] like Figure 4 As shown, the text processing method may include the following steps S401 to S403:
[0109] Step S401 : determining a first distribution score based on the number of times the candidate name appears in the first M chapters and / or the last N chapters in the story text.
[0110] The values of M and N can be pre-set or determined based on the total number of chapters in the story text and a set ratio. M and N are positive integers.
[0111] As an example, the set ratio may include a first set ratio and a second set ratio, the first set ratio being used to determine M, and the second set ratio being used to determine N. The first set ratio and the second set ratio may be the same or different; for example, the first set ratio and the second set ratio may be 10%.
[0112] Exemplarily, the product of the total number of chapters and the first set ratio is determined, and the product of the total number of chapters and the first set ratio is rounded to obtain M; the product of the total number of chapters and the second set ratio is determined, and the product of the total number of chapters and the second set ratio is rounded to obtain N.
[0113] As an example, the first distribution score may be determined based on the number of times the candidate name appears in the first M chapters and the last N chapters in the story text.
[0114] Since the core protagonist often has more scenes in the beginning and ending chapters, determining the first distribution score based on the number of occurrences of the candidate name in the first M chapters and / or the last N chapters can accurately capture the occurrence characteristics of the candidate name at the key positions in the story text, and thus provide a strong basis for the evaluation result of the importance of the candidate name.
[0115] Step S402: Determine a second distribution score based on the chapter span between the chapters in which the candidate name appears in the story text.
[0116] Among them, the chapter numbers corresponding to the chapters in which the candidate name appears in the story text can be obtained, and the chapter numbers can be sorted in ascending or descending order to obtain a sequence of chapter numbers; based on the number differences between any two adjacent chapter numbers in the sequence of chapter numbers, the above-mentioned chapter span is determined.
[0117] As an example, obtain the number differences between any two adjacent chapter numbers in the sequence of chapter numbers; determine the chapter span according to the maximum value or the average value of the number differences.
[0118] The chapter span between the chapters in which the candidate name appears can intuitively reflect the degree of dispersion or concentration of the candidate name in the story text, help to understand the coherence of its penetration into the plot, and provide an important basis for comprehensively evaluating the importance of the candidate name in the story text.
[0119] Step S403: Determine a position distribution score based on the first distribution score and / or the second distribution score.
[0120] Among them, the first distribution score and the second distribution score can be weighted and fused based on the set weights to obtain the position distribution score.
[0121] Based on the position distribution score, it is possible to avoid misjudging a non-core character as the protagonist due to its high frequency of appearance in a certain chapter.
[0122] The text processing method of the embodiments of the present disclosure determines the first distribution score based on the number of occurrences of the candidate name in the first M chapters and / or the last N chapters in the story text, which can accurately capture the occurrence characteristics of the candidate name at the key positions in the story text; determines the second distribution score based on the chapter span between the chapters in which the candidate name appears in the story text, which can intuitively reflect the degree of dispersion or concentration of the candidate name in the story text; and then determines the position distribution score based on the first distribution score and / or the second distribution score, which can make the position distribution score more accurately reflect the core status of the candidate name in the story text and avoid misjudging a non-core character as the protagonist due to its high frequency of appearance in a certain chapter.
[0123] To clearly illustrate how to determine the importance of a candidate name based on at least one of the number of occurrences of the candidate name in the story text, the position distribution score, the social centrality, and the degree of correlation between the candidate name and the emotional fluctuations in the story text in any embodiment of the present disclosure, the present disclosure also proposes a text processing method.
[0124] Figure 5 It is a schematic flowchart of a text processing method provided according to another embodiment of the present disclosure.
[0125] As Figure 5 shown, the text processing method may include the following steps S501 to S505:
[0126] Step S501, obtain the story text to be processed.
[0127] Step S502, extract the character names from the story text to obtain candidate names.
[0128] For the explanatory notes of steps S501 to S502, reference may be made to the relevant descriptions in any embodiment of the present disclosure, and details are not described herein again.
[0129] Step S503, obtain the number of occurrences of the candidate name in the story text, the position distribution score, the social centrality, and the degree of correlation between the candidate name and the emotional fluctuations in the story text, and obtain the weights corresponding to the number of occurrences, the position distribution score, the social centrality, and the degree of correlation.
[0130] In any embodiment of the present disclosure, the weights corresponding to the number of occurrences, the position distribution score, the social centrality, and the degree of correlation may be preset.
[0131] In any embodiment of the present disclosure, determine the target text style corresponding to the story text; based on the target text style, determine the weights corresponding to the number of occurrences, the position distribution score, the social centrality, and the degree of correlation.
[0132] Among them, the target text style refers to the text category of the story text. Exemplarily, the text category includes but is not limited to suspense, romance, horror, martial arts, science fiction, etc.
[0133] As an example, the weights of the number of occurrences, the position distribution score, the social centrality, and the degree of correlation matching the target text style may be determined according to the mapping relationship between the text style and the weights corresponding to the number of occurrences, the position distribution score, the social centrality, and the degree of correlation.
[0134] As another example, a machine learning model (such as an XGBoost model) can be pre-trained with story text samples in different text styles to output corresponding weights for the number of occurrences, position distribution scores, social centrality weights, and relevance weights. The story text to be processed is input into the trained machine learning model to obtain the weights for the number of occurrences, position distribution scores, social centrality weights, and relevance weights output by the machine learning model.
[0135] The narrative styles and focuses of story texts in different text styles are different. For example, the suspense style focuses on plot twists and suspense settings, which can increase the weights corresponding to the number of occurrences and position distribution scores to accurately locate the key characters that drive the development of the suspense. The romance style focuses on the emotions of the characters and romantic plots, which can increase the weights corresponding to social centrality and relevance to accurately extract the key characters that drive the key plots. In summary, determining the weights based on the text style of the story text can make the analysis of the core characters fit the text characteristics, thereby improving the accuracy of extracting the target name.
[0136] In any one of the embodiments of the present disclosure, target keywords in the story text are extracted, and a first text style is determined based on the target keywords, where the target keywords include keywords with the number of occurrences greater than a set occurrence threshold. Semantic feature analysis is performed on the story text, and a second text style is determined based on the results of the semantic feature analysis. Syntactic structure analysis and / or sentiment analysis are performed on the story text, and a third text style is determined based on the results of the syntactic structure analysis and / or sentiment analysis. The target text style is determined based on at least one of the first text style, the second text style, and the third text style.
[0137] Among them, the extracted target keywords are matched with a pre-constructed style dictionary to determine the first text style. Exemplarily, the style dictionary is as follows:
[0138]
[0139] Among them, performing semantic feature analysis on the story text and determining the second text style based on the results of the semantic feature analysis include at least one of the following implementation methods:
[0140] (1) Extract the target text vector of the story text to be processed, and perform similarity matching between the target text vector and the text vectors corresponding to story texts in different text styles in the text vector library to determine the second text style.
[0141] (2) Perform supervised learning on the story text dataset based on the labeled text style to train a text style classification model, and use the trained text style classification model to determine the second text style. Among them, the text style classification model can be a model such as SVM (Support Vector Machine), XGBoost, Transformer, etc.
[0142] (3) For the story text to be processed, calculate the topic distribution at the sentence level, analyze the style bias of the main topic words, and then determine the second text style.
[0143] Among them, syntactic structure analysis of the story text includes analyzing the sentence patterns in the story text. Exemplarily, sentence pattern analysis includes, but is not limited to: whether there are many inverted sentences, whether there are many ancient-style expressions, whether there are many short sentences with obvious emotional fluctuations, whether technical terms are included, and whether there are many long compound sentences.
[0144] As an example, there are many inverted sentences and ancient-style expressions in the story text of the martial arts style; there are many short sentences with obvious emotional fluctuations in the story text of the romance style; the sentences in the story text of the science fiction style often contain technical terms and many long compound sentences.
[0145] Among them, sentiment analysis of the story text includes analyzing the corresponding sentiment curve of the story text.
[0146] As an example, the sentiment curve corresponding to the story text of the martial arts style often includes emotional fluctuations of the passionate / revenge type, the sentiment curve corresponding to the story text of the romance style is mostly an alternation of sweet and sad emotions, and the sentiment curve corresponding to the story text of the science fiction style has a relatively high proportion of calm narrative emotions.
[0147] As an example, any one of the first text style, the second text style, and the third text style can be used as the target text style; alternatively, at least two of the first text style, the second text style, and the third text style can be combined to determine the final target text style.
[0148] In summary, by combining multi-faceted information such as high-frequency keywords, semantic features, syntactic structure, and sentiment, analyzing text features comprehensively and multi-levelly can accurately capture the text style, effectively avoid the deviation caused by a single method, and improve the accuracy and reliability of text style determination.
[0149] The explanations of the number of occurrences, position distribution score, social centrality, and degree of relevance mentioned in step S503 can be referred to the relevant descriptions in any embodiment of the present disclosure, and will not be elaborated here.
[0150] Step S504: Based on the weights, perform weighted fusion on the occurrence times, location distribution score, social centrality, and relevance degree to obtain the importance degree.
[0151] Among them, based on the weights, perform weighted summation on the occurrence times, location distribution score, social centrality, and relevance degree to obtain the importance degree.
[0152] Step S505: Select the target name from the candidate names based on the importance degree.
[0153] For the explanatory description of Step S505, reference can be made to the relevant descriptions in any embodiment of the present disclosure, and details will not be elaborated here.
[0154] The text processing method according to the embodiments of the present disclosure obtains the weights corresponding to the occurrence times, location distribution score, social centrality, and relevance degree; based on the weights, perform weighted fusion on the occurrence times, location distribution score, social centrality, and relevance degree to obtain the importance degree, which can balance the influence of different indicators, avoid the excessive influence of a single indicator on the result, and ensure the accuracy and objectivity of the importance degree evaluation result. In addition, when facing the diversity of text styles, the adaptability of the present disclosure to determine the importance degree of candidate names through a dynamic weighting mechanism is stronger, the core role recognition accuracy rate is higher, and the misjudgment rate is lower.
[0155] To clearly illustrate how the present disclosure extracts the target name, the following takes the story text as a novel text as an example to illustrate the text processing method:
[0156] (1) Obtain the novel text, convert the novel text to UTF-8 format, and perform word segmentation, cleaning, normalization, etc. on the formatted novel text.
[0157] (2) Based on the processed novel text, extract candidate names through the NER model; and combine POS tagging and text context to eliminate misrecognized common nouns, and count the low-frequency words (such as names that appear only 1-2 times) with the occurrence times less than the set times in the story text, and cross-verify whether they conform to the personal name structure.
[0158] (3) Count the occurrence times / frequency of each candidate name in the novel text; among them, when performing the statistics, the names in the introduction part (such as the book preface, appendix) can be ignored to avoid statistical noise; in addition, since the protagonist often appears in the dialogue, for the personal names in the dialogue box, the weight can be increased.
[0159] (4) Count the number of occurrences of each candidate name in the first 10% and the last 10% of the chapters, calculate the first distribution score based on the counted number of occurrences; count the chapter span between the chapters where each candidate name appears, calculate the second distribution score based on the chapter span; determine the position distribution score based on the first distribution score and the second distribution score.
[0160] (5) Conduct sentiment analysis on the novel text, filter out the target chapters with large emotional fluctuations; calculate TF-IDF based on the number of occurrences of the candidate name in the target chapters, and then determine the first importance degree; determine the second importance degree based on the number of occurrences of the candidate name in the syntactic functions such as subject, object, and modifier in the target chapters and the corresponding weight of each syntactic function; calculate the correlation degree between the candidate name and the emotional fluctuation in the story text based on the first importance degree and the second importance degree.
[0161] (6) Traverse the novel text, record the co-occurrence situation of the candidate name in the dialogue-type unit, adjacent sentence-type unit, and paragraph-type unit, construct an undirected weighted graph, that is, the character co-occurrence network; calculate the centrality index value of the candidate name in the character co-occurrence network based on the degree centrality index, betweenness centrality index, and PageRank index, and then obtain the social centrality of the candidate name in the character co-occurrence network.
[0162] (7) Identify the target text style of the novel text, determine the weights corresponding to the number of occurrences, position distribution score, social centrality, and correlation degree based on the target text style; perform weighted summation on the number of occurrences, position distribution score, social centrality, and correlation degree based on the corresponding weights to obtain the importance degree of the candidate name in the novel text.
[0163] (8) Based on the importance degree of the candidate name in the novel text, filter out the core character list in the novel text, as well as the corresponding character relationship network and character type of the core characters, which is convenient for subsequent applications in scenarios such as novel recommendation, search, and data mining. In addition, a force-directed graph of character relationships can be generated to visually present the primary and secondary relationships, and the character weights can be distinguished by combining color coding (red for the main character, blue for the secondary character, etc.) and size. Among them, the content such as the character relationship network and character type can be output in formats such as JSON (JavaScript Object Notation), CSV (Comma-Separated Values), HTML (HyperText Markup Language), and PDF (Portable Document Format).
[0164] This disclosure starts from text preprocessing, obtains candidate names through word segmentation, cleaning, and named entity recognition, and then adopts a multi-level analysis method to organically and weightedly combine the basic statistics, location analysis, and graph theory algorithms of the text. The entire implementation process is efficient and stable, not only greatly improving the processing speed but also enhancing the accuracy of core protagonist recognition. In addition, this disclosure also designs a dynamic weighting mechanism that can automatically adjust the weight parameters according to the text styles of different novels to adapt to various types of text analysis.
[0165] Corresponding to the text processing method provided in the above Figures 1 to 5 embodiment, this disclosure also provides a text processing device. Since the text processing device provided in the embodiments of this disclosure corresponds to the text processing method provided in the above Figures 1 to 5 embodiment, the implementation manners of the text processing method are also applicable to the text processing device provided in the embodiments of this disclosure and will not be described in detail in the embodiments of this disclosure.
[0166] Figure 6 is a schematic structural diagram of a text processing device provided according to an embodiment of this disclosure.
[0167] As Figure 6 shown, the text processing device 600 may include: a text acquisition module 610, a name extraction module 620, a first determination module 630, and a selection module 640.
[0168] Among them, the text acquisition module 610 is configured to acquire the story text to be processed;
[0169] The name extraction module 620 is configured to extract character names from the story text to obtain candidate names;
[0170] The first determination module 630 is configured to determine the importance of the candidate names based on at least one of the number of occurrences of the candidate names in the story text, the location distribution score, the social centrality, and the degree of correlation between the candidate names and the emotional fluctuations in the story text;
[0171] The selection module 640 is configured to select target names from the candidate names based on the importance.
[0172] In a possible implementation manner of the embodiments of this disclosure, the story text includes multiple text units, and the device further includes a second determination module, configured to:
[0173] acquire multiple candidate names that co-occur in any one text unit;
[0174] build a character co-occurrence network based on the multiple candidate names that co-occur in any one text unit;
[0175] For any candidate name in the role co-occurrence network, based on the target centrality index, determine the social centrality of the candidate name in the role co-occurrence network.
[0176] In a possible implementation manner of the embodiment of the present disclosure, the second determination module is specifically configured to:
[0177] For multiple candidate names that co-occur in any text unit, use any two of the multiple candidate names as two network nodes, where there is a connection edge between the two network nodes;
[0178] Determine the weight of the connection edge according to the number of times the any two candidate names co-occur in multiple text units;
[0179] Construct a role co-occurrence network based on the determined network nodes and the weights of the connection edges between the network nodes.
[0180] In a possible implementation manner of the embodiment of the present disclosure, the text unit is any one of the following: a dialogue unit, an adjacent sentence pattern unit, a paragraph unit, and the second determination module is specifically configured to:
[0181] Obtain the number of times any two candidate names co-occur in any type of text unit;
[0182] Determine the weight of the connection edge according to the number of times any two candidate names co-occur in at least one type of text unit and the weight corresponding to at least one type.
[0183] In a possible implementation manner of the embodiment of the present disclosure, the target centrality index includes at least one of the following:
[0184] Degree centrality index;
[0185] Betweenness centrality index;
[0186] PageRank index.
[0187] In a possible implementation manner of the embodiment of the present disclosure, the target centrality index includes multiple centrality indexes, and the second determination module is specifically configured to:
[0188] For any centrality index included in the target centrality index, based on the role co-occurrence network, determine the index value of the candidate name under the centrality index;
[0189] Perform weighted fusion on the index values of the candidate name under multiple centrality indexes to obtain the social centrality.
[0190] In a possible implementation manner of the embodiment of the present disclosure, the device further includes a third determination module, configured to:
[0191] Perform sentiment analysis on the story text to obtain the target chapters with emotional fluctuations greater than the set fluctuation threshold;
[0192] Based on the number of occurrences of the candidate name in the target chapter, determine the first importance degree of the candidate name in the target chapter;
[0193] Based on the number of occurrences of the candidate name in the target syntactic function in the target chapter, determine the second importance degree of the candidate name in the target chapter;
[0194] Based on the first importance degree and / or the second importance degree, determine the correlation degree between the candidate name and the emotional fluctuation in the story text.
[0195] In a possible implementation manner of the embodiment of the present disclosure, the target syntactic function includes at least one of the following:
[0196] Subject;
[0197] Object;
[0198] Modifier.
[0199] In a possible implementation manner of the embodiment of the present disclosure, the target syntactic function includes multiple syntactic functions, and the third determination module is specifically configured to:
[0200] Based on the weights corresponding to the multiple syntactic functions, perform weighted fusion on the number of occurrences of the candidate name in the target syntactic function in the target chapter to obtain the second importance degree.
[0201] In a possible implementation manner of the embodiment of the present disclosure, the third determination module is specifically configured to:
[0202] Obtain the inverse document frequency of the candidate name in the story text library;
[0203] Based on the number of occurrences of the candidate name in the target chapter and the inverse document frequency, determine the first importance degree.
[0204] In a possible implementation manner of the embodiment of the present disclosure, the device further includes a fourth determination module, configured to:
[0205] Based on the number of occurrences of the candidate name in the first M chapters and / or the last N chapters in the story text, determine the first distribution score;
[0206] Based on the chapter span between the chapters where the candidate name appears in the story text, determine the second distribution score;
[0207] Based on the first distribution score and / or the second distribution score, determine the position distribution score.
[0208] In a possible implementation manner of the embodiment of the present disclosure, the first determination module 630 is specifically configured to:
[0209] Obtain the weights corresponding to the occurrence times, position distribution scores, social centrality, and correlation degree;
[0210] Based on the weights, perform weighted fusion on the occurrence times, position distribution scores, social centrality, and correlation degree to obtain the importance degree.
[0211] In a possible implementation manner of the embodiment of the present disclosure, the first determination module 630 is specifically configured to:
[0212] Determine the target text style corresponding to the story text;
[0213] Based on the target text style, determine the weights corresponding to the occurrence times, position distribution scores, social centrality, and correlation degree.
[0214] In a possible implementation manner of the embodiment of the present disclosure, the first determination module 630 is specifically configured to:
[0215] Extract the target keywords in the story text, and determine the first text style based on the target keywords, where the target keywords include the keywords whose occurrence times are greater than the set occurrence threshold;
[0216] Perform semantic feature analysis on the story text, and determine the second text style based on the semantic feature analysis result;
[0217] Perform syntactic structure analysis and / or sentiment analysis on the story text, and determine the third text style based on the syntactic structure analysis result and / or the sentiment analysis result;
[0218] Determine the target text style based on at least one of the first text style, the second text style, and the third text style.
[0219] In the text processing device according to the embodiment of the present disclosure, the number of occurrences of the candidate name in the story text can intuitively reflect its occurrence frequency; the position distribution score can reflect the degree of dispersion or concentration of its candidate name in the story text; the social centrality can reflect whether the character is in the core position in the story social network; the correlation degree with the emotional fluctuation can reveal the degree of its influence on the emotional fluctuation of the plot. Therefore, by comprehensively considering these parameters, the importance of the candidate name can be evaluated more accurately and comprehensively, thereby providing a strong basis for the extraction of the target name and improving the recognition accuracy and efficiency of the core character.
[0220] According to the embodiments of the present disclosure, the present disclosure also provides an electronic device, a readable storage medium, and a computer program product.
[0221] Figure 7FIG. 0 shows a schematic block diagram of an exemplary electronic device 700 that may be used to implement embodiments of the present disclosure. The electronic device 700 is intended to represent various forms of digital computers, such as, for example, laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as, for example, personal digital processors, cellular telephones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely exemplary and are not intended to limit the implementation of the present disclosure described and / or claimed herein.
[0222] As Figure 7 shown, the electronic device 700 includes a computing unit 701 that can perform various appropriate actions and processes in accordance with a computer program stored in a ROM (Read-Only Memory) 702 or a computer program loaded from a storage unit 708 into a RAM (Random Access Memory) 703. In the RAM 703, various programs and data required for the operation of the electronic device 700 can also be stored. The computing unit 701, the ROM 702, and the RAM 703 are connected to each other via a bus 704. An I / O (Input / Output) interface 705 is also connected to the bus 704.
[0223] Multiple components in the electronic device 700 are connected to the I / O interface 705, including: an input unit 706, such as a keyboard, a mouse, etc.; an output unit 707, such as various types of displays, speakers, etc.; a storage unit 708, such as a magnetic disk, an optical disk, etc.; and a communication unit 709, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 709 allows the electronic device 700 to exchange information / data with other devices via a computer network such as the Internet and / or various telecommunication networks.
[0224] The computing unit 701 can be various general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 701 include, but are not limited to, a CPU (Central Processing Unit), a GPU (Graphic Processing Units), various dedicated AI (Artificial Intelligence) computing chips, various computing units running machine learning model algorithms, a DSP (Digital Signal Processor), and any suitable processor, controller, microcontroller, etc. The computing unit 701 executes the various methods and processes described above, such as the text processing method. For example, in some embodiments, the text processing method can be implemented as a computer software program that is tangibly embodied in a machine-readable medium, such as the storage unit 708. In some embodiments, part or all of the computer program can be loaded and / or installed onto the electronic device 700 via the ROM 702 and / or the communication unit 709. When the computer program is loaded into the RAM 703 and executed by the computing unit 701, one or more steps of the text processing method described above can be executed. Alternatively, in other embodiments, the computing unit 701 can be configured to execute the text processing method by any other suitable means (e.g., by means of firmware).
[0225] The various embodiments of the systems and techniques described above in this document can be implemented in digital electronic circuitry, integrated circuit systems, FPGAs (Field Programmable Gate Arrays), ASICs (Application-Specific Integrated Circuits), ASSPs (Application Specific Standard Products), SOCs (System On Chip), CPLDs (Complex Programmable Logic Devices), computer hardware, firmware, software, and / or combinations thereof. These various embodiments can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special or general programmable processor, and can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit the data and instructions to the storage system, the at least one input device, and the at least one output device.
[0226] The program code for implementing the methods of the present disclosure can be written in any combination of one or more programming languages. These program codes can be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing devices, such that when the program codes are executed by the processor or controller, the functions / operations specified in the flowcharts and / or block diagrams are implemented. The program codes can be executed entirely on the machine, partially on the machine, executed partially on the machine as an independent software package and partially on a remote machine, or executed entirely on a remote machine or server.
[0227] In the context of the present disclosure, a machine-readable medium can be a tangible medium that can contain or store a program for use by or in connection with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer disk, a hard disk, a RAM, a ROM, an EPROM (Electrically Programmable Read-Only-Memory), or a flash memory, an optical fiber, a CD-ROM (Compact Disc Read-Only Memory), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0228] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (Cathode-Ray Tube) or an LCD (Liquid Crystal Display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or a trackball) through which the user can provide input to the computer. Other kinds of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and the input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0229] The systems and techniques described herein can be implemented in a computing system including backend components (e.g., as a data server), or a computing system including middleware components (e.g., an application server), or a computing system including frontend components (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with embodiments of the systems and techniques described herein), or a computing system including any combination of such backend components, middleware components, or frontend components. The components of the system can be interconnected to each other by digital data communication in any form or medium (e.g., a communication network). Examples of communication networks include: LAN (Local Area Network), WAN (Wide Area Network), the Internet, and blockchain networks.
[0230] A computer system can include a client and a server. The client and the server are generally far from each other and usually interact through a communication network. The client-server relationship is created by computer programs running on respective computers and having a client-server relationship with each other. The server can be a cloud server, also known as a cloud computing server or a cloud host, which is a host product in the cloud computing service system, solving the defects of difficult management and weak business scalability existing in traditional physical hosts and VPS services ("Virtual Private Server", or simply "VPS"). The server can also be a server of a distributed system, or a server combined with blockchain.
[0231] It should be noted that artificial intelligence is a discipline that studies enabling a computer to simulate certain human thought processes and intelligent behaviors (such as learning, reasoning, thinking, planning, etc.), and it has both hardware-level technologies and software-level technologies. Artificial intelligence hardware technologies generally include technologies such as sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, and big data processing; artificial intelligence software technologies mainly include several major directions such as computer vision technology, speech recognition technology, natural language processing technology, and machine learning / deep learning, big data processing technology, and knowledge graph technology.
[0232] It should be understood that various forms of processes shown above can be used, with steps reordered, added, or deleted. For example, the steps recited in this disclosure can be executed in parallel, sequentially, or in a different order, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved, and no limitations are imposed herein.
[0233] The above specific embodiments do not constitute a limitation on the protection scope of the present disclosure. Those skilled in the art should understand that various modifications, combinations, sub - combinations and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principle of the present disclosure shall be included within the protection scope of the present disclosure.
Claims
1. A text processing method, comprising: Obtaining a story text to be processed; Performing character name extraction on the story text to obtain candidate names; Determining the importance degree of the candidate names based on at least one of the number of occurrences of the candidate names in the story text, the position distribution score, the social centrality, and the correlation degree between the candidate names and the emotional fluctuations in the story text; Selecting target names from the candidate names based on the importance degree.
2. The method according to claim 1, wherein, The story text includes multiple text units, and the method further includes: Obtaining multiple candidate names that co-occur in any one text unit; Constructing a character co-occurrence network based on the multiple candidate names that co-occur in any one text unit; For any candidate name in the character co-occurrence network, determining the social centrality of the candidate name in the character co-occurrence network based on a target centrality index.
3. The method according to claim 2, wherein constructing a character co-occurrence network based on the multiple candidate names that co-occur in any one text unit includes: For the multiple candidate names that co-occur in any one text unit, taking any two candidate names among the multiple candidate names as two network nodes, wherein there is a connection edge between the two network nodes; Determining the weight of the connection edge according to the number of times the any two candidate names co-occur in the multiple text units; Constructing the character co-occurrence network based on the determined network nodes and the weights of the connection edges between the network nodes.
4. The method according to claim 3, wherein the text unit is any one of the following: a dialogue type unit, an adjacent sentence pattern unit, a paragraph type unit, and determining the weight of the connection edge according to the number of times the any two candidate names co-occur in the multiple text units includes: Obtaining the number of times the any two candidate names co-occur in any type of text unit; Determining the weight of the connection edge according to the number of times the any two candidate names co-occur in at least one type of text unit and the weight corresponding to at least one type.
5. The method according to claim 2, wherein the target centrality index includes at least one of the following: Degree centrality index; Betweenness centrality index; PageRank index of web page ranking.
6. The method according to any one of claims 2-5, wherein the target centrality index includes multiple centrality indexes, and determining the social centrality of the candidate name in the character co-occurrence network based on the target centrality index includes: For any centrality index included in the target centrality index, determining the index value of the candidate name under the centrality index based on the character co-occurrence network; Performing weighted fusion on the index values of the candidate name under the multiple centrality indexes to obtain the social centrality.
7. The method according to claim 1, wherein the method further includes: Performing emotional analysis on the story text to obtain a target chapter with an emotional fluctuation greater than a set fluctuation threshold; Determine the first importance level of the candidate name in the target chapter based on the number of occurrences of the candidate name in the target chapter; Determine the second importance level of the candidate name in the target chapter based on the number of occurrences of the candidate name in the target chapter under the target syntactic function; Determine the degree of correlation between the candidate name and the emotional fluctuations in the story text based on the first importance level and / or the second importance level.
8. The method according to claim 7, wherein the target syntactic function includes at least one of the following: Subject; Object; Modifier.
9. The method according to claim 7 or 8, wherein the target syntactic function includes multiple syntactic functions, and determining the second importance level of the candidate name in the target chapter based on the number of occurrences of the candidate name in the target chapter under the target syntactic function includes: Based on the weights corresponding to the multiple syntactic functions, perform weighted fusion on the number of occurrences of the candidate name in the target chapter under the target syntactic function to obtain the second importance level.
10. The method according to claim 7, wherein determining the first importance level of the candidate name in the target chapter based on the number of occurrences of the candidate name in the target chapter includes: Obtain the inverse document frequency of the candidate name in the story text library; Determine the first importance level based on the number of occurrences of the candidate name in the target chapter and the inverse document frequency.
11. The method according to claim 1, wherein the method further includes: Determine a first distribution score based on the number of occurrences of the candidate name in the first M chapters and / or the last N chapters of the story text; Determine a second distribution score based on the chapter span between the chapters in which the candidate name appears in the story text; Determine the position distribution score based on the first distribution score and / or the second distribution score.
12. The method according to claim 1, wherein determining the importance level of the candidate name based on at least one of the number of occurrences of the candidate name in the story text, the position distribution score, the social centrality, and the degree of correlation between the candidate name and the emotional fluctuations in the story text includes: Obtain the weights corresponding to the number of occurrences, the position distribution score, the social centrality, and the degree of correlation; Based on the weights, perform weighted fusion on the number of occurrences, the position distribution score, the social centrality, and the degree of correlation to obtain the importance level.
13. The method according to claim 12, wherein obtaining the weights corresponding to the number of occurrences, the position distribution score, the social centrality, and the degree of correlation includes: Determine the target text style corresponding to the story text; Based on the target text style, determine the weights corresponding to the number of occurrences, the position distribution score, the social centrality, and the degree of correlation.
14. The method according to claim 13, wherein determining the target text style corresponding to the story text includes: Extract the target keywords in the story text, and determine the first text style based on the target keywords, where the target keywords include the keywords whose occurrence times are greater than the set threshold; Perform semantic feature analysis on the story text, and determine the second text style based on the semantic feature analysis results; Perform syntactic structure analysis and / or sentiment analysis on the story text, and determine the third text style based on the syntactic structure analysis results and / or sentiment analysis results; Determine the target text style based on at least one of the first text style, the second text style, and the third text style.
15. A text processing device, comprising: A text acquisition module, configured to acquire a story text to be processed; A name extraction module, configured to extract character names from the story text to obtain candidate names; A first determination module, configured to determine the importance level of the candidate names based on at least one of the occurrence times of the candidate names in the story text, the position distribution score, the social centrality, and the correlation degree between the candidate names and the emotional fluctuations in the story text; A selection module, configured to select target names from the candidate names based on the importance level.
16. An electronic device, comprising: At least one processor; And A memory communicatively connected to the at least one processor; wherein, The memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute the method according to any one of claims 1-14.
17. A non-transitory computer-readable storage medium storing computer instructions, wherein, The computer instructions are used to cause the computer to execute the method according to any one of claims 1-14.
18. A computer program product, comprising a computer program, where the computer program, when executed by a processor, implements the method according to any one of claims 1-14.