Word segmentation method, device, electronic device and storage medium
By combining the word segmentation parameters from the back-to-front direction and the front-to-back direction, the cumulative word frequency and part-of-speech probability of the candidate words are determined, and the divergent words are analyzed, which solves the problem of low accuracy of word segmentation in complex sentences and improves the accuracy of word segmentation.
Patent Information
- Application Number
- CN202010722115.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-07-24
- Publication Date
- 2024-10-22
- Estimated Expiration
- 2040-07-24
AI Technical Summary
The existing technology has low word segmentation accuracy when processing complex sentences, resulting in poor word segmentation effects.
By using the candidate word parameters combined from the back-to-front direction and the front-to-back direction in the word segmentation method, the cumulative word frequency probability and part-of-speech probability of the candidate word are determined, so as to locate and analyze divergent words between the word segmentation results, using the setting The algorithm selects the final word segmentation result.
It improves the word segmentation processing effect of complex sentences, enhances the accuracy of word segmentation, can better handle divergent words, and improves the word segmentation processing effect of complex sentences.
Smart Images

Figure CN113971397B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing, and in particular to a word segmentation method, device, electronic equipment and storage medium. Background Art
[0002] Currently, when a string matching algorithm is used for word segmentation, the word segmentation is performed based on a pre-configured dictionary and features. When complex sentences are segmented, the processing effect is poor, resulting in reduced accuracy of complex sentence segmentation. Summary of the invention
[0003] In view of this, embodiments of the present invention provide a word segmentation method, device, electronic device and storage medium to at least solve the problem that the related art has reduced accuracy in word segmentation of complex sentences.
[0004] The technical solution of the embodiment of the present invention is achieved as follows:
[0005] An embodiment of the present invention provides a word segmentation method, the method comprising:
[0006] According to the first parameter of the candidate words in the first group of candidate words of the text to be processed, a first target candidate word is selected from the first group of candidate words in a direction from back to front to obtain a first word segmentation result of the text to be processed, wherein the first group of candidate words is a group of candidate words obtained by segmenting the text to be processed in a direction from front to back, the first parameter is the cumulative word frequency probability of all candidate word combinations in the left neighbor words of a candidate word; the first target candidate word is the left neighbor word corresponding to the maximum first parameter of a candidate word;
[0007] According to the second parameter of the candidate words in the second group of candidate words of the to-be-processed text, a second target candidate word is selected from the second group of candidate words in a direction from front to back, to obtain a second word segmentation result of the to-be-processed text, wherein the second group of candidate words is a group of candidate words obtained by segmenting the to-be-processed text in a direction from back to front, the second parameter is the accumulated part-of-speech probability of all candidate word combinations in the right neighbor words of a candidate word; the second target candidate word is the right neighbor word corresponding to the maximum second parameter of a candidate word;
[0008] Determine at least one pair of divergent words in the first word segmentation result and the second word segmentation result, wherein the pair of divergent words includes a word in the first word segmentation result and a word in the second word segmentation result, and the pair of divergent words corresponds to a word segmentation difference between the first word segmentation result and the second word segmentation result;
[0009] According to the set algorithm, a segmentation word is determined from the pair of divergent words as the final segmentation result of the pair of divergent words, so as to obtain a third segmentation result of the text to be processed.
[0010] In the above scheme, the first parameter of the candidate word in the first group of candidate words of the text to be processed is used to select the first target candidate word from the first group of candidate words in a direction from back to front to obtain the first word segmentation result of the text to be processed, including:
[0011] For each candidate word in the first group of candidate words, determine the word frequency probability corresponding to each candidate word in a set word frequency dictionary, and determine the first parameter corresponding to each candidate word according to the word frequency probability corresponding to each candidate word in the set word frequency dictionary;
[0012] Based on the maximum first parameter of each candidate word, a first target candidate word is selected from the first group of candidate words in a direction from back to front to obtain a first word segmentation result of the text to be processed.
[0013] In the above scheme, according to the set algorithm, determining a segmentation word from the pair of divergent words as the final segmentation result of the pair of divergent words to obtain the third segmentation result of the text to be processed includes:
[0014] Determine the number of first segmented words of the first segmented result and the number of second segmented words of the second segmented result;
[0015] Detecting whether the number of the first participles is the same as the number of the second participles, and obtaining a detection result;
[0016] A set algorithm corresponding to the detection result is used to select a segmentation word from the pair of divergent words as a final segmentation result of the pair of divergent words, so as to obtain a third segmentation result of the text to be processed.
[0017] In the above scheme, the step of adopting a set algorithm corresponding to the detection result to determine a segmentation word from the pair of divergent words as the final segmentation result of the pair of divergent words to obtain a third segmentation result of the text to be processed includes:
[0018] In the case where the detection result indicates that the number of the first segmented words is the same as the number of the second segmented words, a first probability and a second probability are determined according to a set dictionary; the set dictionary stores the probability of connection between segmented words; the first probability is the probability of connection between each divergent word in at least one divergent word in the first segmented word result and an adjacent word; the second probability is the probability of connection between each divergent word in at least one divergent word in the second segmented word result and an adjacent word;
[0019] According to the comparison result of the first probability and the second probability, selecting a segmentation word from each pair of the at least one pair of divergent words as a corresponding segmentation result;
[0020] A third word segmentation result of the text to be processed is determined according to the word segmentation result corresponding to each pair of divergent words in at least one pair of divergent words in the text to be processed.
[0021] In the above solution, the determining the first probability and the second probability according to the setting dictionary includes:
[0022] According to the left neighbor words of each of the at least one pair of divergent words, the set dictionary is subjected to deletion processing; the words in the set dictionary after the deletion processing are the same as the paragraph head words of the left neighbor words of each of the at least one pair of divergent words;
[0023] A first probability and a second probability are determined according to the setting dictionary after the deletion process.
[0024] In the above scheme, for each candidate word in the first group of candidate words, determining the word frequency probability corresponding to each candidate word in a set word frequency dictionary, the method further includes:
[0025] When a candidate word in the first group of candidate words does not have a corresponding word frequency probability in the word frequency dictionary, the word frequency of the candidate word without a corresponding word frequency probability is set to a set value; the set value is a value greater than 0.
[0026] In the above solution, the second parameter of the candidate word in the second group of candidate words of the text to be processed includes:
[0027] For each candidate word in the second group of candidate words, determine the part-of-speech probability corresponding to each candidate word in the set part-of-speech dictionary, and determine the second parameter of each candidate word in the second group of candidate words based on the part-of-speech probability corresponding to each candidate word and the corresponding part-of-speech transfer probability; the part-of-speech transfer probability is the connection probability of the part-of-speech.
[0028] The embodiment of the present invention further provides a word segmentation device, including:
[0029] A first determination unit is used to select a first target candidate word from a first group of candidate words in a text to be processed according to a first parameter of the candidate words in the first group of candidate words in a direction from back to front, to obtain a first word segmentation result of the text to be processed, wherein the first group of candidate words is a group of candidate words obtained by segmenting the text to be processed in a direction from front to back, the first parameter is the cumulative word frequency probability of all candidate word combinations in the left neighbor words of a candidate word; the first target candidate word is the left neighbor word corresponding to the maximum first parameter of a candidate word;
[0030] A second determination unit is used to select a second target candidate word from the second group of candidate words in the text to be processed according to the second parameter of the candidate words in the second group of candidate words in the text to be processed in a direction from front to back, so as to obtain a second word segmentation result of the text to be processed, wherein the second group of candidate words is a group of candidate words obtained by segmenting the text to be processed in a direction from back to front, the second parameter is the accumulated part-of-speech probability of all candidate word combinations in the right neighboring words of a candidate word; the second target candidate word is the right neighboring word corresponding to the maximum second parameter of a candidate word;
[0031] A third determining unit is used to determine at least one pair of divergent words in the first word segmentation result and the second word segmentation result, wherein the pair of divergent words includes a word in the first word segmentation result and a word in the second word segmentation result, and the pair of divergent words corresponds to a word segmentation difference between the first word segmentation result and the second word segmentation result;
[0032] The fourth determining unit is used to determine a segmentation word from the pair of divergent words as a final segmentation result of the pair of divergent words according to a set algorithm, so as to obtain a third segmentation result of the text to be processed.
[0033] An embodiment of the present invention further provides an electronic device, comprising: a processor and a memory for storing a computer program that can be run on the processor,
[0034] Wherein, the processor is used to execute the steps of any of the above methods when running the computer program.
[0035] An embodiment of the present invention further provides a storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps of any of the above methods are implemented.
[0036] In an embodiment of the present invention, according to the first parameters of the candidate words in the first group of candidate words of the text to be processed, a first target candidate word is selected from the first group of candidate words in a direction from back to front to obtain a first word segmentation result of the text to be processed, wherein the first group of candidate words is a group of candidate words obtained by segmenting the text to be processed from the front to back direction, the first parameter is the cumulative word frequency probability of all candidate word combinations in the left neighboring words of a candidate word, the first target candidate word is the left neighboring word corresponding to the maximum first parameter of a candidate word, according to the second parameters of the candidate words in the second group of candidate words of the text to be processed, a second target candidate word is selected from the second group of candidate words in a direction from front to back to obtain a second word segmentation result of the text to be processed, wherein the second group of candidate words is a group of candidate words obtained by segmenting the text to be processed from the back to front direction, the second parameter is the cumulative word frequency probability of all candidate word combinations in the right neighboring words of a candidate word. The accumulated part-of-speech probabilities of all candidate word combinations are obtained, and the second target candidate word is the right neighbor word corresponding to the maximum second parameter of a candidate word. At least one pair of divergent words in the first word segmentation result and the second word segmentation result is determined, wherein a pair of divergent words includes a segmentation in the first word segmentation result and a segmentation in the second word segmentation result. A pair of divergent words corresponds to a segmentation difference between the first word segmentation result and the second word segmentation result. According to the set algorithm, a segmentation is determined from a pair of divergent words as the final segmentation result of a pair of divergent words to obtain a third segmentation result of the text to be processed. Two different segmentation results of the text to be processed are determined by word frequency and part of speech, which can better locate the segmentation difference, determine the divergent words and analyze the divergent words, and better process the segmentation results corresponding to the divergent words, thereby improving the segmentation processing effect of complex sentences and enhancing the accuracy of word segmentation. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] Figure 1 A schematic diagram of the implementation flow of a word segmentation method provided in one embodiment of the present invention.
[0038] Figure 2 A schematic diagram of the implementation flow of a word segmentation method provided in yet another embodiment of the present invention.
[0039] Figure 3 A schematic diagram of the implementation flow of a word segmentation method provided in yet another embodiment of the present invention.
[0040] Figure 4 A schematic diagram of the implementation flow of a word segmentation method provided in yet another embodiment of the present invention.
[0041] Figure 5 A schematic diagram of the implementation flow of a word segmentation method provided in yet another embodiment of the present invention.
[0042] Figure 6 A schematic diagram of a flow chart for word segmentation of a text to be processed provided by an application embodiment of the present invention
[0043] Figure 7 A schematic diagram of the structure of a word segmentation device provided in one embodiment of the present invention.
[0044] Figure 8 A schematic diagram of the hardware structure of an electronic device is provided for one embodiment of the present invention. DETAILED DESCRIPTION
[0045] The present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0046] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present invention. However, it should be clear to those skilled in the art that the present invention may be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, and methods are omitted to prevent unnecessary details from obstructing the description of the present invention.
[0047] It should be noted that the technical solutions described in the embodiments of the present invention can be combined arbitrarily without conflict.
[0048] In addition, in the embodiments of the present invention, "first", "second", etc. are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.
[0049] Figure 1 The implementation process of the word segmentation method provided by the embodiment of the present invention is shown. Figure 1 As shown, the method includes:
[0050] S101: According to the first parameter of a candidate word in a first group of candidate words of a text to be processed, a first target candidate word is selected from the first group of candidate words in a direction from back to front to obtain a first word segmentation result of the text to be processed, wherein the first group of candidate words is a group of candidate words obtained by segmenting the text to be processed in a direction from front to back, the first parameter is the accumulated word frequency probability of all candidate word combinations in the left neighboring words of a candidate word; the first target candidate word is the left neighboring word corresponding to the maximum first parameter of a candidate word.
[0051] Here, the text to be processed is the corpus that needs to be segmented. Segment the text to be processed in the forward direction (also known as forward segmentation) to obtain the first set of candidate words. According to the first parameter of each candidate word in the first set of candidate words of the text to be processed, select the first target candidate word from the first set of candidate words in the reverse direction. Herein, the first parameter refers to the cumulative word frequency probability of all candidate word combinations in the left adjacent words of a candidate word, and the first target candidate word refers to the left adjacent word corresponding to the maximum first parameter of a candidate word. For example, if the text to be processed is "Zhonghua Renmin" (Chinese People), segment it in the forward direction, that is, from the beginning to the end of the sentence, to obtain the first set of candidate words, which respectively include "Zhong", "Zhonghua", "Hua", "Huaren", "Ren", "Renmin", "Min". Determine the first parameter of each candidate word in the first set of candidate words. The first parameter is the cumulative word frequency probability representing all candidate combinations in the left adjacent words of the candidate word. For example, taking the candidate word "Renmin" as an example, all candidate combinations in the left adjacent words include "Zhong / Huaren", "Zhonghua / Ren", "Zhonghua / Renmin". Record the cumulative word frequency probability of all candidate combinations in the left adjacent words of the candidate word "Renmin". In the reverse direction, select the left adjacent word corresponding to the maximum first parameter from the first set of candidate words. For example, for the candidate word "Renmin", the left adjacent word corresponding to the maximum first parameter is "Zhonghua", so "Zhonghua" is the first target candidate word. According to the first target candidate word obtained for each candidate word, obtain the first segmentation result of the text to be processed. In practical applications, the text to be processed can be regarded as a character string S. Then, each candidate word determined in the first set of candidate words of the text to be processed in the forward direction can be regarded as w1, w2, ……, wn, where n is the number of segmentation words obtained based on the forward direction corresponding to the text to be processed.
[0052] In one embodiment, as Figure 2 shown, the step of selecting the first target candidate word from the first set of candidate words according to the first parameter of the candidate words in the first set of candidate words of the text to be processed in the reverse direction to obtain the first segmentation result of the text to be processed includes:
[0053] S201: For each candidate word in the first set of candidate words, determine the word frequency probability corresponding to each candidate word in the set word frequency dictionary, and determine the first parameter corresponding to each candidate word according to the word frequency probability corresponding to each candidate word in the set word frequency dictionary.
[0054] Here, the word frequency dictionary records the word frequency probabilities of words. By searching the word frequency dictionary, the word frequency probability corresponding to each candidate word in the first group of candidate words can be determined, and based on the word frequency probability corresponding to each candidate word in the first group of candidate words, the first parameter corresponding to each candidate word can be determined. By way of example, taking the text to be processed as "Zhonghua Renmin" (Chinese People) as an example, through the word frequency dictionary, the word frequency probability of "Zhong" (中) can be determined as P1, the word frequency probability of "Zhonghua" (中华) as P2, the word frequency probability of "Hua" (华) as P3, the word frequency probability of "Huaren" (华人) as P4, the word frequency probability of "Ren" (人) as P5, the word frequency probability of "Renmin" (人民) as P6, and the word frequency probability of "Min" (民) as P7. When calculating the first parameter of each candidate word, it is calculated by the word frequency probability of the candidate word and the word frequency probability corresponding to the combination of all candidate words in the left adjacent words of the candidate word. By way of example, taking "Renmin" (人民) as an example, when calculating the cumulative word frequency probability of "Renmin" (人民) and its left adjacent word "Zhonghua" (中华), it is obtained through the operation of P6 and P2. In practical applications, the word frequency dictionary is calculated by counting different test sets such as the People's Daily picture and text database to calculate the word frequency of each word, and at the same time collecting data such as network keywords and hot words and merging them with the test set to form a word frequency dictionary. Due to the large amount of data collected, the word frequency corresponding to some words is relatively low and the word frequency probability is small. When performing operations, overflow may occur and the second word frequency corresponding to the word cannot be determined. To avoid this phenomenon, the obtained word frequency probability can be logarithmically processed. The specific expression is P = -log(count + 1 / max_count + 1), where P represents the word frequency probability corresponding to each word, count represents the word frequency corresponding to each word, and max_count represents the total amount of all data collected. When representing the word frequency probability in the log domain, the first parameter is obtained by adding the word frequency probability of the candidate word and the word frequency probability of the left adjacent word, thereby reducing the amount of data in the operation and improving the operation speed. In practical applications, the word frequency dictionary can be updated regularly. By collecting data such as network materials and network hot words, the statistical data of the set word frequency dictionary can be updated. The set time can be updated on a monthly basis, or it can be automatically detected after the user issues an update instruction to update the set word frequency dictionary.
[0055] S202: Based on the maximum first parameter of each candidate word, select the first target candidate word from the first group of candidate words in the reverse direction from the back to the front to obtain the first word segmentation result of the text to be processed.
[0056] Here, after determining the first parameter of each candidate word in the first group of candidate words, the first target candidate word is selected from the first group of candidate words in the direction from back to front, and the first word segmentation result of the text to be processed is obtained. For example, taking the text to be processed as "Chinese People" as an example, when selecting words from the back to front, start with "People", assuming that the cumulative word frequency probability of the candidate word combination "People" is the largest according to the first parameter of "People", "People" is used as the first target candidate word, and then the left neighbor word of "Hua" is determined according to the first parameter corresponding to "Hua", and the determined first target candidate words are connected to obtain the first word segmentation result of the text to be processed. In practical applications, when selecting the first target candidate word, the word length of the first target candidate word can also be determined. For example, when determining that "People" is the first target candidate word, the word length corresponding to "People" can be determined to be 2. When determining the next candidate word from the back to front, according to the word length corresponding to "People", the word "People" is skipped, and the first target candidate word is selected for the candidate word "Hua".
[0057] In the above embodiment, for each candidate word in the first group of candidate words, the word frequency probability corresponding to each candidate word in the set word frequency dictionary is determined, and the first parameter corresponding to each candidate word is determined according to the word frequency probability corresponding to each candidate word in the set word frequency dictionary. Based on the maximum first parameter of each candidate word, the first target candidate word is selected from the first group of candidate words in a back-to-front direction to obtain the first word segmentation of the text to be processed. The word segmentation result corresponding to the text to be processed can be determined based on the word frequency, so that the word segmentation result is more accurate and rigorous, which is conducive to improving the recognition effect of divergent paragraphs and improving the effectiveness of divergent paragraphs.
[0058] In one embodiment, for each candidate word in the first group of candidate words, determining the word frequency probability corresponding to each candidate word in a set word frequency dictionary, the method further includes:
[0059] When a candidate word in the first group of candidate words does not have a corresponding word frequency probability in the word frequency dictionary, the word frequency of the candidate word without a corresponding word frequency probability is set to a set value; the set value is a value greater than 0.
[0060] Here, when querying the word frequency probability of each candidate word in the first group of candidate words through the word frequency dictionary, it may happen that the candidate words in the first group of candidate words do not have a corresponding word frequency probability in the word frequency dictionary. In this case, the word frequency of the candidate words that do not have a corresponding word frequency probability is set to a set value, and the set value is a value greater than 0. After setting the word frequency of the candidate words that do not have a corresponding word frequency probability in the word frequency dictionary to the set value, the corresponding word frequency probability is calculated based on the total number of words collected in the word frequency dictionary and the corresponding word frequency. In practical applications, Laplace smoothing technology can be used to ensure that the minimum word frequency of each candidate word in the first group of candidate words in the word frequency dictionary is 1.
[0061] In the above embodiment, when a candidate word in the first group of candidate words does not have a corresponding word frequency probability in the word frequency dictionary, the word frequency of the candidate word that does not have a corresponding word frequency probability is set to a set value, and the set value is a value greater than 0. It can ensure that when there is no corresponding word frequency in the word frequency dictionary, the corresponding word segmentation result can be obtained, so that the divergent segments can be determined, the divergent segments can be processed, and the accuracy of word segmentation can be improved.
[0062] S102: According to the second parameter of the candidate words in the second group of candidate words of the text to be processed, select the second target candidate word from the second group of candidate words in a front-to-back direction to obtain the second word segmentation result of the text to be processed, wherein the second group of candidate words is a group of candidate words obtained by segmenting the text to be processed from the back to the front, the second parameter is the accumulated part-of-speech probability of all candidate word combinations in the right neighboring words of a candidate word; the second target candidate word is the right neighboring word corresponding to the maximum second parameter of a candidate word.
[0063] Here, the text to be processed is segmented from back to front (also called backward segmentation), different candidate words are determined, a second group of candidate words are obtained, and a second target candidate word is selected from the second group of candidate words from the front to back direction to obtain the second segmentation result of the text to be processed, wherein the second parameter is the cumulative part-of-speech probability of all candidate word combinations in the right neighbor words of a candidate word, and the second target candidate word is the right neighbor word corresponding to the maximum second parameter of a candidate word. For example, taking the text to be processed as "Chinese People" as an example, the text to be processed is segmented from back to front, and a second group of candidate words consisting of "People", "People", "People", "Chinese", "Hua", "Zhonghua", and "Zhong" can be obtained, and the second parameter corresponding to each candidate word is determined, wherein the second parameter can be obtained by accumulating the part-of-speech probabilities of the candidate word and the right neighbor word. After determining the second parameters corresponding to all candidate words, from front to back, starting from the first candidate word at the beginning of the sentence, the right neighbor word corresponding to the maximum second parameter of the first candidate word is determined as the second target candidate word, and the second target candidate words are connected to obtain the second segmentation result of the text to be processed.
[0064] In one embodiment, the second parameter of the candidate word in the second group of candidate words according to the text to be processed includes:
[0065] For each candidate word in the second group of candidate words, determine the part-of-speech probability corresponding to each candidate word in the set part-of-speech dictionary, and determine the second parameter of each candidate word in the second group of candidate words based on the part-of-speech probability corresponding to each candidate word and the corresponding part-of-speech transfer probability; the part-of-speech transfer probability is the connection probability of the part-of-speech.
[0066] Here, the part-of-speech probability of each candidate word in the second group of candidate words is determined by the set part-of-speech dictionary, wherein the part-of-speech probability refers to the probability of each candidate word corresponding to a different part-of-speech. For a candidate word, it may have multiple parts of speech, and the probability of the candidate word in each part of speech is different. For example, for the word "action", it can be a noun or a verb. The part-of-speech probability corresponding to "action" refers to the probability corresponding to when "action" is a noun and the probability corresponding to when "action" is a verb. According to the part-of-speech probability of each candidate word in the second group of candidate words and the corresponding part-of-speech transfer probability, the second parameter of each candidate word in the second group of candidate words is determined. In practical applications, when the candidate words have different parts of speech, the probability of the candidate words being connected to words of different parts of speech is also different. The part-of-speech of the candidate words and the part-of-speech transfer probability are combined to determine the cumulative part-of-speech probability corresponding to all candidate word combinations in the right neighbor words of each candidate word. For example, taking the text to be processed as "action organization", by querying the preset part-of-speech dictionary, it can be determined that the probability of the part of speech of "action" being a verb is 0.3, the probability of the part of speech being a noun is 0.7, the probability of the part of speech of "organization" being a noun is 1, and the probability of a verb being connected to a noun is 0.6, and the probability of a noun being connected to a noun is 0.1. Then, the second parameter corresponding to the part of speech of "organization" and its right neighbor word "action" being a noun is 0.7*0.1*1=0.07, and the second parameter corresponding to the part of speech of "organization" and its right neighbor word "action" being a verb is 0.3*0.6*1=0.18. By comparing the second parameters, it can be determined that the probability of "action" being a verb is the greatest, that is, the second target candidate word corresponding to the maximum second parameter of "organization" is "action" with a verb part of speech. In practical applications, the position of a word in a sentence also has a certain influence on the word's part of speech. For example, in a complete sentence, a noun often begins the sentence, while a verb is relatively rare at the beginning of a sentence. Therefore, the probability of a noun being at the beginning of a sentence is greater than that of a verb. When determining the part of speech of each word in the word segmentation result of the second word order direction, the position of the word in the sentence also needs to be considered. In practical applications, when recording the part-of-speech probability of a word, the preset part-of-speech dictionary includes the part-of-speech probability when the word is at the beginning of a sentence and the part-of-speech probability when the word is at the end of a sentence. The part-of-speech probability when the word is at the beginning of a sentence can be recorded as BEG→n, which represents the probability of a noun at the beginning of a sentence. In practical applications, the part-of-speech index of each word is recorded in the set part-of-speech dictionary. The part-of-speech dictionary can be obtained through training. Data is collected to generate a training set. The training set contains multiple expectations. Based on the language technology platform, the training set is analyzed and counted, and the part of speech corresponding to each word in the training set is calculated. Each part of speech of each word is counted to obtain the part-of-speech index corresponding to each word, and the part-of-speech index of each word obtained by statistics is stored in the part-of-speech dictionary.
[0067] In the above embodiment, for each candidate word in the second group of candidate words, the corresponding part-of-speech probability of each candidate word in the set part-of-speech dictionary is determined, and the second parameter of each candidate word in the second group of candidate words is determined according to the part-of-speech probability corresponding to each candidate word and the corresponding part-of-speech transfer probability. The part-of-speech transfer probability is the connection probability of the parts of speech, and the word segmentation result can be determined according to the part of speech of the candidate word and the probability of the candidate word being connected with words of different parts of speech, and the different probabilities corresponding to different positions of the candidate word in the sentence are also considered, thereby improving the processing effect of the word segmentation result.
[0068] S103: Determine at least one pair of divergent words in the first word segmentation result and the second word segmentation result, wherein a pair of divergent words includes a word in the first word segmentation result and a word in the second word segmentation result, and a pair of divergent words corresponds to a word segmentation difference between the first word segmentation result and the second word segmentation result.
[0069] Here, after determining the first segmentation result and the second segmentation result corresponding to the text to be processed, the first segmentation result and the second segmentation result corresponding to the text to be processed are compared, and at least one pair of divergent words are determined in the first segmentation result and the second segmentation result, wherein each divergent word corresponds to a difference between the first pair of segmentation results and the second segmentation result. If the text to be processed is a simple short sentence, there may be a pair of divergent words between the first segmentation result and the second segmentation result corresponding to the text to be processed. If the text to be processed is a complex long sentence or text, there may be multiple pairs of divergent words between the first segmentation result and the second segmentation result corresponding to the text to be processed. The divergent words refer to the segmentation differences between the first segmentation result and the second segmentation result. For example, the text to be processed is "there are differences in opinions", the first segmentation result is "there are / opinions / divergence", and the second segmentation result is "intentional / see / divergence". There are two pairs of divergent words, the first pair of divergent words is "there are" and "intentional", and the second pair of divergent words is "see" and "opinion". In practical applications, since the first word segmentation result is obtained based on the word frequency probability of the text to be processed, and the second word segmentation result is obtained based on the part-of-speech probability of the text to be processed, there is a high probability that the first word segmentation result and the second word segmentation result will be different. This can help find out the differences between most of the word segmentation results in the text to be processed, and improve the word segmentation processing effect.
[0070] S104: According to a set algorithm, a segmentation is determined from the pair of divergent words as a final segmentation result of the pair of divergent words, so as to obtain a third segmentation result of the text to be processed.
[0071] Here, after determining at least one pair of divergent words, according to the set algorithm, the final segmentation result of each pair of divergent words is determined between the segmentation result corresponding to each pair of divergent words in the first segmentation result and the segmentation result corresponding to each divergent segment in the second segmentation result, and the third segmentation result of the text to be processed is obtained. In practical applications, the bigram algorithm can be used to process the divergent words, so as to determine the segmentation results corresponding to the divergent words in the first segmentation result or the second segmentation result. For example, the first segmentation result is "有 / 意见 / 分歧" (yǒu / yìjiàn / fēnqí), and the second segmentation result is "有意 / 见 / 分歧" (yǒu yì / jiàn / fēnqí). There are two pairs of divergent words. The first pair of divergent words is "有" (yǒu) and "有意" (yǒu yì), and the second pair of divergent words is "见" (jiàn) and "意见" (yìjiàn). By using the bigram algorithm to process the divergent words, after processing the divergent words, the final segmentation result will be selected from each pair of divergent words, and the final segmentation result of the text to be processed will be obtained according to the selected segmentation result. The bigram algorithm can determine the segmentation results of a pair of divergent words "有" (yǒu) and "有意" (yǒu yì). If the bigram algorithm determines that the segmentation results corresponding to the divergent words are "有" (yǒu) and "意见" (yìjiàn), then "有 / 意见" (yǒu / yìjiàn) will be used as the segmentation result at the divergence point, and the third segmentation result of the text to be processed will be determined according to the segmentation result at the divergence point.
[0072] In the above embodiments, according to the first parameter of the candidate words in the first group of candidate words of the text to be processed, the first target candidate word is selected from the first group of candidate words in the reverse direction from the back to the front to obtain the first word segmentation result of the text to be processed. Among them, the first group of candidate words is a group of candidate words obtained by segmenting the text to be processed in the forward direction from the front to the back. The first parameter is the cumulative word frequency probability of all candidate word combinations in the left adjacent words of a candidate word. The first target candidate word is the left adjacent word corresponding to the maximum first parameter of a candidate word. According to the second parameter of the candidate words in the second group of candidate words of the text to be processed, the second target candidate word is selected from the second group of candidate words in the forward direction from the front to the back to obtain the second word segmentation result of the text to be processed. Among them, the second group of candidate words is a group of candidate words obtained by segmenting the text to be processed in the reverse direction from the back to the front. The second parameter is the cumulative part-of-speech probability of all candidate word combinations in the right adjacent words of a candidate word. The second target candidate word is the right adjacent word corresponding to the maximum second parameter of a candidate word. At least one pair of divergent words in the first word segmentation result and the second word segmentation result is determined. Among them, a pair of divergent words includes a word segment in the first word segmentation result and a word segment in the second word segmentation result. A pair of divergent words corresponds to a word segmentation difference between the first word segmentation result and the second word segmentation result. According to the set algorithm, a word segment is determined from a pair of divergent words as the final word segmentation result of the pair of divergent words to obtain the third word segmentation result of the text to be processed. By determining two different word segmentation results of the text to be processed through word frequency and part of speech, it is possible to better determine the divergent words of the text to be processed without increasing the computational complexity of the algorithm, enhance the recognition of divergent words, and analyze the divergent words, which can better process the divergent words and confirm the word segmentation results corresponding to the divergent words, thereby improving the word segmentation processing effect of complex sentences and enhancing the accuracy of word segmentation.
[0073] In one embodiment, as Figure 3 shown, the step of determining a word segment from the pair of divergent words as the final word segmentation result of the pair of divergent words to obtain the third word segmentation result of the text to be processed according to the set algorithm includes:
[0074] S301: Determine the first word segment number of the first word segmentation result and the second word segment number of the second word segmentation result.
[0075] Here, when determining the processing of the divergent words, it is necessary to determine the first word segment number of the first word segmentation result and the second word segment number of the second word segmentation result. The word segment number refers to the number of words divided in the word segmentation result. For example, the word segmentation result corresponding to "have / opinions / differences" has a word segment number of 3.
[0076] S302: Detect whether the first word segment number is the same as the second word segment number to obtain a detection result.
[0077] Here, after determining the number of first participles and the number of second participles, it is detected whether the number of first participles and the number of second participles are the same, and a detection result is obtained, wherein there are two detection results, including the number of first participles and the number of second participles are the same, and the number of first participles and the number of second participles are different. For example, the number of first participles corresponding to the first participle result "there are / opinions / differences" is 3, and the number of second participles corresponding to the second participle result "there are / opinions / differences" is 3. When the number of first participles and the number of second participles are detected, the detection result obtained is that the number of first participles and the number of second participles are the same. When the first participle result is "this / student / will / play / basketball / ?", the number of first participles corresponding to the second participle result is 5, and the number of second participles corresponding to the second participle result "this / student / will / play / basketball / ?" is 4, when detecting whether the number of first participles and the number of second participles are the same, the detection result obtained is that the number of first participles and the number of second participles are different.
[0078] S303: Using a set algorithm corresponding to the detection result, select one segmentation word from the pair of divergent words as the final segmentation result of the pair of divergent words, so as to obtain a third segmentation result of the text to be processed.
[0079] Here, after obtaining the detection result, according to the detection result, a set algorithm corresponding to the detection result is adopted for the divergent word, and one segmentation word is selected from a pair of divergent words as the final segmentation result of the pair of divergent words, so as to obtain the third segmentation result of the text to be processed. The divergent words may correspond to different numbers of segmentations, or divergent words caused by different meanings. The processing methods of divergent words caused by different reasons are different. Therefore, it is necessary to select a suitable processing method for the divergent words according to the detection result. Among them, when the detection result shows that the number of the first segmentation words is different from the number of the second segmentation words, according to the user's needs, the segmentation result corresponding to the appropriate number of segmentations is selected as the third segmentation result of the text to be processed. In practical applications, the segmentation result corresponding to the larger number of segmentations is usually selected as the segmentation result in a pair of divergent words, so as to complete the processing of the divergent words. When the detection result shows that the number of the first segmentation words is the same as the number of the second segmentation words, an algorithm that can process the meaning of the word is selected for the divergent paragraph.
[0080] In the above embodiment, by determining the first word segmentation number of the first word segmentation result and the second word segmentation number of the second word segmentation result, detecting whether the first word segmentation number is the same as the second word segmentation number, obtaining a detection result, and using a set algorithm corresponding to the detection result, selecting a word from a pair of divergent words as the final word segmentation result of the pair of divergent words to obtain a third word segmentation result of the text to be processed, and being able to adopt appropriate processing methods according to divergent paragraphs in different situations, thereby improving the processing effect and speed of divergent paragraphs, and improving the accuracy of processing divergent paragraphs.
[0081] In one embodiment, if Figure 4 As shown, the method adopts a set algorithm corresponding to the detection result to determine a segmentation word from the pair of divergent words as the final segmentation result of the pair of divergent words to obtain a third segmentation result of the text to be processed, including:
[0082] S401: When the detection result indicates that the number of the first segmented words is the same as the number of the second segmented words, determine a first probability and a second probability according to a set dictionary; the set dictionary stores the probabilities of connection between segmented words; the first probability is the probability of connection between each divergent word in at least one divergent word in the first segmented word result and an adjacent word; the second probability is the probability of connection between each divergent word in at least one divergent word in the second segmented word result and an adjacent word.
[0083] Here, when the detection result indicates that the number of the first segmentation words is the same as the number of the second segmentation words, the first probability and the second probability are determined according to the set dictionary, wherein the set dictionary is used to record the connection probabilities between different words, the first probability is the connection probability between one of a pair of divergent words in the first segmentation result and the adjacent word, and the second probability is the connection probability between one of a pair of divergent words in the second segmentation result and the adjacent word. When the detection result indicates that the number of the first segmentation words is the same as the number of the second segmentation words, it indicates that the divergent paragraphs are caused by the difference in word meanings, and the meanings of the divergent words in the first segmentation results and the second segmentation results need to be analyzed in order to process the divergent words accordingly. In practical applications, the connection probability between the divergent words and the adjacent words can be used to determine whether the meaning of the divergent words is a common usage. The connection probability corresponding to the divergent words can be obtained from the set dictionary. For example, the first word segmentation result "have / opinion / disagreement" and the second word segmentation result "have intention / view / disagreement" correspond to two pairs of divergent words, where the first pair of divergent words are "have" and "have intention". For the first pair of divergent words, the first probability of the connection between "have" and "opinion" can be obtained from the setting dictionary, and the second probability of the connection between "have intention" and "view" can be obtained from the setting dictionary. In practical applications, the setting dictionary can count the connection between each word and the corresponding connection probability based on the training set of the word frequency dictionary, and store the connection probability in the setting dictionary. In order to speed up the calculation, the connection probability can be converted into a probability value in the log domain.
[0084] S402: According to the comparison result of the first probability and the second probability, select a segmented word from each pair of the at least one pair of divergent words as a corresponding segmented word result.
[0085] Here, after determining the first probability and the second probability corresponding to at least one pair of divergent words, the first probability corresponding to one of the divergent words in a pair of divergent words is compared with the second probability corresponding to the other divergent word, and according to the comparison result of the first probability and the second probability, the word segmentation result corresponding to the pair of divergent words is determined. In practical applications, the word segmentation result corresponding to the maximum connection probability in a pair of divergent words is used as the word segmentation result corresponding to the pair of divergent words. When the connection probability corresponding to a divergent word is larger, it means that the usage frequency of this divergent word is high, and it is more likely to be the processing result of a pair of divergent words. For example, when the first probability of the connection between "yǒu" and "yìjiàn" in a pair of divergent words is greater than the second probability of the connection between "yǒuyì" and "jiàn" in the pair of divergent words, then the word segmentation result corresponding to the divergent word is "yǒu / yìjiàn".
[0086] S403: Determine the third word segmentation result of the text to be processed according to the word segmentation results corresponding to each pair of divergent words in at least one pair of divergent words in the text to be processed.
[0087] Here, according to the word segmentation results corresponding to at least one pair of divergent words in the text to be processed, the third word segmentation result of the text to be processed is determined. Since the word segmentation results of other text segments are the same except for the divergent parts, after determining the word segmentation results corresponding to at least one pair of divergent words in the text to be processed, the third word segmentation result can be determined according to the word segmentation results corresponding to at least one pair of divergent words and the word segmentation results of the non-divergent text segments in the text to be processed. For example, the text to be processed is "yǒu yìjiàn fēnqí", the first word segmentation result is "yǒu / yìjiàn / fēnqí", the second word segmentation result is "yǒuyì / jiàn / fēnqí", and through setting an algorithm, it is determined that the word segmentation result corresponding to the first pair of divergent words "yǒu" and "yǒuyì" is "yǒu", and the word segmentation result corresponding to the second pair of divergent words "yìjiàn" and "jiàn" is "yìjiàn". According to the word segmentation result corresponding to the divergent part in the text to be processed as "yǒu / yìjiàn" and the word segmentation result corresponding to the non-divergent text segment in the text to be processed " / fēnqí", the third word segmentation result "yǒu / yìjiàn / fēnqí" is determined.
[0088] In the above embodiment, when the detection result represents that the number of words in the first word segmentation is the same as the number of words in the second word segmentation, according to the set dictionary, the first probability and the second probability are determined. The set dictionary stores the connection probabilities between word segmentations. The first probability is the connection probability between each divergent word and its adjacent word in at least one divergent word in the first word segmentation result, and the second probability is the connection probability between each divergent word and its adjacent word in at least one divergent word in the second word segmentation result. According to the comparison result of the first probability and the second probability, one word segmentation is selected from each pair of divergent words in at least one pair of divergent words as the corresponding word segmentation result, which can determine the word segmentation result corresponding to the divergent word when the number of words in the first word segmentation is the same as the number of words in the second word segmentation. By judging the connection probability between the divergent word and its adjacent word to determine the word segmentation result corresponding to the divergent word, the word segmentation result can be made more consistent with the meaning of words used in daily life, improving the accuracy of word segmentation and enhancing the effect of word segmentation processing.
[0089] In one embodiment, as Figure 5 shown, determining the first probability and the second probability according to the set dictionary includes:
[0090] S501: Perform a deletion process on the set dictionary according to the left adjacent word of each pair of divergent words in the at least one pair of divergent words; the words in the set dictionary after the deletion process are the same as the leading words of the left adjacent words of each divergent word in the at least one pair of divergent words.
[0091] Here, since the connection probabilities of a large number of words are recorded in the set dictionary, directly searching for the corresponding connection probabilities between each divergent word in the at least one pair of divergent words and its adjacent word in the set dictionary will take a lot of time, thereby reducing the speed of the word segmentation process. Perform a deletion process on the set dictionary according to the left adjacent word of each divergent word in the at least one pair of divergent words, so that the words in the set dictionary after the deletion process are the same as the leading words of the left adjacent words of each divergent word in the at least one pair of divergent words. Since the leading words corresponding to the left adjacent words of each divergent word in the first word segmentation result are different from the leading words corresponding to the left adjacent words of each divergent word in the second word segmentation result, the words in the set dictionary after the deletion process include the leading words corresponding to the left adjacent words of each divergent word in the first word segmentation result and the leading words corresponding to the left adjacent words of each divergent word in the second word segmentation result. For example, the left adjacent word of a divergent word "opinion" in the first word segmentation result is "have", taking "have" as the leading word, and the left adjacent word of a divergent word "view" in the second word segmentation result is "intentionally", taking "intentionally" as the leading word. Then, when performing the deletion process on the set dictionary, the set dictionary retains the connection probabilities corresponding to the words starting with "have" and the connection probabilities corresponding to the words starting with "intentionally", and deletes the connection probabilities corresponding to other words. In practical applications, the deletion process on the set dictionary can be performed through a prefix tree, a HASH table or other methods.
[0092] S502: Determine the first probability and the second probability according to the set dictionary after the deletion process.
[0093] Here, according to the set dictionary after the deletion process, determine the first probability corresponding to each divergent word in at least one pair of divergent words in the first word segmentation result, and determine the second probability corresponding to each divergent word in at least one divergent word in the second word segmentation result.
[0094] In the above embodiment, the set dictionary is pruned according to the left neighboring words of each pair of divergent words in at least one pair of divergent words. The words in the set dictionary after the pruned words are the same as the first words of the left neighboring words of each pair of divergent words in at least one pair of divergent words. This can speed up the data processing while ensuring the corresponding connection probability between the divergent words and the neighboring words, thereby improving the efficiency of the word segmentation processing and preventing overfitting from occurring, which results in reduced word segmentation effect.
[0095] The present invention also provides an application example. Figure 6 As shown, Figure 6 A schematic diagram showing word segmentation processing of a text to be processed is shown.
[0096] S601: Obtain resource files. Here, resource files refer to dictionaries required when performing word segmentation processing, including dictionaries that record word frequency dictionaries, word part dictionaries, and dictionaries that record connection probabilities between words. Obtaining resource files is completed in an offline state. When generating resource files, first, a sample set must be obtained. The sample set can be composed of labeled test sets such as People's Daily 2014, MSR, PKU, and data collected from the network, wherein the data collected from the network includes collecting network keywords, hot words, and other data, by calculating the word frequency probability corresponding to each word in the sample set, and each word in the sample set and the corresponding word frequency probability form a word frequency dictionary. The generation of the word part dictionary can be through the open source LTP tool, using the 863 word part standard to determine the word part of each word in the sample set, and counting the probability of each word part of each word, to obtain the word part probability, and counting the transition probability of the two parts of speech, and the word part probability and the word part transition probability form a word part dictionary. When counting the transition probability of the two parts of speech, it is necessary to consider the influence of the beginning and end of the sentence on the word part. The word part probability at the beginning of the sentence is represented by BEG, and the word part probability at the end of the sentence is represented by END. The dictionary that records the connection probability between words is obtained by calculating the number of transitions between words in the sample set, and the transition probability is stored. When the word frequency probability, part of speech probability, part of speech transition probability, and transition probability are stored in the corresponding dictionary, the corresponding probability is the probability value converted to the log domain through P = -log (count + 1 / max_count + 1).
[0097] S602: Loading resource files Here, the dictionary required for word segmentation processing is loaded into the memory using the prefix tree method.
[0098] S603: According to the word frequency dictionary, for the first parameter of the first group of candidate words obtained by forward word segmentation of the to-be-processed text, the first target candidate word is selected from the first group of candidate words in the direction from back to front, and the first word segmentation result corresponding to the to-be-processed text is obtained. Here, all candidate words of the to-be-processed text are taken from the direction from front to back to form the first group of candidate words, the word frequency probability of each candidate word is determined in the word frequency dictionary, and the cumulative word frequency probability of all candidate word combinations in the left neighbor words of each candidate word is calculated through the word frequency probability of each candidate word, and the first parameter of each candidate word is obtained, and the left neighbor word corresponding to the maximum first parameter of each candidate word is selected from the first group of candidate words in the direction from back to front as the target candidate word, and the first word segmentation result is obtained.
[0099] S604: According to the part-of-speech dictionary, for the second parameter of the second group of candidate words obtained by backward segmentation of the text to be processed, a second target candidate word is selected from the second group of candidate words in a direction from front to back, and a second segmentation result corresponding to the text to be processed is obtained. Here, all candidate words of the text to be processed are taken from the back to front direction to form a second group of candidate words, the part-of-speech probability of each candidate word is determined in the part-of-speech dictionary, and the cumulative part-of-speech probability of all candidate word combinations in the right neighbor words of each candidate word is calculated through the part-of-speech probability of each candidate word and the part-of-speech transfer probability, and the second parameter of each candidate word is obtained. The right neighbor word corresponding to the maximum second parameter of each candidate word is selected from the second group of candidate words in a direction from front to back as the target candidate word to obtain the second segmentation result.
[0100] S605: Determine at least one pair of divergent words. Here, by comparing the first segmentation result with the second segmentation result, the segmentation results corresponding to the different segmentation results in the first segmentation result and the second segmentation result are determined as divergent words, wherein a pair of divergent words includes a segmentation in the first segmentation result and a segmentation in the second segmentation result, and a pair of divergent words corresponds to a segmentation difference between the first segmentation result and the second segmentation result.
[0101] S606: Based on the set algorithm, determine a segmentation from a pair of divergent words as the final segmentation result of the pair of divergent words. Here, the processing methods selected for divergent words caused by different reasons are different. For divergences caused by different numbers of segmentations, the segmentation results corresponding to the divergent words can be determined in the segmentation results with a larger number of segmentations. If the divergent words are caused by semantics, the divergent words can be processed by the bigram algorithm. Specifically, the connection probability corresponding to the divergent words and the adjacent words in the first segmentation result and the connection probability corresponding to the divergent words and the adjacent words in the second segmentation result are obtained, and the segmentation with a larger connection probability in a pair of divergent words is used as the segmentation result of a pair of divergent words.
[0102] S607: Obtain the third word segmentation result. Here, the word segmentation results of the first word segmentation result and the second word segmentation result other than the divergent word are the same. After determining the word segmentation result corresponding to the divergent word, the third word segmentation result corresponding to the to-be-processed text can be obtained according to the word segmentation results of the first word segmentation result or the second word segmentation result other than the divergent word. The third word segmentation result is the word segmentation result that has completed the processing of the divergent paragraph.
[0103] In order to implement the word segmentation method of the embodiment of the present invention, the embodiment of the present invention also provides a word segmentation device, such as Figure 7 As shown, the word segmentation device includes:
[0104] The first determination unit 701 is used to select a first target candidate word from the first group of candidate words in the to-be-processed text according to the first parameter of the candidate words in the first group of candidate words in the direction from back to front, and obtain a first word segmentation result of the to-be-processed text, wherein the first group of candidate words is a group of candidate words obtained by segmenting the to-be-processed text from front to back, the first parameter is the cumulative word frequency probability of all candidate word combinations in the left neighbor words of a candidate word; the first target candidate word is the left neighbor word corresponding to the maximum first parameter of a candidate word;
[0105] The second determination unit 702 is used to select a second target candidate word from the second group of candidate words in the text to be processed according to the second parameter of the candidate words in the second group of candidate words in the text to be processed in a direction from front to back, and obtain a second word segmentation result of the text to be processed, wherein the second group of candidate words is a group of candidate words obtained by segmenting the text to be processed in a direction from back to front, the second parameter is the accumulated part-of-speech probability of all candidate word combinations in the right neighbor words of a candidate word; the second target candidate word is the right neighbor word corresponding to the maximum second parameter of a candidate word;
[0106] A third determining unit 703 is configured to determine at least one pair of divergent words in the first word segmentation result and the second word segmentation result, wherein the pair of divergent words includes one word in the first word segmentation result and one word in the second word segmentation result, and the pair of divergent words corresponds to a word segmentation difference between the first word segmentation result and the second word segmentation result;
[0107] The fourth determining unit 704 is configured to determine a segmentation word from the pair of divergent words as a segmentation result of the pair of divergent words according to a set algorithm, so as to obtain a third segmentation result of the text to be processed.
[0108] In one embodiment, the first determining unit 701 selects a first target candidate word from the first group of candidate words in the to-be-processed text according to the first parameter of the candidate word in the first group of candidate words in a direction from back to front, and obtains a first word segmentation result of the to-be-processed text, including:
[0109] For each candidate word in the first group of candidate words, determine the word frequency probability corresponding to each candidate word in a set word frequency dictionary, and determine the first parameter corresponding to each candidate word according to the word frequency probability corresponding to each candidate word in the set word frequency dictionary;
[0110] Based on the maximum first parameter of each candidate word, a first target candidate word is selected from the first group of candidate words in a direction from back to front to obtain a first word segmentation result of the text to be processed.
[0111] In one embodiment, the fourth determining unit 704 determines a segmentation from the pair of divergent words as a final segmentation result of the pair of divergent words according to a set algorithm to obtain a third segmentation result of the text to be processed, including:
[0112] Determine the number of first segmented words of the first segmented result and the number of second segmented words of the second segmented result;
[0113] Detecting whether the number of the first participles is the same as the number of the second participles, and obtaining a detection result;
[0114] A set algorithm corresponding to the detection result is used to select a segmentation word from the pair of divergent words as a final segmentation result of the pair of divergent words, so as to obtain a third segmentation result of the text to be processed.
[0115] In one embodiment, the fourth determining unit 704 uses a set algorithm corresponding to the detection result to determine a segmentation from the pair of divergent words as a final segmentation result of the pair of divergent words to obtain a third segmentation result of the text to be processed, including:
[0116] In the case where the detection result indicates that the number of the first segmented words is the same as the number of the second segmented words, a first probability and a second probability are determined according to a set dictionary; the set dictionary stores the probability of connection between segmented words; the first probability is the probability of connection between each divergent word in at least one divergent word in the first segmented word result and an adjacent word; the second probability is the probability of connection between each divergent word in at least one divergent word in the second segmented word result and an adjacent word;
[0117] According to the comparison result of the first probability and the second probability, selecting a segmentation word from each pair of the at least one pair of divergent words as a corresponding segmentation result;
[0118] A third word segmentation result of the text to be processed is determined according to the word segmentation results corresponding to the divergent words in the text to be processed.
[0119] In one embodiment, the fourth determining unit 704 determines the first probability and the second probability according to the setting dictionary, including:
[0120] According to the left neighbor words of each of the at least one pair of divergent words, the set dictionary is subjected to deletion processing; the words in the set dictionary after the deletion processing are the same as the paragraph head words of the left neighbor words of each of the at least one pair of divergent words;
[0121] A first probability and a second probability are determined according to the setting dictionary after the deletion process.
[0122] In one embodiment, the first determining unit 701 determines, for each candidate word in the first group of candidate words, a word frequency probability corresponding to each candidate word in a set word frequency dictionary, and the method further includes:
[0123] When a candidate word in the first group of candidate words does not have a corresponding word frequency probability in the word frequency dictionary, the word frequency of the candidate word without a corresponding word frequency probability is set to a set value; the set value is a value greater than 0.
[0124] In one embodiment, the second determining unit 702 determines the second parameter of the candidate word in the second group of candidate words in the text to be processed, including:
[0125] For each candidate word in the second group of candidate words, determine the part-of-speech probability corresponding to each candidate word in the set part-of-speech dictionary, and determine the second parameter of each candidate word in the second group of candidate words based on the part-of-speech probability corresponding to each candidate word and the corresponding part-of-speech transfer probability; the part-of-speech transfer probability is the connection probability of the part-of-speech.
[0126] In actual application, the first determining unit 701, the second determining unit 702, the third determining unit 703, and the fourth determining unit 704 can be implemented by a processor in the word segmentation device. Of course, the processor needs to run the program stored in the memory to implement the functions of the above program modules.
[0127] It should be noted that the above Figure 7 The word segmentation device provided in the embodiment only uses the division of the above-mentioned program modules as an example when performing word segmentation. In practical applications, the above-mentioned processing can be assigned to different program modules as needed, that is, the internal structure of the device is divided into different program modules to complete all or part of the processing described above. In addition, the word segmentation device provided in the above embodiment and the word segmentation method embodiment belong to the same concept, and the specific implementation process is detailed in the method embodiment, which will not be repeated here.
[0128] Based on the hardware implementation of the above program modules and in order to implement the method of the embodiment of the present invention, the embodiment of the present invention further provides an electronic device, Figure 8 FIG. 1 is a schematic diagram of the hardware structure of an electronic device according to an embodiment of the present invention. Figure 8 As shown, the electronic equipment includes:
[0129] Communication interface 1, capable of exchanging information with other devices such as network devices;
[0130] The processor 2 is connected to the communication interface 1 to implement information exchange with other devices and is used to execute the word segmentation method provided by one or more technical solutions when running a computer program. The computer program is stored in the memory 3.
[0131] Of course, in actual application, the various components in the electronic device are coupled together through the bus system 4. It can be understood that the bus system 4 is used to realize the connection and communication between these components. In addition to the data bus, the bus system 4 also includes a power bus, a control bus and a status signal bus. However, for the sake of clarity, Figure 8 Various buses are labeled as bus system 4 .
[0132] The memory 3 in the embodiment of the present invention is used to store various types of data to support the operation of the electronic device. Examples of these data include: any computer program for operating on the electronic device. It can be understood that the memory 3 can be a volatile memory or a non-volatile memory, and can also include both volatile and non-volatile memories. Among them, the non-volatile memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), a magnetic random access memory (FRAM), a ferromagnetic random access memory, a flash memory, a magnetic surface memory, an optical disc, or a read-only optical disc (CD-ROM); the magnetic surface memory can be a disk memory or a tape memory. The volatile memory can be a random access memory (RAM), which is used as an external cache.By way of example but not limitation, many forms of RAM are available, such as static random access memory (SRAM), synchronous static random access memory (SSRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM), direct memory bus random access memory (DRRAM). The memory 3 described in the embodiments of the present invention is intended to include but is not limited to these and any other suitable types of memory.
[0133] The method disclosed in the above embodiment of the present invention can be applied to the processor 2, or implemented by the processor 2. The processor 2 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the hardware integrated logic circuit in the processor 2 or the instruction in the form of software. The above processor 2 can be a general-purpose processor, a DSP, or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. The processor 2 can implement or execute the methods, steps and logic block diagrams disclosed in the embodiment of the present invention. The general-purpose processor can be a microprocessor or any conventional processor, etc. In combination with the steps of the method disclosed in the embodiment of the present invention, it can be directly embodied as a hardware decoding processor to execute, or it can be executed by a combination of hardware and software modules in the decoding processor. The software module can be located in a storage medium, which is located in the memory 3. The processor 2 reads the program in the memory 3 and completes the steps of the above method in combination with its hardware.
[0134] When the processor 2 executes the program, the corresponding processes in the various methods of the embodiments of the present invention are implemented, which will not be described here for the sake of brevity.
[0135] In an exemplary embodiment, the embodiment of the present invention further provides a storage medium, namely a computer storage medium, specifically a computer readable storage medium, for example, including a memory 3 storing a computer program, and the above-mentioned computer program can be executed by a processor 2 to complete the steps of the above-mentioned method. The computer readable storage medium can be a memory such as FRAM, ROM, PROM, EPROM, EEPROM, Flash Memory, magnetic surface storage, optical disk, or CD-ROM.
[0136] In the several embodiments provided in the present application, it should be understood that the disclosed devices, terminals and methods can be implemented in other ways. The device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as: multiple units or components can be combined, or can be integrated into another system, or some features can be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the components shown or discussed can be through some interfaces, and the indirect coupling or communication connection of the devices or units can be electrical, mechanical or other forms.
[0137] The units described above as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units; some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0138] In addition, all functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may be separately used as a unit, or two or more units may be integrated into one unit; the above-mentioned integrated units may be implemented in the form of hardware or in the form of hardware plus software functional units.
[0139] A person of ordinary skill in the art can understand that: all or part of the steps of implementing the above-mentioned method embodiment can be completed by hardware related to program instructions, and the aforementioned program can be stored in a computer-readable storage medium, which, when executed, executes the steps of the above-mentioned method embodiment; and the aforementioned storage medium includes: various media that can store program codes, such as mobile storage devices, ROM, RAM, disks or optical disks.
[0140] Alternatively, if the above-mentioned integrated unit of the present invention is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiment of the present invention can be essentially or partly reflected in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium and includes several instructions for an electronic device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the methods described in each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as mobile storage devices, ROM, RAM, magnetic disks or optical disks.
[0141] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art can easily think of changes or substitutions within the technical scope disclosed by the present invention, which should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.
Claims
1. A word segmentation method, characterized in that: include: According to the first parameter of the candidate words in the first group of candidate words of the text to be processed, a first target candidate word is selected from the first group of candidate words in a direction from back to front to obtain a first word segmentation result of the text to be processed, wherein the first group of candidate words is a group of candidate words obtained by segmenting the text to be processed in a direction from front to back, the first parameter is the cumulative word frequency probability of all candidate word combinations in the left neighbor words of a candidate word; the first target candidate word is the left neighbor word corresponding to the maximum first parameter of a candidate word; According to the second parameter of the candidate words in the second group of candidate words of the to-be-processed text, a second target candidate word is selected from the second group of candidate words in a direction from front to back, to obtain a second word segmentation result of the to-be-processed text, wherein the second group of candidate words is a group of candidate words obtained by segmenting the to-be-processed text in a direction from back to front, the second parameter is the accumulated part-of-speech probability of all candidate word combinations in the right neighbor words of a candidate word; the second target candidate word is the right neighbor word corresponding to the maximum second parameter of a candidate word; Determine at least one pair of divergent words in the first word segmentation result and the second word segmentation result, wherein the pair of divergent words includes a word in the first word segmentation result and a word in the second word segmentation result, and the pair of divergent words corresponds to a word segmentation difference between the first word segmentation result and the second word segmentation result; Determine the number of first segmented words of the first segmented result and the number of second segmented words of the second segmented result; Detecting whether the number of the first participles is the same as the number of the second participles, and obtaining a detection result; A set algorithm corresponding to the detection result is used to select a segmentation word from the pair of divergent words as a final segmentation result of the pair of divergent words, so as to obtain a third segmentation result of the text to be processed.
2. The word segmentation method according to claim 1, characterized in that: The step of selecting a first target candidate word from the first group of candidate words in the to-be-processed text according to the first parameter of the candidate word in the first group of candidate words in a direction from back to front to obtain a first word segmentation result of the to-be-processed text includes: For each candidate word in the first group of candidate words, determine the word frequency probability corresponding to each candidate word in a set word frequency dictionary, and determine the first parameter corresponding to each candidate word according to the word frequency probability corresponding to each candidate word in the set word frequency dictionary; Based on the maximum first parameter of each candidate word, a first target candidate word is selected from the first group of candidate words in a direction from back to front to obtain a first word segmentation result of the text to be processed.
3. The word segmentation method according to claim 1, wherein the step of using a set algorithm corresponding to the detection result to determine a word segmentation from the pair of divergent words as a final word segmentation result of the pair of divergent words to obtain a third word segmentation result of the text to be processed comprises: When the detection result indicates that the number of the first participles is the same as the number of the second participles, determining a first probability and a second probability according to a set dictionary; The setting dictionary stores the probability of connection between segmented words; the first probability is the probability of connection between each segmented word in at least one segmented word in the first segmented word result and an adjacent word; the second probability is the probability of connection between each segmented word in at least one segmented word in the second segmented word result and an adjacent word; According to the comparison result of the first probability and the second probability, selecting a segmentation word from each pair of the at least one pair of divergent words as a corresponding segmentation result; A third word segmentation result of the text to be processed is determined according to the word segmentation result corresponding to each pair of divergent words in at least one pair of divergent words in the text to be processed.
4. The word segmentation method according to claim 3, characterized in that: The determining the first probability and the second probability according to the setting dictionary includes: According to the left neighbor words of each of the at least one pair of divergent words, the set dictionary is subjected to deletion processing; the words in the set dictionary after the deletion processing are the same as the paragraph head words of the left neighbor words of each of the at least one pair of divergent words; A first probability and a second probability are determined according to the setting dictionary after the deletion process.
5. The word segmentation method according to claim 2, characterized in that: For each candidate word in the first group of candidate words, determining the word frequency probability corresponding to each candidate word in a set word frequency dictionary, the method further includes: When a candidate word in the first group of candidate words does not have a corresponding word frequency probability in the word frequency dictionary, the word frequency of the candidate word without a corresponding word frequency probability is set to a set value; the set value is a value greater than 0.
6. The word segmentation method according to claim 1, characterized in that: The second parameter of the candidate word in the second group of candidate words according to the text to be processed includes: For each candidate word in the second group of candidate words, determine the part-of-speech probability corresponding to each candidate word in the set part-of-speech dictionary, and determine the second parameter of each candidate word in the second group of candidate words based on the part-of-speech probability corresponding to each candidate word and the corresponding part-of-speech transfer probability; the part-of-speech transfer probability is the connection probability of the part-of-speech.
7. A word segmentation device, characterized in that: include: A first determination unit is used to select a first target candidate word from a first group of candidate words in a text to be processed according to a first parameter of the candidate words in the first group of candidate words in a direction from back to front, to obtain a first word segmentation result of the text to be processed, wherein the first group of candidate words is a group of candidate words obtained by segmenting the text to be processed in a direction from front to back, and the first parameter is a cumulative word frequency probability of all candidate word combinations in the left neighboring words of a candidate word; The first target candidate word is a left neighbor word corresponding to the maximum first parameter of a candidate word; A second determination unit is used to select a second target candidate word from the second group of candidate words in the text to be processed according to the second parameter of the candidate words in the second group of candidate words in the text to be processed in a direction from front to back, so as to obtain a second word segmentation result of the text to be processed, wherein the second group of candidate words is a group of candidate words obtained by segmenting the text to be processed in a direction from back to front, the second parameter is the accumulated part-of-speech probability of all candidate word combinations in the right neighboring words of a candidate word; the second target candidate word is the right neighboring word corresponding to the maximum second parameter of a candidate word; A third determining unit is used to determine at least one pair of divergent words in the first word segmentation result and the second word segmentation result, wherein the pair of divergent words includes a word in the first word segmentation result and a word in the second word segmentation result, and the pair of divergent words corresponds to a word segmentation difference between the first word segmentation result and the second word segmentation result; The fourth determination unit is used to determine the first word segmentation number of the first word segmentation result and the second word segmentation number of the second word segmentation result; detect whether the first word segmentation number is the same as the second word segmentation number to obtain a detection result; use a set algorithm corresponding to the detection result to select a word from the pair of divergent words as the final word segmentation result of the pair of divergent words to obtain a third word segmentation result of the text to be processed.
8. An electronic device, characterized in that: include: a processor and a memory for storing a computer program capable of being executed on the processor, Wherein, when the processor is used to run the computer program, it executes the steps of the method described in any one of claims 1 to 6.
9. A storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
