Method and device for intent recognition and named entity extraction based on instant messaging message
By using a combination of regular expressions and trie in instant messaging messages, the problems of low speed and accuracy in intent recognition and named entity extraction are solved, enabling fast and accurate extraction of user intent and named entities, thus improving response speed and accuracy.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- BEIKE TECH CO LTD
- Filing Date
- 2022-04-11
- Publication Date
- 2026-07-07
AI Technical Summary
Existing intent recognition and named entity extraction technologies based on instant messaging messages suffer from slow response speed and low accuracy, mainly due to insufficient speed and accuracy of intent recognition and named entity extraction.
By matching the text of instant messaging messages against a regular expression corpus, obtaining matching regular expressions, performing secondary retrieval matching using a trie, correcting named entities to the most similar strings, and executing automated responses via API addresses.
It enables rapid and accurate extraction of user intent and named entities, improving response speed and accuracy, and completing the identification and matching of named entities within an average of 1 second.
Smart Images

Figure CN114970531B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer technology, and in particular to a method and apparatus for intent recognition and named entity extraction based on instant messaging messages. Background Technology
[0002] With the development of computer technology, intelligent technologies are being applied to all aspects of life, such as automated responses based on instant messaging messages. Automated responses based on instant messaging messages include automatically answering user inquiries or performing automated operations based on user commands. The technical implementation of automated responses based on instant messaging messages requires recognizing the user's intent and extracting named entities from the instant messaging messages, and then executing the corresponding automated response based on the intent and named entities.
[0003] Existing technologies for automated response based on instant messaging generally suffer from slow response speed and low accuracy. The root cause lies in the slow speed and low accuracy of intent recognition and named entity extraction. Improving the speed and accuracy of intent recognition and named entity extraction based on instant messaging can effectively improve the speed and accuracy of automated response. Summary of the Invention
[0004] To address the problems in the prior art, the present invention provides a method and apparatus for intent recognition and named entity extraction based on instant messaging messages.
[0005] This invention provides a method for intent recognition and named entity extraction based on instant messaging messages, comprising: obtaining the text corresponding to the instant messaging message; matching the text in a regular expression corpus to obtain matching regular expressions; wherein the regular expression corpus includes a set of regular expressions obtained by regularizing instant messaging message samples, and the regular expressions in the set of regular expressions classify user intents; obtaining the corresponding user intent based on the matching regular expressions; extracting named entities of at least one category based on the matching regular expressions; performing a secondary search and matching on the named entities using a pre-built trie based on the named entity samples to obtain at least one string in the trie in which the characters of the named entities appear in their original order; and correcting the data content of the named entities to the string among the at least one strings that has the highest similarity to the current data content.
[0006] According to the present invention, an intent recognition and named entity extraction method based on instant messaging messages, after obtaining the corresponding user intent according to the matching regular expression and before extracting named entities of at least one category according to the matching regular expression, the method further includes: obtaining the corresponding API address for executing an automated response according to the user intent; obtaining the category of the named entity to be extracted according to the API address; after correcting the data content of the named entity to the string with the highest similarity to the current data content among the at least one string, the method further includes: using the named entity as an input parameter to request the API address to request the execution of the automated response corresponding to the API address.
[0007] According to the present invention, an intent recognition and named entity extraction method based on instant messaging messages is provided, wherein the regular expressions in the regular expression set are stored in a database table in text style; the step of matching the text in the regular expression corpus to obtain the matching regular expression includes: using the regular expression retrieval function of the database to match the text in the regular expression corpus to obtain the matching regular expression.
[0008] According to the present invention, an intent recognition and named entity extraction method based on instant messaging messages is provided. The step of extracting named entities of at least one category based on the matching regular expression includes: extracting named entities of at least one category based on the positions of pre-labeled named entities of different categories in the regular expression.
[0009] According to the present invention, an intent recognition and named entity extraction method based on instant messaging messages is provided. The step of correcting the data content of the named entity to the string with the highest similarity to the current data content among the at least one strings includes: obtaining a preset number of strings with the highest ranking by calculating the TF-IDF score of the at least one string; calculating the similarity between the named entity and the preset number of strings; and correcting the data content of the named entity to the string with the highest similarity to the current data content among the at least one string.
[0010] According to the present invention, an intent recognition and named entity extraction method based on instant messaging messages is provided. The step of matching the text in a regular expression corpus to obtain the matching regular expression includes: matching the text in a regular expression corpus corresponding to a scenario, and obtaining the matching regular expression according to the priority of the scenario.
[0011] This invention also provides an intent recognition and named entity extraction device based on instant messaging messages, comprising: a text acquisition module, used to: acquire the text corresponding to the instant messaging message; a regular expression matching module, used to: match the text in a regular expression corpus to acquire the matching regular expression; wherein, the regular expression corpus includes a set of regular expressions obtained by regularizing instant messaging message samples, and the regular expressions in the set of regular expressions classify user intents; an intent recognition module, used to: acquire the corresponding user intent based on the matching regular expression; a named entity extraction module, used to: extract named entities of at least one category based on the matching regular expression; a trie secondary matching module, used to: perform secondary retrieval and matching on the named entities using a trie pre-built based on the named entity samples, to acquire at least one string in the trie in which the characters of the named entities appear in their original order; and a named entity correction module, used to: correct the data content of the named entity to the string among the at least one strings that has the highest similarity to the current data content.
[0012] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the steps of the intent recognition and named entity extraction method based on instant messaging messages as described above.
[0013] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the intent recognition and named entity extraction method based on instant messaging messages as described above.
[0014] The present invention also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the intent recognition and named entity extraction method based on instant messaging messages as described above.
[0015] The present invention provides a method and apparatus for intent recognition and named entity extraction based on instant messaging messages. This method obtains a regular expression by matching the text corresponding to the instant messaging message in a regular expression corpus. Based on the regular expression, the user intent and at least one category of named entities are obtained. A trie is used to perform a secondary search and matching on the named entities to obtain at least one string in which the characters of the named entities appear in the original order. Through similarity matching, the data content of the named entities is corrected to the string with the highest similarity to the current data content among at least one string. This achieves fast and accurate extraction of user intent and named entities. Attached Figure Description
[0016] To more clearly illustrate the technical solutions in this invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0017] Figure 1 This is one of the flowcharts of the intent recognition and named entity extraction method based on instant messaging messages provided by the present invention;
[0018] Figure 2 This is a schematic diagram of the trie structure;
[0019] Figure 3 This is the second flowchart of the method for intent recognition and named entity extraction based on instant messaging messages provided by the present invention;
[0020] Figure 4 This is a schematic diagram of the structure of the intent recognition and named entity extraction device based on instant messaging messages provided by the present invention;
[0021] Figure 5 This is a schematic diagram of the structure of the electronic device provided by the present invention. Detailed Implementation
[0022] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.
[0023] The following is combined with Figures 1-5 The present invention describes the method and apparatus for intent recognition and named entity extraction based on instant messaging messages.
[0024] Figure 1 This is one of the flowcharts for the intent recognition and named entity extraction method based on instant messaging messages provided by this invention. For example... Figure 1 As shown, the method includes:
[0025] Step 101: Obtain the text corresponding to the instant messaging message.
[0026] To retrieve the text corresponding to an instant messaging message, if the instant messaging message is in text format, then retrieving the instant messaging message will yield the corresponding text; if the instant messaging message is in voice format, then the text after voice recognition can be retrieved to obtain the text corresponding to the instant messaging message.
[0027] The intent recognition and named entity extraction method based on instant messaging messages provided by this invention can be developed based on the functions of existing instant messaging software, such as WeChat Work, and can be integrated into WeChat Work as a tool or plugin. In this case, obtaining the text corresponding to the instant messaging message requires using the API service provided by the instant messaging software. The intent recognition and named entity extraction method based on instant messaging messages provided by this invention can enhance the ease of data use in WeChat Work applications, and is particularly suitable for interactive scenarios in WeChat Work instant messaging where user intent recognition and named entity extraction are performed using regular expressions.
[0028] After obtaining the text corresponding to the instant messaging message, the text can be written to a Kafka queue for subsequent consumption processing.
[0029] Step 102: Match the text in a regular expression corpus to obtain the matching regular expressions; wherein, the regular expression corpus includes a set of regular expressions obtained by regularizing instant messaging message samples, and the regular expressions in the set of regular expressions delineate user intent.
[0030] This process involves collecting, analyzing, and refining instant messaging message samples with different user intents, then regularizing these samples to identify user intents. A regular expression corpus is constructed based on the set of regular expressions obtained from the regularization of instant messaging message samples. Instant messaging message samples can be obtained, for example, by collecting common query or command text. Regularization involves obtaining the corresponding regular expression from each instant messaging message sample. Since each instant messaging message sample corresponds to an intent, the regular expressions obtained from these samples also correspond to that intent; that is, the regular expressions in the regular expression set segment user intents.
[0031] The process involves matching the text corresponding to an instant messaging message against a regular expression corpus to obtain the matching regular expressions. For example, the regular expression for the text corresponding to an instant messaging message can be obtained, and then this regular expression can be matched against regular expressions in the regular expression set to obtain the matching regular expressions.
[0032] By matching text against a regular expression corpus, the resulting matching regular expressions can accurately match user intent. Furthermore, the regular expression corpus can rapidly iterate rules based on business developments to adapt to changing needs.
[0033] Step 103: Obtain the corresponding user intent based on the matched regular expression.
[0034] Since the regular expressions in the regular expression set are segmented according to user intent, the corresponding user intent can be obtained based on the matched regular expression.
[0035] Step 104: Extract named entities of at least one category based on the matched regular expression.
[0036] A named entity (NE) is a person's name, organization's name, place name, or any other entity identified by a name. User intent reflects the specific needs that a user's instant messaging message corresponds to, and combining it with named entities concretizes that user intent.
[0037] The system retrieves a matching regular expression from the text of the instant messaging message. After identifying the corresponding user intent based on this regular expression, a response needs to be executed to fulfill that intent. This automated response requires retrieving named entities of a defined category; the category and number of named entities required may vary depending on the specific automated response. The regular expression may retain all or only a portion of the named entity information, allowing for extraction. Therefore, depending on the category of named entities required for the automated response corresponding to the user intent, at least one category of named entities must be extracted based on the matching regular expression.
[0038] Step 105: Use the trie pre-built based on the named entity sample to perform a secondary search and matching on the named entity, and obtain at least one string in the trie in which the characters of the named entity appear in the original order.
[0039] The instant messaging-based intent recognition and named entity extraction method provided by this invention can be applied to business systems. Depending on the specific business, the business system may include different categories of named entities. Named entities in the business system can be used as input parameters for requesting the execution of business-related instructions.
[0040] In practice, the named entities extracted from a user's input statement are likely to be colloquial entities. As a result, the names of the named entities in the business system are similar to but not the same as the extracted colloquial named entities. It is necessary to match the extracted named entities with the named entities in the business system to obtain the corresponding named entities in the business system.
[0041] A trie, also known as a word lookup tree, is a tree-like data structure and a variant of a hash tree. Figure 2 This is a schematic diagram of a trie structure. The construction process of a trie includes three parts: defining nodes, constructing functions, and building the trie. A single process can be used to continuously update the trie to maintain its timeliness.
[0042] The trie tree has the following characteristics:
[0043] a. The root node does not contain characters. Each child node except the root node contains a character, which can be an English character, a Chinese character, or other characters.
[0044] b. From the root node to any node, the characters passed through on the path are concatenated to form the string corresponding to that node.
[0045] c. The characters contained in all child nodes of each node are different from each other.
[0046] When matching the extracted named entities with the named entities in the business system, if exact matching is used, it is very likely that the named entities that the user really hopes to identify cannot be recognized. If conventional text fuzzy query is used, only the results containing the extracted named entities can be found, and the similar named entities cannot be fully extracted. For example, there is an extra "de" character in the middle of the statement.
[0047] In order to be able to more widely identify the information of similar named entities, the named entities in the business system are used as named entity samples, and a trie tree is pre-constructed according to the named entity samples. The trie tree includes strings corresponding to multiple named entity samples, that is, the named entity samples exist in the trie tree in the form of strings. The constructed trie tree is used to perform secondary retrieval and matching on the extracted named entities, and at least one string in which the characters in the named entities in the trie tree appear in the original order is obtained. Since the strings in the trie tree correspond to the named entity samples, at least one string matched in the trie tree corresponds to at least one named entity sample. The named entity sample includes the characters in the extracted named entity, and the characters in the named entity appear in the original order in the named entity sample, but other characters are allowed to appear between the characters in the named entity. That is, by matching the named entity with the trie tree, a named entity sample including the characters in the extracted named entity and in which the characters in the named entity appear in the original order is obtained.
[0048] For example, if the string corresponding to the named entity sample is abcdefg and the string corresponding to the named entity extracted according to the regular expression is abe, then the string abcdefg corresponding to the named entity sample is the string in which the characters in the named entity abe appear in the original order; another example, if the string corresponding to the named entity sample is abcdefg and the string corresponding to the named entity extracted according to the regular expression is afg, then the string abcdefg corresponding to the named entity sample is the string in which the characters in the named entity afg appear in the original order.
[0049] After the above process, for named entities extracted from regular expressions, multiple strings may be matched in the trie.
[0050] Step 106: Modify the data content of the named entity to the string among the at least one strings that has the highest similarity to the current data content.
[0051] After extracting named entities based on regular expressions, a trie is used for secondary matching and further similarity matching to determine the precise named entity that is most similar to the user's instant messaging message.
[0052] After achieving a broader identification of similar named entity samples (i.e., obtaining multiple matched strings), the most similar named entity sample is identified through similarity matching. Specifically, this involves performing similarity matching between the named entity string and the strings obtained from the trie (e.g., calculating edit distance), correcting the named entity's data content to at least one string with the highest similarity to the current data content. In other words, the named entity sample most similar to the extracted named entity in the business system is obtained, and the named entity is replaced with the most similar named entity sample in the business system.
[0053] The method for intent recognition and named entity extraction based on instant messaging messages provided by this invention not only achieves accurate acquisition of user intent and named entities, but also greatly improves the speed of user intent and named entity extraction. Experiments have shown that after a user enters instant messaging text information through WeChat Work, the user intent can be recognized in an average of about 1 second, and the named entity extraction and accurate matching operations can be completed.
[0054] The present invention provides a method for intent recognition and named entity extraction based on instant messaging messages. This method obtains the corresponding regular expression by matching the text of the instant messaging message with a regular expression corpus. Based on the regular expression, the user intent and at least one category of named entities are obtained. A trie is used to perform a secondary search and matching on the named entities to obtain at least one string in which the characters of the named entities appear in the original order. Through similarity matching, the data content of the named entities is corrected to the string with the highest similarity to the current data content among at least one string. This method achieves fast and accurate extraction of user intent and named entities.
[0055] According to the present invention, an intent recognition and named entity extraction method based on instant messaging messages, after obtaining the corresponding user intent according to the matching regular expression and before extracting named entities of at least one category according to the matching regular expression, the method further includes: obtaining the corresponding API address for executing an automated response according to the user intent; obtaining the category of the named entity to be extracted according to the API address; after correcting the data content of the named entity to the string with the highest similarity to the current data content among the at least one string, the method further includes: using the named entity as an input parameter to request the API address to request the execution of the automated response corresponding to the API address.
[0056] The corresponding intent is realized through automated responses that correspond to user intents. These automated responses can be bound to an API address, and the corresponding automated response is executed by accessing the bound API address. Accessing the API address requires input parameters, including named entities required for accessing the API address. The categories of the input parameters for accessing the API address can be predefined.
[0057] Therefore, after obtaining the corresponding user intent based on the matching regular expression, the corresponding API address for executing automated responses is obtained based on the user intent, the category of the named entity to be extracted is obtained based on the API address, and then the named entity of the corresponding category is extracted based on the matching regular expression.
[0058] After correcting the data content of the named entity to at least one string that has the highest similarity to the current data content, that is, after accurately matching the named entity sample, the named entity sample is used as the input parameter of the API address to request the execution of the automatic response corresponding to the API address, thus realizing the automatic response of the corresponding instant messaging message.
[0059] Based on intent categories, corresponding Action classes and Action methods can be developed. The Action method executes the automated response, and the Action class defines the Action method. Configuration plugins can be developed to allow calling Action methods by instantiating configuration classes.
[0060] The present invention provides an intent recognition and named entity extraction method based on instant messaging messages. By obtaining the corresponding API address for executing automated responses according to user intent, and obtaining the category of the named entity to be extracted according to the API address, the method achieves the determination of the category of the named entity to be extracted. By using the named entity as the input parameter of the requested API address, the method requests the execution of the automated response corresponding to the API address, thereby achieving the automated response of the corresponding instant messaging message.
[0061] According to the present invention, an intent recognition and named entity extraction method based on instant messaging messages is provided, wherein the regular expressions in the regular expression set are stored in a database table in text style; the step of matching the text in the regular expression corpus to obtain the matching regular expression includes: using the regular expression retrieval function of the database to match the text in the regular expression corpus to obtain the matching regular expression.
[0062] By configuring regular expression retrieval, the extracted regularization rules are stored in a data table, and the database's regular expression retrieval function is used to perform regularized retrieval of instant messaging messages.
[0063] We collect and summarize common user queries and commands, abstract the core structure of these queries, categorize them, and construct a regular expression corpus based on this categorization. The regular expressions from this corpus are then stored as text in a database table, such as a MySQL table. When matching the text corresponding to instant messaging messages against the regular expression corpus, the RLIKE syntax is used (in MySQL, the RLIKE operator is used to determine whether a string matches a regular expression).
[0064] The present invention provides an intent recognition and named entity extraction method based on instant messaging messages. By storing regular expressions in a database table in text style from a set of regular expressions, and using the database's regular expression retrieval function to match the text in a regular expression corpus to obtain the matching regular expressions, the speed of regular expression matching is improved, thereby improving the speed of intent recognition.
[0065] According to the present invention, an intent recognition and named entity extraction method based on instant messaging messages is provided. The step of extracting named entities of at least one category based on the matching regular expression includes: extracting named entities of at least one category based on the positions of pre-labeled named entities of different categories in the regular expression.
[0066] It is possible to label the position of different categories of named entities in regular expressions in a regular expression corpus, thereby extracting the corresponding categories of named entities based on the labeling of regular expressions.
[0067] For example, the process of building a regular expression corpus can be as follows:
[0068] 1) Determine the intent category;
[0069] 2) Construct a daily language corpus based on intent categories and everyday Chinese usage;
[0070] 3) Extract a regular expression corpus based on the everyday language corpus;
[0071] 4) Based on the regular expression rules, determine the location information of the named entities to be extracted from the regular expressions in the regular expression corpus.
[0072] The present invention provides an intent recognition and named entity extraction method based on instant messaging messages, which improves the extraction speed of named entities by extracting at least one category of named entities based on the position of pre-labeled different categories of named entities in regular expressions.
[0073] According to the present invention, an intent recognition and named entity extraction method based on instant messaging messages is provided. The step of correcting the data content of the named entity to the string with the highest similarity to the current data content among the at least one strings includes: obtaining a preset number of strings with the highest ranking by calculating the TF-IDF score of the at least one string; calculating the similarity between the named entity and the preset number of strings; and correcting the data content of the named entity to the string with the highest similarity to the current data content among the at least one string.
[0074] If the number of strings obtained through secondary search of the trie is large, it will be time-consuming and computationally expensive to perform similarity matching on the named entities extracted from the instant messaging messages and the obtained strings one by one.
[0075] TF-IDF (term frequency–inverse document frequency) is a commonly used weighting technique in information retrieval and data mining. TF stands for Term Frequency, and IDF stands for Inverse Document Frequency. TF-IDF is a statistical method used to evaluate the importance of a word to a document within a document set or corpus. The importance of a word increases proportionally to the number of times it appears in a document, but decreases inversely proportionally to its frequency in the corpus.
[0076] When there are a large number of strings obtained by secondary retrieval of a trie, the importance of each string can be evaluated by calculating the TF-IDF score of at least one string, and the string with the highest TF-IDF score can be extracted for matching. This ensures the accuracy of the matching results while saving computation time and resources.
[0077] Therefore, when correcting the data content of a named entity to at least one string that has the highest similarity to the current data content, a predetermined number of strings are obtained by calculating the TF-IDF score of at least one string. The similarity between the named entity and the predetermined number of strings is then calculated, and the data content of the named entity is corrected to at least one string that has the highest similarity to the current data content. Edit distance can be used to calculate the similarity between the named entity and the predetermined number of strings.
[0078] The present invention provides an intent recognition and named entity extraction method based on instant messaging messages. It obtains a preset number of strings by calculating the TF-IDF score of at least one string, calculates the similarity between the named entity and the preset number of strings, and corrects the data content of the named entity to the string with the highest similarity to the current data content among at least one string. This method improves the extraction speed while ensuring the accuracy of named entity extraction.
[0079] According to the method for intent recognition and named entity extraction based on instant messaging messages provided by the present invention, the step of matching the text in a regular expression corpus to obtain the matching regular expression includes: matching the text in a regular expression corpus corresponding to a scenario, and obtaining the matching regular expression according to the priority of the scenario.
[0080] When applying the intent recognition and named entity extraction method based on instant messaging messages provided by this invention for automatic response, different application scenarios can be set up. For example:
[0081] Scenario 1: Query the timeliness of a task based on its task ID or name, and provide the queryer with operational suggestions.
[0082] Example:
[0083] Could you please check how task 12345 is running?
[0084] I'd like to know if tasks 12345 will be delayed today?
[0085] What time is the expected output for Tasks 1, 2, 3, 4, and 5 today?
[0086] What time does the task stg_xxxx_da typically produce?
[0087] Scenario 2: Query the reason for indicator fluctuations based on indicator ID or indicator name.
[0088] Example:
[0089] Why did the indicator 12345 rise by 30% today?
[0090] Are the values for indicators 1, 2, 3, 4, and 5 normal today?
[0091] Indicator xxx, what is the expected trend tomorrow?
[0092] Scenario 3: Query the timeliness of a custom task combination.
[0093] Example:
[0094] Will the group's daily report be produced normally today?
[0095] How did the tasks go overall today?
[0096] Is the core task running normally?
[0097] Scenario 4: Add / modify / delete monitoring alarms according to user instructions.
[0098] Example:
[0099] Please add a timely alarm for task 12345.
[0100] If indicator xxx fluctuates by more than 10%, send an alert to me and A.
[0101] All recipients of my alerts have been deleted.
[0102] Sometimes, the same sentence can convey different intentions due to differences in tone or individual words. Scene segmentation, besides corresponding to different application scenarios, can also reflect the different intentions conveyed by similar statements. Therefore, different regular expression corpora can be set up for different scenarios. When matching the text corresponding to instant messaging messages in the regular expression corpus, matching is performed in the corresponding regular expression corpus according to the different scenarios.
[0103] When matching the text of an instant messaging message against a corpus of regular expressions corresponding to different scenarios, multiple scenarios' regular expressions may be matched, and these multiple scenarios' regular expressions may correspond to different intentions. By setting priorities for scenarios, the matching regular expression is determined based on the priority of the scenario. Among the multiple matching regular expressions, the priority of the scenario is compared, and the regular expression of the scenario with the highest priority is used as the final matching regular expression.
[0104] The present invention provides an intent recognition and named entity extraction method based on instant messaging messages. By matching text in a regular expression corpus corresponding to a scene and obtaining the matching regular expression according to the priority of the scene, intent recognition can be performed according to different scenes, thus improving flexibility.
[0105] Figure 3This is the second flowchart of the intent recognition and named entity extraction method based on instant messaging messages provided by this invention. Figure 3 As shown, taking the WeChat Work application as an example, the process of the intent recognition and named entity extraction method based on instant messaging messages provided by this invention is further illustrated. The process includes the following steps:
[0106] Users send instant messaging (IM) messages through the WeChat Work client. The system retrieves the corresponding text of the IM message by calling the WeChat Work API service and writes it to a Kafka queue. The consuming process then retrieves the text from the queue and matches it against regular expressions in a regular expression (RE) corpus. Based on the matched regular expression, intent recognition is performed, and an Action route is determined. The Action route can be the API address corresponding to the identified intent for executing the automated response. The category of the named entities to be extracted is obtained based on the Action route, and named entities of the corresponding category are extracted using regular expressions (NER extraction). The extracted regular expressions are further searched in a Trie model to obtain matching strings. The similarity between the extracted named entities and the matching strings is calculated, and the data content of the named entities is corrected to the string with the highest similarity to the current data content (NER selection). The corrected named entities are used as input parameters to request the aforementioned API address, executing the corresponding automated response (Action method execution).
[0107] The method for intent recognition and named entity extraction based on instant messaging messages provided by this invention can accurately identify the intent of a user's instant messaging messages and extract named entities, and perform accurate information search or system operation based on the user's intent.
[0108] The following describes the intent recognition and named entity extraction device based on instant messaging messages provided by the present invention. The intent recognition and named entity extraction device based on instant messaging messages described below can be referred to in correspondence with the intent recognition and named entity extraction method based on instant messaging messages described above.
[0109] Figure 4 This is a schematic diagram of the device for intent recognition and named entity extraction based on instant messaging messages provided by the present invention. Figure 4As shown, the device includes a text acquisition module 10, a regular expression matching module 20, an intent recognition module 30, a named entity extraction module 40, a trie secondary matching module 50, and a named entity correction module 60. The text acquisition module 10 is used to acquire the text corresponding to the instant messaging message. The regular expression matching module 20 is used to match the text in a regular expression corpus to obtain the matching regular expression. The regular expression corpus includes a set of regular expressions obtained by regularizing instant messaging message samples, and the regular expressions in the set delineate user intents. The intent recognition module 30... The identification module 30 is used to: obtain the corresponding user intent based on the matching regular expression; the named entity extraction module 40 is used to: extract named entities of at least one category based on the matching regular expression; the trie secondary matching module 50 is used to: perform secondary retrieval and matching on the named entities using a trie pre-built based on the named entity samples, and obtain at least one string in the trie in which the characters of the named entities appear in the original order; the named entity correction module 60 is used to: correct the data content of the named entity to the string among the at least one strings that has the highest similarity to the current data content.
[0110] The present invention provides an intent recognition and named entity extraction device based on instant messaging messages. This device obtains the corresponding regular expression by matching the text of the instant messaging message with a regular expression corpus. Based on the matched regular expression, it obtains the user intent and at least one category of named entities. It then uses a trie to perform a secondary search and matching on the named entities, obtaining at least one string in the trie in which the characters of the named entities appear in their original order. Finally, through similarity matching, it corrects the data content of the named entities to the string with the highest similarity to the current data content among at least one string, thus achieving fast and accurate extraction of user intent and named entities.
[0111] According to the present invention, an intent recognition and named entity extraction device based on instant messaging messages is provided. The device further includes a named entity category acquisition module and an automated response execution module. The named entity category acquisition module is used to: obtain the corresponding API address for executing the automated response based on the user intent, and obtain the category of the named entity to be extracted based on the API address, before the named entity extraction module 40 extracts named entities of at least one category according to the matching regular expression; the automated response execution module is used to: use the named entity as the input parameter for requesting the API address, and request the execution of the automated response corresponding to the API address, after the named entity correction module 60 corrects the data content of the named entity to the string with the highest similarity to the current data content among the at least one strings, after the named entity correction module 60 corrects the data content of the named entity to the string with the highest similarity among the at least one strings.
[0112] The present invention provides an intent recognition and named entity extraction device based on instant messaging messages. By obtaining the corresponding API address for executing automated responses according to user intent, and obtaining the category of the named entity to be extracted according to the API address, the device achieves the determination of the category of the named entity to be extracted. By using the named entity as the input parameter of the requested API address, the device requests the execution of the automated response corresponding to the API address, thereby achieving the automated response of the corresponding instant messaging message.
[0113] According to the present invention, an intent recognition and named entity extraction device based on instant messaging messages is provided. The regular expressions in the regular expression set are stored in a database table in text style. When the regular expression matching module 20 is used to match the text in the regular expression corpus and obtain the matching regular expression, it is specifically used to: use the regular expression retrieval function of the database to match the text in the regular expression corpus and obtain the matching regular expression.
[0114] The present invention provides an intent recognition and named entity extraction device based on instant messaging messages. By storing regular expressions in a database table in text style from a set of regular expressions, the device uses the regular expression retrieval function of the database to match the text in the regular expression corpus and obtain the matching regular expressions, thereby improving the speed of regular expression matching and thus improving the speed of intent recognition.
[0115] According to the present invention, an intent recognition and named entity extraction device based on instant messaging messages is provided. The named entity extraction module 40 is specifically used to extract named entities of at least one category based on the position of pre-labeled named entities of different categories in the regular expression.
[0116] The present invention provides an intent recognition and named entity extraction device based on instant messaging messages, which improves the extraction speed of named entities by extracting named entities of at least one category based on the position of pre-labeled named entities of different categories in regular expressions.
[0117] According to the present invention, an intent recognition and named entity extraction device based on instant messaging messages is provided. The named entity correction module 60 is specifically used to: obtain a preset number of strings with the highest sorting order by calculating the TF-IDF score of the at least one string; calculate the similarity between the named entity and the preset number of strings, and correct the data content of the named entity to the string with the highest similarity to the current data content among the at least one string.
[0118] The present invention provides an intent recognition and named entity extraction device based on instant messaging messages. It obtains a preset number of strings with the highest TF-IDF score by calculating the TF-IDF score of at least one string, calculates the similarity between the named entity and the preset number of strings, and corrects the data content of the named entity to the string with the highest similarity to the current data content among at least one string. This improves the extraction speed while ensuring the accuracy of named entity extraction.
[0119] According to the present invention, an intent recognition and named entity extraction device based on instant messaging messages is provided. The regular expression matching module 20 is specifically used to: match the text in a regular expression corpus corresponding to the scene, and obtain the matching regular expression according to the priority of the scene.
[0120] The present invention provides an intent recognition and named entity extraction device based on instant messaging messages. By matching text in a corpus of regular expressions corresponding to a scene and obtaining the matching regular expressions according to the priority of the scene, intent recognition can be performed according to different scenes, thus improving flexibility.
[0121] Figure 5 This is a schematic diagram of the structure of the electronic device provided by the present invention, such as... Figure 5 As shown, the electronic device may include: a processor 510, a communication interface 520, a memory 530, and a communication bus 540, wherein the processor 510, the communication interface 520, and the memory 530 communicate with each other through the communication bus 540. The processor 510 can call logical instructions in the memory 530 to execute an intent recognition and named entity extraction method based on instant messaging messages. This method includes: acquiring the text corresponding to the instant messaging message; matching the text in a regular expression corpus to obtain matching regular expressions; wherein the regular expression corpus includes a set of regular expressions obtained by regularizing instant messaging message samples, and the regular expressions in the set of regular expressions classify user intents; acquiring the corresponding user intent based on the matching regular expressions; extracting named entities of at least one category based on the matching regular expressions; performing a secondary search and matching on the named entities using a pre-built trie based on named entity samples to obtain at least one string in the trie where the characters of the named entities appear in their original order; and correcting the data content of the named entities to the string among the at least one strings that has the highest similarity to the current data content.
[0122] Furthermore, the logical instructions in the aforementioned memory 530 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, essentially, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0123] On the other hand, the present invention also provides a computer program product, which includes a computer program that can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the intent recognition and named entity extraction method based on instant messaging messages provided by the above methods. The method includes: obtaining the text corresponding to the instant messaging message; matching the text in a regular expression corpus to obtain matching regular expressions; wherein the regular expression corpus includes a set of regular expressions obtained by regularizing instant messaging message samples, and the regular expressions in the set of regular expressions classify user intents; obtaining the corresponding user intent according to the matching regular expressions; extracting named entities of at least one category according to the matching regular expressions; performing a secondary search and matching on the named entities using a trie pre-built based on the named entity samples to obtain at least one string in the trie in which the characters of the named entities appear in the original order; and correcting the data content of the named entities to the string with the highest similarity to the current data content among the at least one strings.
[0124] In another aspect, the present invention also provides a non-transitory computer-readable storage medium storing a computer program thereon. When executed by a processor, the computer program implements the intent recognition and named entity extraction method based on instant messaging messages provided by the above methods. The method includes: obtaining the text corresponding to the instant messaging message; matching the text in a regular expression corpus to obtain matching regular expressions; wherein the regular expression corpus includes a set of regular expressions obtained by regularizing instant messaging message samples, and the regular expressions in the set of regular expressions classify user intents; obtaining the corresponding user intent according to the matching regular expressions; extracting named entities of at least one category according to the matching regular expressions; performing a secondary search and matching on the named entities using a trie pre-built based on named entity samples to obtain at least one string in the trie in which the characters of the named entities appear in their original order; and correcting the data content of the named entities to the string among the at least one strings that has the highest similarity to the current data content.
[0125] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.
[0126] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.
[0127] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for intent recognition and named entity extraction based on instant messaging messages, characterized in that, include: Get the text corresponding to the instant messaging message; The text is matched in a regular expression corpus to obtain matching regular expressions; wherein, the regular expression corpus includes a set of regular expressions obtained by regularizing instant messaging message samples, and the regular expressions in the set of regular expressions delineate user intent. The corresponding user intent is obtained based on the matched regular expression; Extract named entities of at least one category based on the matched regular expression; The named entities are subjected to a secondary search and matching using a pre-built trie based on the named entity samples to obtain at least one string in the trie in which the characters of the named entities appear in their original order. The trie includes strings corresponding to multiple named entity samples, and at least one string in the matched trie corresponds to at least one named entity sample. The named entity sample includes the characters extracted from the named entities, and the characters in the named entities appear in the named entity sample in their original order in the named entities, but other characters are allowed to appear between characters in the named entities. The data content of the named entity is corrected to the string among the at least one strings that has the highest similarity to the current data content; The step of correcting the data content of the named entity to the string among the at least one strings that has the highest similarity to the current data content includes: The first preset number of strings are obtained by calculating the TF-IDF score of the at least one string; Calculate the similarity between the named entity and the preset number of strings, and correct the data content of the named entity to the string with the highest similarity to the current data content among the at least one strings; The regular expressions in the set of regular expressions are stored in a database table in text format; The step of matching the text in a regular expression corpus to obtain the matching regular expression includes: using the regular expression retrieval function of the database to match the text in the regular expression corpus to obtain the matching regular expression.
2. The method for intent recognition and named entity extraction based on instant messaging messages according to claim 1, characterized in that, After obtaining the corresponding user intent based on the matched regular expression and before extracting at least one category of named entities based on the matched regular expression, the method further includes: obtaining the corresponding API address for executing automated responses based on the user intent; and obtaining the category of the named entities to be extracted based on the API address. After correcting the data content of the named entity to the string with the highest similarity to the current data content among the at least one strings, the method further includes: using the named entity as an input parameter to request the API address, and requesting the execution of the automated response corresponding to the API address.
3. The method for intent recognition and named entity extraction based on instant messaging messages according to claim 1, characterized in that, The step of extracting named entities of at least one category based on the matched regular expression includes: Extract named entities of at least one category based on their positions in the regular expression according to pre-labeled different categories of named entities.
4. The method for intent recognition and named entity extraction based on instant messaging messages according to claim 1, characterized in that, The step of matching the text in a regular expression corpus to obtain the matching regular expression includes: The text is matched against a corpus of regular expressions corresponding to the scene, and the matching regular expression is obtained according to the priority of the scene.
5. An intent recognition and named entity extraction device based on instant messaging messages, characterized in that, include: The text acquisition module is used to: acquire the text corresponding to instant messaging messages; The regular expression matching module is used to: match the text in a regular expression corpus and obtain the matching regular expression; wherein, the regular expression corpus includes a set of regular expressions obtained by regularizing instant messaging message samples, and the regular expressions in the set of regular expressions delineate user intent. The intent recognition module is used to: obtain the corresponding user intent based on the matched regular expression; The named entity extraction module is used to: extract named entities of at least one category based on the matched regular expression; The trie secondary matching module is used to: perform secondary retrieval and matching on the named entities using a trie pre-built based on the named entity samples, and obtain at least one string in the trie where the characters in the named entities appear in their original order; wherein, the trie includes strings corresponding to multiple named entity samples, at least one string in the matched trie corresponds to at least one named entity sample, the named entity sample includes the characters extracted from the named entities, and the characters in the named entities appear in the named entity sample in their original order in the named entities, but other characters are allowed to appear between characters in the named entities; The named entity correction module is used to: correct the data content of the named entity to the string among the at least one strings that has the highest similarity to the current data content; The named entity correction module is used to: obtain a preset number of strings that rank first by calculating the TF-IDF score of the at least one string; calculate the similarity between the named entity and the preset number of strings, and correct the data content of the named entity to the string among the at least one strings that has the highest similarity to the current data content; The regular expressions in the set of regular expressions are stored in a database table in text format; the regular expression matching module is used to: use the regular expression retrieval function of the database to match the text in the regular expression corpus and obtain the matching regular expression.
6. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the steps of the intent recognition and named entity extraction method based on instant messaging messages as described in any one of claims 1 to 4.
7. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the intent recognition and named entity extraction method based on instant messaging messages as described in any one of claims 1 to 4.
8. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the intent recognition and named entity extraction method based on instant messaging messages as described in any one of claims 1 to 4.