Text matching method and device, equipment and medium

By segmenting and matching text using a pre-defined root word library and index library, the problem of low efficiency in existing technologies is solved, and fast and efficient text matching is achieved.

CN121935360APending Publication Date: 2026-04-28CHINA UNITED NETWORK COMM GRP CO LTD +2
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
CHINA UNITED NETWORK COMM GRP CO LTD
Filing Date
2025-12-31
Publication Date
2026-04-28

AI Technical Summary

Technical Problem

Existing technologies have low efficiency in data analysis and modeling, especially in ultra-large-scale problem template libraries where computation time is enormous and new vocabulary cannot be effectively handled.

Method used

The target word combination is obtained by segmenting the text to be matched using word roots from a preset word root library. A candidate text library is obtained using a preset word root index library. Through data analysis, the number of texts to be matched obtained from the preset word root index library is less than that from the preset text library, thus improving matching efficiency.

Benefits of technology

It enables fast text matching in ultra-large-scale text databases, reduces computation time, improves matching efficiency, and effectively handles new vocabulary.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121935360A_ABST
    Figure CN121935360A_ABST
Patent Text Reader

Abstract

The invention provides a text matching method and device, equipment and a medium. Relates to the technical field of data analysis, and the method comprises the steps: obtaining a to-be-matched text, cutting the to-be-matched text according to a preset root in a preset root library, obtaining a target root combination of the to-be-matched text, and aiming at each root in the target root combination, according to the text index information of the roots in a preset root index library, obtaining the to-be-matched text. And finally, according to the text index information of each word root in the target word root combination, obtaining a matching result of the to-be-matched text from the alternative text library. Through the embodiment of the invention, the obtained matching result is the preset text with more roots in the target root combination in the preset text library, so that the text matching efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of data analysis technology, and in particular to a text matching method, apparatus, device and medium. Background Technology

[0002] Data modeling refers to the abstract organization of various types of data in the real world. Through data analysis, we can better understand the essence of a problem and thus build a more accurate mathematical model.

[0003] In existing technologies, data analysis and modeling requirements are formed into word vectors according to the word order. Then, by comparing each word vector with the word vector of the question template, the question template with the smallest angle between the vectors is selected as the best matching result.

[0004] However, existing technologies require calculating the angle between vectors one by one, which means that for ultra-large-scale problem template libraries, existing technologies require a huge amount of computing time to complete the global matching work, resulting in low efficiency. Summary of the Invention

[0005] This application provides a text matching method, apparatus, device, and medium to solve the problem of low efficiency in the prior art.

[0006] Firstly, this application provides a text matching method, including:

[0007] Get the text to be matched;

[0008] The text to be matched is segmented according to the preset word roots in the preset word root library to obtain the target word root combination of the text to be matched. The word roots in the target word root combination do not overlap.

[0009] For each root word in the target root word combination, a candidate text library for the text to be matched is obtained based on the text index information of the root word in the preset root word index library. The text index information is the index information of the preset texts containing the root word in the preset text library. The number of texts in the candidate text library is less than the number of texts in the preset text library.

[0010] Based on the text index information of each word root in the target word root combination, the matching results of the text to be matched are obtained from the candidate text library.

[0011] In this application, based on the text index information of each word root in the target word root combination, the matching results of the text to be matched are obtained from the candidate text library, including:

[0012] Based on the text index information of each word root in the target word root combination, count the number of texts for each preset text in the candidate text library;

[0013] Sort all preset texts according to the number of texts in each preset text, and obtain the sorting result;

[0014] Based on the preset text of the preset sequence in the sorting results, the matching result of the text to be matched is obtained.

[0015] In this application, the text to be matched is segmented according to preset word roots in a preset word root library to obtain the target word root combination of the text to be matched, including:

[0016] Based on preset word roots, the text to be matched is segmented to obtain at least two word root combinations;

[0017] For each word root combination, determine the transition matrix between any two adjacent word roots in the word root combination. The transition matrix is ​​used to characterize the degree of association between the two word roots.

[0018] The score of a word root combination is obtained by multiplying all the transition matrices in the word root combination.

[0019] Based on the score of each root word combination, the target root word combination is obtained from at least two root word combinations.

[0020] In this application, for each root word combination, the transition matrix between any two adjacent roots in the root word combination is determined, including:

[0021] For each word root combination, determine the first and second word roots that are any two adjacent words in the word root combination;

[0022] Take the first root word and the second root word as the first combination, and obtain the first count of the first combination from the preset text library;

[0023] Take the last character of the first root word and the first character of the second root word as the second combination, and obtain the second count of the second combination from the preset text library;

[0024] Based on the first count and the second count, the transition matrix of the first root word and the second root word is obtained;

[0025] Based on the transition matrices of the first and second root words, the transition matrices of any two adjacent root words in the root word combination can be obtained.

[0026] In this application, the transition matrices of the first and second word roots are obtained based on the first and second counts, satisfying the following:

[0027] ;

[0028] ;

[0029] ;

[0030] in, The transition matrix is ​​for the first and second root words. As the first root word, As the second root word, for and Adjacent relationships, For all texts in the preset text library and The total number of adjacent relationships, It is the last character in the first root word. It is the first character in the second root word. for and Adjacent relationships, For all texts in the preset text library and The total number of adjacent relationships.

[0031] In this application, based on the score of each root word combination, a target root word combination is obtained from at least two root word combinations, including:

[0032] Determine the number of word root combinations corresponding to the highest score in the rating of each word root combination;

[0033] If the number of combinations is greater than or equal to two, then determine the number of word roots in the word root combination corresponding to the highest score;

[0034] The word root combination with the fewest word roots corresponding to the highest score is identified as the target word root combination among at least two word root combinations;

[0035] If there is only one possible combination, then the word root combination corresponding to the highest score will be the target word root combination among at least two word root combinations.

[0036] In this application, the method also includes:

[0037] For each root word in the target root word combination, determine whether the root word is a preset root word;

[0038] If the root word is not a preset root word, then based on the root word, search for preset texts containing the root word in the preset text library to obtain text index information;

[0039] Store the root words and text index information in a pre-defined root word index library.

[0040] Secondly, this application provides a text matching device, comprising:

[0041] The first acquisition module is used to acquire the text to be matched;

[0042] The cutting module is used to cut the text to be matched according to the preset word roots in the preset word root library, so as to obtain the target word root combination of the text to be matched, and the word roots in the target word root combination do not overlap.

[0043] The second acquisition module is used to obtain a candidate text library for each word root in the target word root combination based on the text index information of the word root in the preset word root index library. The text index information is the index information of the preset text containing the word root in the preset text library. The number of texts in the candidate text library is less than the number of texts in the preset text library.

[0044] The matching module is used to obtain the matching results of the text to be matched from the candidate text library based on the text index information of each word root in the target word root combination.

[0045] Thirdly, this application provides an electronic device, including: a processor, and a memory communicatively connected to the processor;

[0046] The memory stores instructions that the computer executes;

[0047] The processor executes computer-executable instructions stored in memory to implement the method of the first aspect.

[0048] Fourthly, this application provides a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, are used to implement the method of the first aspect.

[0049] The text matching method, apparatus, device, and medium provided in this application acquire the text to be matched, segment the text according to preset root words in a preset root word library to obtain target root word combinations, and for each root word in the target root word combination, obtain a candidate text library for the text to be matched based on the text index information of the root words in a preset root word index library. The preset root word index library allows for quick retrieval of the preset text corresponding to the root words, avoiding the step of searching within the preset text library. Furthermore, the number of candidate texts obtained is less than the preset text library, improving text matching efficiency. Finally, based on the text index information of each root word in the target root word combination, the matching result of the text to be matched is obtained from the candidate text library. Through the embodiments of this application, the obtained matching result is a preset text in the preset text library containing a large number of root words from the target root word combination, achieving the technical effect of text matching. Attached Figure Description

[0050] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.

[0051] Figure 1 A schematic diagram of a text matching scenario provided in an embodiment of this application;

[0052] Figure 2 A flowchart illustrating a text matching method provided in an embodiment of this application;

[0053] Figure 3 This is a schematic diagram of the structure of a text matching device provided in an embodiment of this application;

[0054] Figure 4 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application.

[0055] The accompanying drawings have illustrated specific embodiments of this application, which will be described in more detail below. These drawings and descriptions are not intended to limit the scope of the concept in any way, but rather to illustrate the concept of this application to those skilled in the art through reference to specific embodiments. Detailed Implementation

[0056] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.

[0057] To clearly understand the technical solution of this application, the solutions of the prior art will be described in detail first.

[0058] Data modeling refers to the abstract organization of various types of data in the real world. Through data analysis, we can better understand the essence of a problem and thus build a more accurate mathematical model.

[0059] In existing technologies, data analysis and modeling requirements are formed into word vectors according to the word order. Then, by comparing each word vector with the word vector of the question template, the question template with the smallest angle between the vectors is selected as the best matching result.

[0060] However, existing technologies require calculating the angle between vectors one by one, which means that for ultra-large-scale problem template libraries, existing technologies require a huge amount of computing time to complete the global matching work, resulting in low efficiency.

[0061] Furthermore, since the formation of word vectors in natural language relies entirely on the vocabulary, the introduction of new words that do not belong to the vocabulary often fails to correctly form word vectors, which means that the existing technology becomes ineffective.

[0062] To address any of the above problems, the inventors discovered in their research that the target word root combination of the text to be matched can be obtained by segmenting the text according to the preset word root in the preset word root library, and the word roots in the target word root combination do not overlap.

[0063] For each root word in the target root word combination, a candidate text library for the text to be matched is obtained based on the text index information of each root word in the preset root word index library. The text index information is the index information of the preset texts containing the root words in the preset text library. The number of texts in the candidate text library is less than the number of texts in the preset text library, which can reduce the number of texts to be matched and improve the matching efficiency. Finally, based on the text index information of each root word in the target root word combination, the matching result of the text to be matched is obtained from the candidate text library.

[0064] The following describes the application scenarios of the text matching method provided in the embodiments of this application.

[0065] Figure 1 This is a schematic diagram of a text matching scenario provided in an embodiment of this application, such as... Figure 1 As shown, the scenario includes the text to be matched, a preset root word library, a preset root word index library, a preset text library, and a server. The server is used to obtain the text to be matched, and to segment the text to be matched according to the preset root words in the preset root word library to obtain the target root word combination of the text to be matched. The root words in the target root word combination do not overlap. For each root word in the target root word combination, a candidate text library of the text to be matched is obtained according to the text index information of the root word in the preset root word index library. The text index information is the index information of the preset text containing the root word in the preset text library. The number of texts in the candidate text library is less than the number of texts in the preset text library. According to the text index information of each root word in the target root word combination, the matching result of the text to be matched is obtained from the candidate text library.

[0066] Figure 2 This is a flowchart illustrating a text matching method provided in an embodiment of this application, as shown below. Figure 2 As shown, the method includes:

[0067] S201. Obtain the text to be matched.

[0068] The text to be matched can be text input by the user. The server performs text matching based on this text to obtain the corresponding matching results, which can then be used for subsequent processing. For example, if a user inputs a question, the server receives the question and needs to match it with preset questions in a preset text library. After selecting the closest preset question, the server outputs the corresponding answer, allowing the server to better understand the user's question.

[0069] S202. The text to be matched is segmented according to the preset word roots in the preset word root library to obtain the target word root combination of the text to be matched, and the word roots in the target word root combination do not overlap.

[0070] The preset root word library can be a pre-defined database that stores multiple root words in advance. These root words are used to segment text based on the root words, and the target root word combination refers to the segmentation result. For example, assuming the text to be matched is "I want to go to school, how do I get there?", and the root word library contains "I", "want", "go", "school", "how", and "walk", then the text to be matched can be segmented into "I / want / go / school / how / walk", resulting in the target root word combination "I, want, go, school, how, walk".

[0071] For example, the above cutting can be achieved recursively:

[0072] result=[]

[0073] def split_sentences(sts,split_result):

[0074] if not sts:

[0075] result.append(split_result)

[0076] for index in range(sts):

[0077] try:

[0078] W[sts[:index+1]]

[0079] split_result.append(sts[:index+1])

[0080] split_sentences(sts[index+1:],split_result)

[0081] except:

[0082] pass

[0083] Where W is the preset root word library, sts is the text to be matched, and result is the segmentation result.

[0084] In some implementations, there may be multiple segmentation results when segmenting the text to be matched. Therefore, segmenting the text to be matched according to preset word roots in a preset word root library to obtain the target word root combination of the text to be matched may include:

[0085] Based on preset word roots, the text to be matched is segmented to obtain at least two word root combinations;

[0086] For each root combination, determine the transition matrix of any two adjacent roots in the root combination, where the transition matrix is used to characterize the degree of association between two roots;

[0087] Obtain the score of the root combination according to the product of all the transition matrices in the root combination;

[0088] According to the scores of each root combination, obtain the target root combination from at least two root combinations.

[0089] In this application, when there are multiple root combinations, the score of the root combination can be obtained according to the transition matrix between any two adjacent roots in each root combination. For example, assume that the text to be matched is "How can we get to school", and in the root library there are "I", "we", "want to", "go", "school", "how", "go", "I think", "want to go". Then the text to be matched can be segmented into root combination 1: "we / want to / go / school / should / how / go", and root combination 2: "I think / want to go / school / should / how / go". For root combination 1, calculate the transition matrices in "we / want to", "want to / go", "go / school", "school / should", "should / how", "how / go", so as to obtain the association relationship between two adjacent roots. According to the product of all the above transition matrices, assume that the score of root combination 1 is A. Using the same method, the score of root combination 2 is obtained as B. Since A is higher than B, root combination 1 is determined as the target root combination.

[0090] Further, for each root combination, determining the transition matrix of any two adjacent roots in the root combination may include:

[0091] For each root combination, determine any adjacent first root and second root in the root combination;

[0092] Take the first root and the second root as the first combination, and obtain the first count of the first combination in the preset text library;

[0093] Take the last character of the first root and the first character of the second root as the second combination, and obtain the second count of the second combination in the preset text library;

[0094] Obtain the transition matrix of the first root and the second root according to the first count and the second count;

[0095] Obtain the transition matrix of any two adjacent roots in the root combination according to the transition matrix of the first root and the second root.

[0096] In this application, the transition matrix is used to evaluate the association relationship between two root words. Therefore, the situation where two root words are adjacent can be queried from a preset text library, and the association relationship between the two root words can be determined according to the proportion of the situation where the two root words are adjacent. For example, assume that the first root word is "we" and the second root word is "want", then the first combination is "we want", and the second combination is "want to". The number of occurrences of the first combination and the second combination can be counted from the preset text library. Assume that the number of the first combination is C and the number of the second combination is D, and C is less than or equal to D. Then the transition matrix of the first root word and the second root word is C / D.

[0097] Specifically, when any transition matrix in the root word combination is 0, the 0 value is removed, and the product of the other non-0 transition matrices is used as the score of the root word combination.

[0098] Among them, the formula for obtaining the transition matrix of the first root word and the second root word according to the first count and the second count can be:

[0099] ;

[0100] ;

[0101] ;

[0102] Among them, is the transition matrix of the first root word and the second root word, is the first root word, is the second root word, is and adjacent relationship, is all in the preset text library and total number of adjacent relationships, is the last character in the first root word, is the first character in the second root word, is and adjacent relationship, is all in the preset text library and total number of adjacent relationships.

[0103] Furthermore, there may be multiple cases where the scores of root word combinations are the highest and the same. Therefore, according to the scores of each root word combination, the target root word combination is obtained among at least two root word combinations, including:

[0104] According to the highest score in the scores of each root word combination, determine the number of combinations of the root word combination corresponding to the highest score;

[0105] If the number of combinations is greater than or equal to two, then determine the number of word roots in the word root combination corresponding to the highest score;

[0106] The word root combination with the fewest word roots corresponding to the highest score is identified as the target word root combination among at least two word root combinations;

[0107] If there is only one possible combination, then the word root combination corresponding to the highest score will be the target word root combination among at least two word root combinations.

[0108] For example, assuming that the scores of word root combination 1 and word root combination 2 are the same and the highest, then the number of word roots in word root combination 1 is determined to be E and the number of word roots in word root combination 2 is determined to be F. Then, compare the size of E and F. If E is less than F, then word root combination 1 is determined as the target word root combination.

[0109] S203. For each root word in the target root word combination, obtain a candidate text library of texts to be matched based on the text index information of the root words in the preset root word index library. The text index information is the index information of the preset texts containing the root words in the preset text library. The number of texts in the candidate text library is less than the number of texts in the preset text library.

[0110] In this application, after obtaining the target word root combination, the text index information of the word root can be determined based on the word roots in the target word root combination. The text index information is pre-configured information stored in a preset word root index library. The text index information is used to determine the correspondence between the word root and the preset text in the preset text library. For example, for the word root 'ab', the preset text library contains preset texts 1, 2, and 3 containing the word root 'ab'. The text index information can be represented as ab:[number(preset text 1), number(preset text 2), number(preset text 3)]. The word root index library is a collection of text index information, for example, {word root A:[number(preset text a), number(preset text b), number(preset text c)], word root B:[number(preset text c), number(preset text d), number(preset text e)],...}. After obtaining the text index information of all word roots in the target word root combination, the numbers of the preset texts in all text index information can be counted to obtain a candidate text library. This application embodiment filters the preset text library using an existing preset root word index library. When the number of preset texts in the preset text library is in the millions, the efficiency of text matching can be significantly improved.

[0111] In particular, to avoid the situation where a word root in the target word root combination does not have corresponding text index information, after obtaining the target word root combination, for each word root in the target word root combination, it can be determined whether the word root is a preset word root;

[0112] If the root word is not a preset root word, then based on the root word, search for preset texts containing the root word in the preset text library to obtain text index information;

[0113] Store the root words and text index information in a pre-defined root word index library.

[0114] S204. Based on the text index information of each word root in the target word root combination, obtain the matching result of the text to be matched from the candidate text library.

[0115] In this application, after obtaining the candidate text library, it is necessary to select the preset text that is most similar to the text to be matched as the matching result of the text to be matched.

[0116] In some implementations, the matching results of the text to be matched are obtained from a candidate text library based on the text index information of each root word in the target root word combination, including:

[0117] Based on the text index information of each word root in the target word root combination, count the number of texts for each preset text in the candidate text library;

[0118] Sort all preset texts according to the number of texts in each preset text, and obtain the sorting result;

[0119] Based on the preset text of the preset sequence in the sorting results, the matching result of the text to be matched is obtained.

[0120] In this application, the number of times each preset text appears in all text index information in the candidate text library can be counted, and the preset text that satisfies the preset sequence in the text count sorting result can be taken as the text that is most similar to the text to be matched, so as to obtain the matching result of the text to be matched.

[0121] The preset sequence can be the first sequence in the sorting results, for example, the first 5.

[0122] To better match the text to be matched, the matching results of the preset sequence can be displayed in the user interface for the user to select.

[0123] For example, suppose the text to be matched is "How is the weather today?", and the target word root combination is "today / weather / how". The text index information for each word root is: today: [number(text1), number(text2), number(text3)]; {weather: [number(text1), number(text2), number(text4)]; {how: [number(text1), number(text3), number(text6)]; After counting, the number of occurrences of number(text1) is 3, the number of occurrences of number(text2) is 2, the number of occurrences of number(text3) is 2, the number of occurrences of number(text4) is 1, and the number of occurrences of number(text6) is 1. If the preset sequence is the first 3 items, then text1, text2, and text3 can be used as the matching results for the text to be matched.

[0124] For example, matching results can also be obtained in the following ways:

[0125] res={}

[0126] for q in candi_q:

[0127] try:

[0128] res[q]+=1

[0129] except:

[0130] res[q]-1

[0131] order=sorted([(q,res[i])for q in res],key=lambda x:x[1])[::-1]

[0132] Where candi_q is the candidate text library, q is the preset text in the candidate text library, and order is the sorting result.

[0133] The text matching method provided in this application obtains the text to be matched, segments it according to preset root words in a preset root word library to obtain target root word combinations, and for each root word in the target root word combination, obtains a candidate text library for the text to be matched based on the text index information of the root word in a preset root word index library. The preset root word index library allows for quick retrieval of the corresponding preset text by root word, avoiding the step of searching within the preset text library. Furthermore, the number of candidate texts obtained is less than the preset text library, improving text matching efficiency. Finally, based on the text index information of each root word in the target root word combination, the matching result of the text to be matched is obtained from the candidate text library. Through this application embodiment, the obtained matching result is a preset text in the preset text library containing a large number of root words from the target root word combination, achieving the technical effect of text matching.

[0134] Figure 3 This is a schematic diagram of the structure of a text matching device provided in an embodiment of this application, as shown below. Figure 3 As shown, the device 30 includes:

[0135] The first acquisition module 301 is used to acquire the text to be matched;

[0136] The cutting module 302 is used to cut the text to be matched according to the preset word roots in the preset word root library to obtain the target word root combination of the text to be matched, wherein the word roots in the target word root combination do not overlap.

[0137] The second acquisition module 303 is used to obtain a candidate text library of text to be matched for each root in the target root combination, based on the text index information of the root in the preset root index library. The text index information is the index information of the preset text containing the root in the preset text library. The number of texts in the candidate text library is less than the number of texts in the preset text library.

[0138] The matching module 304 is used to obtain the matching result of the text to be matched from the candidate text library based on the text index information of each word root in the target word root combination.

[0139] In some embodiments, the matching module 304 is further configured to:

[0140] Based on the text index information of each word root in the target word root combination, count the number of texts for each preset text in the candidate text library;

[0141] Sort all preset texts according to the number of texts in each preset text, and obtain the sorting result;

[0142] Based on the preset text of the preset sequence in the sorting results, the matching result of the text to be matched is obtained.

[0143] In some embodiments, the cutting module 302 is further used for:

[0144] Based on preset word roots, the text to be matched is segmented to obtain at least two word root combinations;

[0145] For each word root combination, determine the transition matrix between any two adjacent word roots in the word root combination. The transition matrix is ​​used to characterize the degree of association between the two word roots.

[0146] The score of a word root combination is obtained by multiplying all the transition matrices in the word root combination.

[0147] Based on the score of each root word combination, the target root word combination is obtained from at least two root word combinations.

[0148] In some embodiments, the cutting module 302 is further used for:

[0149] For each word root combination, determine the first and second word roots that are any two adjacent words in the word root combination;

[0150] Take the first root word and the second root word as the first combination, and obtain the first count of the first combination from the preset text library;

[0151] Take the last character of the first root word and the first character of the second root word as the second combination, and obtain the second count of the second combination from the preset text library;

[0152] Based on the first count and the second count, the transition matrix of the first root word and the second root word is obtained;

[0153] Based on the transition matrices of the first and second root words, the transition matrices of any two adjacent root words in the root word combination can be obtained.

[0154] In some embodiments, the cutting module 302 is also used to satisfy:

[0155] ;

[0156] ;

[0157] ;

[0158] in, The transition matrix is ​​for the first and second root words. As the first root word, As the second root word, for and Adjacent relationships, For all texts in the preset text library and The total number of adjacent relationships, It is the last character in the first root word. It is the first character in the second root word. for and Adjacent relationships, For all texts in the preset text library and The total number of adjacent relationships.

[0159] In some embodiments, the cutting module 302 is further used for:

[0160] Determine the number of word root combinations corresponding to the highest score in the rating of each word root combination;

[0161] If the number of combinations is greater than or equal to two, then determine the number of word roots in the word root combination corresponding to the highest score;

[0162] The word root combination with the fewest word roots corresponding to the highest score is identified as the target word root combination among at least two word root combinations;

[0163] If there is only one possible combination, then the word root combination corresponding to the highest score will be the target word root combination among at least two word root combinations.

[0164] Figure 4 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Figure 4 As shown, the electronic device 40 includes:

[0165] The electronic device 40 may include a processor 401 with one or more processing cores, a memory 402 with one or more computer-readable storage media, a communication component 403, and other components. The processor 401, memory 402, and communication component 403 are connected via a bus 404.

[0166] In the specific implementation process, at least one processor 401 executes computer execution instructions stored in memory 402, causing at least one processor 401 to perform the above method.

[0167] The specific implementation process of processor 401 can be found in the above method embodiments, and its implementation principle and technical effect are similar. It will not be repeated here.

[0168] In the above Figure 4 In the illustrated embodiments, it should be understood that the processor can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), etc. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the method disclosed in this invention can be directly implemented by a hardware processor, or implemented by a combination of hardware and software modules within the processor.

[0169] The memory may include random access memory (RAM) and may also include non-volatile memory (NVM), such as at least one disk storage device.

[0170] The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. Buses can be categorized as address buses, data buses, control buses, etc. For ease of illustration, the buses shown in the accompanying drawings are not limited to a single bus or a single type of bus.

[0171] In some embodiments, a computer program product is also provided, comprising a computer program or instructions that, when executed by a processor, implement the steps in any of the methods described above.

[0172] For details on the implementation of each of the above operations, please refer to the previous examples, which will not be repeated here.

[0173] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be performed by instructions, or by instructions controlling related hardware. These instructions can be stored in a computer-readable storage medium and loaded and executed by a processor.

[0174] Therefore, embodiments of this application provide a computer-readable storage medium storing a plurality of instructions that can be loaded by a processor to execute steps in any of the methods provided in embodiments of this application.

[0175] The storage medium may include: read-only memory (ROM), random access memory (RAM), disk or optical disk, etc.

[0176] According to one aspect of this application, a computer program product or computer program is provided, the computer program product or computer program including computer instructions stored in a computer-readable storage medium.

[0177] Since the instructions stored in the storage medium can execute the steps of any of the methods provided in the embodiments of this application, the beneficial effects that any of the methods provided in the embodiments of this application can achieve can be realized, as detailed in the preceding embodiments, and will not be repeated here.

[0178] Other embodiments of this application will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of this application that follow the general principles of this application and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this application are indicated by the following claims.

[0179] It should be understood that this application is not limited to the precise structure described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this application is limited only by the appended claims.

Claims

1. A text matching method, characterized in that, include: Get the text to be matched; The text to be matched is segmented according to the preset word roots in the preset word root library to obtain the target word root combination of the text to be matched, wherein the word roots in the target word root combination do not overlap. For each root word in the target root word combination, a candidate text library for the text to be matched is obtained based on the text index information of the root word in the preset root word index library. The text index information is the index information of the preset text containing the root word in the preset text library. The number of texts in the candidate text library is less than the number of texts in the preset text library. Based on the text index information of each word root in the target word root combination, the matching result of the text to be matched is obtained from the candidate text library.

2. The method according to claim 1, characterized in that, The step of obtaining the matching result of the text to be matched from the candidate text library based on the text index information of each word root in the target word root combination includes: Based on the text index information of each root word in the target root word combination, count the number of texts for each preset text in the candidate text library; Sort all preset texts according to the number of texts in each preset text, and obtain the sorting result; Based on the preset text of the preset sequence in the sorting results, the matching result of the text to be matched is obtained.

3. The method according to any one of claims 1-2, characterized in that, The step of segmenting the text to be matched according to preset word roots in a preset word root library to obtain the target word root combination of the text to be matched includes: The text to be matched is segmented according to preset word roots to obtain at least two word root combinations; For each word root combination, determine the transition matrix between any two adjacent word roots in the word root combination, where the transition matrix is ​​used to characterize the degree of association between the two word roots; The score of the word root combination is obtained by multiplying all the transition matrices in the word root combination. Based on the score of each root combination, the target root combination is obtained from the at least two root combinations.

4. The method according to claim 3, characterized in that, The step of determining the transition matrix for any two adjacent roots in each root combination includes: For each word root combination, determine any adjacent first and second word roots in the word root combination; Take the first root word and the second root word as a first combination, and obtain the first count of the first combination in the preset text library; Take the last character of the first root word and the first character of the second root word as a second combination, and obtain the second count of the second combination in the preset text library; Based on the first count and the second count, the transition matrices of the first word root and the second word root are obtained; Based on the transition matrices of the first and second root words, the transition matrices of any two adjacent root words in the root word combination are obtained.

5. The method according to claim 4, characterized in that, The transition matrices of the first and second word roots are obtained based on the first and second counts, satisfying: ; ; ; in, Let be the transition matrix between the first word root and the second word root. The first root word, It is the second root word. for and Adjacent relationships, For all texts in the preset text library and The total number of adjacent relationships, It is the last character in the first root word. It is the first character in the second root word. for and Adjacent relationships, For all texts in the preset text library and The total number of adjacent relationships.

6. The method according to claim 3, characterized in that, The step of obtaining the target word root combination from the at least two word root combinations based on the score of each word root combination includes: The number of word root combinations corresponding to the highest score in the rating of each word root combination is determined. If the number of combinations is greater than or equal to two, then the number of word roots in the word root combination corresponding to the highest score is determined. The word root combination with the fewest word roots corresponding to the highest score is determined as the target word root combination among the at least two word root combinations; If the number of combinations is one, then the word root combination corresponding to the highest score is determined as the target word root combination among the at least two word root combinations.

7. The method according to any one of claims 1-2, characterized in that, The method further includes: For each root word in the target root word combination, determine whether the root word is a preset root word; If the root word is not a preset root word, then based on the root word, search for preset text containing the root word in the preset text library to obtain text index information; The root words and the text index information are stored in the preset root word index library.

8. A text matching device, characterized in that, include: The first acquisition module is used to acquire the text to be matched; The cutting module is used to cut the text to be matched according to the preset word roots in the preset word root library to obtain the target word root combination of the text to be matched, wherein the word roots in the target word root combination do not overlap; The second acquisition module is used to obtain a candidate text library for the text to be matched for each root in the target root combination, based on the text index information of the root in the preset root index library. The text index information is the index information of preset texts containing the root in the preset text library. The number of texts in the candidate text library is less than the number of texts in the preset text library. The matching module is used to obtain the matching result of the text to be matched from the candidate text library based on the text index information of each word root in the target word root combination.

9. An electronic device, characterized in that, include: A processor, and a memory communicatively connected to the processor; The memory stores computer-executed instructions; The processor executes computer execution instructions stored in the memory to implement the method as described in any one of claims 1-7.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions, which, when executed by a processor, are used to implement the method as described in any one of claims 1-7.