Text recognition method and device, electronic equipment and readable storage medium

CN116070639BActive Publication Date: 2026-10-27VIVO MOBILE COMM CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202310084480.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-01-16
Publication Date
2026-10-27
Estimated Expiration
2043-01-16

AI Technical Summary

Technical Problem

[0005]本申请实施例的目的是提供一种文本识别方法、装置、电子设备及可读存储介质,能够解决在无网络或网络信号差时,无法识别出语音或文本对应的意图的问题

Benefits of technology

[0012]在本申请实施例中,电子设备将请求识别信息进行分词,得到字符串;获取字符串的字符编码,字符编码用于指示字符串在请求识别信息中的位置信息,位置信息包括起始位置和结束位置;基于字符串和字符编码,从预设词槽组合模板中,确定出目标词槽组合模板,每个预设词槽组合模板对应一种意图;基于目标词槽组合模板,获取请求识别信息对应的文本意图。通过该方案,由于电子设备可以根据请求识别信息对应的字符串,及其在请求识别信息中的位置信息,从预设词槽组合模板中,确定出目标词槽组合模板,并根据目标词槽组合模板对应的意图,确定出请求识别信息所对应的本文意图,因此可以使得电子设备无需通过调用云端接口进行语音识别和语义理解,就可以获取请求识别信息对应的意图。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116070639B_ABST
    Figure CN116070639B_ABST
Patent Text Reader

Abstract

The application discloses a text recognition method and device, electronic equipment and a readable storage medium, and belongs to the field of artificial intelligence. The method comprises the following steps: performing word segmentation on request recognition information to obtain a character string; obtaining character encoding of the character string, wherein the character encoding is used for indicating position information of the character string in the request recognition information, and the position information comprises a starting position and an ending position; determining a target word slot combination template from preset word slot combination templates based on the character string and the character encoding, wherein each preset word slot combination template corresponds to an intention; and obtaining a text intention corresponding to the request recognition information based on the target word slot combination template.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application belongs to the field of artificial intelligence, and specifically relates to a text recognition method, device, electronic device, and readable storage medium. Background Technology

[0002] Currently, more and more electronic devices are enabling voice assistant functionality to allow users to control the devices via voice or text.

[0003] Specifically, in a good network environment, electronic devices can perform speech recognition and semantic understanding by calling cloud interfaces, and then display pages and interact with users through corresponding applications.

[0004] Thus, when electronic devices are without a network or have a poor network signal, they cannot access cloud interfaces to perform speech recognition and semantic understanding, resulting in the inability to recognize the intent corresponding to the speech or text. Summary of the Invention

[0005] The purpose of this application is to provide a text recognition method, device, electronic device, and readable storage medium that can solve the problem of being unable to recognize the intent corresponding to speech or text when there is no network or the network signal is poor.

[0006] In a first aspect, embodiments of this application provide a text recognition method, which includes: segmenting request recognition information into words to obtain a string; obtaining the character encoding of the string, the character encoding being used to indicate the position information of the string in the request recognition information, the position information including the start position and the end position; determining a target slot combination template from preset slot combination templates based on the string and the character encoding, each preset slot combination template corresponding to an intent; and obtaining the text intent corresponding to the request recognition information based on the target slot combination template.

[0007] Secondly, embodiments of this application provide a text recognition device, which includes: a word segmentation module, an acquisition module, a determination module, and a processing module; the word segmentation module is used to segment the requested recognition information into words to obtain a string; the acquisition module is used to acquire the character encoding corresponding to the string obtained by the word segmentation module, the character encoding being used to indicate the position information of the string in the requested recognition information, the position information including the start position and the end position; the determination module is used to determine a target slot combination template from preset slot combination templates based on the string and character encoding acquired by the acquisition module, each preset slot combination template corresponding to an intent; the processing module is used to acquire the text intent corresponding to the requested recognition information based on the target slot combination template determined by the determination module.

[0008] Thirdly, embodiments of this application provide an electronic device including a processor and a memory, the memory storing programs or instructions executable on the processor, the programs or instructions, when executed by the processor, implementing the steps of the method described in the first aspect.

[0009] Fourthly, embodiments of this application provide a readable storage medium on which a program or instructions are stored, which, when executed by a processor, implement the steps of the method described in the first aspect.

[0010] Fifthly, embodiments of this application provide a chip, the chip including a processor and a communication interface, the communication interface being coupled to the processor, the processor being used to run programs or instructions to implement the method as described in the first aspect.

[0011] In a sixth aspect, embodiments of this application provide a computer program product stored in a storage medium, which is executed by at least one processor to implement the method described in the first aspect.

[0012] In this embodiment, the electronic device segments the request recognition information into words to obtain a string; obtains the character encoding of the string, which indicates the position information of the string in the request recognition information, including the start and end positions; based on the string and the character encoding, determines a target slot combination template from preset slot combination templates, each preset slot combination template corresponding to an intent; and obtains the text intent corresponding to the request recognition information based on the target slot combination template. Through this scheme, since the electronic device can determine the target slot combination template from the preset slot combination templates based on the string corresponding to the request recognition information and its position information in the request recognition information, and determine the text intent corresponding to the request recognition information based on the intent corresponding to the target slot combination template, the electronic device can obtain the intent corresponding to the request recognition information without calling cloud interfaces for speech recognition and semantic understanding. Attached Figure Description

[0013] Figure 1 This is one of the flowcharts of a text recognition method provided in the embodiments of this application;

[0014] Figure 2 This is a second flowchart of a text recognition method provided in an embodiment of this application;

[0015] Figure 3 This is the third flowchart of a text recognition method provided in the embodiments of this application;

[0016] Figure 4 This is a schematic diagram of the structure of a text recognition device provided in an embodiment of this application;

[0017] Figure 5 This is one of the hardware structure diagrams of an electronic device provided in the embodiments of this application;

[0018] Figure 6 This is a second schematic diagram of the hardware structure of an electronic device provided in an embodiment of this application. Detailed Implementation

[0019] The technical solutions of the embodiments of this application will be clearly described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this application. All other embodiments obtained by those skilled in the art based on the embodiments of this application are within the scope of protection of this application.

[0020] The terms "first," "second," etc., used in the specification and claims of this application are used to distinguish similar objects and not to describe a specific order or sequence. It should be understood that such terms can be used interchangeably where appropriate so that embodiments of this application can be implemented in orders other than those illustrated or described herein, and the objects distinguished by "first," "second," etc., are generally of the same class and the number of objects is not limited; for example, a first object can be one or more. Furthermore, in the specification and claims, "and / or" indicates at least one of the connected objects, and the character " / " generally indicates that the preceding and following objects are in an "or" relationship.

[0021] The following explains some terms / nouns used in the embodiments of this application.

[0022] 1. Random Access Memory (RAM)

[0023] Also known as main memory, it is the internal memory that directly exchanges data with the CPU. It can be read and written at any time (except during refresh) and is very fast. It is usually used as a temporary data storage medium for the operating system or other running programs.

[0024] 2. Read-Only Memory (ROM)

[0025] It operates in a non-destructive read mode, meaning it can only read information and cannot write it. Once information is written, it is fixed and will not be lost even if the power is cut off, hence it is also called a fixed-function memory.

[0026] 3. Word slots

[0027] The slots are the key information that electronic devices need to collect, and filling the slots is the process of collecting that key information. The slot value is the specific key information. For example, for the slot "destination", "Shanghai" can be filled into the slot, and the slot value for "destination" will then be "Shanghai".

[0028] 4. Word slot combination template

[0029] Slot combination templates are templates obtained by combining different slots, and each slot combination template corresponds to an intent.

[0030] 5. Intention

[0031] An intent is information that an electronic device can recognize related to the content input by the user. One intent can correspond to multiple slot combination templates, each intent can contain multiple slots, and different slots can be combined to obtain multiple different slot combination templates.

[0032] The text recognition method, apparatus, electronic device, and readable storage medium provided in this application will be described in detail below with reference to the accompanying drawings and through specific embodiments and application scenarios.

[0033] Currently, semantic understanding technology is widely used in various tasks of Natural Language Processing (NLP).

[0034] Among related technologies, rule-based and statistical methods are the two most widely used semantic understanding methods. Rule-based semantic understanding methods mainly construct prefix matching trees from slots and templates to achieve the effects of lexical and syntactic analysis. Statistical semantic understanding methods mainly use recurrent neural networks and their derivative models to perform sequence labeling on the text to be semantically recognized and understood. Each character in the text is labeled in the form of B / I / O (Begin / inside / Outside) to achieve the purpose of slot extraction.

[0035] In rule-based semantic understanding methods, the constructed prefix matching tree can meet engineering requirements when the data volume is small. However, memory consumption and time consumption increase linearly with the number of slots and templates. For example, when the number of slots reaches tens of millions, the memory consumption and query time of electronic devices will increase significantly when performing semantic understanding on text. For instance, taking a query rate of 1000 queries per second (QPS) as an example, if the query time is less than 60ms, 50 nodes need to be deployed. At this time, the memory occupied by a single instance is 10GB, and the total memory usage can reach 500GB. Since the RAM of electronic devices is generally between 8GB and 16GB, and the ROM is generally between 128GB and 512GB, the prefix matching tree can easily reach 10GB of RAM usage, causing the electronic device to become unresponsive. Therefore, the high memory consumption of the prefix matching tree makes it impossible to deploy it directly on electronic devices. Semantic understanding and recognition must be performed through a cloud interface under conditions of good network signal.

[0036] While statistical semantic understanding methods can distill cloud-based intent recognition models into smaller models for deployment on electronic devices, statistical models suffer from drawbacks in practical engineering, such as long training cycles, high update costs, and misjudgments in semantic understanding. These limitations restrict the application of cloud-based intent recognition models.

[0037] Currently, voice assistants enable users to control electronic devices via voice or text primarily by: In a stable network environment, the device calls a cloud interface for voice recognition and semantic understanding, then displays pages and interacts with the user through a corresponding application. However, when the device is offline or has a weak network signal, it cannot access the cloud interface, thus hindering voice recognition and semantic understanding, and consequently, making voice or text control impossible in such situations.

[0038] In this embodiment, the electronic device segments the request recognition information into words to obtain a string; obtains the character encoding of the string, which indicates the position information of the string in the request recognition information, including the start and end positions; based on the string and the character encoding, determines a target slot combination template from preset slot combination templates, each preset slot combination template corresponding to an intent; and obtains the text intent corresponding to the request recognition information based on the target slot combination template. Through this scheme, since the electronic device can determine the target slot combination template from the preset slot combination templates based on the string corresponding to the request recognition information and its position information in the request recognition information, and determine the text intent corresponding to the request recognition information based on the intent corresponding to the target slot combination template, the electronic device can obtain the intent corresponding to the request recognition information without calling cloud interfaces for speech recognition and semantic understanding.

[0039] The text recognition method provided in this application can be implemented by a text recognition device. For example, the item recall device can be an electronic device, or a component within that electronic device, such as an integrated circuit or a chip. The following will use an electronic device as an example to illustrate the item recall method provided in this application.

[0040] This application provides a text recognition method. Figure 1 A flowchart of a text recognition method provided in an embodiment of this application is shown, which can be applied to electronic devices. Figure 1 As shown, the text recognition method provided in this application embodiment may include the following steps 101 to 104.

[0041] Step 101: The electronic device segments the requested recognition information into words to obtain a string.

[0042] Optionally, the aforementioned request identification information may be text input by the user or text generated from speech, in order to control the electronic device to perform the corresponding operation.

[0043] For example, taking the aforementioned request recognition information as text generated from the user's input speech as an example, after the electronic device receives the user's input speech, it can recognize the speech through an automatic speech recognition (ASR) model and generate the text corresponding to the request recognition information.

[0044] Optionally, the electronic device can segment the requested identification information into words at the character level to obtain strings with at least one different character length.

[0045] For example, assuming that the request identification information includes X characters, the electronic device may first perform word segmentation on the request identification information at a granularity of one character to obtain X character strings; then perform word segmentation on the request identification information at a granularity of two characters to obtain X-1 character strings ... finally segment the request identification information at a granularity of X characters to obtain 1 character string. That is, after the electronic device performs word segmentation on the request identification information, X+X-1+...+1 character strings can be obtained.

[0046] For example, if the request identification information is "open application A", that is, the request identification information includes 5 characters, the electronic device may first perform word segmentation on the request identification information at a granularity of one character to obtain a total of five character strings: "open", "A", "app", "lica" and "tion"; then, the electronic device may perform word segmentation on the request identification information at a granularity of two characters to obtain a total of four character strings: "open A", "A app", "app lica" and "lica tion"; next, the electronic device may perform word segmentation on the request identification information at a granularity of three characters to obtain a total of three character strings: "open A app", "A app lica" and "app lica tion"; next, the electronic device may perform word segmentation on the request identification information at a granularity of four characters to obtain a total of two character strings: "open A app lica" and "A app lica tion"; finally, the electronic device may perform word segmentation on the request identification information at a granularity of five characters to obtain a total of one character string: "open application A". That is, after the electronic device performs word segmentation on the request identification information, a total of fifteen character strings can be obtained: "open", "A", "app", "lica", "tion", "open A", "A app", "app lica", "lica tion", "open A app", "A app lica", "app lica tion", "open A app lica", "A app lica tion", and "open application A".

[0047] Step 102: The electronic device obtains the character code of the character string.

[0048] The character code may be used to indicate position information of the character string in the request identification information, and the position information may include a start position and an end position.

[0049] It can be understood that the character code corresponding to one character string may indicate the start position and the end position of the character string in the request identification information.

[0050] Optionally, the character code may consist of the code of the start position and the code of the end position of a character string in the request identification information, and a special symbol connecting the code of the start position and the code of the end position.

[0051] For example, the electronic device may perform character coding on the position of each character in the request identification information, associate the character code at each position with the character at the position, so as to construct an association relationship between a character string and the start position and end position of the character string in the request identification information.

[0052] For example, if the request identification information is "open App A", the electronic device may encode the starting positions of the five characters in the request identification information starting from 0. In this way, a total of 15 character strings and their corresponding character encodings can be obtained: 0_0: o, 1_1: p, 2_2: e, 3_3: n, 4_4: A, 0_1: op, 1_2: pe, 2_3: en, 3_4: nA, 0_2: ope, 1_3: pen, 2_4: enA, 0_3: open, 1_4: penA, 0_4: openA. Among the character strings and their corresponding character encodings, the number before ":" represents the character encoding, and the content after ":" is the character string; the number before "_" represents the starting position of the character string in the request identification information, and the number after "_" represents the ending position of the character string in the request identification information.

[0053] It should be noted that one character string and its corresponding character encoding, for example, 3_3: n, may be referred to as a substring. That is, the substring may include the character string and its corresponding character encoding.

[0054] Step 103: The electronic device determines a target slot combination template from preset slot combination templates based on the character strings and the character encodings.

[0055] Each preset slot combination template corresponds to one intention.

[0056] Optionally, the electronic device may pre-set a plurality of different slots, and different combinations of slots may obtain different preset slot combination templates.

[0057] It should be noted that the electronic device may pre-set a plurality of different intentions, each intention may correspond to a plurality of different preset slot combination templates, and each preset slot combination template corresponds to one intention.

[0058] For example, the electronic device may preconfigure an intention of opening an application, and the intention may correspond to a preset slot combination template " <opt> <name>The preset slot combination template contains slots. <opt>"and slots" <name>".

[0059] Optionally, step 103 can be implemented through steps 103a and 103b below.

[0060] Step 103a: The electronic device matches the string with the slots in the preset slot combination template based on the string and character encoding to generate the target slot combination.

[0061] Optionally, the aforementioned preset slot combination template can be a preset slot combination template from a preset slot library.

[0062] In this embodiment of the application, the slots in the preset slot combination template can be key information that the electronic device needs to identify.

[0063] It can be understood that the process by which an electronic device matches a string with the slots in a preset slot combination template can be regarded as a slot filling process, that is, the slot filling process can be the process by which the electronic device identifies key information in the request information.

[0064] For example, an electronic device can combine strings that match slots to obtain a target slot combination.

[0065] Optionally, the aforementioned request identification information may contain X locations, where X is a positive integer. Step 103a can be specifically implemented through steps a to c below.

[0066] Step a: For each string and its corresponding character encoding, the electronic device queries the preset slot combination template to find the slot that matches the string.

[0067] The character encoding corresponding to the above string can indicate that the starting position of the string is at the starting position of the above requested identification information.

[0068] In this embodiment of the application, the character encoding can be a character encoding that indicates the starting position of the string in the requested identification information.

[0069] It can be understood that if the position indicated by the character encoding corresponding to the string is the same as the starting position of the above-mentioned request identification information, then the string is a string located at the starting position of the request identification information.

[0070] Optionally, "searching for slots that match the string" can be understood as: the meaning of the slots retrieved by the electronic device is the same as the attribute of the string. For example, if the string is "Application A", the slots retrieved by the electronic device that match the string are slots for the application name.

[0071] Step b: For each string corresponding to the i-th character encoding, the electronic device queries the preset slot combination template for slots that match the i-th string.

[0072] The encoding of the i-th character corresponding to the i-th string can indicate that the starting position of the i-th string is located at the i-th position of the above-mentioned requested identification information, so as to obtain at least one word slot, i∈{2,……,X}.

[0073] In this embodiment of the application, the i-th position of the above-mentioned request identification information is the position after the end position of the (i-1)-th string, that is, the starting position of the i-th string is the position after the end position of the (i-1)-th string.

[0074] In this embodiment of the application, when the end position of the recorded i-th string is the last position of the requested identification information, the query for the word slot matching the i-th string from the preset word slot combination template is stopped.

[0075] Optionally, after finding a slot that matches the i-th string, the electronic device can record the slot and its corresponding string.

[0076] For example, suppose an electronic device has pre-set slots. <opt>"and slots" <name>The request identifies the information as "Open application A". The electronic device can then use the slot... <opt>"Encoded as 12, slots..." <name>" is encoded as 20, and the starting positions of the four characters in the request identification information are encoded starting from 0. In this way, a total of 15 substrings can be obtained: 0_0: da, 1_1: kai, 2_2: A, 3_3: ying, 4_4: yong, 0_1: da kai, 1_2: kai A, 2_3: A ying, 3_4: ying yong, 0_2: da kai A, 1_3: kai A ying, 2_4: A ying yong, 0_3: da kai A ying, 1_4: kai A ying yong, 0_4: da kai A ying yong.

[0077] Wherein, 0_0: da, 0_1: da kai, 0_2: da kai A, 0_3: da kai A ying, 0_4: da kai A ying yong are the first substrings located at the starting position of the request identification information. The electronic device queries the slots matching the first substrings, and obtains the query results as: null, 12, null, null, null. The electronic device records the queried slot corresponding to the first character string as "da kai: 12".

[0078] Then, the electronic device takes the next position after the end position of the character string "da kai" as the starting position, and queries the slot matching the second substring corresponding to the character string located at this starting position, that is, queries the slots matching the substring "2_2: A", the substring "2_3: A ying" and the substring "2_4: A ying yong", and the obtained query results are null, null, 20. The electronic device records the queried slot corresponding to the second character string as "A ying yong: 20".

[0079] Step c: The electronic device combines at least one slot according to the sequence of X positions to obtain a target slot combination.

[0080] In the embodiment of the present application, the electronic device may combine at least one queried slot according to the sequence in the request identification information to obtain the target slot combination.

[0081] Optionally, in the embodiment of the present application, one slot may include a character string and its corresponding slot.

[0082] Optionally, in the embodiment of the present application, the target slot combination may be a combination of slots, or a combination of slot codes.

[0083] For example, the electronic device obtains the first slots "da kai: 12" and "A ying yong: 20" through query. According to the sequence in the request identification information "da kai A ying yong", the electronic device combines the two slots above to obtain the target slot combination "12_20".

[0084] Thus, since the electronic device can query the first slot that matches a string based on its start and end positions in the requested recognition information, and combine all the queried first slots in the order they appear in the requested recognition information to obtain the target slot combination, it can identify the key information in the requested recognition information. In this way, the target slot combination template can be obtained based on the target slot combination corresponding to the key information, thereby identifying the intent corresponding to the requested recognition information.

[0085] Step 103b: The electronic device determines the target slot combination template that matches the target slot combination from the preset slot combination templates.

[0086] In this embodiment of the application, the electronic device can query a preset slot combination template that matches the target slot combination.

[0087] Thus, since electronic devices can generate target slot combinations based on strings and their corresponding character codes, and determine the target slot combination template that matches the template slot combination template from the preset slot combination template, they can identify the intent corresponding to the requested identification information based on the intent corresponding to the target slot combination template.

[0088] Optionally, step 103b above can be implemented through steps d and e below.

[0089] Step d: The electronic device acquires the intent file corresponding to the preset slot combination template.

[0090] In this context, an intent file corresponds to an intent, and an intent corresponds to at least one preset slot combination template. The intent file corresponding to any intent may include: any intent, the preset slot combination template corresponding to the intent, and the relationship between slots contained in the preset slot combination template corresponding to the intent.

[0091] In this embodiment of the application, the association contained in the intent file can be: one intent corresponds to multiple preset slot combination templates, and each preset slot combination template is obtained by combining at least one slot.

[0092] It is understandable that the intent file corresponding to a preset slot combination template can indicate the intent corresponding to that preset slot combination template.

[0093] Step e: The electronic device matches the target slot combination with the association in each intent file to determine the target slot combination template that matches the target slot combination.

[0094] Optionally, the electronic device can match the relationships between slots in the target slot combination with the relationships between slots in the slot combination template corresponding to the intent in each intent file to determine the target slot combination template that matches the target slot combination.

[0095] For example, the electronic device can encode each slot in the preset slot combination template according to the association relationship in the intent file, thereby obtaining the code corresponding to the preset slot combination template. The electronic device queries the obtained codes to find the codes that match the codes corresponding to the target slot combination, and determines the preset slot combination template corresponding to the queried codes as the target slot combination template.

[0096] It can be understood that if the codes of slot combinations match, it indicates that the slots in that slot combination have the same relationship.

[0097] For example, the target slot combination "open_A application" corresponds to the code "12_20", and the preset slot combination template is " <opt> <name>If the corresponding code is also "12_20", then the electronic device will use the preset slot combination template. <opt> <name>"Identified as the target slot combination template. Among them, slots..." <opt>Fill with "open", slot <name>Fill in "Application A".

[0098] Thus, since the electronic device determines the target slot combination template that matches the target slot combination based on the intent in the intent file, the preset slot combination template corresponding to the intent, and the relationship between the slots contained in the preset slot combination template corresponding to the intent, it can accurately identify the target intent corresponding to the target slot combination obtained based on the request identification information, thereby accurately identifying the text intent of the request identification information.

[0099] Optionally, prior to step 103b above, the text recognition method provided in this application embodiment may further include steps 103c and 103d below.

[0100] Step 103c: Obtain the installation package for the electronic device.

[0101] Optionally, the installation package can be an installation package configured for electronic devices or an installation package configured for servers.

[0102] Step 103d: The electronic device configures the intent file based on the installation package.

[0103] In this embodiment of the application, the electronic device can obtain an installation package and store the configured intent file in the ROM of the electronic device. This can reduce memory consumption and accurately identify the text intent requesting recognition information by means of the intent in the intent file, the slot combination template corresponding to the intent, and the relationship between the slots contained in the slot combination template corresponding to the intent.

[0104] Step 104: The electronic device obtains the text intent corresponding to the requested recognition information based on the target slot combination template.

[0105] In this embodiment of the application, the electronic device can preset a variety of different intentions, each of which corresponds to a different operation.

[0106] For example, the electronic device determines the target slot combination template. <opt> <name>After the corresponding intent is "Open application A", the electronic device obtains the text intent corresponding to the request recognition information as "Open application A".

[0107] Optionally, after the electronic device obtains the text intent corresponding to the requested identification information, it can perform corresponding control operations based on the text intent.

[0108] Optionally, if the electronic device fails to determine the target slot combination template, it can output an empty result, i.e., the text intent corresponding to the requested recognition information has not been obtained.

[0109] In the text recognition method provided in this application embodiment, since the electronic device can determine the target slot combination template from the preset slot combination template based on the string corresponding to the requested recognition information and its position information in the requested recognition information, and determine the text intent corresponding to the requested recognition information based on the intent corresponding to the target slot combination template, the electronic device can obtain the intent corresponding to the requested recognition information without calling the cloud interface for speech recognition and semantic understanding.

[0110] Optionally, before step 103c above, such as Figure 2 As shown, the text recognition method provided in this application embodiment may further include the following steps 103e and 103f.

[0111] Step 103e: The electronic device configures the first intent for each intent.

[0112] Among them, the preset slot combination template corresponding to the first intention and the relationship between the slots contained in the preset slot combination template corresponding to the first intention.

[0113] In this embodiment of the application, different intentions correspond to different preset slot combination templates and slots.

[0114] Optionally, the electronic device can first configure slots and then combine the slots to obtain a preset slot combination template.

[0115] Optionally, each intent can be configured with a template configuration file, which can be used as a switch for intent templates.

[0116] Optionally, in the configuration of the preset slot combination template, parts obtained by combining slots can also be used to reduce the number of templates, thereby improving the overall configuration efficiency.

[0117] For example, suppose an electronic device needs to construct an intent to open an application. Then, the electronic device can first configure slots. <name>The content of this slot can be defined as the name of the application, such as: Application A, Application B, Application C, etc. Then, the server can configure the slots. <opt>The content of this slot can include "open" or "enabled". After configuring the slot, the server can... <opt>And slot <name>Combine them to obtain a preset slot combination template. <opt> <name>And generate a correspondence between it and the intent "open application".

[0118] Step 103f: The electronic device generates an intent file corresponding to the first intent based on the association relationship corresponding to the first intent and the slots and their codes contained in the preset slot combination template corresponding to the first intent, and saves the intent file into the installation package.

[0119] In this embodiment of the application, the electronic device can encode the configured slots.

[0120] For example, slots <name>Encoding is 20, slots <opt>The code is 12.

[0121] Optionally, the electronic device can generate a word slot and its encoding association relationship with multiple words corresponding to one word slot encoding according to the inverted index of word:slot encoding.

[0122] For example, for slots <name>The slot library can contain application A: 20, application B: 20, application C: 20; for slots <opt>The slot library can contain "open: 12" and "enabled: 12".

[0123] In this embodiment of the application, the electronic device can generate the encoding of a preset slot combination template based on slot encoding, and map the encoding of the preset slot combination template to its corresponding intent.

[0124] For example, for the intent "open application", the corresponding preset slot combination template is: <opt> <name>If the slot <opt>The encoding is 12, slots <name>If the encoding is 20, the mapping from the slot combination template to the intent is stored in reverse order according to the preset slot combination template. 12_20: Open the application.

[0125] It is understandable that an installation package containing slots, slot codes, and slot combination template libraries can store slots, slot codes, and slot combination template libraries into a database in the ROM of an electronic device during the installation process.

[0126] Thus, since slots, slot encodings, and slot combination template libraries can be generated into intent files and stored in the ROM of electronic devices without loading slots and slot combination templates into RAM, memory consumption is reduced compared to rule matching that uses prefix matching trees to build a tree structure in RAM. Furthermore, the separation of data storage and querying improves the efficiency of the semantic understanding rule system. Compared to offline semantic models, semantic understanding has higher accuracy, faster configuration, and lower memory consumption.

[0127] The following specific examples illustrate the text recognition method provided in the embodiments of this application.

[0128] Example 1: As Figure 3 As shown, the text recognition method provided in this application embodiment may include the following steps 301 to 308.

[0129] Step 301: The electronic device receives the request identification information.

[0130] Step 302: The electronic device segments the requested identification information into words and generates a substring containing the string and the start and end positions of the string in the requested identification information.

[0131] Step 303: The electronic device queries the slots in the preset slot combination template to find the slot that matches the string located at the beginning of the requested recognition information.

[0132] Step 304: The electronic device will use the position after the end of the matching slot string as the starting position of the next string to be queried, and perform a loop search.

[0133] Step 305: When the electronic device finds the end position of the matching slot string, which is located at the end position of the requested recognition information, the query ends.

[0134] Step 306: The electronic device records all the queried slots and combines them to obtain the target slot combination.

[0135] Step 307: The electronic device queries the preset slot combination template library for the target slot combination template that matches the target slot combination.

[0136] Step 308: If the electronic device finds a target slot combination template, it executes the target operation corresponding to the target intent of the target slot template; if it does not find a target slot combination template, it outputs an empty result.

[0137] Thus, since the electronic device can determine the target slot combination template from the preset slot combination template based on the string corresponding to the requested recognition information and its position information in the requested recognition information, and determine the textual intent corresponding to the requested recognition information based on the intent corresponding to the target slot combination template, the electronic device can obtain the intent corresponding to the requested recognition information without having to call the cloud interface for speech recognition and semantic understanding.

[0138] The text recognition method provided in this application can be executed by a text recognition device. This application uses a text recognition device executing the text recognition method as an example to illustrate the text recognition device provided in this application.

[0139] Figure 4 A schematic diagram of a possible structure of the text recognition device involved in an embodiment of this application is shown. For example... Figure 4 As shown, the text recognition device 40 may include: a word segmentation module 41, an acquisition module 42, and a determination module 43.

[0140] The system includes a word segmentation module 41, which segments the request recognition information into words to obtain a string; an acquisition module 42, which acquires the character encoding of the string obtained by the word segmentation module 41, whereby the character encoding indicates the position information of the string in the request recognition information, including the start and end positions; a determination module 43, which, based on the string and character encoding acquired by the acquisition module 42, determines a target slot combination template from a set of preset slot combination templates, where each preset slot combination template corresponds to an intent; and an acquisition module 42, which, based on the target slot combination template determined by the determination module 43, acquires the text intent corresponding to the request recognition information.

[0141] In one possible implementation, the aforementioned determining module 43 is specifically used for:

[0142] Based on strings and character encoding, the string is matched with slots in a preset slot combination template to generate the target slot combination;

[0143] From the preset slot combination templates, determine the target slot combination template that matches the target slot combination.

[0144] In one possible implementation, the requested identification information contains X locations, where X is a positive integer;

[0145] The aforementioned determining module 43 is specifically used for:

[0146] For each string and its corresponding character encoding, query the preset slot combination template to find the slot that matches the string. The character encoding of the string indicates that the starting position of the string is at the starting position of the requested recognition information.

[0147] For each string corresponding to the i-th character encoding, query the preset slot combination template to find the slot that matches the i-th string. The i-th character encoding corresponding to the i-th string indicates that the starting position of the i-th string is located at the i-th position of the requested recognition information, so as to obtain at least one slot, i∈{2,……,X};

[0148] Combine at least one slot according to the order of X positions to obtain the target slot combination.

[0149] In one possible implementation, the aforementioned determining module 43 is specifically used for:

[0150] Obtain the intent file corresponding to the preset slot combination template. One intent file corresponds to one intent. One intent corresponds to at least one preset slot combination template. The intent file corresponding to any intent includes: any intent, the preset slot combination template corresponding to any intent, and the relationship between slots contained in the preset slot combination template corresponding to any intent.

[0151] The target slot combination is matched with the association in each intent file to determine the target slot combination template that matches the target slot combination.

[0152] In one possible implementation, the above-mentioned device further includes: a processing module;

[0153] The aforementioned acquisition module 42 is also used to acquire the installation package before the determination module 43 determines the target slot combination template that matches the target slot combination from the preset slot combination templates;

[0154] The processing module is used to obtain the installation package configuration intent file obtained by the acquisition module 42.

[0155] In one possible implementation, the above-mentioned apparatus further includes: a configuration module and a generation module;

[0156] The above configuration module is used to configure, for each intent, a first intent, a preset slot combination template corresponding to the first intent, and the relationship between slots contained in the preset slot combination template corresponding to the first intent before the acquisition module 42 acquires the installation package.

[0157] The aforementioned generation module is used to generate an intent file corresponding to the first intent based on the association relationship corresponding to the first intent configured by the configuration module, and the slots and their codes contained in the preset slot combination template corresponding to the first intent, and to save the intent file into the installation package.

[0158] This application provides a text recognition device. Since the text recognition device can determine the target slot combination template from the preset slot combination template based on the string corresponding to the requested recognition information and its position information in the requested recognition information, and determine the text intent corresponding to the requested recognition information based on the intent corresponding to the target slot combination template, the text recognition device can obtain the intent corresponding to the requested recognition information without calling the cloud interface for speech recognition and semantic understanding.

[0159] The text recognition device in this application embodiment can be an electronic device or a component within an electronic device, such as an integrated circuit or a chip. The electronic device can be a terminal or other devices besides a terminal. For example, the electronic device can be a mobile phone, tablet computer, laptop computer, PDA, in-vehicle electronic device, mobile internet device (MID), augmented reality (AR) / virtual reality (VR) device, robot, wearable device, ultra-mobile personal computer (UMPC), netbook, or personal digital assistant (PDA), etc. It can also be a server, network attached storage (NAS), personal computer (PC), television set (TV), ATM, or self-service machine, etc. This application embodiment does not specifically limit the device.

[0160] The text recognition device in this application embodiment can be a device with an operating system. This operating system can be Android, iOS, or other possible operating systems; this application embodiment does not specifically limit the specific operating system used.

[0161] The text recognition device provided in this application embodiment can implement all the processes implemented in the method embodiments of Figures N to N+x, and achieve the same technical effect. To avoid repetition, it will not be described again here.

[0162] Optionally, such as Figure 5 As shown, this application embodiment also provides an electronic device 500, including a processor 501 and a memory 502. The memory 502 stores a program or instructions that can run on the processor 501. When the program or instructions are executed by the processor 501, they implement the various steps of the above-described text recognition method embodiment and can achieve the same technical effect. To avoid repetition, they will not be described again here.

[0163] It should be noted that the electronic devices in the embodiments of this application include the mobile electronic devices and non-mobile electronic devices described above.

[0164] Figure 6 A schematic diagram of the hardware structure of an electronic device to implement an embodiment of this application.

[0165] The electronic device 600 includes, but is not limited to, components such as: radio frequency unit 601, network module 602, audio output unit 603, input unit 604, sensor 605, display unit 606, user input unit 607, interface unit 608, memory 609, and processor 610.

[0166] Those skilled in the art will understand that the electronic device 600 may also include a power supply (such as a battery) for supplying power to various components. The power supply may be logically connected to the processor 610 through a power management system, thereby enabling functions such as managing charging, discharging, and power consumption through the power management system. Figure 6 The electronic device structure shown does not constitute a limitation on the electronic device. The electronic device may include more or fewer components than shown, or combine certain components, or have different component arrangements, which will not be elaborated here.

[0167] The processor 610 is used to segment the request recognition information into words to obtain a string; it is also used to obtain the character encoding of the string, which is used to indicate the position information of the string in the request recognition information, including the start position and the end position; it is also used to determine the target slot combination template from the preset slot combination templates based on the string and the character encoding, each preset slot combination template corresponding to an intent; and it is also used to obtain the text intent corresponding to the request recognition information based on the target slot combination template.

[0168] Optionally, the processor 610 described above is specifically used for:

[0169] Based on strings and character encoding, the string is matched with slots in a preset slot combination template to generate the target slot combination;

[0170] From the preset slot combination templates, determine the target slot combination template that matches the target slot combination.

[0171] Optionally, the requested identification information contains X locations, where X is a positive integer;

[0172] The aforementioned processor 610 is specifically used for:

[0173] For each string and its corresponding character encoding, query the preset slot combination template to find the slot that matches the string. The character encoding of the string indicates that the starting position of the string is at the starting position of the requested recognition information.

[0174] For each string corresponding to the i-th character encoding, query the preset slot combination template to find the slot that matches the i-th string. The i-th character encoding corresponding to the i-th string indicates that the starting position of the i-th string is located at the i-th position of the requested recognition information, so as to obtain at least one slot, i∈{2,……,X};

[0175] Combine at least one slot according to the order of X positions to obtain the target slot combination.

[0176] Optionally, the processor 610 described above is specifically used for:

[0177] Obtain the intent file corresponding to the preset slot combination template. One intent file corresponds to one intent. One intent corresponds to at least one preset slot combination template. The intent file corresponding to any intent includes: any intent, the preset slot combination template corresponding to any intent, and the relationship between slots contained in the preset slot combination template corresponding to any intent.

[0178] The target slot combination is matched with the association in each intent file to determine the target slot combination template that matches the target slot combination.

[0179] Optionally, the processor 610 is further configured to obtain the installation package before determining the target slot combination template that matches the target slot combination from the preset slot combination templates; and to configure the intent file based on the installation package.

[0180] Optionally, the processor 610 is further configured to configure a first intent, a preset slot combination template corresponding to the first intent, and the association relationship between slots contained in the preset slot combination template corresponding to the first intent for each intent before obtaining the installation package; and to generate an intent file corresponding to the first intent based on the association relationship corresponding to the first intent, as well as the slots and their encodings contained in the preset slot combination template corresponding to the first intent, and store the intent file in the installation package.

[0181] This application provides an electronic device that can determine the target slot combination template from a preset slot combination template based on the string corresponding to the request recognition information and its position information in the request recognition information, and determine the textual intent corresponding to the request recognition information based on the intent corresponding to the target slot combination template. Therefore, the electronic device can obtain the intent corresponding to the request recognition information without calling the cloud interface for speech recognition and semantic understanding.

[0182] It should be understood that, in this embodiment, the input unit 604 may include a graphics processing unit (GPU) 6041 and a microphone 6042. The GPU 6041 processes image data of still images or videos obtained by an image capture device (such as a camera) in video capture mode or image capture mode. The display unit 606 may include a display panel 6061, which may be configured in the form of a liquid crystal display, an organic light-emitting diode, or the like. The user input unit 607 includes at least one of a touch panel 6071 and other input devices 6072. The touch panel 6071 is also called a touch screen. The touch panel 6071 may include two parts: a touch detection device and a touch controller. Other input devices 6072 may include, but are not limited to, a physical keyboard, function keys (such as volume control buttons, power buttons, etc.), a trackball, a mouse, and a joystick, which will not be described in detail here.

[0183] The memory 609 can be used to store software programs and various data. The memory 609 may primarily include a first storage area for storing programs or instructions and a second storage area for storing data. The first storage area may store the operating system, application programs or instructions required for at least one function (such as sound playback, image playback, etc.). Furthermore, the memory 609 may include volatile memory or non-volatile memory, or both. The non-volatile memory may be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. Volatile memory can be random access memory (RAM), static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM), and direct memory bus RAM (DRRAM). The memory 609 in this embodiment includes, but is not limited to, these and any other suitable types of memory.

[0184] Processor 610 may include one or more processing units; optionally, processor 610 integrates an application processor and a modem processor, wherein the application processor mainly handles operations involving the operating system, user interface, and applications, and the modem processor mainly handles wireless communication signals, such as a baseband processor. It is understood that the aforementioned modem processor may also not be integrated into processor 610.

[0185] This application also provides a readable storage medium storing a program or instructions. When the program or instructions are executed by a processor, they implement the various processes of the above-described text recognition method embodiments and achieve the same technical effect. To avoid repetition, they will not be described again here.

[0186] The processor is the processor in the electronic device described in the above embodiments. The readable storage medium includes computer-readable storage media, such as computer read-only memory (ROM), random access memory (RAM), magnetic disk, or optical disk.

[0187] This application embodiment also provides a chip, which includes a processor and a communication interface. The communication interface is coupled to the processor. The processor is used to run programs or instructions to implement the various processes of the above-described text recognition method embodiments and can achieve the same technical effect. To avoid repetition, it will not be described again here.

[0188] It should be understood that the chip mentioned in the embodiments of this application may also be referred to as a system-on-a-chip, system chip, chip system, or system-on-a-chip, etc.

[0189] This application provides a computer program product, which is stored in a storage medium and executed by at least one processor to implement the various processes of the text recognition method embodiments described above, and can achieve the same technical effect. To avoid repetition, it will not be described again here.

[0190] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one…" does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element. Furthermore, it should be noted that the scope of the methods and apparatuses in the embodiments of this application is not limited to performing functions in the order shown or discussed, but may also include performing functions substantially simultaneously or in the reverse order, depending on the functions involved. For example, the described methods may be performed in a different order than described, and various steps may be added, omitted, or combined. Additionally, features described with reference to certain examples may be combined in other examples.

[0191] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a computer software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal (which may be a mobile phone, computer, server, or network device, etc.) to execute the methods described in the various embodiments of this application.

[0192] The embodiments of this application have been described above with reference to the accompanying drawings. However, this application is not limited to the specific embodiments described above. The specific embodiments described above are merely illustrative and not restrictive. Those skilled in the art can make many other forms under the guidance of this application without departing from the spirit and scope of the claims, and all of these forms are within the protection scope of this application.< / name> < / opt> < / name> < / opt> < / opt> < / name> < / opt> < / name> < / name> < / opt> < / name> < / opt> < / opt> < / name> < / name> < / opt> < / name> < / opt> < / name> < / opt> < / name> < / opt> < / name> < / opt> < / name> < / opt> < / name> < / opt> < / name> < / opt>

Claims

1. A text recognition method, characterized in that, The method includes: The requested identification information is segmented into words to obtain a string; Obtain the character encoding of the string, the character encoding being used to indicate the position information of the string in the request identification information, the position information including the start position and the end position; Based on the string and the character encoding, the string is matched with slots in a preset slot combination template to generate a target slot combination. Each preset slot combination template corresponds to an intent. From the preset slot combination templates, determine the target slot combination template that matches the target slot combination; Based on the target slot combination template, obtain the text intent corresponding to the request recognition information; The step of segmenting the requested identification information to obtain a string includes: The request identification information is segmented into words at the character level to obtain strings with at least one different character length; The text intent is the intent to indicate the control command corresponding to the request identification information; The requested identification information contains X locations, where X is a positive integer; The step of matching the string with slots in the preset slot combination template based on the string and the character encoding to generate a target slot combination includes: For each string and its corresponding character encoding, query the preset slot combination template to find the slot that matches the string. The character encoding of the string indicates that the starting position of the string is located at the starting position of the requested recognition information. For each string corresponding to the i-th character encoding, query the preset slot combination template to find a slot that matches the i-th string. The i-th character encoding corresponding to the i-th string indicates that the starting position of the i-th string is located at the i-th position of the requested recognition information, so as to obtain at least one slot, i∈{2,……,X}; The at least one slot is combined according to the order of the X positions to obtain the target slot combination.

2. The method according to claim 1, characterized in that, The step of determining a target slot combination template that matches the target slot combination from the preset slot combination templates includes: Obtain the intent file corresponding to the preset slot combination template. One intent file corresponds to one intent, and one intent corresponds to at least one preset slot combination template. The intent file corresponding to any intent includes: the intent, the preset slot combination template corresponding to the intent, and the relationship between slots contained in the preset slot combination template corresponding to the intent. The target slot combination is matched with the association in each intent file to determine the target slot combination template that matches the target slot combination.

3. The method according to claim 2, characterized in that, Before determining the target slot combination template that matches the target slot combination from the preset slot combination templates, the method further includes: Obtain the installation package; Configure the intent file based on the installation package.

4. The method according to claim 2, characterized in that, Before obtaining the installation package, the method further includes: For each intent, configure a first intent, a preset slot combination template corresponding to the first intent, and the relationship between slots contained in the preset slot combination template corresponding to the first intent; Based on the association relationship corresponding to the first intent, and the slots and their codes contained in the preset slot combination template corresponding to the first intent, an intent file corresponding to the first intent is generated, and the intent file is stored in the installation package.

5. A text recognition device, characterized in that, The device includes: a word segmentation module, an acquisition module, and a determination module; The word segmentation module is used to segment the request recognition information into words to obtain a string; The acquisition module is used to acquire the character encoding corresponding to the string obtained by the word segmentation module. The character encoding is used to indicate the position information of the string in the request recognition information. The position information includes the start position and the end position. The determining module is used to match the string with slots in a preset slot combination template based on the string and the character encoding to generate a target slot combination, where each preset slot combination template corresponds to an intent; and to determine a target slot combination template that matches the target slot combination from the preset slot combination templates. The acquisition module is further configured to acquire the text intent corresponding to the request recognition information based on the target slot combination template determined by the determining module; the text intent is the intent to indicate the control command corresponding to the request recognition information. Specifically, the word segmentation module is used to segment the request recognition information into words at the character granularity to obtain at least one string with different character lengths; The requested identification information contains X locations, where X is a positive integer; The determining module is specifically used for: For each string and its corresponding character encoding, query the preset slot combination template to find the slot that matches the string. The character encoding of the string indicates that the starting position of the string is located at the starting position of the requested recognition information. For each string corresponding to the i-th character encoding, query the preset slot combination template to find a slot that matches the i-th string. The i-th character encoding corresponding to the i-th string indicates that the starting position of the i-th string is located at the i-th position of the requested recognition information, so as to obtain at least one slot, i∈{2,……,X}; The at least one slot is combined according to the order of the X positions to obtain the target slot combination.

6. The apparatus according to claim 5, characterized in that, The determining module is specifically used for: Obtain the intent file corresponding to the preset slot combination template. One intent file corresponds to one intent, and one intent corresponds to at least one preset slot combination template. The intent file corresponding to any intent includes: the intent, the preset slot combination template corresponding to the intent, and the relationship between slots contained in the preset slot combination template corresponding to the intent. The target slot combination is matched with the association in each intent file to determine the target slot combination template that matches the target slot combination.

7. The apparatus according to claim 6, characterized in that, The device further includes: a processing module The acquisition module is further configured to acquire the installation package before the determining module determines the target slot combination template that matches the target slot combination from the preset slot combination template; The processing module is used to configure the intent file based on the installation package obtained by the acquisition module.

8. The apparatus according to claim 6, characterized in that, The device further includes: a configuration module and a generation module; The configuration module is used to configure a first intent, a preset slot combination template corresponding to the first intent, and the association relationship between slots contained in the preset slot combination template corresponding to the first intent for each intent before the acquisition module acquires the installation package. The generation module is used to generate an intent file corresponding to the first intent based on the association relationship configured by the configuration module and the slots and their codes contained in the preset slot combination template corresponding to the first intent, and to store the intent file in the installation package.

9. An electronic device, characterized in that, It includes a processor and a memory, the memory storing a program or instructions that can run on the processor, the program or instructions being executed by the processor to implement the steps of the text recognition method as described in any one of claims 1 to 4.

10. A readable storage medium, characterized in that, The readable storage medium stores a program or instructions that, when executed by a processor, implement the steps of the text recognition method as described in any one of claims 1 to 4.

Citation Information

Patent Citations

  • Instrument panel drawing processing method and device, electronic equipment and storage medium

    CN111597808A

  • Text semantic recognition method and device, electronic equipment and storage medium

    CN112241631A

  • Speech recognition method and device, electronic equipment and storage medium

    CN114299960A