A method and device for generating poetry

Obtain user input through natural language interaction, extract subject words and user attribute words, and generate customized poetry text. This solves the problem that poetry generation in the existing system does not meet user needs, and achieves higher personalization and creation quality.

CN115080711BActive Publication Date: 2024-10-15INSPUR SUZHOU INTELLIGENT TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210554530.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-05-20
Publication Date
2024-10-15
Estimated Expiration
2042-05-20

AI Technical Summary

Technical Problem

The existing poetry generation system requires users to input concise and concise titles and high-quality examples, and the generated poetry content does not meet the personalized needs of users and cannot accurately meet the creative needs of creators, especially for creations in specific regions or themes.

Method used

Obtain user-input text through natural language interaction, extract subject words and user attribute words, integrate and generate poetry search terms, combine user portraits and natural language models to generate customized poetry text, and use preset scoring rules to select the most appropriate poetry content.

Benefits of technology

It lowers the threshold for users to generate poetry, improves the degree of personalization and creation quality of poetry, and ensures that the generated poetry content meets the user's individual needs and creative intentions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115080711B_ABST
    Figure CN115080711B_ABST
Patent Text Reader

Abstract

The present application relates to a poetry generation method and device. The method comprises: obtaining a natural language text, extracting a subject word based on the natural language text, the natural language text being input by a user; obtaining a user portrait, extracting a user attribute word based on the user portrait; fusing the user attribute word and the subject word to generate a poetry search formula; and generating a target poetry text based on the poetry search formula. The method described in the present application is based on the interaction of natural language as a pre-input, which lowers the threshold for users to generate poetry; fuses the subject word with the user attribute word, and generates customized poetry based on the user's individual attributes and content requirements, thereby satisfying the user's creative needs to the greatest extent.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of big data processing, and in particular to a poetry generation method and device. Background Art

[0002] At present, artificial intelligence has realized the automatic generation of poetry. Chinese poetry has the characteristics of concise language, rich semantics, and regular rhythm, which is a difficult problem in natural language generation. At present, the poetry generation system based on large models, such as the Wudao poetry generation system and the Yuan poetry generation system, has greatly improved the quality of poetry generation content compared with previous poetry generation systems such as "Nine Songs" and "Three Hundred Poems". However, these poetry generation systems require users to enter concise and refined poetry titles, and have high requirements for the format of preset input texts. They often need to provide several high-quality poetry content examples and appropriate keywords, and have high requirements for the language and literature level of the user, that is, the creator. Moreover, the generated poetry content has nothing to do with the creator. Even if it is possible to generate poetry with fluent language and beautiful artistic conception, it is highly likely that it will not meet the personalized needs of users, and users will not like it very much. For example, if a preschool child wants to compose poetry, it is difficult for him to input a concise and refined title of the poem; for another example, if a creator is in Suqian and is inspired by the scenery of the beginning of spring in Suqian and wants to compose a poem about the "beginning of spring", the poem generation system will most likely generate a "beginning of spring" that is not in Suqian, but may be the beginning of spring in Nanjing or Beijing, which cannot accurately meet the user's creative needs.

[0003] Therefore, there is an urgent need to propose a poetry generation method and device that can generate customized poetry based on natural language interaction and user individual portraits. Summary of the invention

[0004] Based on this, it is necessary to provide a poetry generation method and device that can generate customized poetry based on natural language interaction and user individual portraits to address the above technical problems.

[0005] On the one hand, a method for generating poetry is provided, the method comprising:

[0006] Step A: obtaining a natural language text, and extracting a keyword based on the natural language text, wherein the natural language text is input by a user;

[0007] Step B: Obtain a user portrait, and extract user attribute words based on the user portrait;

[0008] Step C: integrating the user attribute words and the subject words to generate a poetry search formula;

[0009] Step D: Generate the target poetry text based on the poetry search formula.

[0010] In one of the embodiments, extracting subject words based on the natural language text includes: segmenting the natural language text to generate a keyword sequence; determining whether the number of keywords in the keyword sequence exceeds a first threshold; if the number of keywords exceeds the first threshold, performing secondary extraction based on the keyword sequence to regenerate the keyword sequence; if the number of keywords in the keyword sequence does not exceed the first threshold, extracting the keywords as subject words.

[0011] In one of the embodiments, obtaining a user portrait and extracting user attribute words based on the user portrait include: obtaining a user portrait, and obtaining the user's age, user's gender and user's geographical location information based on the user portrait; the user's geographical location information includes: the user's geographical location, and the current name and former name of the user's geographical location; the user's geographical location includes: province, city, block, and / or tourist attraction.

[0012] In one of the embodiments, when generating a poetry search formula, the method also includes: based on the natural language text, determining whether the natural language text contains poetry genre limitations; if the natural language text contains poetry genre limitations, extracting the poetry genre and generating a poetry search formula in the order of user attribute words, subject words, and poetry genre; if the natural language text does not contain poetry genre limitations, generating a poetry search formula in the order of user attribute words and subject words.

[0013] In one of the embodiments, when the user attribute words and the subject words are integrated to generate a poetry search formula, the method further includes: searching whether there are words with the same part of speech between the user attribute words and the subject words; if there are words with the same part of speech between the user attribute words and the subject words, deleting the user attribute words; if the subject words include user age, user gender, and / or user geographical location information, determining whether there are words with the same part of speech between the user attribute words and the subject words.

[0014] In one of the embodiments, when the subject word includes the user's geographical location information, the method further includes: defining the user's geographical location information included in the subject word as the first user's geographical location information; defining the user's geographical location information included in the user attribute word as the second user's geographical location information; based on the regional level, comparing the first user's geographical location information and the second user's geographical location information; if the regional level of the first user's geographical location information is higher than the regional level of the second user's geographical location information, then not deleting the second user's geographical location information; if the regional level of the first user's geographical location information is not higher than the regional level of the second user's geographical location information, then deleting the second user's geographical location information.

[0015] In one of the embodiments, a target poetry text is generated based on the poetry search formula, including: based on the poetry search formula, a first poetry text is generated, the number of the first poetry text is at least one; when the number of the first poetry text is one, the first poetry text is directly output as the target poetry text; if the number of the first poetry text is not one, each of the first poetry texts is scored based on a preset scoring rule, and the first poetry text with the highest score is output as the target poetry text.

[0016] In one embodiment, scoring each of the first poetry texts based on a preset scoring rule includes: obtaining scores of multiple dimensions of the first poetry text and a weighting coefficient corresponding to each dimension; scoring each of the first poetry texts based on the scores of the multiple dimensions and the weighting coefficient corresponding to each dimension through the following formula:

[0017]

[0018] Among them, k represents the number of dimensions; w i Indicates the weighting coefficient corresponding to any dimension; Score i Represents the score of any dimension.

[0019] In one embodiment, obtaining scores of multiple dimensions of the first poetry text includes: extracting the poetry outline corresponding to the first poetry text, and obtaining a similarity score between the poetry outline and the poetry search formula based on the poetry outline; obtaining a tone score and a rhyme score of the first poetry text based on the tone and rhyme information data of the first poetry text; and obtaining an artistic conception score of the first poetry text based on the scene, mirror and emotion expressions of the first poetry text.

[0020] On the other hand, a poetry generation device is provided, the device comprising:

[0021] A keyword extraction unit is used to obtain natural language text and extract subject words based on the natural language text, wherein the natural language text is input by a user; a user attribute word extraction unit is used to obtain a user portrait and extract user attribute words based on the user portrait; a search formula generation unit is communicated with the keyword extraction unit and the user attribute word extraction unit, and the search formula generation unit is used to fuse the user attribute words and the subject words to generate a poetry search formula; a target poetry text generation unit is communicated with the search formula generation unit, and the target poetry text generation unit generates a target poetry text based on the poetry search formula.

[0022] In another aspect, a computer device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the following steps are implemented:

[0023] Step A: obtaining a natural language text, and extracting a keyword based on the natural language text, wherein the natural language text is input by a user;

[0024] Step B: Obtain a user portrait, and extract user attribute words based on the user portrait;

[0025] Step C: integrating the user attribute words and the subject words to generate a poetry search formula;

[0026] Step D: Generate the target poetry text based on the poetry search formula.

[0027] The above-mentioned poetry generation method and device, the method includes: obtaining natural language text, extracting subject words based on the natural language text, the natural language text is input by the user; obtaining user portraits, extracting user attribute words based on the user portraits; fusing the user attribute words and the subject words to generate poetry search formulas; based on the poetry search formulas, generating target poetry texts. The method described in this application is based on the interaction of natural language as pre-input, which reduces the threshold for users to generate poetry; fuses subject words with user attribute words, and generates customized poetry based on the user's individual attributes and content requirements, so as to meet the user's creative needs to the greatest extent. BRIEF DESCRIPTION OF THE DRAWINGS

[0028] Figure 1 An application environment diagram of a poetry generation method in an embodiment;

[0029] Figure 2 A schematic diagram of a flow chart of a poetry generation method in one embodiment;

[0030] Figure 3 A schematic diagram of a flow chart of a poetry generation method in one embodiment;

[0031] Figure 4 A structural block diagram of a poetry generation device in an embodiment;

[0032] Figure 5 This is an internal structure diagram of a target poetry text generation unit in one embodiment;

[0033] Figure 6 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION

[0034] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0035] Embodiment 1

[0036] The poetry generation method provided in this application can be applied to Figure 1 In the application environment shown, the terminal 102 communicates with the server 104 through the network. The server 104 obtains the natural language text and the user portrait through the terminal 102. The terminal 102 can be, but is not limited to, various personal computers, laptops, smart phones, tablet computers, and portable wearable devices, and the server 104 can be implemented by an independent server or a server cluster composed of multiple servers.

[0037] In one embodiment, Figure 2 As shown, a poetry generation method is provided, which is applied to Figure 1 The server in the example is used to illustrate the following steps:

[0038] Step A: obtaining a natural language text, and extracting a keyword based on the natural language text, wherein the natural language text is input by a user;

[0039] Step B: Obtain a user portrait, and extract user attribute words based on the user portrait;

[0040] Step C: integrating the user attribute words and the subject words to generate a poetry search formula;

[0041] Step D: Generate the target poetry text based on the poetry search formula.

[0042] The natural language text in step A is the initial text input by the user, which is one of the bases for generating the target poetry text. For example, the sentence "It is the beginning of spring today, and the weather is getting warmer" input by the user is the natural language text in step A of this application. It should be understood that the natural language text can be a complete sentence or a word.

[0043] In one embodiment, Figure 3 As shown, extracting subject words based on the natural language text includes: segmenting the natural language text to generate a keyword sequence; judging whether the number of keywords in the keyword sequence exceeds a first threshold; if the number of keywords exceeds the first threshold, performing secondary extraction based on the keyword sequence to regenerate the keyword sequence; if the number of keywords in the keyword sequence does not exceed the first threshold, extracting the keywords as subject words.

[0044] Specifically, the natural language text can be segmented based on the open source jieba word segmentation tool or other tools or models that can realize keyword extraction to form a keyword sequence. In this embodiment, the first threshold is defined as 3, that is, when the number of keywords in the keyword sequence exceeds 3, the keyword sequence is subjected to secondary keyword extraction based on the open source source 1.0 pre-trained language model (Yuan1.0_13B), and the keyword sequence is regenerated until the number of keywords in the keyword sequence does not exceed 3; when the number of keywords in the keyword sequence does not exceed 3, the keywords are used as subject words. Among them, the number of keywords of the few-shot example of the open source source 1.0 pre-trained language model (Yuan1.0_13B) is limited based on the set first threshold. The present application defines the first threshold as 3, so the number of keywords of the few-shot example of the open source source 1.0 pre-trained language model (Yuan1.0_13B) is also 3.

[0045] In one of the embodiments, obtaining a user portrait and extracting user attribute words based on the user portrait include: obtaining a user portrait, and obtaining the user's age, user's gender and user's geographical location information based on the user portrait; the user's geographical location information includes: the user's geographical location, and the current name and former name of the user's geographical location; the user's geographical location includes: province, city, block, and / or tourist attraction.

[0046] Specifically, the current name and former names of the user's geographical location are all the names of the user's geographical location from ancient times to the present. For example, if the user's current geographical location is Nanjing, the user's geographical location information included in the user portrait includes all names such as Beijing, Beiping, Yanjing and Dadu.

[0047] In one embodiment, when generating a poetry search formula, the method also includes: based on the natural language text, determining whether the natural language text contains poetry genre limitations; if the natural language text contains poetry genre limitations, extracting the poetry genre and generating a poetry search formula in the order of user attribute words, subject words, and poetry genre; if the natural language text does not contain poetry genre limitations, generating a poetry search formula in the order of user attribute words and subject words.

[0048] Specifically, when the natural language text is "Today is the beginning of spring, the weather is getting warmer, let's write a five-character quatrain." The five-character quatrain is the poetry genre limitation input by the user, then the "five-character quatrain" is extracted and used as the poetry genre limitation and integrated with user attribute words and subject words to generate a poetry retrieval formula.

[0049] In one embodiment, when the user attribute words and the subject words are integrated to generate a poetry search formula, the method further includes: searching whether there are words with the same part of speech between the user attribute words and the subject words; if there are words with the same part of speech between the user attribute words and the subject words, deleting the user attribute words; if the subject words include the user's age, the user's gender, and / or the user's geographical location information, determining whether there are words with the same part of speech between the user attribute words and the subject words. That is, when the obtained user attribute words show that the user's geographical location is Nanjing, but the extracted subject words show that the user wants to get a poem about Beijing, the user's geographical location information "Nanjing" in the user attribute words is deleted, and the poem is generated by default with the subject word "Beijing". In other words, when age, gender, and / or user's geographical location information appear in both the subject words and the user attribute words, the poem is generated based on the subject word content.

[0050] In one embodiment, when the subject words include the user's geographical location information, the method further includes: defining the user's geographical location information included in the subject words as the first user's geographical location information; defining the user's geographical location information included in the user attribute words as the second user's geographical location information; comparing the first user's geographical location information and the second user's geographical location information based on the regional level; if the regional level of the first user's geographical location information is higher than the regional level of the second user's geographical location information, then the second user's geographical location information is not deleted; if the regional level of the first user's geographical location information is not higher than the regional level of the second user's geographical location information, then the second user's geographical location information is deleted. Wherein, the regional levels are from high to low: province, city, block, and scenic spot.

[0051] Specifically, when the user's geographical location information included in the subject word is Henan, and the user's geographical location information included in the user attribute word is Zhengzhou, based on the geographical level, the geographical level of Henan is higher than that of Zhengzhou, then the user attribute word Zhengzhou will be retained. When the poetry search formula is integrated, the search formula includes both Henan and Zhengzhou. When generating poetry, as long as the poem contains or implies Henan and / or the place name of Zhengzhou, the poem will be output as the first poetry text.

[0052] In one embodiment, based on the poetry search formula, generating a target poetry text includes:

[0053] Based on the poetry search formula, a first poetry text is generated, and the number of the first poetry text is at least one; when the number of the first poetry text is one, the first poetry text is directly output as the target poetry text; if the number of the first poetry text is not one, each of the first poetry texts is scored based on a preset scoring rule, and the first poetry text with the highest score is output as the target poetry text.

[0054] In one embodiment, scoring each of the first poetry texts based on a preset scoring rule includes: obtaining scores of multiple dimensions of the first poetry text and a weighting coefficient corresponding to each dimension; scoring each of the first poetry texts based on the scores of the multiple dimensions and the weighting coefficient corresponding to each dimension through the following formula:

[0055]

[0056] Among them, k represents the number of dimensions; w i Indicates the weighting coefficient corresponding to any dimension; Score i Represents the score of any dimension.

[0057] In one embodiment, obtaining the scores of multiple dimensions of the first poetry text includes: extracting the poetry outline corresponding to the first poetry text, and obtaining the similarity score between the poetry outline and the poetry search formula based on the poetry outline; obtaining the level and rhyme score of the first poetry text based on the level and rhyme information data of the first poetry text; obtaining the artistic conception score of the first poetry text based on the scene, mirror and emotion expression of the first poetry text. Among them, the level and rhyme information data in "Zhonghua Tongyun" is used as the judgment standard for the level and rhyme score of the first poetry text. The artistic conception score of the first poetry text can be obtained based on 1.0 pre-trained language model (Yuan1.0_13B), by adopting manual annotation, forming 1000 positive samples and 2000 negative samples, and fine-tuning the training source 1.0 pre-trained language model (Yuan1.0_13B) in a supervised manner, and obtaining the artistic conception score judgment model after convergence, and finally outputting the artistic conception score of the first poetry text based on the artistic conception score judgment model.

[0058] Specifically, there is no limitation on the size of the weighting coefficient corresponding to each dimension, and the technology in this field can select the weighting coefficient of the appropriate size based on the actual application scenario. The weighting coefficient can be obtained based on the training of the poetry text training set, that is, based on the training of the natural language training set and the user portrait training set; it can also be obtained based on the analysis of the like rate of the generated target poetry text by the user. For example, through the feedback of the user on the generated target poetry text, it is found that compared with the scene mirror and similarity, the user prefers the poetry text with a higher score of level and oblique rhyme. Therefore, the technicians in this field can increase the weighting coefficient value corresponding to the score of the level and oblique rhyme dimension.

[0059] Based on the above-mentioned poetry generation method, a practical example is used for detailed description. For example, a 20-year-old boy in Nanjing feels that the weather is getting warmer on the day of the beginning of spring, and uses this method to create a poem. The creator expresses in natural language "Today is the beginning of spring, and the weather is getting warmer." That is, the natural language text obtained is "Today is the beginning of spring, and the weather is getting warmer." The user attribute words are: Nanjing, 20 years old, and male.

[0060] Step A: The text "Today is the beginning of spring, and the weather is getting warmer." is input into the Source 1.0 pre-trained language model for keyword extraction, and the extracted keywords are: {beginning of spring, warm};

[0061] Step B: extracting the user attribute words of the creator as "male, 20 years old, Nanjing";

[0062] Step C: Based on the natural language text, determining that the natural language text does not contain any subject matter limitation;

[0063] Step D: Combine user attribute words and subject words to form a poetry search formula {male, 20 years old, Nanjing, beginning of spring, warm}

[0064] Step E: Input the poetry search formula {male, 20 years old, Nanjing, beginning of spring, warm} into the source poetry creation model, wherein "male" is used as the "poet parameter", "20 years old" is used as the "style parameter", and "Nanjing beginning of spring is warm" is used as the "title parameter". The hyperparameter of the "first threshold" is set to 3, and the first poetry text is generated, which is:

[0065] Content 1: Jiangnan is new everywhere, flowers are blooming and swallows are flying all over the city. I love the flowers and willows in Jinling the most, and the spring breeze makes the Qinhuai River green.

[0066] Content 2: Spring has arrived at the Pearl Spring, the willows are green and the orioles are singing. In the warm beginning of spring, I meet good guests, and they return drunkenly listening to the pipa music under the flowers.

[0067] Content 3: Spring arrives at the riverside and the river is warm, flowers blossom and willow trees are new. The east wind blows away the drunkenness, and the sound of rain falls frequently all night.

[0068] Step F: scoring each of the first poetry texts based on a preset scoring rule, and outputting the first poetry text with the highest score as the target poetry text;

[0069] After scoring, the scores of content one to content three are {content one: 0.89}, {content two: 0.91}, {content three: 0.73} respectively. Therefore, content two is finally selected as the target poetry text for output.

[0070] The above-mentioned poetry generation method has the following beneficial effects: First, the natural language interaction method is used as the pre-input, which reduces the threshold and convenience of user-based poetry generation, and can effectively expand the population of creators. Second, taking into account the personalized needs of different user portraits, the user portrait attribute words are used as the basis for generating the target poetry text, so that the generated poetry content can match the individual needs of the user, which helps to improve the richness and personalization of the generated poetry content. Third, based on the user's natural language text, the subject words are extracted from the natural language text, and the poetry retrieval formula is generated based on the subject words and the user attribute words. The poetry text is generated by integrating the user's individual attributes and content needs, and the generated poetry content is comprehensively scored, which significantly improves the quality of poetry creation. In summary, the poetry generation method described in this application fully considers the individual characteristics of the creator through a more convenient interactive method, and finally achieves the beneficial effect of improving the quality and personalization level of poetry creation.

[0071] Embodiment 2

[0072] The present application provides a poetry generation method, the method comprising:

[0073] Step A: obtaining a natural language text, and extracting a keyword based on the natural language text, wherein the natural language text is input by a user;

[0074] Step B: Obtain a user portrait, and extract user attribute words based on the user portrait;

[0075] Step C: integrating the user attribute words and the subject words to generate a poetry search formula;

[0076] Step D: Generate the target poetry text based on the poetry search formula.

[0077] In one embodiment, extracting keywords based on the natural language text includes: segmenting the natural language text to generate a keyword sequence; determining whether the number of keywords in the keyword sequence exceeds a first threshold; if the number of keywords exceeds the first threshold, performing secondary extraction based on the keyword sequence to regenerate the keyword sequence; if the number of keywords in the keyword sequence does not exceed the first threshold, extracting the keywords as keyword sequences.

[0078] In one embodiment, obtaining a user portrait and extracting user attribute words based on the user portrait include: obtaining a user portrait, and obtaining the user's age, user's gender and user's geographical location information based on the user portrait; the user's geographical location information includes: the user's geographical location, and the current name and former name of the user's geographical location; the user's geographical location includes: province, city, block, and / or tourist attraction.

[0079] In one embodiment, when generating a poetry search formula, the method also includes: based on the natural language text, determining whether the natural language text contains poetry genre limitations; if the natural language text contains poetry genre limitations, extracting the poetry genre and generating a poetry search formula in the order of user attribute words, subject words, and poetry genre; if the natural language text does not contain poetry genre limitations, generating a poetry search formula in the order of user attribute words and subject words.

[0080] In one embodiment, when the user attribute words and the subject words are integrated to generate a poetry search formula, the method further includes: searching whether there are words with the same part of speech between the user attribute words and the subject words; if there are words with the same part of speech between the user attribute words and the subject words, deleting the user attribute words; if the subject words include user age, user gender, and / or user geographical location information, determining whether there are words with the same part of speech between the user attribute words and the subject words.

[0081] In one embodiment, when the subject word includes the user's geographical location information, the method further includes: defining the user's geographical location information included in the subject word as the first user's geographical location information; defining the user's geographical location information included in the user attribute word as the second user's geographical location information; based on the regional level, comparing the first user's geographical location information and the second user's geographical location information; if the regional level of the first user's geographical location information is higher than the regional level of the second user's geographical location information, then the second user's geographical location information is not deleted; if the regional level of the first user's geographical location information is not higher than the regional level of the second user's geographical location information, then the second user's geographical location information is deleted.

[0082] In one embodiment, based on the poetry search formula, a target poetry text is generated, including: based on the poetry search formula, a first poetry text is generated, the number of the first poetry text is at least one; when the number of the first poetry text is one, the first poetry text is directly output as the target poetry text; if the number of the first poetry text is not one, each of the first poetry texts is scored based on a preset scoring rule, and the first poetry text with the highest score is output as the target poetry text.

[0083] In one embodiment, scoring each of the first poetry texts based on a preset scoring rule includes: obtaining scores of multiple dimensions of the first poetry text and a weighting coefficient corresponding to each dimension; scoring each of the first poetry texts based on the scores of the multiple dimensions and the weighting coefficient corresponding to each dimension through the following formula:

[0084]

[0085] Among them, k represents the number of dimensions; w i Indicates the weighting coefficient corresponding to any dimension; Score i Represents the score of any dimension.

[0086] In one embodiment, obtaining scores of multiple dimensions of the first poetry text includes: extracting the poetry outline corresponding to the first poetry text, and obtaining a similarity score between the poetry outline and the poetry search formula based on the poetry outline; obtaining a tone score and a rhyme score of the first poetry text based on the tone and rhyme information data of the first poetry text; and obtaining an artistic conception score of the first poetry text based on the scene, mirror and emotion expressions of the first poetry text.

[0087] It should be understood that although Figure 2-3 The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, Figure 2-3 At least part of the steps may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least part of the sub-steps or stages of other steps.

[0088] Embodiment 3

[0089] In one embodiment, Figure 4As shown, a poetry generation device is provided, including: a keyword extraction unit, used to obtain natural language text, and extract subject words based on the natural language text, wherein the natural language text is input by a user; a user attribute word extraction unit, used to obtain a user portrait, and extract user attribute words based on the user portrait; a search formula generation unit, wherein the search formula generation unit is communicatively connected with the keyword extraction unit and the user attribute word extraction unit, and the search formula generation unit is used to fuse the user attribute words and the subject words to generate a poetry search formula; a target poetry text generation unit, wherein the target poetry text generation unit is communicatively connected with the search formula generation unit, and the target poetry text generation unit generates a target poetry text based on the poetry search formula.

[0090] In one embodiment, Figure 5 As shown, the target poetry text generation unit includes: a first poetry text generation module, a judgment module, a scoring module and a target poetry text output module which are sequentially connected in communication; wherein:

[0091] A first poetry text generating module, used for generating a first poetry text based on the poetry search formula, wherein the number of the first poetry text is at least one;

[0092] A judging module, used for judging the number of the first poetry texts, and when the number of the first poetry texts is one, directly outputting the first poetry text as a target poetry text;

[0093] A scoring module, if the number of the first poetry texts is not one, scoring each of the first poetry texts based on a preset scoring rule;

[0094] The target poetry text output module outputs the first poetry text with the highest score as the target poetry text.

[0095] For the specific definition of the poetry generation device, please refer to the definition of the poetry generation method above, which will not be repeated here. Each unit in the above-mentioned poetry generation device can be implemented in whole or in part by software, hardware and a combination thereof. The above-mentioned units can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory in the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above-mentioned units.

[0096] Embodiment 4

[0097] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Figure 6As shown. The computer device includes a processor, a memory, a network interface and a database connected via a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store the number of likes of the user for the generated target poetry text. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a poetry generation method is implemented.

[0098] Those skilled in the art will understand that Figure 6 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0099] In one embodiment, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the following steps when executing the computer program:

[0100] Step A: obtaining a natural language text, and extracting a keyword based on the natural language text, wherein the natural language text is input by a user;

[0101] Step B: Obtain a user portrait, and extract user attribute words based on the user portrait;

[0102] Step C: integrating the user attribute words and the subject words to generate a poetry search formula;

[0103] Step D: Generate the target poetry text based on the poetry search formula.

[0104] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:

[0105] The natural language text is segmented to generate a keyword sequence; whether the number of keywords in the keyword sequence exceeds a first threshold is determined; if the number of keywords exceeds the first threshold, secondary extraction is performed based on the keyword sequence to regenerate the keyword sequence; if the number of keywords in the keyword sequence does not exceed the first threshold, the keywords are extracted as subject words.

[0106] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:

[0107] Obtain a user portrait, and obtain the user's age, gender, and geographical location information based on the user portrait; wherein the geographical location information of the user includes: the geographical location of the user, and the current name and former name of the geographical location of the user; the geographical location of the user includes: province, city, block, and / or scenic spot.

[0108] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:

[0109] Based on the natural language text, determine whether the natural language text contains any poetry genre limitation; if the natural language text contains any poetry genre limitation, extract the poetry genre and generate a poetry search formula in the order of user attribute words, subject words and poetry genre; if the natural language text does not contain any poetry genre limitation, generate a poetry search formula in the order of user attribute words and subject words.

[0110] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:

[0111] Search whether the user attribute words and the subject words have the same part of speech; if the user attribute words and the subject words have the same part of speech, delete the user attribute words; if the subject words include the user age, the user gender, and / or the user's geographical location information, determine whether the user attribute words and the subject words have the same part of speech. Search whether the user attribute words and the subject words have the same part of speech; if the user attribute words and the subject words have the same part of speech, delete the user attribute words; if the subject words include the user age, the user gender, and / or the user's geographical location information, determine whether the user attribute words and the subject words have the same part of speech.

[0112] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:

[0113] Define the user's geographical location information included in the subject word as the geographical location information of the first user; define the user's geographical location information included in the user attribute word as the geographical location information of the second user; based on the regional level, compare the first user's geographical location information and the second user's geographical location information; if the regional level of the first user's geographical location information is higher than the regional level of the second user's geographical location information, do not delete the second user's geographical location information; if the regional level of the first user's geographical location information is not higher than the regional level of the second user's geographical location information, delete the second user's geographical location information.

[0114] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:

[0115] Based on the poetry search formula, a first poetry text is generated, and the number of the first poetry text is at least one; when the number of the first poetry text is one, the first poetry text is directly output as the target poetry text; if the number of the first poetry text is not one, each of the first poetry texts is scored based on a preset scoring rule, and the first poetry text with the highest score is output as the target poetry text.

[0116] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:

[0117] Obtain the scores of multiple dimensions of the first poetry text and the weighting coefficient corresponding to each dimension; and score each of the first poetry texts based on the scores of the multiple dimensions and the weighting coefficient corresponding to each dimension using the following formula: Among them, k represents the number of dimensions; w i Indicates the weighting coefficient corresponding to any dimension; Score i Represents the score of any dimension.

[0118] In one embodiment, when the processor executes the computer program, the following steps are also implemented: extracting the poem outline corresponding to the first poem text, and based on the poem outline, obtaining the similarity score between the poem outline and the poem search formula; based on the tone and rhyme information data of the first poem text, obtaining the tone score and rhyme score of the first poem text; based on the scene, mirror and emotion expression of the first poem text, obtaining the artistic conception score of the first poem text.

[0119] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).

[0120] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0121] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the attached claims.

Claims

1. A method for generating poetry, It is characterized in that The method comprises: Acquire natural language text, and extract keywords based on the natural language text, wherein the natural language text is input by a user; The extracting of subject words based on the natural language text includes: segmenting the natural language text to generate a keyword sequence; determining whether the number of keywords in the keyword sequence exceeds a first threshold; if the number of keywords exceeds the first threshold, performing secondary extraction based on the keyword sequence to regenerate a keyword sequence; if the number of keywords in the keyword sequence does not exceed the first threshold, extracting the keywords as subject words; Obtaining a user portrait, and extracting user attribute words based on the user portrait; Fusion of the user attribute words and the subject words to generate a poetry search formula; Wherein, when generating a poetry search formula, it also includes: based on the natural language text, judging whether the natural language text contains a poetry genre limitation; if the natural language text contains a poetry genre limitation, extracting the poetry genre, and generating a poetry search formula in the order of user attribute words, subject words, and poetry genre; if the natural language text does not contain a poetry genre limitation, generating a poetry search formula in the order of user attribute words and subject words; Based on the poetry search formula, a target poetry text is generated.

2. The poetry generation method according to claim 1, It is characterized in that Obtaining a user portrait, and extracting user attribute words based on the user portrait, including: Obtaining a user portrait, and obtaining user age, user gender, and user location information based on the user portrait; The user's geographical location information includes: the user's geographical location, and the current name and former name of the user's geographical location; The user's geographical location includes: province, city, block, and / or scenic spot.

3. The poetry generation method according to claim 1, It is characterized in that When the user attribute words and the subject words are integrated to generate a poetry search formula, the method further includes: Searching whether the user attribute word and the subject word have words with the same part of speech; If the user attribute word and the subject word have words with the same part of speech, the user attribute word is deleted; If the subject word includes user age, user gender, and / or user location information, it is determined that the user attribute word has a word with the same part of speech as the subject word.

4. The poetry generation method according to claim 3, It is characterized in that When the subject word includes the user's geographical location information, the method further includes: Define the user location information included in the subject word as the first user location information; defining the user geographical location information included in the user attribute word as the second user geographical location information; Based on the regional level, comparing the regional location information of the first user and the regional location information of the second user; If the regional level of the regional location information of the first user is higher than the regional level of the regional location information of the second user, the regional location information of the second user is not deleted; If the regional level of the regional location information of the first user is not higher than the regional level of the regional location information of the second user, the regional location information of the second user is deleted.

5. The poetry generation method according to claim 4, It is characterized in that Based on the poetry search formula, a target poetry text is generated, including: Based on the poetry search formula, generating a first poetry text, the number of the first poetry text is at least one; When the number of the first poetry texts is one, the first poetry text is directly output as the target poetry text; If the number of the first poetry texts is not one, each of the first poetry texts is scored based on a preset scoring rule, and the first poetry text with the highest score is output as the target poetry text.

6. The poetry generation method according to claim 5, It is characterized in that Scoring each of the first poetry texts based on a preset scoring rule includes: Obtaining scores of multiple dimensions of the first poem text and weighting coefficients corresponding to each dimension; By the following formula, each of the first poetry texts is scored based on the scores of the multiple dimensions and the weighting coefficient corresponding to each dimension: Among them, k represents the number of dimensions; w i Indicates the weighting coefficient corresponding to any dimension; Score i Represents the score of any dimension.

7. The poetry generation method according to claim 6, It is characterized in that Obtaining scores of multiple dimensions of the first poem text includes: Extracting a poem outline corresponding to the first poem text, and obtaining a similarity score between the poem outline and the poem search formula based on the poem outline; Based on the level and rhyme information data of the first poem text, obtaining the level and rhyme score and rhyme score of the first poem text; Based on the scene, mirror and emotion expressions of the first poetry text, an artistic conception score of the first poetry text is obtained.

8. A poetry generation device based on the method according to any one of claims 1 to 7, It is characterized in that The device comprises: a keyword extraction unit, which is used to obtain a natural language text and extract a subject word based on the natural language text, wherein the natural language text is input by a user; A user attribute word extraction unit, used to obtain a user portrait and extract user attribute words based on the user portrait; a search formula generation unit, the search formula generation unit is connected to the keyword extraction unit and the user attribute word extraction unit, and the search formula generation unit is used to fuse the user attribute words and the subject words to generate a poetry search formula; A target poetry text generating unit is communicatively connected with the search formula generating unit, and the target poetry text generating unit generates a target poetry text based on the poetry search formula.