Sentence processing method and device, and electronic equipment
By establishing entity indexes and matching pinyin and tones, the entity terms in sentences are split and replaced, which solves the problem of inaccurate automatic speech recognition, realizes accurate command execution of electronic devices and improves user experience.
Patent Information
- Application Number
- CN202111321370.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-09
- Publication Date
- 2025-10-14
- Estimated Expiration
- 2041-11-09
AI Technical Summary
In the existing technology, automatic speech recognition methods cannot accurately convert voice data into text sentences, resulting in electronic devices being unable to accurately understand user commands, affecting intelligent control and user experience.
By establishing an entity index, splitting the sentence into multiple processing parts, and using pinyin and tone matching to perform fuzzy queries, the entity terms in the sentence are replaced to improve the accuracy of entity term recognition.
The recognition accuracy of entity terms in sentences is improved, ensuring that electronic devices can accurately execute commands indicated by users and improving user experience.
Smart Images

Figure CN116108828B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of natural language processing technology, and in particular to a sentence processing method, device and electronic device. Background Art
[0002] With the continuous development of science and technology, more and more electronic devices such as mobile phones and computers are equipped with voice dialogue systems, allowing users of electronic devices to control the electronic devices in a "conversational" manner.
[0003] In the prior art, when a user speaks a command to an electronic device, the electronic device can collect the user's voice data through a voice collection device such as a microphone, convert the voice data into a text sentence, and then determine the command corresponding to the sentence and finally execute the command.
[0004] However, the automatic speech recognition and other methods used in the existing technology cannot completely and accurately convert voice data into text sentences, resulting in the inability to accurately understand and execute user commands, affecting the electronic device's ability to achieve intelligent control based on voice data and reducing the user experience of the electronic device. Summary of the Invention
[0005] The present application provides a sentence processing method, device and electronic device for processing sentences in text form obtained through voice data, correcting the text of entity terms therein, improving the accuracy of entity terms in the sentences, and thereby ensuring that the electronic device can accurately implement intelligent control based on voice data and improve the user experience of the electronic device.
[0006] In a first aspect, the present application provides a method for processing a sentence, comprising: obtaining a sentence to be processed; wherein the sentence to be processed is obtained by recognizing voice data, and the sentence to be processed includes a plurality of characters arranged in sequence; splitting the sentence to be processed into a plurality of processing parts; wherein the processing part includes one character in the sentence, or a plurality of consecutive characters; determining a first processing part corresponding to a first entity term in an entity index from the plurality of processing parts; wherein the first entity term and the first processing part have the same number of characters, and the first entity term and the characters in the same arrangement position in the first processing part have the same pinyin, the entity index includes a plurality of entity terms, a first-level index of the entity terms, and a second-level index of the entity terms, the first-level index includes the pinyin of each character in the entity term, and the arrangement position of the character in the entity term, and the second-level index includes the arrangement position of all characters in the plurality of entity terms; when the characters in the first processing part are different from the characters in the first entity term, the characters in the first entity term are used to replace the characters in the first processing part.
[0007] In an embodiment of the first aspect of the present application, the first processing part corresponding to the first entity in the entity index is determined from the plurality of processing parts, comprising: determining a candidate entity set corresponding to the pinyin of each character of each processing part according to the entity index; the candidate entity set includes at least one entity; the processing part in which the same first candidate entity is included in the candidate entity set corresponding to each character is determined as the first processing part from the plurality of processing parts.
[0008] In an embodiment of the first aspect of the present application, the candidate entity set corresponding to the pinyin of each character in the processing part is determined, comprising: determining a second index of the first arrangement position of the first character in the processing part from the entity index according to the first arrangement position of the first character in the processing part; determining at least one candidate first index from a plurality of first indexes indicated by the second index according to the pinyin of the first character; wherein the pinyin of the second character at the first arrangement position in the entity indicated by the candidate first index meets the first preset condition; and adding the entity indicated by the candidate first index to the candidate entity set.
[0009] In an embodiment of the first aspect of the present application, the first preset condition comprises: the pinyin of the first character and the pinyin of the second character are the same; or the ratio of the edit distance between the pinyin of the first character and the pinyin of the second character to the first length is less than a first threshold value; wherein the first length is the maximum length of the pinyin length of the first character and the pinyin length of the second character.
[0010] In an embodiment of the first aspect of the present application, the entity index further comprises: the tone of each entity in the plurality of entities, and the entity indicated by the first index is added to the candidate entity set, comprising: adding the entity whose tone meets the second preset condition from the entity indicated by the first index to the candidate entity set.
[0011] In an embodiment of the first aspect of the present application, the second preset condition comprises: the ratio of the edit distance between the tone of all characters in the processing part and the tone of all characters in the entity to the first length is less than a second threshold value.
[0012] In an embodiment of the first aspect of the present application, the method further comprises: obtaining a plurality of entity words, and establishing the entity index according to the pinyin of each character in the plurality of entity words and the arrangement position of the character in the entity word.
[0013] In an embodiment of the first aspect of the present application, the method further comprises: storing the first processing part and the correspondence between the first processing part and the first entity entry; and replacing the text of the first processing part with the text of the first entity entry when the first processing part is included in a sentence to be processed obtained again.
[0014] The second aspect of the present application provides a sentence processing apparatus, comprising: an obtaining module configured to obtain a sentence to be processed; wherein the sentence to be processed is obtained by recognizing voice data, and the sentence to be processed comprises a plurality of texts arranged in sequence; a splitting module configured to split the sentence to be processed into a plurality of processing parts; wherein each processing part comprises one text or a plurality of continuous texts in the sentence; a determining module configured to determine a first processing part corresponding to a first entity entry in an entity index from the plurality of processing parts; wherein the first entity entry and the first processing part have the same number of texts, and the pinyin of the texts arranged in the same position in the first entity entry and the first processing part is the same, the entity index comprises a plurality of entity entries, a first index of an entity entry and a second index of an entity entry, the first index comprises the pinyin of each text in the entity entry and the arrangement position of the text in the entity entry, and the second index comprises the arrangement positions of all texts in the plurality of entity entries; and a processing module configured to replace the text of the first processing part with the text of the first entity entry when the text of the first processing part is different from the text of the first entity entry.
[0015] The third aspect of the present application provides an electronic device, comprising: a memory and a processor; the memory stores computer execution instructions; and the processor executes the computer execution instructions stored in the memory, so that the processor executes the sentence processing method according to any one of the first aspect of the present application.
[0016] In summary, the sentence processing method, apparatus and electronic device provided by the present application can convert voice data into a text form of a sentence through automatic speech recognition, further split the sentence into a plurality of processing parts, and perform fuzzy query on entity entries included in the sentence according to the pinyin of the plurality of processing parts to obtain an entity entry corresponding to a processing part in an entity index, and replace the processing part in the sentence with the entity entry when the text of the processing part is different from the text of the entity entry, so as to ensure that the text of the entity entry in the sentence is correct, avoid the influence of homophonic characters, homonym characters and the like in the text on the recognition of the entity entry, improve the recognition accuracy of the entity entry in the sentence, and further ensure that the command of the sentence can be accurately determined through natural language understanding, so as to finally accurately execute the command indicated by the user, and improve the user experience of the electronic device. BRIEF DESCRIPTION OF DRAWINGS
[0017] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings needed to be used in the embodiments or prior art description. Obviously, the drawings in the following description only represent some of the embodiments of the present application, and for those skilled in the art, other drawings can also be obtained from these drawings without any creative effort.
[0018] Figure 1 A schematic diagram of a dialogue system;
[0019] Figure 2 A schematic diagram of a dialogue system provided by the present application;
[0020] Figure 3 A schematic diagram of an entity index provided by the present application;
[0021] Figure 4 A flowchart of an embodiment of a sentence processing method provided by the present application;
[0022] Figure 5 A schematic diagram of sentence splitting provided by the present application;
[0023] Figure 6 A schematic diagram of determining a candidate entity term set provided by the present application. DETAILED DESCRIPTION
[0024] The technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments only represent some of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without any creative effort fall within the scope of protection of the present application.
[0025] The terms "first", "second", "third", "fourth" and the like (if any) in the specification and claims of the present application and the above drawings are used to distinguish similar objects, and do not necessarily indicate a specific order or sequence. It should be understood that the data thus used can be interchanged under appropriate circumstances, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein. In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusion, for example, a process, method, system, product or device including a series of steps or units does not necessarily have to include those steps or units clearly listed, but can include other steps or units not clearly listed or inherent to these processes, methods, products or devices.
[0026] Before introducing the embodiments of the present application, the scenario to which the present application is applied and the problems existing in the prior art will be described with reference to the drawings. For example, Figure 1 is a schematic diagram of a dialogue system, wherein, in the dialogue scenario shown in Figure 1 The dialogue system provided in the dialogue scenario shown in the dialogue system can be applied to intelligent electronic devices such as mobile phones, computers, household appliances and the like. The present application is described taking an electronic device as an execution subject, so that a user can "say" an instruction that the user wants the electronic device to execute to the electronic device in the form of voice, so as to realize a more intelligent control mode to improve the user experience of the electronic device. For example, when the electronic device is a television, when the user wants the electronic device to play a program "Harry Potter", the user only needs to say "play Harry Potter" to the electronic device without using a remote control or the like.
[0027] At this time, for the electronic device, the voice data of the user can be collected through a microphone or the like, and then in S10, the voice data of the user is converted into a text form of a sentence through automatic speech recognition (ASR) or the like. Subsequently, in S20, the command corresponding to the sentence is determined to be playing the program "Harry Potter" through natural language understanding (NLU) or the like, and finally in S30, the electronic device executes the command of playing the program "Harry Potter", so as to realize policy execution based on user dialogue.
[0028] Although the dialogue system shown in Figure 1 can realize intelligent control based on voice data of a user, the accuracy of automatic speech recognition in S10 through ASR or the like is insufficient, and some homophonic characters and homophonic words in the voice data cannot be accurately converted into a text form, for example, the voice data of the user actually expressing "Harry Potter" can be converted into "Harry Potter". The problem of "Harry Potter" leads to that the command corresponding to the sentence cannot be accurately determined in S20, especially the entity term included in the sentence cannot be determined, so that the electronic device cannot accurately execute the command indicated by the user in S30, which affects the electronic device to realize intelligent control based on voice data of the user, and reduces the user experience of the electronic device.
[0029] Therefore, the present application also provides a sentence processing method, which can be used in the system shown in Figure 1 , so that the electronic device can perform fuzzy query on the entity term included in the text form of the sentence converted through automatic speech recognition, improve the recognition accuracy of the entity term in the sentence, and then ensure that the command of the sentence can be accurately determined through natural language understanding, and finally accurately execute the command indicated by the user.
[0030] The technical solutions of the present application are described in detail below with specific examples. The following specific examples can be combined with each other, and the same or similar concepts or processes can not be described in detail in some examples.
[0031] In some embodiments, Figure 2 A schematic diagram of a dialogue system provided by the present application is shown in Figure 2 The dialogue system shown in Figure 1 After the electronic device performs automatic speech recognition on the speech data to obtain a text form of the sentence in S10, the sentence is processed in S40, and then the sentence is processed for natural language understanding in S20 to obtain a command corresponding to the sentence. Finally, the command is executed in S30. The processing method of the sentence provided by the present application can correspond to the S40 step in Figure 2 performed by the electronic device.
[0032] To determine the entity word in the sentence in the embodiments of the present application, an index of the entity word can be established, denoted as an entity index. For example, Figure 3 A schematic diagram of an entity index provided by the present application is shown in Figure 3 The entity index provided by the present application includes: a plurality of entity words, a first-level index of the entity words, and a second-level index of the entity words.
[0033] Exemplarily, Figure 3 The entity words in the example shown in include: "Harry Potter", "Harry Potter and the Prisoner of Azkaban", "The Cat and the Mouse", and other texts as examples. Each entity word includes at least one sequentially arranged character. In a specific implementation, a plurality of entity words can be denoted as an entity dictionary D={e i |i=1,...,n}, where e i is an entity word to be queried in the dictionary. Each entity word is in the form of e i =c i,1 c i,2 ...c i,li , where c i,j represents the character at position j of the word e i , and l i represents the length of the word e i . For each entity word e i , the pinyin (also referred to as syllable, etc.) of each character can be obtained, denoted as a syllable sequence p i =s i,1 s i,2 ...s i,li , where s i,j represents the pinyin corresponding to the character c i,j .
[0034] The first-level index includes the pinyin of each character in the entity entry and the arrangement position of the character in the entity entry. The specific form can be represented as <s Figure 3 The first-level index includes the pinyin of each character in the entity entry and the arrangement position of the character in the entity entry. The specific form can be represented as <s i,j i For example, <ha+1> is used to indicate that the pinyin of the first character in the entity entry "Harry Potter" is "ha"; <li+2> is used to indicate that the pinyin of the second character in the entity entry "Harry Potter" is "li"; <mao+1> is used to indicate that the pinyin of the first character in the entity entry "Cat and Mouse" is "mao"; and so on.
[0035] The second-level index includes the arrangement positions of all possible characters in multiple entity entries. The specific form can be represented as <s i,j For example, <1> in the second-level index is used to indicate <ha+1> and <mao+1> in the first-level index; and so on.
[0036] In some embodiments, the multiple entity entries in the entity index can be uniformly preset or related to the electronic device. For example, when the electronic device is a television, the entity entries can be texts related to programs that can be played by the electronic device; when the electronic device is a smart speaker, the entity entries can be texts related to audio played by the smart speaker; and so on.
[0037] In some embodiments, the entity index can be pre-installed in the electronic device, or established by the electronic device after obtaining the multiple entity entries, or specified by a user of the electronic device.
[0038] Based on the entity index as shown in Figure 3 , the processing method for the sentence provided in the present application includes the following steps. Figure 4 The flowchart of an embodiment of the processing method for the sentence provided in the present application is shown in Figure 4 The method can be applied in the dialogue system as shown in Figure 2 The specific implementation of the processing method for the sentence provided in the present application includes the following steps.
[0039] S101: The electronic device obtains a to-be-processed sentence.
[0040] In some embodiments, the electronic device can obtain the to-be-processed sentence by performing automatic speech recognition on the voice data of the user. In some embodiments, due to errors that may occur during automatic speech recognition, when the voice data of the user is "play Harry Potter", the to-be-processed sentence obtained by automatic speech recognition is "play Harry Potter". The multiple characters in the to-be-processed sentence are arranged in order and the arrangement position is maintained in the subsequent processing process.
[0041] S102: The electronic device splits the to-be-processed sentence obtained in S101 to obtain a plurality of processing parts each composed of one character or a plurality of consecutive characters.
[0042] In some embodiments, the electronic device can perform "n-gram" segmentation on the to-be-processed sentence to obtain a plurality of texts of different lengths, each of which is a processing part for subsequent processing, and each of which includes one or more characters in the order of the to-be-processed sentence.
[0043] In a specific implementation process, the to-be-processed sentence can be defined as T=t1t2...t m When performing n-gram segmentation on the to-be-processed sentence, the value of n ranges from the length of the shortest entity term in the entity index to the maximum value of the length of the longest entity term in the entity index and the length of the current to-be-processed sentence, which can be represented as [min(l i ), max(m, max(l i ))] for example, when n=2, the processing parts obtained can be represented as T2={t1t2, t2t3,...,t m- 1t m}, and so on.
[0044] Figure 5 An example of sentence splitting provided in the present application is shown in the following figure. When performing 1-gram segmentation on the to-be-processed sentence "play Harry Potter", the processing parts obtained include "play", "play", "Harry", "Harry", "Harry", "Potter", and when performing 2-gram segmentation, the processing parts obtained include "play Harry", "Harry Potter", and so on.
[0045] S103: From the plurality of processing parts obtained in S102, a first processing part corresponding to a first entity term in the entity index is determined. The correspondence between the entity term and the processing part is that the number of characters included in the entity term is the same as the number of characters included in the processing part, and the pinyin of each character in the corresponding arrangement position is the same.
[0046] In some embodiments, the electronic device specifically compares each processing part with the entity index in S103 to determine a candidate entity term set corresponding to each character in each processing part. For example, as shown in the entity index, when the to-be-processed sentence is "play Harry Potter", the processing parts obtained by performing 1-gram segmentation include "play", "play", "Harry", "Harry", "Harry", "Potter", and the processing parts obtained by performing 2-gram segmentation include "play Harry", "Harry Potter", and so on. Figure 3 Figure 5 The plurality of processing parts shown in the middle, taking "Harry Potter" as an example in the plurality of processing parts, through the pinyin of each character in the processing part, the pinyin corresponding candidate entity entry set of each character can be determined from the entity index.
[0047] The above process can be represented as, for a text segment T' = t1t2...tm' in a processing part, the pinyin of each character in the text segment T' = t1t2...tm' can be determined from the entity index. m' , the candidate first-level index that can be obtained at each bit j = 1,..., m' is denoted as idx j = {<s1,j>,..., <s n' ,j>}, then the pinyin s T,j of the current scanning position is compared with s1to s n If both satisfy the first preset condition, the entity entry indicated by the first-level index is added to the candidate entry set, and the above process can be represented as r j = {e i |<s i ,j>→e i ,edit(s i ,s T,j )<α}, and finally the candidate entity entry set of each character in the entire processing part can be represented as The above process can also be referred to as entity fuzzy query, etc.
[0048] For example, Figure 6 The schematic diagram provided by the present application for determining the candidate entity entry set, wherein for the first character "Ha" in the processing part "Harry Potter", the pinyin of the first character can be obtained as ha, and the first arrangement position in the processing part is 1; according to the first arrangement position 1, the second-level index corresponding to the arrangement position <1> can be determined from the entity index, and then at least one candidate first-level index can be determined from the plurality of first-level indexes indicated by the second-level index according to the pinyin ha, wherein the pinyin of the second character at the first arrangement position in the entity entry indicated by the candidate first-level index is less than the first threshold value. Or, in another possible implementation, the first preset condition can be that the pinyin of the first character and the pinyin of the second character are the same.
[0049] Specifically, the edit distance refers to the number of changes between two pinyins to keep consistent, for example, the pinyin ha and ha are the same without changes, and the edit distance is 0, the pinyin ha and hua need to delete one u to keep consistent, and the edit distance is 1, the pinyin ha and li need to change twice to keep consistent, and the edit distance is 2, and so on. The first length is the length of the pinyin of the first character in the processing part and the length of the pinyin of the second character in the entity entry indicated by the first-level index, and the maximum of the two lengths. The first threshold value a can be set to 0.5 and the like.
[0050] Exemplarily, for the first character "ha" in the processing part "Harry Potter", the first arrangement position is 1, the pinyin is ha, and the edit distance between the pinyin of the first-level index <ha, 1> is 0, the maximum length between the pinyin of the first character and the pinyin of the second character is 2, so the ratio of the edit distance to the first length is 0, which is less than the first threshold value 0.5, so the entity entry "Harry Potter" indicated by <ha, 1> can be added to the candidate entity entry set corresponding to the character "ha". Correspondingly, the edit distance between the first character "ha" and the first-level index <hua, 1> is 1, and the ratio of the edit distance to the first length is 1 / 3, which is also less than the first threshold value 0.5, so the entity entry "Hua Yang Jie Jie" indicated by <hua, 1> can also be added to the candidate entity entry set corresponding to the character "ha".
[0051] In the same way as the above example, finally, as shown in Figure 6 , the candidate entity entry set corresponding to each character in the processing part "Harry Potter" can be obtained, and each candidate entity entry set includes at least one entity entry. Similarly, in the same way as shown in Figure 6 , the candidate entity entry set corresponding to each processing part of the to-be-processed sentence can be obtained, and the specific implementation and principles are the same, which will not be repeated here.
[0052] Finally, from the above plurality of processing parts, the processing part in which the same first candidate entity entry is included in the candidate entity entry set of each character is determined as the first processing part. For example, in the example shown in Figure 6 , in the processing part "Harry Potter" in the to-be-processed sentence, the candidate entity entry set corresponding to each character includes the same first entity entry "Harry Potter", and the processing part "Harry Potter" in the to-be-processed sentence is determined as the first processing part.
[0053] S104: Then, the electronic device determines whether the text in the first processing part determined in S103 is the same as the text in the first entity entry, for example, the first processing part "Harry Potter" is not the same as the first entity entry "Harry Potter", and uses the text in the first entity entry "Harry Potter" to replace the first processing part in the sentence to be processed, so that the first processing part in the sentence to be processed changes from "Harry Potter" to "Harry Potter".
[0054] In some embodiments, in order to further improve the similarity of the candidate entity entry set to the current processing part, after determining the candidate entity entry set as shown in the first threshold a Figure 6 The tone of each text of the processing part is compared with the tone of the entity entry indicated by the first index, and the entity entry whose tone indicated by the first index satisfies the second preset condition is added to the candidate entity entry set. The second preset condition includes that the edit distance between the tone of all texts in the processing part and the tone of all texts in the entity entry is less than the second threshold divided by the first length.
[0055] Specifically, the edit distance between the tones defined in the embodiment is a difference score value between two pinyin tones, for example, the edit distance is 0 when the pinyin tones are the same, and the edit distance is 0.5 when the tones are different. Then, the tone of the second text "Li" in the first processing part "Harry Potter" is three, and the tone of the second text "Li" in the entity entry "Harry Potter" indicated by the first index is four, and the edit distance between them is 0.5. Similarly, the second threshold β can be set to 0.3, etc. In particular, for some easily confused tones, the edit distance can be individually defined as 0.5, for example, z / zh, ing / in, l / n, etc. Pinyin, no matter whether the tone is the same or not, the determined edit distance is 0.5.
[0056] The above process can be represented as, for each entity entry in the candidate entity entry set, e i First, determine the processing part T' and the entity entry e i Each corresponding syllable sequence p T' And p i In the above example, the length m' of p T' And the length l i Of p i Equal. Then, determine the edit distance of the syllables s T,j And s i,j At corresponding positions j in the two sequences, and finally obtain the sum of the edit distances between all text tones in the processing part and all text tones in the entity entry. Calculate the ratio of the sum of the edit distances to the first length, and if the ratio is less than the second threshold β, the entity entry can be added to the candidate entity entry set.
[0057] In some embodiments, the pinyin tones of the entity entries can be recorded in the entity index, and stored in the form of attribute information of multiple entries, etc. When needed, the entity entries can be called from the entity index according to the indication of the second-level index and the first-level index.
[0058] In summary, the sentence processing method provided in the embodiments can convert the voice data into text form sentences through automatic speech recognition, further split the sentences into multiple processing parts, and perform fuzzy query on the entity entries included in the sentences according to the pinyin of the multiple processing parts, to obtain the entity entries corresponding to the processing parts in the entity index. When the text of the processing part is different from the text of the entity entry, the processing part in the sentence is replaced by the entity entry, so as to ensure that the text of the entity entry in the sentence is correct, avoid the influence of homophonic characters, homophonic characters, etc. in the text on the recognition of the entity entry, improve the recognition accuracy of the entity entry in the sentence, and further ensure that the subsequent command of the sentence can be accurately determined through natural language understanding, so as to finally accurately execute the command indicated by the user, and improve the user experience of the electronic device.
[0059] In addition, the entity index established in the embodiments includes a two-level index structure of the first-level index and the second-level index, which can reduce the calculation amount of one-to-one matching of the entity entries in the entity index when the number of entity entries is large, and can also improve the calculation efficiency when processing the sentence. In addition, when determining the entity entry corresponding to the processing part, the fuzzy matching threshold control based on the edit distance for a single pinyin is added, so that the balance between the query efficiency and the recall rate of the overall scheme can be adjusted according to the actual use scene, and the word-level fuzzy matching method based on syllable can also adapt to the matching degree calculation demand when Chinese and English are mixed.
[0060] In some embodiments, the electronic device can process the entity entries that are not recognized in the sentence, so after executing the sentence processing method in the above embodiments, the replaced first processing part and the correspondence between the first processing part and the first entity entry are stored. When the electronic device obtains the first processing part included in the to-be-processed sentence next time, the above sentence processing method can no longer be executed, and the text of the first entity entry can be directly used to replace the text of the first processing part, so as to improve the processing efficiency of the sentence.
[0061] In the foregoing embodiments, the processing method of the sentence provided by the embodiments of the present application is introduced. In order to realize each function in the method provided by the embodiments of the present application, the electronic device as an execution subject can include a hardware structure and / or a software module to realize each function in the form of a hardware structure, a software module, or a hardware structure plus a software module. Whether a certain function in each function is executed in the form of a hardware structure, a software module, or a hardware structure plus a software module depends on the specific application of the technical solution and the design constraint conditions.
[0062] For example, the present application provides a sentence processing apparatus, comprising: an acquisition module, a splitting module, a determination module and a processing module; wherein the acquisition module is configured to acquire a sentence to be processed; the splitting module is configured to split the sentence to be processed into a plurality of processing parts; the determination module is configured to determine, from the plurality of processing parts, a first processing part corresponding to a first entity entry in an entity index; and the processing module is configured to replace the text of the first processing part with the text of the first entity entry when the text of the first processing part is different from the text of the first entity entry.
[0063] The specific implementation and principles of each module of the sentence processing apparatus provided by the present application can refer to the processing method of the sentence provided by the foregoing embodiments of the present application, which has the same specific implementation manner and principles, and will not be repeated here.
[0064] It should be noted that the division of each module of the above apparatus should be understood as only a logical function division, and all or part of the modules can be integrated into one physical entity, or can be physically separated. These modules can all be implemented in the form of software called by a processing element; or all can be implemented in the form of hardware; or part of the modules can be implemented in the form of software called by a processing element, and part of the modules can be implemented in the form of hardware. It can be a separate processing element, or can be integrated in a chip of the above apparatus, in addition, it can be stored in the form of program code in the memory of the above apparatus, and the function of the above determination module is called and executed by a processing element of the above apparatus. The implementation of other modules is similar. In addition, all or part of these modules can be integrated together, or can be independently implemented. The processing element described herein can be an integrated circuit with signal processing capability. In the implementation process, each step of the above method or each module can be completed by the integrated logic circuit of hardware or the instruction of software in the processing element.
[0065] For example, the above modules can be one or more integrated circuits configured to implement the above methods, such as one or more application specific integrated circuits (ASICs), or one or more digital signal processors (DSPs), or one or more field programmable gate arrays (FPGAs), or the like. For another example, when a certain module above is implemented by means of a processing element scheduling code, the processing element can be a general purpose processor, such as a central processing unit (CPU) or other processor that can invoke code. For yet another example, the modules can be integrated together to be implemented in a system-on-a-chip (SOC) form.
[0066] In the embodiments described above, all or some of the embodiments can be implemented through software, hardware, firmware or any combination thereof. When implemented by software, all or some of the embodiments can be implemented in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded into and executed by a computer, all or some of the processes or functions according to the embodiments described in the present application are generated. The computer can be a general purpose computer, a special purpose computer, a computer network, or other programmable apparatuses. The computer instructions can be stored in a computer readable storage medium or transmitted from one computer readable storage medium to another computer readable storage medium, for example, the computer instructions can be transmitted from one website site, computer, server or data center to another website site, computer, server or data center through wired (such as coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (such as infrared, wireless, microwave, etc.) manner. The computer readable storage medium can be any available medium accessible by a computer or a data storage device such as a server, data center, etc. integrated with one or more available media. The available medium can be a magnetic medium (for example, floppy disk, hard disk, magnetic tape), an optical medium (for example, DVD), or a semiconductor medium (for example, solid state disk (SSD)) and the like.
[0067] The present application also provides an electronic device, including: a processor and a memory; wherein the memory stores a computer program, and when the processor executes the computer program, the processor can be used to execute the processing method as recited in any of the preceding embodiments of the present application.
[0068] The application further provides a computer readable storage medium, which stores a computer program, and the computer program is used to execute the processing method as recited in any one of the preceding embodiments of the application.
[0069] The application further provides a chip for executing an operation instruction, which is used to execute the processing method as recited in any one of the preceding embodiments of the application.
[0070] The application further provides a program product, which comprises a computer program stored in a storage medium, and at least one processor can read the computer program from the storage medium, and the at least one processor executes the computer program to implement the processing method as recited in any one of the preceding embodiments of the application.
[0071] Those skilled in the art can understand that all or part of the steps of the above-mentioned method embodiments can be completed by using a program instruction related hardware. The foregoing program can be stored in a computer readable storage medium. When the program is executed, the steps of the above-mentioned method embodiments are executed; and the foregoing storage medium includes ROM, RAM, magnetic disk or optical disk and various media that can store program codes.
[0072] Finally, it should be noted that: the above embodiments are only used to illustrate the technical solutions of the application, rather than limit them; although the application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that: they can still modify the technical solutions recorded in the foregoing embodiments, or make equivalent replacement for part or all of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the scope of the technical solutions of the embodiments of the application.
Claims
1. A method for processing a statement, characterized in that: include: Obtaining a sentence to be processed; wherein the sentence to be processed is obtained by recognizing voice data, and the sentence to be processed includes a plurality of characters arranged in sequence; Splitting the statement to be processed into multiple processing parts; wherein the processing part includes one character in the statement, or multiple consecutive characters; Determining, from the multiple processing parts, a first processing part corresponding to a first entity term in the entity index; wherein the first entity term and the first processing part have the same number of characters, and the first entity term and the characters arranged in the same position in the first processing part have the same pinyin, the entity index includes multiple entity terms, a first-level index of the entity terms, and a second-level index of the entity terms, the first-level index includes the pinyin of each character in the entity term and the arrangement position of the character in the entity term, and the second-level index includes the arrangement position of all characters in the multiple entity terms; When the text of the first processed portion is different from the text of the first entity term, the text of the first entity term is used to replace the text of the first processed portion; Determining, from the plurality of processing parts, a first processing part corresponding to a first entity term in the entity index includes: Determining a set of candidate entity terms corresponding to the pinyin of each character in each processing part according to the entity index; the set of candidate entity terms includes at least one entity term; From the multiple processing parts, determine the processing part that includes the same first candidate entity term in the candidate entity term set corresponding to each character as the first processing part.
2. The method according to claim 1, characterized in that Determining a set of candidate entity terms corresponding to the pinyin of each character in the processing portion includes: Determining, from the entity index, a second-level index of the first arrangement position of the first character in the processing portion according to the first arrangement position of the first character in the processing portion; Determining at least one candidate first-level index from the plurality of first-level indexes indicated by the second-level index based on the pinyin of the first character; wherein the pinyin of the second character at the first arrangement position in the entity terms indicated by the candidate first-level indexes meets a first preset condition; The entity term indicated by the candidate first-level index is added to the candidate entity term set.
3. The method according to claim 2, characterized in that The first preset condition includes: The pinyin of the first character is the same as the pinyin of the second character; or The ratio of the edit distance between the pinyin of the first character and the pinyin of the second character to a first length is less than a first threshold; wherein the first length is the maximum length between the pinyin length of the first character and the pinyin length of the second character.
4. The method according to claim 3, characterized in that The entity index further includes: the tone of each entity term in the plurality of entity terms, and the adding of the entity term indicated by the candidate first-level index to the candidate entity term set includes: Among the entity terms indicated by the candidate first-level indexes, entity terms whose tones meet the second preset condition are added to the candidate entity term set.
5. The method according to claim 4, characterized in that The second preset condition includes: A ratio of an edit distance between the tones of all characters in the processing portion and the tones of all characters in the entity terms to a first length is smaller than a second threshold.
6. The method according to any one of claims 1 to 5, characterized in that The method further comprises: A plurality of entity terms are obtained, and the entity index is established according to the pinyin of each character in the plurality of entity terms and the arrangement position of the character in the entity terms.
7. The method according to claim 1, characterized in that The method further comprises: storing the first processing part and a corresponding relationship between the first processing part and the first entity term; When the sentence to be processed obtained again includes the first processing part, the text of the first processing part is replaced by the text of the first entity term.
8. A sentence processing device, characterized in that: include: An acquisition module, configured to acquire a sentence to be processed; wherein the sentence to be processed is obtained by recognizing voice data, and the sentence to be processed includes a plurality of characters arranged in sequence; a splitting module, configured to split the statement to be processed into a plurality of processing parts; wherein the processing part includes a character in the statement, or a plurality of consecutive characters; A determination module is configured to determine, from the multiple processing parts, a first processing part corresponding to a first entity term in an entity index; wherein the first entity term and the first processing part have the same number of characters, and the first entity term and the characters arranged in the same position in the first processing part have the same pinyin, the entity index includes multiple entity terms, a first-level index of the entity terms, and a second-level index of the entity terms, the first-level index includes the pinyin of each character in the entity term and the arrangement position of the character in the entity term, and the second-level index includes the arrangement position of all characters in the multiple entity terms; the determination module is specifically configured to determine, based on the entity index, a set of candidate entity terms corresponding to the pinyin of each character in each processing part; the set of candidate entity terms includes at least one entity term; and from the multiple processing parts, the processing part that includes the same first candidate entity term in the set of candidate entity terms corresponding to each character is determined to be the first processing part; A processing module is configured to replace the text of the first processing part with the text of the first entity term when the text of the first processing part is different from the text of the first entity term.
9. An electronic device, characterized in that: include: memory and processor; The memory stores computer-executable instructions; the processor executes the computer-executable instructions stored in the memory, so that the processor executes the statement processing method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Data retrieval method, data retrieval engine and embedded terminal
CN101770478A
Method for acquiring polyphone spelling, method for retrieving based on spelling, and corresponding devices
CN103365925A