A language recognition method and device

By obtaining the character encoding and language tag features in the text to be recognized, and using the deep network model to recognize languages, the problem of misrecalling multilingual text recognition in the prior art is solved, and the recognition accuracy and user experience are improved.

CN113688625BActive Publication Date: 2025-02-18ALIBABA GROUP HOLDING LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202010426835.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-05-19
Publication Date
2025-02-18
Estimated Expiration
2040-05-19

AI Technical Summary

Technical Problem

The prior art can easily lead to misrecalls when identifying multilingual texts, resulting in a decrease in user experience because the keyword meanings in different languages ​​cannot be accurately identified.

Method used

By obtaining the encoding of each character in the text to be recognized, its language tag features are obtained, and using a language recognition model based on a deep network, the language type to be recognized is determined to improve the recognition accuracy.

Benefits of technology

It improves the accuracy of language recognition, reduces the situation of misrecalls, thereby improving the user experience, and improving the generalization of language recognition models.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113688625B_ABST
    Figure CN113688625B_ABST
Patent Text Reader

Abstract

The present application provides a language identification method and device. In the present application, the language tag features of each character in the text to be identified are obtained according to the encoding of each character in the text to be identified, and then the language tag features of each character are input into the language identification model, so that the language identification model identifies the language of the text to be identified based on the language tag features of each character. In this way, for the language identification model, the input data it receives includes more language-related information of each character in the text to be identified, so that the language identification model can identify the language of the text to be identified based on more data. Since the language identification model uses the language-related information of each character in the text to be identified when identifying the text to be identified, the accuracy of the language of the identified text to be identified can be improved, thereby reducing the possibility of false recall, thereby avoiding reducing the user experience.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of Internet, and in particular to a language recognition method and device. Background Art

[0002] The development of the Internet has made information rich and varied, and users can use search technology to search for the information they need on the Internet. For the server on the Internet, it can perform a search operation based on the search text entered by the user to provide search results to the user.

[0003] However, some search texts may involve illegal situations, for example, search texts include illegal keywords such as "guns", "controlled knives" and "jammers". In order to purify the network environment, restrictions need to be imposed. For example, when the search text entered by the user includes these keywords, search results may be refused to be provided to the user.

[0004] However, some texts are used in different languages ​​and have different meanings in different languages, for example, the word "jammer" means "jammer" in English and "pity" in Dutch.

[0005] Assuming that the server needs to restrict "jammer" but does not need to restrict "unfortunately", if the user enters the search text in the Dutch context and the server performs semantic recognition on it in the English context, the server will determine the meaning of "jammer" in the search text as "jammer" and refuse to provide search results to the user.

[0006] In this way, there occurs a situation where the search results should be provided to the user but are actually refused to be provided to the user, which will reduce the user experience. Summary of the invention

[0007] In order to improve user experience, the present application shows a language recognition method and device.

[0008] In a first aspect, the present application provides a language recognition method, which is applied to an electronic device, and the method includes:

[0009] Get the text to be recognized;

[0010] Obtaining the encoding of each character in the text to be recognized;

[0011] Acquire language tag features of each character in the text to be recognized according to the encoding;

[0012] The language of the text to be recognized is determined according to the language tag features of each character and a language recognition model based on a deep network.

[0013] In an optional implementation, the acquiring, according to the encoding, the language tag feature of each character in the text to be recognized includes:

[0014] For each character in the text to be recognized, determining whether the character belongs to one language or multiple languages ​​at the same time according to the encoding of the character;

[0015] When the character belongs to a language, obtaining a language tag feature of the character according to the language;

[0016] In the case where the character belongs to at least two languages ​​at the same time, determining adjacent characters of the character in the text to be recognized, and generating a language tag feature of the character according to the character and the adjacent characters;

[0017] In an optional implementation, determining, according to the encoding of the character, that the character belongs to one language or to multiple languages ​​at the same time, includes:

[0018] Get the encoding segment where the encoding of the character is located;

[0019] In the correspondence between the coding segment and the language, searching for the language corresponding to the coding segment;

[0020] When there is only one language corresponding to the encoding segment, determining that the character belongs to one language;

[0021] When there are at least two languages ​​corresponding to the encoding segment, it is determined that the character belongs to multiple languages ​​at the same time.

[0022] In an optional implementation, the acquiring, according to the encoding, the language tag feature of each character in the text to be recognized includes:

[0023] In the case where the character is a word, in the word, a preset number of consecutive letters are respectively formed into a letter set;

[0024] A language tag feature of the character is generated according to the word and the letter set.

[0025] In an optional implementation, obtaining the text to be recognized includes:

[0026] Get the original text;

[0027] The non-language characters in the original text are removed to obtain the text to be recognized.

[0028] In an optional implementation, the method further includes:

[0029] Acquire a sample data set, wherein the sample language label features of each sample character in at least one sample text in the sample data set;

[0030] Obtain the annotated language of each sample text in the sample data set;

[0031] The deep network model is trained based on the sample data set and the annotated language until the parameters in the deep network model converge, thereby obtaining the deep network-based language recognition model.

[0032] In an optional implementation, obtaining the sample data set includes:

[0033] Acquire a plurality of first sample texts, each sample text comprising characters of a language;

[0034] generating a second sample text according to at least two first sample texts including characters in different languages;

[0035] The sample data set is generated according to the plurality of first sample texts and the generated second sample texts.

[0036] In a second aspect, the present application shows a language recognition device, which is applied to an electronic device, and the device includes:

[0037] A first acquisition module, used to acquire the text to be recognized;

[0038] A second acquisition module is used to acquire the code of each character in the text to be recognized;

[0039] A third acquisition module, used for acquiring language tag features of each character in the text to be recognized according to the encoding;

[0040] The determination module is used to determine the language of the text to be recognized based on the language tag features of each character and a language recognition model based on a deep network.

[0041] In an optional implementation, the third acquisition module includes:

[0042] A first determination unit, configured to determine, for each character in the to-be-recognized text, whether the character belongs to one language or to multiple languages ​​at the same time according to the encoding of the character;

[0043] A first acquisition unit, configured to acquire a language tag feature of the character according to the language when the character belongs to a language;

[0044] a second determining unit, configured to determine adjacent characters of the character in the to-be-recognized text when the character belongs to at least two languages ​​at the same time; and a first generating unit, configured to generate a language tag feature of the character based on the character and the adjacent characters;

[0045] In an optional implementation, the first determining unit includes:

[0046] An acquisition subunit, used for acquiring the encoding segment where the encoding of the character is located;

[0047] A search subunit, used to search for a language corresponding to the coding segment in the correspondence between the coding segment and the language;

[0048] A first determination subunit, configured to determine that the character belongs to one language when the language corresponding to the encoding segment is one;

[0049] The second determining subunit is used to determine that the character belongs to multiple languages ​​at the same time when there are at least two languages ​​corresponding to the encoding segment.

[0050] In an optional implementation, the third acquisition module includes:

[0051] A composition unit, for, when the character is a word, respectively composing a preset number of consecutive letters in the word into a letter set;

[0052] The second generating unit is used to generate a language tag feature of the character according to the word and the letter set.

[0053] In an optional implementation, the first acquisition module includes:

[0054] A second acquisition unit, used for acquiring the original text;

[0055] The removal unit is used to remove non-language characters in the original text to obtain the text to be recognized.

[0056] In an optional implementation, the device further includes:

[0057] A fourth acquisition module, configured to acquire a sample data set, wherein the sample language label features of each sample character in at least one sample text in the sample data set;

[0058] A fifth acquisition module, used to acquire the annotated language of each sample text in the sample data set;

[0059] A training module is used to train the deep network model based on the sample data set and the annotated language until the parameters in the deep network model converge, thereby obtaining the deep network-based language recognition model.

[0060] In an optional implementation, the fourth acquisition module includes:

[0061] A third acquisition unit is used to acquire a plurality of first sample texts, each sample text comprising characters of a language;

[0062] A third generating unit, configured to generate a second sample text according to at least two first sample texts including characters in different languages;

[0063] The fourth generating unit is used to generate the sample data set according to the multiple first sample texts and the generated second sample texts.

[0064] In a third aspect, the present application shows an electronic device, the electronic device comprising:

[0065] Processor; and

[0066] A memory having executable codes stored thereon, which, when executed, causes the processor to execute the language recognition method as described in the first aspect.

[0067] In a fourth aspect, the present application shows one or more machine-readable media on which executable codes are stored. When the executable codes are executed, the processor executes the language recognition method as described in the first aspect.

[0068] Compared with the prior art, the embodiments of the present application have the following advantages:

[0069] In one method, each character in the text to be recognized is directly input into the language recognition model, and the language recognition model outputs the language of the text to be recognized based on processing the text to be recognized.

[0070] However, in the present application, the language tag features of each character in the text to be recognized are obtained according to the encoding of each character in the text to be recognized, and then the language tag features of each character are input into the language recognition model, so that the language recognition model recognizes the language of the text to be recognized based on the language tag features of each character.

[0071] Among them, the language tag features of each character can at least directly or indirectly reflect which languages ​​each character may belong to. The language tag features of any character may include: the character, the language to which the character belongs, and the adjacent characters of the character in the text to be recognized, etc., and, in the case where the character is a word composed of multiple letters, the language tag features may also include: a letter set composed of a preset number of consecutive letters in the word, etc.

[0072] In this way, for the language recognition model, the input data it receives includes more language-related information about each character in the text to be recognized, so that the language recognition model can recognize the language of the text to be recognized based on more data. Since the language recognition model uses the language-related information of each character in the text to be recognized when recognizing the text to be recognized, the accuracy of the recognized language of the text to be recognized can be improved, thereby reducing the possibility of false recalls, thereby avoiding reducing the user experience.

[0073] In addition, the language recognition model in the present application is obtained through model training based on a deep network, which can improve the generalization of the language recognition model. For example, after the language recognition model is launched, even if the text to be recognized has not appeared in the sample text used in the process of training the language recognition model, the language recognition model's recognition accuracy of the language of the text to be recognized is greater than that of the model based on a shallow network. BRIEF DESCRIPTION OF THE DRAWINGS

[0074] Figure 1 It is a flowchart of a language recognition method shown in an exemplary embodiment of the present application.

[0075] Figure 2 It is a flowchart of a method for obtaining language tag features shown in an exemplary embodiment of the present application.

[0076] Figure 3 It is a flowchart of a method for obtaining language tag features shown in an exemplary embodiment of the present application.

[0077] Figure 4 It is a flowchart of a method for training a language recognition model shown in an exemplary embodiment of the present application.

[0078] Figure 5 It is a structural block diagram of a language recognition device shown in an exemplary embodiment of the present application.

[0079] Figure 6 It is a schematic diagram of the structure of a device provided in one embodiment of the present application. DETAILED DESCRIPTION

[0080] In order to make the above-mentioned objects, features and advantages of the present application more obvious and easy to understand, the present application is further described in detail below in conjunction with the accompanying drawings and specific implementation methods.

[0081] Reference Figure 1 , shows a flow chart of a language recognition method of the present application, the method is applied in an electronic device, and the method may include:

[0082] In step S101, the text to be recognized is obtained;

[0083] In the present application, the text to be recognized may include text input by a user, for example, text input by a user in a search box, etc. The electronic device may obtain the text input by the user and use it as the text to be recognized.

[0084] Alternatively, the text to be recognized may also include text recognized from audio, video or image.

[0085] In one example, if there is a person speaking in a video, semantic recognition can be performed on the voice spoken by the person in the video based on voice-to-text technology to obtain text expressed in the voice and use it as the text to be recognized.

[0086] In another example, during a voice call between two or more people, semantic recognition can be performed on the voice spoken by the people during the call based on voice-to-text technology to obtain text expressed by the voice and use it as text to be recognized.

[0087] In another example, the image includes text, and the text included in the image can be recognized based on OCR (Optical Character Recognition) technology and used as the text to be recognized.

[0088] Of course, in this application, the text to be recognized can also be obtained by other methods, and this application does not limit the specific acquisition method.

[0089] In step S102, the code of each character in the text to be recognized is obtained;

[0090] In the present application, the text to be recognized may include one character or at least two characters. In the present application, one character needs to represent a specific meaning. For example, for English and Latin-prepared languages ​​such as French, a single letter usually does not represent a specific meaning, but a word composed of at least two letters usually represents a specific meaning. Therefore, in these languages, one character may not include a single letter but may include a word.

[0091] For Chinese, Chinese, and Japanese, a single word can often represent a specific meaning. Therefore, in these languages, a single word can be a character.

[0092] In this application, for any language, for any character in the language, the encoding of the character can be set in advance, and then the character and the encoding of the character form a corresponding table item and are stored in the corresponding relationship between the character and the encoding. The same is true for every other character in the language. The same is true for every other language.

[0093] Therefore, in the present application, for any character in the text to be recognized, the code corresponding to the character can be found in the correspondence between the character and the code. For each other character in the text to be recognized, the above operation is also performed, thereby obtaining the code of each character in the text to be recognized.

[0094] In step S103, language tag features of each character in the text to be recognized are obtained according to the encoding of each character;

[0095] For any character, the language tag feature of the character may include: the character, the language to which the character belongs, and the adjacent characters of the character in the text to be recognized, etc., and. In the case where the character is a word composed of multiple letters, it may also include: a set of letters composed of a preset number of consecutive letters in the word, etc. For details, see Figure 2 as well as Figure 3 The embodiment shown will not be described in detail here. The language tag feature of the character can at least directly or indirectly reflect which language the character may belong to. The same is true for each other character.

[0096] In step S104, the language of the text to be recognized is determined according to the language tag features of each character and a language recognition model based on a deep network.

[0097] Among them, the language tag features of each character can be input into a language recognition model based on a deep network to obtain the language of the text to be recognized output by the language recognition model based on the deep network.

[0098] In one embodiment of the present application, the language recognition model determines the most likely language of the text to be recognized, and outputs the most likely language as the language of the text to be recognized. For example, the language of the text to be recognized is output as Chinese, English, or Japanese.

[0099] In another embodiment of the present application, the language recognition model outputs the probability that the text to be recognized belongs to each language. For example, the probability that the text to be recognized belongs to Chinese is 82%, the probability that it belongs to English is 15%, and the probability that it belongs to Japanese is 1%, and so on.

[0100] After determining the language of the text to be recognized, the text to be recognized can be processed in combination with the language of the text to be recognized. For example, it is determined whether a search operation can be performed on the text to be recognized based on the language of the text to be recognized. If a search operation can be performed on the text to be recognized, the search operation is performed on the text to be recognized and the search results are returned to the user.

[0101] In one method, each character in the text to be recognized is directly input into the language recognition model, and the language recognition model outputs the language of the text to be recognized based on processing the text to be recognized.

[0102] However, in the present application, the language tag features of each character in the text to be recognized are obtained according to the encoding of each character in the text to be recognized, and then the language tag features of each character are input into the language recognition model, so that the language recognition model recognizes the language of the text to be recognized based on the language tag features of each character.

[0103] Among them, the language tag features of each character can at least directly or indirectly reflect which languages ​​each character may belong to. The language tag features of any character may include: the character, the language to which the character belongs, and the adjacent characters of the character in the text to be recognized, etc., and, in the case where the character is a word composed of multiple letters, the language tag features may also include: a letter set composed of a preset number of consecutive letters in the word, etc.

[0104] In this way, for the language recognition model, the input data it receives includes more language-related information about each character in the text to be recognized, so that the language recognition model can recognize the language of the text to be recognized based on more data. Since the language recognition model uses the language-related information of each character in the text to be recognized when recognizing the text to be recognized, the accuracy of the recognized language of the text to be recognized can be improved, thereby reducing the possibility of false recalls, thereby avoiding reducing the user experience.

[0105] In addition, the language recognition model in the present application is obtained through model training based on a deep network, which can improve the generalization of the language recognition model. For example, after the language recognition model is launched, even if the text to be recognized has not appeared in the sample text used in the process of training the language recognition model, the language recognition model's recognition accuracy of the language of the text to be recognized is greater than that of the model based on a shallow network.

[0106] In another embodiment of the present application, see Figure 2 , step S102 includes:

[0107] In step S201, for each character in the text to be recognized, determine which language or languages the character belongs to according to the encoding of the character.

[0108] For any character, the character may be used in only one of multiple languages. For example, the four characters "chi", "mei", "wang", and "liang" in the idiom "chimeiwangliang" are only used in Chinese, so the characters "chi", "mei", "wang", and "liang" belong to only one language, Chinese. And characters such as "suo", "bian", and "ri" are used in at least two languages including Chinese and Japanese, so the characters "suo", "bian", and "ri" belong to two languages respectively.

[0109] All available encodings of character encodings can be divided into multiple encoding segments in advance. For any one encoding segment, the encoding segment can correspond to one language, or can correspond to at least two languages at the same time. The encoding segment and the language corresponding to the encoding segment can be formed into a corresponding table entry in advance and stored in the corresponding relationship between the encoding segment and the language. The same applies to each of the other encoding segments.

[0110] In this way, in this step, the encoding segment where the encoding of the character is located can be obtained; in the corresponding relationship between the encoding segment and the language, find the language corresponding to the encoding segment; when the language corresponding to the encoding segment is one, determine that the character belongs to one language; when the language corresponding to the encoding segment is at least two, determine that the character belongs to multiple languages at the same time.

[0111] For any character, when encoding the character, if the character is used in only one language, the encoding segment corresponding to the one language can be found in the corresponding relationship between the encoding segment and the language, and then a code is selected from the encoding segment as the encoding of the character. If the character is used in at least two languages, the encoding segment corresponding to the at least two languages can be found in the corresponding relationship between the encoding segment and the language, and then a code is selected from the encoding segment as the encoding of the character. The encoding of each of the other characters is also carried out in the above manner.

[0112] When the character belongs to one language, in step S202, obtain the language label feature of the character according to the language.

[0113] In this application, the language can be used as the language label feature of the character.

[0114] When the character belongs to at least two languages at the same time, in step S203, determine the adjacent characters of the character in the text to be recognized.

[0115] In the present application, when a character belongs to at least two languages at the same time, it is often impossible to directly determine which language the character specifically belongs to based on this character. This makes it impossible to provide accurate input data for the language recognition model, thereby affecting the accuracy of the language of the text to be recognized identified by the language recognition model.

[0116] Therefore, in order to avoid this situation from occurring, in another embodiment of the present application, it is necessary to determine which language the character belongs to. In order to be able to determine which language the character belongs to, the adjacent characters of the character can be determined in the text to be recognized. For example, the adjacent characters of the character can be determined in the text to be recognized based on N-gram.

[0117] In one example, a character located after the character and adjacent to the character can be determined as the adjacent character. Or, at least two characters located after the character and closest to the character can be determined as the adjacent characters. Or, a character located before the character and adjacent to the character can be determined as the adjacent character. Or, at least two characters located before the character and closest to the character can be determined as the adjacent characters, etc. Or, a character located before the character and adjacent to the character, and a character located after the character and adjacent to the character can be determined as the adjacent characters. Or, at least two characters located after the character and closest to the character, and at least two characters located after the character and closest to the character can be determined as the adjacent characters.

[0118] For example, in one example, the user needs to search for "soft toothbrush", and the user enters the search text "柔らかい歯ブラシ" in the search box based on the Japanese context. The electronic device obtains the search text "柔らかい歯ブラシ" input by the user and uses it as the text to be recognized.

[0119] Among them, the characters "ら", "か", "い", "ブ", "ラ", and "シ" in the text to be recognized belong to the Japanese language.

[0120] The character "柔" in the text to be recognized belongs to both Japanese and Chinese languages at the same time, and the character "歯" in the text to be recognized belongs to both Japanese and Chinese languages at the same time.

[0121] For the character "柔", in the text to be recognized "柔らかい歯ブラシ", the character "柔" is the first character, so the adjacent characters of the character "柔" can be determined among the characters after the character "柔". For example, the adjacent characters of the character "柔" can include "ら", "らか", or "らかい", etc. For the character "歯", the same is true, which will not be elaborated here.

[0122] In step S204, a language label feature of the character is generated based on the character and adjacent characters.

[0123] In this application, the character and the adjacent character can be combined to obtain the language label feature of the character.

[0124] In this application, a user usually inputs the text to be recognized in the context of a certain language. In the case where a certain character in a text belongs to multiple languages at the same time, although in fact the certain character belongs to multiple languages, subjectively, the user inputs the certain character in the context of a certain language. At this time, although the electronic device cannot determine which language the certain character belongs to only based on the certain character, if the adjacent character of the certain character in the text belongs to a certain language, generally, the certain character also belongs to the language to which the adjacent character of the certain character belongs.

[0125] For example, in the above example, the electronic device cannot accurately determine which language the character "柔" belongs to based on the character "柔".

[0126] However, the adjacent characters "ら", "らか", or "らかい" of the character "柔" in the text to be recognized "柔らかい歯ブラシ" belong to Japanese. Therefore, later, the language recognition model can also use the adjacent characters "ら", "らか", or "らかい" to determine that the language to which the character "柔" belongs is probably Japanese, thereby increasing the possibility of determining that the language of the text to be recognized is Japanese, and thus improving the accuracy of determining the language of the text to be recognized.

[0127] The embodiments of this application can increase the possibility and accuracy of determining the language to which a character belonging to multiple languages at the same time belongs in the text to be recognized, thereby providing accurate input data for the language recognition model, and further improving the accuracy of the language of the text to be recognized recognized by the language recognition model.

[0128] In another embodiment of this application, refer to Figure 3 , step S02 includes:

[0129] In step S301, when the character is a word, in the word, consecutive preset numbers of letters are respectively formed into letter sets.

[0130] In this application, in Romance languages such as English, French, and German, words include multiple letters.

[0131] Sometimes when a user inputs a word in the search box, the word may be misspelled accidentally or deliberately.

[0132] In one example, the Chinese interpretation of the word "volunteer" is "volunteer", and it is assumed that the word "volunteer" is only used in English and not in other languages.

[0133] For example, a user originally wanted to enter the English word "volunteer" in the search box, but the user mistakenly spelled it as "volunterr", assuming that the word "volunterr" does not exist in English.

[0134] In this way, the electronic device cannot determine the language of the word "volunterr" based on the word "volunterr". For example, the language of the word "volunterr" will not be determined as English, or the language of "volunterr" will be mistakenly determined as other languages ​​other than English, etc. This makes it impossible to provide accurate input data to the language recognition model, thereby affecting the accuracy of the language of the text to be recognized by the language recognition model.

[0135] Therefore, in order to avoid this situation, in another embodiment of the present application, in the word "volunterr", different consecutive preset numbers of letters can be used to form a letter set, for example, 4 consecutive letters "volu" are used to form a letter set, 4 consecutive letters "olun" are used to form a letter set, 4 consecutive letters "lunt" are used to form a letter set, 4 consecutive letters "unte" are used to form a letter set, 4 consecutive letters "nter" are used to form a letter set, and 4 consecutive letters "terr" are used to form a letter set.

[0136] The preset number can be determined according to actual conditions. The preset number can be greater than 1 and can be less than the number of letters included in the word, etc.

[0137] In step S302, a language tag feature of the character is generated according to the word and the letter set.

[0138] In the present application, the word can be combined with the letter set to obtain the language tag feature of the character.

[0139] In the case where the word is misspelled, sometimes it is impossible to determine which language the word belongs to. Or sometimes the language determined to belong to the word may be wrong, for example, the user wants to input an English word, but misspells a letter, and the misspelled word does not exist in English, but exists in French. Therefore, the electronic device may determine that the language of the word is French, but this is different from the language of the word that the user actually wants to input, resulting in the situation that the language of the word is determined to be wrong.

[0140] However, in this embodiment, in the word, different consecutive preset numbers of letters are respectively combined into letter sets; any letter set includes at least two consecutive letters in the word. Although sometimes it is impossible to accurately determine the language to which the word belongs based on the word, at least two consecutive letters in at least one letter set belong to at least one language.

[0141] For example, in the above example, the electronic device cannot accurately determine which language the word "volunterr" belongs to based on the word "volunterr".

[0142] However, since the word "volunteer" is used in English, the letter sets "volu", "olun", "lunt" and "unte" are also used in English. Therefore, the language recognition model can also use the letter sets "volu", "olun", "lunt" and "unte" to determine that the language of "volunterr" is most likely English, thereby increasing the possibility of determining that the language of the text to be recognized is English, thereby improving the accuracy of determining the language of the text to be recognized.

[0143] The embodiments of the present application can improve the possibility and accuracy of determining the language to which the characters as words belong, thereby providing accurate input data to the language recognition model, and further improving the accuracy of the language of the text to be recognized by the language recognition model.

[0144] In an embodiment of the present application, the word is a misspelled word. In this way, after determining the language of the text to be recognized based on the language recognition model, the misspelled word can be corrected in the context of the determined language in combination with the word, the context in the text to be recognized, and the error correction algorithm. For example, in the context of English, "volunterr" is corrected, for example, it is corrected to "volunteer", and then "volunteer" is used to replace "volunterr" in the text to be recognized, and then the search operation is performed according to the replaced text to be recognized, and the search results are returned to the user. Among them, this application does not limit the specific error correction algorithm.

[0145] In the present application, in order to determine the language of the text to be recognized in step S104 according to the language tag features of each character and the language recognition model based on the deep network, the language recognition model can be trained in advance, wherein, see Figure 4 , training methods include:

[0146] In step S401, a sample data set is obtained, where the sample data set includes sample language label features of each sample character in at least one sample text;

[0147] The sample text may be selected by a technician from a large amount of text on the Internet. For any sample text, the characters in the sample text may all be characters of one language.

[0148] The method for obtaining the sample language tag features of each sample character in the sample text can be found in Figure 2 as well as Figure 3 The illustrated embodiment will not be described in detail here.

[0149] In step S402, the annotated language of each sample text in the sample data set is obtained;

[0150] In this application, the annotated language may be annotated by a technician for each sample text manually. Of course, the annotated language of the sample text may also be obtained by other means. For example, the sample text is obtained from an English electronic magazine. The text in the English electronic magazine is usually composed of English words. Therefore, the annotated language of the sample text obtained from the English electronic magazine may be automatically determined as English. This application does not limit the annotated language of the sample text.

[0151] In step S403, the deep network model is trained based on the sample data set and the annotated language until the parameters in the deep network model converge, thereby obtaining a language recognition model based on the deep network.

[0152] Among them, deep network models include Convolutional Neural Networks, Recurrent Neural Networks, and Recursive Neural Networks.

[0153] In one embodiment, the language recognition model can be trained based on sample language label features of each sample character in a sample text of single language characters. In this way, after the trained language recognition model is put online, its accuracy in recognizing the language of a text including characters of a single language is higher, and its accuracy in recognizing the language of a text including characters of at least two languages ​​is lower.

[0154] In the present application, sometimes the text entered by the user in the search box may include characters in at least two languages. However, the trained language recognition model does not actually have the ability to recognize the language of the text including characters in at least two languages. Therefore, in this case, the language of the text to be recognized based on the language recognition model is likely to be inaccurate, which will lead to the problem of incorrectly recognizing the language of the text to be recognized.

[0155] Therefore, in order to avoid the above situation, in another embodiment of the present application, it is necessary to improve the robustness of the language recognition model. For example, when obtaining a sample data set, multiple first sample texts can be obtained, and each sample text includes characters of one language; that is, the characters included in any sample text are all characters of the same language, without being mixed with characters of other languages.

[0156] Then, a second sample text may be generated according to at least two first sample texts including characters in different languages. For example, at least two first sample texts including characters in different languages ​​are combined to obtain the second sample text.

[0157] Then, a sample data set may be generated according to the plurality of first sample texts and the generated second sample texts.

[0158] For example, the sample language label features of each sample character in each first sample text are obtained, and the sample language label features of each sample character in each second sample text are obtained, and then the sample language label features of each sample character in each first sample text and the sample language label features of each sample character in each second sample text are combined to obtain a sample data set.

[0159] In this embodiment, the language recognition model is trained based on the sample language label features of each sample character in the first sample text of single language characters and the sample language label features of each sample character in the second sample text of multilingual characters. In this way, the trained language recognition model can have the ability to recognize the language of a text including characters of at least two languages. Therefore, the accuracy of the trained language recognition model in recognizing the language of a text including characters of at least two languages ​​can be improved.

[0160] In this application, the original text entered by the user in the search box can be used as the text to be recognized. However, the original text entered by the user in the search box sometimes includes not only language characters but also non-language characters, such as punctuation marks and Arabic numerals. Among them, language characters can reflect the language, while non-language characters often do not reflect the language.

[0161] When training a language recognition model, if the sample text used includes non-language symbols in addition to language symbols, then when training the model based on the sample text and the annotated language of the sample text, the language recognition model will learn the language classification of the non-language characters in the sample text as the annotated language of the sample text.

[0162] In this way, after the language recognition model is put into use, if the user enters a search text in the search box, and the search text includes language characters and the non-language characters, when the proportion of non-language characters in the entire search text is greater than the preset threshold, the learned language of the language characters may be determined as the language of the search text, but the determined language may not be the language of the language characters in the search text. In this case, the problem of incorrectly identifying the language of the search text will arise.

[0163] Therefore, in order to avoid this situation, in another embodiment of the present application, when training the language recognition model, the sample text may include language characters but may not include non-language characters. In this way, each sample character in the sample text is a language character but there are no non-language characters.

[0164] In this way, in the process of training the language recognition model, non-language characters will not be learned, but language characters will be learned. For example, the language classification of the language characters in the sample text is learned as the annotated language of the sample text.

[0165] In this way, after the language recognition model is applied online, the electronic device can obtain the original text, which includes the text entered by the user in the search box. For example, if the user enters a search text in the search box, the electronic device obtains the search text entered by the user and uses it as the original text.

[0166] Sometimes the original text includes non-language characters. However, the language recognition model is trained using sample text that only includes language characters. Therefore, the language recognition model has a higher accuracy rate for language recognition of search texts that only include language characters, but a lower accuracy rate for language recognition of search texts mixed with non-language characters.

[0167] Therefore, in order to avoid the non-language characters in the original text from having an adverse effect on the recognition accuracy of the language of the original text by the language recognition model, in the present application, the non-language characters in the original text can be removed to obtain the text to be recognized. The text to be recognized includes language characters but does not include non-language characters, and then step S102 is performed.

[0168] Reference Figure 5 , shows a structural block diagram of an embodiment of a language recognition device of the present application, which may specifically include the following modules:

[0169] A first acquisition module 11, used to acquire the text to be recognized;

[0170] A second acquisition module 12 is used to acquire the code of each character in the text to be recognized;

[0171] A third acquisition module 13 is used to acquire language tag features of each character in the text to be recognized according to the encoding;

[0172] The determination module 14 is used to determine the language of the text to be recognized based on the language tag features of each character and a language recognition model based on a deep network.

[0173] In an optional implementation, the third acquisition module includes:

[0174] A first determination unit, configured to determine, for each character in the to-be-recognized text, whether the character belongs to one language or to multiple languages ​​at the same time according to the encoding of the character;

[0175] A first acquisition unit, configured to acquire a language tag feature of the character according to the language when the character belongs to a language;

[0176] a second determining unit, configured to determine adjacent characters of the character in the to-be-recognized text when the character belongs to at least two languages ​​at the same time; and a first generating unit, configured to generate a language tag feature of the character based on the character and the adjacent characters;

[0177] In an optional implementation, the first determining unit includes:

[0178] An acquisition subunit, used for acquiring the encoding segment where the encoding of the character is located;

[0179] A search subunit, used to search for a language corresponding to the coding segment in the correspondence between the coding segment and the language;

[0180] A first determination subunit, configured to determine that the character belongs to one language when the language corresponding to the encoding segment is one;

[0181] The second determining subunit is used to determine that the character belongs to multiple languages ​​at the same time when there are at least two languages ​​corresponding to the encoding segment.

[0182] In an optional implementation, the third acquisition module includes:

[0183] A composition unit, for, when the character is a word, respectively composing a preset number of consecutive letters in the word into a letter set;

[0184] The second generating unit is used to generate a language tag feature of the character according to the word and the letter set.

[0185] In an optional implementation, the first acquisition module includes:

[0186] A second acquisition unit, used for acquiring the original text;

[0187] The removal unit is used to remove non-language characters in the original text to obtain the text to be recognized.

[0188] In an optional implementation, the device further includes:

[0189] A fourth acquisition module, configured to acquire a sample data set, wherein the sample language label features of each sample character in at least one sample text in the sample data set;

[0190] A fifth acquisition module, used to acquire the annotated language of each sample text in the sample data set;

[0191] A training module is used to train the deep network model based on the sample data set and the annotated language until the parameters in the deep network model converge, thereby obtaining the deep network-based language recognition model.

[0192] In an optional implementation, the fourth acquisition module includes:

[0193] A third acquisition unit is used to acquire a plurality of first sample texts, each sample text comprising characters of a language;

[0194] A third generating unit, configured to generate a second sample text according to at least two first sample texts including characters in different languages;

[0195] The fourth generating unit is used to generate the sample data set according to the multiple first sample texts and the generated second sample texts.

[0196] In one method, each character in the text to be recognized is directly input into the language recognition model, and the language recognition model outputs the language of the text to be recognized based on processing the text to be recognized.

[0197] However, in the present application, the language tag features of each character in the text to be recognized are obtained according to the encoding of each character in the text to be recognized, and then the language tag features of each character are input into the language recognition model, so that the language recognition model recognizes the language of the text to be recognized based on the language tag features of each character.

[0198] Among them, the language tag features of each character can at least directly or indirectly reflect which languages ​​each character may belong to. The language tag features of any character may include: the character, the language to which the character belongs, and the adjacent characters of the character in the text to be recognized, etc., and, in the case where the character is a word composed of multiple letters, the language tag features may also include: a letter set composed of a preset number of consecutive letters in the word, etc.

[0199] In this way, for the language recognition model, the input data it receives includes more language-related information about each character in the text to be recognized, so that the language recognition model can recognize the language of the text to be recognized based on more data. Since the language recognition model uses the language-related information of each character in the text to be recognized when recognizing the text to be recognized, the accuracy of the recognized language of the text to be recognized can be improved, thereby reducing the possibility of false recalls, thereby avoiding reducing the user experience.

[0200] In addition, the language recognition model in the present application is obtained through model training based on a deep network, which can improve the generalization of the language recognition model. For example, after the language recognition model is launched, even if the text to be recognized has not appeared in the sample text used in the process of training the language recognition model, the language recognition model's recognition accuracy of the language of the text to be recognized is greater than that of the model based on a shallow network.

[0201] The embodiment of the present application also provides a non-volatile readable storage medium, which stores one or more modules (programs). When the one or more modules are applied to a device, the device can execute instructions (instructions) of each method step in the embodiment of the present application.

[0202] The present application embodiment provides one or more machine-readable media on which instructions are stored, and when executed by one or more processors, the electronic device executes one or more of the methods described in the above embodiments. In the present application embodiment, the electronic device includes a server, a gateway, a sub-device, etc., and the sub-device is an Internet of Things device or other device.

[0203] The embodiments of the present disclosure may be implemented as an apparatus configured as desired using any appropriate hardware, firmware, software, or any combination thereof, and the apparatus may include electronic devices such as servers (clusters), terminal devices such as IoT devices, and the like.

[0204] Figure 6 An exemplary apparatus 1300 that can be used to implement various embodiments described in this application is schematically shown.

[0205] For one embodiment, Figure 6An exemplary apparatus 1300 is shown having one or more processors 1302, a control module (chip set) 1304 coupled to at least one of the (one or more) processors 1302, a memory 1306 coupled to the control module 1304, a non-volatile memory (NVM) / storage device 1308 coupled to the control module 1304, one or more input / output devices 1310 coupled to the control module 1304, and a network interface 1312 coupled to the control module 1306.

[0206] The processor 1302 may include one or more single-core or multi-core processors, and the processor 1302 may include any combination of general-purpose processors or special-purpose processors (such as graphics processors, application processors, baseband processors, etc.). In some embodiments, the device 1300 can be used as a server device such as a gateway described in the embodiments of the present application.

[0207] In some embodiments, the device 1300 may include one or more computer-readable media (e.g., memory 1306 or NVM / storage device 1308) having instructions 1314 and one or more processors 1302 configured to execute the instructions 1314 in combination with the one or more computer-readable media to implement a module to perform the actions described in the present disclosure.

[0208] For one embodiment, the control module 1304 may include any suitable interface controller to provide any suitable interface to at least one of the processor(s) 1302 and / or any suitable device or component in communication with the control module 1304 .

[0209] The control module 1304 may include a memory controller module to provide an interface to the memory 1306. The memory controller module may be a hardware module, a software module, and / or a firmware module.

[0210] The memory 1306 may be used, for example, to load and store data and / or instructions 1314 for the device 1300. For one embodiment, the memory 1306 may include any suitable volatile memory, such as a suitable DRAM. In some embodiments, the memory 1306 may include double data rate type four synchronous dynamic random access memory (DDR4 SDRAM).

[0211] For one embodiment, control module 1304 may include one or more input / output controllers to provide an interface to NVM / storage device 1308 and input / output device(s) 1310 .

[0212] For example, NVM / storage 1308 may be used to store data and / or instructions 1314. NVM / storage 1308 may include any suitable non-volatile memory (e.g., flash memory) and / or may include any suitable non-volatile storage device(s) (e.g., one or more hard disk drives (HDDs), one or more compact disk (CD) drives, and / or one or more digital versatile disk (DVD) drives).

[0213] NVM / storage device 1308 may include storage resources that are physically part of the device on which apparatus 1300 is installed, or it may be accessible to the device without being part of the device. For example, NVM / storage device 1308 may be accessed via input / output device(s) 1310 over a network.

[0214] (One or more) input / output devices 1310 may provide an interface for the apparatus 1300 to communicate with any other appropriate device, and the input / output device 1310 may include a communication component, a phonetic component, a sensor component, etc. The network interface 1312 may provide an interface for the apparatus 1300 to communicate through one or more networks, and the apparatus 1300 may wirelessly communicate with one or more components of a wireless network according to any of one or more wireless network standards and / or protocols, for example, accessing a wireless network based on a communication standard, such as WiFi, 2G, 3G, 4G, 5G, etc., or a combination thereof for wireless communication.

[0215] For one embodiment, at least one of the processor(s) 1302 may be packaged together with the logic of one or more controllers (e.g., a memory controller module) of the control module 1304. For one embodiment, at least one of the processor(s) 1302 may be packaged together with the logic of one or more controllers of the control module 1304 to form a system-in-package (SiP). For one embodiment, at least one of the processor(s) 1302 may be integrated on the same die with the logic of one or more controllers of the control module 1304. For one embodiment, at least one of the processor(s) 1302 may be integrated on the same die with the logic of one or more controllers of the control module 1304 to form a system-on-chip (SoC).

[0216] In various embodiments, the device 1300 may be, but is not limited to, a terminal device such as a server, a desktop computing device, or a mobile computing device (e.g., a laptop computing device, a handheld computing device, a tablet computer, a netbook, etc.). In various embodiments, the device 1300 may have more or fewer components and / or a different architecture. For example, in some embodiments, the device 1300 includes one or more cameras, a keyboard, a liquid crystal display (LCD) screen (including a touch screen display), a non-volatile memory port, multiple antennas, a graphics chip, an application-specific integrated circuit (ASIC), and a speaker.

[0217] An embodiment of the present application provides an electronic device, comprising: one or more processors; and one or more machine-readable media having instructions stored thereon, which, when executed by the one or more processors, enable the electronic device to perform one or more language recognition methods as described in the present application.

[0218] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0219] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.

[0220] The embodiments of the present application are described with reference to the flowcharts and / or block diagrams of the methods, terminal devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0221] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing terminal device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured product including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0222] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable terminal device to implement the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0223] Although the preferred embodiments of the present application have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the embodiments of the present application.

[0224] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or terminal device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or terminal device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or terminal device including the elements.

[0225] The above is a detailed introduction to a language recognition method and device provided by the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea. At the same time, for a person skilled in the art, according to the idea of ​​the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.

Claims

1. A language recognition method, characterized in that: Applied to electronic equipment, the method comprises: Get the text to be recognized; Obtaining the encoding of each character in the text to be recognized; Acquire language tag features of each character in the text to be recognized according to the encoding; Determining the language of the text to be recognized based on the language tag features of each character and a language recognition model based on a deep network; The step of determining the language of the text to be recognized based on the language tag features of each character and a language recognition model based on a deep network includes: Inputting the language tag features of each character into a language recognition model based on a deep network to obtain the language of the text to be recognized output by the language recognition model based on the deep network; The step of obtaining the language tag feature of each character in the text to be recognized according to the encoding includes: For each character in the text to be recognized, determining whether the character belongs to one language or multiple languages ​​at the same time according to the encoding of the character; When the character belongs to a language, obtaining a language tag feature of the character according to the language; In the case that the character belongs to at least two languages ​​at the same time, adjacent characters of the character are determined in the text to be recognized, and a language tag feature of the character is generated according to the character and the adjacent characters.

2. The method according to claim 1, characterized in that Determining, according to the encoding of the character, that the character belongs to one language or to multiple languages ​​at the same time, includes: Get the encoding segment where the encoding of the character is located; In the correspondence between the coding segment and the language, searching for the language corresponding to the coding segment; When there is only one language corresponding to the encoding segment, determining that the character belongs to one language; When there are at least two languages ​​corresponding to the encoding segment, it is determined that the character belongs to multiple languages ​​at the same time.

3. The method according to claim 1, characterized in that The step of obtaining the language tag feature of each character in the text to be recognized according to the encoding includes: In the case where the character is a word, in the word, a preset number of consecutive letters are respectively formed into a letter set; A language tag feature of the character is generated according to the word and the letter set.

4. The method according to claim 1, characterized in that: The step of obtaining the text to be recognized includes: Get the original text; The non-language characters in the original text are removed to obtain the text to be recognized.

5. The method according to claim 1, characterized in that The method further comprises: Acquire a sample data set, wherein the sample language label features of each sample character in at least one sample text in the sample data set; Obtain the annotated language of each sample text in the sample data set; The deep network model is trained based on the sample data set and the annotated language until the parameters in the deep network model converge, thereby obtaining the deep network-based language recognition model.

6. The method according to claim 5, characterized in that The obtaining of the sample data set comprises: Acquire a plurality of first sample texts, each sample text comprising characters of a language; generating a second sample text according to at least two first sample texts including characters in different languages; The sample data set is generated according to the plurality of first sample texts and the generated second sample texts.

7. A language recognition device, characterized in that: Applied to electronic equipment, the device comprises: A first acquisition module, used to acquire the text to be recognized; A second acquisition module is used to acquire the code of each character in the text to be recognized; A third acquisition module, used for acquiring language tag features of each character in the text to be recognized according to the encoding; A determination module, used to determine the language of the text to be recognized based on the language tag features of each character and a language recognition model based on a deep network; The determination module is specifically used to input the language tag features of each character into the language recognition model based on the deep network, and obtain the language of the text to be recognized output by the language recognition model based on the deep network; The third acquisition module includes: A first determination unit, configured to determine, for each character in the to-be-recognized text, whether the character belongs to one language or to multiple languages ​​at the same time according to the encoding of the character; A first acquisition unit, configured to acquire a language tag feature of the character according to the language when the character belongs to a language; The second determining unit is used to determine adjacent characters of the character in the text to be recognized when the character belongs to at least two languages ​​at the same time. The first generating unit is used to generate a language tag feature of the character based on the character and the adjacent characters.

8. The device according to claim 7, characterized in that The first determining unit includes: An acquisition subunit, used for acquiring the encoding segment where the encoding of the character is located; A search subunit, used to search for a language corresponding to the coding segment in the correspondence between the coding segment and the language; A first determination subunit, configured to determine that the character belongs to one language when the language corresponding to the encoding segment is one; The second determining subunit is used to determine that the character belongs to multiple languages ​​at the same time when there are at least two languages ​​corresponding to the encoding segment.

9. The device according to claim 7, characterized in that The third acquisition module includes: A composition unit, for, when the character is a word, respectively composing a preset number of consecutive letters in the word into a letter set; The second generating unit is used to generate a language tag feature of the character according to the word and the letter set.

10. The device according to claim 7, characterized in that The first acquisition module includes: A second acquisition unit, used for acquiring the original text; The removal unit is used to remove non-language characters in the original text to obtain the text to be recognized.

11. The device according to claim 7, characterized in that The device also includes: A fourth acquisition module, configured to acquire a sample data set, wherein the sample language label features of each sample character in at least one sample text in the sample data set; A fifth acquisition module, used to acquire the annotated language of each sample text in the sample data set; A training module is used to train the deep network model based on the sample data set and the annotated language until the parameters in the deep network model converge, thereby obtaining the deep network-based language recognition model.

12. The device according to claim 11, characterized in that The fourth acquisition module includes: A third acquisition unit is used to acquire a plurality of first sample texts, each sample text comprising characters of a language; A third generating unit, configured to generate a second sample text according to at least two first sample texts including characters in different languages; The fourth generating unit is used to generate the sample data set according to the multiple first sample texts and the generated second sample texts.

13. An electronic device, characterized in that: The electronic device comprises: Processor; and A memory having executable codes stored thereon, which, when executed, enables the processor to execute the language recognition method according to any one of claims 1 to 6.

14. One or more machine-readable media having executable codes stored thereon, which, when executed, cause a processor to execute the language identification method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Language identification method and device, terminal equipment and computer readable storage medium

    CN111027528A