Text generation method and device, computer equipment, product and storage medium

By generating a web page structure diagram and using hierarchical relationships to determine node groups, the problem of regular expressions misidentifying paragraphs is solved, and accurate splicing of document text and improved readability are achieved.

CN120688476APending Publication Date: 2025-09-23MASHANG CONSUMER FINANCE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510105469.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-22
Publication Date
2025-09-23

AI Technical Summary

Technical Problem

When conventional techniques use regular expressions to extract content from Hypertext Markup Language text, they tend to mistakenly identify text content in different paragraphs as the same paragraph, resulting in a disordered structure of the generated document text and reduced readability.

Method used

By parsing the web page text, a web page structure diagram is generated, the hierarchical relationship is used to determine the node group, and the text content of the corresponding paragraph is generated based on the node group to ensure that the text units of the same paragraph are correctly identified and spliced.

Benefits of technology

This improves the accuracy of identifying text units within the same paragraph, reduces the probability of text units from different paragraphs being mistakenly identified as the same paragraph, and improves the readability of the document text.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120688476A_ABST
    Figure CN120688476A_ABST
Patent Text Reader

Abstract

The invention discloses a text generation method and device, computer equipment, a product and a storage medium, and the method comprises the steps that a webpage text is analyzed, a webpage structure chart is generated, the webpage structure chart comprises a first node and a second node which have a hierarchical relationship, the first node corresponds to a webpage label in the webpage text, and the second node corresponds to the webpage label in the webpage text; the webpage label indicates a category to which a text unit in the webpage text belongs, and the second node corresponds to the text unit in the webpage text; according to the webpage label corresponding to the first node and the hierarchical relationship between the first node and the second node, determining a plurality of node groups, each node group comprising at least one second node, and text units corresponding to the second nodes in each node group belonging to the same paragraph; and for each node group, generating text content of the corresponding paragraph according to the text unit corresponding to the node group, and generating a document text corresponding to the webpage text according to the text content of each paragraph. According to the invention, the readability of the document text can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of text extraction technology, and in particular to a text generation method, apparatus, computer equipment, product and storage medium (computer-readable storage medium). Background Art

[0002] When summarizing the content in a Hypertext Markup Language text using a large language model, it is necessary to first extract text content from the Hypertext Markup Language (HTML) text, and then summarize the extracted text content using the large language model.

[0003] Currently, regular expressions can be used to extract content from Hypertext Markup Language (HTML) text. However, using regular expressions to extract content from webpage text can easily misidentify content from different paragraphs as the same paragraph, causing the structure of the resulting document to become disordered and reducing its readability. Summary of the Invention

[0004] In response to the above technical problems, embodiments of the present application provide a text generation method, apparatus, computer device, product, and storage medium, which can reduce the probability of misidentifying text content in different paragraphs of a web page text as text content in the same paragraph.

[0005] In a first aspect, an embodiment of the present application provides a text generation method, comprising:

[0006] Parsing the webpage text to generate a webpage structure diagram, the webpage structure diagram including a first node and a second node in a hierarchical relationship, the first node corresponding to a webpage tag in the webpage text, the webpage tag indicating a category to which a text unit in the webpage text belongs, and the second node corresponding to a text unit in the webpage text;

[0007] Determining a plurality of node groups based on the webpage tag corresponding to the first node and the hierarchical relationship between the first node and the second node, each node group including at least one second node, and the text units corresponding to the second nodes in each node group belonging to the same paragraph;

[0008] For each node group, the text content of the corresponding paragraph is generated according to the text unit corresponding to the node group, and the document text corresponding to the webpage text is generated according to the text content of each paragraph.

[0009] In a second aspect, an embodiment of the present application provides a text generation device, comprising:

[0010] a generating module for parsing the webpage text to generate a webpage structure diagram, the webpage structure diagram including a first node and a second node in a hierarchical relationship, the first node corresponding to a webpage tag in the webpage text, the webpage tag indicating a category to which a text unit in the webpage text belongs, and the second node corresponding to a text unit in the webpage text;

[0011] a determination module, configured to determine, based on the webpage tag corresponding to the first node and the hierarchical relationship between the first node and the second node, a plurality of node groups, each node group including at least one second node, and the text units corresponding to the second nodes in each node group belonging to the same paragraph;

[0012] The generating module is further configured to generate, for each node group, text content of a corresponding paragraph according to the text units corresponding to the node group, and generate document text corresponding to the webpage text according to the text content of each paragraph.

[0013] In a third aspect, an embodiment of the present application further provides a computer device, comprising a memory storing a plurality of instructions; a processor loading instructions from the memory to execute the steps of any one of the text generation methods provided in the embodiments of the present application.

[0014] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, which stores a plurality of instructions suitable for loading by a processor to execute the steps of any text generation method provided in an embodiment of the present application.

[0015] In a fifth aspect, an embodiment of the present application further provides a computer program product, comprising a computer program or instructions, which, when executed by a processor, implements the steps of any text generation method provided in an embodiment of the present application.

[0016] In a sixth aspect, an embodiment of the present application further provides a computer software, including a computer program, which, when executed by a processor, implements the steps of any text generation method provided in the embodiment of the present application.

[0017] The solution of the embodiment of the present application is adopted to parse the web page text and generate a web page structure diagram, which includes a first node and a second node with a hierarchical relationship, the first node corresponding to the web page label in the web page text, the web page label indicating the category to which the text unit in the web page text belongs, and the second node corresponding to the text unit in the web page text; according to the web page label corresponding to the first node and the hierarchical relationship between the first node and the second node, multiple node groups are determined, each node group includes at least one second node, and the text units corresponding to the second nodes in each node group belong to the same paragraph; for each node group, the text content of the corresponding paragraph is generated according to the text unit corresponding to the node group, and the document text corresponding to the web page text is generated according to the text content of each paragraph, so that the text units belonging to the same paragraph in the web page text are determined through the label corresponding to the first node and the hierarchical relationship between the first node and the second node, thereby improving the accuracy of identifying text units belonging to the same paragraph, reducing the probability of misidentifying text units of different paragraphs in the web page text as text units of the same paragraph, and improving the readability of the document text. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.

[0019] Figure 1 Schematic diagram of the application environment of the text generation method provided in the embodiment of the present application;

[0020] Figure 2 This is a flow chart of an embodiment of the text generation method provided in the embodiments of the present application;

[0021] Figure 3 is a schematic diagram of a web page structure diagram provided in an embodiment of the present application;

[0022] Figure 4 This is a schematic diagram of a web page structure diagram provided in an embodiment of the present application;

[0023] Figure 5 This is another schematic diagram of the web page structure diagram provided in the embodiment of the present application;

[0024] Figure 6 This is another schematic diagram of the web page structure diagram provided in the embodiment of the present application;

[0025] Figure 7 is a schematic diagram of a node list provided in an embodiment of the present application;

[0026] Figure 8 This is a schematic diagram of a node list provided in an embodiment of the present application;

[0027] Figure 9 is another schematic diagram of a node list provided in an embodiment of the present application;

[0028] Figure 10 is a schematic diagram of a paragraph list provided in the examples of this application;

[0029] Figure 11 This is a schematic diagram of a paragraph list provided in the examples of this application;

[0030] Figure 12 is another schematic diagram of a node list provided in an embodiment of the present application;

[0031] Figure 13 This is another schematic diagram of the node list provided in the embodiment of the present application;

[0032] Figure 14 is a structural diagram of a text generation device provided in an embodiment of the present application;

[0033] Figure 15 It is a schematic diagram of the internal structure of the computer device provided in the embodiment of the present application. DETAILED DESCRIPTION

[0034] The technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without making creative work are within the scope of protection of this application. At the same time, in the description of the embodiments of the present application, the terms "first", "second", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance. Thus, the features defined as "first" and "second" may explicitly or implicitly include one or more features. In the description of the embodiments of the present application, the meaning of "multiple" is two or more, unless otherwise clearly and specifically defined.

[0035] In one embodiment of the present application, the text generation method can be run on a local terminal device or a server. When the text generation method is run on a server, the method can be implemented and executed based on a cloud interaction system, wherein the cloud interaction system includes a server and a client device.

[0036] In order to better understand the text generation method, device, computer equipment, software and storage medium provided in the embodiments of the present application, the application environment applicable to the embodiments of the present application is described below.

[0037] See also Figure 1 , Figure 1 A schematic diagram of an application environment of the text generation method provided by an embodiment of the present application is shown. Figure 1 The server 110 shown in FIG. 1 can be connected to the terminal device 120 via a network. The network is used to provide a medium for a communication link between the server 110 and the terminal device 120. The network can include various connection types, such as wired communication links, wireless communication links, etc., which are not limited in the embodiments of the present application. Alternatively, in other embodiments, the computer device can also be a smartphone, a laptop computer, etc.

[0038] It should be understood that Figure 1 The server 110, network, and terminal device 120 are merely illustrative. Any number of servers, networks, and terminal devices may be provided as needed. For example, the server 110 may be a physical server or a server cluster consisting of multiple servers, and the terminal device 120 may be a mobile phone, tablet, desktop computer, laptop computer, or the like. It will be appreciated that embodiments of the present application may also allow multiple terminal devices 120 to access the server 110 simultaneously.

[0039] The following is a detailed description of each step in conjunction with the accompanying drawings. In this embodiment, the execution subject is a terminal device. It should be noted that the order in which the following embodiments are described does not limit the preferred order of the embodiments. Although the flowcharts illustrate a logical order, in some cases, the steps shown or described may be performed in a different order than that shown in the accompanying drawings.

[0040] The text generation method of this embodiment can be applied to scenarios where text units in web page text need to be processed. For example, the text generation method of this embodiment can be applied to at least one of the scenarios of capturing and analyzing text units in web page text, simplifying text units in web page text, denoising web page text, or unifying the language in web page text.

[0041] The present application parses web page text and generates a web page structure diagram, which includes a first node and a second node with a hierarchical relationship, the first node corresponding to a web page tag in the web page text, the web page tag indicating the category to which the text unit in the web page text belongs, and the second node corresponding to the text unit in the web page text; based on the web page tag corresponding to the first node and the hierarchical relationship between the first node and the second node, multiple node groups are determined, each node group includes at least one second node, and the text units corresponding to the second nodes in each node group belong to the same paragraph; for each node group, the text content of the corresponding paragraph is generated according to the text unit corresponding to the node group, and the document text corresponding to the web page text is generated according to the text content of each paragraph, so as to realize the determination of the text units belonging to the same paragraph in the web page text through the tag corresponding to the first node and the hierarchical relationship between the first node and the second node, thereby improving the accuracy of identifying the text units belonging to the same paragraph, reducing the probability of misidentifying the text units of different paragraphs in the web page text as the text units of the same paragraph, and improving the readability of the document text.

[0042] Please refer to Figure 2 The specific process of the text generation method can be as follows: Step 201 to Step 203, wherein:

[0043] Step 201: parse the web page text to generate a web page structure diagram. The web page structure diagram includes a first node and a second node with a hierarchical relationship. The first node corresponds to a web page tag in the web page text. The web page tag indicates the category to which the text unit in the web page text belongs. The second node corresponds to the text unit in the web page text.

[0044] The webpage text refers to the text including the content displayed on the webpage. The type of webpage text can be set according to the actual situation. For example, the webpage text can be Hypertext Markup Language (HTML) text or Extensible Markup Language (XML) text, which is not limited in this embodiment of the present application.

[0045] A text unit in a webpage refers to the text that users can see on the webpage. A text unit can be a single character, a single word, or a single sentence. For example, a text unit that is a single character might be "and," a text unit that is a single word might be "but," and a text unit that is a single sentence might be "Celebrity A got married."

[0046] Web page text not only includes the text that users can see on the web page, but also includes content that defines the category to which a text unit belongs in the web page structure. Specifically, the content that defines the category to which a text unit belongs in the web page structure is called a web page tag. A web page tag indicates the category to which a text unit belongs in the web page text. For example, the category to which a text unit belongs can include paragraph, title, or table.

[0047] The first node corresponds to the web page tag in the web page text, which can be understood as the first node including the web page tag. The second node corresponds to the text unit in the web page text, which can be understood as the second node including the web page unit in the web page text.

[0048] A web page structure diagram is a mathematical model used to describe the hierarchical relationship between different nodes. Specifically, the web page structure diagram is used in this application to describe the hierarchical relationship between a first node and a second node (the second node may also be referred to as a TextNode). The hierarchical relationship is used to describe the nested structure or hierarchical structure between the first node and the second node. Optionally, a hierarchical relationship may also exist between different first nodes. In this case, the hierarchical relationship is used to describe the nested structure or hierarchical structure between different first nodes.

[0049] It is understood that the hierarchical relationship between two nodes can be represented by describing one node as a subordinate node of another node, or by describing one node as a superior node of another node. The superior node can also be called a parent node or an ancestor node, and the subordinate node can also be called a child node or a second-child node.

[0050] For example, the hierarchical relationship between node n1 and node n2 can be: node n1 is a subordinate node of node n2, or node n2 is a superior node of node n1. Specifically, when parsing web page text and generating a web page structure diagram, if it is a web page tag in the web page text, a first node corresponding to the web page tag is generated so that the web page tag in the web page text is represented by the first node. If it is a text unit in the web page text, a second node corresponding to the text unit is generated so that the second node includes the text unit in the web page text.

[0051] For example, the webpage text is: " <title> Hot Topics< / title> <h3> Famous stars are married< / h3> A star got married In this webpage text, webpage tags include html, head, title, body, h3 and b, and text units include hot topics, famous stars got married and star A got married. When a webpage structure diagram is generated based on this webpage text, the generated webpage structure diagram can be as follows: Figure 3 As shown, Figure 3 All nodes except the second node are the first nodes. Figure 3The hierarchical relationship between the first node and the second node is: the second node "hot topic" is the child node of the first node "title", the second node "famous star got married" is the child node of the first node "h3", and the second node "star A got married" is the child node of the first node "b". Figure 3 The hierarchical relationship between different first nodes is: the first node "title" is a child node of the first node "head", and the first node "h3" and the first node "b" are both child nodes of the first node "body".

[0052] Optionally, the method of parsing the web page text and generating the web page structure diagram can be set according to actual conditions. For example, the web page text can be parsed and the web page structure diagram can be generated by using the Jsoup tool or the BeautifulSoup tool. This embodiment of the present application does not limit this.

[0053] Step 202 : Determine multiple node groups based on the web page tag corresponding to the first node and the hierarchical relationship between the first node and the second node. Each node group includes at least one second node, and the text units corresponding to the second nodes in each node group belong to the same paragraph.

[0054] After obtaining the web page structure diagram, the terminal can traverse the web page structure diagram. During each traversal, a node can be taken from the web page structure diagram. If the node is a second node, the paragraph to which the text unit corresponding to the second node belongs can be determined based on the label corresponding to the first node of the second node's parent. Finally, based on the paragraph to which the text unit corresponding to each second node belongs, at least one second node corresponding to the text unit belonging to the same paragraph can be grouped into a node group.

[0055] Optionally, the upper first node refers to a node that is the upper level of the second node in the web page structure and is also the first node. It can be the direct upper level node of the second node. In this case, the upper first node can also be called the parent first node. Alternatively, the upper first node can also be the indirect upper level node of the second node. In this case, the upper first node can also be called the ancestor first node. For example, Figure 3 As shown, the parent first node of the second node "hot topics" is "title", and the ancestor first node of the second node "hot topics" is "head".

[0056] In some embodiments, determining multiple node groups based on the web page tag corresponding to the first node and the hierarchical relationship between the first node and the second node includes: generating a paragraph identifier corresponding to the second node based on the web page tag corresponding to the first node and the hierarchical relationship between the first node and the second node; and forming a node group with the second nodes having the same paragraph identifier. The paragraph identifier can be a string, and the string can include at least one character. The type of the character can be set according to actual conditions, for example, the character can be at least one of a number, a letter, and a symbol.

[0057] In an embodiment of the present application, a paragraph identifier can be assigned to the second node based on the web page tag corresponding to the first node and the hierarchical relationship between the first node and the second node. When the paragraph identifiers corresponding to the second nodes are the same, it means that the paragraphs to which the second nodes belong are the same. Therefore, the second nodes with the same paragraph identifier can be grouped into a node group.

[0058] In some embodiments, generating a paragraph marker corresponding to the second node based on a webpage tag corresponding to the first node and a hierarchical relationship between the first node and the second node includes: for each second node, determining a first node that has a hierarchical relationship with the second node based on the hierarchical relationship between the first node and the second node; and generating a paragraph marker corresponding to the second node based on a webpage tag corresponding to the first node that has a hierarchical relationship with the second node. The first node that has a hierarchical relationship with the second node may be referred to as the superior first node of the second node, and the superior first node may be the parent first node or ancestor first node of the second node.

[0059] The terminal can traverse the web page structure diagram to extract the node from the web page structure diagram, and then determine whether the node is the first node or the second node. If it is the second node, based on the hierarchical relationship between the first node and the second node, determine the first node that has a hierarchical relationship with the second node, and generate a paragraph tag corresponding to the second node based on the web page tag corresponding to the first node that has a hierarchical relationship with the second node.

[0060] The method of traversing the web page structure graph can be set according to actual conditions. For example, the web page structure graph can be traversed according to the post-order traversal method or the pre-order traversal method. This embodiment of the present application does not limit this.

[0061] In this embodiment, for each second node, based on the hierarchical relationship between the first node and the second node, the first node that has a hierarchical relationship with the second node is determined, and according to the web page tag corresponding to the first node that has a hierarchical relationship with the second node, a paragraph tag corresponding to the second node is generated, thereby determining the paragraph tag corresponding to the second node based on the superior first node of the second node.

[0062] In some embodiments, generating a paragraph marker corresponding to a second node based on a web page tag corresponding to a first node that has a hierarchical relationship with the second node includes: obtaining a first paragraph marker or a preset second paragraph marker of the first node that has a hierarchical relationship with the second node based on the web page tag corresponding to the first node that has a hierarchical relationship with the second node; and generating a paragraph marker corresponding to the second node based on the first paragraph marker or the preset second paragraph marker. The first paragraph marker refers to a marker set for the first node based on the web page tag corresponding to the first node, and the preset second paragraph marker refers to the value of a preset variable, which can be a pre-set variable and is used to generate the paragraph marker corresponding to the second node.

[0063] In an embodiment of the present application, based on the web page tag corresponding to the first node that has a hierarchical relationship with the second node, the first paragraph identifier or the preset second paragraph identifier of the first node that has a hierarchical relationship with the second node is obtained, and based on the first paragraph identifier or the preset second paragraph identifier, the paragraph identifier corresponding to the second node is generated, so as to realize the use of the first paragraph identifier or the second paragraph identifier as the paragraph identifier corresponding to the second node, so as to further ensure that the paragraph identifiers corresponding to the second nodes belonging to the same paragraph are the same.

[0064] In some embodiments, based on the web page tag corresponding to the first node that has a hierarchical relationship with the second node, the first paragraph marker or the preset second paragraph marker of the first node that has a hierarchical relationship with the second node is obtained, including: if the web page tag corresponding to the first node that has a hierarchical relationship with the second node is a paragraph start tag, then the first paragraph marker of the first node that has a hierarchical relationship with the second node is obtained; if the web page tag corresponding to the first node that has a hierarchical relationship with the second node is not a paragraph start tag, then the preset second paragraph marker is obtained.

[0065] The paragraph start tag is a web page tag that indicates the beginning of a paragraph. The paragraph start tag can be set according to actual conditions. For example, the paragraph start identifier can include at least one of a paragraph tag (p tag), a region tag (div tag), and a table tag (table tag). This embodiment of the present application does not limit this.

[0066] Specifically, the terminal can first determine whether the web page tag corresponding to the parent first node of the second node is a paragraph start tag. If the web page tag corresponding to the parent first node of the second node is a paragraph start tag, the first paragraph identifier corresponding to the parent first node is obtained. If the web page tag corresponding to the parent first node of the second node is not a paragraph start tag, it can be determined whether the web page tag corresponding to the ancestor first node of the second node is a paragraph start tag. If the web page tag corresponding to the ancestor first node of the second node is a paragraph start tag, the first paragraph identifier corresponding to the ancestor first node is obtained. If the web page tag corresponding to the ancestor first node of the second node is not a paragraph start tag, the preset second paragraph identifier is obtained.

[0067] For example, a web page structure diagram can be Figure 4 As shown, for node 112, the parent first node of node 112 is node 11, the web page tag corresponding to node 11 is a paragraph tag, and the paragraph tag is a paragraph start tag. Therefore, the first paragraph tag "g1" corresponding to node 11 is assigned to node 112; for node 1111, the ancestor first node of node 1111 is node 11, the tag corresponding to node 11 is a paragraph tag, and the paragraph tag is a paragraph start tag. Therefore, the first paragraph tag "g1" corresponding to node 11 is assigned to node 1111; for node 1131, node 1131 is the second node and the ancestor first node of node 1131 is node 11, the tag corresponding to node 11 is a paragraph tag, and the paragraph tag is a paragraph start tag. Therefore, the first paragraph tag "g1" corresponding to node 1131 is assigned to node 1131. Since the paragraph tags of node 112, node 1111, and node 1131 are all "g1", node 112, node 1111, and node 1131 form a node group. For node 4, node 4 is the second node and the web page tag corresponding to the parent node of node 4 is not a paragraph start tag. Therefore, the preset second paragraph tag "g5" is assigned to node 4, and node 4 is formed into a node group. And so on. Figure 4 The second nodes shown in can form 6 node groups, and the paragraph tags corresponding to the second nodes in the 6 node groups are g1, g3, g4, g5, g6 and g7 respectively.

[0068] In an embodiment of the present application, if the web page tag corresponding to the first node that has a hierarchical relationship with the second node is a paragraph start tag, the first paragraph identifier of the first node that has a hierarchical relationship with the second node is obtained, so that when the superior first nodes of different second nodes are the same and the web page tag corresponding to the superior first node is a paragraph start tag, the paragraph identifiers of different second nodes are all the first paragraph identifiers corresponding to the superior first node, thereby making the paragraph identifiers of different second nodes belonging to the same superior first node the same, so that the different second nodes belonging to the same superior first node are formed into a node group, and if the web page tag corresponding to the first node that has a hierarchical relationship with the second node is not a paragraph start tag, the preset second paragraph identifier is obtained, and the second paragraph identifier is used as the paragraph identifier corresponding to the second node, so that when the web page tag corresponding to the superior first node of the second node is not a paragraph start tag, the second node can form a node group alone.

[0069] In some embodiments, the embodiments of the present application further include: for each first node, if the web page tag corresponding to the first node is a paragraph start tag, a first paragraph marker corresponding to the first node is generated, and the preset second paragraph marker is initialized.

[0070] At this time, if the web page tag corresponding to the first node that has a hierarchical relationship with the second node is not a paragraph start tag, then obtain the preset second paragraph identifier, including: if the web page tag corresponding to the first node that has a hierarchical relationship with the second node is not a paragraph start tag, then determine whether the value corresponding to the preset variable is an initialization value; if the value corresponding to the preset variable is an initialization value, then update the value corresponding to the preset variable to the second paragraph identifier.

[0071] Among them, since the attributes of the web page tag in the web page text can define or modify the behavior, appearance or function of the web page tag, the terminal can set the first paragraph marker according to the attributes of the web page tag. In this case, the first paragraph marker is the value of the attribute of the web page tag, that is, generating the first paragraph marker corresponding to the first node can be understood as generating the value of the attribute of the first node.

[0072] The initialization value can be set according to the actual situation. For example, the initialization value can be 0 or 1, or the initialization value can be empty. When the initialization value is empty, it means that the preset variable does not have a corresponding value. If the value corresponding to the preset variable is the initialization value, the value corresponding to the preset variable is randomly updated to obtain the second paragraph identifier. If the value corresponding to the preset variable is not the initialization value, the value of the preset variable can be directly determined as the second paragraph identifier.

[0073] For example, a web page structure diagram can be Figure 5As shown, for node 3, node 3 is the first node and the web page tag corresponding to node 3 is a paragraph tag, and the paragraph tag is a paragraph start tag. Therefore, the first paragraph identifier of node 3 is generated as "g4", and the preset variable is initialized so that the value of the preset variable becomes the initialization value. For node 311, node 32 and node 331, since node 311, node 32 and node 331 are all second nodes and the parent first node of node 311, node 32 and node 331 is all node 3, the paragraph identifiers corresponding to node 311, node 32 and node 331 are all g4. For node 4, since node 4 is the second node, the web page tag corresponding to the parent first node of node 4 is not a paragraph start tag and the value of the preset variable is the initialization value, the value corresponding to the preset variable is updated to the second paragraph identifier "g5", and "g5" is assigned to node 4. Next, since the web page tag corresponding to node 5 is not a paragraph start tag, there is no need to initialize the preset variable. At this time, the value of the preset variable is still "g5". When the nodes are node 51 and node 52, since the web page tag corresponding to the parent first node of node 51 and node 52 is not a paragraph start identifier and the value of the preset variable is not an initialized value, the value "g5" corresponding to the preset variable is assigned to node 51 and node 52. Node 6 is the first node and the web page tag corresponding to node 6 is a paragraph start tag. Therefore, the first paragraph identifier "g6" corresponding to node 6 is generated, and the preset variable is initialized again.

[0074] It is understandable that the second paragraph identifier obtained by updating the value of the preset variable each time is different.

[0075] In an embodiment of the present application, for each first node, if the web page tag corresponding to the first node is a paragraph start tag, a first paragraph identifier corresponding to the first node is generated, and the preset second paragraph identifier is initialized. If the web page tag corresponding to the first node that has a hierarchical relationship with the second node is not a paragraph start tag, it is determined whether the value corresponding to the preset variable is an initialized value. If the value corresponding to the preset variable is an initialized value, the value corresponding to the preset variable is updated to the second paragraph identifier, so that when the paragraphs to which the second node belongs are different, the paragraph identifier of the second node generated according to the preset second paragraph identifier is different.

[0076] In some embodiments, second nodes with the same paragraph identifier are formed into a node group, including: arranging the second nodes with the same paragraph identifier based on the position of the second nodes in the web page structure diagram to form a node group. Wherein, arranging the second nodes with the same paragraph identifier based on the position of the second nodes in the web page structure diagram can be understood as determining the position of the second nodes with the same paragraph identifier from the web page structure diagram, and then arranging the second nodes with the same paragraph identifier based on the position, among the second nodes with the same paragraph identifier, the second nodes with the earlier position are arranged in the front, and the second nodes with the later position are arranged in the back, to obtain a node group.

[0077] For example, the second node includes node n1, node n2 and node n3, and the paragraph tags of node n1, node n2 and node n3 are the same. The position of node n1 in the web page structure diagram precedes the position of node n2 in the web page structure diagram, and the position of node n2 in the web page structure diagram precedes the position of node n3 in the web page structure diagram. Then, in the node group composed of node n1, node n2 and node n3, the order of node n1 in the node group precedes the order of node n2 in the node group, and the order of node n2 in the node group precedes the order of node n3 in the node group.

[0078] Alternatively, since the process of traversing the web page structure diagram to obtain the second node is based on the position of each node in the web page structure diagram, the earlier the second node is traversed from the web page structure diagram, the earlier its position in the web page structure diagram. Therefore, based on the position of the second node in the web page structure diagram, the second nodes with the same paragraph identifier are arranged. It can also be understood that the second nodes with the same paragraph identifier are arranged based on the order in which the second nodes are traversed.

[0079] In this embodiment, based on the position of the second node in the web page structure diagram, the second nodes with the same paragraph identifier are arranged to form a node group, so that when the text units corresponding to the second nodes in the node group are subsequently spliced, the splicing can be performed directly based on the order of the second nodes in the node group, without the need to rely on the web page structure diagram, thereby improving the efficiency of text unit splicing and thus improving the efficiency of generating document text.

[0080] In some embodiments, a paragraph identifier corresponding to the second node is generated based on the web page tag corresponding to the first node and the hierarchical relationship between the first node and the second node, including: taking out the target node from the node list, the node list includes at least one layer of nodes in the web page structure diagram; if the target node is the first node and the web page tag corresponding to the first node is a paragraph start tag, then a paragraph list is created, and based on the hierarchical relationship in the web page structure diagram, the child nodes of the target node in the web page structure diagram are stored in the node list, and the step of taking out the target node from the node list is returned; if the target node is the second node, the second node is stored in the paragraph list, and based on the identifier of the paragraph list, the second paragraph identifier corresponding to the second node is determined, and the step of taking out the target node from the node list is returned, and the process stops until all nodes in the node list are taken out.

[0081] At this time, the second node in a paragraph list constitutes a node group. The child nodes of the target node in the web page structure diagram refer to the child nodes located in the next layer of the target node in the web page structure diagram, which may include the first node and / or the second node in a hierarchical relationship with the target node. The nodes of a layer refer to nodes belonging to the same layer. For example, when the nodes of a layer are the nodes of the first layer in the web page structure diagram, the nodes of the first layer are as follows: Figure 6 As shown, the nodes of the first layer include Node 1, Node 2, Node 3, Node 4, and Node 5. The node list refers to the intermediate storage space used to store the nodes of each layer traversed from the web page structure. The form of the node list can be set according to actual conditions. For example, the node list can be a queue or a stack, which is not limited in this embodiment of the present application.

[0082] For example, when the node list is a stack, Figure 6 The nodes of the first layer in the stack are stored in the stack. At this time, the stack can be Figure 7 As shown in 701, a target node is taken out from the stack, and the target node taken out is node 1. Node 1 is the first node and the web page tag of node 1 is the paragraph start mark. Then, a paragraph list is created and the child nodes of node 1 are read. Figure 6 It can be seen that the child nodes of node 1 include node 11, node 12 and node 13. Node 11, node 12 and node 13 are stored in the stack. At this time, the node list can be as follows Figure 7 As shown in 702.

[0083] It can be understood that when a target node is taken out from the node list, if the target node is the first node and the web page tag corresponding to the first node is a paragraph start marker, a paragraph list is created and the child nodes of the target node are read from the web page structure diagram; if the target node is the first node and the web page tag corresponding to the first node is not a paragraph start marker, the child nodes of the target node are read from the web page structure diagram.

[0084] For example, the web page structure diagram is as follows Figure 8 As shown, the nodes of the first layer are read from the web page structure diagram, and the nodes of the first layer are stored in the node list, a target node is taken out from the node list, the target node is node 1, node 1 is the first node and the web page tag corresponding to node 1 is the paragraph start tag, a paragraph list is created, the child nodes of node 1 are read from the web page structure diagram, the child nodes of node 1 include node 11, node 12 and node 13, node 11, node 12 and node 13 are stored in the node list, and a target node is taken out from the node list, the target node is node 11, node 11 is the first node and the web page tag corresponding to node 11 is the paragraph start tag, then a new paragraph list is created (at this time, the paragraph list created based on node 1 does not store the second node), and the paragraph list is created from the web page The structure diagram reads the child nodes of node 11. If the child nodes of node 11 do not exist, then a target node is taken out from the node list. At this time, the target node taken out is node 12. Node 12 is the second node, so node 12 is added to the new paragraph list. Then a target node is taken out from the node list. At this time, the target node taken out is node 13. Node 13 is the first node and the label corresponding to the first node is not a paragraph start label. Therefore, there is no need to create a new paragraph list. Just read the child nodes of node 13 from the web page structure diagram, store the child nodes of node 13 in the node list, and execute this process in a loop. When nodes 1311, 132, and 133 in the web page structure diagram are read and stored in the node list, the node list can be as follows: Figure 8 As shown, at this time, the target nodes taken out from the node list three times in a row are node 1311, node 132 and node 133 respectively. Node 1311, node 132 and node 133 are all second nodes. Therefore, node 1311, node 132 and node 133 are stored in the same paragraph list, as shown in Figure 9 As shown, ultimately, the text units included in node 12, node 1311, node 132, and node 133 are in the same paragraph.

[0085] It is understandable that when a new paragraph list is created, the text content in the previously created paragraph list may be the text content in a paragraph, and the text content in the new paragraph list may be the text content in a new paragraph.

[0086] For example, the previously created paragraph list and the new paragraph list can be Figure 10 As shown, at this time, the text unit of the second node in the last created paragraph list constitutes a paragraph, and the text unit of the second node in the new paragraph list created based on node 3 constitutes a paragraph.

[0087] In some embodiments, the attributes of the node list, the reading order of the nodes, and the storage order of the nodes may cause the order of the nodes retrieved from the node list to be different from the order of the nodes read directly from the web page structure diagram, resulting in errors in the structure of the document text ultimately generated based on the retrieved nodes.

[0088] For example, the web page structure diagram is as follows Figure 6 As shown, in Figure 6 In the web page structure diagram shown, the order of the web page tags corresponding to the nodes on the left in the web page text is earlier than the order of the web page tags corresponding to the nodes on the right in the web page text. For example, the order of the web page tags corresponding to node 1 in the web page text is earlier than the order of the web page tags corresponding to node 2 in the web page text, the order of the web page tags corresponding to node 11 in the web page text is earlier than the order of the web page tags corresponding to node 12 in the web page text, and the order of the web page tags corresponding to node 1311 in the web page text is earlier than the order of the web page tags corresponding to node 132 in the web page text. Therefore, a node is read directly from the web page structure diagram in order from left to right. The first node read is node Point 1, if you read the nodes of the first layer from the web page structure diagram from left to right, you will first read node 1, then node 2, then node 3, then node 4, and finally node 5. At this time, if you directly store node 1, node 2, node 3, node 4 and node 5 into the node list, it will result in node 1 being stored first, then node 2, then node 3, then node 4, and finally node 5. If the node list is a stack and the stack's attribute is first-in-last-out, then the node taken out of the stack at this time is node 5, not node 1. If the node list is a queue and the queue's attribute is first-in-first-out, then the node taken out of the queue at this time is node 1.

[0089] Therefore, in order to further reduce the probability of the structure of the document text being disordered due to the attributes of the node list, the reading order of the nodes and the storage order of the nodes, when the node list is a stack, this embodiment also includes: reading a layer of nodes from the web page structure diagram according to a preset reading order; sorting the nodes of one layer in reverse order, and storing the nodes of the layer after reverse order in the stack.

[0090] Similarly, based on the hierarchical relationship in the web page structure diagram, the process of storing the child nodes of the target node in the web page structure diagram into the node list can be: based on the hierarchical relationship in the web page structure diagram, read the child nodes of the next layer of the target node from the web page structure diagram in a preset reading order; sort the child nodes of the next layer in reverse order, and store the child nodes sorted in reverse order into a stack.

[0091] Among them, the preset reading order can be set according to the order of the web page tags corresponding to the nodes in the web page structure diagram in the web page text. For example, the order of the web page tags corresponding to the left node in the web page structure diagram in the web page text is earlier than the order of the web page tags corresponding to the right node in the web page text, then the preset reading order can be the order from left to right. For another example, the order of the web page tags corresponding to the left node in the web page structure diagram in the web page text is later than the order of the web page tags corresponding to the right node in the web page text, then the preset reading order can be the order from right to left.

[0092] For example, when the default reading order is from left to right, the web page structure diagram is as follows Figure 6 As shown, according to the preset reading order, the nodes of the first layer read from the web page structure diagram include node 1, node 2, node 3, node 4 and node 5. Node 1, node 2, node 3, node 4 and node 5 are sorted in reverse order. The nodes of the first layer after reverse order are node 5, node 4, node 3, node 2 and node 1. The nodes of the first layer after reverse order are stored in a stack. At this time, the stack can be as follows Figure 11 As shown, a target node is taken out from the stack, and the target node is node 1. The node read directly from the web page structure diagram for the first time from left to right is also node 1, and the two are the same. Since node 1 is the first node, the child nodes of node 1 are read from the web page structure diagram from left to right. The child nodes of node 1 include node 11, node 12 and node 13. After node 11, node 12 and node 13 are sorted in reverse order, the child nodes after reverse order are node 13, node 12 and node 11. After node 13, node 12 and node 11 are stored in the stack, the stack can be as follows Figure 11 shown.

[0093] In an embodiment of the present application, the node list is a stack. According to a preset reading order, one layer of nodes is read from the web page structure diagram, the nodes of one layer are sorted in reverse order, and the nodes of the layer after reverse sorting are stored in the stack. This can reduce the probability of structural disorder of the document text caused by the attributes of the node list, the reading order of the nodes, and the storage order of the nodes.

[0094] In some embodiments, when the web page tag corresponding to the first node is a paragraph start tag, the child node of the first node includes the second node, and the node at the same level of the first node is also the second node, the text unit included in the child node of the first node and the text unit included in the node at the same level of the first node will be mistakenly combined into one paragraph, but the text unit included in the child node of the first node and the text unit included in the node at the same level of the first node should actually belong to different paragraphs. At this time, an error occurs in identifying the paragraph to which the text unit belongs. Alternatively, when the tag corresponding to the first node is a paragraph start tag, the child node of the first node includes the second node, and the node at the same level of the first node also includes the second node, the text unit included in the child node of the first node and the text unit included in the node at the same level of the first node will be mistakenly combined into one paragraph, but the text unit included in the child node of the first node and the text unit included in the node at the same level of the first node should actually belong to different paragraphs. At this time, an error occurs in identifying the paragraph to which the text unit belongs.

[0095] For example, the web page structure diagram is as follows Figure 12 As shown, when the child nodes of node 1 are stored in the node list, the node list can be as follows Figure 12 As shown in 1201, a target node is taken from the node list. When the target node is node 11, node 11 is the first node and the label corresponding to node 11 is the paragraph start mark. A paragraph list is created and the child nodes of node 11 are stored in the node list. The child node of node 11 is node 111. At this time, the node list can be as follows Figure 12 As shown in 1202, node 111 is taken out from the node list, node 111 is the second node, and node 111 is added to the paragraph list. Then, a target node is taken out from the node list, and the target node is node 12, which is the second node (node ​​12 is a node at the same level as node 11), and node 12 is added to the paragraph list. At this time, the paragraph list includes nodes 111 and 12, which leads to the text units included in node 111 and the text units included in node 12 being mistakenly identified as text units belonging to the same paragraph, that is, the text units included in the child nodes and the text units included in the nodes at the same level are mistakenly formed into one paragraph, but the text units included in node 111 and the text units included in node 12 actually belong to different paragraphs, and node 111 and node 12 should be in different paragraph lists.

[0096] Next, a target node is taken from the node list. The target node is node 13 (node ​​13 is a node at the same level as node 11). Node 13 is the first node and the tag corresponding to node 13 is not a paragraph start marker. The child nodes of node 13 are stored in the node list. At this time, the node list can be as follows: Figure 12As shown in 1203, a target node is taken from the node list. The target node is node 131. Node 131 is the first node and the tag corresponding to the first node is not a paragraph start mark. Then, the child nodes of node 131 are stored in the node list. At this time, the node list can be as follows Figure 12 As shown in 1204, then, the nodes taken out from the node list three times in a row are all the second nodes, namely node 1311, node 132 and node 133, and node 1311, node 132 and node 133 are added to the paragraph list. At this time, the paragraph list includes node 111, node 12, node 1311, node 132 and node 133, and the text units included in node 111, the text units included in node 12, the text units included in node 1311, the text units included in node 132 and the text units included in node 133 are mistakenly identified as text units belonging to the same paragraph, that is, the text units included in the child nodes and the text units included in the subordinate nodes of the same level nodes are mistakenly formed into a paragraph, but the paragraph in which the text units included in node 1311, the text units included in node 132 and the text units included in node 133 are located is different from the paragraph in which the text units included in node 111 are located.

[0097] Therefore, in order to solve the above problem, before storing the child nodes of the target node in the node list, it also includes: judging whether the node adjacent to the target node in the node list is the second node or the first node corresponding to the non-paragraph start tag; if the adjacent node is the second node or the first node corresponding to the non-paragraph start tag, then storing a virtual node in the node list, the virtual node is a node not included in the web page structure diagram and the virtual node is used to indicate the creation of a paragraph list.

[0098] Among them, a non-paragraph start tag refers to a tag that cannot be used to indicate the start of a paragraph. It can be set according to actual conditions. For example, a non-paragraph start tag can be a span tag or an i tag, which is not limited in this embodiment of the present application. The name of the virtual node can be a preset name. When the name of the target node taken out from the node list is a preset name, it indicates that the target node is a virtual node. At this time, a paragraph list is created. Alternatively, a web page tag corresponding to the virtual node can be set. When the web page tag corresponding to the target node taken out from the node list is a preset tag, it indicates that the target node is a virtual node. At this time, a paragraph list is created. The preset tag can be set according to actual conditions. For example, the preset tag can be a br tag or a q tag. This is not limited in this embodiment of the present application.

[0099] For example, the web page structure diagram is as follows Figure 12As shown in FIG, when a target node taken from the node list is node 11, node 11 is the first node and the label corresponding to the first node is the paragraph start mark, a paragraph list is created, and the node adjacent to node 11 in the node list is node 12, and node 12 is the second node. Therefore, the virtual node is first stored in the node list, and then the child node of node 11 is stored in the node list. The child node of node 11 is node 111. At this time, the node list can be as follows Figure 13 As shown. Node 111 is taken out from the node list, which is the second node. Node 111 is added to the paragraph list. Next, a target node is taken out from the node list. Since the target node is a virtual node, a new paragraph list is created. A target node is taken out from the node list, which is node 12, which is the second node. Node 12 is added to the new paragraph list. At this point, the paragraph list where node 111 is located is different from the paragraph list where node 12 is located, thereby avoiding mistakenly forming the text unit included in node 111 and the text unit included in node 12 into the same paragraph.

[0100] In an embodiment of the present application, it is determined whether the node adjacent to the target node in the node list is the second node or the first node corresponding to a non-paragraph start tag. If the adjacent node is the second node or the first node corresponding to a non-paragraph start tag, a virtual node is stored in the node list. The virtual node is a node not included in the web page structure diagram and the virtual node is used to indicate the creation of a paragraph list, further reducing the probability of mistakenly identifying the text content of different paragraphs as the text content of the same paragraph, and further improving the readability of the document text.

[0101] Step 203 : for each node group, generate the text content of the corresponding paragraph according to the text unit corresponding to the node group, and generate the document text corresponding to the webpage text according to the text content of each paragraph.

[0102] The document text refers to a text including plain text. The format of the document text can be set according to the actual situation. For example, the format of the document text can be text, doc, and docx, which is not limited in this embodiment of the present application.

[0103] After obtaining the node group, the terminal may combine the text units corresponding to the second nodes in the node group into the text content of the corresponding paragraph.

[0104] Specifically, the terminal can organize the text units corresponding to each second node in the node group into text content of the corresponding paragraph based on the position of each second node in the node group in the web page structure diagram, wherein the text unit corresponding to the second node in the node group that is located earlier in the web page structure diagram has an earlier position in the corresponding paragraph, and the text unit corresponding to the second node in the node group that is located later in the web page structure diagram has a later position in the corresponding paragraph.

[0105] Alternatively, when the second nodes of the same paragraph are sorted based on the position of the second nodes in the web page structure diagram to form a node group, for each node group, the text content of the corresponding paragraph is generated according to the text units corresponding to the node group, including: for each node group, according to the order of the second nodes in the node group, the text units corresponding to the second nodes in the node group are spliced ​​to obtain the text content of the corresponding paragraph. Among them, the text units of the second nodes with an earlier order in the node group are positioned earlier in the corresponding paragraph, and the text units of the second nodes with a later order in the node group are positioned later in the corresponding paragraph.

[0106] In this embodiment, since the second nodes with the same paragraph identifiers are arranged to form a node group based on the position of the second nodes in the web page structure diagram, when splicing the text units corresponding to the second nodes in the node group, the splicing can be performed directly based on the order of the second nodes in the node group, without the need to rely on the web page structure diagram, thereby improving the efficiency of text unit splicing and thus improving the efficiency of generating document text.

[0107] In some embodiments, when the paragraph identifier corresponding to the second node is determined based on the identifier of the paragraph list, the text units included in the second node can also be stored in the paragraph list, so that after obtaining the node group, the text units in the paragraph list where the second node in the node group is located can be combined into the text content of the corresponding paragraph, so that there is no need to traverse the web page structure diagram again, and the text unit corresponding to the second node in the node group is obtained according to the traversal, thereby improving the efficiency of generating the corresponding paragraph and thus improving the efficiency of generating the document text.

[0108] After obtaining the text content of the corresponding paragraph, the terminal then combines the text content of each paragraph into the document text corresponding to the web page text. Specifically, the earlier the node group is obtained, the earlier the paragraph obtained based on the text unit corresponding to the node group is positioned in the document text, and the later the node group is obtained, the later the paragraph obtained based on the text unit corresponding to the node group is positioned in the document text. Alternatively, the position of the paragraph obtained based on the text unit corresponding to the node group in the document text can be determined based on the position of the second node in the node group in the web page structure diagram.

[0109] In an embodiment of the present application, a web page text is parsed to generate a web page structure diagram, which includes a first node and a second node with a hierarchical relationship, the first node corresponding to a web page tag in the web page text, the web page tag indicating the category to which the text unit in the web page text belongs, and the second node corresponding to the text unit in the web page text; based on the web page tag corresponding to the first node and the hierarchical relationship between the first node and the second node, a plurality of node groups are determined, each node group includes at least one second node, and the text units corresponding to the second nodes in each node group belong to the same paragraph; for each node group, the text content of the corresponding paragraph is generated based on the text unit corresponding to the node group, and the document text corresponding to the web page text is generated based on the text content of each paragraph, so that the text units belonging to the same paragraph in the web page text are determined through the tag corresponding to the first node and the hierarchical relationship between the first node and the second node, thereby improving the accuracy of identifying text units belonging to the same paragraph, reducing the probability of misidentifying text units of different paragraphs in the web page text as text units of the same paragraph, and improving the readability of the document text.

[0110] It should be understood that, although each step in the flowcharts involved in the above-mentioned embodiments is displayed in sequence according to the instructions of the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and these steps can be executed in other orders. Moreover, at least a portion of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a portion of steps or stages in other steps.

[0111] Based on the same inventive concept, the embodiments of the present application further provide a text generation device for implementing the above-mentioned text generation method, and a text generation device for implementing the above-mentioned text generation method. The implementation solution provided by the device is similar to the implementation solution described in the above-mentioned method, so the specific limitations of the one or more text generation devices and embodiments of the text generation device provided below can be referred to the above-mentioned limitations of the text generation method and the text generation method, and the specific limitations are not repeated here.

[0112] This embodiment also provides a text generation device, which can be integrated into a terminal device. Figure 14 As shown, the text generating device 1400 may include:

[0113] Generation module 1401 is used to parse the web page text and generate a web page structure diagram. The web page structure diagram includes a first node and a second node with a hierarchical relationship. The first node corresponds to a web page tag in the web page text. The web page tag indicates the category to which the text unit in the web page text belongs. The second node corresponds to the text unit in the web page text.

[0114] Determination module 1402 is used to determine multiple node groups based on the web page tag corresponding to the first node and the hierarchical relationship between the first node and the second node, each node group includes at least one second node, and the text units corresponding to the second nodes in each node group belong to the same paragraph.

[0115] The generating module 1401 is further configured to generate, for each node group, text content of a corresponding paragraph according to the text units corresponding to the node group, and generate document text corresponding to the webpage text according to the text content of each paragraph.

[0116] In some embodiments, the determination module 1402 is specifically used to execute: generating a paragraph tag corresponding to the second node based on the web page tag corresponding to the first node and the hierarchical relationship between the first node and the second node; and forming a node group with the second nodes having the same paragraph tag.

[0117] In some embodiments, the determination module 1402 is specifically used to perform: for each second node, based on the hierarchical relationship between the first node and the second node, determine the first node that has a hierarchical relationship with the second node; based on the web page tag corresponding to the first node that has a hierarchical relationship with the second node, generate a paragraph tag corresponding to the second node.

[0118] In some embodiments, the determination module 1402 is specifically used to execute: based on the web page tag corresponding to the first node that has a hierarchical relationship with the second node, obtain the first paragraph identifier or the preset second paragraph identifier of the first node that has a hierarchical relationship with the second node; based on the first paragraph identifier or the preset second paragraph identifier, generate a paragraph identifier corresponding to the second node.

[0119] In some embodiments, the determination module 1402 is specifically used to execute: if the web page tag corresponding to the first node that has a hierarchical relationship with the second node is a paragraph start tag, then obtain the first paragraph identifier of the first node that has a hierarchical relationship with the second node; if the web page tag corresponding to the first node that has a hierarchical relationship with the second node is not a paragraph start tag, then obtain a preset second paragraph identifier.

[0120] In some embodiments, the determination module 1402 is specifically configured to: arrange the second nodes with the same paragraph identifier based on the positions of the second nodes in the web page structure diagram to form a node group.

[0121] The generating module 1401 is specifically configured to execute: for each node group, according to the order of the second nodes in the node group, splicing the text units corresponding to the second nodes in the node group to obtain the text content of the corresponding paragraph.

[0122] The above-mentioned text generation device parses the web page text and generates a web page structure diagram, which includes a first node and a second node with a hierarchical relationship. The first node corresponds to the web page tag in the web page text, the web page tag indicates the category to which the text unit in the web page text belongs, and the second node corresponds to the text unit in the web page text; according to the web page tag corresponding to the first node and the hierarchical relationship between the first node and the second node, multiple node groups are determined, each node group includes at least one second node, and the text units corresponding to the second nodes in each node group belong to the same paragraph. For each node group, the text content of the corresponding paragraph is generated according to the text unit corresponding to the node group, and the document text corresponding to the web page text is generated according to the text content of each paragraph, so that the text units belonging to the same paragraph in the web page text are determined through the tag corresponding to the first node and the hierarchical relationship between the first node and the second node, thereby improving the accuracy of identifying text units belonging to the same paragraph, reducing the probability of misidentifying text units of different paragraphs in the web page text as text units of the same paragraph, and improving the readability of the document text.

[0123] Based on the same inventive concept, an embodiment of the present application further provides a computer device, which may be a server or a terminal device. The computer device includes a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the steps of the above-mentioned text generation method. This implements various functions, such as:

[0124] The web page text is parsed to generate a web page structure diagram, which includes a first node and a second node with a hierarchical relationship, the first node corresponds to a web page tag in the web page text, the web page tag indicates the category to which the text unit in the web page text belongs, and the second node corresponds to the text unit in the web page text; based on the web page tag corresponding to the first node and the hierarchical relationship between the first node and the second node, a plurality of node groups are determined, each node group includes at least one second node, and the text units corresponding to the second nodes in each node group belong to the same paragraph; for each node group, the text content of the corresponding paragraph is generated according to the text unit corresponding to the node group, and the document text corresponding to the web page text is generated according to the text content of each paragraph.

[0125] In an embodiment of the present application, a web page text is parsed to generate a web page structure diagram, which includes a first node and a second node with a hierarchical relationship, the first node corresponding to a web page tag in the web page text, the web page tag indicating the category to which the text unit in the web page text belongs, and the second node corresponding to the text unit in the web page text; based on the web page tag corresponding to the first node and the hierarchical relationship between the first node and the second node, a plurality of node groups are determined, each node group includes at least one second node, and the text units corresponding to the second nodes in each node group belong to the same paragraph; for each node group, the text content of the corresponding paragraph is generated based on the text unit corresponding to the node group, and the document text corresponding to the web page text is generated based on the text content of each paragraph, so that the text units belonging to the same paragraph in the web page text are determined through the tag corresponding to the first node and the hierarchical relationship between the first node and the second node, thereby improving the accuracy of identifying text units belonging to the same paragraph, reducing the probability of misidentifying text units of different paragraphs in the web page text as text units of the same paragraph, and improving the readability of the document text.

[0126] The specific implementation of the above operations can be found in the previous embodiments and will not be repeated here.

[0127] In one embodiment, the computer device is a terminal device, for example, its internal structure diagram can be as follows Figure 15 As shown. The computer device includes a processor, a memory, an input / output interface, a communication interface, a display unit and an input device. The processor, the memory and the input / output interface are connected via a system bus, and the communication interface, the display unit and the input device are connected to the system bus via the input / output interface. 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 and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner can be implemented through WIFI, a mobile cellular network, NFC (near field communication) or other technologies. When the computer program is executed by the processor, a text generation method is implemented. The display unit of the computer device is used to form a visually visible image, and can be a display screen, a projection device or a virtual reality imaging device. The display screen can be a liquid crystal display screen or an electronic ink display screen. The input device of the computer device can be a touch layer covering the display screen, or a button, trackball or touchpad set on the computer device casing, or an external keyboard, touchpad or mouse, etc.

[0128] Those skilled in the art will understand that Figure 15The 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 shown in the figure, or combine certain components, or have a different component arrangement.

[0129] Based on the same inventive concept, an embodiment of the present application also provides a computer-readable storage medium, which may include: a read-only memory (ROM), a random access memory (RAM), a disk or an optical disk, etc.

[0130] Since the computer program stored in the computer-readable storage medium can execute any text generation method provided in the embodiments of the present application, the beneficial effects that can be achieved by any text generation method provided in the embodiments of the present application can be achieved. Please refer to the previous embodiments for details and will not be repeated here.

[0131] Based on the same inventive concept, embodiments of the present application further provide a computer program product or computer program, which includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the methods provided in various optional implementations of the above embodiments.

[0132] It should be noted that the object data (including but not limited to user device information, user personal information, etc.) and conversation data involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of the relevant countries and regions. Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be implemented by instructing the relevant hardware through a computer program. 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.

[0133] Any reference to the memory, database or other media used in the various embodiments provided herein may include at least one of non-volatile and volatile memory. Non-volatile memory may include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory may include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM).

[0134] The databases involved in the various embodiments provided herein may include at least one of a relational database and a non-relational database. Non-relational databases may include, but are not limited to, distributed databases based on blockchains. The processors involved in the various embodiments provided herein may include, but are not limited to, general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic units, data processing logic units based on quantum computing, and the like.

[0135] In the above-described embodiments of the text generation device, computer-readable storage medium, computer device, and computer program product, the descriptions of each embodiment have different emphases. For portions not described in detail in a particular embodiment, reference can be made to the relevant descriptions of other embodiments. Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes and beneficial effects of the above-described text generation device, computer-readable storage medium, computer program product, computer device, and their corresponding units can be referred to in the description of the text generation method in the above embodiments, and the details will not be repeated here.

Claims

1. A text generation method, characterized in that: The method comprises: Parsing the webpage text to generate a webpage structure graph, the webpage structure graph including a first node and a second node in a hierarchical relationship, the first node corresponding to a webpage tag in the webpage text, the webpage tag indicating a category to which a text unit in the webpage text belongs, and the second node corresponding to the text unit in the webpage text; Determining, based on the webpage tag corresponding to the first node and the hierarchical relationship between the first node and the second node, a plurality of node groups, each node group including at least one second node, and text units corresponding to the second nodes in each node group belonging to the same paragraph; For each node group, the text content of the corresponding paragraph is generated according to the text unit corresponding to the node group, and the document text corresponding to the webpage text is generated according to the text content of each paragraph.

2. The text generation method according to claim 1, wherein: The determining of a plurality of node groups according to the webpage tag corresponding to the first node and the hierarchical relationship between the first node and the second node includes: generating a paragraph tag corresponding to the second node according to the webpage tag corresponding to the first node and the hierarchical relationship between the first node and the second node; The second node with the same paragraph identifier is grouped into a node group.

3. The text generation method according to claim 2, wherein: Generating a paragraph tag corresponding to the second node according to the webpage tag corresponding to the first node and the hierarchical relationship between the first node and the second node includes: For each second node, determining a first node that has a hierarchical relationship with the second node based on the hierarchical relationship between the first node and the second node; A paragraph tag corresponding to the second node is generated according to a webpage tag corresponding to a first node that has a hierarchical relationship with the second node.

4. The text generation method according to claim 3, wherein: Generating a paragraph mark corresponding to the second node according to a webpage tag corresponding to a first node having a hierarchical relationship with the second node includes: Obtaining, according to a webpage tag corresponding to a first node that has a hierarchical relationship with the second node, a first paragraph identifier or a preset second paragraph identifier of the first node that has a hierarchical relationship with the second node; A paragraph identifier corresponding to the second node is generated according to the first paragraph identifier or the preset second paragraph identifier.

5. The text generation method according to claim 4, wherein: The acquiring, based on the webpage tag corresponding to the first node that has a hierarchical relationship with the second node, a first paragraph identifier or a preset second paragraph identifier of the first node that has a hierarchical relationship with the second node, includes: If the webpage tag corresponding to the first node in a hierarchical relationship with the second node is a paragraph start tag, obtaining the first paragraph identifier of the first node in a hierarchical relationship with the second node; If the webpage tag corresponding to the first node in a hierarchical relationship with the second node is not the paragraph start tag, a preset second paragraph marker is obtained.

6. The text generation method according to claim 3, wherein: The second node with the same paragraph identifier is formed into a node group, including: Arrange the second nodes with the same paragraph identifier based on the positions of the second nodes in the web page structure diagram to form a node group; For each node group, generating text content of a corresponding paragraph according to text units corresponding to the node group includes: For each node group, the text units corresponding to the second nodes in the node group are spliced ​​according to the order of the second nodes in the node group to obtain the text content of the corresponding paragraph.

7. A text generation device, characterized in that: The device comprises: a generating module, configured to parse the webpage text and generate a webpage structure diagram, wherein the webpage structure diagram includes a first node and a second node in a hierarchical relationship, wherein the first node corresponds to a webpage tag in the webpage text, the webpage tag indicating a category to which a text unit in the webpage text belongs, and the second node corresponds to a text unit in the webpage text; a determination module, configured to determine, based on the webpage tag corresponding to the first node and the hierarchical relationship between the first node and the second node, a plurality of node groups, each node group including at least one second node, and text units corresponding to the second nodes in each node group belonging to the same paragraph; The generating module is further configured to generate, for each node group, text content of a corresponding paragraph according to the text units corresponding to the node group, and generate document text corresponding to the webpage text according to the text content of each paragraph.

8. A computer device, characterized in that: The method comprises a processor and a memory, wherein the memory stores a plurality of instructions; the processor loads instructions from the memory to execute the steps of the text generation method according to any one of claims 1 to 6.

9. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a plurality of instructions, and the instructions are suitable for being loaded by a processor to execute the steps of the text generation method according to any one of claims 1 to 6.

10. A computer program product, characterized in that The computer program product comprises a computer program or instructions, and the computer program or the instructions are used by a processor to execute the steps of the text generation method according to any one of claims 1 to 6.