Text segmentation method and device

By generating a one-dimensional array and mapping objects and dividing the text into blocks according to semantic relationships, the problem of unreasonable numbering of titles and text paragraphs in the existing technology is solved, and the user experience is improved.

CN115470777BActive Publication Date: 2025-09-16BEIJING WODONG TIANJUN INFORMATION TECH CO LTD +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211123800.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-09-15
Publication Date
2025-09-16
Estimated Expiration
2042-09-15

AI Technical Summary

Technical Problem

In the prior art, when rich text editors number paragraphs, they are unable to effectively distinguish the semantic relationship between titles and body paragraphs, which results in users having to manually reset the numbers, resulting in a poor user experience.

Method used

A target one-dimensional array is generated by extracting the element information of the text to be segmented, and its first element is determined as the target element. The segmentation operation is performed, including storing the elements into a preset one-dimensional array, queue and mapping object, and segmenting and renumbering them according to semantic relationships.

Benefits of technology

It implements semantic-based text segmentation, improves the rationality and effectiveness of numbering, improves user experience, and avoids the unreasonable numbering problem caused by relying solely on indentation levels.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115470777B_ABST
    Figure CN115470777B_ABST
Patent Text Reader

Abstract

This application discloses a text segmentation method and apparatus, relating to the field of text processing technology. A specific implementation of this method includes extracting element information from each paragraph in the text to be segmented, generating a target one-dimensional array; identifying the first element in the target one-dimensional array as the target element, and performing a target operation. This implementation implements semantically based segmentation of selected text, improves the rationality and effectiveness of numbering, and enhances the user experience.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of collaborative office technology, specifically to the field of text processing technology, and in particular to a text segmentation method and device. Background Art

[0002] With the continuous development of the Internet, the requirements for collaborative office software are getting higher and higher. In the existing rich text editor, you can set the list style to number the paragraphs to list the content more clearly. By default, the selected paragraphs are numbered from top to bottom. Summary of the Invention

[0003] Embodiments of the present application provide a text segmentation method, apparatus, device, and storage medium.

[0004] According to the first aspect, an embodiment of the present application provides a text segmentation method, which includes: extracting element information of each paragraph in the text to be segmented, generating a target one-dimensional array; determining the first element in the target one-dimensional array as the target element, and performing the target operation.

[0005] According to the second aspect, an embodiment of the present application provides a text segmentation device, which includes: an extraction module, configured to extract element information of each paragraph in the text to be segmented and generate a target one-dimensional array; a segmentation module, configured to determine the first element in the target one-dimensional array as the target element and perform the target operation.

[0006] According to the third aspect, an embodiment of the present application provides an electronic device, which includes one or more processors; a storage device on which one or more programs are stored, and when the one or more programs are executed by the one or more processors, the one or more processors implement the text segmentation method of any embodiment of the first aspect.

[0007] According to a fourth aspect, an embodiment of the present application provides a computer-readable medium having a computer program stored thereon, which, when executed by a processor, implements the text segmentation method of any embodiment of the first aspect.

[0008] This application generates a target one-dimensional array by extracting element information of each paragraph in the text to be segmented; determines the first element in the target one-dimensional array as the target element, performs the target operation, and realizes the semantic-based segmentation operation of the selected text, overcoming the problem of poor user experience of simply relying on the indentation level for numbering in the existing technology, improving the rationality and effectiveness of the numbering, and improving the user experience.

[0009] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0010] Figure 1 is an exemplary system architecture diagram to which the present application may be applied;

[0011] Figure 2a is a flowchart of an embodiment of a text segmentation method according to the present application;

[0012] Figure 2b It is a schematic diagram of an application scenario according to the numbering method in the prior art;

[0013] Figure 3 is a flowchart of an embodiment of a text segmentation method according to the present application;

[0014] Figure 4 is a flowchart of another embodiment of the text segmentation method according to the present application;

[0015] Figure 5 is a schematic diagram of an application scenario of the text segmentation method according to the present application;

[0016] Figure 6 is a flowchart of another embodiment of the text segmentation method according to the present application;

[0017] Figure 7 is a schematic diagram of an embodiment of a text segmentation device according to the present application;

[0018] Figure 8 It is a structural diagram of a computer system suitable for implementing a server in an embodiment of the present application. DETAILED DESCRIPTION

[0019] The following description of exemplary embodiments of the present application is made in conjunction with the accompanying drawings, including various details of the embodiments of the present application to facilitate understanding. These details should be considered as merely exemplary. Therefore, those skilled in the art will recognize that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present application. Similarly, for the sake of clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description.

[0020] It should be noted that, in the absence of conflict, the embodiments and features of the embodiments in this application can be combined with each other. The present application will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.

[0021] Figure 1 An exemplary system architecture 100 is shown to which embodiments of the text chunking method of the present application may be applied.

[0022] like Figure 1As shown, system architecture 100 may include terminal devices 101, 102, 103, a network 104, and a server 105. Network 104 is a medium for providing communication links between terminal devices 101, 102, 103 and server 105. Network 104 may include various connection types, such as wired or wireless communication links or fiber optic cables.

[0023] The terminal devices 101 , 102 , 103 interact with the server 105 via the network 104 to receive or send messages, etc. Various communication client applications, such as text processing applications and communication applications, may be installed on the terminal devices 101 , 102 , 103 .

[0024] Terminal devices 101, 102, 103 can be hardware or software. When terminal devices 101, 102, 103 are hardware, they can be various electronic devices with display screens, including but not limited to mobile phones and laptop computers. When terminal devices 101, 102, 103 are software, they can be installed in the electronic devices listed above. They can be implemented as multiple software or software modules (for example, to provide text segmentation services), or as a single software or software module. No specific limitations are made here.

[0025] The server 105 may be a server that provides various services, for example, extracting element information of each paragraph in the text to be segmented, generating a target one-dimensional array, determining the first element in the target one-dimensional array as the target element, and performing a target operation.

[0026] It should be noted that the server 105 can be hardware or software. When the server 105 is hardware, it can be implemented as a distributed server cluster consisting of multiple servers, or it can be implemented as a single server. When the server is software, it can be implemented as multiple software or software modules (for example, for providing text segmentation services), or it can be implemented as a single software or software module. No specific limitations are made here.

[0027] It should be noted that the text segmentation method provided in the embodiments of the present disclosure can be executed by the server 105, or by the terminal devices 101, 102, 103, or by the server 105 and the terminal devices 101, 102, 103 in cooperation with each other. Accordingly, the various parts (e.g., various units, sub-units, modules, sub-modules) included in the text segmentation device can be all set in the server 105, or all set in the terminal devices 101, 102, 103, or can be set separately in the server 105 and the terminal devices 101, 102, 103.

[0028] It should be understood that Figure 1The number of terminal devices, networks and servers in the embodiment is merely illustrative. Any number of terminal devices, networks and servers may be provided as required.

[0029] Figure 2a A flowchart 200 of an embodiment of a text segmentation method applicable to the present application is shown. In this embodiment, the text segmentation method includes the following steps:

[0030] Step 201: extract element information of each paragraph in the text to be segmented and generate a target one-dimensional array.

[0031] In this embodiment, since the current editor can set both ordinary paragraphs and title paragraphs as ordered lists, but does not make semantic distinctions, for all lines set as lists, the numbering range is distinguished only by the indentation level. For title paragraphs and ordinary paragraphs with the same indentation, they are generally numbered sequentially from top to bottom, as shown in the following example. Figure 2b shown.

[0032] However, for an article, the title and its paragraphs are inclusive. The ordered lists under each major heading have no dependencies on the lists under other headings, let alone the title itself, and should not be numbered directly. Therefore, users have to manually renumber the items each time, which is a poor interaction and user experience.

[0033] To solve the above problems, the execution entity can monitor the user's selection operation on the original text in real time or periodically. In response to the user's selection operation, the selected text, that is, the text to be segmented, is obtained, the element information of each paragraph in the text to be segmented is extracted, and the target one-dimensional array is generated according to the paragraph order of each element information.

[0034] The element information may include: paragraph category and category parameters.

[0035] Here, the selection operation is used to indicate that the starting position and the ending position of the selected text are determined in the original text. Here, the starting position can be at the beginning of a paragraph or in the middle of a paragraph, and the ending position can be at the end of a paragraph or in the middle of a paragraph, and this application does not limit this.

[0036] Specifically, the execution entity can first obtain the paragraph where the selected text starts and record this paragraph as the starting point. Then, it can obtain the paragraph where the selected text ends and record this paragraph's ending point. The data between the starting and ending points can be intercepted and converted into list paragraphs (i.e., body paragraphs) and title paragraphs. The element information of each paragraph can be extracted to generate the target one-dimensional array.

[0037] The paragraph categories include: body paragraph, title paragraph, quote paragraph, etc. The category parameter corresponds to the paragraph category. For example, if the paragraph category is body paragraph, the category parameter is the indent value; if the paragraph category is title paragraph, the category parameter is the title level.

[0038] Step 202: Determine the first element in the target one-dimensional array as the target element and perform the target operation.

[0039] In this embodiment, the execution entity may determine the first element in the one-dimensional array, that is, the element corresponding to the first paragraph, as the target element, and perform the target operation.

[0040] The target operations include:

[0041] 1. Perform block operation.

[0042] Block operations include:

[0043] (1) In response to determining that the preset one-dimensional array corresponding to the paragraph category of the target element is empty, the target element is stored in the preset one-dimensional array.

[0044] Here, if the paragraph categories of the elements are different, the corresponding preset one-dimensional arrays are different.

[0045] Specifically, the paragraph category of the target element is a title paragraph, and the preset one-dimensional array corresponding to the paragraph category of the target element is a first one-dimensional array; the paragraph category of the target element is a body paragraph, and the preset one-dimensional array corresponding to the paragraph category of the target element is a second one-dimensional array; the paragraph category of the target element is a reference paragraph, and the preset one-dimensional array corresponding to the paragraph category of the target element is a third one-dimensional array.

[0046] The first one-dimensional array, the second one-dimensional array, and the third one-dimensional array are different.

[0047] (2) In response to determining that the preset one-dimensional array corresponding to the paragraph category of the target element is not empty, performing a preset operation according to a comparison result of the category parameter of the target element with the category parameters of the elements in the preset one-dimensional array.

[0048] The preset operations include:

[0049] In response to determining that the comparison result is greater than, the preset one-dimensional array is pushed (last in first out) into the preset queue corresponding to the paragraph category of the target element, and the target element is stored in the reset preset one-dimensional array.

[0050] 2. In response to the block operation being completed and the next element existing in the target one-dimensional array, the next element is determined as the target element, and the target operation is continued.

[0051] Here, the execution subject can determine whether the block operation is completed in real time or periodically. If the block operation is completed and there is a next element in the target one-dimensional array, the next element is determined as the target element and the target operation is continued.

[0052] 3. In response to determining that the block operation is completed and there is no next element in the target one-dimensional array, the preset one-dimensional array corresponding to the paragraph category of the target element and each array in the preset queue are stored as independent blocks in the preset mapping object corresponding to the paragraph category of the target element to obtain the target mapping object.

[0053] Here, the execution entity can determine in real time or periodically whether the block operation is completed. If the block operation is completed and the next element does not exist in the target one-dimensional array, the elements in the preset one-dimensional array and the preset queue corresponding to the paragraph category of the target element are added to the corresponding preset mapping object according to the category parameters corresponding to each element to obtain the target mapping object.

[0054] It should be noted that, since the target one-dimensional array may include elements corresponding to different paragraph categories, the target mapping object may include one mapping object or multiple mapping objects.

[0055] Specifically, the target one-dimensional array includes 4 elements, 2 elements have the paragraph category of title paragraphs, and 2 elements have the paragraph category of body paragraphs. Different paragraph categories correspond to different mapping objects, so the target mapping object includes two preset mapping objects.

[0056] Furthermore, it should be noted that the execution entity must perform initialization operations before executing the block operation. These initialization operations may include: Initializing a preset one-dimensional array, such as currArr, to store target elements, ensuring that the category parameters of each element in the array are equal; Initializing a preset queue, such as queue, to serve as a stack for temporary array storage; and Initializing a mapping object, such as a map object, to store independent blocks corresponding to different category parameters.

[0057] It should be noted that the preset one-dimensional array is stored in the preset mapping object as an independent block, and each time the independent block is stored in the preset mapping object, the elements in the independent block will be renumbered.

[0058] In some optional embodiments, the preset operation further includes: in response to determining that the category parameter of the target element is equal to the category parameter of an element in a preset one-dimensional array, storing the target element in a preset one-dimensional array.

[0059] In this implementation, the execution subject can judge whether the preset one-dimensional array is empty. If it is determined that the preset one-dimensional array is not empty, the preset operation is performed based on the comparison result of the category parameters of the target element and the category parameters of the elements in the preset one-dimensional array; the preset operation includes: if it is determined that the comparison result is equal, that is, the category parameters of the target element are equal to the category parameters of the elements in the preset one-dimensional array, then the target element is directly stored in the preset one-dimensional array.

[0060] This implementation implements a processing operation on the target element whose comparison result is equal by storing the target element into a preset one-dimensional array in response to determining that the comparison result is equal.

[0061] In some optional embodiments, the preset operation also includes: in response to determining that the category parameter of the target element is less than the category parameter of the element in the preset one-dimensional array, and there is no array in the preset queue corresponding to the paragraph category of the target element, storing the preset one-dimensional array as an independent block in the preset mapping object corresponding to the paragraph category of the target element; in response to determining that the category parameter of the target element is less than the category parameter of the element in the preset one-dimensional array, and there is an array in the preset queue corresponding to the paragraph category of the target element, storing the preset one-dimensional array as an independent block in the preset mapping object corresponding to the paragraph category of the target element, determining the top array of the stack as the initial array, and performing a pop operation.

[0062] In this implementation, the execution entity can judge whether the preset one-dimensional array is empty. If it is determined that the preset one-dimensional array is not empty, the preset operation is performed according to the comparison result of the category parameter of the target element and the category parameter of the element in the preset one-dimensional array; the preset operation includes: in response to determining that the comparison result is less than, and there is no array in the preset queue corresponding to the paragraph category of the target element, the preset one-dimensional array is stored as an independent block in the preset mapping object corresponding to the paragraph category of the target element.

[0063] Here, the execution entity stores the elements in the preset one-dimensional array as an independent block into the preset mapping object corresponding to the paragraph category of the target element by constructing a key-value pair based on the elements in the preset one-dimensional array and the corresponding category parameters, and storing the key-value pair as an independent block into the preset mapping object.

[0064] Furthermore, the execution body resets the preset one-dimensional array and stores the target element into the reset preset one-dimensional array.

[0065] If the comparison result is determined to be less than, and there is an array in the preset queue corresponding to the paragraph category of the target element, the preset one-dimensional array is stored as an independent block in the preset mapping object corresponding to the paragraph category of the target element, the top array of the stack is determined as the initial array, and the pop operation is performed.

[0066] Among them, the pop operation includes: in response to determining that the category parameter of the element in the initial array is greater than the category parameter of the target element, popping the initial array from the stack and storing it in the preset mapping object as an independent block, and judging whether there is a next array in the preset queue; in response to determining that the category parameter of the element in the initial array is equal to the category parameter of the target element, popping the initial array and assigning a preset one-dimensional array, and determining the preset one-dimensional array after assignment as a new preset one-dimensional array, and judging whether there is a next array in the preset queue; in response to determining that there is a next array, determining the next element as the initial array, and continuing to perform the pop operation.

[0067] In response to determining that the category parameter of the element in the initial array is less than the category parameter of the target element or there is no next array, the target element is stored in a preset one-dimensional array corresponding to the paragraph category of the target element.

[0068] Here, in the pop operation, the array popped from the stack and stored in the preset mapping object is treated as an independent block, and the elements in the independent block are renumbered.

[0069] This implementation method stores the preset one-dimensional array as an independent block in the preset mapping object corresponding to the paragraph category of the target element in response to determining that the comparison result is less than and the array does not exist in the preset queue corresponding to the paragraph category of the target element, and stores the target element into the reset preset one-dimensional array; in response to determining that the comparison result is less than and the array exists in the preset queue, the top array of the stack is determined as the initial array, and a pop operation is performed, thereby achieving the blocking of the array in the preset queue when the comparison result is less than and the array does not exist in the preset queue and when the array exists.

[0070] In some optional methods, the blocking operation also includes: in response to determining that the paragraph category of the target element is a title paragraph, and the preset one-dimensional array corresponding to the body paragraph is not empty, pushing the preset one-dimensional array corresponding to the body paragraph into the preset queue corresponding to the body paragraph to obtain the pushed preset queue; storing each array in the pushed preset queue as an independent block according to the category parameter into the preset mapping object corresponding to the body paragraph.

[0071] In this implementation, the execution entity responds to determining that the paragraph category of the target element is a title paragraph and the preset one-dimensional array corresponding to the body paragraph is not empty, and pushes the preset one-dimensional array corresponding to the body paragraph, such as the second one-dimensional array, into the corresponding preset queue, such as the second preset queue, to obtain the pushed preset queue, and stores each array in the pushed preset queue as an independent block according to the category parameter into the preset mapping object corresponding to the body paragraph.

[0072] This implementation method, in response to determining that the paragraph category of the target element is a title paragraph and the preset one-dimensional array corresponding to the body paragraph is not empty, pushes the preset one-dimensional array corresponding to the body paragraph into the preset queue corresponding to the body paragraph to obtain the stacked preset queue; and stores each array in the stacked preset queue as an independent block according to the category parameter into the preset mapping object corresponding to the body paragraph, effectively avoiding the continuous numbering of body paragraphs under different titles, and further improving the effectiveness of text segmentation.

[0073] In some optional embodiments, the method further includes: generating target block text based on the target mapping object.

[0074] In this implementation method, after obtaining the target mapping object, the execution entity can directly generate the target block text based on the target mapping object, or it can further renumber the elements in each independent block according to the attributes set for the first element in each independent block in the target mapping object, and generate the target block text based on the renumbered elements, that is, the text renumbered based on the dependency relationship between paragraphs.

[0075] This implementation method generates target block texts based on the target mapping object, thereby realizing the generation of corresponding target block texts from the target mapping object.

[0076] In some optional embodiments, the paragraph category is a heading paragraph, and the category parameter is a heading level.

[0077] In this implementation, the execution entity can determine the paragraph category of the target element. If the paragraph category of the target element is a title paragraph and the category parameter is a title level, the operation is performed in the preset one-dimensional array, preset queue and preset mapping object corresponding to the title paragraph.

[0078] Specifically, if Figure 3 As shown, the target one-dimensional array includes six elements. The category parameter of the first element is the first-level title, the category parameter of the second element is the second-level title, the category parameter of the third element is the second-level title, the category parameter of the fourth element is the third-level title, the category parameter of the fifth element is the second-level title, and the category parameter of the sixth element is the first-level title.

[0079] The execution subject may first determine the first element in the target one-dimensional array as the target element and perform a target operation. The target operation includes: performing a block operation, which includes: in response to determining that the paragraph category of the target element is a title paragraph and the preset one-dimensional array corresponding to the title paragraph, such as the first one-dimensional array, is empty, storing the target element in the first one-dimensional array; in response to the completion of the block operation, determining the second element as the target element and continuing to perform the target operation.

[0080] In response to determining that the paragraph category of the target element is a title paragraph, and the first one-dimensional array corresponding to the title paragraph is not empty, the category parameter of the target element, i.e., level two, is compared with the category parameter of the element in the first one-dimensional array, i.e., level one. Since level two is greater than level one, the first one-dimensional array is pushed into the first queue corresponding to the title paragraph, and the first one-dimensional array is reset. The target element is stored in the reset first one-dimensional array to obtain a new preset one-dimensional array, i.e., the new first one-dimensional array. In response to the end of the blocking operation, the third element is determined as the target element, and the target operation is continued.

[0081] In response to determining that the paragraph category of the target element is a title paragraph, and the first one-dimensional array corresponding to the title paragraph is not empty, the category parameter of the target element, i.e., level two, is compared with the category parameter of the element in the first one-dimensional array, i.e., level two. Since level two is equal to level two, the target element is directly stored in the first one-dimensional array. In response to the end of the blocking operation, the fourth element is determined as the target element, and the target operation is continued.

[0082] In response to determining that the paragraph category of the target element is a title paragraph, and the first one-dimensional array corresponding to the title paragraph is not empty, the category parameter of the target element, i.e., level three, is compared with the category parameter of the element in the first one-dimensional array, i.e., level two. Since level three is greater than level two, the first one-dimensional array is pushed into the first queue corresponding to the title paragraph (at this time, the first queue includes two arrays, i.e., an array including one level one title and an array including two level two titles, wherein the array including two level two titles is the top array of the stack), and the first one-dimensional array is reset, and the target element is stored in the reset first one-dimensional array to obtain a new preset one-dimensional array, i.e., the new first one-dimensional array. In response to the end of the blocking operation, the fifth element is determined as the target element, and the target operation is continued.

[0083] In response to determining that the paragraph category of the target element is a title paragraph and the first one-dimensional array corresponding to the title paragraph is not empty, the category parameter of the target element, i.e., level two, is compared with the category parameter of the element in the first one-dimensional array, i.e., level three. Since level two is smaller than level three, the current first one-dimensional array (including a level three title) is stored as an independent block in the first mapping object corresponding to the paragraph category of the target element. Furthermore, since there is an array in the first queue, a pop operation is performed on the top array as the initial array. In response to determining that the category parameter of the element in the initial array is equal to the category parameter of the target element (both are level two), the initial array is popped and the first one-dimensional array is assigned, and it is determined whether there is a next array in the preset queue. In response to determining that there is a next array (including an array of level one titles), the next element is determined as the initial array, and the pop operation is continued.

[0084] In response to determining that the category parameter (level 1) of the element in the initial array is less than the category parameter (level 2) of the target element, the target element is stored in a preset one-dimensional array corresponding to the paragraph category of the target element, that is, the target element is stored in the current first one-dimensional array, thereby obtaining a new first one-dimensional array (a first one-dimensional array including the three level 2 headings). In response to the block operation being completed, the sixth element is determined as the target element, and the target operation is continued.

[0085] In response to determining that the paragraph category of the target element is a title paragraph, and the first one-dimensional array corresponding to the title paragraph is not empty, the category parameter of the target element, i.e., level one, is compared with the category parameter of the element in the first one-dimensional array, i.e., level two. Since level one is smaller than level two, the first one-dimensional array (including three level two titles) is stored as an independent block in the first mapping object according to the corresponding category parameter (level two). Since the first queue has an array, a pop operation is performed on the top array of the stack as the initial array. In response to determining that the category parameter (level one) of the element in the initial array is equal to the category parameter (level one) of the target element, the initial array is popped and assigned to the first one-dimensional array, and it is determined whether there is a next array in the preset queue; in response to the absence of the next array, the target element is stored in the first one-dimensional array to obtain a new first one-dimensional array (including two level one titles).

[0086] In response to the block operation being completed and the absence of a next element (because no elements exist in the first queue), the new first one-dimensional number is stored as an independent block in the first mapping object according to the corresponding category parameter, thereby obtaining a target mapping object corresponding to the paragraph category. Furthermore, based on the target mapping object, a target block text is generated.

[0087] This implementation method realizes the segmentation of the title paragraph by performing operations in the preset one-dimensional array, preset queue and preset mapping object corresponding to the title paragraph when the paragraph category of the target element is the title paragraph and the category parameter is the title level.

[0088] In some optional embodiments, the paragraph category is a body paragraph, and the category parameter is an indentation value.

[0089] In this implementation, the execution entity can determine the paragraph category of the target element. If the paragraph category of the target element is a body paragraph, and the category parameter is an indentation value, that is, a paragraph indentation value, the operation is performed in the preset one-dimensional array, preset queue, and preset mapping object corresponding to the body paragraph.

[0090] Specifically, if Figure 4 As shown, the target one-dimensional array includes four elements, the category parameter of the first element is indent value 1, the category parameter of the second element is indent value 3, the category parameter of the third element is indent value 2, and the category parameter of the fourth element is indent value 1.

[0091] The execution subject may first determine the first element in the target one-dimensional array as the target element and perform a target operation. The target operation includes: performing a block operation, which includes: in response to determining that the paragraph category of the target element is a body paragraph and the preset one-dimensional array corresponding to the body paragraph, such as the second one-dimensional array, is empty, storing the target element in the second one-dimensional array; in response to the completion of the block operation, determining the second element as the target element, and continuing to perform the target operation.

[0092] In response to determining that the paragraph category of the target element is a body paragraph, and the second one-dimensional array corresponding to the body paragraph is not empty, the category parameter of the target element, i.e., the indent value 3, is compared with the category parameter of the element in the second one-dimensional array, i.e., the indent value 1. Since 3 is greater than 1, the second one-dimensional array is pushed into the second queue corresponding to the second one-dimensional array, and the second one-dimensional array is reset. The target element is stored in the reset second one-dimensional array. In response to the end of the blocking operation, the third element is determined as the target element, and the target operation is continued.

[0093] In response to determining that the paragraph category of the target element is a text paragraph and that the second one-dimensional array corresponding to the text paragraph is not empty, the category parameter of the target element, i.e., the indentation value 2, is compared with the category parameter of the element in the second one-dimensional array, i.e., the indentation value 3. Since 2 is less than 3, the second one-dimensional array is divided into independent blocks according to the corresponding category parameters and stored in the second mapping object corresponding to the second queue. At the same time, since the category parameter of the element in the array in the second queue is less than the category parameter of the target element, there is no need to pop the stack. Further, the second one-dimensional array is reset, and the target element is stored in the reset second one-dimensional array. In response to the end of the block operation, the fourth element is determined as the target element, and the target operation is continued.

[0094] In response to determining that the paragraph category of the target element is a text paragraph, and the second one-dimensional array corresponding to the text paragraph is not empty, the category parameter of the target element, i.e., the indent value 1, is compared with the category parameter of the element in the second one-dimensional array, i.e., the indent value 2. Since 1 is less than 2, the second one-dimensional array is stored as an independent block according to the corresponding category parameter in the second mapping object corresponding to the second queue. At the same time, since the category parameter (indent value 1) of the element of the array in the second queue is equal to the category parameter of the target element, the array in the first queue is popped out, the second one-dimensional array is assigned to obtain a new second one-dimensional array, and further, the target element is stored in the new second one-dimensional array. In response to the end of the block operation and the absence of the next element, (since there is no element in the first queue) the second one-dimensional array is stored as an independent block in the second mapping object according to the corresponding category parameter to obtain the target mapping object corresponding to the paragraph category. Further, based on the target mapping object, the target block text is generated.

[0095] This implementation method realizes the segmentation of the body paragraph by performing operations in the preset one-dimensional array, preset queue and preset mapping object corresponding to the body paragraph when the paragraph category of the target element is the body paragraph and the category parameter is the indentation value.

[0096] Continue to see Figure 5 , Figure 5 It is a schematic diagram of an application scenario of the text segmentation method according to this embodiment.

[0097] exist Figure 5 In the application scenario, the execution subject 501 can extract the element information of each paragraph in the text to be segmented, and generate a target one-dimensional array 502. The element information includes: paragraph category and category parameters. The first element in the target one-dimensional array 502 is determined as the target element, and the target operation is performed. The target operation includes: performing a segmentation operation 503. The segmentation operation includes: judging whether the preset one-dimensional array corresponding to the paragraph category of the target element is empty 504. In response to determining that the preset one-dimensional array corresponding to the paragraph category of the target element is empty, the target element is stored in the preset one-dimensional array 505; in response to determining that the preset one-dimensional array corresponding to the paragraph category of the target element is not empty, according to the comparison result of the category parameter of the target element and the category parameter of the element in the preset one-dimensional array, a preset operation 506 is performed; the preset operation includes: in response to determining If the comparison result is greater than, the preset one-dimensional array is pushed into the preset queue corresponding to the paragraph category of the target element, and the target element is stored in the reset preset one-dimensional array; in response to determining that the block operation is completed and the next element exists in the target one-dimensional array, the next element is determined as the target element, and the target operation is continued; in response to determining that the block operation is completed 507 and the next element does not exist in the target one-dimensional array, the preset one-dimensional array corresponding to the paragraph category of the target element and each array in the preset queue are respectively stored as independent blocks in the preset mapping object corresponding to the paragraph category of the target element to obtain the target mapping object 508.

[0098] The text segmentation method disclosed in the present invention generates a target one-dimensional array by extracting element information of each paragraph in the text to be segmented; determines the first element in the target one-dimensional array as the target element, performs the target operation, and realizes the semantic-based segmentation operation of the selected text. It overcomes the problem of poor user experience of simply relying on indentation level for numbering in the prior art, improves the rationality and effectiveness of numbering, and enhances the user experience.

[0099] Further references Figure 6 , which shows a process 600 of another embodiment of the text segmentation method shown in Figure 2. In this embodiment, the process 600 of the text segmentation method may include the following steps:

[0100] Step 601: extract element information of each paragraph in the text to be segmented and generate a target one-dimensional array.

[0101] In this embodiment, the implementation details and technical effects of step 601 can be found in the description of step 601 and will not be repeated here.

[0102] Step 602: Determine the first element in the target one-dimensional array as the target element and perform the target operation.

[0103] In this embodiment, the implementation details and technical effects of step 602 can be found in the description of step 202 and will not be repeated here.

[0104] Step 603: For each independent block in the target mapping object, in response to detecting a number update operation for a specified element in the independent block, update the number of the specified element.

[0105] In this embodiment, for each independent block in the target mapping object, the execution entity can monitor the user's number update operation on the specified element in the independent block in real time or periodically, and in response to detecting the number update operation on the specified element, update the number of the specified element to obtain the updated number of the specified element.

[0106] The numbering update operation for the specified element may include setting the attribute of the specified element to a continue numbering attribute, a renumbering attribute, an empty attribute, etc.

[0107] Specifically, if the numbering update operation is to set the attribute of the specified element to be an empty attribute, the element is numbered according to the original number in the independent block.

[0108] Here, the specified element can be any element in an independent block, and this application does not limit this.

[0109] In some optional embodiments, updating the number of the specified element includes: in response to determining that the specified element is the first element in the corresponding independent block, setting the number of the specified element to the sum of the number of the last element of the previous independent block and a preset step size.

[0110] In this implementation, the numbering update operation is to set the attribute of the specified element to the continue numbering attribute, and the execution subject determines whether the specified element is the first element in its corresponding independent block. If it is the first element, the number of the specified element is set to the sum of the number of the last element of the previous independent block and the preset step size.

[0111] Among them, the preset step size can be set according to experience and actual needs, for example, 1, 2, 3, etc., and this application does not limit this.

[0112] This implementation method effectively improves the flexibility of numbering setting by setting the number of the specified element to the sum of the number of the last element of the previous independent block and the preset step size when the numbering update operation sets the attribute of the specified element to the continue numbering attribute.

[0113] In some optional manners, updating the number of the designated element includes setting the number of the designated element to an initial number.

[0114] In this implementation, the number update operation is to set the attribute of the specified element to a renumbering attribute, and the execution subject can set the number of the specified element to the initial number.

[0115] The initial number can be any number representing the beginning, for example, 1, a, A, (1), etc., and this application does not limit this.

[0116] This implementation further improves the flexibility of numbering setting by setting the attribute of the specified element to the renumbering attribute in the numbering update operation and setting the number of the specified element to the initial number.

[0117] Step 604 : In response to determining that there are remaining elements in the independent block that are sorted after the designated element, the numbers of the remaining elements are updated based on the updated numbers of the designated element to obtain an updated target mapping object.

[0118] In this embodiment, the execution entity may determine whether there are any remaining elements in the independent block that are sorted after the specified element. If not, the execution entity may directly generate the target block text based on the updated target mapping object. If so, the execution entity may update the numbers of the remaining elements based on the updated number of the specified element to obtain the updated target mapping object.

[0119] Specifically, the execution entity can further determine whether there is the next element of the specified element in the independent block. If it is determined that there is no next element of the specified element in the independent block, the execution entity can directly generate the target block text based on the updated target mapping object.

[0120] If the next element of the specified element exists, the next element of the specified element is determined as the target element, and then the numbering operation is performed.

[0121] The numbering operation includes: determining the sum of the number of the previous element and the preset step size as the number of the target element to obtain a new number of the target element; in response to the existence of the next element of the target element in the independent block (i.e., the next element sorted after the target element), determining the next element of the target element as the target element and continuing the numbering operation. In response to the absence of the next element of the target element, generating the target block text based on the target mapping object after the numbering operation, i.e., the updated target mapping object.

[0122] Step 605: Generate target block text based on the updated target mapping object

[0123] In this embodiment, the execution entity determines whether the next element of the target element exists in the independent block. If the next element of the target element does not exist, the independent blocks in the updated target mapping object can be mapped and rendered according to the set list style, for example, English letters a / b / c / d, Arabic numerals 1 / 2 / 3 / 4, Roman numerals, etc., to generate the target block text.

[0124] from Figure 6 As can be seen, compared with the embodiment corresponding to Figure 2, the process 600 of the text segmentation method in this embodiment reflects that for each independent block in the target mapping object, in response to detecting a number update operation for a specified element in the independent block, the number of the specified element is updated to obtain an updated number of the specified element; in response to determining that there are remaining elements in the independent block that are sorted after the specified element, based on the updated number of the specified element, the numbers of the remaining elements are updated to obtain an updated target mapping object; based on the updated target mapping object, the target block text is generated, which effectively improves the flexibility of the numbering and further enhances the user's interactive experience.

[0125] Further references Figure 7 As an implementation of the methods shown in the above figures, the present application provides an embodiment of a text segmentation device, which corresponds to the method embodiment shown in Figure 2 and can be specifically applied to various electronic devices.

[0126] like Figure 7 As shown, the text segmentation device 700 of this embodiment includes: an extraction module 701 and a segmentation module 702 .

[0127] The extraction module 701 may be configured to extract element information of each paragraph in the text to be segmented and generate a target one-dimensional array.

[0128] The blocking module 702 may be configured to determine the first element in the target one-dimensional array as the target element and perform the target operation.

[0129] In some optional aspects of this embodiment, the device further includes a generation module, which can be configured to generate target block text based on the target mapping object.

[0130] In some optional embodiments of this embodiment, the generation module is further configured to: for each independent block in the target mapping object, in response to detecting a number update operation for a specified element in the independent block, update the number of the specified element to obtain an updated number of the specified element; in response to determining that there are remaining elements in the independent block that are sorted after the specified element, update the numbers of the remaining elements based on the updated number of the specified element to obtain an updated target mapping object; and generate the target block text based on the updated target mapping object.

[0131] In some optional methods of this embodiment, the number of the specified element is updated, including: in response to determining that the specified element is the first element in the corresponding independent block, the number of the specified element is set to the sum of the number of the last element of the previous independent block and a preset step size.

[0132] In some optional manners of this embodiment, updating the number of the designated element includes: setting the number of the designated element to an initial number.

[0133] In some optional aspects of this embodiment, the preset operation further includes: in response to determining that the category parameter of the target element is equal to the category parameter of the element in the preset one-dimensional array, storing the target element in the preset one-dimensional array.

[0134] In some optional embodiments of this embodiment, the preset operation also includes: in response to determining that the category parameter of the target element is less than the category parameter of the element in the preset one-dimensional array, and there is no array in the preset queue corresponding to the paragraph category of the target element, storing the preset one-dimensional array as an independent block in the preset mapping object corresponding to the paragraph category of the target element, and storing the target element in the reset preset one-dimensional array; in response to determining that the comparison result is less than, and there is an array in the preset queue corresponding to the paragraph category of the target element, storing the preset one-dimensional array as an independent block in the preset mapping object corresponding to the paragraph category of the target element, determining the top array of the stack as the initial array, and performing a pop operation.

[0135] In some optional methods of this embodiment, the block operation further includes: in response to determining that the paragraph category of the target element is a title paragraph, and the preset one-dimensional array corresponding to the body paragraph is not empty, pushing the preset one-dimensional array corresponding to the body paragraph into the preset queue corresponding to the body paragraph to obtain the pushed preset queue; storing each array in the pushed preset queue as an independent block in the preset mapping object corresponding to the body paragraph according to the category parameter

[0136] According to an embodiment of the present application, the present application also provides an electronic device and a readable storage medium.

[0137] like Figure 8, which is a block diagram of an electronic device according to the text segmentation method of an embodiment of the present application.

[0138] 800 is a block diagram of an electronic device according to a text segmentation method according to an embodiment of the present application. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present application described and / or required herein.

[0139] like Figure 8 As shown, the electronic device includes: one or more processors 801, a memory 802, and interfaces for connecting various components, including high-speed interfaces and low-speed interfaces. The various components are connected to each other using different buses and can be installed on a common mainboard or installed in other ways as needed. The processor can process instructions executed in the electronic device, including instructions stored in or on the memory to display graphical information of a GUI on an external input / output device (such as a display device coupled to the interface). In other embodiments, if necessary, multiple processors and / or multiple buses can be used together with multiple memories and multiple memories. Similarly, multiple electronic devices can be connected, and each device provides some necessary operations (for example, as a server array, a group of blade servers, or a multi-processor system). Figure 8 A processor 801 is taken as an example.

[0140] Memory 802 is the non-transitory computer-readable storage medium provided in this application. The memory stores instructions executable by at least one processor, causing the at least one processor to perform the text segmentation method provided in this application. The non-transitory computer-readable storage medium of this application stores computer instructions for causing a computer to perform the text segmentation method provided in this application.

[0141] The memory 802 is a non-transient computer-readable storage medium that can be used to store non-transient software programs, non-transient computer executable programs and modules, such as the program instructions / modules corresponding to the text segmentation method in the embodiment of the present application (for example, the attached Figure 7 The processor 801 executes the non-transient software programs, instructions and modules stored in the memory 802 to execute various functional applications and data processing of the server, that is, to implement the text segmentation method in the above method embodiment.

[0142] The memory 802 may include a program storage area and a data storage area, wherein the program storage area may store an operating system and application programs required for at least one function; the data storage area may store data created by the use of the electronic device of the text segmentation, etc. In addition, the memory 802 may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some embodiments, the memory 802 may optionally include a memory remotely arranged relative to the processor 801, and these remote memories may be connected to the electronic device of the text segmentation via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0143] The electronic device of the text segmentation method may further include: an input device 803 and an output device 804. The processor 801, the memory 802, the input device 803 and the output device 804 may be connected via a bus or other means. Figure 8 The bus connection is taken as an example.

[0144] The input device 803 can receive input digital or character information, such as an input device such as a touch screen, a keypad, a mouse, a trackpad, a touch pad, a pointer, one or more mouse buttons, a trackball, a joystick, etc. The output device 804 can include a display device, an auxiliary lighting device (e.g., an LED), and a tactile feedback device (e.g., a vibration motor). The display device can include, but is not limited to, a liquid crystal display (LCD), a light emitting diode (LED) display, and a plasma display. In some embodiments, the display device can be a touch screen.

[0145] Various implementations of the systems and techniques described herein can be realized in digital electronic circuit systems, integrated circuit systems, dedicated ASICs (application specific integrated circuits), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system that includes at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.

[0146] These computer programs (also referred to as programs, software, software applications, or code) include machine instructions for a programmable processor and can be implemented using high-level procedural and / or object-oriented programming languages, and / or assembly / machine languages. As used herein, the terms "machine-readable medium" and "computer-readable medium" refer to any computer program product, apparatus, and / or device (e.g., a magnetic disk, an optical disk, a memory, a programmable logic device (PLD)) for providing machine instructions and / or data to a programmable processor, including a machine-readable medium that receives machine instructions as a machine-readable signal. The term "machine-readable signal" refers to any signal for providing machine instructions and / or data to a programmable processor.

[0147] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).

[0148] The systems and techniques described herein can be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network (LAN), a wide area network (WAN), and the Internet.

[0149] Computer systems may include clients and servers. A client and server are generally remote from each other and typically interact through a communication network. The client and server relationship arises through computer programs running on the respective computers and having a client-server relationship to each other.

[0150] According to the technical solution of the embodiment of the present application, semantic-based block operation of the selected text is realized, the rationality and effectiveness of the numbering are improved, and the user experience is improved.

[0151] It should be understood that the various forms of the processes shown above can be used to reorder, add, or delete steps. For example, the steps described in this application can be performed in parallel, sequentially, or in a different order, as long as the desired results of the technical solutions disclosed in this application can be achieved. This is not a limitation herein.

[0152] The above specific embodiments do not constitute a limitation on the scope of protection of this application. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions may be made based on design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this application shall be included within the scope of protection of this application.

Claims

1. A text segmentation method, comprising: Extracting element information of each paragraph in the text to be segmented and generating a target one-dimensional array, wherein the element information includes paragraph category and category parameters; Determine the first element in the target one-dimensional array as the target element, and perform a target operation; the target operation includes: performing a block operation, the block operation including: in response to determining that a preset one-dimensional array corresponding to the paragraph category of the target element is empty, storing the target element in the preset one-dimensional array; in response to determining that the preset one-dimensional array corresponding to the paragraph category of the target element is not empty, performing a preset operation based on a comparison result of the category parameter of the target element with the category parameters of the elements in the preset one-dimensional array; the preset operation includes: in response to determining that the category parameter of the target element is greater than the category parameters of the elements in the preset one-dimensional array, pushing the preset one-dimensional array into a preset queue corresponding to the paragraph category of the target element, and storing the target element in a reset preset one-dimensional array; In response to determining that the blocking operation is finished and there is a next element in the target one-dimensional array, determining the next element as the target element and continuing to perform the target operation; In response to determining that the blocking operation is completed and there is no next element in the target one-dimensional array, the preset one-dimensional array corresponding to the paragraph category of the target element and each array in the preset queue are stored as independent blocks in the preset mapping object corresponding to the paragraph category of the target element to obtain the target mapping object.

2. The method according to claim 1, further comprising: Based on the target mapping object, target block text is generated.

3. The method according to claim 2, wherein: The step of generating target block text based on the target mapping object includes: For each independent block in the target mapping object, in response to detecting a number update operation for a specified element in the independent block, updating the number of the specified element to obtain an updated number of the specified element; In response to determining that there are remaining elements in the independent block that are sorted after the designated element, the numbers of the remaining elements are updated based on the updated numbers of the designated element to obtain an updated target mapping object; Based on the updated target mapping object, target block text is generated.

4. The method according to claim 3, wherein the number update operation is to set the attribute of the specified element to a continuous numbering attribute, and the updating of the number of the specified element comprises: In response to determining that the designated element is the first element in the corresponding independent block, the number of the designated element is set to the sum of the number of the last element of the previous independent block and a preset step size.

5. The method according to claim 3, wherein the number update operation is to set the attribute of the specified element to a renumbering attribute, and the updating of the number of the specified element comprises: Sets the number of the specified element to the initial number.

6. The method according to claim 1, wherein The preset operation also includes: In response to determining that the category parameter of the target element is equal to the category parameter of the element in the preset one-dimensional array, the target element is stored in the preset one-dimensional array.

7. The method according to claim 1, wherein The preset operation also includes: In response to determining that the category parameter of the target element is less than the category parameter of the elements in the preset one-dimensional array, and that an array corresponding to the paragraph category of the target element does not exist in the preset queue, storing the preset one-dimensional array as an independent block in a preset mapping object corresponding to the paragraph category of the target element, and storing the target element in the reset preset one-dimensional array; In response to determining that the category parameter of the target element is less than the category parameter of the elements in the preset one-dimensional array, and an array exists in the preset queue corresponding to the paragraph category of the target element, the preset one-dimensional array is stored as an independent block in a preset mapping object corresponding to the paragraph category of the target element, the top array of the stack is determined as the initial array, and a pop operation is performed, the pop operation comprising: In response to determining that the category parameter of the element in the initial array is greater than the category parameter of the target element, popping the initial array from the stack and storing it in a preset mapping object as an independent block, and determining whether there is a next array in the preset queue; In response to determining that the category parameter of the element in the initial array is equal to the category parameter of the target element, popping the initial array and assigning the value of the preset one-dimensional array, determining the assigned preset one-dimensional array as a new preset one-dimensional array, and determining whether there is a next array in the preset queue; In response to determining that a next array exists, determining the next element as the initial array and continuing to perform the pop operation; In response to determining that the category parameter of the element in the initial array is less than the category parameter of the target element or there is no next array, the target element is stored in a preset one-dimensional array corresponding to the paragraph category of the target element.

8. The method according to claim 1, wherein The block operation also includes: In response to determining that the paragraph category of the target element is a title paragraph and the preset one-dimensional array corresponding to the body paragraph is not empty, the preset one-dimensional array corresponding to the body paragraph is pushed into the preset queue corresponding to the body paragraph to obtain the pushed preset queue; Each array in the stacked preset queue is stored as an independent block in a preset mapping object corresponding to the text paragraph according to the category parameter.

9. A text segmentation device, comprising: An extraction module is configured to extract element information of each paragraph in the text to be segmented and generate a target one-dimensional array, wherein the element information includes paragraph category and category parameters; The block module is configured to determine the first element in the target one-dimensional array as the target element and perform a target operation, the target operation including: performing a block operation, the block operation including: in response to determining that the preset one-dimensional array corresponding to the paragraph category of the target element is empty, storing the target element in the preset one-dimensional array; in response to determining that the preset one-dimensional array corresponding to the paragraph category of the target element is not empty, performing a preset operation based on the comparison result of the category parameter of the target element and the category parameter of the elements in the preset one-dimensional array; the preset operation including: in response to determining that the category parameter of the target element is greater than the category parameter of the elements in the preset one-dimensional array Category parameter, the preset one-dimensional array is pushed into the preset queue corresponding to the paragraph category of the target element, and the target element is stored in the reset preset one-dimensional array; in response to determining that the block operation is completed and there is a next element in the target one-dimensional array, the next element is determined as the target element, and the target operation is continued; in response to determining that the block operation is completed and there is no next element in the target one-dimensional array, the preset one-dimensional array corresponding to the paragraph category of the target element and each array in the preset queue are respectively stored as independent blocks in the preset mapping object corresponding to the paragraph category of the target element to obtain the target mapping object.

10. An electronic device, characterized in that: include: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, so that the at least one processor can perform the method according to any one of claims 1 to 8.

11. A non-transitory computer-readable storage medium storing computer instructions, characterized in that: The computer instructions are used to cause the computer to execute the method according to any one of claims 1 to 8.

Citation Information

Patent Citations

  • Document analysis method and apparatus

    CN106445910A

  • Paragraph hierarchy construction method and device, electronic equipment and storage medium

    CN110427614A