Text matching method, device, electronic device and storage medium

By constructing a dictionary tree and a preset index table for keywords, combined with a dictionary tree and an index table formed by matching conditions, the problem of insufficient time and flexibility in massive keyword matching is solved, and efficient text matching is achieved.

CN115004173BActive Publication Date: 2024-12-17SHENZHEN HEYTAP TECHNOLOGY CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202080094722.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-04-14
Publication Date
2024-12-17
Estimated Expiration
2040-04-14

AI Technical Summary

Technical Problem

In the field of natural language processing, in the massive keyword matching tasks, the existing technology is difficult to ensure low time-consuming and flexibility at the same time. Regular expression matching takes time, while dictionary tree matching is low and only suitable for single word matching, and cannot be processed Multiple word combination.

Method used

By constructing a dictionary tree and a preset index table for keywords, after matching the keywords, add them to the temporary index table, determine whether the text to be matched meets the matching conditions based on the temporary index table, and match it with the dictionary tree and the index table formed by the matching conditions. .

Benefits of technology

This reduces the complexity of text matching, improves matching efficiency, avoids the process of individual matching of each keyword combination, and significantly improves the speed of matching massive keywords.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115004173B_ABST
    Figure CN115004173B_ABST
Patent Text Reader

Abstract

A text matching method, device, electronic device and storage medium, the text matching method comprising: obtaining a text to be matched (S110); matching the keywords in the text to be matched according to a pre-established keyword dictionary tree (S120); when matching the keywords in the text to be matched, querying the target position of the matched keywords in a preset index table, the preset index table comprising at least one index corresponding to a matching condition, the matching condition comprising one or more keywords (S130); adding the matched keywords to the target position in a temporary index table, the temporary index table being a blank index table having the same structure as the preset index table (S140); and determining whether the text to be matched meets the matching condition according to the keywords added in the temporary index table (S150).
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of text processing technology, and more specifically, to a text matching method, device, electronic device and storage medium. Background Art

[0002] Natural language processing is an important research direction in the fields of computer science and artificial intelligence. In the field of natural language processing, keyword matching is applied in various aspects, such as content review, intelligent customer service, etc. In the keyword matching process, the matching efficiency of massive keywords needs to be guaranteed to meet user needs. Summary of the invention

[0003] In view of the above problems, the present application proposes a text matching method, device, electronic device and storage medium.

[0004] In the first aspect, an embodiment of the present application provides a text matching method, which includes: obtaining a text to be matched; matching keywords in the text to be matched according to a pre-established keyword dictionary tree; when matching keywords in the text to be matched, querying the target position of the matched keywords in a preset index table, the preset index table including at least one index corresponding to a matching condition, and the matching condition including one or more keywords; adding the matched keywords to the target position in a temporary index table, the temporary index table being a blank index table with the same structure as the preset index table; determining whether the text to be matched meets the matching condition based on the keywords added in the temporary index table.

[0005] In the second aspect, an embodiment of the present application provides a text matching device, which includes: a text acquisition module, a keyword matching module, a position query module, a keyword adding module and a condition determination module, wherein the text acquisition module is used to acquire the text to be matched; the keyword matching module is used to match the keywords in the text to be matched according to a pre-established keyword dictionary tree; the position query module is used to query the target position of the matched keywords in a preset index table when matching the keywords in the text to be matched, and the preset index table includes at least one index corresponding to a matching condition, and the matching condition includes one or more keywords; the keyword adding module is used to add the matched keywords to the target position in a temporary index table, and the temporary index table is a blank index table with the same structure as the preset index table; the condition determination module is used to determine whether the text to be matched meets the matching condition based on the keywords added in the temporary index table.

[0006] In a third aspect, an embodiment of the present application provides an electronic device, comprising: one or more processors; a memory; one or more applications, wherein the one or more applications are stored in the memory and configured to be executed by the one or more processors, and the one or more programs are configured to execute the text matching method provided in the first aspect above.

[0007] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, in which a program code is stored. The program code can be called by a processor to execute the text matching method provided in the first aspect above.

[0008] The solution provided by the present application obtains the text to be matched, matches the keywords in the text to be matched according to a pre-established dictionary tree of keywords, and when the keywords in the text to be matched are matched, queries the target position of the matched keywords in a preset index table, the preset index table includes at least one index corresponding to a matching condition, the matching condition includes one or more keywords, and then adds the matched keywords to the target position in a temporary index table, the temporary index table is a blank index table with the same structure as the preset index table, and then determines whether the text to be matched meets the matching conditions based on the keywords added in the temporary index table, thereby realizing the combination of the dictionary tree of keywords and the index table formed by the matching conditions, matching the text to be matched to determine whether the text to be matched meets the matching conditions, reducing the complexity of text matching, and thus improving the efficiency of text matching. BRIEF DESCRIPTION OF THE DRAWINGS

[0009] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.

[0010] Figure 1 A schematic diagram of a dictionary tree provided in an embodiment of the present application is shown.

[0011] Figure 2 A flow chart of a text matching method according to an embodiment of the present application is shown.

[0012] Figure 3 A schematic diagram of a dictionary tree provided by an embodiment of the present application is shown.

[0013] Figure 4 A schematic diagram of a preset index table provided by an embodiment of the present application is shown.

[0014] Figure 5A schematic diagram of a temporary index table provided by an embodiment of the present application is shown.

[0015] Figure 6 A flow chart of a text matching method according to another embodiment of the present application is shown.

[0016] Figure 7 A state diagram of a temporary index table provided in another embodiment of the present application is shown.

[0017] Figure 8 Another state diagram of a temporary index table provided in another embodiment of the present application is shown.

[0018] Fig. 9 Another state diagram of a temporary index table provided in another embodiment of the present application is shown.

[0019] Fig.10 A flow chart of a text matching method according to yet another embodiment of the present application is shown.

[0020] Fig.11 A schematic diagram of a preset index table provided in yet another embodiment of the present application is shown.

[0021] Fig.12 A time-consuming schematic diagram of a text matching method provided in yet another embodiment of the present application is shown.

[0022] Fig.13 A block diagram of a text matching device according to an embodiment of the present application is shown.

[0023] Fig.14 It is a block diagram of an electronic device according to an embodiment of the present application for executing the text matching method according to an embodiment of the present application.

[0024] Fig.15 It is a storage unit of an embodiment of the present application for storing or carrying program codes for implementing the text matching method according to an embodiment of the present application. DETAILED DESCRIPTION

[0025] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application.

[0026] In the field of Natural Language Processing (NLP), the task of keyword matching is widely used. For example, in the review of illegal content, illegal keywords are matched against comments or articles posted by users to prevent the spread of a large number of illegal texts; in intelligent customer service, keywords are matched against customer's question texts to assist in decision-making scenario questions and answers. With the growth of business, the capacity of the keyword library has expanded rapidly. When the number of keywords exceeds 50,000, it can be called a massive keyword, which means that there is often a need to match a massive number of keywords in the text. In the task of massive keyword matching, it is necessary to ensure both low time consumption and flexibility of keyword matching, which is technically challenging.

[0027] In traditional keyword matching, keywords are usually matched through regular expressions and dictionary trees.

[0028] Among them, regular expressions use a single string to describe and match a series of strings that conform to a certain syntactic rule. Due to the richness of the matching syntax, regular expression matching has great flexibility. When there are a large number of keywords, it is necessary to call the matching syntax of each keyword in a loop. Example description: If there is the following keyword combination: download...game, where "..." represents any character. The matched text: "I plan to download game A", can be matched using the regular syntax: "download\S+game". If the text length of the text to be matched is n, and the number of keywords in the keyword library is m, the time complexity of the regular expression matching the keyword library is: O(m*n), that is, for each keyword combination, the regular expression corresponding to each keyword combination needs to be used to match the text to be matched.

[0029] The dictionary tree is also called the word search tree, Trie tree, which is a tree structure and a variant of the hash tree. The dictionary tree can store keywords as a tree structure, and each node of the tree is a character. For example, the keywords include: apple, application, return and return to China, then the dictionary tree constructed is as follows Figure 1 As shown in the figure, in the algorithm (Trie algorithm) that uses a dictionary tree to match keywords, it is necessary to traverse the text to be matched once. If a string that is exactly the same as that in the dictionary tree is found along the traversal, and the flag bit of the last node is obtained, the keyword is matched. If the length of the text to be matched is n, the time complexity of the dictionary tree matching is O(n), that is, it is necessary to use the dictionary tree to traverse the text to be matched once to complete the matching of keywords in the text to be matched.

[0030] After long-term research, the inventor found that the matching time complexity of the method of matching keywords through regular expressions is O(m*n), which is time-consuming in the scenario of massive keywords. The time complexity of matching keywords through dictionary trees is O(n) regardless of the number of keywords. However, it has low flexibility and is only applicable to single word matching. For example, in the above example, words such as apple and application can only be matched individually, and it is impossible to complete a combination of two or more words (such as apple...application, "..." represents any character). In actual business, its use is limited.

[0031] In view of the above problems, the inventors have proposed a text matching method, device, electronic device and storage medium provided in the embodiments of the present application, which can realize a dictionary tree combining keywords and an index table formed by matching conditions to match the text to be matched, so as to determine whether the text to be matched meets the matching conditions, reduce the complexity of text matching, and thus improve the efficiency of text matching. Among them, the specific text matching method is described in detail in the subsequent embodiments.

[0032] See also Figure 2 , Figure 2 FIG. 1 is a flow chart of a text matching method provided by an embodiment of the present application. In a specific embodiment, the text matching method is applied to Fig.13 The text matching device 400 and the mobile terminal 100 ( Fig.14 ). The following will take a mobile terminal as an example to illustrate the specific process of this embodiment. Of course, it can be understood that the electronic device used in this embodiment can be a server, a PC, a laptop, etc., which is not limited here. Figure 2 The process shown is described in detail, and the text matching method may specifically include the following steps:

[0033] Step S110: Obtain the text to be matched.

[0034] In the embodiment of the present application, the electronic device can obtain text to be matched, that is, text that needs to be determined whether it meets the matching conditions. The text to be processed can be text extracted from web page content, text extracted from chat content, text obtained by voice-to-text conversion, text extracted from text images, etc. The specific text may not be limited.

[0035] In some embodiments, the electronic device can obtain the text to be matched online, and the network obtains the text to be matched from other devices. For example, in the scenario of online content review, the electronic device can be a server, and can receive text content uploaded by other users, and match the text content with keyword matching conditions to complete the content review; for example, in the scenario of intelligent customer service, the question text sent by the user can be matched with keyword matching conditions, and questions and answers can be conducted based on the matching results. Of course, the specific method of obtaining the text to be matched online may not be limited.

[0036] In some implementations, the electronic device may also obtain the text to be matched from a locally stored file, that is, the text to be processed is pre-stored locally in the electronic device. For example, in a scenario where a teacher reviews homework, the teacher may store the homework text to be reviewed in the electronic device, and when the review is needed, the homework text is read out and the keyword is matched to complete the corresponding review work. Of course, the scenario where the electronic device obtains the text to be matched locally may not be limited.

[0037] In some implementations, the text length and the number of characters in the text to be matched may not be limited. For example, the text to be matched may be a paragraph or a sentence.

[0038] Step S120: matching the keywords in the text to be matched according to the pre-established keyword dictionary tree.

[0039] In an embodiment of the present application, a dictionary tree with keywords can be pre-established, and the dictionary tree can be stored in an electronic device. Among them, the keywords can be keywords included in the matching conditions, and the matching conditions can be one or more. Each matching condition can be a single keyword or a combination of multiple keywords. It can be understood that the keyword dictionary tree can include the keywords included in all matching conditions. For example, the matching condition can be "keyword 1"; for another example, the matching condition can be "keyword 1...keyword 2", and "..." is any character. Of course, the above matching conditions are only examples, and the specific number of keywords in the matching conditions may not be limited.

[0040] In some implementations, the keyword dictionary tree may be created by an electronic device and stored locally, so that when the to-be-matched text needs to be processed, the keyword dictionary tree is read locally.

[0041] In other embodiments, the keyword dictionary tree may be created by other devices (such as a server, etc.), and then sent to the electronic device by the other device, which then stores it so that the dictionary tree can be read locally when the matching text needs to be processed.

[0042] In some other embodiments, the electronic device may also obtain the dictionary tree of keywords from other devices (such as a server, etc.) in real time each time it needs to process the matching text, and then cache the obtained dictionary tree for use in the current processing of the matching text.

[0043] For example, see Figure 3 , Figure 3 A schematic diagram of a dictionary tree provided by an embodiment of the present application is shown, where matching conditions include: "court", "court...playing", "national team...captain", "court...captain", and all keywords corresponding to the matching conditions may include: "court", "national team", "captain" and "playing", and therefore, a dictionary tree including "court", "national team", "captain" and "playing" may be established.

[0044] In some implementations, after obtaining the text to be matched, the electronic device can match the keywords in the text to be matched according to the keyword dictionary tree established above. Specifically, the electronic device uses the dictionary tree matching algorithm to traverse the text to be matched using the dictionary tree. If a string that is exactly the same as that in the dictionary tree is found along the traversal, and the flag bit of the last node is obtained, the keyword is matched.

[0045] Step S130: When a keyword in the text to be matched is matched, a target position of the matched keyword in a preset index table is queried, wherein the preset index table includes at least one index corresponding to a matching condition, and the matching condition includes one or more keywords.

[0046] In an embodiment of the present application, a preset index table corresponding to the matching conditions may also be pre-created, wherein the preset index table may include an index corresponding to each matching condition, and each index may include keywords in its corresponding matching condition.

[0047] In some implementations, the index may be a row content or a column content in a preset index table. When the index is a column content in a preset index table, the keywords in a column of the preset index table may constitute a matching condition corresponding to the index corresponding to the column; when the index is a row content in a preset index table, the keywords in a row of the preset index table may constitute a matching condition corresponding to the index corresponding to the row.

[0048] In some embodiments, in addition to the content of the index corresponding to each matching condition, the preset index table may also include other information, for example, the position of the keywords in each index in the preset index table, the number of keywords in each index (i.e., the number of keywords in the matching conditions corresponding to the index), the index identifier of each index, etc.

[0049] For example, see Figure 4 , Figure 4 A schematic diagram of a preset index table provided in an embodiment of the present application is shown, wherein matching conditions include: "court", "court...play ball", "national team...captain...play ball", "court...captain", "court...national team", and the preset index table may include index identifiers. In the preset index table, the index is the row content in the preset index table. The preset index table includes an index identifier for each index, a position identifier for the keywords in each index, and the number of keywords in each index. For example, the matching condition "court...play ball" corresponds to an index identifier of 2 in the preset index table, and the row content includes the keywords "court" and "play ball", and the corresponding number of keywords is 2.

[0050] In some embodiments, the size (rows and columns) of the preset index table can be determined according to the number of matching conditions and the maximum number of keywords in the matching conditions. For example, as in the above example, if the matching conditions include 5, the preset index table includes 5 rows of content, and the maximum number of keywords is 3, then the preset index table includes 3 columns of content.

[0051] In the embodiment of the present application, when the electronic device matches the keyword in the text to be matched, the target position of the matched keyword in the preset index table can be queried according to the preset index table, so as to add the matched keyword to the temporary index table later. For example, in the above example, when the keyword "court" is matched, the preset index table can be queried to find that "court" is located at the first position among index 1, index 2, index 4 and index 5, that is, position identifier 1.

[0052] In some implementations, the electronic device may query the target position of each keyword in the preset index table after querying all keywords in the text to be matched; the electronic device may also query the target position of the keyword in the preset index table each time a keyword is found.

[0053] Step S140: adding the matched keyword to the target position in a temporary index table, where the temporary index table is a blank index table having the same structure as the preset index table.

[0054] In an embodiment of the present application, after the electronic device obtains the target position of the matched keyword in the preset index table through query, it can add the matched keyword to the target position in the temporary index table, so as to determine whether the text to be matched meets the matching condition according to the keyword added in the temporary index table. The temporary index table corresponds to the preset index table, and the temporary index table can be a blank index table with the same structure as the preset index table, wherein the number of rows and columns of the temporary index table and the preset index table can be the same, and other parameter information included in the preset index table can also be the same. For example, refer to Figure 5 , Figure 5 is with Figure 4 The temporary index table corresponding to the preset index table shown has the same structure and includes the same information. The difference from the preset index table is that the position of each keyword in the temporary index table is empty.

[0055] Step S150: Determine whether the text to be matched meets the matching condition according to the keywords added in the temporary index table.

[0056] In an embodiment of the present application, after adding the matched keywords to the temporary index table, the electronic device can determine whether the text to be matched meets the matching condition based on the keywords added in the temporary index table.

[0057] In some implementations, whether the number of keywords in each index (row or column) in the temporary index table is the same as the number of keywords recorded in the index can be used to determine whether the matching condition corresponding to the index is satisfied. In other words, if they are the same, it means that the text to be matched includes the keywords of the index, that is, the matching condition corresponding to the index is satisfied. Of course, it is also possible to directly compare whether the keywords in the index in the temporary index table are the same as the keywords in the preset index table. If they are the same, it also means that the text to be matched includes the keywords of the index, that is, the matching condition corresponding to the index is satisfied.

[0058] After determining whether the matching condition corresponding to the index is satisfied based on the keywords added to each temporary index, the electronic device can obtain the matching condition satisfied by the text to be matched, thereby obtaining the result of matching the matching condition for the text to be matched.

[0059] Through the text matching method provided in the embodiment of the present application, the keywords in the text to be matched are determined through a dictionary tree, and then the matched keywords are added to a temporary index table according to a pre-established preset index table. Then, it is only necessary to determine whether the text to be matched meets the corresponding matching conditions based on the keywords added in the temporary index table. There is no need to use the regular expression corresponding to each keyword combination to match the text to be matched, thereby effectively saving the time of keyword matching and improving the efficiency of keyword matching.

[0060] See also Figure 6 , Figure 6 A flowchart of a text matching method provided by another embodiment of the present application is shown. The method is applied to the above electronic device. Figure 6 The process shown is described in detail, and the text matching method may specifically include the following steps:

[0061] Step S210: Obtain the text to be matched.

[0062] Step S220: matching the keywords in the text to be matched according to the pre-established keyword dictionary tree.

[0063] In the embodiment of the present application, step S210 and step S220 can refer to the contents of the aforementioned embodiment and will not be described again here.

[0064] Step S230: When a keyword in the text to be matched is matched according to the dictionary tree, the target position of the currently matched keyword in the preset index table is queried, and the preset index table includes at least one index corresponding to a matching condition, and the matching condition includes one or more keywords.

[0065] In the embodiment of the present application, the electronic device may also perform a query for the target position of the currently matched keyword in the preset index table each time a keyword is found, so as to add the currently matched keyword to the temporary index table. It is understandable that the target position may be one position or multiple positions, that is, when the keyword is in the index corresponding to multiple matching conditions, the target position is multiple positions, and when the keyword is in the index corresponding to one matching condition, the target position is one position.

[0066] Step S240: adding the matched keyword to the target position in a temporary index table, where the temporary index table is a blank index table having the same structure as the preset index table.

[0067] In an embodiment of the present application, after the electronic device determines the target position of the currently matched keyword in the preset index table, it can add the currently matched keyword to the temporary index table according to the target position.

[0068] Step S250: Determine whether the text to be matched meets the matching condition based on the keywords added to the temporary index table.

[0069] In an embodiment of the present application, after the currently matched keywords are added to the temporary index table, the matching conditions matched by the to-be-matched text can be determined based on the keywords added in the current temporary index table.

[0070] For example, the preset index table is Figure 4 As shown, the temporary index table is Figure 5 As shown in , the text to be matched is "Coach, I want to go to the stadium to watch the national team play", and the first keyword matched is the stadium. Therefore, Figure 7 As shown, after finding that the position of "court" in index identifiers 1, 2, 4 and 5 is 1, it can be added to the first position in the indexes of index identifiers 1, 2, 4 and 5 respectively. At this time, the matching conditions satisfied by the text to be matched can be determined based on the keywords added in the current temporary index table. For example, it can be compared whether the number of current keywords in each index is the same as the total number of keywords recorded in the index. For example, in the above example, the number of keywords in the indexes of the current index identifiers 1, 2, 4 and 5 is 1, 1, 0, 1, 1 respectively. At this time, only the number of keywords in the index corresponding to index identifier 1 is the same as the number of keywords in the index corresponding to index identifier 1 in the preset index table. Therefore, it is currently determined that the text to be matched meets the matching condition corresponding to the index corresponding to index identifier 1, that is, "court".

[0071] Step S260: Repeat the step of matching the keywords in the text to be matched according to the pre-established keyword dictionary tree, to the step of determining whether the text to be matched meets the matching conditions according to the keywords added in the temporary index table, until all existing keywords in the text to be matched are added to the temporary index table, and then determine whether the text to be matched meets the matching conditions according to the keywords added in the temporary index table.

[0072] In the embodiment of the present application, since each time a keyword in the text to be matched is matched, after the keyword is added to the preset index table, it is determined whether the matching condition is met. There may be other keywords in the text to be matched, so the matching of keywords can be continued to be performed, so that the matched keywords are added to the temporary index table, and then the keywords added in the temporary index table are determined to determine whether the text to be matched meets the corresponding matching condition. Thus, the electronic device can repeat steps S230 to S250. After the text to be matched is traversed using the dictionary tree, all keywords are determined, and the last matched keyword is added to the temporary index table, and after determining whether the text to be matched meets the corresponding matching condition based on the keywords added in the temporary index table, the process can be terminated, so that the result of matching the text to be matched with the matching condition can be obtained.

[0073] For example, in the above example, the text to be matched is "coach, I want to go to the stadium to watch the national team play", and the second keyword matched is "national team". Figure 8 As shown, after finding that the position of "national team" in the index of index identifier 3 is 1 and the position of "national team" in the index of index identifier 5 is 2, "national team" can be added to the first position of the index of index identifier 2 and the second position of the index of index identifier 5 respectively. At this time, the matching condition satisfied by the text to be matched can be determined based on the keywords added in the current temporary index table. For example, it can be compared whether the number of current keywords in each index is the same as the total number of keywords in the recorded index. For example, in the above example, the number of keywords in the indexes of the current index identifiers 1, 2, 4 and 5 is 1, 1, 1, 1, 2 respectively. At this time, the number of keywords in the index corresponding to index identifier 1 is the same as the number of keywords in the index corresponding to index identifier 1 in the preset index table. Therefore, it is currently determined that the text to be matched meets the matching condition corresponding to the index corresponding to index identifier 1, that is, "ball court", and the number of keywords in the index corresponding to index identifier 5 is the same as the number of keywords in the index corresponding to index identifier 5 in the preset index table. Therefore, it can also be determined that the text to be matched meets the matching condition corresponding to the index corresponding to index identifier 5, that is, "ball court...national team".

[0074] Similarly, the third keyword matched is "playing ball", so if Fig. 9As shown, after finding that the position of "playing ball" in the index of index identifier 2 is 2 and the position of "playing ball" in the index of index identifier 3 is 3, "playing ball" can be added to the second position in the index of index identifier 3 and the third position in the index of index identifier 3 respectively. At this time, the matching conditions satisfied by the text to be matched can be determined based on the keywords added in the current temporary index table. For example, the number of current keywords in each index can be compared to see whether it is the same as the total number of keywords in the recorded index. In the above example, the number of keywords in the indexes of the current index identifiers 1, 2, 4, and 5 are 1, 2, 2, 1, and 2, respectively. At this time, it can be determined that the number of keywords in the index corresponding to index identifier 1 is the same as the number of keywords in the index corresponding to index identifier 1 in the preset index table, the number of keywords in the index corresponding to index identifier 2 is the same as the number of keywords in the index corresponding to index identifier 2 in the preset index table, and the number of keywords in the index corresponding to index identifier 5 is the same as the number of keywords in the index corresponding to index identifier 5 in the preset index table. Therefore, it is currently determined that the text to be matched satisfies the matching conditions corresponding to the index corresponding to index identifier 1, i.e., "court", satisfies the matching conditions corresponding to the index corresponding to index identifier 2, i.e., "court...playing ball", and satisfies the matching conditions corresponding to the index corresponding to index identifier 5, i.e., "court...national team".

[0075] In some embodiments, the electronic device can also process the index corresponding to the matching condition from the temporary index table each time after determining the matching condition satisfied by the text to be matched, so as to avoid judging the keyword added in the index after adding the next keyword, thereby wasting processing time. Therefore, before repeatedly executing steps S230 to S250, the text matching method can also include: if it is determined that the text to be matched satisfies the matching condition corresponding to the specified index, the specified index in the temporary index table is preset, and the preset processing is used to indicate that the matching condition corresponding to the specified index has been matched. Wherein, the specified index is any index. After the preset processing is performed on the specified index, when the electronic device subsequently processes the next matched keyword, that is, after adding the next keyword, it will no longer judge the keyword added in the index, thereby further saving the time of text matching and improving the efficiency of keyword matching.

[0076] As an implementation mode, the electronic device performs preset processing on the specified index in the temporary index table, which may be to delete the row or column corresponding to the specified index from the temporary index table; as another implementation mode, the electronic device performs preset processing on the specified index in the temporary index table, which may be to mark the row or column corresponding to the specified index in the temporary index table. Of course, the specific preset processing may not be used as a limitation, and the preset processing only requires that the electronic device will not process the specified index in the temporary index table again when processing the next matched keyword, so as to improve the efficiency of keyword matching.

[0077] In some embodiments, after the electronic device uses the dictionary tree to traverse the text to be matched, all keywords are determined, and the last matched keyword is added to the temporary index table, and after all matching conditions satisfied by the text to be matched are determined based on the keywords added in the temporary index table, all matching conditions satisfied by the text to be matched can also be output so that the user can understand the result of matching the matching conditions of the text to be matched, that is, the result of keyword matching. For example, all the matching conditions that are satisfied can be displayed, or voice playback can be performed, which is not limited here.

[0078] Through the text matching method provided in the embodiment of the present application, the keywords in the text to be matched are determined through a dictionary tree, and then according to the pre-established preset index table, after each keyword is matched, the keyword is added to the temporary index table, and then it is only necessary to determine whether the text to be matched meets the corresponding matching conditions based on the keywords added in the temporary index table, and then repeatedly add the keywords matched each time to the temporary index table, and then determine whether the text to be matched meets the corresponding matching conditions, and finally determine the matching conditions satisfied by the entire text to be matched, without the need to use the regular expression corresponding to each keyword combination to match the text to be matched, thereby effectively saving the time of keyword matching and improving the efficiency of keyword matching.

[0079] See also Fig.10 , Fig.10 A flowchart of a text matching method provided by another embodiment of the present application is shown. The method is applied to the above electronic device. Fig.10 The process shown is described in detail, and the text matching method may specifically include the following steps:

[0080] Step S310: Obtain keywords in each matching condition.

[0081] In an embodiment of the present application, the electronic device can obtain keywords in the matching conditions to pre-build a dictionary tree. There can be multiple matching conditions, and the electronic device can obtain keywords in each matching condition.

[0082] In some implementations, the electronic device may obtain the matching condition from other devices or obtain the matching condition input by the user. When the obtained matching condition is a matching condition that only includes keywords, the electronic device may directly obtain the keywords in the matching condition; when the obtained matching condition is in text form, the electronic device may segment the matching condition and determine the keywords in the matching condition. For example, if the matching condition is: playing ball on the court, the keywords may be determined as "court" and "playing ball".

[0083] Step S320: construct a dictionary tree according to the keywords.

[0084] In an embodiment of the present application, after obtaining the keywords in each matching condition, the electronic device can construct a dictionary tree. Specifically, the electronic device can determine the first node of each branch in the dictionary tree according to the first character of the keyword, and then sequentially connect the other characters in the keyword as nodes to the first node, thereby constructing a dictionary tree of the keyword. After constructing the dictionary tree of the keyword, the electronic device can store the dictionary tree.

[0085] Step S330: Generate an index according to the keywords in each matching condition and add it to the initial index table to obtain the preset index table.

[0086] In an embodiment of the present application, the electronic device may also construct a preset index table in advance according to the keywords in each matching condition.

[0087] In some implementations, the electronic device may add the keywords in each matching condition to a row or a column in the initial index table to obtain a preset index table, wherein the row or column where each matching condition is located is used as the index corresponding to the matching condition. It is understandable that the initial index table may be a blank index table, and the number of rows and columns in the initial table may not be limited, but the minimum requirements required by the matching condition shall be met.

[0088] Furthermore, after adding the keywords in each matching condition to a row or a column in the initial index table, the electronic device may also delete the positions in the initial index table where the keywords do not exist, thereby obtaining a final preset index table. Fig.11 As shown, the rows and columns in the preset index table only include the locations where the keywords exist, thereby making the preset index table concise, which not only saves space but also improves the efficiency of the electronic device in determining whether the to-be-matched text meets the matching conditions based on the keywords added in the temporary index table.

[0089] In some implementations, the electronic device may also record the position of the keywords of each index in the preset index table and the number of keywords of each index, for example, Fig.11 In the preset index table shown, the position identifier of each indexed keyword and the number of keywords are recorded in the preset index table, so that the electronic device can process the matching keywords more quickly when using the preset index table.

[0090] Step S340: Obtain the text to be matched.

[0091] Step S350: matching the keywords in the text to be matched according to the pre-established keyword dictionary tree.

[0092] Step S360: When a keyword in the text to be matched is matched, a target position of the matched keyword in a preset index table is queried, and the preset index table includes at least one index corresponding to a matching condition, and the matching condition includes one or more keywords.

[0093] Step S370: adding the matched keyword to the target position in a temporary index table, where the temporary index table is a blank index table having the same structure as the preset index table.

[0094] Step S380: Determine whether the text to be matched meets the matching condition based on the keywords added to the temporary index table.

[0095] In an embodiment of the present application, the electronic device may query all keywords in the text to be matched, query the target position of each keyword in the preset index table, and then perform steps S370 and S380 to determine the matching condition satisfied by the text to be matched. As described in the previous embodiment, the electronic device may also perform steps S370 and S380 each time a keyword is matched, until the last matched keyword is added to the preset index table, and the matching condition is determined.

[0096] In some implementations, the electronic device determines whether the to-be-matched text satisfies the matching condition according to the keywords added in the temporary index table, which may include:

[0097] The keywords added in each index of the temporary index table are compared with the keywords of the corresponding index in the preset index table; based on the comparison result, it is determined whether the text to be matched meets the matching condition.

[0098] As a method, the electronic device can obtain the number of keywords added in each index of the temporary index table, and then compare the number of keywords added in each index with the number of keywords in the corresponding index in the preset index table; if the number of keywords added in the target index is the same as the number of keywords in the target index in the preset index table, it is determined that the text to be matched meets the matching condition corresponding to the target index, and the target index is any index in the temporary index table. If there is no index in which the number of keywords added is the same as the number of keywords in the same index in the preset index table, it is determined that the text to be matched does not meet any matching condition. It can be understood that since the structure of the temporary index table is the same as that of the preset index table, and the position where each matched keyword is added is the same as the position of the keyword in the preset index table, when the number of keywords added in any index is the same as the number of keywords in the index in the preset index table, it means that the text to be matched includes the keywords of the index, that is, it meets the matching condition corresponding to the index.

[0099] As another way, the electronic device can also compare whether the keywords added in each index are the same as the keywords of the corresponding index in the preset index table; if the keywords added in the target index are the same as the keywords of the target index in the preset index table, it is determined that the text to be matched meets the matching conditions corresponding to the target index, and the target index is any index in the temporary index table. If there is no keyword added in any index that is the same as the keyword of the same index in the preset index table, it is determined that the text to be matched does not meet any matching conditions. It can be understood that if the keywords added in any index are the same as the keywords in the index in the preset index table, it means that the text to be matched includes the keywords of the index, that is, it meets the matching conditions corresponding to the index.

[0100] In some implementations, since the preset index table may not contain positions other than the positions of the keywords in the index, for example, Fig.11 In the preset index table shown, the rows and columns in the preset index table only include positions where keywords exist. Therefore, the electronic device can determine whether there is a vacancy in each index, that is, based on the keywords added in the temporary index table, determine whether there is a vacancy in the row or column corresponding to each index in the temporary index table; if there is no vacancy in the row or column corresponding to the target index, it means that the row or column corresponding to the target index in the temporary index table is filled, so the text to be matched includes the keywords of the target index, so that it can be determined that the text to be matched meets the matching condition corresponding to the target index, and the target index is any index in the temporary index table. By using the vacancy method to determine whether the text to be matched meets the matching condition corresponding to the corresponding index, since it only needs to be determined whether the vacancy is 0, the efficiency of keyword matching of the text can be further improved.

[0101] The following is an example of the improvement in matching efficiency brought about by the text matching method provided in the embodiment of the present application. If the number of combined keywords is m and the length of the text to be matched is n, the time complexity of the regular expression (re) matching the keyword library is still O(m*n), and the time complexity of the text matching method provided in the embodiment of the present application is O(n), but the Trie algorithm cannot directly match combined words, and the time complexity of the co-Trie algorithm is O(n)+O(mp), where p is the average word frequency in the vocabulary. For general scenarios, p is much smaller than m. In theory, the text matching method provided in the embodiment of the present application is less time-consuming than the regular expression matching method and is close to the dictionary tree algorithm. Fig.12 The experimental result diagram of the time-consuming comparison experiment of the text matching method provided by the embodiment of the present application and the regular expression matching method is shown, wherein the string length of the matched text is 200. Fig.12 It can be found that as the number of keywords increases, the time consumption of the text matching method provided in the embodiment of the present application remains basically unchanged, while the time consumption of the regular expression matching method increases with the increase in the number of keywords. In the matching of massive keywords, the time consumption of the text matching method provided in the embodiment of the present application is significantly lower than that of the regular expression matching method.

[0102] See also Fig.13 , which shows a structural block diagram of a text matching device 400 provided in an embodiment of the present application. The text matching device 400 applies the above-mentioned electronic device, and the text matching device 400 includes: a text acquisition module 410, a keyword matching module 420, a position query module 430, a keyword adding module 440 and a condition determination module 450. Among them, the text acquisition module 410 is used to acquire the text to be matched; the keyword matching module 420 is used to match the keywords in the text to be matched according to the pre-established keyword dictionary tree; the position query module 430 is used to query the target position of the matched keyword in the preset index table when matching the keyword in the text to be matched, and the preset index table includes at least one index corresponding to the matching condition, and the matching condition includes one or more keywords; the keyword adding module 440 is used to add the matched keyword to the target position in the temporary index table, and the temporary index table is a blank index table with the same structure as the preset index table; the condition determination module 450 is used to determine whether the text to be matched meets the matching condition according to the keywords added in the temporary index table.

[0103] In some embodiments, the preset index table includes multiple indexes corresponding to the matching conditions. The condition determination module 450 may include: a comparison unit and a first determination unit. The comparison unit is used to compare the keywords added in each index of the temporary index table with the keywords of the corresponding index in the preset index table; the first determination unit is used to determine whether the text to be matched meets the matching condition based on the comparison result.

[0104] As an implementation mode, the comparison unit may include: a quantity acquisition subunit and a quantity comparison subunit. The quantity acquisition subunit is used to acquire the number of keywords added to each index of the temporary index table; the quantity comparison subunit is used to compare the number of keywords added to each index with the number of keywords of the corresponding index in the preset index table.

[0105] In this embodiment, the first determination unit can be specifically used to: if the number of keywords added in the target index is the same as the number of keywords in the target index in the preset index table, then determine that the text to be matched meets the matching condition corresponding to the target index, and the target index is any index in the temporary index table.

[0106] As another implementation, the comparison unit may include: a keyword comparison subunit. The keyword comparison subunit is used to compare whether the keywords added in each index are the same as the keywords of the corresponding index in the preset index table.

[0107] In this embodiment, the first determination unit can be specifically used to: if the keywords added in the target index are the same as the keywords of the target index in the preset index table, then determine that the text to be matched meets the matching conditions corresponding to the target index, and the target index is any index in the temporary index table.

[0108] In other embodiments, the preset index table includes indexes corresponding to multiple matching conditions, and the preset index table and the temporary index table do not contain positions other than the positions of the keywords in the index. The condition determination module 450 may include: a position determination unit and a second determination unit. The position determination unit is used to determine whether there are free positions in the rows or columns corresponding to each index in the temporary index table based on the keywords added to the temporary index table; the second determination unit is used to determine whether the text to be matched meets the matching condition corresponding to the target index if there are no free positions in the rows or columns corresponding to the target index, and the target index is any index in the temporary index table.

[0109] In some implementations, the position query module 430 may be specifically configured to: when a keyword in the text to be matched is matched according to the dictionary tree, query the target position of the currently matched keyword in the preset index table.

[0110] In this embodiment, the text matching device 400 may further include: a repeated execution module. The repeated execution module is used to: repeatedly execute the step of matching the keywords in the text to be matched according to the pre-established keyword dictionary tree, to the step of determining whether the text to be matched meets the matching condition according to the keywords added in the temporary index table, until all the keywords existing in the text to be matched are added to the temporary index table, and then determine whether the text to be matched meets the matching condition according to the keywords added in the temporary index table.

[0111] In this embodiment, the text matching device 400 may further include: an index processing module. The index processing module is used to perform a preset process on the specified index in the temporary index table before the step of repeatedly performing the step of matching the keywords in the text to be matched according to the pre-established keyword dictionary tree to the step of determining whether the text to be matched meets the matching condition according to the keywords added in the temporary index table, if it is determined that the text to be matched meets the matching condition corresponding to the specified index, and the preset process is used to indicate that the matching condition corresponding to the specified index has been matched.

[0112] As a method, the index processing module may be specifically configured to delete the row or column corresponding to the designated index from the temporary index table.

[0113] As another way, the index processing module may also be specifically used to mark the row or column corresponding to the specified index in the temporary index table.

[0114] In some implementations, the position query module 430 may also be specifically configured to: after all the keywords in the to-be-matched text are matched, query the target position of each of all the keywords in the preset index table.

[0115] In some implementations, the text matching device 400 may further include: an output module. The output module is used to output all matching conditions satisfied by the text to be matched after determining whether the text to be matched meets the matching condition according to the keywords added to the temporary index table.

[0116] In some embodiments, the text matching device 400 may further include: a keyword acquisition module and an index generation module. The keyword acquisition module is used to obtain the keywords in each matching condition before searching for the target position of the matched keywords in the preset index table when matching the keywords in the text to be matched; the index generation module is used to generate an index according to the keywords in each matching condition and add it to the initial index table to obtain the preset index table.

[0117] In this embodiment, the index generation module can be specifically used to: add the keywords in each matching condition to a row or a column in the initial index table to obtain the preset index table, wherein the row or column where each matching condition is located serves as the index corresponding to the matching condition.

[0118] Furthermore, the index generation module may also be used to delete positions in the initial index table where no keywords exist.

[0119] In some embodiments, the text matching device 400 may further include an index recording module. The index recording module is used to generate an index according to the keywords in each matching condition and add it to the initial index table, and after obtaining the preset index table, record the position of the keywords of each index in the preset index table and the number of keywords of each index.

[0120] In some embodiments, the text matching device 400 may further include: a keyword acquisition module and a dictionary tree construction module. The keyword acquisition module is used to match the keywords in the text to be matched according to the dictionary tree of the pre-established keywords, and the dictionary tree construction module is used to construct a dictionary tree according to the keywords.

[0121] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the above-described devices and modules can refer to the corresponding processes in the aforementioned method embodiments, and will not be repeated here.

[0122] In several embodiments provided in the present application, the coupling between modules may be electrical, mechanical or other forms of coupling.

[0123] In addition, each functional module in each embodiment of the present application can be integrated into a processing module, or each module can exist physically separately, or two or more modules can be integrated into one module. The above integrated modules can be implemented in the form of hardware or software functional modules.

[0124] To summarize, the solution provided by the present application obtains the text to be matched, and matches the keywords in the text to be matched according to a pre-established dictionary tree of keywords. When the keywords in the text to be matched are matched, the target position of the matched keywords in the preset index table is queried, and the preset index table includes at least one index corresponding to a matching condition, and the matching condition includes one or more keywords. The matched keywords are then added to the target position in the temporary index table, and the temporary index table is a blank index table with the same structure as the preset index table. Then, based on the keywords added in the temporary index table, it is determined whether the text to be matched meets the matching conditions, thereby realizing the combination of the dictionary tree of keywords and the index table formed by the matching conditions, matching the text to be matched to determine whether the text to be matched meets the matching conditions, reducing the complexity of text matching, and thus improving the efficiency of text matching.

[0125] Please refer to Fig.14 , which shows a structural block diagram of an electronic device provided in an embodiment of the present application. The electronic device 100 can be an electronic device capable of running applications, such as a server, a PC, a laptop, a mobile terminal, etc. The electronic device 100 in the present application may include one or more of the following components: a processor 110, a memory 120, and one or more applications, wherein the one or more applications may be stored in the memory 120 and configured to be executed by one or more processors 110, and the one or more programs are configured to execute the method described in the aforementioned method embodiment.

[0126] The processor 110 may include one or more processing cores. The processor 110 uses various interfaces and lines to connect various parts of the entire electronic device 100, and executes various functions and processes data of the electronic device 100 by running or executing instructions, programs, code sets or instruction sets stored in the memory 120, and calling data stored in the memory 120. Optionally, the processor 110 can be implemented in at least one hardware form of digital signal processing (DSP), field-programmable gate array (FPGA), and programmable logic array (PLA). The processor 110 can integrate one or a combination of a central processing unit (CPU), a graphics processing unit (GPU), and a modem. Among them, the CPU mainly processes the operating system, user interface, and application programs; the GPU is responsible for rendering and drawing display content; and the modem is used to process wireless communications. It can be understood that the above-mentioned modem may not be integrated into the processor 110, but may be implemented separately through a communication chip.

[0127] The memory 120 may include a random access memory (RAM) or a read-only memory (ROM). The memory 120 may be used to store instructions, programs, codes, code sets or instruction sets. The memory 120 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for implementing at least one function (such as a touch function, a sound playback function, an image playback function, etc.), instructions for implementing the following various method embodiments, etc. The data storage area may also store data (such as a phone book, audio and video data, chat record data) created by the electronic device 100 during use.

[0128] Please refer to Fig.15 , which shows a structural block diagram of a computer-readable storage medium provided in an embodiment of the present application. The computer-readable medium 800 stores program codes, which can be called by a processor to execute the method described in the above method embodiment.

[0129] The computer readable storage medium 800 may be an electronic memory such as a flash memory, an EEPROM (electrically erasable programmable read-only memory), an EPROM, a hard disk, or a ROM. Optionally, the computer readable storage medium 800 includes a non-transitory computer-readable storage medium. The computer readable storage medium 800 has storage space for program code 810 that performs any method step in the above method. These program codes can be read from or written to one or more computer program products. The program code 810 can be compressed, for example, in an appropriate form.

[0130] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements 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 application.

Claims

1. A text matching method, It is characterized in that The method comprises: Get the text to be matched; Matching the keywords in the to-be-matched text according to a pre-established keyword dictionary tree; When a keyword in the text to be matched is matched, querying a target position of the matched keyword in a preset index table, wherein the preset index table includes at least one index corresponding to a matching condition, and the matching condition includes one or more keywords; Adding the matched keyword to the target position in a temporary index table, wherein the temporary index table is a blank index table with the same structure as the preset index table, and the preset index table includes indexes corresponding to multiple matching conditions; Based on the keywords added in the temporary index table, determine whether the text to be matched contains any keyword of the index to determine whether the text to be matched meets the matching condition, wherein if the text to be matched contains any keyword of the index, it is determined that the text to be matched meets the matching condition.

2. The method according to claim 1, It is characterized in that The preset index table includes indexes corresponding to a plurality of matching conditions, and determining whether the to-be-matched text contains a keyword of any index according to the keywords added in the temporary index table includes: Compare the keywords added in each index of the temporary index table with the keywords of the corresponding index in the preset index table; According to the comparison result, it is determined whether the text to be matched contains any indexed keyword.

3. The method according to claim 2, It is characterized in that The comparing the keywords added in each index of the temporary index table with the keywords of the corresponding index in the preset index table includes: Obtain the number of keywords added to each index of the temporary index table; Compare the number of keywords added in each index with the number of keywords in the corresponding index in the preset index table; Determining whether the to-be-matched text contains any indexed keyword according to the comparison result includes: If the number of keywords added in the target index is the same as the number of keywords in the target index in the preset index table, it is determined that the text to be matched contains keywords in the target index, and the target index is any index in the temporary index table.

4. The method according to claim 2, It is characterized in that The comparing the keywords added in each index with the keywords of the corresponding index in the preset index table includes: Compare whether the keywords added in each index are the same as the keywords of the corresponding index in the preset index table; Determining whether the to-be-matched text contains any indexed keyword according to the comparison result includes: If the keywords added in the target index are the same as the keywords of the target index in the preset index table, it is determined that the text to be matched contains the keywords of the target index, and the target index is any index in the temporary index table.

5. The method according to claim 1, It is characterized in that The preset index table includes indexes corresponding to a plurality of matching conditions, and the preset index table and the temporary index table do not contain positions other than the positions of the keywords in the indexes, and determining whether the to-be-matched text contains any keyword of any index according to the keywords added in the temporary index table includes: Determine whether there is an empty position in the row or column corresponding to each index in the temporary index table according to the keywords added in the temporary index table; If there is no free position in the row or column corresponding to the target index, it is determined that the to-be-matched text contains a keyword of the target index, where the target index is any index in the temporary index table.

6. The method according to any one of claims 1 to 5, It is characterized in that When a keyword in the to-be-matched text is matched, querying a target position of the matched keyword in a preset index table includes: When a keyword in the to-be-matched text is matched according to the dictionary tree, the target position of the currently matched keyword in the preset index table is queried.

7. The method according to claim 6, It is characterized in that After determining whether the text to be matched contains any indexed keyword according to the keywords added in the temporary index table to determine whether the text to be matched meets the matching condition, the method further includes: Repeat the step of matching the keywords in the text to be matched according to the pre-established keyword dictionary tree, to the step of determining whether the text to be matched contains any indexed keyword according to the keywords added in the temporary index table, so as to determine whether the text to be matched meets the matching condition, until all existing keywords in the text to be matched are added to the temporary index table, and then determine whether the text to be matched contains any indexed keyword according to the keywords added in the temporary index table, so as to determine whether the text to be matched meets the matching condition.

8. The method according to claim 7, It is characterized in that Before the step of repeatedly performing the step of matching the keywords in the text to be matched according to the pre-established keyword dictionary tree to the step of determining whether the text to be matched contains any indexed keyword according to the keywords added in the temporary index table to determine whether the text to be matched meets the matching condition, the method further includes: If it is determined that the text to be matched satisfies the matching condition corresponding to the specified index, a preset process is performed on the specified index in the temporary index table, and the preset process is used to indicate that the matching condition corresponding to the specified index has been matched.

9. The method according to claim 8, It is characterized in that The performing preset processing on the designated index in the temporary index table includes: The row or column corresponding to the specified index is deleted from the temporary index table.

10. The method according to claim 8, It is characterized in that The performing preset processing on the designated index in the temporary index table includes: The row or column corresponding to the specified index is marked in the temporary index table.

11. The method according to any one of claims 1 to 5, It is characterized in that When a keyword in the to-be-matched text is matched, querying a target position of the matched keyword in a preset index table includes: After all the keywords in the to-be-matched text are matched, the target position of each keyword in the preset index table is queried.

12. The method according to any one of claims 1 to 5, It is characterized in that After determining whether the text to be matched contains any indexed keyword according to the keywords added in the temporary index table to determine whether the text to be matched meets the matching condition, the method further includes: Output all matching conditions satisfied by the text to be matched.

13. The method according to any one of claims 1 to 5, It is characterized in that When a keyword in the to-be-matched text is matched, searching for the matched keyword before the target position in the preset index table, the method further includes: Get the keywords in each matching condition; According to the keywords in each matching condition, an index is generated and added to the initial index table to obtain the preset index table.

14. The method according to claim 13, It is characterized in that The step of generating an index according to the keywords in each matching condition and adding the index to the initial index table to obtain the preset index table includes: The keywords in each matching condition are added to a row or a column in the initial index table to obtain the preset index table, wherein the row or column where each matching condition is located is used as the index corresponding to the matching condition.

15. The method according to claim 14, It is characterized in that After adding the keywords in each matching condition to a row or a column in the initial index table, the method further includes: The positions in the initial index table where no keywords exist are deleted.

16. The method according to claim 13, It is characterized in that After generating an index according to the keywords in each matching condition and adding it to the initial index table to obtain the preset index table, the method further includes: The position of the keywords of each index in the preset index table and the number of keywords of each index are recorded.

17. The method according to any one of claims 1 to 5, It is characterized in that Before matching the keywords in the to-be-matched text according to the pre-established keyword dictionary tree, the method further includes: Get the keywords in each matching condition; According to the keywords, a dictionary tree is constructed.

18. A text matching device, It is characterized in that The device comprises: a text acquisition module, a keyword matching module, a location query module, a keyword adding module and a condition determination module, wherein: The text acquisition module is used to acquire the text to be matched; The keyword matching module is used to match the keywords in the to-be-matched text according to a pre-established keyword dictionary tree; The position query module is used for querying the target position of the matched keyword in the preset index table when matching the keyword in the to-be-matched text, wherein the preset index table includes at least one index corresponding to a matching condition, and the matching condition includes one or more keywords; The keyword adding module is used to add the matched keyword to the target position in the temporary index table, the temporary index table is a blank index table with the same structure as the preset index table, and the preset index table includes indexes corresponding to multiple matching conditions; The condition determination module is used to determine whether the text to be matched contains any indexed keyword based on the keywords added in the temporary index table, so as to determine whether the text to be matched meets the matching condition, wherein if the text to be matched contains any indexed keyword, it is determined that the text to be matched meets the matching condition.

19. An electronic device, It is characterized in that include: one or more processors; Memory; One or more application programs, wherein the one or more application programs are stored in the memory and configured to be executed by the one or more processors, and the one or more programs are configured to execute the method according to any one of claims 1-17.

20. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores program code, and the program code can be called by a processor to execute the method according to any one of claims 1 to 17.