A method, device and computer-readable storage medium for processing statements
By performing word segmentation, reverse order conversion and language model prediction on sentences with missing words or missing words in pronunciation, the problem of missing words or missing words in pronunciation is solved, and the accuracy and interaction of recognition are improved. Fluency.
Patent Information
- Application Number
- CN202110438964.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-04-22
- Publication Date
- 2025-02-25
- Estimated Expiration
- 2041-04-22
AI Technical Summary
During the speech recognition process, it is common to miss words or words at the beginning of a sentence, which leads to incomplete text statements after identification and affects the accuracy of subsequent processing.
By performing word segmentation processing on the sentence to be processed, after reverse order transformation, the first word of the sentence is predicted using the trained reverse order language model to generate a predicted reverse order word sequence, thereby completing the missing word or missing word at the beginning of the sentence.
It effectively solves the problem of missing words or missing words at the beginning of a sentence, and improves the accuracy of speech recognition and the fluency of speech interaction.
Smart Images

Figure CN113051915B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of text processing, and more particularly to a method, device and computer-readable storage medium for sentence processing. Background Art
[0002] With the gradual development of science and technology, the application of speech recognition technology is becoming more and more extensive. For example, smart robots, smart speakers, and smart phones will recognize speech during speech interaction, and convert the recognized speech into text sentences before entering the next step of processing. In order to ensure the integrity and fluency of speech interaction, it is particularly important to convert speech into correct and complete text sentences.
[0003] During the speech recognition process, if the collected speech has missing words or noise at the beginning of a sentence due to line modification, the speech recognition text sentence generated after recognition by the speech recognition module is prone to missing words or missing characters at the beginning of the sentence, which will affect all subsequent links. Therefore, completing and correcting the missing words in the text sentences with missing words or missing characters at the beginning of the sentence has become an urgent problem to be solved. Summary of the invention
[0004] The purpose of the embodiments of the present application is to provide a sentence processing method, device and computer-readable storage medium for completing and correcting missing characters in text sentences with missing characters or words at the beginning of the sentence.
[0005] In a first aspect, an embodiment of the present application provides a method for sentence processing, including: performing word segmentation on a sentence to be processed to obtain a normal word sequence of the sentence to be processed; performing reverse conversion on the normal word sequence to obtain a reverse word sequence of the sentence to be processed; using a trained reverse language model to predict the next word of the last word in the reverse word sequence to generate a predicted reverse word sequence; and obtaining a sentence without missing words corresponding to the sentence to be processed based on the predicted reverse word sequence.
[0006] In the above implementation process, by swapping the word order of the sentence to be processed, it is convenient to use the language model to predict the word at the beginning of the sentence to be processed, and further predict the next word of the last word in the reverse word order through the trained reverse language model, and correct it according to the predicted reverse word sequence, thereby effectively solving the problem of missing words or characters at the beginning of the sentence, and further ensuring the accuracy of speech recognition during voice interaction.
[0007] In combination with the first aspect, in one embodiment, the word segmentation processing of the sentence to be processed to obtain the normal word sequence of the sentence to be processed includes: performing word segmentation processing on the sentence to be processed to obtain the initial word sequence of the sentence to be processed; replacing the keywords in the initial word sequence with keyword tags to obtain the normal word sequence.
[0008] In the above implementation process, by replacing the keywords in the sentence to be processed with the keyword markers, it is convenient to perform subsequent confirmation of the recognized keywords during the voice interaction process, thereby improving the accuracy of recognition.
[0009] In combination with the first aspect, in another embodiment, before using the trained reverse language model to predict the next word of the last word in the reverse word sequence, the method also includes: performing word segmentation processing on at least one sentence in the corpus to obtain an initial training word sequence for each of the at least one sentence; replacing the keywords in the initial training word sequence of each sentence with keyword tags to obtain the training word sequence of each sentence; adding a start tag before the first word in the training word sequence of each sentence to obtain the marked training word sequence of each sentence; performing reverse conversion on the marked training word sequence of each sentence to obtain the reverse training word sequence of each sentence; and training a statistical language model using the reverse training word sequence of at least one sentence to obtain the trained reverse language model.
[0010] In the above implementation process, the statistical language model is trained using the corpus to obtain a reverse language model, which can complete the missing ending words in the reverse language according to the existing reverse language, and further complete the missing characters or words at the beginning of the sentence in the forward language.
[0011] In combination with the first aspect, in another embodiment, the method of using a trained reverse language model to predict the next word of the last word in the reverse word sequence to generate a predicted reverse word sequence includes: using the trained reverse language model to calculate the probability of all words in the corpus being the next word of the last word in the reverse word sequence; selecting the word with the highest probability as a candidate word; and adding the candidate word to the reverse word sequence to generate the predicted reverse word sequence.
[0012] In the above implementation process, the probability of each word in the corpus being a predicted word is calculated through the reverse language model, and the word with the highest probability is selected as the final predicted word, thereby realizing the prediction of missing words in the reverse sentence.
[0013] In combination with the first aspect, in another embodiment, the method of obtaining a sentence without missing words corresponding to the sentence to be processed based on the predicted reverse word sequence includes: judging whether the candidate word is the starting tag; if the candidate word is the starting tag, deleting the starting tag in the predicted reverse word sequence, and then converting the predicted reverse word sequence into a positive order to obtain a sentence without missing words corresponding to the sentence to be processed; if the candidate word is not the starting tag, judging whether the candidate word is a keyword tag; if the candidate word is a keyword tag, retaining the candidate word in the predicted reverse word sequence, and using the trained reverse language model to predict the next word of the candidate word in the predicted reverse word sequence to obtain the next candidate word, and repeat the above process; if the candidate word is not a keyword tag, obtain the pinyin first letter of the first character in the candidate word, and determine whether the pinyin first letter belongs to one of the preset first letter sets; if the pinyin first letter belongs to any one of the preset first letter sets, retain the candidate word in the predicted reverse word sequence, and use the trained reverse language model to predict the next word of the candidate word in the predicted reverse word sequence to obtain the next candidate word, and repeat the above process; if the pinyin first letter does not belong to any one of the preset first letter sets, after deleting the candidate word in the predicted reverse word sequence, the predicted reverse word sequence is converted into a positive order to obtain a sentence without missing words corresponding to the sentence to be processed.
[0014] In the above implementation process, whether the candidate word is an over-complemented word is determined by the first pinyin letter of the first character in the candidate word. If it is an over-complemented word, the word is deleted and the word sequence is transposed to obtain a sentence without missing words, thereby effectively avoiding over-complementation of the sentence due to the speech recognition engine itself.
[0015] In a second aspect, an embodiment of the present application provides a device for sentence processing, the device comprising: a word segmentation module, used to perform word segmentation processing on a sentence to be processed to obtain a normal word sequence of the sentence to be processed; a conversion module, used to perform reverse conversion on the normal word sequence to obtain a reverse word sequence of the sentence to be processed; a prediction module, used to use a trained reverse language model to predict the next word of the last word in the reverse word sequence to generate a predicted reverse word sequence; a processing module, used to obtain a sentence without missing words corresponding to the sentence to be processed according to the predicted reverse word sequence.
[0016] In combination with the second aspect, in one implementation, the word segmentation module is specifically used to: perform word segmentation on the sentence to be processed to obtain an initial word sequence of the sentence to be processed; replace keywords in the initial word sequence with keyword tags to obtain the normal word sequence.
[0017] In combination with the second aspect, in another embodiment, the prediction module is also used to: perform word segmentation on at least one sentence in the corpus to obtain an initial training word sequence for each of the at least one sentence; replace the keywords in the initial training word sequence of each sentence with keyword tags to obtain the training word sequence of each sentence; add a start tag before the first word in the training word sequence of each sentence to obtain the marked training word sequence of each sentence; perform reverse conversion on the marked training word sequence of each sentence to obtain a reverse training word sequence for each sentence; and train a statistical language model using the reverse training word sequence of at least one sentence to obtain the trained reverse language model.
[0018] In combination with the second aspect, in another embodiment, the prediction module is specifically used to: use the trained reverse language model to calculate the probability of all words in the corpus being the next word of the last word in the reverse word sequence; select the word with the highest probability as the candidate word; add the candidate word to the reverse word sequence to generate the predicted reverse word sequence.
[0019] In combination with the second aspect, in another embodiment, the processing module is specifically used to: determine whether the candidate word is the starting tag; if the candidate word is the starting tag, after deleting the starting tag in the predicted reverse word sequence, the predicted reverse word sequence is converted into a positive order to obtain a sentence without missing words corresponding to the sentence to be processed; if the candidate word is not the starting tag, determine whether the candidate word is a keyword tag; if the candidate word is a keyword tag, retain the candidate word in the predicted reverse word sequence, and use the trained reverse language model to predict the next word of the candidate word in the predicted reverse word sequence to obtain the next candidate word, and repeat the above process; If the candidate word is not a keyword tag, obtain the first pinyin letter of the first character in the candidate word, and determine whether the first pinyin letter belongs to one of the preset first letter sets; if the first pinyin letter belongs to any one of the preset first letter sets, retain the candidate word in the predicted reverse word sequence, and use the trained reverse language model to predict the next word of the candidate word in the predicted reverse word sequence to obtain the next candidate word, and repeat the above process; if the first pinyin letter does not belong to any one of the preset first letter sets, after deleting the candidate word in the predicted reverse word sequence, the predicted reverse word sequence is converted into a forward order to obtain a sentence without missing words corresponding to the sentence to be processed.
[0020] In a third aspect, an embodiment of the present application provides a statement processing device, comprising: a processor, a memory and a bus, wherein the processor is connected to the memory via the bus, and the memory stores computer-readable instructions. When the computer-readable instructions are executed by the processor, they are used to implement the method provided in the first aspect above.
[0021] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a server, the steps in the method provided in the first aspect are implemented.
[0022] Other features and advantages of the present application will be described in the following description, and partly become apparent from the description, or be understood by practicing the embodiments of the present application. The purpose and other advantages of the present application can be realized and obtained by the structures specifically pointed out in the written description, claims, and drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments of the present application will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0024] Figure 1 A flow chart of a method for statement processing provided in an embodiment of the present application;
[0025] Figure 2 A flow chart of a method for obtaining a sentence without missing words based on a predicted reverse word sequence provided in an embodiment of the present application;
[0026] Figure 3 A structural block diagram of a device for sentence processing provided in an embodiment of the present application;
[0027] Figure 4 A block diagram of another device structure for statement processing provided in an embodiment of the present application. DETAILED DESCRIPTION
[0028] The technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all of the embodiments. The components of the embodiments of the present application described and shown in the drawings here can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the application claimed for protection, but merely represents the selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present application.
[0029] It should be noted that similar reference numerals and letters represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further defined and explained in subsequent drawings. At the same time, in the description of this application, the terms "first", "second", etc. are only used to distinguish the description and cannot be understood as indicating or implying relative importance.
[0030] With the in-depth development of digital and intelligent technologies in various fields, more intelligent devices play an important role in life. Various intelligent voice devices, such as smart speakers, smart phones, smart robots and other devices can support voice dialogue, and can control the device through voice dialogue to complete ticket booking, chatting and other customer-required functions. These intelligent voice devices basically include speech recognition (ASR, Automatic Speech Recognition), natural language understanding (NLU, Natural Language Processing), dialogue management (DM, Dialog Management), natural language generation (NLG, Natural Language Generation) and speech synthesis (TTS, Text To Speech) and other modules. The ASR module performs speech recognition work at the forefront of the speech recognition process. If the collected speech has missing words or noise at the beginning of the sentence due to the modification of the line, the speech recognition text sentence generated after the speech recognition module is easily missing words or missing words at the beginning of the sentence, which will affect various downstream tasks. Therefore, providing a method for text sentence processing to complete the text with missing words or missing words has become an urgent problem to be solved.
[0031] Combine the following Figure 1 A statement processing method provided in an embodiment of the present application is described.
[0032] Please refer to Figure 1 , Figure 1 A flowchart of a method for sentence processing provided in an embodiment of the present application, which can be applied to Figure 3 In the device 300 for sentence processing shown in FIG. 1 , specifically, Figure 1 The methods shown include:
[0033] 110, performing word segmentation processing on the sentence to be processed to obtain a normal word sequence of the sentence to be processed.
[0034] Perform word segmentation on the sentence to be processed to obtain the normal word sequence of the sentence to be processed, including:
[0035] Perform word segmentation on the sentence to be processed to obtain the initial word sequence of the sentence to be processed;
[0036] The keywords in the initial word sequence are replaced with keyword tags to obtain a normal word sequence.
[0037] As an embodiment, the processor obtains text generated after recognition by the speech recognition module, divides the text into sentences using punctuation marks such as periods, semicolons, question marks or exclamation marks, and generates sentences to be processed.
[0038] In some embodiments, the text generated after recognition by the speech recognition module includes only one sentence, and the sentence is the sentence to be processed.
[0039] It should be noted that the statement to be processed in the present application may also be a statement to be processed input by a user, or a statement to be processed sent by other terminals or devices, but the present application is not limited thereto.
[0040] As an embodiment, the sentence to be processed is sentence, and the sentence to be processed is segmented to generate a normal word sequence {W1, W2, ...W n-1 , ,W n}, where W n Indicates the nth word in the sentence sentence;
[0041] In some embodiments, the types of keywords to be replaced and the corresponding keyword tags are pre-set in the database. During the keyword replacement process, it is identified whether the keyword to be replaced appears in the above word sequence. If the keyword to be replaced appears, it is replaced with the corresponding keyword tag.
[0042] If the keyword that needs to be replaced does not appear in the normal word sequence, the steps without replacement are performed and the next related operations are directly performed.
[0043] It should be noted that the keywords in the embodiments of the present application may refer to a type of words in a sentence that require further confirmation, or may refer to a type of words in a sentence that require special attention, but the present application is not limited thereto.
[0044] As an embodiment, if the sentence to be processed contains keywords such as time, quantity, and item type, the keywords are replaced with corresponding tags.
[0045] As an embodiment, the keyword corresponding to the keyword time is marked as TIME, the keyword corresponding to the keyword quantity is marked as NUM, and the keyword corresponding to the keyword item type is marked as TYPE;
[0046] As an embodiment, the voice actually uttered by the user is "buy 3 bottles of mineral water", but the sentence generated after processing by the voice recognition module is: "3 bottles of mineral water", so there is a missing word at the beginning of the sentence. In order to complete the missing word at the beginning of the sentence, the sentence generated after processing by the voice recognition module is used as the sentence to be processed, that is, the sentence to be processed is: "3 bottles of mineral water".
[0047] It should be noted that in the embodiments of the present application, the situation where a word is missing at the beginning of a sentence may be one word missing at the beginning of the sentence, two words missing at the beginning of the sentence, or three words missing at the beginning of the sentence, but the present application is not limited thereto.
[0048] After word segmentation for the sentence "3 bottles of mineral water", the normal word sequence generated is: "{3, bottle, mineral water}", where the first word is the keyword "3" indicating quantity, and it is replaced with the keyword marker "NUM" indicating quantity. The word sequence generated after replacement is: "{NUM, bottle, mineral water}", that is, the word sequence after replacement is: "{NUM, W2, W3}".
[0049] As an embodiment, in the subsequent voice interaction process, if the smart device recognizes a keyword tag in the sentence, the smart device will perform further polling;
[0050] As an embodiment, further polling work may be that the smart device issues a voice again, asking the user: "Please tell me the amount of mineral water you need"; or the smart device prompts the user in the form of text on the display interface: "Please enter the amount of mineral water you need", and displays an input window; or the smart device prompts the user in the form of text and voice at the same time: "Please enter the amount of mineral water you need", and displays an input window; further, the smart device will confirm the corresponding quantity based on the user's answer or the information entered by the user.
[0051] In the above implementation process, by replacing the keywords in the sentence to be processed with keyword tags, in the subsequent voice interaction process, it is convenient for the smart device to perform subsequent confirmation of the recognized keywords, thereby improving the accuracy of recognition.
[0052] 120, reverse the normal word sequence to obtain a reverse word sequence of the sentence to be processed.
[0053] As an embodiment, if there is no keyword to be replaced in the normal word sequence, the normal word sequence {W1, W2, ..., W n-1 , W n} to perform reverse transformation to obtain the reverse word sequence of the sentence to be processed {W n , W n-1 ,…,W2,W1}.
[0054] As an embodiment, if a keyword that needs to be replaced appears in a normal word sequence, and the word sequence generated after the keyword replacement in step 110 is: "{NUM, W2, W3}", the word sequence after the keyword replacement is reversed to obtain the reverse word sequence of the sentence to be processed: "{W3, W2, NUM}". That is, the reverse word sequence of the sentence to be processed sentence "3 bottles of mineral water" after reverse conversion is: "{mineral water, bottle, NUM}".
[0055] 130, using the trained reverse language model to predict the next word of the last word in the reverse word sequence, and generate a predicted reverse word sequence.
[0056] Before predicting the next word of the last word in the reverse word sequence using the trained reverse language model, the method further includes:
[0057] Performing word segmentation processing on at least one sentence in the corpus to obtain an initial training word sequence for each sentence in the at least one sentence;
[0058] Replace the keywords in the initial training word sequence of each sentence with the keyword marker to obtain the training word sequence of each sentence;
[0059] Add a start tag before the first word in the training word sequence of each sentence to obtain a marked training word sequence for each sentence;
[0060] Reverse transform the marked training word sequence of each sentence to obtain the reverse training word sequence of each sentence;
[0061] The statistical language model is trained using a reverse training word sequence of at least one sentence to obtain a trained reverse language model.
[0062] The trained reverse language model is used to predict the next word of the last word in the reverse word sequence to generate a predicted reverse word sequence, including:
[0063] Use the trained reverse language model to calculate the probability of all words in the corpus being the next word of the last word in the reverse word sequence;
[0064] Select the word with the highest probability as the candidate word;
[0065] The candidate words are added to the reverse word sequence to generate a predicted reverse word sequence.
[0066] As an embodiment, before using the trained reverse order language model to predict the next word of the last word in the reverse order word sequence, it is necessary to train the text corpus to obtain the reverse order language model.
[0067] It should be noted that the process of training the text corpus and obtaining the reverse language model can be after step 120 and before step 130, or after step 110 and before step 120, or before step 110, that is, before applying the reverse language model, it is sufficient to obtain the reverse language model, and the stage of the training process of the reverse language model is not limited.
[0068] As an embodiment, the training process of the reverse order language model is before step 110, and the training process of the reverse order language model is specifically as follows:
[0069] Generate standard text corpus dataset Corpus text ;
[0070] It should be noted that the standard text corpus dataset Corpus text The data source may be manually annotated text data in a speech recognition dataset, such as Switchboard, TIMIT and other datasets, or text data of video subtitles, or a collection of manually annotated text data in a speech recognition dataset and text data of video subtitles, but the present application is not limited thereto.
[0071] As an example, the standard text corpus dataset Corpus text It is a collection of manually annotated text data and video subtitle text data in the speech recognition dataset, and a standard text corpus dataset Corpus text Sentence segmentation is performed based on punctuation marks such as periods, semicolons, question marks, or exclamation marks in the text. The standard text corpus dataset Corpus after segmentation text It can be expressed as {sentence1, ..., sentence k ,..., sentence n}, where k is the sentence number and n is the total number of sentences in the text.
[0072] Corpus text Perform word segmentation on the sentences in to obtain the initial training word sequence of the sentences;
[0073] It should be noted that the sentences used for training can be the standard text corpus dataset Corpus text Any sentence in the standard text corpus dataset Corpus text Any two sentences in the standard text corpus dataset Corpus text Any three sentences in the standard text corpus dataset Corpus text However, the present application is not limited thereto.
[0074] As an example, the sentences used in the training are from the standard text corpus dataset Corpus text All words in;
[0075] Corpus text Any sentence in i , perform word segmentation and get the sentence sentence i The initial training word sequence Here, k is the word number, 1≤k≤10. In some embodiments, when K>10, the words after the 11th word are deleted, and only the first 10 words are retained, so as to further reduce the processing time and improve the processing efficiency of the statement.
[0076] Furthermore, the keywords appearing in the sentence are replaced with keyword markers. i If the second word in the sentence is a word indicating time, it is replaced with the time marker TIME, and the generated sentence is sentence i The training word sequence
[0077] In sentence i The training word sequence The first word in Add the start tag START before the sentence sentencei, indicating that the sentence is from the word The marked training word sequence is
[0078] The labeled training word sequence is Perform reverse transformation to get sentence i Reverse training word sequence
[0079] And the standard text corpus dataset Corpus text Each sentence in the sentence iSimilar processing is used to generate a reverse training word sequence corresponding to each sentence. The reverse training word sequences corresponding to all sentences constitute the set of training corpus Corpus text-for-model ;
[0080] Using the Corpus collection of training corpus text-for-model The statistical language model is trained to generate a reverse language model.
[0081] It should be noted that in the embodiments of the present application, the statistical language model may be a 3-gram language model, a 2-gram language model, or a neural network language model, but the present application is not limited thereto.
[0082] As an embodiment, the statistical language model in this application is a 3-gram language model, using the set of training corpus Corpus text-for-model Train the 3-gram language model to generate a reverse language model.
[0083] In the above implementation process, the statistical language model is trained using the corpus to obtain a reverse language model, which can complete the missing ending words in the reverse language according to the existing reverse language, and further complete the missing characters or words at the beginning of the sentence in the forward language.
[0084] As an embodiment, the reverse order language model trained above is used to predict the reverse order word sequence as {W n , W n-1 , ..., W2, W1}, the process of finding the next word of "W1" includes:
[0085] Calculate the corpus set Corpus using the reverse language model text-for-model The probability of all words in being the next word of "W1" is calculated, and the word w with the largest probability is selected. canidate As the next word of "W1", that is, the word w with the highest probability canidate The candidate word w is predicted by the reverse language model. canidate , add in the reverse word sequence {W n , W n-1 , ..., W2, W1}, generate the predicted reverse word sequence {W n , W n-1 ,…,W2,W1,w canidate}.
[0086] In one embodiment, the trained reverse language model is used to predict the probability of the next word of "NUM" in the reverse word sequence {mineral water, bottle, NUM}, and the word w with the highest probability is selected. canidateIf the candidate word "buy" is "buy", the candidate word "buy" is added to the reverse word sequence {mineral water, bottle, NUM} to generate a predicted reverse word sequence {mineral water, bottle, NUM, buy}.
[0087] In the above implementation process, the probability of each word in the corpus being a predicted word is calculated through the reverse language model, and the word with the highest probability is selected as the final predicted word, thereby realizing the prediction of missing words in the reverse sentence.
[0088] 140, obtaining a sentence without missing words corresponding to the sentence to be processed according to the predicted reverse word sequence.
[0089] According to the predicted reverse word sequence, the sentence without missing words corresponding to the sentence to be processed is obtained, including:
[0090] Determine whether the candidate word is a start tag;
[0091] If the candidate word is a start tag, after deleting the start tag in the predicted reverse word sequence, the predicted reverse word sequence is transformed into a positive order to obtain a sentence without missing words corresponding to the sentence to be processed;
[0092] If the candidate word is not a start tag, determine whether the candidate word is a keyword tag;
[0093] If the candidate word is a keyword tag, keep the candidate word in the predicted reverse word sequence, and use the trained reverse language model to predict the next word of the candidate word in the predicted reverse word sequence to obtain the next candidate word, and repeat the above process;
[0094] If the candidate word is not a keyword tag, obtain the pinyin initial letter of the first character in the candidate word, and determine whether the pinyin initial letter belongs to one of the preset initial letter sets;
[0095] If the pinyin first letter belongs to any one of the preset first letter sets, the candidate word is retained in the predicted reverse word sequence, and the next word of the candidate word in the predicted reverse word sequence is predicted using the trained reverse language model to obtain the next candidate word, and the above process is repeated;
[0096] If the pinyin first letter does not belong to any of the preset first letter sets, after deleting the candidate words in the predicted reverse word sequence, the predicted reverse word sequence is transformed into a positive order to obtain a sentence without missing words corresponding to the sentence to be processed.
[0097] In order to prevent the reverse language model from over-completing the sentence, it is necessary to further correct the predicted reverse word sequence after completion.
[0098] In the above implementation process, by swapping the word order of the sentence to be processed, it is convenient to use the language model to predict the word at the beginning of the sentence to be processed, and further predict the next word of the last word in the reverse word order through the trained reverse language model, and correct it according to the predicted reverse word sequence, thereby effectively solving the problem of missing words or characters at the beginning of the sentence, and further ensuring the accuracy of speech recognition during voice interaction.
[0099] As an embodiment, a sentence without missing words corresponding to the sentence to be processed is obtained according to the candidate words in the predicted reverse word sequence, such as Figure 2 As shown, Figure 2 A flow chart of a method for obtaining a sentence without missing words based on a predicted reverse word sequence provided in an embodiment of the present application, specifically, Figure 2 The methods shown include:
[0100] 210, predicting candidate words using the reverse language model.
[0101] In step 130, the reverse order language model is used to predict the reverse order word sequence {W n , W n-1 ,…,W2,W1} is the candidate word w canidate .
[0102] 220, determine whether the candidate word is a start tag.
[0103] Predict the candidate word w through the reverse language model canidate After that, we determine the candidate word w canidate Is it the start mark START?
[0104] If the candidate word w canidate is the start tag START, it means predicting the reverse word sequence {W n , W n-1 ,…,W2,W1,w canidate} The sentence to be processed corresponding to sentence is a complete sentence and does not need to be completed. The process proceeds to step 250 to predict the reverse word sequence {W n , W n-1 ,…,W2,W1,w canidate} in the candidate word w canidate , that is, the starting mark START is deleted, and {W n , W n-1 , …, W2, W1}, and transform the word sequence of the deleted candidate words into positive order to obtain a sentence without missing words;
[0105] 230, determine whether the candidate word is a keyword tag.
[0106] If the candidate word w canidateIf it is not the start tag START, then the candidate word w is judged canidate Whether it is any of multiple keyword tags;
[0107] If the candidate word w canidate is any one of the multiple keyword tags, then the candidate word w is retained canidate , that is, the keyword tag is in the predicted reverse word sequence {W n , W n-1 ,…,W2,W1,w canidate}, and return to step 210, using the reverse language model to predict the next candidate word until the missing word in the sentence is completed;
[0108] 240, determining whether the pinyin first letter of the candidate word belongs to any one of the preset letter sets.
[0109] In some embodiments, due to reasons of the speech recognition engine itself, some sounds produced by the vocal cords not vibrating will be lost with a certain probability, that is, during speech recognition, there is no need to supplement such words. Therefore, such words predicted by the reverse language model are over-supplemented. In order to determine whether a candidate word is an over-supplemented word, the pinyin of the candidate word is used for judgment.
[0110] If the candidate word w canidate If it is not any of the multiple keyword tags, then get the candidate word w canidate The pinyin initial letter of the first word in the word, and whether the pinyin initial letter belongs to any one of the preset initial letter sets;
[0111] It should be noted that the preset initial letter set in the embodiment of the present application can be expressed as a set of letters consisting of letters whose vocal cords vibrate when pronouncing, such as f, s, x, h, m, n and other letters, but the present application is not limited to this.
[0112] If the candidate word w canidate If the pinyin initial letter of the first word in the word belongs to any one of the preset initial letter sets, then the candidate word w is retained. canidate , in predicting the reverse word sequence {W n , W n-1 ,…,W2,W1,w canidate}, and return to step 210, using the reverse language model to predict the next candidate word until the missing word in the sentence is completed;
[0113] As an example, the candidate words w predicted by the reverse language model for the sentence “3 bottles of mineral water” to be processed are: canidateThe generated predicted reverse word sequence is: {mineral water, bottle, NUM, buy}, then it is determined that the pinyin first letter of "buy" is "m", which belongs to one of the preset first letter sets, then "buy" is retained in the predicted reverse word sequence {mineral water, bottle, NUM, buy}, and the process returns to step 210, and the reverse language model is used to predict that the next candidate word is the starting mark START. After deleting the starting mark START, the predicted reverse word sequence {mineral water, bottle, NUM, buy} is converted into a positive order, and the generated sentence without missing words is "buy NUM bottles of mineral water". In order to confirm the specific quantity of mineral water in the sentence, the smart device will perform the next polling operation, and prompt the user to confirm the quantity of mineral water again through voice or display device.
[0114] 250, delete the candidate words and perform positive order conversion to obtain a sentence without missing words.
[0115] If the candidate word w canidate The pinyin initial letter of the first word in does not belong to any of the preset initial letter sets, that is, the candidate word w canidate The pinyin initials of the first word in the sentence are letters that the vocal cords do not vibrate when pronouncing, indicating that the candidate word is an over-complementary word. The predicted reverse word sequence {W n , W n-1 ,…,W2,W1,w canidate} in the candidate word w canidate , we get {W n , W n-1 , …, W2, W1}, and transform the word sequence of the deleted candidate words into positive order to obtain a sentence without missing words.
[0116] In the above implementation process, whether the candidate word is an over-complemented word is determined by the first pinyin letter of the first character in the candidate word. If it is an over-complemented word, the word is deleted and the word sequence is transposed to obtain a sentence without missing words, thereby effectively avoiding over-complementation of the sentence due to the speech recognition engine itself.
[0117] Please refer to Figure 3 , Figure 3 A structural block diagram of a device for sentence processing provided in an embodiment of the present application, Figure 3 The statement processing apparatus 300 is provided with Figure 1 The method shown corresponds to, with implementation Figure 1 Functional modules of the method shown.
[0118] As an embodiment, the statement processing device 300 includes:
[0119] The word segmentation module 310 is used to perform word segmentation processing on the sentence to be processed to obtain a normal word sequence of the sentence to be processed;
[0120] The conversion module 320 is used to perform reverse conversion on the normal word sequence to obtain a reverse word sequence of the sentence to be processed;
[0121] A prediction module 330 is used to predict the next word of the last word in the reverse word sequence by using the trained reverse language model to generate a predicted reverse word sequence;
[0122] The processing module 340 is used to obtain a sentence without missing words corresponding to the sentence to be processed according to the predicted reverse word sequence.
[0123] In one embodiment, the word segmentation module is specifically used to: perform word segmentation processing on the sentence to be processed to obtain an initial word sequence of the sentence to be processed; and replace the keywords in the initial word sequence with keyword tags to obtain a normal word sequence.
[0124] In another embodiment, the prediction module is also used to: perform word segmentation on at least one sentence in the corpus to obtain an initial training word sequence for each sentence in the at least one sentence; replace the keywords in the initial training word sequence of each sentence with keyword tags to obtain a training word sequence for each sentence; add a start tag before the first word in the training word sequence of each sentence to obtain a marked training word sequence for each sentence; perform reverse conversion on the marked training word sequence of each sentence to obtain a reverse training word sequence for each sentence; and train a statistical language model using the reverse training word sequence of at least one sentence to obtain a trained reverse language model.
[0125] In another embodiment, the prediction module is specifically used to: use the trained reverse language model to calculate the probability of all words in the corpus being the next word of the last word in the reverse word sequence; select the word with the highest probability as the candidate word; add the candidate word to the reverse word sequence to generate a predicted reverse word sequence.
[0126] In another embodiment, the processing module is specifically used to: determine whether the candidate word is a start tag; if the candidate word is a start tag, after deleting the start tag in the predicted reverse word sequence, the predicted reverse word sequence is converted into a positive order to obtain a sentence without missing words corresponding to the sentence to be processed; if the candidate word is not a start tag, determine whether the candidate word is a keyword tag; if the candidate word is a keyword tag, retain the candidate word in the predicted reverse word sequence, and use the trained reverse language model to predict the next word of the candidate word in the predicted reverse word sequence to obtain the next candidate word, and repeat the above process; if the candidate word is not a keyword, Keyword tagging, obtain the pinyin first letter of the first character in the candidate word, and determine whether the pinyin first letter belongs to one of the preset first letter sets; if the pinyin first letter belongs to any one of the preset first letter sets, retain the candidate word in the predicted reverse word sequence, and use the trained reverse language model to predict the next word of the candidate word in the predicted reverse word sequence to obtain the next candidate word, and repeat the above process; if the pinyin first letter does not belong to any one of the preset first letter sets, delete the candidate word in the pre-reverse word sequence, and then convert the predicted reverse word sequence into a positive order to obtain a sentence without missing words corresponding to the sentence to be processed.
[0127] It should be noted that Figure 3 The provided statement processing device 300 can implement Figure 1 The method embodiment involves various processes of the statement processing method. The operations and / or functions of the various modules in the statement processing device 300 are respectively to implement Figure 1 For details, please refer to the description in the above method embodiment. To avoid repetition, detailed description is appropriately omitted here.
[0128] Please refer to Figure 4 , Figure 4 A structural block diagram of another device for sentence processing provided in an embodiment of the present application, Figure 4Another statement processing device 400 provided may include: at least one processor 410, the processor 410 may be a CPU (Central Processing Unit), or a GPU (Graphics Processing Unit), or a CPU and a GPU, and the embodiments of the present application are not limited thereto, at least one communication interface 420, at least one memory 430 and at least one communication bus 440. Among them, the communication bus 440 is used to realize the direct connection and communication between these components. Among them, the communication interface 420 of the device in the embodiment of the present application is used to communicate signaling or data with other node devices. The memory 430 may be a high-speed RAM (random access memory) memory, or it may be a non-volatile memory (non-volatile memory), such as at least one disk storage. The memory 430 may optionally be at least one storage device located away from the aforementioned processor. The memory 430 stores computer-readable instructions, and when the computer-readable instructions are executed by the processor 410, it is used to execute Figure 1 The method process is shown.
[0129] The present invention provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a server, Figure 1 The method process shown.
[0130] In the several embodiments provided in this application, it should be understood that the disclosed systems and methods can also be implemented in other ways. The system embodiments described above are only illustrative. For example, the division of the system devices is only a logical function division. There may be other division methods in actual implementation. For example, multiple devices or components can be combined or integrated into another system, or some features can be ignored or not executed.
[0131] In addition, the units described as separate components may or may not be physically separated, and the components shown 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 solution of this embodiment.
[0132] The above description is only an embodiment of the present application and is not intended to limit the protection scope of the present application. For those skilled in the art, the present application may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.
Claims
1. A method for sentence processing, characterized in that: include: Perform word segmentation processing on the sentence to be processed to obtain a normal word sequence of the sentence to be processed; Reverse-converting the normal word sequence to obtain a reverse-order word sequence of the sentence to be processed; The method uses a trained reverse language model to predict the next word of the last word in the reverse word sequence to generate a predicted reverse word sequence, including: using the trained reverse language model to calculate the probability of all words in the corpus being the next word of the last word in the reverse word sequence; selecting the word with the highest probability as a candidate word; adding the candidate word to the reverse word sequence to generate the predicted reverse word sequence; wherein the reverse language model is a statistical language model; the statistical language model includes one or more of a 3-gram language model, a 2-gram language model, and a neural network language model; Determine whether the candidate word is a start tag; If the candidate word is the start marker, after deleting the start marker in the predicted reverse word sequence, the predicted reverse word sequence is converted into a positive order to obtain a sentence without missing words corresponding to the sentence to be processed; If the candidate word is not the start tag, determining whether the candidate word is a keyword tag; If the candidate word is a keyword tag, retain the candidate word in the predicted reverse word sequence, and use the trained reverse language model to predict the next word of the candidate word in the predicted reverse word sequence to obtain the next candidate word, and repeat the above process; If the candidate word is not the keyword tag, obtaining the pinyin initial letter of the first character in the candidate word, and determining whether the pinyin initial letter belongs to one of the preset initial letter sets; If the pinyin initial letter belongs to any one of the preset initial letter sets, the candidate word is retained in the predicted reverse word sequence, and the next word of the candidate word in the predicted reverse word sequence is predicted using the trained reverse language model to obtain the next candidate word, and the above process is repeated; If the pinyin first letter does not belong to any one of the preset first letter set, after deleting the candidate words in the predicted reverse word sequence, the predicted reverse word sequence is converted into a positive order to obtain a sentence without missing words corresponding to the sentence to be processed.
2. The method according to claim 1, characterized in that The word segmentation process is performed on the sentence to be processed to obtain a normal word sequence of the sentence to be processed, including: Performing word segmentation processing on the sentence to be processed to obtain an initial word sequence of the sentence to be processed; The keywords in the initial word sequence are replaced with keyword tags to obtain the normal word sequence.
3. The method according to claim 1 or 2, characterized in that: Before predicting the next word of the last word in the reverse word sequence using the trained reverse language model, the method further includes: Performing word segmentation processing on at least one sentence in the corpus to obtain an initial training word sequence for each sentence in the at least one sentence; Replacing the keywords in the initial training word sequence of each sentence with the keyword marker to obtain the training word sequence of each sentence; Adding a start mark before the first word in the training word sequence of each sentence to obtain a marked training word sequence of each sentence; Reverse-converting the labeled training word sequence of each sentence to obtain a reverse-order training word sequence of each sentence; The statistical language model is trained using a reverse-order training word sequence of at least one sentence to obtain the trained reverse-order language model.
4. A device for sentence processing, characterized in that: The device comprises: A word segmentation module, used for performing word segmentation processing on the sentence to be processed to obtain a normal word sequence of the sentence to be processed; A conversion module, used for performing reverse conversion on the normal word sequence to obtain a reverse word sequence of the sentence to be processed; A prediction module is used to predict the next word of the last word in the reverse word sequence by using a trained reverse language model to generate a predicted reverse word sequence, including: using the trained reverse language model to calculate the probability of all words in the corpus being the next word of the last word in the reverse word sequence; selecting the word with the highest probability as a candidate word; adding the candidate word to the reverse word sequence to generate the predicted reverse word sequence; wherein the reverse language model is a statistical language model; the statistical language model includes one or more of a 3-gram language model, a 2-gram language model and a neural network language model; A processing module is used to determine whether the candidate word is a starting tag; if the candidate word is the starting tag, after deleting the starting tag in the predicted reverse word sequence, the predicted reverse word sequence is converted into a positive order to obtain a sentence without missing words corresponding to the sentence to be processed; if the candidate word is not the starting tag, it is determined whether the candidate word is a keyword tag; if the candidate word is a keyword tag, the candidate word is retained in the predicted reverse word sequence, and the trained reverse language model is used to predict the next word of the candidate word in the predicted reverse word sequence to obtain the next candidate word, and the above process is repeated; if the candidate word is not the keyword tag In the step of: obtaining the first pinyin letter of the first character in the candidate word, determining whether the first pinyin letter belongs to one of the preset first letter sets; if the first pinyin letter belongs to any one of the preset first letter sets, retaining the candidate word in the predicted reverse word sequence, and using the trained reverse language model to predict the next word of the candidate word in the predicted reverse word sequence, obtaining the next candidate word, and repeating the above process; if the first pinyin letter does not belong to any one of the preset first letter sets, deleting the candidate word in the predicted reverse word sequence, and converting the predicted reverse word sequence into a forward order to obtain a sentence without missing words corresponding to the sentence to be processed.
5. The device according to claim 4, characterized in that The word segmentation module is specifically used for: Performing word segmentation processing on the sentence to be processed to obtain an initial word sequence of the sentence to be processed; The keywords in the initial word sequence are replaced with keyword tags to obtain the normal word sequence.
6. The device according to claim 4 or 5, characterized in that The prediction module is also used to: Performing word segmentation processing on at least one sentence in the corpus to obtain an initial training word sequence for each sentence in the at least one sentence; Replacing the keywords in the initial training word sequence of each sentence with the keyword marker to obtain the training word sequence of each sentence; Adding a start mark before the first word in the training word sequence of each sentence to obtain a marked training word sequence of each sentence; Reverse-converting the labeled training word sequence of each sentence to obtain a reverse-order training word sequence of each sentence; The statistical language model is trained using a reverse-order training word sequence of at least one sentence to obtain the trained reverse-order language model.
7. A device for sentence processing, characterized in that: include: A processor, a memory and a bus, wherein the processor is connected to the memory via the bus, and the memory stores computer-readable instructions. When the computer-readable instructions are executed by the processor, they are used to implement the method according to any one of claims 1 to 3.
8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, which, when executed by a server, implements the method as claimed in any one of claims 1 to 3.
Citation Information
Patent Citations
Natural language correction method and system, equipment and storage medium
CN108647207A
Statement completion method and device, medium and dialogue processing system
CN110427625A