Speech recognition method and apparatus, storage medium, and electronic device
Patent Information
- Application Number
- CN202310094370.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-01-31
- Publication Date
- 2026-09-18
- Estimated Expiration
- 2043-01-31
AI Technical Summary
[0005]本申请实施例提供了一种语句识别方法和装置、存储介质及电子装置,以至少解决相关技术中的语句识别方法存在由于存在噪声干扰导致的语句有效性识别的准确性低的问题
[0024]In this embodiment, the target statement is split into multiple sub-statements. The target statement is a statement with M characters, and the number of characters in each sub-statement is an integer within the range [N, M]. Using a target language model, the target value of each sub-statement is determined, where each target value represents the probability that the sub-statement is valid. The average target value of the target statement is then calculated, representing the probability that the target statement is valid. The average target value is compared to a preset threshold to determine whether the target statement is valid. By splitting the target statement into multiple sub-statements, determining the target value for each sub-statement, and using the average of these target values as the probability of a valid statement, noise interference in identifying the validity of the target statement is reduced. This improves the accuracy of statement validity identification and solves the problem of low accuracy in statement recognition methods due to noise interference.
Smart Images

Figure CN116306682B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of smart home / intelligent home, and more specifically, to a sentence recognition method and apparatus, storage medium and electronic device. Background Technology
[0002] Currently, in the field of smart home appliances, after a smart device turns on its radio function, it will continuously pick up all the sounds in the environment. If other devices are playing audio in the environment, or multiple people are speaking at the same time, or if the user pauses or repeats himself / herself while speaking, the text obtained by the voice recognition module through the recognition of the voice signal received by the smart device may be incoherent and invalid, which will affect the smart device's ability to interpret the control commands for home appliances.
[0003] In related technologies, language models used for text recognition can be used to calculate the validity of text and filter out invalid statements. However, in statements collected by smart devices, language models may misidentify statements with noise interference that does not affect semantic parsing as invalid statements, thus affecting the accuracy of statement validity recognition.
[0004] It is evident that the sentence recognition methods in related technologies suffer from low accuracy in sentence validity recognition due to noise interference. Summary of the Invention
[0005] This application provides a sentence recognition method and apparatus, storage medium and electronic device to at least solve the problem of low accuracy in sentence validity recognition due to noise interference in related technologies.
[0006] According to one aspect of the embodiments of this application, a statement recognition method is provided, comprising: splitting a target statement into multiple sub-statements, wherein the target statement is a statement with M characters, and the number of characters in each of the multiple sub-statements is an integer in the interval [N, M]; determining a target value for each of the multiple sub-statements using a target language model, wherein the target value of each of the multiple sub-statements is the probability that each of the multiple sub-statements is a valid statement; determining the average of the target values of each of the multiple sub-statements to obtain an average target value of the target statement, wherein the average target value is the probability that the target statement is a valid statement; and determining whether the target statement is a valid statement by comparing the average target value of the target statement with a preset threshold.
[0007] In an exemplary embodiment, splitting the target statement into multiple substatements includes: determining the number K of the multiple substatements based on M and a preset N, where K is a positive integer greater than or equal to (M-N+1); performing the following operations on the target statement to obtain the i-th substatement among the K substatements, where i is a positive integer greater than or equal to 1 and less than or equal to K; determining the number L of words included in the i-th substatement, where L is a positive integer greater than or equal to N; and extracting L words starting from the first word of the target statement to obtain the i-th substatement.
[0008] In an exemplary embodiment, K equals (M-N+1), and L equals (N+i-1); the step of extracting L characters starting from the first character of the target statement to obtain the i-th sub-statement includes: extracting (N+i-1) consecutive characters starting from the first character of the target statement to obtain the i-th sub-statement.
[0009] In an exemplary embodiment, determining the target value of each sub-statement among the plurality of sub-statements using a target language model includes: when the plurality of sub-statements are (M-N+1) sub-statements, for the i-th sub-statement among the plurality of sub-statements, performing the following steps using the target language model to obtain the target value of the i-th sub-statement: in the i-th sub-statement, a target sliding window slides from the first character of the i-th sub-statement, each time extracting a sentence fragment including N characters, until the last position of the target sliding window covers the last character of the i-th sub-statement, resulting in a set of sentence fragments, wherein the number of characters covered by the target sliding window each time is N; determining the probability value corresponding to each sentence fragment in the set of sentence fragments, wherein the probability value corresponding to each sentence fragment is the probability that each sentence fragment is a valid statement; and determining the product of the probability values corresponding to each sentence fragment as the target value of the i-th sub-statement.
[0010] In an exemplary embodiment, determining the probability value corresponding to each statement fragment in the set of statement fragments includes: when N is equal to or greater than 2, performing the following operations on each statement fragment in the set of statement fragments, wherein each statement fragment is the current statement fragment when performing the following operations: obtaining the probability of the current statement fragment appearing in a preset target dataset to obtain a first probability, wherein the target dataset contains multiple statements; obtaining the probability that the first character to the (N-1)th character in the current statement fragment appears as a whole in the target dataset to obtain a second probability; and determining the ratio of the first probability to the second probability as the probability value corresponding to the current statement fragment.
[0011] In an exemplary embodiment, determining the probability value corresponding to each statement fragment in the set of statement fragments includes: when N equals 1, performing the following operations on each statement fragment in the set of statement fragments, wherein each statement fragment is the current statement fragment when performing the following operations: obtaining the probability of the current statement fragment appearing in a preset target dataset to obtain a first probability, wherein the target dataset contains multiple statements; obtaining the sum of the probabilities of each word appearing in the i-th sub-statement in the target dataset to obtain a cumulative probability; and determining the ratio of the first probability to the cumulative probability as the probability value corresponding to the current statement fragment.
[0012] In one exemplary embodiment, determining whether a target statement is a valid statement by comparing its average target value with a preset threshold includes: determining that the target statement is not a valid statement if the average target value of the target statement is less than the preset threshold; and determining that the target statement is a valid statement if the average target value of the target statement is greater than or equal to the preset threshold.
[0013] In an exemplary embodiment, after determining whether the target statement is a valid statement by comparing the average target value of the target statement with a preset threshold, the method further includes: if it is determined that the target statement is not a valid statement, controlling the voice device to refuse to perform semantic parsing on the target statement.
[0014] According to another aspect of the embodiments of this application, a statement recognition device is also provided, comprising: a splitting unit, configured to split a target statement into multiple sub-statements, wherein the target statement is a statement with M characters, and the number of characters in each of the multiple sub-statements is an integer in the interval [N, M]; a first determining unit, configured to determine the target value of each of the multiple sub-statements using a target language model, wherein the target value of each of the multiple sub-statements is the probability that each of the multiple sub-statements is a valid statement; a second determining unit, configured to determine the average of the target values of each of the multiple sub-statements to obtain the average target value of the target statement, wherein the average target value is the probability that the target statement is a valid statement; and a third determining unit, configured to determine whether the target statement is a valid statement by comparing the average target value of the target statement with a preset threshold.
[0015] In an exemplary embodiment, the splitting unit includes: a first determining module, configured to determine the number K of the plurality of sub-statements based on M and a preset N, wherein K is a positive integer greater than or equal to (M-N+1); and a first execution module, configured to perform the following operations on the target statement to obtain the i-th sub-statement among the K sub-statements, wherein i is a positive integer greater than or equal to 1 and less than or equal to K: determining the number L of words included in the i-th sub-statement, wherein L is a positive integer greater than or equal to N; and extracting L words starting from the first word in the target statement to obtain the i-th sub-statement.
[0016] In an exemplary embodiment, K equals (M-N+1) and L equals (N+i-1); the first execution module includes: a truncation submodule, configured to truncate (N+i-1) consecutive characters starting from the first character in the target statement to obtain the i-th substatement.
[0017] In an exemplary embodiment, the first determining unit includes: a second execution module, configured to, when the plurality of sub-statements are (M-N+1) sub-statements, perform the following steps through the target language model to obtain the target value of the i-th sub-statement for the i-th sub-statement: in the i-th sub-statement, a target sliding window slides from the first character of the i-th sub-statement, each time extracting a sentence fragment including N characters, until the last position of the target sliding window covers the last character of the i-th sub-statement, resulting in a set of sentence fragments, wherein the number of characters covered by the target sliding window each time is N; determine the probability value corresponding to each sentence fragment in the set of sentence fragments, wherein the probability value corresponding to each sentence fragment is the probability that each sentence fragment is a valid statement; and determine the product of the probability values corresponding to each sentence fragment as the target value of the i-th sub-statement.
[0018] In an exemplary embodiment, the second execution module includes: a first execution submodule, configured to perform the following operations on each statement fragment in the set of statement fragments when N is equal to or greater than 2, wherein each statement fragment is a current statement fragment when performing the following operations: obtaining the probability of the current statement fragment appearing in a preset target dataset to obtain a first probability, wherein the target dataset contains multiple statements; obtaining the probability that the first character to the (N-1)th character in the current statement fragment appears as a whole in the target dataset to obtain a second probability; and determining the ratio of the first probability to the second probability as the probability value corresponding to the current statement fragment.
[0019] In an exemplary embodiment, the second execution module includes: a second execution submodule, configured to perform the following operations on each statement fragment in the set of statement fragments when N equals 1, wherein each statement fragment is a current statement fragment when performing the following operations: obtaining the probability of the current statement fragment appearing in a preset target dataset to obtain a first probability, wherein the target dataset contains multiple statements; obtaining the sum of the probabilities of each word appearing in the i-th sub-statement in the target dataset to obtain a cumulative probability; and determining the ratio of the first probability to the cumulative probability as the probability value corresponding to the current statement fragment.
[0020] In an exemplary embodiment, the third determining unit includes: a second determining module, configured to determine that the target statement is not a valid statement when the average target value of the target statement is less than the preset threshold; and a third determining module, configured to determine that the target statement is a valid statement when the average target value of the target statement is greater than or equal to the preset threshold.
[0021] In one exemplary embodiment, the apparatus further includes a control unit, configured to, after determining whether the target statement is a valid statement by comparing the average target value of the target statement with a preset threshold, control the voice device to refuse semantic parsing of the target statement if it is determined that the target statement is not a valid statement.
[0022] According to another aspect of the embodiments of this application, a computer-readable storage medium is also provided, wherein a computer program is stored in the computer-readable storage medium, and the computer program is configured to execute the above-described statement recognition method at runtime.
[0023] According to another aspect of the embodiments of this application, an electronic device is also provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the above-described statement recognition method through the computer program.
[0024] In this embodiment, the target statement is split into multiple sub-statements. The target statement is a statement with M characters, and the number of characters in each sub-statement is an integer within the range [N, M]. Using a target language model, the target value of each sub-statement is determined, where each target value represents the probability that the sub-statement is valid. The average target value of the target statement is then calculated, representing the probability that the target statement is valid. The average target value is compared to a preset threshold to determine whether the target statement is valid. By splitting the target statement into multiple sub-statements, determining the target value for each sub-statement, and using the average of these target values as the probability of a valid statement, noise interference in identifying the validity of the target statement is reduced. This improves the accuracy of statement validity identification and solves the problem of low accuracy in statement recognition methods due to noise interference. Attached Figure Description
[0025] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.
[0026] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0027] Figure 1 This is a schematic diagram of the hardware environment for an optional sentence recognition method according to an embodiment of this application;
[0028] Figure 2 This is a flowchart illustrating an optional sentence recognition method according to an embodiment of this application;
[0029] Figure 3 This is a structural block diagram of an optional sentence recognition device according to an embodiment of this application;
[0030] Figure 4 This is a structural block diagram of an optional electronic device according to an embodiment of this application. Detailed Implementation
[0031] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort should fall within the scope of protection of the present application.
[0032] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0033] According to one aspect of the embodiments of this application, a statement recognition method is provided. This statement recognition method is widely used in whole-house intelligent digital control application scenarios such as smart homes, smart home ecosystems, and intelligencehouse ecosystems. Optionally, in this embodiment, the above-mentioned statement recognition method can be applied to, for example... Figure 1 The hardware environment shown consists of terminal device 102 and server 104. For example... Figure 1 As shown, server 104 is connected to terminal device 102 via a network and can be used to provide services (such as application services) to the terminal or clients installed on the terminal. A database can be set up on the server or independently of the server to provide data storage services for server 104. Cloud computing and / or edge computing services can be configured on the server or independently of the server to provide data processing services for server 104.
[0034] The aforementioned network may include, but is not limited to, at least one of the following: wired network, wireless network. The aforementioned wired network may include, but is not limited to, at least one of the following: wide area network, metropolitan area network, local area network. The aforementioned wireless network may include, but is not limited to, at least one of the following: Wi-Fi (Wireless Fidelity), Bluetooth. The terminal device 102 may not be limited to PC, mobile phone, tablet computer, smart air conditioner, smart range hood, smart refrigerator, smart oven, smart stove, smart washing machine, smart water heater, smart washing equipment, smart dishwasher, smart projector, smart TV, smart clothes rack, smart curtains, smart audio-visual equipment, smart socket, smart speaker, smart speaker box, smart fresh air equipment, smart kitchen and bathroom equipment, smart bathroom equipment, smart robot vacuum cleaner, smart window cleaning robot, smart mopping robot, smart air purifier, smart steam oven, smart microwave oven, smart water heater, smart air purifier, smart water dispenser, smart door lock, etc.
[0035] The statement recognition method of this application embodiment can be executed by server 104, by terminal device 102, or by both server 104 and terminal device 102. Alternatively, the statement recognition method of this application embodiment can be executed by a client installed on terminal device 102.
[0036] Taking the statement recognition method in this embodiment as an example, which is executed by terminal device 102, Figure 2 This is a flowchart illustrating an optional sentence recognition method according to an embodiment of this application, such as... Figure 2 As shown, the process of this method may include the following steps:
[0037] Step S202: Split the target statement into multiple substatements, where the target statement is a statement with M words, and the number of words in each substatement is an integer in the range [N, M].
[0038] The statement recognition method in this embodiment can be applied to scenarios where interactive statements acquired by a voice device (i.e., the aforementioned terminal device) are recognized. The voice device can be a smart voice device, and its device type can be a smart home device, such as a smart washing machine, smart speaker, or smart air conditioner. Interactive statements can be extracted from the voice data collected during voice interaction with the user. By recognizing the user's intent, the method can execute corresponding device operations or respond to the user's interactive voice. If the voice device can parse the interactive statement and recognize the user's intent, the interactive statement is valid; otherwise, the interactive statement is invalid.
[0039] After activating the voice recording function of the voice device, it can capture all sounds in the environment in real time. This includes sounds from devices like televisions and radios playing audio, multiple people speaking simultaneously, and pauses or repetitions in the user's speech. During a voice interaction, the voice device performs speech recognition on the captured voice data to obtain the target sentence, which is a sentence with M characters. The voice device can then perform semantic analysis on the target sentence to determine the user's intent. This semantic analysis can be performed by the voice device's speech recognition module.
[0040] Recognizing target statements may yield semantically ambiguous and invalid text. For example, if other devices are playing audio or multiple people are speaking simultaneously, and the target statement acquired by the voice device is "This lifetime is all about planting refrigerators, cooking and eating 12 songs," the voice device cannot interpret the user's intent based on the speech recognition results after performing speech recognition on this target statement. Such invalid statements significantly hinder the interpretation of user intent, thus preventing the execution of corresponding device operations or the provision of correct responses to the user. Therefore, one approach to handling invalid text is to filter out such text, thereby reducing interference with smart home appliance systems.
[0041] In related technologies, there are two ways to identify invalid text: Method 1 (forward method), which uses a large-scale pre-trained language model for binary classification, such as BERT (Bidirectional Encoder Representations from Transformers) and CNN (Convolutional Neural Network); Method 2 (reverse method), which uses a language model (which can be a statistical model) to calculate the probability of valid text corpus. The language model can be a statistical model N-gram (a statistical language model).
[0042] The first method is currently widely used in the field of NLP (Natural Language Processing) and has good performance for both classification and generation tasks. With a large amount of labeled corpus, a binary classification task can be performed to identify whether a piece of text is valid or invalid. However, the training samples usually collected at present are valid and fluent text corpora, and there are not enough invalid training samples available for training. Therefore, it is impossible to use a large-scale pre-trained language model to complete the task of identifying invalid text.
[0043] However, language models such as the statistical model N-gram have advantages in calculating the rationality of text, because characters in a sentence have a specific order. Changing the order or deleting some characters may result in different meanings, and may also result in an ungrammatical sentence. For example, for the sentence "I want to eat watermelon in the refrigerator", swapping the order of some characters may get "I want to eat watermelon in the refrigerator", and deleting some characters may get "I want to eat ice" and "I watermelon in the box".
[0044] Here, the basic idea of N-gram is to perform a sliding window operation of size N on the content of text according to the order, forming a sequence of text fragments with a length of N. For example, when N=3, the sentence "I want to eat watermelon" forms the fragment sequence "I want, want to eat, eat watermelon". In practical applications, N-gram generally uses Markov assumption to simplify calculation, that is, the occurrence of a word is only related to the previous n-1 words, and has nothing to do with other words. For example, for a fragment consisting of m characters, the probability calculation method is shown in formula (1):
[0045] P(w1, w2, w3...w m )=P(w m |w m-n+1 , w m-n+2 , ...w m-1 ) (1)
[0046] That is, the probability of a sentence is equal to the product of the probabilities of all fragments, where w is a fragment. For this, the probability of all fragments can be calculated first.
[0047] For example, for the sentence "I want to eat watermelon", the probability of this sentence is equal to the product of the probabilities of the fragments "I want", "want to eat", and "eat watermelon", which is shown in formula (2):
[0048] P(I, want, to, eat, watermelon)=P(eat|I want)P(watermelon|want to eat)P(watermelon|eat watermelon)(2)
[0049] Wherein, P(watermelon|eat watermelon) represents the probability of the occurrence of "watermelon" under the prior condition "eat watermelon", that is, the possibility of "watermelon" appearing after "eat watermelon".
[0050] When calculating the N-gram probability of a sentence, the common practice is to divide the sentence into segments of size N from beginning to end, and then calculate the product of the probabilities of each segment. However, in the field of home appliance control, this sentence processing method often encounters situations where the sentence contains noise at the beginning and end, such as "I want to eat watermelon, so I'll leave it empty." Here, "leave it empty" is the noise that is misidentified. If we calculate the 5-gram of "I want to eat watermelon, so I'll leave it empty," the probability of the result being valid text will be low. However, the semantics of this sentence are actually quite clear, and the noise does not affect the semantic parsing. It can be regarded as valid text. Therefore, it is necessary to increase the N-gram probability value of such noisy sentences.
[0051] To address the aforementioned technical issues, reduce noise interference in sentence recognition, and improve the accuracy of sentence recognition, when identifying whether a target sentence is valid, the target sentence can be divided into multiple sub-sentences. The number of characters in each sub-sentence is an integer within the range [N, M]. That is, a target sentence with M characters can be divided into sub-sentences with N, N+1, ..., M characters. The target value of each sub-sentence is calculated, and the average of the target values of multiple sub-sentences is calculated to obtain the probability that the target sentence is valid. Based on this, valid target sentences are parsed, and invalid target sentences are filtered out.
[0052] Step S204: Using the target speech model, determine the target value of each sub-statement in the multiple sub-statements, wherein the target value of each sub-statement in the multiple sub-statements is the probability that each sub-statement in the multiple sub-statements is a valid statement.
[0053] In this embodiment, for each sub-statement among multiple sub-statements, the target value of each sub-statement can be determined by the target speech model. The target value of each sub-statement can reflect the probability that the sub-statement is a valid statement. Here, the target speech model can be an N-gram model. The N-gram value of each sub-statement can be obtained by the N-gram model. The N-gram value of each sub-statement is the probability value that the sub-statement is a valid statement.
[0054] Step S206: Determine the average of the target values of each sub-statement in the multiple sub-statements to obtain the average target value of the target statement, wherein the average target value is the probability that the target statement is a valid statement.
[0055] The target value of each sub-statement reflects the probability that each sub-statement is a valid statement, rather than the probability that the target statement is a valid statement. Therefore, after obtaining the target values of multiple sub-statements, the average of the target values of all sub-statements can be calculated to obtain the average target value of the target statement. The average target value of the target statement can reflect the probability that the target statement is a valid statement.
[0056] Step S208: By comparing the average target value of the target statement with a preset threshold, it is determined whether the target statement is a valid statement.
[0057] In this embodiment, the average target value of the target statement can be compared with a preset threshold to determine whether the target statement is a valid statement. Here, the preset threshold is a pre-defined minimum value that the average target value corresponding to a valid interactive statement must meet. If the average target value of the target statement is greater than or equal to the preset threshold, the target statement can be determined to be a valid statement; if the average target value of the target statement is less than the preset threshold, the target statement can be determined to be an invalid statement.
[0058] Here, since voice control commands in smart home systems may contain a variety of incoherent queries, it is impossible to collect all of these invalid queries to train the classification model in a positive direction. Therefore, the target language model can be a model trained using existing, reasonable corpora. By calculating a probability value and comparing it with a set threshold, it can be determined whether the query is reasonable and coherent.
[0059] Through steps S202 to S208, the target sentence is divided into multiple sub-sentences, where the target sentence is a sentence with M characters, and the number of characters in each sub-sentence is an integer within the interval [N, M]. Using the target speech model, the target value of each sub-sentence is determined, where the target value of each sub-sentence is the probability that it is a valid sentence. The average target value of the target sentence is then determined, representing the probability that it is a valid sentence. By comparing the average target value of the target sentence with a preset threshold, the validity of the target sentence is determined. This process solves the problem of low accuracy in sentence validity recognition due to noise interference in related technologies, thus improving the accuracy of sentence recognition.
[0060] In one exemplary embodiment, the target statement is split into multiple sub-statements, including:
[0061] S11, Based on M and the preset N, determine the number K of the multiple sub-statements, where K is a positive integer greater than or equal to (M-N+1);
[0062] S12, perform the following operation on the target statement to obtain the i-th substatement among K substatements, where i is a positive integer greater than or equal to 1 and less than or equal to K:
[0063] Determine the number L of words included in the i-th sub-statement, where L is a positive integer greater than or equal to N;
[0064] Extract L characters from the first character of the target statement to obtain the i-th substatement.
[0065] When voice devices collect voice data, the preceding and following segments of the target sentence may contain noise. If the target value of the target sentence—that is, the probability that the target sentence is a valid sentence—is calculated using a target speech model, noise will significantly interfere with the calculation. Therefore, the target sentence can be broken down into multiple sub-sentences, and the average target value of the target sentence can be determined by calculating the target value of each sub-sentence separately. In the above calculation process, the valid probability of the main body of the target sentence (i.e., the part that does not contain noise) is calculated multiple times, which has a significant impact on determining the average target value of the target sentence, thus reducing the interference of noise.
[0066] Based on the number of characters M in the target statement and a preset N, the target statement can be divided into K substatements, each containing more than or equal to N characters. The division rule can be to sequentially extract N to M characters from the target statement. To reduce the number of substatements to be processed and improve the efficiency of statement recognition, substatement extraction can be performed starting from the first character of the target statement, and / or, consecutive extracted characters can be used as substatements. To ensure the accuracy of statement recognition, the number of substatements K can be a positive integer greater than or equal to (M-N+1).
[0067] For the i-th sub-statement in K sub-statements (i is a positive integer less than or equal to K), the i-th sub-statement can be obtained as follows: First, based on the sub-statement division rules, determine the number L of words included in the i-th sub-statement (L is a positive integer greater than or equal to N); then, extract L words (which can be consecutive or non-consecutive) starting from the first word of the target statement to obtain the i-th sub-statement.
[0068] It should be noted that the number of sub-statements K can be based on the number of words M of the target statement and the preset N, and the number of words L of the i-th sub-statement can be based on i and the preset N.
[0069] In this embodiment, by splitting the interactive statement into multiple sub-statements, the main body of the interactive statement is calculated multiple times with a certain probability, which can reduce the impact of noise on the effectiveness of the interactive statement and improve the accuracy of statement recognition.
[0070] In an exemplary embodiment, the number of substatements K can be (M-N+1), and the number of characters L in the i-th substatement can be (N+i-1). Correspondingly, L characters are extracted from the first character of the target statement to obtain the i-th substatement, which includes:
[0071] S21, consecutively intercept (N+i-1) characters starting from the first character in the target statement to obtain the i-th sub-statement.
[0072] When acquiring the i-th sub-statement, consecutively (N+i-1) characters can be intercepted starting from the first character of the target statement, so as to obtain the i-th sub-statement. That is, a target statement with a character number of M is split into a plurality of sub-statements with lengths of N, N+1, N+2, ..., M.
[0073] For example, a forward iterative N-gram calculation method can be adopted, that is, a sentence is split into sub-sentences of N, N+1, N+2...M. For example, for an 8-character statement "I want to eat watermelon empty", when N=5, forward iteration can be performed on N to determine that the character number of each sub-statement is 5, 6, 7, 8, splitting the statement to obtain four sub-statements with 5, 6, 7 and 8 characters respectively: "I want to", "I want to eat", "I want to eat wate", "I want to eat waterm". The N-gram value of the four sub-statements is calculated respectively, and then the average value is calculated. In this way, the main part "I want to eat watermel" of the statement will be calculated multiple times, and its probability will be increased.
[0074] It should be noted that the statement identification method in this embodiment uses the N-gram algorithm to identify invalid corpus, and forward iterative calculation is added in the process of using the N-gram algorithm to identify invalid corpus. Since online speech is prone to have some noise prefixes and suffixes when transcribed into text, it is necessary to increase the probability value of statements with slight noise, so that sentences with clear semantics will not be filtered out. By adding forward iterative calculation, one sentence is split into multiple sentences, and the N-gram value of each sentence is calculated separately, which can increase the proportion of the effective sentence part and better tolerate statements with slight noise.
[0075] According to this embodiment, by intercepting the interactive statement according to a preset number of characters to obtain a plurality of sub-statements, the influence of noise on the validity of the interactive statement can be reduced, and the accuracy of statement identification can be improved.
[0076] In an exemplary embodiment, determining a target value for each of a plurality of sub-statements respectively by means of a target language model comprises:
[0077] S31, when there are (M-N+1) sub-statements in the plurality of sub-statements, for the i-th sub-statement in the plurality of sub-statements, the following steps are performed through the target language model to obtain the target value of the i-th sub-statement:
[0078] In the i-th sub-statement, the target sliding window starts sliding from the first word in the i-th sub-statement and extracts a sentence fragment containing N words each time, until the last position in the target sliding window covers the last word in the i-th sub-statement, resulting in a set of sentence fragments. The number of words covered by the target sliding window each time is N.
[0079] Determine the probability value for each statement fragment in a set of statement fragments, where the probability value for each statement fragment is the probability that each statement fragment is a valid statement;
[0080] The product of the probability values corresponding to each statement fragment is determined as the target value of the i-th sub-statement.
[0081] In this embodiment, when there are (M-N+1) sub-statements, for the i-th sub-statement, the i-th sub-statement can be truncated into one or more statement fragments, and the product of the valid probabilities of all statement fragments is calculated to obtain the probability that the i-th sub-statement belongs to a valid statement, that is, to obtain the target value of the i-th sub-statement.
[0082] When calculating the target value of the i-th sub-statement, a target sliding window of size N can be used to slide from the first word of the i-th sub-statement, extracting a statement segment containing N words each time, until the last position in the target sliding window covers the last word of the i-th sub-statement. By extracting the i-th sub-statement through a target sliding window of size N, a set of statement segments (i.e., i statement segments) can be obtained.
[0083] For each statement fragment in a set of statement segments, the probability value corresponding to each statement fragment can be determined separately. Here, the probability value corresponding to each statement fragment is the probability that each statement fragment is a valid statement, and the valid probability of the i-th substatement is the product of the valid probabilities of all statement fragments. That is, the product of the probability values corresponding to each statement fragment is determined as the target value of the i-th substatement.
[0084] In this embodiment, by extracting statement fragments from each statement and calculating the probability that each substatement is valid, the probability that each substatement is a valid statement can be obtained, thereby improving the accuracy of target value calculation.
[0085] In one exemplary embodiment, determining the probability value corresponding to each statement fragment in a set of statement fragments includes:
[0086] S41, when N is equal to or greater than 2, perform the following operations on each statement fragment in a set of statement fragments, wherein each statement fragment is the current statement fragment when performing the following operations:
[0087] Obtain the probability of the current statement fragment appearing in the preset target dataset to get the first probability, where the target dataset contains multiple statements;
[0088] Obtain the probability that the first to N-1 characters in the current sentence segment in the target dataset appear as a whole, and get the second probability;
[0089] The ratio of the first probability to the second probability is determined as the probability value corresponding to the current statement segment.
[0090] In this embodiment, when N is equal to or greater than 2, the valid probability of each sentence fragment can be the probability of the Nth character appearing given that the first to N-1 characters appear as a whole in the sentence fragment; that is, the probability that the Nth character appears after the first to N-1 characters. Here, the above probability can be represented by the ratio of the probability of the sentence fragment appearing in the target dataset (first probability) to the probability of the first to N-1 characters appearing as a whole in the target dataset (second probability).
[0091] To address this, the following operations can be performed on each statement fragment as the current statement fragment to determine the probability value corresponding to each statement fragment: obtain the probability of the current statement fragment appearing in the preset target dataset to obtain the first probability, where the target dataset contains multiple statements; obtain the probability of the first to N-1 characters in the current statement fragment appearing as a whole in the target dataset to obtain the second probability; and determine the probability value corresponding to the current statement fragment as the ratio of the first probability to the second probability.
[0092] For example, for the N-gram calculation formula, when N=2, P(w1, w2, w3...w m The calculation formula for ) is shown in formula (3):
[0093]
[0094] P(w m |w m-1 ) represents the probability that the m-th character appears after the (m-1)-th character, and its calculation method is shown in formula (4):
[0095]
[0096] Among them, C(w) m-1 ,w m ) represents the number of times the (m-1)th and mth characters appear simultaneously, C(w) m-1 () represents the number of times the (m-1)th character appears.
[0097] For example, P(box|ice) = C(refrigerator) / C(ice), which is the ratio of the number of times "refrigerator" appears to the number of "ice".
[0098] Similarly, when N=3, P(w1, w2, w3...w m The calculation formula for ) is shown in formula (5):
[0099]
[0100] In this embodiment, when N is equal to or greater than 2, the probability of each sub-statement segment being valid is calculated, thereby improving the accuracy of statement validity identification.
[0101] In one exemplary embodiment, determining the probability value corresponding to each statement fragment in a set of statement fragments includes:
[0102] S51, when N equals 1, perform the following operation on each statement fragment in a set of statement fragments, wherein each statement fragment is the current statement fragment when performing the following operation:
[0103] Obtain the probability of the current statement fragment appearing in the preset target dataset to get the first probability, where the target dataset contains multiple statements;
[0104] The cumulative probability is obtained by summing the probabilities of each word appearing in the i-th sub-statement in the target dataset.
[0105] The ratio of the first probability to the cumulative probability is determined as the probability value corresponding to the current statement segment.
[0106] When N equals 1, meaning each sub-statement segment contains only one character, the method for calculating the probability of a valid segment when N is greater than or equal to 2 is not applicable. Therefore, in this embodiment, for each segment obtained by dividing the i-th sub-statement, the probability of that segment appearing in the target dataset (first probability) can be calculated, and the sum of the probabilities of each character in the i-th sub-statement in the target dataset (cumulative probability) can be calculated. The ratio of the first probability to the cumulative probability is the probability value corresponding to that segment.
[0107] For each statement fragment, the following operations can be performed on it as the current statement fragment to determine the probability value corresponding to each statement fragment: obtain the probability of the current statement fragment appearing in the preset target dataset to obtain the first probability. Here, the target dataset contains multiple statements; obtain the sum of the probabilities of each word appearing in the i-th sub-statement in the target dataset to obtain the cumulative probability; and determine the probability value corresponding to the current statement fragment as the ratio of the first probability to the cumulative probability.
[0108] For example, for the N-gram calculation formula, when N=1, P(w1, w2, w3...w m The calculation formula for ) is shown in formula (6):
[0109]
[0110] That is, the product of the probabilities of each character appearing, and the probability of each character appearing is shown in formula (7):
[0111] P(w i )=C(w i ) / C(all) (7)
[0112] That is, the probability of each word appearing refers to the ratio of the number of times a word appears to the total number of words in a corpus (containing a large number of sentences of various kinds).
[0113] In this embodiment, when N equals 1, the probability of each sub-statement fragment being valid is calculated, thereby improving the accuracy of statement validity identification.
[0114] In one exemplary embodiment, determining whether a target statement is a valid statement involves comparing its average target value with a preset threshold, including:
[0115] S61, if the average target value of the target statement is less than a preset threshold, the target statement is determined to be an invalid statement;
[0116] S62, if the average target value of the target statement is greater than or equal to a preset threshold, the target statement is determined to be a valid statement.
[0117] In this embodiment, after obtaining the average target value of the target statement, the target statement can be determined as a valid or invalid statement based on the average target value. The average target value of the target statement can be compared with a preset threshold. If the average target value of the target statement is less than the preset threshold, the target statement can be determined as an invalid statement; if the average target value of the target statement is greater than or equal to the preset threshold, the target statement can be determined as a valid statement.
[0118] For example, a statement with M words can be split into clauses of length N, N+1, N+2...M; the N-gram value of each clause can be calculated; the average of all N-gram values can be calculated; the average value can be compared with a set threshold. If it is less than the threshold, the statement can be filtered out; otherwise, the normal parsing process can be followed.
[0119] This embodiment improves the accuracy of valid interaction statement judgment by comparing the average target value of the interaction statement with a preset threshold to determine whether the interaction statement is valid or invalid.
[0120] In one exemplary embodiment, after determining whether a target statement is a valid statement by comparing its average target value with a preset threshold, the method further includes:
[0121] S71, if it is determined that the target statement is not a valid statement, the voice device is controlled to refuse to perform semantic parsing on the target statement.
[0122] If the target statement is valid, the user's intent can be obtained through semantic parsing of the target statement, and corresponding device operations or responses to the user's interactive voice can be executed. If the target statement is invalid, it may be impossible to obtain the user's intent through semantic parsing of the target statement, or the obtained user intent may be incorrect. In order to reduce the interference of invalid statements on the semantic parsing of the voice device, the voice device can be controlled to refuse to perform semantic parsing of the target statement when it is determined to be invalid, which can reduce the consumption of voice device resources.
[0123] For example, when the final probability value is lower than the set threshold, the statement can be considered an invalid query and will not enter the subsequent semantic parsing process, thereby reducing interference with the system.
[0124] This embodiment controls the voice device to refuse semantic parsing of invalid statements, thereby reducing the interference of invalid statements on semantic parsing and improving the accuracy of semantic parsing by the voice device.
[0125] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that this application is not limited to the described order of actions, as some steps may be performed in other orders or simultaneously according to this application. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are preferred embodiments, and the actions and modules involved are not necessarily essential to this application.
[0126] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods according to the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM (Read-Only Memory) / RAM (Random Access Memory), magnetic disk, optical disk), and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, or network device, etc.) to execute the methods described in the various embodiments of this application.
[0127] According to another aspect of the embodiments of this application, a statement recognition device for implementing the above-described statement recognition method is also provided. Figure 3 This is a structural block diagram of an optional sentence recognition device according to an embodiment of this application, such as... Figure 3 As shown, the device may include:
[0128] The splitting unit 302 is used to split the target statement into multiple substatements, wherein the target statement is a statement with M words, and the number of words in each substatement is an integer in the range [N, M].
[0129] The first determining unit 304, connected to the splitting unit 302, is used to determine the target value of each sub-statement in the multiple sub-statements through the target language model, wherein the target value of each sub-statement in the multiple sub-statements is the probability that each sub-statement in the multiple sub-statements is a valid statement.
[0130] The second determining unit 306, connected to the first determining unit 304, is used to determine the average value of the target values of each sub-statement in the multiple sub-statements, and to obtain the average target value of the target statement, wherein the average target value is the probability that the target statement is a valid statement;
[0131] The third determining unit 308, connected to the second determining unit 306, is used to determine whether the target statement is a valid statement by comparing the average target value of the target statement with a preset threshold.
[0132] It should be noted that the splitting unit 302 in this embodiment can be used to execute the above step S202, the first determining unit 304 in this embodiment can be used to execute the above step S204, the second determining unit 306 in this embodiment can be used to execute the above step S206, and the third determining unit 308 in this embodiment can be used to execute the above step S208.
[0133] The above modules break down the target statement into multiple sub-statements, where the target statement is a statement with M characters, and the number of characters in each sub-statement is an integer within the range [N, M]. Using a target language model, the target value of each sub-statement is determined, where the target value of each sub-statement represents the probability that it is a valid statement. The average target value of the target statement is then calculated, representing the probability that it is a valid statement. By comparing the average target value with a preset threshold, the validity of the target statement is determined. This approach addresses the problem of low accuracy in statement validity recognition due to noise interference in related technologies, thus improving the accuracy of statement recognition.
[0134] In one exemplary embodiment, the splitting unit includes:
[0135] The first determining module is used to determine the number K of multiple sub-statements based on M and a preset N, where K is a positive integer greater than or equal to (M-N+1).
[0136] The first execution module performs the following operations on the target statement to obtain the i-th substatement among K substatements, where i is a positive integer greater than or equal to 1 and less than or equal to K:
[0137] Determine the number L of words included in the i-th sub-statement, where L is a positive integer greater than or equal to N;
[0138] Extract L characters from the first character of the target statement to obtain the i-th substatement.
[0139] In one exemplary embodiment, K equals (M-N+1), and L equals (N+i-1); the first execution module includes:
[0140] The truncation module is used to extract (N+i-1) consecutive characters starting from the first character in the target statement to obtain the i-th sub-statement.
[0141] In one exemplary embodiment, the first determining unit includes:
[0142] The second execution module is used to, when there are (M-N+1) sub-statements, perform the following steps through the target language model to obtain the target value of the i-th sub-statement:
[0143] In the i-th sub-statement, the target sliding window starts sliding from the first word in the i-th sub-statement and extracts a sentence fragment containing N words each time, until the last position in the target sliding window covers the last word in the i-th sub-statement, resulting in a set of sentence fragments. The number of words covered by the target sliding window each time is N.
[0144] Determine the probability value for each statement fragment in a set of statement fragments, where the probability value for each statement fragment is the probability that each statement fragment is a valid statement;
[0145] The product of the probability values corresponding to each statement fragment is determined as the target value of the i-th sub-statement.
[0146] In one exemplary embodiment, the second execution module includes:
[0147] The first execution submodule is used to perform the following operations on each statement fragment in a set of statement fragments when N is equal to or greater than 2, wherein each statement fragment is the current statement fragment when performing the following operations:
[0148] Obtain the probability of the current sentence fragment appearing in the preset target dataset to get the first probability, where the target dataset contains multiple sentences; obtain the probability of the first character to the (N-1)th character in the current sentence fragment in the target dataset appearing as a whole to get the second probability;
[0149] The ratio of the first probability to the second probability is determined as the probability value corresponding to the current statement segment.
[0150] In one exemplary embodiment, the second execution module includes: a second execution submodule, configured to perform the following operations on each statement fragment in a set of statement fragments when N equals 1, wherein each statement fragment is the current statement fragment when performing the following operations:
[0151] Obtain the probability of the current statement fragment appearing in the preset target dataset to get the first probability, where the target dataset contains multiple statements;
[0152] The cumulative probability is obtained by summing the probabilities of each word appearing in the i-th sub-statement in the target dataset.
[0153] The ratio of the first probability to the cumulative probability is determined as the probability value corresponding to the current statement segment.
[0154] In one exemplary embodiment, the third determining unit includes:
[0155] The second determination module is used to determine that the target statement is not a valid statement when the average target value of the target statement is less than a preset threshold.
[0156] The third determination module is used to determine that the target statement is a valid statement if the average target value of the target statement is greater than or equal to a preset threshold.
[0157] In one exemplary embodiment, the apparatus further includes:
[0158] The control unit is used to determine whether a target statement is valid by comparing its average target value with a preset threshold, and to control the voice device to refuse to perform semantic parsing on the target statement if it is determined to be invalid.
[0159] It should be noted that the examples and application scenarios implemented by the above modules and corresponding steps are the same, but are not limited to the content disclosed in the above embodiments. It should also be noted that the above modules, as part of a device, can operate in environments such as... Figure 1 The hardware environment shown can be implemented through software or hardware, and the hardware environment includes the network environment.
[0160] According to another aspect of the embodiments of this application, a storage medium is also provided. Optionally, in this embodiment, the storage medium can be used to execute the program code of any of the statement recognition methods described above in the embodiments of this application.
[0161] Optionally, in this embodiment, the storage medium may be located on at least one of the network devices in the network shown in the above embodiment.
[0162] Optionally, in this embodiment, the storage medium is configured to store program code for performing the following steps:
[0163] S1, split the target statement into multiple substatements, where the target statement is a statement with M words, and the number of words in each substatement is an integer in the range [N, M].
[0164] S2, using the target language model, determine the target value of each sub-statement in the multiple sub-statements, where the target value of each sub-statement in the multiple sub-statements is the probability that each sub-statement in the multiple sub-statements is a valid statement;
[0165] S3, determine the average of the target values of each sub-statement in the multiple sub-statements, and obtain the average target value of the target statement, where the average target value is the probability that the target statement is a valid statement;
[0166] S4 determines whether the target statement is a valid statement by comparing the average target value of the target statement with a preset threshold.
[0167] Optionally, specific examples in this embodiment can refer to the examples described in the above embodiments, and will not be repeated in this embodiment.
[0168] Optionally, in this embodiment, the storage medium may include, but is not limited to, various media capable of storing program code, such as USB flash drives, ROMs, RAMs, portable hard drives, magnetic disks, or optical disks.
[0169] According to another aspect of the embodiments of this application, an electronic device for implementing the above-described sentence recognition method is also provided. The electronic device may be a server, a terminal, or a combination thereof.
[0170] Figure 4 This is a structural block diagram of an optional electronic device according to an embodiment of this application, such as... Figure 4 As shown, it includes a processor 402, a communication interface 404, a memory 406, and a communication bus 408. The processor 402, communication interface 404, and memory 406 communicate with each other via the communication bus 408.
[0171] Memory 406 is used to store computer programs;
[0172] When processor 402 executes a computer program stored in memory 406, it performs the following steps:
[0173] S1, split the target statement into multiple substatements, where the target statement is a statement with M words, and the number of words in each substatement is an integer in the range [N, M].
[0174] S2, using the target language model, determine the target value of each sub-statement in the multiple sub-statements, where the target value of each sub-statement in the multiple sub-statements is the probability that each sub-statement in the multiple sub-statements is a valid statement;
[0175] S3, determine the average of the target values of each sub-statement in the multiple sub-statements, and obtain the average target value of the target statement, where the average target value is the probability that the target statement is a valid statement;
[0176] S4 determines whether the target statement is a valid statement by comparing the average target value of the target statement with a preset threshold.
[0177] Optionally, the communication bus can be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus, etc. This communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 4 The symbol is represented by a single thick line, but this does not indicate that there is only one bus or one type of bus. The communication interface is used for communication between the aforementioned electronic device and other devices.
[0178] The memory may include RAM, or non-volatile memory, such as at least one disk storage device. Optionally, the memory may also be at least one storage device located remotely from the aforementioned processor.
[0179] As an example, the memory 406 described above may include, but is not limited to, the splitting unit 302, the first determining unit 304, the second determining unit 306, and the third determining unit 308 from the statement recognition device described above. Furthermore, it may include, but is not limited to, other module units from the statement recognition device described above, which will not be elaborated upon in this example.
[0180] The processors mentioned above can be general-purpose processors, including but not limited to: CPU (Central Processing Unit), NP (Network Processor), etc.; they can also be DSP (Digital Signal Processor), ASIC (Application Specific Integrated Circuit), FPGA (Field-Programmable Gate Array), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.
[0181] Optionally, specific examples in this embodiment can refer to the examples described in the above embodiments, and will not be repeated here.
[0182] Those skilled in the art will understand that Figure 4 The structure shown is for illustrative purposes only. The device implementing the above statement recognition method can be a terminal device, such as a smartphone (e.g., Android phone, iOS phone), tablet computer, PDA, mobile Internet Devices (MID), PAD, etc. Figure 4 This does not limit the structure of the aforementioned electronic device. For example, the electronic device may also include components that are more... Figure 4 The more or fewer components shown (such as network interfaces, display devices, etc.), or having the same Figure 4 The different configurations shown.
[0183] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be implemented by a program instructing the hardware related to the terminal device. The program can be stored in a computer-readable storage medium, which may include: flash drive, ROM, RAM, disk or optical disk, etc.
[0184] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0185] If the integrated units in the above embodiments are implemented as software functional units and sold or used as independent products, they can be stored in the aforementioned computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause one or more computer devices (which may be personal computers, servers, or network devices, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application.
[0186] In the above embodiments of this application, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0187] In the several embodiments provided in this application, it should be understood that the disclosed client can be implemented in other ways. The device embodiments described above are merely illustrative; for example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces, indirect coupling or communication connection between units or modules, and may be electrical or other forms.
[0188] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of the solution provided in this embodiment, depending on actual needs.
[0189] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or at least two units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0190] The above description is only a preferred embodiment of this application. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of this application, and these improvements and modifications should also be considered within the scope of protection of this application.
Claims
1. A sentence recognition method, characterized in that, include: The target statement is split into multiple substatements, wherein the target statement is a statement with M words, and the number of words in each of the multiple substatements is an integer in the range [N, M]. Using a target language model, the target value of each sub-statement in the plurality of sub-statements is determined, wherein the target value of each sub-statement in the plurality of sub-statements is the probability that each sub-statement in the plurality of sub-statements is a valid statement; The average of the target values of each substatement in the plurality of substatements is determined to obtain the average target value of the target statement, wherein the average target value is the probability that the target statement is a valid statement; Whether the target statement is a valid statement is determined by comparing the average target value of the target statement with a preset threshold. The step of splitting the target statement into multiple substatements includes: determining the number K of the multiple substatements based on M and a preset N, where K is a positive integer greater than or equal to (M-N+1); performing the following operations on the target statement to obtain the i-th substatement among the K substatements, where i is a positive integer greater than or equal to 1 and less than or equal to K; determining the number L of words included in the i-th substatement, where L is a positive integer greater than or equal to N; and extracting L words from the first word of the target statement to obtain the i-th substatement.
2. The method according to claim 1, characterized in that, K equals (M-N+1), L equals (N+i-1); the step of extracting L characters from the first character of the target statement to obtain the i-th sub-statement includes: Starting from the first character in the target statement, extract (N+i-1) consecutive characters to obtain the i-th sub-statement.
3. The method according to claim 1, characterized in that, The step of determining the target value of each sub-statement among the plurality of sub-statements through the target language model includes: When there are (M-N+1) sub-statements, for the i-th sub-statement among the multiple sub-statements, the following steps are performed through the target language model to obtain the target value of the i-th sub-statement: In the i-th sub-statement, the target sliding window starts sliding from the first character in the i-th sub-statement and extracts a sentence fragment containing N characters each time, until the last position of the target sliding window covers the last character in the i-th sub-statement, resulting in a set of sentence fragments. The number of characters covered by the target sliding window each time is N. Determine the probability value corresponding to each statement fragment in the set of statement fragments, wherein the probability value corresponding to each statement fragment is the probability that each statement fragment is a valid statement; The product of the probability values corresponding to each of the statement fragments is determined as the target value of the i-th sub-statement.
4. The method according to claim 3, characterized in that, Determining the probability value corresponding to each statement fragment in the set of statement fragments includes: When N is equal to or greater than 2, perform the following operations on each statement fragment in the set of statement fragments, wherein each statement fragment is the current statement fragment when performing the following operations: Obtain the probability of the current statement fragment appearing in a preset target dataset to obtain a first probability, wherein the target dataset contains multiple statements; Obtain the probability that the first to N-1 characters in the current sentence segment appear as a whole in the target dataset, and get the second probability; The ratio of the first probability to the second probability is determined as the probability value corresponding to the current statement fragment.
5. The method according to claim 3, characterized in that, Determining the probability value corresponding to each statement fragment in the set of statement fragments includes: When N equals 1, perform the following operations on each statement fragment in the set of statement fragments, wherein each statement fragment is the current statement fragment when performing the following operations: Obtain the probability of the current statement fragment appearing in a preset target dataset to obtain a first probability, wherein the target dataset contains multiple statements; The cumulative probability is obtained by summing the probabilities of each word appearing in the i-th sub-statement in the target dataset. The ratio of the first probability to the cumulative probability is determined as the probability value corresponding to the current statement fragment.
6. The method according to claim 1, characterized in that, The step of determining whether the target statement is a valid statement by comparing the average target value of the target statement with a preset threshold includes: If the average target value of the target statement is less than the preset threshold, the target statement is determined to be an invalid statement. If the average target value of the target statement is greater than or equal to the preset threshold, the target statement is determined to be a valid statement.
7. The method according to claim 1, characterized in that, After determining whether the target statement is a valid statement by comparing its average target value with a preset threshold, the method further includes: If the target statement is determined to be invalid, the voice device is controlled to refuse to perform semantic parsing on the target statement.
8. A sentence recognition device, characterized in that, include: A splitting unit is used to split a target statement into multiple substatements, wherein the target statement is a statement with M words, and the number of words in each of the multiple substatements is an integer in the range [N, M]. The first determining unit is configured to determine the target value of each sub-statement among the plurality of sub-statements by means of a target language model, wherein the target value of each sub-statement among the plurality of sub-statements is the probability that each sub-statement among the plurality of sub-statements is a valid statement. The second determining unit is used to determine the average value of the target values of each of the plurality of sub-statements to obtain the average target value of the target statement, wherein the average target value is the probability that the target statement is a valid statement; The third determining unit is used to determine whether the target statement is a valid statement by comparing the average target value of the target statement with a preset threshold. The splitting unit includes: a first determining module, configured to determine the number K of the multiple sub-statements based on M and a preset N, where K is a positive integer greater than or equal to (M-N+1); and a first execution module, configured to perform the following operations on the target statement to obtain the i-th sub-statement among the K sub-statements, where i is a positive integer greater than or equal to 1 and less than or equal to K: determining the number L of words included in the i-th sub-statement, where L is a positive integer greater than or equal to N; and extracting L words from the first word of the target statement to obtain the i-th sub-statement.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes a stored program, wherein the program, when executed, performs the method of any one of claims 1 to 7.
10. An electronic device comprising a memory and a processor, characterized in that, The memory stores a computer program, and the processor is configured to execute the method of any one of claims 1 to 7 through the computer program.
Citation Information
Patent Citations
Speech recognition method and system for correcting noise text and storage medium
CN111326160A