WO2020052060A1 - 用于生成修正语句的方法和装置 - Google Patents
用于生成修正语句的方法和装置 Download PDFInfo
- Publication number
- WO2020052060A1 WO2020052060A1 PCT/CN2018/115953 CN2018115953W WO2020052060A1 WO 2020052060 A1 WO2020052060 A1 WO 2020052060A1 CN 2018115953 W CN2018115953 W CN 2018115953W WO 2020052060 A1 WO2020052060 A1 WO 2020052060A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- word
- words
- pending
- probability
- modified
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Ceased
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F40/00—Handling natural language data
- G06F40/20—Natural language analysis
- G06F40/279—Recognition of textual entities
- G06F40/289—Phrasal analysis, e.g. finite state techniques or chunking
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F40/00—Handling natural language data
- G06F40/20—Natural language analysis
- G06F40/205—Parsing
- G06F40/216—Parsing using statistical methods
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F40/00—Handling natural language data
- G06F40/20—Natural language analysis
- G06F40/232—Orthographic correction, e.g. spell checking or vowelisation
Definitions
- Embodiments of the present application relate to the field of computer technology, and in particular, to a method and an apparatus for generating a modified sentence.
- a search engine generally corrects a search sentence input by a user, and displays the corrected sentence for a user to select.
- the embodiments of the present application provide a method and a device for generating a modified sentence.
- an embodiment of the present application provides a method for generating a modified sentence.
- the method includes: obtaining a target sentence, and cutting the target sentence to obtain a set of words to be modified; Modify the word to determine whether there is a preset set of pending words in the target storage area corresponding to the word to be modified, where the pending word has a corresponding error probability and use probability, and the error probability is used to indicate that the pending word is incorrectly replaced with the
- the probability of the word to be modified is used to characterize the probability of the word to be used; in response to determining the existence, the modification probability of the word to be determined is determined based on the error probability and the use probability of the word to be determined, where the modification probability is used to characterize the word to be modified Probability that modified words will be modified into pending words; in accordance with the order of the obtained modified probability, a preset number of pending words are extracted from the pending word set as a subset of pending words; based on the obtained subset of pending words,
- the target storage area is a pre-established correspondence table.
- the correspondence table includes the words to be modified and the set of words to be determined.
- the correspondence table is used to represent the correspondence between the words to be modified and the set of words to be determined. Includes the probability of errors and usage of pending words.
- the error probability and usage probability of the pending word are obtained in advance according to the following steps: for the pending word in the pending word set, determining a preset word included in the text subset corresponding to the pending word and the pending word The number of is the first number, wherein the text subset is a preset subset of the text set; it is determined that the number of words to be modified included in the text in the text subset corresponding to the pending word and the pending word corresponding to the pending word is the second number ; Divide the determined second quantity by the sum of the first quantity and the second quantity to obtain the error probability of the pending word; determine the quantity of the pending word in the text set as the third quantity; and determine the determined third quantity The ratio to the total number of words included in the text in the text set is determined as the probability of use of the pending word.
- generating a correction sentence based on the obtained subset of pending words includes: using the pending words in the obtained subset of pending words, generating at least one candidate correction sentence, and obtaining at least one candidate correction sentence. Confidence of candidate correction sentences; based on the order of the obtained confidence degrees, candidate correction sentences are extracted from at least one candidate correction sentence as correction sentences.
- the method further includes: in response to determining that the preset storage area does not exist in the target storage area, and the The set of pending words corresponding to the word to be modified determines the pinyin of the Chinese characters included in the word to be modified; based on the determined pinyin, obtains at least one matching word that matches the pinyin; and selects a preset from the obtained at least one matching word A number of matching words are used as a subset of the pending words.
- the obtained matching words in the at least one matching word have a corresponding popularity value, and the popularity value is used to characterize the frequency with which the matching word is used; and from the obtained at least one matching word, selecting a preset number
- the matching words as the sub-set of pending words include: selecting a preset number of matching words from at least one of the obtained matching words as the sub-set of pending words according to the order of the magnitude of the heat value.
- an embodiment of the present application provides a device for generating a modified sentence.
- the device includes: an obtaining unit configured to obtain a target sentence, and segmenting the target sentence to obtain a set of words to be modified; an extraction unit , Configured to determine, for the to-be-corrected words in the to-be-corrected word set, a preset pending word set corresponding to the to-be-corrected word in the target storage area, where the pending word has a corresponding error probability and use probability, The error probability is used to characterize the probability that the pending word is wrongly replaced with the word to be revised, and the probability is used to characterize the probability that the pending word is used; in response to determining the existence, the modification of the pending word is determined based on the error probability and the use probability of the pending word Probability, in which the modified probability is used to characterize the probability of modifying the word to be modified into a word to be determined; according to the order of magnitude of the obtained modified probability, a preset number
- the target storage area is a pre-established correspondence table.
- the correspondence table includes the words to be modified and the set of words to be determined.
- the correspondence table is used to represent the correspondence between the words to be modified and the set of words to be determined. Includes the probability of errors and usage of pending words.
- the error probability and usage probability of the pending word are obtained in advance according to the following steps: for the pending word in the pending word set, determining a preset word included in the text subset corresponding to the pending word and the pending word The number of is the first number, wherein the text subset is a preset subset of the text set; it is determined that the number of words to be modified included in the text in the text subset corresponding to the pending word and the pending word corresponding to the pending word is the second number ; Divide the determined second quantity by the sum of the first quantity and the second quantity to obtain the error probability of the pending word; determine the quantity of the pending word in the text set as the third quantity; and determine the determined third quantity The ratio to the total number of words included in the text in the text set is determined as the probability of use of the pending word.
- the generating unit includes a generating module configured to generate at least one candidate correction sentence by using the pending words in the obtained subset of pending words, and obtain confidence of the candidate correction sentence in the at least one candidate correction sentence. Degree; an extraction module configured to extract a candidate correction sentence from at least one candidate correction sentence as a correction sentence based on a magnitude order of the obtained confidence degree.
- the extraction unit includes a determination module configured to determine the Pinyin of the Chinese character included in the to-be-corrected word in response to determining that there is no preset to-be-word set corresponding to the to-be-corrected word in the target storage area.
- An obtaining module configured to obtain at least one matching word that matches the pinyin based on the determined pinyin; a selecting module configured to select a preset number of matching words as the pending words from the obtained at least one matching word Child collection.
- the obtained matching words in the at least one matching word have a corresponding popularity value
- the popularity value is used to characterize the frequency with which the matching words are used
- the selection module is further configured to: according to the order of the popularity value, A preset number of matching words are selected from the obtained at least one matching word as a sub-set of pending words.
- an embodiment of the present application provides a server.
- the server includes: one or more processors; a storage device on which one or more programs are stored; and when one or more programs are processed by one or more The processor executes such that one or more processors implement the method as described in any implementation of the first aspect.
- an embodiment of the present application provides a computer-readable medium having stored thereon a computer program that, when executed by a processor, implements the method as described in any implementation manner of the first aspect.
- the method and device for generating a modified sentence obtained by the embodiments of the present application obtain a set of words to be modified by cutting a target sentence, and then determine a pending word corresponding to the word to be modified in the set of words to be modified.
- the word set and then based on the error probability and usage probability of the pending word, determine the modification probability of the pending word, and extract a preset number of pending words from the pending word set according to the order of the modified probability as the pending word corresponding to the pending word Sub-sets, and finally, based on the obtained sub-sets of each pending word, a modified sentence is generated, thereby improving the accuracy of correcting the sentence.
- FIG. 1 is an exemplary system architecture diagram to which an embodiment of the present application can be applied;
- FIG. 1 is an exemplary system architecture diagram to which an embodiment of the present application can be applied;
- FIG. 2 is a flowchart of an embodiment of a method for generating a modified sentence according to an embodiment of the present application
- FIG. 3 is a schematic diagram of an application scenario of a method for generating a modified sentence according to an embodiment of the present application
- FIG. 4 is a flowchart of another embodiment of a method for generating a modified sentence according to an embodiment of the present application
- FIG. 5 is a schematic structural diagram of an embodiment of an apparatus for generating a modified sentence according to an embodiment of the present application
- FIG. 6 is a schematic structural diagram of a computer system suitable for implementing a server according to an embodiment of the present application.
- FIG. 1 illustrates an exemplary system architecture 100 to which a method for generating a correction sentence or a device for generating a correction sentence according to an embodiment of the present application can be applied.
- the system architecture 100 may include terminal devices 101, 102, and 103, a network 104, and a server 105.
- the network 104 is a medium for providing a communication link between the terminal devices 101, 102, 103 and the server 105.
- the network 104 may include various connection types, such as wired, wireless communication links, or fiber optic cables, and so on.
- the user can use the terminal devices 101, 102, 103 to interact with the server 105 through the network 104 to receive or send messages and the like.
- Various communication client applications such as web browser applications, shopping applications, and search applications, can be installed on the terminal devices 101, 102, and 103.
- the terminal devices 101, 102, and 103 may be hardware or software.
- the terminal devices 101, 102, and 103 can be various electronic devices, including but not limited to smartphones, tablets, e-book readers, MP3 players (Moving Pictures Experts Group Audio Layer III, Motion Picture Expert Compression Standard Audio Level 3), MP4 (Moving Picture Experts Group Audio Audio Layer IV, Motion Picture Expert Compression Standard Audio Level 4) player, laptop portable computer and desktop computer, etc.
- the terminal devices 101, 102, and 103 are software, they can be installed in the electronic devices listed above. It can be implemented as multiple software or software modules (such as software or software modules used to provide distributed services), or it can be implemented as a single software or software module. It is not specifically limited here.
- the server 105 may be a server that provides various services, such as a background information processing server that processes target sentences uploaded by the terminal devices 101, 102, and 103.
- the background information processing server may process the obtained target sentence and obtain a processing result (for example, a correction sentence).
- the method for generating a correction sentence provided by the embodiment of the present application is generally executed by the server 105, and accordingly, a device for generating a correction sentence is generally provided in the server 105.
- the server may be hardware or software.
- the server can be implemented as a distributed server cluster consisting of multiple servers or as a single server.
- the server can be implemented as multiple software or software modules (such as software or software modules used to provide distributed services), or it can be implemented as a single software or software module. It is not specifically limited here.
- terminal devices, networks, and servers in FIG. 1 are merely exemplary. According to implementation needs, there can be any number of terminal devices, networks, and servers.
- a flowchart 200 of one embodiment of a method for generating a revised sentence according to the present application is shown.
- the method for generating a correction statement includes the following steps:
- Step 201 Obtain a target sentence and perform word segmentation on the target sentence to obtain a set of words to be modified.
- an execution subject of the method for generating a modified sentence may obtain the target sentence from a remote or local place through a wired connection method or a wireless connection method.
- the target sentence may be a sentence to be word-cut, and the target sentence may be a sentence input by a user using a terminal device (such as the terminal device shown in FIG. 1) and sent to the execution subject, or stored in advance in the above.
- Execute the statements in the body As an example, the target sentence may be a search sentence for searching for information, or a sentence extracted in advance from information such as an article, a text comment, and the like.
- the execution body may further perform word segmentation on the obtained target sentence to obtain a set of words to be modified.
- the foregoing execution subject may perform word segmentation on the target sentence according to an existing word segmentation method (such as a maximum forward matching method, an N-gram model method, a hidden Markov model method, etc.) to obtain a set of words to be modified.
- an existing word segmentation method such as a maximum forward matching method, an N-gram model method, a hidden Markov model method, etc.
- the set of words to be modified may include all words obtained by cutting the target sentence, and may also include words that partially meet preset conditions.
- part-of-speech tagging may be performed on each word obtained after segmentation of the target sentence, and words with a preset part-of-speech (eg, noun and / or verb) are extracted from each word as the words to be modified.
- a preset part-of-speech eg, noun and / or verb
- the method of tagging a part of speech is a well-known technique that is widely studied and applied at present, and is not repeated here.
- Step 202 For the to-be-modified words in the to-be-modified words set, determine whether a preset pending word set corresponding to the to-be-modified words exists in the target storage area; and in response to determining the existence, based on the error probability and use probability of the to-be-modified words To determine the correction probability of the pending words; in accordance with the order of the obtained revision probability, a preset number of pending words are extracted from the pending word set as a subset of the pending words.
- the foregoing execution subject may perform the following steps:
- step 2021 it is determined whether a preset pending word set corresponding to the word to be modified exists in the target storage area.
- the pending words have corresponding error probability and usage probability.
- the error probability corresponding to the pending word is used to represent the probability that the pending word is mistakenly replaced with the pending word. As an example, assuming that the probability of error of a pending word A is 10%, it means that the probability of the pending word being mistakenly used as the modified word is 10%.
- the use probability is used to characterize the probability that a pending word is used. Generally, the use probability may be a probability of occurrence of a pending word obtained by performing word frequency statistics on a preset text in advance.
- the error probability may be a probability obtained by counting the number of times a pending word is incorrectly replaced with a word to be corrected.
- the error probability and usage probability of a pending word can be obtained in advance according to the following steps:
- Step 1 Determine the preset number of the pending words included in the text in the text subset corresponding to the pending words as the first number.
- the text subset is a subset of a preset text set.
- step two it is determined that the number of to-be-corrected words corresponding to the pending word included in the text in the text subset corresponding to the pending word is the second number.
- the text subset corresponding to the to-be-determined words may be a text subset included in a text set preset by a technician.
- a text set is a collection of search statements entered in advance by a user.
- the text subset corresponding to the pending word may be a set of multiple search sentences including the pending word in the text set and multiple search sentences including the pending word corresponding to the pending word.
- Step 3 Divide the determined second quantity by the sum of the first quantity and the second quantity to obtain the error probability of the pending word.
- the word "suona" corresponds The probability of error is 10 / (10 + 90).
- Step four determine the number of the pending words in the text set as a third number, and determine the ratio of the determined third number to the total number of words included in the text in the text set as the use probability of the pending word.
- the target storage area may be a storage area pre-allocated in the execution body, or may be a storage area pre-allocated in an electronic device communicatively connected with the execution body. It should be noted that the target storage area may be an actual physical storage area (for example, an internal storage area such as a disk or a chip), or a virtual storage area (for example, a table or the like).
- the target storage area may store multiple to-be-revised words and multiple to-be-revised word sets, and each to-be-revised word may correspond to one to-be-revised word set.
- the target storage area is a pre-established correspondence table
- the correspondence table includes a word to be modified and a set of words to be determined, and the correspondence table is used to represent the words to be modified and the set of words to be determined.
- the correspondence table also includes the error probability and usage probability of the pending words.
- the correspondence table may be a two-dimensional table, and the table may store multiple words to be modified. Each word to be modified corresponds to three rows (or three columns) in the two-dimensional table, and each row (or column) is used separately. It is used to store the pending words corresponding to the pending words, the error probability of the pending words, and the usage probability of the pending words.
- the correspondence relationship table the set of pending words corresponding to the word to be corrected can be accurately determined, and it is helpful to visually present the words to be modified and the corresponding set of pending words.
- step 2022 in response to determining the existence, based on the error probability and the use probability of the pending word, a correction probability of the pending word is determined.
- the modification probability is used to represent the probability of modifying the word to be modified into a word to be determined.
- the greater the probability of modification the greater the probability that an error occurs in the word to be modified, that is, the greater the possibility that the word to be modified should be modified into the word to be determined.
- the above-mentioned execution subject may calculate a modified probability of a pending word based on a Bayesian formula.
- the Bayesian formula is:
- c is used to characterize the pending word
- w is used to characterize the pending word
- P (c) is the probability of using the pending word
- c) is the error probability corresponding to the pending word c, which is correct in the pending word c
- P (w) is the probability of using the pending word
- w) is the modification probability of the pending word c, that is, the pending word w should be modified Modification to the probability of the pending word c.
- P (w) may be a probability obtained by performing statistics on the words to be modified included in the text in the preset text set. For example, the ratio of the number of words to be modified to the total number of words included in the text in the text set is determined as the use probability of the words to be modified.
- Step 2023 Extract a preset number of pending words from the pending word set according to the obtained order of the modified probability as a pending word subset.
- the foregoing execution subject may extract a preset number of pending words from the pending word set in the order of each modification probability. It should be noted that when the number of pending words included in the pending word set is less than or equal to the preset number, the pending word set may be used as the pending word sub-set corresponding to the pending word set.
- Step 203 Generate a correction sentence based on the obtained sub-set of pending words.
- the execution subject may generate a correction sentence based on the obtained sub-set of pending words.
- the above-mentioned execution subject may extract the pending words from each pending word subset in the order of the modification probability from large to small, and compare the extracted pending words with those in the pending word set that do not have a corresponding pending word set.
- the words to be modified are combined into a modified sentence according to the arrangement order of the words to be modified in the set of words to be modified.
- the execution body may generate a correction statement according to the following steps:
- At least one candidate correction sentence is generated by using the pending words in the obtained subset of pending words, and the confidence of the candidate correction sentence in the at least one candidate correction sentence is obtained.
- the above execution body may use an existing sentence generation algorithm to generate at least one candidate correction sentence.
- the set of words to be modified obtained after cutting the target sentence is "A, B, C, D, and E"
- the set of pending words corresponding to the word B to be modified includes the pending words "B1” and "B2”, to be modified
- the set of pending words corresponding to the word E includes pending words "E1" and "E2”
- the generated at least one candidate correction sentence may include: “A1B1CD1E1”, “AB2CD1E1”, “AB1C D2E2 ",” A1B1C2D2E2 ".
- the sentence generation algorithm may include, but is not limited to, at least one of the following: a cluster search algorithm, a greedy search algorithm, and a Viterbi algorithm.
- each candidate correction sentence in the at least one candidate correction sentence obtained by using the above sentence generation algorithm may have a corresponding confidence degree.
- the confidence degree may be a sum of probabilities between pairs of adjacent words among the words included in the candidate correction sentence, where the probability between adjacent words is used to characterize the probability that two adjacent words are correct words . Confidence is used to characterize the probability that a candidate correction sentence is correct. The greater the confidence level, the greater the probability that the target sentence obtained in step 201 is modified into a candidate correction sentence corresponding to the confidence level.
- the above sentence generation algorithm is a well-known technology that is widely studied and applied at present, and is not repeated here.
- a candidate correction sentence is extracted from at least one candidate correction sentence as a correction sentence.
- the number of correction sentences may be at least one.
- the execution body may further output the correction statement in various ways.
- the correction sentence is displayed on a display connected to the execution subject, or the correction sentence is sent to a terminal device connected to the execution subject for display.
- FIG. 3 is a schematic diagram of an application scenario of the method for generating a modified sentence according to this embodiment.
- the server 301 first obtains a search sentence input by the user using the terminal device 302 as the target sentence 303 (for example, “I like to eat and flow”). Then, the server 301 performs word segmentation on the target sentence 303 to obtain a set of words to be modified 304 (for example, including "I", “like", “eat”, and “flowing”). Next, the server 301 determines that in the target storage area 305, the word “flowing” has a corresponding pending word set 306 (for example, it includes "durian", “love”, etc.).
- the server 301 uses the Bayesian formula and the error probability and usage probability of the pending words to calculate the revised probability of each pending word (for example, the durian's correction probability 3061 is 8%, and the "nostalgia" correction probability 3062 6%).
- a predetermined number for example, two
- the server 301 uses the cluster search algorithm to generate a correction sentence 308 (for example, “I like to eat durian”), and sends the correction sentence 308 to the terminal device 302, so that the terminal device 302 displays the correction sentence 308.
- the method provided by the foregoing embodiment of the present application obtains a set of words to be modified by cutting words of a target sentence, and then determines a set of pending words corresponding to the word to be modified for the words to be modified in the set of words to be modified, and then based on the to be determined
- the error probability and usage probability of the word determine the correction probability of the pending word, and extract a preset number of pending words from the pending word set according to the order of the revised probability, and finally based on the determined word subset of the pending word set.
- the obtained sub-set of each pending word generates a modified sentence, thereby improving the accuracy of correcting the sentence.
- a flowchart 400 of yet another embodiment of a method for generating a revised sentence is shown.
- the process 400 of the method for generating a correction statement includes the following steps:
- Step 401 Obtain a target sentence and perform word segmentation on the target sentence to obtain a set of words to be modified.
- step 401 is substantially the same as step 201 in the embodiment corresponding to FIG. 2, and details are not described herein again.
- Step 402 For the to-be-modified words in the to-be-modified words set, determine whether a preset to-be-fixed word set corresponding to the to-be-modified words exists in the target storage area; and in response to determining that they do not exist, determine the Chinese characters included in the to-be-modified words. Based on the determined pinyin, obtain at least one matching word that matches the pinyin; and from the obtained at least one matching word, select a preset number of matching words as a sub-set of pending words.
- the foregoing execution subject may perform the following steps:
- Step 4021 Determine whether a preset pending word set corresponding to the word to be modified exists in the target storage area.
- step 4021 is substantially the same as step 2021 in the embodiment corresponding to FIG. 2, and details are not described herein again.
- Step 4022 In response to determining that there is no preset pending word set corresponding to the word to be modified in the target storage area, determine the pinyin of the Chinese character contained in the word to be modified.
- an execution subject for example, a server shown in FIG. 1
- the method for generating a correction sentence may respond to determining that a preset pending word set corresponding to the word to be corrected does not exist in the target storage area, Determine the pinyin of the Chinese characters contained in the word to be modified. For example, if the word to be modified is "Zhengguo", and there is no set of words to be determined corresponding to "Zhengguo" in the target storage area, the pinyin "zhenggugao" of the word to be revised is determined.
- Step 4023 Based on the determined pinyin, obtain at least one matching word that matches the pinyin.
- the execution subject may obtain at least one matching word that matches the determined Pinyin from a preset word library.
- the preset vocabulary may be set in the execution subject in advance, or may be set in advance in an electronic device communicatively connected with the execution subject.
- the thesaurus may include multiple words, as well as the pinyin of each word.
- the matching words in the extracted at least one matching word may be words having the same or similar pinyin as the determined pinyin.
- the pinyin of the word to be corrected may correspond to a preset pinyin set.
- the pinyin of the word to be corrected is "zhengguogao”
- the corresponding pinyin set may include: “zhuanggugao”, “zhenggugao”
- Step 4024 From the obtained at least one matching word, select a preset number of matching words as a sub-set of pending words.
- the above-mentioned execution subject may select a preset number of matching words from the obtained at least one matching word in various ways as a sub-set of pending words.
- a preset number of matching words may be randomly selected from at least one matching word as a subset of pending words.
- a matching word in the obtained at least one matching word has a corresponding heat value, and the heat value is used to represent a frequency of using the word.
- the popularity value may be the number of times a user uses a word (such as a search using a word) within a preset period of time (for example, the past month); The ratio of the total number of words in the set of words (for example, all words used by some users in a preset time period).
- the above-mentioned execution subject may select a preset number of matching words as a sub-set of pending words from at least one obtained matching word based on the popularity value corresponding to the matching word as follows:
- a preset number of matching words are selected from the obtained at least one matching word as a sub-set of pending words.
- the above-mentioned execution subject may select a preset number of matching words from the obtained at least one matching word in order of the popularity value.
- the higher the heat value the more frequently the matching words are used, that is, the more likely the matching words are the words to be modified.
- the determined set of pending words may include "Zhuangguo" and "Zhengguo".
- Step 403 Generate a correction sentence based on the obtained sub-set of pending words.
- step 403 is substantially the same as step 203 in the embodiment corresponding to FIG. 2, and details are not described herein again.
- the process 400 of the method for generating a modified sentence in this embodiment highlights that there is no pending word corresponding to the word to be modified in the target storage area.
- this application provides an embodiment of an apparatus for generating a modified sentence, the apparatus embodiment corresponding to the method embodiment shown in FIG. 2,
- the device can be applied to various electronic devices.
- the apparatus 500 for generating a modified sentence in this embodiment includes: an obtaining unit 501 configured to obtain a target sentence, and segmenting the target sentence to obtain a set of words to be modified; the extracting unit 502, is It is configured to determine, for the to-be-corrected words in the to-be-corrected word set, a preset pending word set corresponding to the to-be-corrected word in the target storage area, wherein the pending word has a corresponding error probability, use probability, and error probability.
- the modified probability is used to characterize the probability of modifying the word to be modified into a word to be determined; according to the order of the obtained modified probability, a preset number of words to be determined are extracted from the set of words to be determined as a subset of the words to be determined; a generating unit 503, configured to generate a correction sentence based on the obtained subset of pending words. .
- the obtaining unit 501 may obtain the target sentence from a remote or local place through a wired connection method or a wireless connection method.
- the target sentence may be a sentence input by a user using a terminal device (for example, the terminal device shown in FIG. 1) and sent to the apparatus 500, or a sentence stored in the apparatus 500 in advance.
- the obtaining unit 501 may further perform word segmentation on the obtained target sentence to obtain a set of words to be modified.
- the foregoing obtaining unit 501 may perform word segmentation on the target sentence according to an existing word segmentation method (such as a maximum forward matching method, an N-gram model method, a hidden Markov model method, etc.) to obtain a set of words to be modified.
- an existing word segmentation method such as a maximum forward matching method, an N-gram model method, a hidden Markov model method, etc.
- the set of words to be modified may include all words obtained by cutting the target sentence, and may also include words that partially meet preset conditions.
- part-of-speech tagging may be performed on each word obtained after segmentation of the target sentence, and words with a preset part-of-speech (eg, noun and / or verb) are extracted from each word as the words to be modified.
- a preset part-of-speech eg, noun and / or verb
- the method of tagging a part of speech is a well-known technique that is widely studied and applied at present, and is not repeated here.
- the above-mentioned extraction unit 502 may perform the following steps:
- Step 5021 Determine whether a preset pending word set corresponding to the word to be modified exists in the target storage area.
- the pending word has a corresponding error probability and usage probability, and the error probability is used to represent the probability that the pending word is mistakenly replaced with the pending word.
- the error probability corresponding to a pending word A is 10%, which means that there is a 10% probability that the pending word A is misused, and the correct word is the pending word A.
- the use probability is used to characterize the probability that a pending word is used.
- the use probability may be the frequency of occurrence of a pending word obtained by performing word frequency statistics on a preset text in advance.
- the error probability may be a probability obtained by counting the number of times a pending word is incorrectly replaced with a word to be corrected.
- step 5022 in response to determining the existence, based on the error probability and the use probability of the pending word, a correction probability of the pending word is determined.
- the modification probability is used to represent the probability of modifying the word to be modified into a word to be determined.
- the greater the probability of modification the greater the probability that an error occurs in the word to be modified, that is, the greater the possibility that the word to be modified should be modified into the word to be determined.
- the above-mentioned extraction unit 502 may calculate a modified probability of a pending word based on a Bayesian formula.
- Step 5023 Extract a preset number of pending words from the pending word set according to the magnitude of the obtained modified probability as a pending word subset.
- the above-mentioned extraction unit 502 may extract a preset number of pending words from the pending word set in the order of each modification probability. It should be noted that when the number of pending words included in the pending word set is less than or equal to the preset number, the pending word set may be used as the pending word sub-set corresponding to the pending word set.
- the generating unit 503 may generate a correction sentence based on the obtained sub-set of pending words.
- the above-mentioned generating unit 503 may extract the pending words from each of the pending word subsets in the order of the modification probability, and extract the pending words from the pending word set in the pending word set without a corresponding pending word set.
- the words to be corrected are combined into a correction sentence.
- the target storage area is a pre-established correspondence table
- the correspondence table includes a word to be modified and a set of words to be determined, and the correspondence table is used to represent the words to be modified and the set of words to be determined.
- the correspondence table also includes the error probability and usage probability of the pending words.
- the error probability and usage probability of the pending words are obtained in advance according to the following steps: for the pending words in the pending word set, determining a preset preset text subset corresponding to the pending words
- the number of the pending words included in the text is the first number, wherein the text subset is a preset subset of the text set; it is determined that the text in the text subset corresponding to the pending word includes the pending correction corresponding to the pending word
- the number of words is the second number; dividing the determined second number by the sum of the first number and the second number to obtain the error probability of the pending word; determining the number of pending words in the text set as the third number, and A ratio of the determined third number to the total number of words included in the text in the text set is determined as a use probability of the pending word.
- the generating unit 503 may include: a generating module (not shown in the figure) configured to generate at least one candidate correction by using the pending words in the obtained subset of pending words. Statements, and obtain the confidence of candidate correction statements in at least one candidate correction statement; an extraction module (not shown in the figure) is configured to extract candidates from at least one candidate correction statement based on the order of magnitude of the obtained confidence degrees. A correction statement is used as a correction statement.
- the extraction unit 502 may include: a determining module (not shown in the figure), configured to respond to determining that a preset word that does not exist in the target storage area and the word to be modified do not exist.
- the corresponding set of pending words determines the Pinyin of the Chinese characters included in the word to be modified; an obtaining module (not shown in the figure) is configured to obtain at least one matching word that matches the Pinyin based on the determined Pinyin; a selecting module ( (Not shown in the figure), and is configured to select a preset number of matching words from the obtained at least one matching word as a sub-set of pending words.
- a matching word in the obtained at least one matching word has a corresponding heat value, and the heat value is used to characterize the frequency with which the matching word is used; and the selection module may be further configured to : Select a preset number of matching words from the at least one matching word obtained as the sub-set of pending words according to the order of the popularity value.
- the apparatus obtains a set of words to be modified by cutting words of a target sentence, and then determines a set of pending words corresponding to the word to be modified for the words to be modified in the set of words to be modified, and then based on the pending words
- the error probability and usage probability of the word determine the correction probability of the pending word, and extract a preset number of pending words from the pending word set according to the order of the revised probability, and finally based on the determined word subset of the pending word set.
- the obtained sub-set of each pending word generates a modified sentence, thereby improving the accuracy of correcting the sentence.
- FIG. 6 shows a schematic structural diagram of a computer system 600 suitable for implementing a server according to an embodiment of the present application.
- the server shown in FIG. 6 is only an example, and should not impose any limitation on the functions and scope of use of the embodiments of the present application.
- the computer system 600 includes a central processing unit (CPU) 601, which can be loaded into a random access memory (RAM) 603 according to a program stored in a read-only memory (ROM) 602 or from a storage portion 608. Instead, perform various appropriate actions and processes.
- RAM random access memory
- ROM read-only memory
- various programs and data required for the operation of the system 600 are also stored.
- the CPU 601, the ROM 602, and the RAM 603 are connected to each other through a bus 604.
- An input / output (I / O) interface 605 is also connected to the bus 604.
- the following components are connected to the I / O interface 605: an input portion 606 including a keyboard, a mouse, etc .; an output portion 607 including a liquid crystal display (LCD), etc .; a speaker, etc .; a storage portion 608 including a hard disk, etc .; A communication section 609 of a network interface card such as a modem.
- the communication section 609 performs communication processing via a network such as the Internet.
- the driver 610 is also connected to the I / O interface 605 as necessary.
- a removable medium 611 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 610 as needed, so that a computer program read therefrom is installed into the storage section 608 as needed.
- the process described above with reference to the flowchart may be implemented as a computer software program.
- embodiments of the present disclosure include a computer program product including a computer program carried on a computer-readable medium, the computer program containing program code for performing a method shown in a flowchart.
- the computer program may be downloaded and installed from a network through the communication portion 609, and / or installed from a removable medium 611.
- CPU central processing unit
- the computer-readable medium described in this application may be a computer-readable signal medium or a computer-readable medium or any combination of the foregoing.
- the computer-readable medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of computer-readable media may include, but are not limited to: electrical connections with one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable Read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination of the foregoing.
- a computer-readable medium may be any tangible medium that contains or stores a program that can be used by or in combination with an instruction execution system, apparatus, or device.
- a computer-readable signal medium may include a data signal that is included in baseband or propagated as part of a carrier wave, and which carries computer-readable program code. Such a propagated data signal may take many forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the foregoing.
- the computer-readable signal medium may also be any computer-readable medium other than a computer-readable medium, and the computer-readable medium may send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device.
- Program code embodied on a computer-readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
- Computer program code for performing the operations of the present application may be written in one or more programming languages, or combinations thereof, including programming languages such as Java, Smalltalk, C ++, and also conventional Procedural programming language—such as "C" or a similar programming language.
- the program code can be executed entirely on the user's computer, partly on the user's computer, as an independent software package, partly on the user's computer, partly on a remote computer, or entirely on a remote computer or server.
- the remote computer can be connected to the user's computer through any kind of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computer (such as through an Internet service provider) Internet connection).
- LAN local area network
- WAN wide area network
- Internet service provider Internet service provider
- each block in the flowchart or block diagram may represent a module, a program segment, or a part of code, which contains one or more functions to implement a specified logical function Executable instructions.
- the functions noted in the blocks may also occur in a different order than those marked in the drawings. For example, two successively represented boxes may actually be executed substantially in parallel, and they may sometimes be executed in the reverse order, depending on the functions involved.
- each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts can be implemented by a dedicated hardware-based system that performs the specified function or operation , Or it can be implemented with a combination of dedicated hardware and computer instructions.
- the units described in the embodiments of the present application may be implemented by software or hardware.
- the described unit may also be provided in a processor, for example, it may be described as: a processor includes an acquisition unit, an extraction unit, and a generation unit. Among them, the names of these units do not constitute a limitation on the unit itself in some cases.
- the acquisition unit can also be described as "a unit that obtains a target sentence and cuts the target sentence to obtain a set of words to be modified. ".
- the present application also provides a computer-readable medium, which may be included in the server described in the above embodiments; or may exist alone without being assembled into the server.
- the computer-readable medium carries one or more programs, and when the one or more programs are executed by the server, the server: obtains a target sentence, and performs word segmentation on the target sentence to obtain a set of words to be modified;
- the word to be modified in the word set is modified to determine whether a preset pending word set corresponding to the word to be modified exists in the target storage area, wherein the word to be determined has a corresponding error probability and use probability, and the error probability is used to represent the pending word
- the probability that a word is wrongly replaced with the word to be modified, and the use probability is used to characterize the probability of the word to be used; in response to determining the existence, the modification probability of the word to be determined is determined based on the error probability and the use probability of the word to be determined, where It is used to characterize the probability of modifying the pending word into
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- Audiology, Speech & Language Pathology (AREA)
- Computational Linguistics (AREA)
- General Health & Medical Sciences (AREA)
- Health & Medical Sciences (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Artificial Intelligence (AREA)
- Probability & Statistics with Applications (AREA)
- Machine Translation (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
本申请实施例公开了用于生成修正语句的方法和装置。该方法的一具体实施方式包括:获取目标语句,以及对目标语句进行切词,得到待修正词语集合;对于待修正词语集合中的待修正词语,确定目标存储区中是否存在预设的、与该待修正词语对应的待定词语集合;响应于确定存在,基于待定词语的错误概率和使用概率,确定待定词语的修正概率;按照所得到的修正概率的大小顺序,从待定词语集合中,提取预设数量个待定词语作为待定词语子集合;基于所得到的待定词语子集合,生成修正语句。该实施方式提高了对语句进行修正的准确性。
Description
本专利申请要求于2018年9月14日提交的、申请号为201811074035.4、申请人为北京字节跳动网络技术有限公司、发明名称为“用于生成修正语句的方法和装置”的中国专利申请的优先权,该申请的全文以引用的方式并入本申请中。
本申请实施例涉及计算机技术领域,具体涉及用于生成修正语句的方法和装置。
当人们利用手机、电脑等电子设备输入文字(例如向搜索引擎输入搜索语句、输入评论语句等)时,通常会产生输入文字错误的情况。这时需要将错误的文字修正。现有技术中,一般是由搜索引擎对用户输入的搜索语句进行纠错,并将纠正后的语句展示出来供用户选择。
发明内容
本申请实施例提出了用于生成修正语句的方法和装置。
第一方面,本申请实施例提供了一种用于生成修正语句的方法,该方法包括:获取目标语句,以及对目标语句进行切词,得到待修正词语集合;对于待修正词语集合中的待修正词语,确定目标存储区中是否存在预设的、与该待修正词语对应的待定词语集合,其中,待定词语具有对应的错误概率和使用概率,错误概率用于表征待定词语被错换为该待修正词语的概率,使用概率用于表征待定词语被使用的概率;响应于确定存在,基于待定词语的错误概率和使用概率,确定待定词语的修正概率,其中,修正概率用于表征将该待修正词语修改为待定词语的概率;按照所得到的修正概率的大小顺序,从待定词语集 合中,提取预设数量个待定词语作为待定词语子集合;基于所得到的待定词语子集合,生成修正语句。
在一些实施例中,目标存储区为预先建立的对应关系表,对应关系表包括待修正词语和待定词语集合,对应关系表用于表征待修正词语与待定词语集合的对应关系,对应关系表还包括待定词语的错误概率和使用概率。
在一些实施例中,待定词语的错误概率和使用概率预先按照如下步骤得到:对于待定词语集合中的待定词语,确定预设的、该待定词语对应的文本子集中的文本包括的、该待定词语的数量为第一数量,其中,文本子集是预设的文本集的子集;确定该待定词语对应的文本子集中的文本包括的、该待定词语对应的待修正词语的数量为第二数量;将所确定的第二数量除以第一数量与第二数量之和,得到该待定词语的错误概率;确定该待定词语在文本集中的数量为第三数量,以及将所确定的第三数量与文本集中的文本包括的词语的总数的比值确定为该待定词语的使用概率。
在一些实施例中,基于所得到的待定词语子集合,生成修正语句,包括:利用所得到的待定词语子集合中的待定词语,生成至少一个候选修正语句,以及得到至少一个候选修正语句中的候选修正语句的置信度;基于所得到的置信度的大小顺序,从至少一个候选修正语句中提取候选修正语句作为修正语句。
在一些实施例中,在确定目标存储区中是否存在预设的、与该待修正词语对应的待定词语集合之后,该方法还包括:响应于确定目标存储区中不存在预设的、与该待修正词语对应的待定词语集合,确定该待修正词语包含的汉字的拼音;基于所确定的拼音,获取至少一个与拼音相匹配的匹配词语;从所获取的至少一个匹配词语中,选择预设数量个匹配词语作为待定词语子集合。
在一些实施例中,所得到的至少一个匹配词语中的匹配词语具有对应的热度数值,热度数值用于表征匹配词语被使用的频率;以及从所获取的至少一个匹配词语中,选择预设数量个匹配词语作为待定词语子集合,包括:按照热度数值的大小顺序,从所获取的至少一个匹 配词语中选择预设数量个匹配词语作为待定词语子集合。
第二方面,本申请实施例提供了一种用于生成修正语句的装置,该装置包括:获取单元,被配置成获取目标语句,以及对目标语句进行切词,得到待修正词语集合;提取单元,被配置成对于待修正词语集合中的待修正词语,确定目标存储区中是否存在预设的、与该待修正词语对应的待定词语集合,其中,待定词语具有对应的错误概率和使用概率,错误概率用于表征待定词语被错换为该待修正词语的概率,使用概率用于表征待定词语被使用的概率;响应于确定存在,基于待定词语的错误概率和使用概率,确定待定词语的修正概率,其中,修正概率用于表征将该待修正词语修改为待定词语的概率;按照所得到的修正概率的大小顺序,从待定词语集合中,提取预设数量个待定词语作为待定词语子集合;生成单元,被配置成基于所得到的待定词语子集合,生成修正语句。
在一些实施例中,目标存储区为预先建立的对应关系表,对应关系表包括待修正词语和待定词语集合,对应关系表用于表征待修正词语与待定词语集合的对应关系,对应关系表还包括待定词语的错误概率和使用概率。
在一些实施例中,待定词语的错误概率和使用概率预先按照如下步骤得到:对于待定词语集合中的待定词语,确定预设的、该待定词语对应的文本子集中的文本包括的、该待定词语的数量为第一数量,其中,文本子集是预设的文本集的子集;确定该待定词语对应的文本子集中的文本包括的、该待定词语对应的待修正词语的数量为第二数量;将所确定的第二数量除以第一数量与第二数量之和,得到该待定词语的错误概率;确定该待定词语在文本集中的数量为第三数量,以及将所确定的第三数量与文本集中的文本包括的词语的总数的比值确定为该待定词语的使用概率。
在一些实施例中,生成单元包括:生成模块,被配置成利用所得到的待定词语子集合中的待定词语,生成至少一个候选修正语句,以及得到至少一个候选修正语句中的候选修正语句的置信度;提取模块,被配置成基于所得到的置信度的大小顺序,从至少一个候选修正语句 中提取候选修正语句作为修正语句。
在一些实施例中,提取单元包括:确定模块,被配置成响应于确定目标存储区中不存在预设的、与该待修正词语对应的待定词语集合,确定该待修正词语包含的汉字的拼音;获取模块,被配置成基于所确定的拼音,获取至少一个与拼音相匹配的匹配词语;选择模块,被配置成从所获取的至少一个匹配词语中,选择预设数量个匹配词语作为待定词语子集合。
在一些实施例中,所得到的至少一个匹配词语中的匹配词语具有对应的热度数值,热度数值用于表征匹配词语被使用的频率;以及选择模块进一步被配置成:按照热度数值的大小顺序,从所得到的至少一个匹配词语中选择预设数量个匹配词语作为待定词语子集合。
第三方面,本申请实施例提供了一种服务器,该服务器包括:一个或多个处理器;存储装置,其上存储有一个或多个程序;当一个或多个程序被一个或多个处理器执行,使得一个或多个处理器实现如第一方面中任一实现方式描述的方法。
第四方面,本申请实施例提供了一种计算机可读介质,其上存储有计算机程序,该计算机程序被处理器执行时实现如第一方面中任一实现方式描述的方法。
本申请实施例提供的用于生成修正语句的方法和装置,通过对目标语句进行切词,得到待修正词语集合,然后对于待修正词语集合中的待修正词语,确定该待修正词语对应的待定词语集合,再基于待定词语的错误概率和使用概率,确定待定词语的修正概率,以及按照修正概率的大小顺序从待定词语集合中,提取预设数量个待定词语作为该待修正词语对应的待定词语子集合,最后基于所得到的各个待定词语子集合,生成修正语句,从而提高了对语句进行修正的准确性。
通过阅读参照以下附图所作的对非限制性实施例所作的详细描述,本申请的其它特征、目的和优点将会变得更明显:
图1是本申请的一个实施例可以应用于其中的示例性系统架构图;
图2是根据本申请实施例的用于生成修正语句的方法的一个实施例的流程图;
图3是根据本申请实施例的用于生成修正语句的方法的一个应用场景的示意图;
图4是根据本申请实施例的用于生成修正语句的方法的又一个实施例的流程图;
图5是根据本申请实施例的用于生成修正语句的装置的一个实施例的结构示意图;
图6是适于用来实现本申请实施例的服务器的计算机系统的结构示意图。
下面结合附图和实施例对本申请作进一步的详细说明。可以理解的是,此处所描述的具体实施例仅仅用于解释相关发明,而非对该发明的限定。另外还需要说明的是,为了便于描述,附图中仅示出了与有关发明相关的部分。
需要说明的是,在不冲突的情况下,本申请中的实施例及实施例中的特征可以相互组合。下面将参考附图并结合实施例来详细说明本申请。
图1示出了可以应用本申请实施例的用于生成修正语句的方法或用于生成修正语句的装置的示例性系统架构100。
如图1所示,系统架构100可以包括终端设备101、102、103,网络104和服务器105。网络104用以在终端设备101、102、103和服务器105之间提供通信链路的介质。网络104可以包括各种连接类型,例如有线、无线通信链路或者光纤电缆等等。
用户可以使用终端设备101、102、103通过网络104与服务器105交互,以接收或发送消息等。终端设备101、102、103上可以安装有各种通讯客户端应用,例如网页浏览器应用、购物类应用、搜索类应用等。
终端设备101、102、103可以是硬件,也可以是软件。当终端设 备101、102、103为硬件时,可以是各种电子设备,包括但不限于智能手机、平板电脑、电子书阅读器、MP3播放器(Moving Picture Experts Group Audio Layer III,动态影像专家压缩标准音频层面3)、MP4(Moving Picture Experts Group Audio Layer IV,动态影像专家压缩标准音频层面4)播放器、膝上型便携计算机和台式计算机等等。当终端设备101、102、103为软件时,可以安装在上述所列举的电子设备中。其可以实现成多个软件或软件模块(例如用来提供分布式服务的软件或软件模块),也可以实现成单个软件或软件模块。在此不做具体限定。
服务器105可以是提供各种服务的服务器,例如对终端设备101、102、103上传的目标语句进行处理的后台信息处理服务器。后台信息处理服务器可以对获取的目标语句进行处理,并得到处理结果(例如修正语句)。
需要说明的是,本申请实施例所提供的用于生成修正语句的方法一般由服务器105执行,相应地,用于生成修正语句的装置一般设置于服务器105中。
需要说明的是,服务器可以是硬件,也可以是软件。当服务器为硬件时,可以实现成多个服务器组成的分布式服务器集群,也可以实现成单个服务器。当服务器为软件时,可以实现成多个软件或软件模块(例如用来提供分布式服务的软件或软件模块),也可以实现成单个软件或软件模块。在此不做具体限定。
应该理解,图1中的终端设备、网络和服务器的数目仅仅是示意性的。根据实现需要,可以具有任意数目的终端设备、网络和服务器。
继续参考图2,示出了根据本申请的用于生成修正语句的方法的一个实施例的流程200。该用于生成修正语句的方法,包括以下步骤:
步骤201,获取目标语句,以及对目标语句进行切词,得到待修正词语集合。
在本实施例中,用于生成修正语句的方法的执行主体(例如图1所示的服务器)可以通过有线连接方式或者无线连接方式从远程或从本地获取目标语句。其中,目标语句可以是待对其进行切词的语句, 目标语句可以是用户利用终端设备(例如图1所示的终端设备)输入,并发送至上述执行主体的语句,或者是预先存储在上述执行主体中的语句。作为示例,目标语句可以是用于搜索信息的搜索语句,或者是预先从诸如文章、文字评论等信息中提取的语句。
上述执行主体可以进一步对所获取的目标语句进行切词,得到待修正词语集合。具体地,上述执行主体可以按照现有的切词方法(例如最大正向匹配法、N-gram模型方法、隐马尔科夫模型方法等)对目标语句进行切词,得到待修正词语集合。
需要说明的是,待修正词语集合可以包括对上述目标语句进行切词后所得到的全部词语,也可以包括部分符合预设条件的词语。例如,可以对上述目标语句进行切词后所得到的每个词语进行词性标注,从各个词语中提取预设词性(例如名词和/或动词)的词语作为待修正词语。其中,对词语进行词性标注的方法是目前广泛研究和应用的公知技术,在此不再赘述。
步骤202,对于待修正词语集合中的待修正词语,确定目标存储区中是否存在预设的、与该待修正词语对应的待定词语集合;响应于确定存在,基于待定词语的错误概率和使用概率,确定待定词语的修正概率;按照所得到的修正概率的大小顺序,从待定词语集合中,提取预设数量个待定词语作为待定词语子集合。
在本实施例中,对于待修正词语集合中的待修正词语,上述执行主体可以执行如下步骤:
步骤2021,确定目标存储区中是否存在预设的、与该待修正词语对应的待定词语集合。
其中,待定词语具有对应的错误概率和使用概率。待定词语所对应的错误概率用于表征待定词语被错换为该待修正词语的概率。作为示例,假设某待定词语A对应的错误概率为10%,表示该待定词语被错用为该修正词语的概率为10%。使用概率用于表征待定词语被使用的概率。通常,使用概率可以是预先对预设的文本进行词频统计所得到的、待定词语出现的概率。错误概率可以是预先对将待定词语错换为待修正词语的次数进行统计所得到的概率。
在本实施例的一些可选的实现方式中,待定词语的错误概率和使用概率可以预先按照如下步骤得到:
对于待定词语集合中的待定词语,执行如下步骤:
步骤一,确定预设的、该待定词语对应的文本子集中的文本包括的、该待定词语的数量为第一数量。其中,文本子集是预设的文本集的子集。
步骤二,确定该待定词语对应的文本子集中的文本包括的、该待定词语对应的待修正词语的数量为第二数量。
作为示例,假设某待定词语为“唢呐”,对应的文本子集中的所有文本包括的词语“唢呐”的数量为第一数量;词语“唢呐”对应的待修正词语为“所纳”,文本子集中的所有文本包括的词语“所纳”的数量为第二数量。需要说明的是,待定词语对应的文本子集可以是技术人员预先设置的文本集包括的文本子集。例如,文本集是预先获取的、用户输入的搜索语句的集合。待定词语对应的文本子集可以是文本集中的、包括待定词语的多条搜索语句和包括待定词语对应的待修正词语的多条搜索语句的集合。
步骤三,将所确定的第二数量除以第一数量与第二数量之和,得到该待定词语的错误概率。
继续上述示例,假设文本子集中的文本包括的词语“所纳”(即待修正词语)的数量为10,包括的词语“唢呐”(即待定词语)的数量为90,则词语“唢呐”对应的错误概率为10/(10+90)。
步骤四,确定该待定词语在文本集中的数量为第三数量,以及将所确定的第三数量与文本集中的文本包括的词语的总数的比值确定为该待定词语的使用概率。
在本实施例中,上述目标存储区可以是在上述执行主体中预先分配的存储区,也可以是在与上述执行主体通信连接的电子设备中预先分配的存储区。需要说明的是,目标存储区可以是实际的物理存储区(例如磁盘、芯片等内部的存储区),也可以是虚拟存储区(例如表格等)。
作为示例,目标存储区中可以存储有多个待修正词语和多个待定 词语集合,每个待修正词语可以对应一个待定词语集合。
在本实施例的一些可选的实现方式中,目标存储区为预先建立的对应关系表,对应关系表包括待修正词语和待定词语集合,对应关系表用于表征待修正词语与待定词语集合的对应关系,对应关系表还包括待定词语的错误概率和使用概率。作为示例,对应关系表可以是二维表格,该表格可以存储有多个待修正词语,每个待修正词语对应二维表中的三行(或三列),各行(或各列)分别用于存储待修正词语对应的待定词语、待定词语的错误概率和待定词语的使用概率。通过使用对应关系表,可以准确地确定待修正词语对应的待定词语集合,以及有助于直观地呈现待修正词语和对应的待定词语集合。
步骤2022,响应于确定存在,基于待定词语的错误概率和使用概率,确定待定词语的修正概率。
其中,修正概率用于表征将该待修正词语修改为待定词语的概率。通常,修正概率越大,表示该待修正词语发生错误的可能性越大,即应当将该待修正词语修改为待定词语的可能性越大。作为示例,上述执行主体可以基于贝叶斯公式,计算得到待定词语的修正概率。具体地,贝叶斯公式为:
P(c|w)=P(w|c)×P(c)/P(w),
其中,c用于表征待定词语;w用于表征待修正词语;P(c)为待定词语的使用概率;P(w|c)为待定词语c对应的错误概率,即在待定词语c正确的前提下,待定词语c被错误地写成待修正词语w的概率;P(w)为待修正词语的使用概率;P(c|w)为待定词语c的修正概率,即待修正词语w应当被修改为待定词语c的概率。其中,P(w)可以是对预设的文本集合中的文本包括的待修正词语进行统计得到概率。例如,将待修正词语的数量与文本集中的文本包括的词语的总数的比值确定为待修正词语的使用概率。
作为另一示例,对于某个待修正词语的使用概率P(w),由于该待修正词语的使用概率P(w)是固定的,因此,上述公式中的P(c|w)正比于P(w|c)×P(c),确定待定词语的修正概率的公式可以近似为如下公式:
P(c|w)=P(w|c)×P(c)。
步骤2023,按照所得到的修正概率的大小顺序,从待定词语集合中,提取预设数量个待定词语作为待定词语子集合。
作为示例,上述执行主体可以按照各个修正概率由大到小的顺序,从待定词语集合中,提取预设数量个待定词语。需要说明的是,当待定词语集合包括的待定词语的数量小于等于上述预设数量时,可以将待定词语集合作为待修正词语对应的待定词语子集合。
步骤203,基于所得到的待定词语子集合,生成修正语句。
在本实施例中,上述执行主体可以基于所得到的待定词语子集合,生成修正语句。
作为示例,上述执行主体可以按照修正概率由大到小的顺序,从各个待定词语子集合中分别提取待定词语,将提取的待定词语与待修正词语集合中的、不具有对应的待定词语集合的待修正词语按照待修正词语集合中的待修正词语的排列顺序,组合为修正语句。
在本实施例的一些可选的实现方式中,上述执行主体可以按照如下步骤生成修正语句:
首先,利用所得到的待定词语子集合中的待定词语,生成至少一个候选修正语句,以及得到至少一个候选修正语句中的候选修正语句的置信度。具体地,上述执行主体可以利用现有的语句生成算法,生成至少一个候选修正语句。作为示例,假设对目标语句切词后得到的待修正词语集合为“A B C D E”,其中,待修正词语B对应的待定词语子集合包括待定词语“B1”和“B2”,待修正词语E对应的待定词语子集合包括待定词语“E1”和“E2”,则生成的至少一个候选修正语句可以包括:“A B1 C D E1”、“A B2 C D E1”、“A B1 C D E2”、“A B1 C D E2”。
其中,语句生成算法可以包括但不限于以下至少一种:集束搜索算法、贪心搜索算法、维特比算法。
通常,利用上述语句生成算法得到的至少一个候选修正语句中的每个候选修正语句,可以具有对应的置信度。具体地,置信度可以是候选修正语句包括的词语中,各相邻词语对之间的概率之和,其中,相邻词语之间的概率用于表征两个相邻词语是正确的词语的概率。置 信度用于表征候选修正语句为正确语句的概率。置信度越大,表示步骤201中获取的目标语句被修改为该置信度对应的候选修正语句的概率越大。需要说明的是,上述语句生成算法是目前广泛研究和应用的公知技术,在此不再赘述。
然后,基于所得到的置信度的大小顺序,从至少一个候选修正语句中提取候选修正语句作为修正语句。具体地,修正语句的数量可以是至少一个。
可选地,上述执行主体可以进一步将修正语句以各种方式输出。例如,将修正语句在与上述执行主体连接的显示器上显示,或者将修正语句发送到与上述执行主体通信连接的终端设备上显示。
继续参见图3,图3是根据本实施例的用于生成修正语句的方法的应用场景的一个示意图。在图3的应用场景中,服务器301首先获取到用户利用终端设备302输入的搜索语句作为目标语句303(例如“我喜欢吃流连”)。然后,服务器301对目标语句303进行切词,得到待修正词语集合304(例如包括“我”,“喜欢”,“吃”,“流连”)。接着,服务器301确定目标存储区305中,词语“流连”具有对应的待定词语集合306(例如包括“榴莲”,“留恋”等)。而其他词语没有对应的待修正词语集合。再然后,服务器301利用贝叶斯公式,以及利用待定词语的错误概率和使用概率,计算出各个待定词语的修正概率(例如“榴莲”的修正概率3061为8%,“留恋”的修正概率3062为6%)。再按照所得到的修正概率的大小顺序,从待定词语集合306中,提取预设数量个(例如两个)待定词语作为待定词语子集合307。最后,服务器301利用集束搜索算法,生成修正语句308(例如“我喜欢吃榴莲”),并将修正语句308发送给终端设备302,以使终端设备302上显示该修正语句308。
本申请的上述实施例提供的方法,通过对目标语句进行切词,得到待修正词语集合,然后对于待修正词语集合中的待修正词语,确定该待修正词语对应的待定词语集合,再基于待定词语的错误概率和使用概率,确定待定词语的修正概率,以及按照修正概率的大小顺序从待定词语集合中,提取预设数量个待定词语作为该待修正词语对应的 待定词语子集合,最后基于所得到的各个待定词语子集合,生成修正语句,从而提高了对语句进行修正的准确性。
进一步参考图4,其示出了用于生成修正语句的方法的又一个实施例的流程400。该用于生成修正语句的方法的流程400,包括以下步骤:
步骤401,获取目标语句,以及对目标语句进行切词,得到待修正词语集合。
在本实施例中,步骤401与图2对应实施例中的步骤201基本一致,这里不再赘述。
步骤402,对于待修正词语集合中的待修正词语,确定目标存储区中是否存在预设的、与该待修正词语对应的待定词语集合;响应于确定不存在,确定该待修正词语包含的汉字的拼音;基于所确定的拼音,获取至少一个与拼音相匹配的匹配词语;从所获取的至少一个匹配词语中,选择预设数量个匹配词语作为待定词语子集合。
在本实施例中,对于待修正词语集合中的待修正词语,上述执行主体可以执行如下步骤:
步骤4021,确定目标存储区中是否存在预设的、与该待修正词语对应的待定词语集合。
在本实施例中,步骤4021与图2对应实施例中的步骤2021基本一致,这里不再赘述。
步骤4022,响应于确定目标存储区中不存在预设的、与该待修正词语对应的待定词语集合,确定该待修正词语包含的汉字的拼音。
在本实施例中,用于生成修正语句的方法的执行主体(例如图1所示的服务器)可以响应于确定目标存储区中不存在预设的、与该待修正词语对应的待定词语集合,确定该待修正词语包含的汉字的拼音。例如,待修正词语为“正骨膏”,目标存储区中不存在与“正骨膏”对应的待定词语集合,则确定该待修正词语的拼音“zheng gu gao”。
步骤4023,基于所确定的拼音,获取至少一个与拼音相匹配的匹配词语。
在本实施例中,上述执行主体可以从预设的词库中,获取至少一个与所确定的拼音相匹配的匹配词语。其中,预设的词库可以预先设置在上述执行主体中,或者预先设置在与上述执行主体通信连接的电子设备中。作为示例,词库可以包括多个词语,以及每个词语的拼音。
所提取的至少一个匹配词语中的匹配词语可以是包括的汉字的拼音与所确定的拼音相同或相似的词语。具体地,待修正词语的拼音可以对应于预设的拼音集合,例如,该待修正词语的拼音为“zheng gu gao”,对应的拼音集合可以包括:“zhuang gu gao”、“zheng gu gao”,则可以从预设的词库中,提取拼音为“zhuang gu gao”或“zheng gu gao”的词语作为匹配词语(例如至少一个匹配词语包括“壮骨膏”、“壮骨高”、“正骨膏”等)。
步骤4024,从所获取的至少一个匹配词语中,选择预设数量个匹配词语作为待定词语子集合。
在本实施例中,上述执行主体可以按照各种方式从所获取的至少一个匹配词语中,选择预设数量个匹配词语作为待定词语子集合。例如,可以从至少一个匹配词语中,随机选择预设数量个匹配词语作为待定词语子集合。
在本实施例的一些可选的实现方式中,所得到的至少一个匹配词语中的匹配词语具有对应的热度数值,热度数值用于表征词语被使用的频率。作为示例,热度数值可以是预设时间段(例如过去一个月)内,用户使用词语(例如使用词语进行搜索)的次数;或者可以是预设时间段内,用户使用词语的次数与使用预设的词语集合(例如预设时间段内某些用户使用的所有词语)中的词语的总次数的比值。
上述执行主体可以基于匹配词语对应的热度数值,按照如下步骤从所获取的至少一个匹配词语中,选择预设数量个匹配词语作为待定词语子集合:
按照热度数值的大小顺序,从所获取的至少一个匹配词语中选择预设数量个匹配词语作为待定词语子集合。作为示例,上述执行主体可以按照热度数值由大到小的顺序,从所获取的至少一个匹配词语中选择预设数量个匹配词语。通常,热度数值越大,表示匹配词语被使 用的频率越高,即匹配词语是待修正词语应当修改为的词语的可能性越大。
作为示例,假设预设数量为2,至少一个匹配词语中,匹配词语“壮骨膏”的热度数值最大,匹配词语“正骨膏”的热度数值居其次。则确定的待定词语子集合可以包括“壮骨膏”和“正骨膏”。
步骤403,基于所得到的待定词语子集合,生成修正语句。
在本实施例中,步骤403与图2对应实施例中的步骤203基本一致,这里不再赘述。
从图4中可以看出,与图2对应的实施例相比,本实施例中的用于生成修正语句的方法的流程400突出了在目标存储区中不存在与待修正词语对应的待定词语集合的情况下,确定待定词语子集合的步骤。由此,本实施例描述的方案可以使待定词语子集合更加全面,从而可以进一步提高对语句进行修正的准确性。
进一步参考图5,作为对上述各图所示方法的实现,本申请提供了一种用于生成修正语句的装置的一个实施例,该装置实施例与图2所示的方法实施例相对应,该装置具体可以应用于各种电子设备中。
如图5所示,本实施例的用于生成修正语句的装置500包括:获取单元501,被配置成获取目标语句,以及对目标语句进行切词,得到待修正词语集合;提取单元502,被配置成对于待修正词语集合中的待修正词语,确定目标存储区中是否存在预设的、与该待修正词语对应的待定词语集合,其中,待定词语具有对应的错误概率和使用概率,错误概率用于表征待定词语被错换为该待修正词语的概率,使用概率用于表征待定词语被使用的概率;响应于确定存在,基于待定词语的错误概率和使用概率,确定待定词语的修正概率,其中,修正概率用于表征将该待修正词语修改为待定词语的概率;按照所得到的修正概率的大小顺序,从待定词语集合中,提取预设数量个待定词语作为待定词语子集合;生成单元503,被配置成基于所得到的待定词语子集合,生成修正语句。
在本实施例中,获取单元501可以通过有线连接方式或者无线连 接方式从远程或从本地获取目标语句。其中,目标语句可以是用户利用其使用的终端设备(例如图1所示的终端设备)输入,并发送至上述装置500的语句,或者是预先存储在上述装置500中的语句。上述获取单元501可以进一步对所获取的目标语句进行切词,得到待修正词语集合。具体地,上述获取单元501可以按照现有的切词方法(例如最大正向匹配法、N-gram模型方法、隐马尔科夫模型方法等)对目标语句进行切词,得到待修正词语集合。
需要说明的是,待修正词语集合可以包括对上述目标语句进行切词后所得到的全部词语,也可以包括部分符合预设条件的词语。例如,可以对上述目标语句进行切词后所得到的每个词语进行词性标注,从各个词语中提取预设词性(例如名词和/或动词)的词语作为待修正词语。其中,对词语进行词性标注的方法是目前广泛研究和应用的公知技术,在此不再赘述。
在本实施例中,对于待修正词语集合中的待修正词语,上述提取单元502可以执行如下步骤:
步骤5021,确定目标存储区中是否存在预设的、与该待修正词语对应的待定词语集合。
其中,待定词语具有对应的错误概率和使用概率,错误概率用于表征待定词语被错换为该待修正词语的概率。作为示例,假设某待定词语A对应的错误概率为10%,表示该待修正词语有10%的概率被错用,且正确的词语为该待定词语A。使用概率用于表征待定词语被使用的概率。通常,使用概率可以是预先对预设的文本进行词频统计所得到的、待定词语出现的频率。错误概率可以是预先对将待定词语错换为待修正词语的次数进行统计所得到的概率。
步骤5022,响应于确定存在,基于待定词语的错误概率和使用概率,确定待定词语的修正概率。
其中,修正概率用于表征将该待修正词语修改为待定词语的概率。通常,修正概率越大,表示该待修正词语发生错误的可能性越大,即应当将该待修正词语修改为待定词语的可能性越大。作为示例,上述提取单元502可以基于贝叶斯公式,计算得到待定词语的修正概率。
步骤5023,按照所得到的修正概率的大小顺序,从待定词语集合中,提取预设数量个待定词语作为待定词语子集合。
作为示例,上述提取单元502可以按照各个修正概率由大到小的顺序,从待定词语集合中,提取预设数量个待定词语。需要说明的是,当待定词语集合包括的待定词语的数量小于等于上述预设数量时,可以将待定词语集合作为待修正词语对应的待定词语子集合。
在本实施例中,生成单元503可以基于所得到的待定词语子集合,生成修正语句。
作为示例,上述生成单元503可以按照修正概率由大到小的顺序,从各个待定词语子集合中分别提取待定词语,将提取的待定词语与待修正词语集合中的、不具有对应的待定词语集合的待修正词语组合为修正语句。
在本实施例的一些可选的实现方式中,目标存储区为预先建立的对应关系表,对应关系表包括待修正词语和待定词语集合,对应关系表用于表征待修正词语与待定词语集合的对应关系,对应关系表还包括待定词语的错误概率和使用概率。
在本实施例的一些可选的实现方式中,待定词语的错误概率和使用概率预先按照如下步骤得到:对于待定词语集合中的待定词语,确定预设的、该待定词语对应的文本子集中的文本包括的、该待定词语的数量为第一数量,其中,文本子集是预设的文本集的子集;确定该待定词语对应的文本子集中的文本包括的、该待定词语对应的待修正词语的数量为第二数量;将所确定的第二数量除以第一数量与第二数量之和,得到该待定词语的错误概率;确定该待定词语在文本集中的数量为第三数量,以及将所确定的第三数量与文本集中的文本包括的词语的总数的比值确定为该待定词语的使用概率。
在本实施例的一些可选的实现方式中,生成单元503可以包括:生成模块(图中未示出),被配置成利用所得到的待定词语子集合中的待定词语,生成至少一个候选修正语句,以及得到至少一个候选修正语句中的候选修正语句的置信度;提取模块(图中未示出),被配置成基于所得到的置信度的大小顺序,从至少一个候选修正语句中提取候 选修正语句作为修正语句。
在本实施例的一些可选的实现方式中,提取单元502可以包括:确定模块(图中未示出),被配置成响应于确定目标存储区中不存在预设的、与该待修正词语对应的待定词语集合,确定该待修正词语包含的汉字的拼音;获取模块(图中未示出),被配置成基于所确定的拼音,获取至少一个与拼音相匹配的匹配词语;选择模块(图中未示出),被配置成从所获取的至少一个匹配词语中,选择预设数量个匹配词语作为待定词语子集合。
在本实施例的一些可选的实现方式中,所得到的至少一个匹配词语中的匹配词语具有对应的热度数值,热度数值用于表征匹配词语被使用的频率;以及选择模块可以进一步被配置成:按照热度数值的大小顺序,从所得到的至少一个匹配词语中选择预设数量个匹配词语作为待定词语子集合。
本申请的上述实施例提供的装置,通过对目标语句进行切词,得到待修正词语集合,然后对于待修正词语集合中的待修正词语,确定该待修正词语对应的待定词语集合,再基于待定词语的错误概率和使用概率,确定待定词语的修正概率,以及按照修正概率的大小顺序从待定词语集合中,提取预设数量个待定词语作为该待修正词语对应的待定词语子集合,最后基于所得到的各个待定词语子集合,生成修正语句,从而提高了对语句进行修正的准确性。
下面参考图6,其示出了适于用来实现本申请实施例的服务器的计算机系统600的结构示意图。图6示出的服务器仅仅是一个示例,不应对本申请实施例的功能和使用范围带来任何限制。
如图6所示,计算机系统600包括中央处理单元(CPU)601,其可以根据存储在只读存储器(ROM)602中的程序或者从存储部分608加载到随机访问存储器(RAM)603中的程序而执行各种适当的动作和处理。在RAM 603中,还存储有系统600操作所需的各种程序和数据。CPU 601、ROM 602以及RAM 603通过总线604彼此相连。输入/输出(I/O)接口605也连接至总线604。
以下部件连接至I/O接口605:包括键盘、鼠标等的输入部分606;包括诸如液晶显示器(LCD)等以及扬声器等的输出部分607;包括硬盘等的存储部分608;以及包括诸如LAN卡、调制解调器等的网络接口卡的通信部分609。通信部分609经由诸如因特网的网络执行通信处理。驱动器610也根据需要连接至I/O接口605。可拆卸介质611,诸如磁盘、光盘、磁光盘、半导体存储器等等,根据需要安装在驱动器610上,以便于从其上读出的计算机程序根据需要被安装入存储部分608。
特别地,根据本公开的实施例,上文参考流程图描述的过程可以被实现为计算机软件程序。例如,本公开的实施例包括一种计算机程序产品,其包括承载在计算机可读介质上的计算机程序,该计算机程序包含用于执行流程图所示的方法的程序代码。在这样的实施例中,该计算机程序可以通过通信部分609从网络上被下载和安装,和/或从可拆卸介质611被安装。在该计算机程序被中央处理单元(CPU)601执行时,执行本申请的方法中限定的上述功能。
需要说明的是,本申请所述的计算机可读介质可以是计算机可读信号介质或者计算机可读介质或者是上述两者的任意组合。计算机可读介质例如可以是——但不限于——电、磁、光、电磁、红外线、或半导体的系统、装置或器件,或者任意以上的组合。计算机可读介质的更具体的例子可以包括但不限于:具有一个或多个导线的电连接、便携式计算机磁盘、硬盘、随机访问存储器(RAM)、只读存储器(ROM)、可擦式可编程只读存储器(EPROM或闪存)、光纤、便携式紧凑磁盘只读存储器(CD-ROM)、光存储器件、磁存储器件、或者上述的任意合适的组合。在本申请中,计算机可读介质可以是任何包含或存储程序的有形介质,该程序可以被指令执行系统、装置或者器件使用或者与其结合使用。而在本申请中,计算机可读的信号介质可以包括在基带中或者作为载波一部分传播的数据信号,其中承载了计算机可读的程序代码。这种传播的数据信号可以采用多种形式,包括但不限于电磁信号、光信号或上述的任意合适的组合。计算机可读的信号介质还可以是计算机可读介质以外的任何计算机可读介质,该计算机可读介 质可以发送、传播或者传输用于由指令执行系统、装置或者器件使用或者与其结合使用的程序。计算机可读介质上包含的程序代码可以用任何适当的介质传输,包括但不限于:无线、电线、光缆、RF等等,或者上述的任意合适的组合。
可以以一种或多种程序设计语言或其组合来编写用于执行本申请的操作的计算机程序代码,所述程序设计语言包括面向对象的程序设计语言—诸如Java、Smalltalk、C++,还包括常规的过程式程序设计语言—诸如“C”语言或类似的程序设计语言。程序代码可以完全地在用户计算机上执行、部分地在用户计算机上执行、作为一个独立的软件包执行、部分在用户计算机上部分在远程计算机上执行、或者完全在远程计算机或服务器上执行。在涉及远程计算机的情形中,远程计算机可以通过任意种类的网络——包括局域网(LAN)或广域网(WAN)—连接到用户计算机,或者,可以连接到外部计算机(例如利用因特网服务提供商来通过因特网连接)。
附图中的流程图和框图,图示了按照本申请各种实施例的系统、方法和计算机程序产品的可能实现的体系架构、功能和操作。在这点上,流程图或框图中的每个方框可以代表一个模块、程序段、或代码的一部分,该模块、程序段、或代码的一部分包含一个或多个用于实现规定的逻辑功能的可执行指令。也应当注意,在有些作为替换的实现中,方框中所标注的功能也可以以不同于附图中所标注的顺序发生。例如,两个接连地表示的方框实际上可以基本并行地执行,它们有时也可以按相反的顺序执行,这依所涉及的功能而定。也要注意的是,框图和/或流程图中的每个方框、以及框图和/或流程图中的方框的组合,可以用执行规定的功能或操作的专用的基于硬件的系统来实现,或者可以用专用硬件与计算机指令的组合来实现。
描述于本申请实施例中所涉及到的单元可以通过软件的方式实现,也可以通过硬件的方式来实现。所描述的单元也可以设置在处理器中,例如,可以描述为:一种处理器包括获取单元、提取单元、生成单元。其中,这些单元的名称在某种情况下并不构成对该单元本身的限定,例如,获取单元还可以被描述为“获取目标语句,以及对目标语句进 行切词,得到待修正词语集合的单元”。
作为另一方面,本申请还提供了一种计算机可读介质,该计算机可读介质可以是上述实施例中描述的服务器中所包含的;也可以是单独存在,而未装配入该服务器中。上述计算机可读介质承载有一个或者多个程序,当上述一个或者多个程序被该服务器执行时,使得该服务器:获取目标语句,以及对目标语句进行切词,得到待修正词语集合;对于待修正词语集合中的待修正词语,确定目标存储区中是否存在预设的、与该待修正词语对应的待定词语集合,其中,待定词语具有对应的错误概率和使用概率,错误概率用于表征待定词语被错换为该待修正词语的概率,使用概率用于表征待定词语被使用的概率;响应于确定存在,基于待定词语的错误概率和使用概率,确定待定词语的修正概率,其中,修正概率用于表征将该待修正词语修改为待定词语的概率;按照所得到的修正概率的大小顺序,从待定词语集合中,提取预设数量个待定词语作为待定词语子集合;基于所得到的待定词语子集合,生成修正语句。
以上描述仅为本申请的较佳实施例以及对所运用技术原理的说明。本领域技术人员应当理解,本申请中所涉及的发明范围,并不限于上述技术特征的特定组合而成的技术方案,同时也应涵盖在不脱离上述发明构思的情况下,由上述技术特征或其等同特征进行任意组合而形成的其它技术方案。例如上述特征与本申请中公开的(但不限于)具有类似功能的技术特征进行互相替换而形成的技术方案。
Claims (14)
- 一种用于生成修正语句的方法,包括:获取目标语句,以及对所述目标语句进行切词,得到待修正词语集合;对于所述待修正词语集合中的待修正词语,确定目标存储区中是否存在预设的、与该待修正词语对应的待定词语集合,其中,待定词语具有对应的错误概率和使用概率,错误概率用于表征待定词语被错换为该待修正词语的概率,使用概率用于表征待定词语被使用的概率;响应于确定存在,基于待定词语的错误概率和使用概率,确定待定词语的修正概率,其中,修正概率用于表征将该待修正词语修改为待定词语的概率;按照所得到的修正概率的大小顺序,从待定词语集合中,提取预设数量个待定词语作为待定词语子集合;基于所得到的待定词语子集合,生成修正语句。
- 根据权利要求1所述的方法,其中,所述目标存储区为预先建立的对应关系表,所述对应关系表包括待修正词语和待定词语集合,所述对应关系表用于表征待修正词语与待定词语集合的对应关系,所述对应关系表还包括待定词语的错误概率和使用概率。
- 根据权利要求1所述的方法,其中,待定词语的错误概率和使用概率预先按照如下步骤得到:对于待定词语集合中的待定词语,确定预设的、该待定词语对应的文本子集中的文本包括的、该待定词语的数量为第一数量,其中,文本子集是预设的文本集的子集;确定该待定词语对应的文本子集中的文本包括的、该待定词语对应的待修正词语的数量为第二数量;将所确定的第二数量除以第一数量与第二数量之和,得到该待定词语的错误概率;确定该待定词语在所述文本集中的数量为第三数量,以及将所确定的第三数量与所述文本集中的文本包括的词语的总数的比值确定为该待定词语的使用概率。
- 根据权利要求1所述的方法,其中,所述基于所得到的待定词语子集合,生成修正语句,包括:利用所得到的待定词语子集合中的待定词语,生成至少一个候选修正语句,以及得到所述至少一个候选修正语句中的候选修正语句的置信度;基于所得到的置信度的大小顺序,从所述至少一个候选修正语句中提取候选修正语句作为修正语句。
- 根据权利要求1-4之一所述的方法,其中,在所述确定目标存储区中是否存在预设的、与该待修正词语对应的待定词语集合之后,所述方法还包括:响应于确定所述目标存储区中不存在预设的、与该待修正词语对应的待定词语集合,确定该待修正词语包含的汉字的拼音;基于所确定的拼音,获取至少一个与拼音相匹配的匹配词语;从所获取的至少一个匹配词语中,选择预设数量个匹配词语作为待定词语子集合。
- 根据权利要求5所述的方法,其中,所得到的至少一个匹配词语中的匹配词语具有对应的热度数值,热度数值用于表征匹配词语被使用的频率;以及所述从所获取的至少一个匹配词语中,选择预设数量个匹配词语作为待定词语子集合,包括:按照热度数值的大小顺序,从所获取的至少一个匹配词语中选择预设数量个匹配词语作为待定词语子集合。
- 一种用于生成修正语句的装置,包括:获取单元,被配置成获取目标语句,以及对所述目标语句进行切词,得到待修正词语集合;提取单元,被配置成对于所述待修正词语集合中的待修正词语, 确定目标存储区中是否存在预设的、与该待修正词语对应的待定词语集合,其中,待定词语具有对应的错误概率和使用概率,错误概率用于表征待定词语被错换为该待修正词语的概率,使用概率用于表征待定词语被使用的概率;响应于确定存在,基于待定词语的错误概率和使用概率,确定待定词语的修正概率,其中,修正概率用于表征将该待修正词语修改为待定词语的概率;按照所得到的修正概率的大小顺序,从待定词语集合中,提取预设数量个待定词语作为待定词语子集合;生成单元,被配置成基于所得到的待定词语子集合,生成修正语句。
- 根据权利要求7所述的装置,其中,所述目标存储区为预先建立的对应关系表,所述对应关系表包括待修正词语和待定词语集合,所述对应关系表用于表征待修正词语与待定词语集合的对应关系,所述对应关系表还包括待定词语的错误概率和使用概率。
- 根据权利要求7所述的装置,其中,待定词语的错误概率和使用概率预先按照如下步骤得到:对于待定词语集合中的待定词语,确定预设的、该待定词语对应的文本子集中的文本包括的、该待定词语的数量为第一数量,其中,文本子集是预设的文本集的子集;确定该待定词语对应的文本子集中的文本包括的、该待定词语对应的待修正词语的数量为第二数量;将所确定的第二数量除以第一数量与第二数量之和,得到该待定词语的错误概率;确定该待定词语在所述文本集中的数量为第三数量,以及将所确定的第三数量与所述文本集中的文本包括的词语的总数的比值确定为该待定词语的使用概率。
- 根据权利要求7所述的装置,其中,所述生成单元包括:生成模块,被配置成利用所得到的待定词语子集合中的待定词语,生成至少一个候选修正语句,以及得到所述至少一个候选修正语句中 的候选修正语句的置信度;提取模块,被配置成基于所得到的置信度的大小顺序,从所述至少一个候选修正语句中提取候选修正语句作为修正语句。
- 根据权利要求7-10之一所述的装置,其中,所述提取单元包括:确定模块,被配置成响应于确定所述目标存储区中不存在预设的、与该待修正词语对应的待定词语集合,确定该待修正词语包含的汉字的拼音;获取模块,被配置成基于所确定的拼音,获取至少一个与拼音相匹配的匹配词语;选择模块,被配置成从所获取的至少一个匹配词语中,选择预设数量个匹配词语作为待定词语子集合。
- 根据权利要求11所述的装置,其中,所得到的至少一个匹配词语中的匹配词语具有对应的热度数值,热度数值用于表征匹配词语被使用的频率;以及所述选择模块进一步被配置成:按照热度数值的大小顺序,从所得到的至少一个匹配词语中选择预设数量个匹配词语作为待定词语子集合。
- 一种服务器,包括:一个或多个处理器;存储装置,其上存储有一个或多个程序,当所述一个或多个程序被所述一个或多个处理器执行,使得所述一个或多个处理器实现如权利要求1-6中任一所述的方法。
- 一种计算机可读介质,其上存储有计算机程序,其中,该程序被处理器执行时实现如权利要求1-6中任一所述的方法。
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| US16/981,257 US11531814B2 (en) | 2018-09-14 | 2018-11-16 | Method and device for generating modified statement |
Applications Claiming Priority (2)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201811074035.4 | 2018-09-14 | ||
| CN201811074035.4A CN109325227A (zh) | 2018-09-14 | 2018-09-14 | 用于生成修正语句的方法和装置 |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| WO2020052060A1 true WO2020052060A1 (zh) | 2020-03-19 |
Family
ID=65265276
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| PCT/CN2018/115953 Ceased WO2020052060A1 (zh) | 2018-09-14 | 2018-11-16 | 用于生成修正语句的方法和装置 |
Country Status (3)
| Country | Link |
|---|---|
| US (1) | US11531814B2 (zh) |
| CN (1) | CN109325227A (zh) |
| WO (1) | WO2020052060A1 (zh) |
Families Citing this family (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN109325227A (zh) * | 2018-09-14 | 2019-02-12 | 北京字节跳动网络技术有限公司 | 用于生成修正语句的方法和装置 |
| CN112765231A (zh) * | 2021-01-04 | 2021-05-07 | 珠海格力电器股份有限公司 | 一种数据处理方法、装置及计算机可读存储介质 |
| CN116522905B (zh) * | 2023-07-03 | 2024-03-19 | 腾讯科技(深圳)有限公司 | 文本纠错方法、装置、设备、可读存储介质及程序产品 |
Citations (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN1387650A (zh) * | 1999-11-05 | 2002-12-25 | 微软公司 | 对拼写、打字和转换错误具有容错能力的将一种文本形式转换为另一种文本形式的语言输入体系结构 |
| US9471566B1 (en) * | 2005-04-14 | 2016-10-18 | Oracle America, Inc. | Method and apparatus for converting phonetic language input to written language output |
| CN106250364A (zh) * | 2016-07-20 | 2016-12-21 | 科大讯飞股份有限公司 | 一种文本修正方法及装置 |
| CN106708893A (zh) * | 2015-11-17 | 2017-05-24 | 华为技术有限公司 | 搜索查询词纠错方法和装置 |
Family Cites Families (18)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US5572423A (en) * | 1990-06-14 | 1996-11-05 | Lucent Technologies Inc. | Method for correcting spelling using error frequencies |
| US6721697B1 (en) * | 1999-10-18 | 2004-04-13 | Sony Corporation | Method and system for reducing lexical ambiguity |
| US7813928B2 (en) * | 2004-06-10 | 2010-10-12 | Panasonic Corporation | Speech recognition device, speech recognition method, and program |
| KR101465770B1 (ko) * | 2007-06-25 | 2014-11-27 | 구글 인코포레이티드 | 단어 확률 결정 |
| JP5598331B2 (ja) * | 2008-11-28 | 2014-10-01 | 日本電気株式会社 | 言語モデル作成装置 |
| US8494852B2 (en) * | 2010-01-05 | 2013-07-23 | Google Inc. | Word-level correction of speech input |
| CN103914444B (zh) * | 2012-12-29 | 2018-07-24 | 高德软件有限公司 | 一种纠错方法及其装置 |
| GB2533370A (en) * | 2014-12-18 | 2016-06-22 | Ibm | Orthographic error correction using phonetic transcription |
| US9585159B2 (en) * | 2014-12-19 | 2017-02-28 | Qualcomm Incorporated | Opportunistic dual-band relay |
| US9928232B2 (en) * | 2015-02-27 | 2018-03-27 | Microsoft Technology Licensing, Llc | Topically aware word suggestions |
| CN105550173A (zh) * | 2016-02-06 | 2016-05-04 | 北京京东尚科信息技术有限公司 | 文本校正方法和装置 |
| US10200397B2 (en) * | 2016-06-28 | 2019-02-05 | Microsoft Technology Licensing, Llc | Robust matching for identity screening |
| US10402489B2 (en) * | 2016-12-21 | 2019-09-03 | Facebook, Inc. | Transliteration of text entry across scripts |
| US10599645B2 (en) * | 2017-10-06 | 2020-03-24 | Soundhound, Inc. | Bidirectional probabilistic natural language rewriting and selection |
| CN108376129B (zh) * | 2018-01-24 | 2022-04-22 | 北京奇艺世纪科技有限公司 | 一种纠错方法及装置 |
| CN108304385A (zh) * | 2018-02-09 | 2018-07-20 | 叶伟 | 一种语音识别文本纠错方法及装置 |
| CN109325227A (zh) * | 2018-09-14 | 2019-02-12 | 北京字节跳动网络技术有限公司 | 用于生成修正语句的方法和装置 |
| CN109190124B (zh) * | 2018-09-14 | 2019-11-26 | 北京字节跳动网络技术有限公司 | 用于分词的方法和装置 |
-
2018
- 2018-09-14 CN CN201811074035.4A patent/CN109325227A/zh active Pending
- 2018-11-16 WO PCT/CN2018/115953 patent/WO2020052060A1/zh not_active Ceased
- 2018-11-16 US US16/981,257 patent/US11531814B2/en active Active
Patent Citations (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN1387650A (zh) * | 1999-11-05 | 2002-12-25 | 微软公司 | 对拼写、打字和转换错误具有容错能力的将一种文本形式转换为另一种文本形式的语言输入体系结构 |
| US9471566B1 (en) * | 2005-04-14 | 2016-10-18 | Oracle America, Inc. | Method and apparatus for converting phonetic language input to written language output |
| CN106708893A (zh) * | 2015-11-17 | 2017-05-24 | 华为技术有限公司 | 搜索查询词纠错方法和装置 |
| CN106250364A (zh) * | 2016-07-20 | 2016-12-21 | 科大讯飞股份有限公司 | 一种文本修正方法及装置 |
Also Published As
| Publication number | Publication date |
|---|---|
| CN109325227A (zh) | 2019-02-12 |
| US20210192138A1 (en) | 2021-06-24 |
| US11531814B2 (en) | 2022-12-20 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| JP7301922B2 (ja) | 意味検索方法、装置、電子機器、記憶媒体およびコンピュータプログラム | |
| CN108022586B (zh) | 用于控制页面的方法和装置 | |
| US9805718B2 (en) | Clarifying natural language input using targeted questions | |
| US11409813B2 (en) | Method and apparatus for mining general tag, server, and medium | |
| US8886517B2 (en) | Trust scoring for language translation systems | |
| US20190163691A1 (en) | Intent Based Dynamic Generation of Personalized Content from Dynamic Sources | |
| US20180068221A1 (en) | System and Method of Advising Human Verification of Machine-Annotated Ground Truth - High Entropy Focus | |
| CN108052577A (zh) | 一种通用文本内容挖掘方法、装置、服务器及存储介质 | |
| CN113761923B (zh) | 命名实体识别方法、装置、电子设备及存储介质 | |
| US9589049B1 (en) | Correcting natural language processing annotators in a question answering system | |
| WO2018045646A1 (zh) | 基于人工智能的人机交互方法和装置 | |
| CN109241286B (zh) | 用于生成文本的方法和装置 | |
| CN108121699B (zh) | 用于输出信息的方法和装置 | |
| CN109858045B (zh) | 机器翻译方法和装置 | |
| WO2020052061A1 (zh) | 用于处理信息的方法和装置 | |
| US9678947B2 (en) | Pattern identification and correction of document misinterpretations in a natural language processing system | |
| WO2020052069A1 (zh) | 用于分词的方法和装置 | |
| CN114861889A (zh) | 深度学习模型的训练方法、目标对象检测方法和装置 | |
| KR20190138562A (ko) | 정보를 생성하기 위한 방법 및 장치 | |
| CN106663123B (zh) | 以评论为中心的新闻阅读器 | |
| CN112182255A (zh) | 用于存储媒体文件和用于检索媒体文件的方法和装置 | |
| CN108038200A (zh) | 用于存储数据的方法和装置 | |
| US20180189630A1 (en) | Augment Politeness in Question Answer Systems | |
| JP2023002690A (ja) | セマンティックス認識方法、装置、電子機器及び記憶媒体 | |
| WO2020052060A1 (zh) | 用于生成修正语句的方法和装置 |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| NENP | Non-entry into the national phase |
Ref country code: DE |
|
| 32PN | Ep: public notification in the ep bulletin as address of the adressee cannot be established |
Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 29/06/2021) |
|
| 122 | Ep: pct application non-entry in european phase |
Ref document number: 18933137 Country of ref document: EP Kind code of ref document: A1 |