Text cutting method and device, equipment and storage medium
By using semantic information to select cutting points in text cutting, the problem of semantic loss caused by text cutting in the existing technology is solved, and the accuracy of the question and answer effect is improved.
Patent Information
- Application Number
- CN202410445319.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-15
- Publication Date
- 2024-09-17
AI Technical Summary
When cutting text, the existing technology rigidly cuts a text with complete semantics into small fragments, causing the semantics to be lost or broken, and reducing the accuracy of the question and answer effect.
By determining multiple candidate cutting points in the text to be cut, the target cutting points are selected based on the semantic information of each text fragment, and the text to be cut is cut. Vector encoding and semantic similarity matrix construction are used to determine the cutting points to avoid semantic loss.
It effectively improves the accuracy of the question and answer effect, avoids the semantic loss or breakage of text fragments, and ensures the semantic integrity of text cutting.
Smart Images

Figure CN118657146A
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a text cutting method, device, equipment and storage medium. Background Art
[0002] Based on the learning and conversation capabilities of the big model, it is possible to collect and process industry information and knowledge materials more extensively, enhance the information dimension of intelligent applications, and provide enterprises with richer and more valuable information.
[0003] Currently, when a large model is needed to answer questions based on a document, the document can be cut into several segments, and only a small number of document fragments related to the question can be added to the input of the large model. Based on the user's question, the most relevant fragments in the document can be found and returned, thereby achieving a dialogue with the question statement.
[0004] However, the above-mentioned text segmentation methods include segmenting the text according to specified interval characters, or segmenting the text according to a fixed length, or fixed-length segmenting of the text with overlapping segments of a fixed length, etc. All of them rigidly cut a piece of text with complete semantics into small segments, which will cause the semantics of a large number of text segments to be lost or broken, resulting in a decrease in the accuracy of the question and answer effect.
[0005] The above contents are only used to assist in understanding the technical solution of the present invention and do not constitute an admission that the above contents are prior art. Summary of the invention
[0006] The main purpose of the present invention is to provide a text cutting method, device, equipment and storage medium, aiming to solve the technical problem that the prior art rigidly cuts a piece of text with complete semantics into small segments, which will cause the semantics of a large number of text segments to be lost or broken, resulting in a decrease in the accuracy of question and answer effects.
[0007] To achieve the above object, the present invention provides a text cutting method, which comprises:
[0008] Determine multiple candidate cutting points in the text to be cut;
[0009] Dividing the text to be cut into multiple text segments based on the multiple candidate cutting points;
[0010] Selecting a target cutting point from the plurality of candidate cutting points according to semantic information of each text segment;
[0011] The text to be cut is cut based on the target cutting point.
[0012] Optionally, the step of selecting a target cutting point from the plurality of candidate cutting points according to the semantic information of each text segment includes:
[0013] Performing vector encoding on each text segment to obtain semantic information of each text segment;
[0014] Determine semantic similarity between different text segments based on the semantic information;
[0015] A target cutting point is selected from the plurality of candidate cutting points according to the semantic similarities.
[0016] Optionally, the step of selecting a target cutting point from the plurality of candidate cutting points according to the semantic similarities comprises:
[0017] Construct a similarity matrix based on each semantic similarity;
[0018] Determining scores of the plurality of candidate cutting points according to each similarity matrix;
[0019] A candidate cutting point with the highest score is selected from the multiple candidate cutting points as a target cutting point.
[0020] Optionally, the step of determining the scores of the plurality of candidate cutting points according to each similarity matrix includes:
[0021] Each similarity matrix is updated according to a preset step distance to obtain a plurality of updated similarity matrices;
[0022] The scores of the plurality of candidate cutting points are determined based on the plurality of updated similarity matrices.
[0023] Optionally, the step of updating each similarity matrix according to a preset step distance to obtain a plurality of updated similarity matrices includes:
[0024] Each similarity matrix is updated by a preset matrix update formula to obtain a plurality of updated similarity matrices;
[0025] Wherein, the preset matrix update formula is:
[0026]
[0027] In the formula, A ij is the updated similarity matrix, r is the preset step distance, V ij V i and V j The semantic similarity between mn V m and V n The semantic similarity between i is the semantic information of segment i, V j is the semantic information of segment j, V m is the semantic information of segment m, V nis the semantic information of segment n.
[0028] Optionally, the step of determining the scores of the plurality of candidate cutting points based on the plurality of updated similarity matrices comprises:
[0029] Determining text character lengths of the plurality of text segments;
[0030] Calculate the scores of the multiple cutting points by using a preset scoring formula;
[0031] Wherein, the preset scoring formula is:
[0032]
[0033] In the formula, C k is the score of the kth candidate cutting point, A ij is the updated similarity matrix, S k is the length of the kth text segment in characters, S k+1 is the length of the text characters of the k+1th text segment.
[0034] Optionally, after the step of cutting the text to be cut based on the target cutting point, the method further includes:
[0035] Acquire a plurality of cut texts obtained by cutting the to-be-cut text based on the target cutting point;
[0036] Performing vector encoding on the plurality of cut texts to obtain text semantic information of the plurality of cut texts, and saving each text semantic information to a knowledge base;
[0037] Upon receiving a question statement, determining question semantic information of the question semantics;
[0038] The target text semantic information matching the question semantic information is searched in the knowledge base, and the target segmented text corresponding to the target text semantic information is displayed.
[0039] In addition, to achieve the above object, the present invention also provides a text cutting device, the device comprising:
[0040] A candidate cutting point determination module is used to determine multiple candidate cutting points in the text to be cut;
[0041] A text segmentation module, used for segmenting the text to be segmented into multiple text segments based on the multiple candidate segmentation points;
[0042] A cutting point selection module, used for selecting a target cutting point from the plurality of candidate cutting points according to the semantic information of each text segment;
[0043] The text cutting module is used to cut the text to be cut based on the target cutting point.
[0044] In addition, to achieve the above-mentioned purpose, the present invention also proposes a text cutting device, which includes: a memory, a processor, and a text cutting program stored in the memory and executable on the processor, wherein the text cutting program is configured to implement the steps of the text cutting method described above.
[0045] In addition, to achieve the above-mentioned purpose, the present invention also proposes a storage medium, on which a text cutting program is stored, and when the text cutting program is executed by a processor, the steps of the text cutting method described above are implemented.
[0046] The present invention provides a text cutting method, device, equipment and storage medium. The method determines multiple candidate cutting points in a text to be cut; divides the text to be cut into multiple text segments based on the multiple candidate cutting points; selects a target cutting point from the multiple candidate cutting points according to the semantic information of each text segment; and cuts the text to be cut based on the target cutting point. The present invention selects a target cutting point from the multiple candidate cutting points to cut the text to be cut based on the semantic information of the multiple text segments divided by the multiple candidate cutting points. Compared with the prior art that rigidly cuts a complete semantic text into small segments without considering the semantic information of the text segments, the above method of the present invention realizes the cutting of document data based on the semantic information of the text segments, thereby avoiding the semantic loss or breakage of a large number of text segments, and effectively improving the accuracy of the question-answering effect. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] Figure 1 A schematic diagram of the structure of a text cutting device in a hardware operating environment according to an embodiment of the present invention;
[0048] Figure 2 It is a flowchart of the first embodiment of the text cutting method of the present invention;
[0049] Figure 3 It is a flowchart of the second embodiment of the text cutting method of the present invention;
[0050] Figure 4 It is a flowchart of the third embodiment of the text cutting method of the present invention;
[0051] Figure 5 It is a structural block diagram of the first embodiment of the text cutting device of the present invention.
[0052] The realization of the purpose, functional features and advantages of the present invention will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0053] It should be understood that the specific embodiments described herein are only used to explain the present invention, and are not used to limit the present invention.
[0054] Reference Figure 1 , Figure 1 The figure is a schematic diagram of the structure of a text cutting device in the hardware operating environment involved in the embodiment of the present invention.
[0055] like Figure 1 As shown, the text cutting device may include: a processor 1001, such as a central processing unit (CPU), a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. Among them, the communication bus 1002 is used to realize the connection and communication between these components. The user interface 1003 may include a display screen (Display), an input unit such as a keyboard (Keyboard), and the optional user interface 1003 may also include a standard wired interface and a wireless interface. The network interface 1004 may optionally include a standard wired interface and a wireless interface (such as a wireless fidelity (Wireless-Fidelity, Wi-Fi) interface). The memory 1005 may be a high-speed random access memory (Random Access Memory, RAM), or a stable non-volatile memory (Non-Volatile Memory, NVM), such as a disk storage. The memory 1005 may also be a storage device independent of the aforementioned processor 1001.
[0056] Those skilled in the art will understand that Figure 1 The structure shown in the figure does not constitute a limitation on the text cutting device, and may include more or less components than shown in the figure, or combine certain components, or arrange the components differently.
[0057] like Figure 1 As shown, the memory 1005 as a storage medium may include an operating system, a network communication module, a user interface module, and a text cutting program.
[0058] exist Figure 1 In the text cutting device shown, the network interface 1004 is mainly used for data communication with the network server; the user interface 1003 is mainly used for data interaction with the user; the processor 1001 and the memory 1005 in the text cutting device of the present invention can be set in the text cutting device, and the text cutting device calls the text cutting program stored in the memory 1005 through the processor 1001, and executes the text cutting method provided by the embodiment of the present invention.
[0059] The embodiment of the present invention provides a text cutting method, referring to Figure 2 , Figure 2 Schematic diagram of the flow chart of the first embodiment of the text segmentation method of the present invention.
[0060] In this embodiment, the text cutting method includes the following steps:
[0061] Step S10: determining a plurality of candidate cutting points in the text to be cut.
[0062] It should be noted that the execution subject of the method of this embodiment can be a computing service device with text cutting, network communication and program running functions, such as a mobile phone, a tablet computer, a personal computer, etc., and can also be other electronic devices that achieve the same or similar functions. The following text cutting device is used to illustrate this embodiment and the following embodiments.
[0063] It is understandable that the above-mentioned text to be cut can be the text that needs to respond to the question statement in the large model. If the large model is required to answer the question according to the document response question statement, the text to be cut needs to be cut to simplify the length of the document content in the large model input, so as to accurately reply to the document fragments related to the question statement, avoid interference caused by irrelevant document fragments, and improve the accuracy of the reply.
[0064] Among them, the above-mentioned large model can be an intelligent model with learning and dialogue capabilities, and the formats of the above-mentioned text to be cut include but are not limited to word, ppt, pdf, ocr recognition results, xml and json, etc.
[0065] In addition, there may be multiple texts to be cut. For ease of description and understanding, this embodiment and the following embodiments are described with a single text to be cut. For multiple texts to be cut, the processing flow is the same as that of a single text to be cut.
[0066] It should be noted that the candidate cutting points mentioned above may be existing ones in the text content to be cut, so as to cut the text to be cut and obtain cutting points of multiple document fragments, such as specifying spacing characters, fixed lengths and natural punctuation marks.
[0067] In a specific implementation, the candidate cutting points required for the text to be cut can be pre-configured, such as selecting natural punctuation as candidate cutting points from multiple types of cutting points such as specified spacing characters, fixed lengths, and natural punctuation. The above-mentioned text cutting device determines all candidate cutting points from the text content of the text to be cut according to the configuration information.
[0068] Step S20: dividing the text to be cut into multiple text segments based on the multiple candidate cutting points.
[0069] In a specific implementation, the above-mentioned text cutting device can perform preliminary cutting on the text to be cut according to multiple candidate cutting points, and divide the text to be cut into multiple text segments. Taking natural punctuation as an example of the candidate cutting points, assuming that the text content of the extracted text to be cut is "This is a simple example: How should we operate? The specific calculation method is very fast. Different text qualities are applicable.", the text to be cut is divided according to natural punctuation, and four text segments Chunck1, Chunck2, Chunck3 and Chunck4 can be obtained, Chunck1 = "This is a simple example:", Chunck2 = "How should we operate?", Chunck3 = "The specific calculation method is very fast.", Chunck4 = "Different text qualities are applicable.".
[0070] Step S30: selecting a target cutting point from the plurality of candidate cutting points according to the semantic information of each text segment.
[0071] In a specific implementation, the above-mentioned text cutting device can determine the semantic information of each text fragment, and then traverse each candidate cutting point to query the target cutting point that meets the optimal cutting point condition. The optimal cutting point condition may be that the degree of correlation between the semantic information of the text fragments on both sides of the target cutting point is low, and the degree of correlation between the semantic information of the text fragments on the same side of the target cutting point is high.
[0072] Step S40: cutting the text to be cut based on the target cutting point.
[0073] In a specific implementation, the above-mentioned text cutting device can use the selected target cutting point to cut the text to be cut, and obtain multiple cut texts, so that the semantic information of each content in the same cut text is highly correlated, that is, the text segments with high semantic similarity on the same side are divided into the same text. For example, Chunck1, Chunck2, Chunck3 and Chunck4 in the above examples, when the target cutting point is ":", the cut texts obtained by cutting the text to be cut using the target cutting point are: Text1 = "This is a simple example:", Text2 = "How should we do it? The specific calculation method is very fast. Different text qualities are applicable." When responding to user questions, multiple text contents with high semantic similarity on the same side can be returned, which effectively improves the accuracy of the question and answer effect.
[0074] This embodiment determines multiple candidate cutting points in the text to be cut; divides the text to be cut into multiple text segments based on the multiple candidate cutting points; selects a target cutting point from the multiple candidate cutting points according to the semantic information of each text segment; and cuts the text to be cut based on the target cutting point. The present invention divides the text into multiple text segments using multiple candidate cutting points, and selects a target cutting point from the multiple candidate cutting points based on the semantic information of the multiple text segments to cut the text to be cut. Compared with the prior art that rigidly cuts a complete semantic text into small segments without considering the semantic information of the text segments, the above method of this embodiment realizes the cutting of document data based on the semantic information of the text segments, thereby avoiding the semantic loss or breakage of a large number of text segments, and effectively improving the accuracy of the question-answering effect.
[0075] refer to Figure 3 , Figure 3 Schematic diagram of the flow chart of the second embodiment of the text segmentation method of the present invention.
[0076] Based on the above first embodiment, in this embodiment, step S30 includes:
[0077] Step S301: performing vector encoding on each text segment to obtain semantic information of each text segment.
[0078] In a specific implementation, after the above-mentioned text cutting device divides the text to be cut into multiple text segments with multiple candidate cutting points, it can use the text2vec model to perform vector encoding on each text segment, obtain the text vector of each text segment, and use the text vector of each text segment as the semantic information of each text segment. For example, in the above-mentioned examples of Chunck1, Chunck2, Chunck3 and Chunck4, each Chunck is vector encoded, and the vector V1 of Chunck1 is 010010010, the vector V2 of Chunck2 is 011010010, the vector V3 of Chunck3 is 010110010, and the vector V4 of Chunck4 is 010011010.
[0079] Step S302: Determine the semantic similarity between different text segments based on the semantic information.
[0080] In a specific implementation, the text segmentation device can pair the semantic information of each text segment, i.e., the text vector, calculate the cosine similarity between any two text vectors, and use the cosine similarity as the semantic similarity between different text segments. For example, the semantic similarity of the vectors V1, V2, V3, and V4 in the above example after pairing can be V 11 、V 12 and V 13 etc., which can be expressed as V ij, i=1, 2, 3, 4, j=1, 2, 3, 4.
[0081] Step S303: selecting a target cutting point from the plurality of candidate cutting points according to the semantic similarities.
[0082] In a specific implementation, the above-mentioned text cutting device can score multiple candidate cutting points according to the semantic similarity between each text segment. When the semantic similarity of the segments on both sides of any candidate cutting point is greatly different, a higher score is assigned, and then the candidate cutting point with the highest score is used as the target cutting point.
[0083] Furthermore, in this embodiment, step S303 includes:
[0084] Step S3031: construct a similarity matrix according to each semantic similarity.
[0085] In a specific implementation, the above-mentioned text cutting device can construct a similarity matrix based on the semantic similarity between each segment. For ease of understanding, V ij represents the similarity matrix, V 11 It can be the similarity matrix of vector V1 itself, V 12 is the similarity matrix between vector V1 and vector V2. The similarity matrices between other different vectors can be expressed in this way.
[0086] Step S3032: Determine the scores of the multiple candidate cutting points according to each similarity matrix.
[0087] In a specific implementation, the above-mentioned text cutting device can score multiple candidate cutting points according to each constructed similarity matrix.
[0088] Furthermore, in this embodiment, step S3032 includes:
[0089] Each similarity matrix is updated according to a preset step distance to obtain a plurality of updated similarity matrices.
[0090] It should be noted that the above-mentioned preset step distance can be pre-set according to needs, such as setting the preset step distance equal to 2, which is not limited in this embodiment.
[0091] In a specific implementation, in order to further strengthen the gap between the vectors of the text segments, the text cutting device may use the preset step distance to update each similarity matrix to obtain an updated similarity matrix corresponding to each similarity matrix.
[0092] Furthermore, in this embodiment, the step of updating each similarity matrix according to a preset step distance to obtain a plurality of updated similarity matrices includes:
[0093] Each similarity matrix is updated by a preset matrix update formula to obtain a plurality of updated similarity matrices;
[0094] Wherein, the preset matrix update formula is:
[0095]
[0096] In the formula, A ij is the updated similarity matrix, r is the preset step distance, V ij V i and V j The semantic similarity between mn V m and V n The semantic similarity between i is the semantic information of segment i, V j is the semantic information of segment j, V m is the semantic information of segment m, V n is the semantic information of segment n.
[0097] The scores of the plurality of candidate cutting points are determined based on the plurality of updated similarity matrices.
[0098] In a specific implementation, the text cutting device may use each updated similarity matrix to score multiple candidate cutting points.
[0099] Furthermore, in this embodiment, the step of determining the scores of the plurality of candidate cutting points based on the plurality of updated similarity matrices includes:
[0100] The text character lengths of the plurality of text segments are determined.
[0101] It should be noted that the above text character length may be the number of characters in the text segment.
[0102] The scores of the multiple cutting points are calculated using a preset scoring formula.
[0103] Wherein, the preset scoring formula is:
[0104]
[0105] In the formula, C k is the score of the kth candidate cutting point, A ij is the updated similarity matrix, S k is the length of the kth text segment in characters, S k+1 is the length of the text characters of the k+1th text segment.
[0106] It is understandable that when the candidate cutting point is a natural punctuation, the above k can be represented as the end of the sentence of each text segment.
[0107] It should be noted that the higher the score of the candidate segmentation point, the closer the semantics of the text segments on the same side of the candidate segmentation point are, and the greater the semantic difference between the text segments on different sides of the candidate segmentation point is.
[0108] Step S3033: Selecting the candidate cutting point with the highest score from the multiple candidate cutting points as the target cutting point.
[0109] In a specific implementation, the above-mentioned text cutting device can traverse the scores of multiple candidate cutting points, and select the candidate cutting point with the highest demand score from the multiple candidate cutting points as the target cutting point, so that the semantics of the text fragments on the same side of the target cutting point are closer, thereby improving the question and answer accuracy.
[0110] In addition, when a deeper understanding of the text structure is needed, or when multiple relevant cutting points need to be found, such as in the topic segmentation or paragraph division of a long document, the above-mentioned text cutting device can also construct a score sequence based on the score of each candidate cutting point, and then determine the fluctuation of the score sequence, and select the candidate cutting point with higher fluctuation as the text cutting point, so as to realize the processing of complex text and improve the accuracy of the target cutting point selection.
[0111] refer to Figure 4 , Figure 4 Schematic diagram of the flow chart of the third embodiment of the text segmentation method of the present invention.
[0112] Based on the above embodiments, in this embodiment, after step S40, the method further includes:
[0113] Step S50: Acquire a plurality of cut texts obtained by cutting the text to be cut based on the target cutting point.
[0114] In a specific implementation, the text cutting device can cut the text to be cut using the determined target cutting point, and after obtaining a plurality of cut texts, extract the plurality of cut texts.
[0115] Step S60: performing vector encoding on the plurality of cut texts, obtaining text semantic information of the plurality of cut texts, and saving each text semantic information into a knowledge base.
[0116] It should be noted that the above-mentioned knowledge base can be used to store text fragments that respond to the semantics of the question.
[0117] In a specific implementation, the above-mentioned text cutting device can perform vector encoding on each cut text, obtain the text vector of each cut text, and use the text vector of each cut text as the text semantic information of each cut text, and then save the text semantic information into the knowledge base.
[0118] Step S70: upon receiving a question statement, determining question semantics information of the question semantics.
[0119] In a specific implementation, when receiving a question sentence input by a user, the text segmentation device may perform vector encoding on the question sentence to determine question semantic information of the question sentence.
[0120] Step S80: searching the knowledge base for target text semantic information that matches the question semantic information, and displaying the target segmented text corresponding to the target text semantic information.
[0121] In a specific implementation, the above-mentioned text cutting device can traverse the text semantic information of each cut text in the knowledge base, match each text semantic information with the question semantic information, query the target text semantic information that matches the question semantic information most, and then convert the target text semantic information into a corresponding target cut text, and display the target cut text to reply to the user's question statement. Since the target cut text is obtained by cutting the text to be cut through semantic information, the target cut text does not lose a lot of semantics and can better match the semantics of the question statement, so that the target cut text can meet user expectations and effectively improve the user experience.
[0122] In addition, an embodiment of the present invention further proposes a storage medium, on which a text cutting program is stored. When the text cutting program is executed by a processor, the steps of the text cutting method described above are implemented.
[0123] Reference Figure 5 , Figure 5 It is a structural block diagram of the first embodiment of the text cutting device of the present invention.
[0124] like Figure 5 As shown, the text cutting device proposed in the embodiment of the present invention includes:
[0125] The candidate cutting point determination module 501 is used to determine a plurality of candidate cutting points in the text to be cut.
[0126] The text segmentation module 502 is used to segment the text to be segmented into multiple text segments based on the multiple candidate segmentation points.
[0127] The cutting point selection module 503 is used to select a target cutting point from the plurality of candidate cutting points according to the semantic information of each text segment.
[0128] The text cutting module 504 is used to cut the text to be cut based on the target cutting point.
[0129] This embodiment determines multiple candidate cutting points in the text to be cut; divides the text to be cut into multiple text segments based on the multiple candidate cutting points; selects a target cutting point from the multiple candidate cutting points according to the semantic information of each text segment; and cuts the text to be cut based on the target cutting point. The present invention divides the text into multiple text segments using multiple candidate cutting points, and selects a target cutting point from the multiple candidate cutting points based on the semantic information of the multiple text segments to cut the text to be cut. Compared with the prior art that rigidly cuts a complete semantic text into small segments without considering the semantic information of the text segments, the above-mentioned device of this embodiment realizes the cutting of document data based on the semantic information of the text segments, thereby avoiding the semantic loss or breakage of a large number of text segments, and effectively improving the accuracy of the question-answering effect.
[0130] Based on the above-mentioned first embodiment of the text cutting device of the present invention, a second embodiment of the text cutting device of the present invention is proposed.
[0131] In this embodiment, the cutting point selection module 503 is also used to perform vector encoding on each text segment to obtain semantic information of each text segment; determine the semantic similarity between different text segments based on each semantic information; and select a target cutting point from the multiple candidate cutting points according to each semantic similarity.
[0132] As an implementation mode, the cutting point selection module 503 is also used to construct a similarity matrix according to each semantic similarity; determine the scores of the multiple candidate cutting points according to each similarity matrix; and select the candidate cutting point with the highest score from the multiple candidate cutting points as the target cutting point.
[0133] As an implementation manner, the cutting point selection module 503 is further used to update each similarity matrix according to a preset step distance to obtain multiple updated similarity matrices; and determine the scores of the multiple candidate cutting points based on the multiple updated similarity matrices.
[0134] As an implementation manner, the cutting point selection module 503 is further used to update each similarity matrix by a preset matrix update formula to obtain multiple updated similarity matrices; wherein the preset matrix update formula is:
[0135]
[0136] In the formula, A ij is the updated similarity matrix, r is the preset step distance, V ij V iand V j The semantic similarity between mn V m and V n The semantic similarity between i is the semantic information of segment i, V j is the semantic information of segment j, V m is the semantic information of segment m, V n is the semantic information of segment n.
[0137] As an implementation manner, the cutting point selection module 503 is further used to determine the text character lengths of the multiple text segments; and calculate the scores of the multiple cutting points using a preset scoring formula; wherein the preset scoring formula is:
[0138]
[0139] In the formula, C k is the score of the kth candidate cutting point, A ij is the updated similarity matrix, S k is the length of the kth text segment in characters, S k+1 is the length of the text characters of the k+1th text segment.
[0140] Based on the above-mentioned embodiments of the text cutting device of the present invention, a third embodiment of the text cutting device of the present invention is proposed.
[0141] In this embodiment, the text cutting module 503 is also used to obtain multiple cut texts obtained by cutting the text to be cut based on the target cutting point; vector encode the multiple cut texts to obtain text semantic information of the multiple cut texts, and save each text semantic information to the knowledge base; when receiving a question statement, determine the question semantic information of the question semantics; query the knowledge base for target text semantic information matching the question semantic information, and display the target cut text corresponding to the target text semantic information.
[0142] The specific implementation of the text cutting device of the present invention can refer to the above-mentioned method embodiments, which will not be repeated here.
[0143] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or system including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or system. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or system including the element.
[0144] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.
[0145] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as a read-only memory / random access memory, a magnetic disk, or an optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present invention.
[0146] The above are only preferred embodiments of the present invention, and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made using the contents of the present invention specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.
Claims
1. A text cutting method, It is characterized in that The method comprises: Determine multiple candidate cutting points in the text to be cut; Dividing the text to be cut into multiple text segments based on the multiple candidate cutting points; Selecting a target cutting point from the plurality of candidate cutting points according to semantic information of each text segment; The text to be cut is cut based on the target cutting point.
2. The text cutting method according to claim 1, It is characterized in that The step of selecting a target cutting point from the plurality of candidate cutting points according to the semantic information of each text segment comprises: Performing vector encoding on each text segment to obtain semantic information of each text segment; Determine semantic similarity between different text segments based on the semantic information; A target cutting point is selected from the plurality of candidate cutting points according to the semantic similarities.
3. The text cutting method according to claim 2, It is characterized in that The step of selecting a target cutting point from the plurality of candidate cutting points according to the semantic similarities comprises: Construct a similarity matrix based on each semantic similarity; Determining scores of the plurality of candidate cutting points according to each similarity matrix; A candidate cutting point with the highest score is selected from the multiple candidate cutting points as a target cutting point.
4. The text cutting method according to claim 3, It is characterized in that The step of determining the scores of the plurality of candidate cutting points according to the similarity matrices comprises: Each similarity matrix is updated according to a preset step distance to obtain a plurality of updated similarity matrices; The scores of the plurality of candidate cutting points are determined based on the plurality of updated similarity matrices.
5. The text cutting method according to claim 4, It is characterized in that The step of updating each similarity matrix according to a preset step distance to obtain a plurality of updated similarity matrices includes: Each similarity matrix is updated by a preset matrix update formula to obtain a plurality of updated similarity matrices; Wherein, the preset matrix update formula is: In the formula, A ij is the updated similarity matrix, r is the preset step distance, V ij V i and V j The semantic similarity between mn V m and V n The semantic similarity between i is the semantic information of segment i, V j is the semantic information of segment j, V m is the semantic information of segment m, V n is the semantic information of segment n.
6. The text cutting method according to claim 4, It is characterized in that The step of determining the scores of the plurality of candidate cutting points based on the plurality of updated similarity matrices comprises: Determining text character lengths of the plurality of text segments; Calculate the scores of the multiple cutting points by using a preset scoring formula; Wherein, the preset scoring formula is: In the formula, C k is the score of the kth candidate cutting point, A ij is the updated similarity matrix, S k is the length of the kth text segment in characters, S k+1 is the length of the text characters of the k+1th text segment.
7. The text cutting method according to any one of claims 1 to 6, It is characterized in that After the step of cutting the text to be cut based on the target cutting point, the method further includes: Acquire a plurality of cut texts obtained by cutting the to-be-cut text based on the target cutting point; Performing vector encoding on the plurality of cut texts to obtain text semantic information of the plurality of cut texts, and saving each text semantic information to a knowledge base; Upon receiving a question statement, determining question semantic information of the question semantics; The target text semantic information matching the question semantic information is searched in the knowledge base, and the target segmented text corresponding to the target text semantic information is displayed.
8. A text cutting device, It is characterized in that The device comprises: A candidate cutting point determination module is used to determine multiple candidate cutting points in the text to be cut; A text segmentation module, used for segmenting the text to be segmented into multiple text segments based on the multiple candidate segmentation points; A cutting point selection module, used for selecting a target cutting point from the plurality of candidate cutting points according to the semantic information of each text segment; The text cutting module is used to cut the text to be cut based on the target cutting point.
9. A text cutting device, It is characterized in that The device comprises: a memory, a processor, and a text cutting program stored in the memory and executable on the processor, wherein the text cutting program is configured to implement the steps of the text cutting method according to any one of claims 1 to 7.
10. A storage medium, It is characterized in that The storage medium stores a text cutting program, and when the text cutting program is executed by the processor, the steps of the text cutting method according to any one of claims 1 to 7 are implemented.
