A method and apparatus for fuzzy text matching
By determining the target word segmentation and mapping relationship in the text fuzzy matching algorithm, the problem of low retrieval efficiency in the existing technology is solved, and more efficient text retrieval is achieved.
Patent Information
- Application Number
- CN202010213163.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-03-24
- Publication Date
- 2026-02-06
- Estimated Expiration
- 2040-03-24
AI Technical Summary
Existing text fuzzy matching algorithms suffer from low retrieval efficiency due to their dictionary-traversal approach.
By obtaining the words to be fuzzy matched, the target word segmentation is determined from the preset word set, the target document identifier is obtained based on the target word segmentation and mapping relationship, and added to the fuzzy matching set. The fuzzy matching result is obtained based on the updated fuzzy matching set.
It improves the efficiency of text retrieval.
Smart Images

Figure CN113449522B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of computer, in particular to a text fuzzy matching method and device. BACKGROUND
[0002] With the rapid development of the Internet, the text data on the network grows explosively. The text retrieval service can help users quickly obtain the desired data from the massive text data according to the query keywords provided by the user. Text retrieval is widely used in various fields of network information service, such as digital library, e-commerce website and enterprise information management, etc. Text fuzzy matching is the core function of the user in the text retrieval process.
[0003] In the related art, some fuzzy matching algorithms find the words satisfying the fuzzy matching by traversing the dictionary, and there is a problem of low retrieval efficiency. SUMMARY
[0004] The embodiments of the present application provide a text fuzzy matching method and device, which can improve the retrieval efficiency.
[0005] The embodiments of the present application provide a text fuzzy matching method, comprising:
[0006] obtaining a to-be-fuzzy-matched word;
[0007] determining a target segmented word from a preset word set based on the to-be-fuzzy-matched word, wherein the preset word set comprises at least one segmented word, a word prefix of the target segmented word contains the to-be-fuzzy-matched word, and a word prefix of a first adjacent segmented word of the target segmented word does not contain the to-be-fuzzy-matched word;
[0008] obtaining a target document identifier corresponding to the target segmented word based on the target segmented word and a mapping relationship pair, wherein a document corresponding to the target document identifier contains the target segmented word, and the mapping relationship pair comprises a mapping relationship between the segmented word and the document identifier;
[0009] adding the target document identifier to a fuzzy matching set of the to-be-fuzzy-matched word, wherein the fuzzy matching set comprises the document identifiers matched by the to-be-fuzzy-matched word;
[0010] updating the fuzzy matching set based on a second adjacent segmented word of the target segmented word;
[0011] obtaining a fuzzy matching result of the to-be-fuzzy-matched word based on the updated fuzzy matching set.
[0012] Correspondingly, the embodiments of the present application provide a text fuzzy matching device, comprising:
[0013] a first obtaining unit, configured to obtain a to-be-fuzzy-matched word;
[0014] determining unit configured to determine a target word from a preset word set based on the word to be fuzzily matched, wherein the preset word set comprises at least one word, a word prefix of the target word comprises the word to be fuzzily matched, and a word prefix of a first adjacent word of the target word does not comprise the word to be fuzzily matched;
[0015] a second obtaining unit configured to obtain a target document identifier corresponding to the target word based on the target word and a mapping relationship pair, wherein a document corresponding to the target document identifier comprises the target word, and the mapping relationship pair comprises a mapping relationship between a word and a document identifier;
[0016] an adding unit configured to add the target document identifier to a fuzzy matching set of the word to be fuzzily matched, wherein the fuzzy matching set comprises document identifiers matched by the word to be fuzzily matched;
[0017] an updating unit configured to update the fuzzy matching set based on a second adjacent word of the target word;
[0018] a third obtaining unit configured to obtain a fuzzy matching result of the word to be fuzzily matched based on the updated fuzzy matching set.
[0019] Optionally, in some embodiments of the present application, the updating unit can comprise an obtaining subunit, an adding subunit and a circulating subunit, as follows:
[0020] the obtaining subunit is configured to, when a word prefix of the second adjacent word of the target word comprises the word to be fuzzily matched, obtain a document identifier corresponding to the second adjacent word of the target word based on the mapping relationship pair;
[0021] the adding subunit is configured to add the document identifier corresponding to the second adjacent word of the target word to the fuzzy matching set;
[0022] the circulating subunit is configured to take the second adjacent word of the target word as a new target word, and return to execute the step of obtaining the document identifier corresponding to the second adjacent word of the target word based on the mapping relationship pair until the word prefix of the second adjacent word of the target word does not comprise the word to be fuzzily matched.
[0023] Optionally, in some embodiments of the present application, the text fuzzy matching apparatus can further comprise a word dividing unit, a cutting unit, a fourth obtaining unit and an establishing unit, as follows:
[0024] the word dividing unit is configured to perform word dividing processing on the original text to obtain at least one word of the original text;
[0025] an intercepting unit, configured to intercept at least one word suffix from the word segmentation based on the bytes of the word segmentation;
[0026] a fourth obtaining unit, configured to obtain a document identifier corresponding to the word suffix, wherein a document corresponding to the document identifier contains the word suffix;
[0027] a establishing unit, configured to establish a mapping relationship between the word segmentation and the document identifier, to obtain a mapping relationship pair of the word segmentation.
[0028] Optionally, in some embodiments of the present application, the intercepting unit can be specifically configured to intercept at least one word suffix from the word segmentation based on the bytes of the word segmentation, wherein the byte length of the word suffix is not less than a preset byte length.
[0029] Optionally, in some embodiments of the present application, the establishing unit can include a fusion subunit and an establishing subunit, as follows:
[0030] The fusion subunit is configured to fuse the document identifiers corresponding to the word suffixes of the word segmentation, to obtain a document identifier set corresponding to the word segmentation.
[0031] The establishing subunit is configured to establish a mapping relationship between the word segmentation and the document identifier set, to obtain a mapping relationship pair of the word segmentation.
[0032] Optionally, in some embodiments of the present application, the text fuzzy matching apparatus further includes a storage unit, as follows:
[0033] The storage unit is configured to store the mapping relationship pair corresponding to each word segmentation in a multi-level storage area according to a preset arrangement order of the word segmentation.
[0034] Optionally, in some embodiments, the second obtaining unit can be specifically configured to extract the mapping relationship pair corresponding to the target word segmentation from the multi-level storage area, and obtain a target document identifier corresponding to the target word segmentation based on the extracted mapping relationship pair.
[0035] Optionally, in some embodiments of the present application, the storage unit can be specifically configured to determine a current storage area in the multi-level storage area that needs to store the mapping relationship pair, store the mapping relationship pair corresponding to each word segmentation in the current storage area according to a preset arrangement order of the word segmentation, when the current storage area meets a preset condition, store the mapping relationship pairs stored in the current storage area in a next-level storage area of the current storage area, take the next-level storage area as the current storage area, and return to execute the step of storing the mapping relationship pairs stored in the current storage area in the next-level storage area of the current storage area when the current storage area meets the preset condition.
[0036] Optionally, in some embodiments of the present application, the determining unit can be specifically configured to determine the target segmented word from the preset word set according to the preset arrangement order of the segmented word in each level of the multi-level storage area and the to-be-fuzzily-matched word.
[0037] Optionally, in some embodiments of the present application, the determining unit can be specifically configured to determine the target segmented word from the preset word set based on the to-be-fuzzily-matched word through binary search.
[0038] An electronic device provided in an embodiment of the present application includes a processor and a memory. The memory stores a plurality of instructions. The processor loads the instructions to perform the steps in the text fuzzily matching method provided in the embodiment of the present application.
[0039] In addition, an embodiment of the present application further provides a storage medium having a computer program stored thereon. When the computer program is executed by a processor, the steps in the text fuzzily matching method provided in the embodiment of the present application are implemented.
[0040] An embodiment of the present application provides a text fuzzily matching method and device. A to-be-fuzzily-matched word can be obtained. A target segmented word is determined from a preset word set based on the to-be-fuzzily-matched word. The preset word set includes at least one segmented word. A word prefix of the target segmented word contains the to-be-fuzzily-matched word, and a word prefix of a first adjacent segmented word of the target segmented word does not contain the to-be-fuzzily-matched word. A target document identifier corresponding to the target segmented word is obtained based on the target segmented word and a mapping relationship pair. A document corresponding to the target document identifier contains the target segmented word. The mapping relationship pair includes a mapping relationship between a segmented word and a document identifier. The target document identifier is added to a fuzzily matching set of the to-be-fuzzily-matched word. The fuzzily matching set includes document identifiers matched by the to-be-fuzzily-matched word. The fuzzily matching set is updated based on a second adjacent segmented word of the target segmented word. A fuzzily matching result of the to-be-fuzzily-matched word is obtained based on the updated fuzzily matching set. The retrieval efficiency can be improved by improving the fuzzily matching algorithm. BRIEF DESCRIPTION OF DRAWINGS
[0041] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed in the embodiment description will be briefly introduced. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without any creative effort.
[0042] Figure 1a is a scene diagram of the text fuzzily matching method provided in an embodiment of the present application;
[0043] Figure 1bis a reference schematic diagram of the text fuzzy matching method provided by the embodiment of the present application.
[0044] Figure 1c is a reference schematic diagram of the text fuzzy matching method provided by the embodiment of the present application.
[0045] Figure 1d is another reference schematic diagram of the text fuzzy matching method provided by the embodiment of the present application.
[0046] Figure 2a is another flowchart of the text fuzzy matching method provided by the embodiment of the present application.
[0047] Figure 2b is another flowchart of the text fuzzy matching method provided by the embodiment of the present application.
[0048] Figure 3a is a structural schematic diagram of the text fuzzy matching device provided by the embodiment of the present application.
[0049] Figure 3b is another structural schematic diagram of the text fuzzy matching device provided by the embodiment of the present application.
[0050] Figure 3c is another structural schematic diagram of the text fuzzy matching device provided by the embodiment of the present application.
[0051] Figure 3d is another structural schematic diagram of the text fuzzy matching device provided by the embodiment of the present application.
[0052] Figure 3e is another structural schematic diagram of the text fuzzy matching device provided by the embodiment of the present application.
[0053] Figure 4 is a structural schematic diagram of the electronic device provided by the embodiment of the present application. DETAILED DESCRIPTION
[0054] The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor fall within the scope of protection of the present application.
[0055] The text fuzzy matching method provided by the embodiment of the present application relates to natural language processing (NLP) in the field of artificial intelligence (AI). The embodiment of the present application can improve the retrieval efficiency by improving the fuzzy matching algorithm.
[0056] Among them, artificial intelligence (AI, Artificial Intelligence) is to use digital computers or digital computer controlled machine simulation, extension and expansion of human intelligence, perception of the environment, knowledge acquisition and use of knowledge to obtain the best results of theory, method, technology and application system. In other words, artificial intelligence is a comprehensive technology of computer science, which tries to understand the essence of intelligence, and produces a new intelligent machine that can react in a similar way to human intelligence. Artificial intelligence is to study the design principles and implementation methods of various intelligent machines, so that machines have the functions of perception, reasoning and decision-making. Artificial intelligence technology is a comprehensive discipline, which involves a wide range of fields, both hardware and software technologies. Among them, artificial intelligence software technology mainly includes computer vision technology, speech technology, natural language processing technology and machine learning / deep learning, etc.
[0057] Among them, natural language processing (NLP, Nature Language processing) is an important direction in the field of computer science and artificial intelligence. It studies the various theories and methods that can realize effective communication between people and computers using natural language. Natural language processing is a science that integrates linguistics, computer science and mathematics. Therefore, the research in this field will involve natural language, that is, the language used in daily life, so it is closely related to the study of linguistics. Natural language processing technology usually includes text processing, semantic understanding, machine translation, robot question and answer, knowledge graph and other technologies.
[0058] The embodiment of the application provides a text fuzzy matching method and device. Specifically, the embodiment of the application provides a text fuzzy matching device suitable for an electronic device, which can be a terminal or a server and the like.
[0059] It can be understood that the text fuzzy matching method of the embodiment can be executed on a terminal, or executed on a server, or executed by a terminal and a server together.
[0060] Reference Figure 1a Taking the terminal and the server together to execute the text fuzzy matching method as an example. The text fuzzy matching system provided by the embodiment of the application includes a terminal 10 and a server 11 and the like; the terminal 10 and the server 11 are connected through a network, for example, connected through a wired or wireless network and the like, wherein the text fuzzy matching device can be integrated in the server.
[0061] The terminal 10 can obtain a to-be-fuzzy-matching word, and send the to-be-fuzzy-matching word to the server 11, so that the server 11 obtains a fuzzy matching result of the to-be-fuzzy-matching word based on the received to-be-fuzzy-matching word, and returns the fuzzy matching result to the terminal 10, where the fuzzy matching result includes a document identifier matched by the to-be-fuzzy-matching word. The terminal 10 can include a mobile phone, a smart television, a tablet computer, a notebook computer, or a personal computer (PC), and the like.
[0062] The server 11 can be configured to obtain a to-be-fuzzy-matching word, determine a target word from a preset word set based on the to-be-fuzzy-matching word, where the preset word set includes at least one word, a word prefix of the target word includes the to-be-fuzzy-matching word, and a word prefix of a first adjacent word of the target word does not include the to-be-fuzzy-matching word, obtain a target document identifier corresponding to the target word based on the target word and a mapping relationship pair, where the target document identifier corresponds to a document including the target word, the mapping relationship pair includes a mapping relationship between a word and a document identifier, add the target document identifier to a fuzzy matching set of the to-be-fuzzy-matching word, where the fuzzy matching set includes document identifiers matched by the to-be-fuzzy-matching word, update the fuzzy matching set based on a second adjacent word of the target word, obtain a fuzzy matching result of the to-be-fuzzy-matching word based on the updated fuzzy matching set, and send the obtained fuzzy matching result to the terminal 10. The server 11 can be a single server or a server cluster composed of multiple servers.
[0063] The server 11 can obtain a fuzzy matching result of a to-be-fuzzy-matching word, and the terminal 10 can also obtain the fuzzy matching result of the to-be-fuzzy-matching word.
[0064] The following will be described in detail. It should be noted that the order of the following embodiments is not limited as the preferred order of the embodiments.
[0065] The embodiments of the present application will be described from the perspective of a text fuzzy matching device, which can be integrated in an electronic device, which can be a server, a terminal, or the like.
[0066] The text fuzzy matching method of the embodiments of the present application can be applied to various scenarios requiring text matching, for example, can be used in enterprise employee address books, approval, daily reports, weekly reports, reports, enterprise material retrieval, and enterprise mailboxes, and the like.
[0067] As shown in Figure 1b The specific process of the text fuzzy matching method is as follows. The text fuzzy matching method can be executed by a server or a terminal, and the embodiments of the present application do not limit this.
[0068] 101、obtain a word to be fuzzily matched.
[0069] The fuzzily matching can allow a certain difference between the to-be-matched information and the retrieved matching information, and the difference is the meaning of "fuzziness" in the searching. For example, when searching for the word "kit" (equipment), the words "kite" (kite) and "kitty" (kitty) are found. The fuzzily matching means that the matching is given in a general degree according to the given conditions or requirements. Compared with the accurate matching, the content matched by the fuzzily matching is more extensive, unclear, and the accuracy of the matching result of the fuzzily matching is not as high as that of the accurate matching.
[0070] In this embodiment, the word to be fuzzily matched is a word to be searched, and specifically, it is a word to be fuzzily matched, which can be obtained by searching the document information matched with the word to be fuzzily matched. The type of the word to be fuzzily matched is not limited, for example, it can be a word, a number, a Chinese character, or a string, and the like, and the embodiment is not limited in this regard.
[0071] In this embodiment, there are various ways to obtain the word to be fuzzily matched. For example, the word to be fuzzily matched can be obtained by other devices and then provided to the text fuzzily matching device, that is, the text fuzzily matching device can specifically receive the word to be fuzzily matched sent by other devices such as other terminals.
[0072] 102、determine a target word from a preset word set based on the word to be fuzzily matched, wherein the preset word set includes at least one word, the word prefix of the target word includes the word to be fuzzily matched, and the word prefix of the first adjacent word of the target word does not include the word to be fuzzily matched.
[0073] The preset word set includes at least one word, and the words in the preset word set are sorted in a preset manner, which can be set according to actual conditions, and the embodiment is not limited in this regard. For example, the words in the preset word set can be sorted in order according to the byte values corresponding to the words. In addition, the type of the word is not limited, for example, it can be a word, a number, a Chinese character, or a string, and the like, and the embodiment is not limited in this regard. Specifically, if the words in the preset word set are English words, they can be sorted in alphabetical order; if the words in the preset word set are number strings, they can be sorted in alphabetical order; if the words in the preset word set are Chinese characters, they can be sorted based on pinyin; and if the words in the preset word set are strings, the preset sorting manner can be based on the order of 0-9, a-z, and underscore, wherein the string is a string of characters composed of numbers, letters, and underscores.
[0074] The word prefix can refer to a word-forming element in front of a root in a language. For example, for "a ge" and "a ba" in Chinese, the word prefix can be "a" in "a ge" and "a ba". For the word "reunion" in English, the word prefix can be "re". In a computer, the word prefix can be a word obtained by intercepting the first j bytes of a segmented word, where j is a positive integer not greater than the byte length of the segmented word. It should be noted that the word prefix of a segmented word can include the segmented word itself. For example, in the case of one letter occupying one byte of storage space, for the segmented word "kitty", the word prefix can include "k", "ki", "kit", "kitt", and "kitty".
[0075] In this embodiment, the first adjacent segmented word of the target segmented word is the segmented word adjacent to the target segmented word in a first direction. The first direction can be set according to actual conditions, and this embodiment does not limit the first direction. For example, when the segmented words in the preset word set are English words, and the segmented words are arranged in the order of letters, if the segmented words are arranged in the order from a to z, the segmented word adjacent to the target segmented word in the first direction is the previous segmented word of the target segmented word. If the segmented words are arranged in the order from z to a, the segmented word adjacent to the target segmented word in the first direction is the next segmented word of the target segmented word. For example, assuming that the arrangement order of the segmented words is "hello" (hello), "ice" (ice), "kit", "kitty", and "world" (world), and the target segmented word is "kit", the first adjacent segmented word of the target segmented word is "ice". For another example, if the arrangement order of the segmented words is "world", "kitty", "kit", "ice", and "hello", and the target segmented word is "kit", the first adjacent segmented word of the target segmented word is "ice".
[0076] In the embodiment, the word prefix of the target segmented word contains the word to be fuzzily matched, and the word prefix of the first adjacent segmented word of the target segmented word does not contain the word to be fuzzily matched. Specifically, if the segmented words in the preset word set are English words and the segmented words are arranged in the order of letters a to z, a segmented word in the preset word set can be compared with the word to be fuzzily matched. If the word prefix of the segmented word contains the word to be fuzzily matched and the word prefix of the first adjacent segmented word of the segmented word does not contain the word to be fuzzily matched, the segmented word is the target segmented word. If the word prefix of the segmented word does not contain the word to be fuzzily matched, the segmented word before or after the segmented word is determined based on the first letter of the segmented word and the arrangement order of the segmented words in the preset word set, and the target segmented word is searched in the segmented words. If the word prefix of the segmented word contains the word to be fuzzily matched, but the word prefix of the first adjacent segmented word of the segmented word also contains the word to be fuzzily matched, the target segmented word is searched in the segmented words in the first direction of the segmented word. For example, the word to be fuzzily matched is kit, the arrangement order of the segmented words in the preset word set is hello, ice, kit, kitty and world, and the target segmented word in the preset word set is kit because the word prefix kit of kit contains the word to be fuzzily matched and the word prefix of the first adjacent segmented word ice of kit does not contain the word to be fuzzily matched.
[0077] Optionally, in some embodiments, the step of "determining the target segmented word from the preset word set based on the word to be fuzzily matched" can include:
[0078] The target segmented word is determined from the preset word set based on the word to be fuzzily matched by binary search.
[0079] The binary search is also called the dichotomy search, which requires that the segmented words in the preset word set are arranged in order. If the segmented words in the preset word set are English words and the segmented words are arranged in order from a to z, the segmented word recorded at the middle position of the preset word set can be compared with the word to be fuzzily matched. If the word prefix of the segmented word recorded at the middle position of the preset word set contains the word to be fuzzily matched, and the word prefix of the first adjacent segmented word of the segmented word recorded at the middle position does not contain the word to be fuzzily matched, the segmented word recorded at the middle position is the target segmented word. If the word prefix of the segmented word recorded at the middle position does not contain the word to be fuzzily matched, the preset word set is divided into two subsets, i.e., a front subset and a rear subset, based on the middle recorded position, and it is determined whether the further binary search is in the front subset or the rear subset based on the comparison of the size of the segmented word at the middle recorded position and the word to be fuzzily matched. The above process is repeated until the segmented word satisfying the condition is found, and the segmented word is the target segmented word. If the word prefix of the segmented word recorded at the middle position contains the word to be fuzzily matched, but the word prefix of the first adjacent segmented word of the segmented word recorded at the middle position also contains the word to be fuzzily matched, the further binary search is performed in the segmented words in the first direction of the segmented word until the segmented word satisfying the condition is found, and the segmented word is taken as the target segmented word.
[0080] It should be noted that the method for determining the target segmented word in the embodiments of the present application is not limited to the above examples.
[0081] 103、based on the target segmented word and the mapping relationship pair, obtaining a target document identifier corresponding to the target segmented word, the target document identifier corresponding to a document containing the target segmented word, and the mapping relationship pair including a mapping relationship between the segmented word and the document identifier.
[0082] The document can represent a storage object in the form of text, and can cover various forms, such as files in different formats such as Portable Document Format (PDF), Hyper Text Markup Language (HTML), and Extensible Markup Language (XML), and the like. For example, an email or a message can also be referred to as a document.
[0083] In the search engine, each document corresponds to a document number, and the document content can be represented as a series of keyword sets. Based on the document number of the document, the keyword list of the document can be obtained. For example, after the document 1 is segmented, 20 keywords are extracted, and the occurrence frequency and occurrence position of each keyword in the document are recorded. The document identifier can be the number of the document, and the number is used as the unique identifier of the document. According to the document identifier, the corresponding document can be found in the document list.
[0084] The mapping relationship includes the mapping relationship between word segments and document identifiers. Specifically, this mapping relationship can be a table showing the relationship between word segments and their corresponding document identifiers, where the document corresponding to the word segment contains that word. Based on the target word segment, the corresponding target document identifier is searched from the relationship table.
[0085] Specifically, the mapping relationship can be an inverted index table for word segmentation. Each entry in this index table includes an attribute value and the address of each record containing that attribute value. It needs to look up the record based on the attribute value, which can be a word segment. The inverted index table is stored in key-value format, where the key is a word segment from a predefined word set, and the value can be the document identifier corresponding to the document containing that word. Each keyword corresponds to a series of documents, i.e., a list of documents containing that keyword. Using the inverted index, a list of documents containing a specific word segment can be quickly obtained. Based on the target word segmentation, the corresponding target document identifier is found in the inverted index table.
[0086] An inverted index is used to record which documents contain a particular keyword. Typically, a document collection contains many documents with a given keyword. Each document records its document ID, the frequency of the keyword's appearance in that document, and its positions within the document. Documents in the list containing the keyword can be ranked based on this information. During the ranking process, this information is weighted and applied to the final ranking result.
[0087] It's important to note that search engine systems generally don't store the actual document IDs of documents within the inverted index entries. Instead, they store the document ID differences. The document ID difference is the difference between the document IDs of two adjacent inverted index entries. For example, if the original three document IDs are 187, 196, and 199, they will be converted to 187, 9, and 3 during actual storage through ID difference calculation. Calculating the differences between document IDs allows for better data compression, helping to increase the data compression ratio.
[0088] In this embodiment, the document identifier corresponding to the document containing the word can be obtained by using the inverted index and the word segmentation; the corresponding document can be found by using the forward index and the document identifier.
[0089] 104. Add the target document identifier to the fuzzy matching set of the word to be fuzzy matched, wherein the fuzzy matching set includes the document identifiers that the word to be fuzzy matched matches.
[0090] The fuzzy matching set is a set of document identifiers, and the documents corresponding to the document identifiers contain the target segmented word and are the documents to be matched with the fuzzy matching word. In addition, the document identifiers in the fuzzy matching set can be sorted based on the matching degree of the documents corresponding to the document identifiers and the fuzzy matching word. The matching degree can be determined according to the number of times the target segmented word appears in the document and the positions at which the target segmented word appears in the document.
[0091] 105. updating the fuzzy matching set based on the second adjacent segmented word of the target segmented word.
[0092] In this embodiment, the step of "updating the fuzzy matching set based on the second adjacent segmented word of the target segmented word" can include:
[0093] When the word prefix of the second adjacent segmented word of the target segmented word contains the fuzzy matching word, the document identifier corresponding to the second adjacent segmented word of the target segmented word is obtained based on the mapping relationship pair.
[0094] The document identifier corresponding to the second adjacent segmented word of the target segmented word is added to the fuzzy matching set.
[0095] The second adjacent segmented word of the target segmented word is taken as a new target segmented word, and the step of obtaining the document identifier corresponding to the second adjacent segmented word of the target segmented word based on the mapping relationship pair is executed until the word prefix of the second adjacent segmented word of the target segmented word does not contain the fuzzy matching word.
[0096] In this embodiment, after the step of "taking the second adjacent segmented word of the target segmented word as a new target segmented word" in the process of updating the fuzzy matching set, the following steps can be included:
[0097] It is determined whether the word prefix of the second adjacent segmented word of the target segmented word contains the fuzzy matching word.
[0098] If yes, the step of obtaining the document identifier corresponding to the second adjacent segmented word of the target segmented word based on the mapping relationship pair is executed until the word prefix of the second adjacent segmented word of the target segmented word does not contain the fuzzy matching word.
[0099] If no, the updating process of the fuzzy matching set is ended, and the step 106 is executed.
[0100] The second adjacent token of the target token is a token adjacent to the target token in a second direction. The second direction is opposite to the first direction in step 102. For example, when the tokens in the preset token set are English words and the tokens are arranged in the order of letters, if the tokens are arranged in the order from a to z, the token adjacent to the target token in the first direction is the previous token of the target token, and the token adjacent to the target token in the second direction is the next token of the target token. If the tokens are arranged in the order from z to a, the token adjacent to the target token in the first direction is the next token of the target token, and the token adjacent to the target token in the second direction is the previous token of the target token.
[0101] 106. Based on the updated fuzzy matching set, obtain a fuzzy matching result of the word to be fuzzily matched.
[0102] The updated fuzzy matching set contains a plurality of prefixes of words, and the prefixes of words correspond to document identifiers of the word to be fuzzily matched. The document identifiers in the fuzzy matching set can be sorted according to the similarity between the tokens and the word to be fuzzily matched, the number of times the tokens appear in the documents, and the positions of the tokens in the documents, to obtain the fuzzy matching result of the word to be fuzzily matched.
[0103] Optionally, the text fuzzy matching method in the embodiment can further include a process of establishing a mapping relationship pair, and specifically includes:
[0104] Tokenize the original text to obtain at least one token of the original text;
[0105] Based on the bytes of the token, obtain at least one suffix of a word from the token;
[0106] Obtain document identifiers corresponding to the suffix of the word, wherein the documents corresponding to the document identifiers contain the suffix of the word;
[0107] Establish a mapping relationship between the token and the document identifiers to obtain a mapping relationship pair of the token.
[0108] The original text is a text that has not been tokenized, and the text type is not limited. The tokenization can regard one word as one token, or regard multiple words as one token, and the embodiment is not limited in this regard. For example, some nouns such as “New York” can be regarded as one token.
[0109] In linguistics, a postfix can be a suffix that is attached to other morphemes, for example, in English, a postfix can be one or a group of syllables that are attached to a word or a stem to form a new word. In a computer, a postfix can be a word that is obtained by intercepting the i-th byte to the last byte of a segmented word, i being a positive integer not greater than the byte length of the segmented word. It should be noted that the postfix of a segmented word can include the segmented word itself. For example, in the case of one letter occupying one byte of storage space, for the segmented word kitty, its postfixes include y, ty, tty, itty and kitty. Again, the postfixes with too short byte length are quite different from the segmented word itself, and have less distinguishing features, for example, for the postfixes y and ty of kitty, many words include y and ty, so the intercepted postfixes have little meaning, thus the byte length of the intercepted postfixes can be limited, so that the byte length of the intercepted postfixes is not less than a preset byte length.
[0110] Optionally, in some embodiments, the step of "intercepting at least one postfix from the segmented word based on the byte of the segmented word" can include:
[0111] intercepting at least one postfix from the segmented word based on the byte of the segmented word, the byte length of the postfix being not less than a preset byte length.
[0112] The preset byte length can be set according to actual conditions, and the present embodiment does not limit this. For example, the preset byte length can be set according to the byte length of the segmented word itself, for a segmented word with a longer byte length, the preset byte length can be set to be larger, and for a segmented word with a smaller byte length, the preset byte length can be set to be smaller.
[0113] Specifically, the preset byte length can be set to N, representing the shortest byte length of the intercepted postfix of a segmented word, for a segmented word with a byte length of L bytes, max(0, L-N)+1 postfixes can be expanded, wherein max(0, L-N) represents the larger value of 0 and L-N, and if 0 and L-N are equal, max(0, L-N) takes the value of 0. Let T(L) represent a segmented word with a byte length of L, and let Sub(T(L), i) represent the i-th byte to the end of the segmented word as a new word, i.e., a postfix, Sub can represent a function of intercepting a segmented word. The set of intercepted postfixes is denoted as S. For each segmented word T(L), the specific process of intercepting the postfixes can be as follows:
[0114] S1. Add the word T(L) to the postfix set S;
[0115] S2. Let i = 1;
[0116] S3. If L-i is greater than or equal to N, add Sub(T(L), i) to the word suffix set S, and let i = i + 1, repeat step S3, otherwise go to step S4;
[0117] S4. Return the word suffix set S, which contains the word suffixes of the word segmentation T(L) satisfying the requirements.
[0118] In this embodiment, in the step of "obtaining the document identifier corresponding to the word suffix, the document corresponding to the document identifier contains the word suffix", the document identifier corresponding to each word suffix in the word suffix set S can be obtained.
[0119] For each word suffix, there can be multiple documents containing the word suffix, i.e., there are multiple document identifiers corresponding to the word suffix. The document identifiers corresponding to the word suffix can be sorted based on the size of the relevance of the document to the word suffix, which can be determined based on the frequency and position of the word suffix in the document.
[0120] Optionally, in some embodiments, the step of "establishing the mapping relationship between the word segmentation and the document identifier, obtaining the mapping relationship pair of the word segmentation" can include:
[0121] fusing the document identifiers corresponding to each word suffix of the word segmentation, to obtain the document identifier set corresponding to the word segmentation;
[0122] establishing the mapping relationship between the word segmentation and the document identifier set, to obtain the mapping relationship pair of the word segmentation.
[0123] In the process of the step of "fusing the document identifiers corresponding to each word suffix of the word segmentation, to obtain the document identifier set corresponding to the word segmentation", the document identifiers corresponding to each word suffix can be added to the document identifier set in turn. The document identifier set contains the document identifiers corresponding to each word suffix, and the document identifiers in the document identifier set can be sorted based on the byte length of the word suffix and the relevance of the document corresponding to the document identifier to the word suffix.
[0124] The document identifier can be a document number. Each document is marked by a unique numerical value, which is the document identifier (ID, Identity Document). The document identifier set can be a list of document IDs.
[0125] In this embodiment, in the step of "establishing the mapping relationship between the word segmentation and the document identifier set, obtaining the mapping relationship pair of the word segmentation", based on the mapping relationship pair of each word segmentation, a mapping relationship table between the word segmentation and the document identifier set can be established.
[0126] In particular, the mapping table can be an inverted index table of the segmented words, i.e., the segmented words are used as keys, and the document identification sets corresponding to the segmented words are used as values, the inverted index is stored in the form of key-value, and the key-values are arranged in order according to the keys. For example, if the segmented words are English words, the words can be arranged in order according to the alphabetic order. As shown in FIG. 2, an inverted index table in which the segmented words are arranged in order is shown. Figure 1c
[0127] Optionally, in some embodiments, the inverted index table of the storage area is stored in the form of key-value, in which the key is a segmented word, and the value is a list of document IDs; for each segmented word, the document identification set corresponding to the segmented word can be directly inserted into the inverted index table of the storage area, or for each word suffix of the segmented word, the document identification corresponding to the word suffix can be directly inserted into the inverted index table of the storage area based on the segmented word to update the document identification set corresponding to the segmented word.
[0128] Optionally, in some embodiments, after the step of "establishing a mapping relationship between the segmented words and the document identifications to obtain a mapping relationship pair of the segmented words", the method can further include:
[0129] storing the mapping relationship pairs corresponding to the segmented words in a multi-level storage area according to a preset arrangement order of the segmented words.
[0130] Optionally, in some embodiments, the step of "obtaining a target document identification corresponding to the target segmented word based on the target segmented word and the mapping relationship pairs" can include:
[0131] extracting the mapping relationship pair corresponding to the target segmented word from the multi-level storage area, and obtaining the target document identification corresponding to the target segmented word based on the extracted mapping relationship pair.
[0132] Optionally, the step of "storing the mapping relationship pairs corresponding to the segmented words in a multi-level storage area according to a preset arrangement order of the segmented words" can include:
[0133] determining a current storage area in which the mapping relationship pairs need to be stored from the multi-level storage area;
[0134] storing the mapping relationship pairs corresponding to the segmented words in the current storage area according to a preset arrangement order of the segmented words.
[0135] when the current storage area meets a preset condition, storing the mapping relationship pairs stored in the current storage area in a next-level storage area of the current storage area;
[0136] The next level storage area is taken as the current storage area, and the step of storing the mapping relationship pair corresponding to each segmented word in the next level storage area of the current storage area is returned to.
[0137] In some embodiments, the multi-level storage area can include memory and disk, and the files in the disk are divided into multiple levels, i.e., level 0, level 1, level 2, and so on. The level 0 of the disk can be regarded as the next level storage area of the memory, the level 1 can be regarded as the next level storage area of the level 0, and similarly, the level 2 can be regarded as the next level storage area of the level 1, and so on.
[0138] In the step of determining the current storage area in which the mapping relationship pair needs to be stored from the multi-level storage area, the current storage area can be the memory. In the step of storing the mapping relationship pair corresponding to each segmented word in the current storage area according to the preset arrangement order of the segmented words, the arrangement order of the segmented words can be determined based on the byte value of the segmented words, and the key-value pair corresponding to the segmented words can be stored in the memory based on the arrangement order of each segmented word. The key-value pairs in the memory are arranged in order according to the byte sequence. When the memory meets the preset condition, the key-value pairs stored in the memory can be data-persisted to become a file and stored in the level 0 of the disk. The preset condition can be set according to actual conditions, which is not limited in the present embodiment. For example, the preset condition can be that the memory data reaches a set threshold, the system is restarted, or the time interval from the last persistence exceeds a set threshold, and so on.
[0139] In some embodiments, the data persistence can arrange the key-value lists of the forward index and the reverse index in the memory, and persist the key-value lists in the form of a file on a storage medium, such as a disk, and specifically, in the level 0 of the disk. The forward index refers to finding the corresponding document according to the document identifier, and the reverse index refers to obtaining the document identifier corresponding to the segmented word according to the segmented word.
[0140] Optionally, in the present embodiment, referring to Figure 1dThe files in the disk are divided into multiple levels, each level is composed of a plurality of files, and each file can store a key-value list data of a continuous key range, wherein the continuous key range is a key stored in a preset arrangement order, and the file format can be a serialized certificate storage file (SST). Each persistent file is composed of a plurality of key / value pairs, and different key / values in the file are sequentially arranged in byte order, and the byte value of the key is used as the sorting value. For the level 0 file, there is an overlap in the key range between the files, but the key range in the level 0 is not overlapped, for example, there are file 1 and file 2 in the level 0, the file 1 stores the first letter a to d of the segmentation, and the file 2 stores the first letter c to f of the segmentation, and the file 1 and the file 2 have an overlap of the first letter c to d of the segmentation. For the file of the non-level 0, the file of each level has the characteristics of “order between files and order inside the file”. Specifically, the key range of the file inside each level is not overlapped, the files are sequentially arranged, and the key-values inside the file are also sequentially arranged.
[0141] Specifically, when the memory meets the preset condition, the key-value pairs stored in the memory are persisted as files and stored in the level 0 of the disk; as the level 0 files increase, when the files increase to meet the preset condition, part of the level 0 files can be merged into the level 1, and the files in the level 1 after the merging keep the characteristics of the order between the files and the order inside the file, that is, the level 0 is taken as a new current storage area, and the key-value pairs of the current storage area are stored in the next level storage area level 1. Similarly, when the files of the level 1 and above increase to meet the preset condition, they are also merged into the higher level in this way, that is, merged into the level 2.
[0142] Optionally, the step of “determining the target segmentation from the preset word set based on the to-be-fuzzily-matched word” can include:
[0143] According to the preset arrangement order of the segmentation in each level of the multi-level storage area and the to-be-fuzzily-matched word, the target segmentation is determined from the preset word set of each level of the storage area.
[0144] The split word in the preset word set is the key of the mapping relationship pair. The split words in the preset word set in the memory are arranged in order according to byte values. The key ranges of the files in the level 0 in the disk do not overlap, the files are arranged in order, and the keys in the files are also arranged in order. For the files in the level 0 in the disk, the key ranges of the files overlap, but the keys in the files are arranged in order. For the level 0 in the disk, the target split word needs to be determined in the preset word set in each file in the level 0.
[0145] For example, for each layer in the memory and the disk except the level 0, the target split word can be directly queried in the memory by using the binary search, and the target split word can be directly queried in each layer of the level 0 in the disk by using the binary search. For the level 0 in the disk, because the key ranges of the files in the level 0 overlap, but the keys in the files are arranged in order, the target split word needs to be queried in each file in the level 0 by using the binary search, and the fuzzy matching set is updated according to the second adjacent split word of the target split word and the target split word in each file. Finally, the fuzzy matching set is updated based on the second adjacent split word of the target split word and the target split word in each layer in the memory and the disk, and the fuzzy matching result of the word to be fuzzily matched is obtained.
[0146] As can be seen from the above, the word to be fuzzily matched can be obtained. The target split word is determined from a preset word set based on the word to be fuzzily matched, the preset word set includes at least one split word, a word prefix of the target split word includes the word to be fuzzily matched, and a word prefix of a first adjacent split word of the target split word does not include the word to be fuzzily matched. A target document identifier corresponding to the target split word is obtained based on the target split word and a mapping relationship pair, the target document identifier corresponds to a document including the target split word, and the mapping relationship pair includes a mapping relationship between a split word and a document identifier. The target document identifier is added to a fuzzy matching set of the word to be fuzzily matched, the fuzzy matching set includes document identifiers matched by the word to be fuzzily matched. The fuzzy matching set is updated based on a second adjacent split word of the target split word. The fuzzy matching result of the word to be fuzzily matched is obtained based on the updated fuzzy matching set. The retrieval efficiency can be improved by improving the fuzzy matching algorithm.
[0147] According to the method described in the foregoing embodiments, the following will be further described in detail by taking the example of a text fuzzy matching device integrated in a server.
[0148] The embodiment of the present application provides a text fuzzy matching method, as shown in Figure 2a The specific process of the text fuzzy matching method can be as follows:
[0149] 201、the server performs word segmentation on the original text to obtain at least one word segmentation of the original text.
[0150] The original text is text that has not been subjected to word segmentation, and the text type is not limited. The word segmentation can regard one word as one word segmentation, or regard multiple words as one word segmentation, and the embodiment is not limited in this regard. For example, some nouns such as "New York" can be regarded as one word segmentation.
[0151] 202、the server extracts at least one word suffix from the word segmentation based on the bytes of the word segmentation.
[0152] The word suffix is a word obtained by extracting the i-th byte to the last byte of the word segmentation, and i is a positive integer not greater than the byte length of the word segmentation. It should be noted that the word suffix of the word segmentation can include the word segmentation itself. For example, in the case of one letter occupying one byte of storage space, for the word segmentation "kitty", its word suffixes include "y", "ty", "tty", "itty", and "kitty". Again, the word suffixes with too short byte lengths are quite different from the word segmentation itself, and have less distinguishing features. For example, the word suffixes "y" and "ty" of "kitty" include "y" and "ty" in many words, so the word suffixes extracted have little meaning, and thus the byte length of the extracted word suffixes can be limited to be not less than a preset byte length.
[0153] Optionally, in some embodiments, the step "the server extracts at least one word suffix from the word segmentation based on the bytes of the word segmentation" can include:
[0154] The server extracts at least one word suffix from the word segmentation based on the bytes of the word segmentation, and the byte length of the word suffix is not less than a preset byte length.
[0155] The preset byte length can be set according to actual conditions, and the embodiment is not limited in this regard. For example, the preset byte length can be set according to the byte length of the word segmentation itself. For a word segmentation with a relatively long byte length, the preset byte length can be set to be relatively large, and for a word segmentation with a relatively small byte length, the preset byte length can be set to be relatively small.
[0156] 203、the server obtains a document identifier corresponding to the word suffix, and the document corresponding to the document identifier contains the word suffix.
[0157] 204、the server establishes a mapping relationship between the word segmentation and the document identifier to obtain a mapping relationship pair of the word segmentation.
[0158] Optionally, in some embodiments, the step of "the server establishes a mapping relationship between the word segmentation and the document identifier, and obtains a mapping relationship pair of the word segmentation" can include:
[0159] fusing the document identifiers corresponding to each word suffix of the word segmentation, and obtaining a document identifier set corresponding to the word segmentation;
[0160] establishing a mapping relationship between the word segmentation and the document identifier set, and obtaining a mapping relationship pair of the word segmentation.
[0161] In the process of the step of "fusing the document identifiers corresponding to each word suffix of the word segmentation, and obtaining a document identifier set corresponding to the word segmentation", the document identifiers corresponding to each word suffix can be sequentially added to the document identifier set. The document identifiers in the document identifier set can be sorted based on the byte length of the word suffix and the relevance of the document corresponding to the document identifier to the word suffix.
[0162] In this embodiment, in the step of "establishing a mapping relationship between the word segmentation and the document identifier set, and obtaining a mapping relationship pair of the word segmentation", based on the mapping relationship pair of each word segmentation, a mapping relationship table between the word segmentation and the document identifier set can be established.
[0163] Specifically, the mapping relationship table can be an inverted index table of the word segmentation, that is, taking the word segmentation as the key (key) and taking the document identifier set corresponding to the word segmentation as the value (value), the inverted index is stored in the form of key-value, and the key-values are sequentially arranged according to the key. For example, for the case of English words as the word segmentation, the words can be arranged in alphabetical order.
[0164] 205、the server stores the mapping relationship pair corresponding to each word segmentation in the multi-level storage area according to a preset arrangement order of the word segmentation.
[0165] Optionally, the step of "storing the mapping relationship pair corresponding to each word segmentation in the multi-level storage area according to a preset arrangement order of the word segmentation" can include:
[0166] determining a current storage area in the multi-level storage area that needs to store the mapping relationship pair;
[0167] storing the mapping relationship pair corresponding to each word segmentation in the current storage area according to a preset arrangement order of the word segmentation;
[0168] when the current storage area meets a preset condition, storing the mapping relationship pair stored in the current storage area in a next level storage area of the current storage area;
[0169] The next level storage area is taken as the current storage area, and the step of storing the mapping relationship pair corresponding to each word in the next level storage area of the current storage area is returned to.
[0170] In some embodiments, the multi-level storage area can include memory and a disk, and the files in the disk are divided into multiple levels, i.e., level 0, level 1, level 2, and so on. Level 0 of the disk can be regarded as the next level storage area of the memory, level 1 can be regarded as the next level storage area of level 0, and level 2 can be regarded as the next level storage area of level 1, and so on.
[0171] In the step of determining the current storage area in which the mapping relationship pair needs to be stored from the multi-level storage area, the current storage area can be the memory. In the step of storing the mapping relationship pair corresponding to each word in the current storage area according to the preset arrangement order of each word, the arrangement order of each word can be determined based on the byte value of the word, and the key-value pair corresponding to each word can be stored in the memory based on the arrangement order of each word. The key-values in the memory are sequentially arranged according to the byte sequence. When the memory meets the preset condition, the key-value pairs stored in the memory can be data-persisted to become files and stored in level 0 of the disk. The preset condition can be set according to actual conditions, and the present embodiment does not limit this. For example, the preset condition can be that the memory data reaches a set threshold, the system is restarted, or the time interval from the last persistence exceeds a set threshold, and so on.
[0172] Optionally, in the present embodiment, the files in the disk are divided into multiple levels, each level is composed of a plurality of files, and each file can store a key-value list data of a continuous key range, wherein the continuous key range is the key stored according to the preset arrangement order. Each persisted file is composed of a plurality of key / value pairs, and the different key / values in the file are sequentially arranged according to the byte sequence, and the byte value of the key is taken as the sorting value. For the level 0 file, there is an overlap between the files in the key range, but there is no overlap in the key range in the level 0. For the non-level 0 file, the files in each level have the characteristics of "order between files and order inside the file". Specifically, the key range of each file in each level has no overlap, the files are sequentially arranged, and the key-values inside the file are also sequentially arranged.
[0173] Specifically, when the memory meets the preset condition, the key-value pairs stored in the memory are persisted as files in the level 0 of the disk; as the number of the level 0 files increases, when the number of the files increases to meet the preset condition, part of the level 0 files can be merged into the level 1, and the files in the level 1 keep the ordered characteristics between the files and inside the files after the merging, that is, the level 0 is taken as a new current storage area, and the key-value pairs of the current storage area are stored in the next level storage area level 1. Similarly, when the number of the files of the level 1 and above increases to meet the preset condition, the files are also merged into the higher level in this way, that is, merged into the level 2.
[0174] Specifically, in some embodiments, referring to Figure 2b The word list after the word segmentation and the document identification information can be input, the word list contains at least one segmented word, the segmented word is expanded into a plurality of words according to the word suffix, and a mapping relationship pair between the segmented word and the document identification is established based on the correspondence between the expanded word suffix and the document identification information. The mapping relationship pair can be an inverted index item. Based on the inverted index item of the segmented word, the inverted index table of the memory is updated. The inverted index table is stored in the form of key-value in order, where the key is the keyword, and the value is the document list that hits the word. When the memory meets the preset condition, the key-value pairs stored in the memory can be data-persisted as files. The preset condition can be that the total size of the memory reaches a set threshold, the system is restarted, or the time interval from the last persistence exceeds a set threshold, and the like.
[0175] Optionally, in the embodiment, when it is needed to perform fuzzy matching on the to-be-fuzzy-matched word, the following steps can be performed, including:
[0176] Obtaining a to-be-fuzzy-matched word;
[0177] Determining a target segmented word from a preset word set based on the to-be-fuzzy-matched word, wherein the preset word set includes at least one segmented word, the word prefix of the target segmented word contains the to-be-fuzzy-matched word, and the word prefix of the first adjacent segmented word of the target segmented word does not contain the to-be-fuzzy-matched word;
[0178] Obtaining a target document identification corresponding to the target segmented word based on the target segmented word and a mapping relationship pair, wherein the document corresponding to the target document identification contains the target segmented word, and the mapping relationship pair includes the mapping relationship between the segmented word and the document identification;
[0179] Adding the target document identification to a fuzzy matching set of the to-be-fuzzy-matched word, wherein the fuzzy matching set includes the document identification matched by the to-be-fuzzy-matched word;
[0180] update the fuzzy match set based on the second adjacent wordpiece of the target wordpiece;
[0181] obtain the fuzzy match result of the word to be fuzzily matched based on the updated fuzzy match set.
[0182] wherein the word prefix can be a word obtained by intercepting the first byte to the jth byte of the wordpiece, j being a positive integer not greater than the byte length of the wordpiece. It should be noted that the word prefix of a wordpiece can include the wordpiece itself.
[0183] In this embodiment, the first adjacent wordpiece of the target wordpiece is the adjacent wordpiece in the first direction of the target wordpiece, where the first direction can be set according to actual conditions, and this embodiment does not limit this. For example, when the wordpieces in the preset word set are English words and the wordpieces are arranged in the order of letters, if the wordpieces are arranged in the order from a to z, the adjacent wordpiece in the first direction of the target wordpiece is the previous wordpiece of the target wordpiece, and if the wordpieces are arranged in the order from z to a, the adjacent wordpiece in the first direction of the target wordpiece is the next wordpiece of the target wordpiece.
[0184] In this embodiment, the word prefix of the target wordpiece contains the word to be fuzzily matched, and the word prefix of the first adjacent wordpiece of the target wordpiece does not contain the word to be fuzzily matched. Specifically, when the wordpieces in the preset word set are English words and the wordpieces are arranged in the order of letters from a to z, a certain wordpiece in the preset word set can be compared with the word to be fuzzily matched. If the word prefix of the wordpiece contains the word to be fuzzily matched, and the word prefix of the first adjacent wordpiece of the wordpiece does not contain the word to be fuzzily matched, the wordpiece is the target wordpiece. If the word prefix of the wordpiece does not contain the word to be fuzzily matched, it is determined whether to continue searching for the target wordpiece in the wordpieces before or after the wordpiece based on the first letter of the wordpiece and the arrangement order of the wordpieces in the preset word set. If the word prefix of the wordpiece contains the word to be fuzzily matched, but the word prefix of the first adjacent wordpiece of the wordpiece also contains the word to be fuzzily matched, the target wordpiece is continued to be searched in the wordpieces in the first direction of the wordpiece.
[0185] Optionally, in some embodiments, the step of "determining the target wordpiece from the preset word set based on the word to be fuzzily matched" can include:
[0186] determining the target wordpiece from the preset word set based on the word to be fuzzily matched by binary search.
[0187] In this embodiment, the step of "updating the fuzzy match set based on the second adjacent wordpiece of the target wordpiece" can include:
[0188] When the word prefix of the second adjacent wordpiece of the target wordpiece contains the word to be fuzzily matched, based on the mapping relationship pair, the document identifier corresponding to the second adjacent wordpiece of the target wordpiece is obtained;
[0189] The document identifier corresponding to the second adjacent wordpiece of the target wordpiece is added to the fuzzy matching set;
[0190] The second adjacent wordpiece of the target wordpiece is taken as a new target wordpiece, and the step of obtaining the document identifier corresponding to the second adjacent wordpiece of the target wordpiece based on the mapping relationship pair is executed until the word prefix of the second adjacent wordpiece of the target wordpiece does not contain the word to be fuzzily matched.
[0191] The second adjacent wordpiece of the target wordpiece is the second direction adjacent wordpiece of the target wordpiece, and the second direction is opposite to the first direction.
[0192] Optionally, in some embodiments, the step of obtaining the target document identifier corresponding to the target wordpiece based on the target wordpiece and the mapping relationship pair can include:
[0193] The mapping relationship pair corresponding to the target wordpiece is extracted from the multi-level storage area, and the target document identifier corresponding to the target wordpiece is obtained based on the extracted mapping relationship pair.
[0194] Optionally, the step of determining the target wordpiece from the preset word set based on the word to be fuzzily matched can include:
[0195] According to the preset arrangement order of the wordpiece in each level storage area of the multi-level storage area and the word to be fuzzily matched, the target wordpiece is determined from the preset word set of each level storage area.
[0196] The wordpiece in the preset word set is the key of the mapping relationship pair. The wordpieces in the preset word set in the memory are arranged in order according to the byte value of the wordpiece. The key range of the file inside the non-level 0 in the disk is non-overlapping, and the files are in order, and the keys inside the file are also in order. For the file of level 0 in the disk, there is a key range overlap between the files, but the keys inside the file are in order. For the level 0 layer in the disk, the target wordpiece needs to be determined in the preset word set in each file of level 0.
[0197] For example, for each level other than level 0 in the memory and the disk, a binary search can be directly used to query the target token in the memory, and a binary search can be directly used to query the target token in each level other than level 0 in the disk. For level 0 in the disk, since there is an overlap of key ranges between files in level 0, but the keys inside the files are in order, a binary search needs to be used for each file in level 0 to query the target token, and the fuzzy matching set is updated according to the second adjacent token and the target token of the target token in each file. Finally, the fuzzy matching set is updated based on the second adjacent token and the target token of the target token in each level in the memory and the disk, and the fuzzy matching result of the word to be fuzzily matched is obtained.
[0198] Optionally, in some embodiments, the fuzzy matching process separately retrieves the files in the memory and the disk to obtain a complete fuzzy matching result. Specifically, for the key / value list in the memory or the file in the persistent medium, the fuzzy matching process is performed on each of the key / value list and the file respectively and then combined, and a complete fuzzy matching result set is obtained. Wherein, the input word to be fuzzily matched is denoted as T, and the output is a document ID set S satisfying the fuzzy matching, and the fuzzy matching process is as follows:
[0199] 1. Find the first key / value having a common prefix with T by using a binary search;
[0200] 2. Deserializes the value to obtain a document ID list, and adds the list to set S;
[0201] 3. Traverse the adjacent next key / value, if the prefix of the key does not include T, go to step 4; otherwise, go back to step 2;
[0202] 4. Return the fuzzy matching result set S of the word to be fuzzily matched T.
[0203] Currently, the fuzzy matching schemes of search engines Lucene and Sphinx are relatively representative. The Lucene realizes the fuzzy matching in the following way: first, find the words satisfying the fuzzy matching by traversing the dictionary, and then read the inverted list of the words to obtain the result set. The Sphinx realizes the fuzzy matching in the following way: first, expand the words, then establish the inverted index of each word, and directly obtain the inverted list satisfying the fuzzy matching during the retrieval. However, the Lucene retrieval process needs to traverse the dictionary, and there is a problem of low retrieval efficiency due to the random IO reading. The Sphinx needs to expand O(N 2 ) words during the index establishment, and there are problems of storage space amplification and write amplification.
[0204] The text fuzzy matching method provided by the embodiment can expand a word segmentation into multiple words according to a suffix, and establish an inverted index for the words, where the inverted index is stored in the form of key-value, the key is a keyword, and the value is a document list that hits the word. The data of each key-value structure is arranged compactly, and multiple key-values are globally ordered according to the key and are persisted on a storage medium. When searching, the key-value with the user search text as the prefix is found through prefix matching, and the document list recorded in the value is merged, so that the fuzzy matching result that meets the search text can be quickly obtained. The algorithm space of the embodiment is amplified to O(n), the search efficiency is O(1), the storage amplification and random IO can be greatly reduced, and good search efficiency is achieved.
[0205] As can be seen from the above, the embodiment can perform word segmentation on an original text through a server to obtain at least one word segmentation of the original text; based on the bytes of the word segmentation, at least one word suffix is intercepted from the word segmentation; a document identifier corresponding to the word suffix is obtained, and a document corresponding to the document identifier contains the word suffix; a mapping relationship between the word segmentation and the document identifier is established to obtain a mapping relationship pair of the word segmentation; and according to a preset arrangement order of each word segmentation, the mapping relationship pair corresponding to the word segmentation is stored in a multi-level storage area. The application improves the search efficiency and greatly reduces the storage amplification by improving the fuzzy matching algorithm.
[0206] In order to better implement the above method, the embodiment of the application further provides a text fuzzy matching device, as shown in Figure 3a The text fuzzy matching device can include a first obtaining unit 301, a determining unit 302, a second obtaining unit 303, an adding unit 304, an updating unit 305, and a third obtaining unit 306, as follows:
[0207] (1) the first obtaining unit 301;
[0208] The first obtaining unit 301 is configured to obtain a word to be fuzzy matched.
[0209] (2) the determining unit 302;
[0210] The determining unit 302 is configured to determine a target word segmentation from a preset word set based on the word to be fuzzy matched, where the preset word set includes at least one word segmentation, the word prefix of the target word segmentation contains the word to be fuzzy matched, and the word prefix of the first adjacent word segmentation of the target word segmentation does not contain the word to be fuzzy matched.
[0211] (3) the second obtaining unit 303;
[0212] The second obtaining unit 303 is configured to obtain a target document identifier corresponding to the target segmented word based on the target segmented word and the mapping relationship pair, wherein the target document identifier corresponds to a document containing the target segmented word, and the mapping relationship pair comprises a mapping relationship between a segmented word and a document identifier.
[0213] (4) The adding unit 304;
[0214] The adding unit 304 is configured to add the target document identifier to a fuzzy matching set of the to-be-fuzzily-matched word, wherein the fuzzy matching set comprises document identifiers matched by the to-be-fuzzily-matched word.
[0215] (5) The updating unit 305;
[0216] The updating unit 305 is configured to update the fuzzy matching set based on a second adjacent segmented word of the target segmented word.
[0217] Optionally, in some embodiments of the present application, the updating unit 305 can comprise an obtaining subunit 3051, an adding subunit 3052, and a loop subunit 3053, as shown in Figure 3b as follows:
[0218] The obtaining subunit 3051 is configured to, when a word prefix of the second adjacent segmented word of the target segmented word contains the to-be-fuzzily-matched word, obtain a document identifier corresponding to the second adjacent segmented word of the target segmented word based on the mapping relationship pair.
[0219] The adding subunit 3052 is configured to add the document identifier corresponding to the second adjacent segmented word of the target segmented word to the fuzzy matching set.
[0220] The loop subunit 3053 is configured to take the second adjacent segmented word of the target segmented word as a new target segmented word, and return to execute the step of obtaining the document identifier corresponding to the second adjacent segmented word of the target segmented word based on the mapping relationship pair until the word prefix of the second adjacent segmented word of the target segmented word does not contain the to-be-fuzzily-matched word.
[0221] (6) The third obtaining unit 306;
[0222] The third obtaining unit 306 is configured to obtain a fuzzy matching result of the to-be-fuzzily-matched word based on the updated fuzzy matching set.
[0223] Optionally, in some embodiments of the present application, the text fuzzy matching apparatus can further comprise a segmented word unit 307, a cutting unit 308, a fourth obtaining unit 309, and an establishing unit 3010, as shown in Figure 3c as follows:
[0224] The word segmentation unit 307 is configured to perform word segmentation on the original text to obtain at least one word segmentation of the original text.
[0225] The intercepting unit 308 is configured to intercept at least one word suffix from the word segmentation based on the bytes of the word segmentation.
[0226] The fourth obtaining unit 309 is configured to obtain a document identifier corresponding to the word suffix, wherein a document corresponding to the document identifier contains the word suffix.
[0227] The establishing unit 3010 is configured to establish a mapping relationship between the word segmentation and the document identifier, to obtain a mapping relationship pair of the word segmentation.
[0228] Optionally, in some embodiments of the present application, the intercepting unit 308 can be specifically configured to intercept at least one word suffix from the word segmentation based on the bytes of the word segmentation, wherein the word suffix has a byte length not less than a preset byte length.
[0229] Optionally, in some embodiments of the present application, the establishing unit 3010 can include a fusion sub-unit 30101 and an establishing sub-unit 30102, as shown in Figure 3d as follows:
[0230] The fusion sub-unit 30101 is configured to fuse the document identifiers corresponding to the respective word suffixes of the word segmentation, to obtain a document identifier set corresponding to the word segmentation.
[0231] The establishing sub-unit 30102 is configured to establish a mapping relationship between the word segmentation and the document identifier set, to obtain a mapping relationship pair of the word segmentation.
[0232] Optionally, in some embodiments of the present application, the text fuzzy matching apparatus can further include a storage unit 3011, as shown in Figure 3e as follows:
[0233] The storage unit 3011 is configured to store the mapping relationship pairs corresponding to the respective word segmentations in a multi-level storage area according to a preset arrangement order of the word segmentations.
[0234] Optionally, in some embodiments of the present application, the second obtaining unit 303 can be specifically configured to extract the mapping relationship pair corresponding to the target word segmentation from the multi-level storage area, and obtain a target document identifier corresponding to the target word segmentation based on the extracted mapping relationship pair.
[0235] Optionally, in some embodiments of the present application, the storage unit 3011 can be specifically configured to determine a current storage area in which a mapping relationship pair needs to be stored from a plurality of storage areas; store the mapping relationship pair corresponding to each segmented word in the current storage area according to a preset arrangement order of the segmented words; when the current storage area meets a preset condition, store the mapping relationship pair stored in the current storage area in a next storage area of the current storage area; take the next storage area as the current storage area, and return to execute the step of storing the mapping relationship pair stored in the current storage area in the next storage area of the current storage area when the current storage area meets the preset condition.
[0236] Optionally, in some embodiments of the present application, the determination unit 302 can be specifically configured to determine a target segmented word from a preset word set of each storage area of the plurality of storage areas according to a preset arrangement order of the segmented words in each storage area of the plurality of storage areas and the to-be-fuzzily-matched word.
[0237] Optionally, in some embodiments of the present application, the determination unit 302 can be specifically configured to determine a target segmented word from a preset word set based on the to-be-fuzzily-matched word through binary search.
[0238] As can be seen from the above, in the embodiment, the first acquisition unit 301 acquires a to-be-fuzzily-matched word; the determination unit 302 determines a target segmented word from a preset word set based on the to-be-fuzzily-matched word, wherein the preset word set includes at least one segmented word, a word prefix of the target segmented word contains the to-be-fuzzily-matched word, and a word prefix of a first adjacent segmented word of the target segmented word does not contain the to-be-fuzzily-matched word; the second acquisition unit 303 acquires a target document identifier corresponding to the target segmented word based on the target segmented word and a mapping relationship pair, the target document identifier corresponds to a document containing the target segmented word, and the mapping relationship pair includes a mapping relationship between a segmented word and a document identifier; the adding unit 304 adds the target document identifier to a fuzzy matching set of the to-be-fuzzily-matched word, the fuzzy matching set includes document identifiers matched by the to-be-fuzzily-matched word; the updating unit 305 updates the fuzzy matching set based on a second adjacent segmented word of the target segmented word; and the third acquisition unit 306 acquires a fuzzy matching result of the to-be-fuzzily-matched word based on the updated fuzzy matching set. The present application can improve the retrieval efficiency by improving the fuzzy matching algorithm.
[0239] The present application also provides an electronic device, as shown in Figure 4 The present application also provides an electronic device, as shown in
[0240] The electronic device can include a processor 401 having one or more processing cores, a memory 402 having one or more computer-readable storage media, a power supply 403, and an input unit 404, etc. Those skilled in the art can understand that Figure 4 The electronic device structure shown in the figure is not a limitation on the electronic device, and can include more or fewer components than shown, or combine certain components, or different component arrangements. Among them:
[0241] The processor 401 is the control center of the electronic device, which connects various parts of the entire electronic device through various interfaces and lines, and performs various functions of the electronic device and processes data by running or executing software programs and / or modules stored in the memory 402, and calling data stored in the memory 402. Optionally, the processor 401 can include one or more processing cores; preferably, the processor 401 can integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface, and application program, etc., and the modem processor mainly processes wireless communication. It can be understood that the above-mentioned modem processor can also not be integrated into the processor 401.
[0242] The memory 402 can be used to store software programs and modules, and the processor 401 executes various function applications and data processing by running the software programs and modules stored in the memory 402. The memory 402 can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, at least one application program required by a function (such as a sound playing function, an image playing function, etc.), etc.; the data storage area can store data created according to the use of the electronic device, etc. In addition, the memory 402 can include a high-speed random access memory, and can also include a non-volatile memory, such as at least one magnetic disk storage device, a flash memory device, or other volatile solid-state memory device. Accordingly, the memory 402 can also include a memory controller to provide access for the processor 401 to the memory 402.
[0243] The electronic device also includes a power supply 403 for powering various components, and preferably the power supply 403 can be logically connected to the processor 401 through a power management system, so as to realize functions such as management of charging, discharging, and power consumption management through the power management system. The power supply 403 can also include one or more direct current or alternating current power supplies, a recharging system, a power supply failure detection circuit, a power supply converter or inverter, a power supply state indicator, etc. Any component.
[0244] The electronic device can also include an input unit 404, which can be used to receive input digital or character information, and generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function control.
[0245] Although not shown, the electronic device can further include a display unit and the like, which will not be described herein. Specifically, in the present embodiment, the processor 401 in the electronic device will load the executable file corresponding to the process of one or more application programs into the memory 402 according to the following instructions, and run the application program stored in the memory 402 by the processor 401, thereby realizing various functions, as follows:
[0246] obtaining a to-be-fuzzy-matching word; determining a target segmented word from a preset word set based on the to-be-fuzzy-matching word, wherein the preset word set includes at least one segmented word, a word prefix of the target segmented word contains the to-be-fuzzy-matching word, and a word prefix of a first adjacent segmented word of the target segmented word does not contain the to-be-fuzzy-matching word; obtaining a target document identifier corresponding to the target segmented word based on the target segmented word and a mapping relationship pair, wherein a document corresponding to the target document identifier contains the target segmented word, and the mapping relationship pair includes a mapping relationship between a segmented word and a document identifier; adding the target document identifier to a fuzzy matching set of the to-be-fuzzy-matching word, wherein the fuzzy matching set includes document identifiers matched by the to-be-fuzzy-matching word; updating the fuzzy matching set based on a second adjacent segmented word of the target segmented word; and obtaining a fuzzy matching result of the to-be-fuzzy-matching word based on the updated fuzzy matching set.
[0247] The specific implementation of each operation above can refer to the foregoing embodiments, which will not be described herein.
[0248] As can be seen from the above, the present embodiment can obtain a to-be-fuzzy-matching word; determine a target segmented word from a preset word set based on the to-be-fuzzy-matching word, wherein the preset word set includes at least one segmented word, a word prefix of the target segmented word contains the to-be-fuzzy-matching word, and a word prefix of a first adjacent segmented word of the target segmented word does not contain the to-be-fuzzy-matching word; obtain a target document identifier corresponding to the target segmented word based on the target segmented word and a mapping relationship pair, wherein a document corresponding to the target document identifier contains the target segmented word, and the mapping relationship pair includes a mapping relationship between a segmented word and a document identifier; add the target document identifier to a fuzzy matching set of the to-be-fuzzy-matching word, wherein the fuzzy matching set includes document identifiers matched by the to-be-fuzzy-matching word; update the fuzzy matching set based on a second adjacent segmented word of the target segmented word; and obtain a fuzzy matching result of the to-be-fuzzy-matching word based on the updated fuzzy matching set. Through the improvement of the fuzzy matching algorithm, the present application can improve the retrieval efficiency.
[0249] Those skilled in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructions, or by relevant hardware controlled by the instructions, which can be stored in a computer readable storage medium and loaded and executed by a processor.
[0250] To this end, an embodiment of the present application provides a storage medium, in which a plurality of instructions are stored, the instructions being capable of being loaded by a processor to execute steps in any of the text fuzzy matching methods provided by the embodiments of the present application. For example, the instructions can execute the following steps:
[0251] obtaining a word to be fuzzily matched; determining a target word piece from a preset word piece set based on the word to be fuzzily matched, wherein the preset word piece set comprises at least one word piece, a word prefix of the target word piece contains the word to be fuzzily matched, and a word prefix of a first adjacent word piece of the target word piece does not contain the word to be fuzzily matched; obtaining a target document identifier corresponding to the target word piece based on the target word piece and a mapping relationship pair, wherein a document corresponding to the target document identifier contains the target word piece, and the mapping relationship pair comprises a mapping relationship between a word piece and a document identifier; adding the target document identifier to a fuzzy matching set of the word to be fuzzily matched, wherein the fuzzy matching set comprises document identifiers matched by the word to be fuzzily matched; updating the fuzzy matching set based on a second adjacent word piece of the target word piece; and obtaining a fuzzy matching result of the word to be fuzzily matched based on the updated fuzzy matching set.
[0252] The specific implementation of each operation can refer to the foregoing embodiments, which will not be described here again.
[0253] The storage medium can include a read-only memory (ROM), a random access memory (RAM), a magnetic disk, an optical disk, etc.
[0254] Since the instructions stored in the storage medium can execute steps in any of the text fuzzy matching methods provided by the embodiments of the present application, the beneficial effects that can be achieved by any of the text fuzzy matching methods provided by the embodiments of the present application can be achieved, which are described in detail in the foregoing embodiments and will not be described here again.
[0255] The foregoing has described in detail a text fuzzy matching method and device provided by an embodiment of the present application, and the principle and implementation manner of the present application have been described by applying specific examples; the foregoing description of the embodiments is only used to help understand the method of the present application and its core idea; meanwhile, for those skilled in the art, the specific implementation manner and application range can be changed according to the idea of the present application; and in view of the foregoing, the content of the specification should not be understood as limiting the present application.
Claims
1. A method of fuzzy matching of text, characterized by, The method comprises the following steps: obtaining a to-be-fuzzy-matching word; determining a target word from a preset word set based on the to-be-fuzzy-matching word, wherein the preset word set comprises at least one word, the word prefix of the target word contains the to-be-fuzzy-matching word, and the word prefix of the first adjacent word of the target word does not contain the to-be-fuzzy-matching word, the words in the preset word set are sorted in a preset manner, and the word prefix is a word obtained by intercepting the first byte to the jth byte of a word, j being a positive integer not greater than the byte length of the intercepted word; obtaining a target document identifier corresponding to the target word based on the target word and a mapping relationship pair, wherein the document corresponding to the target document identifier contains the target word, and the mapping relationship pair comprises the mapping relationship between the word and the document identifier; adding the target document identifier to a fuzzy matching set of the to-be-fuzzy-matching word, wherein the fuzzy matching set comprises the document identifiers matched by the to-be-fuzzy-matching word; updating the fuzzy matching set based on the second adjacent word of the target word; obtaining a fuzzy matching result of the to-be-fuzzy-matching word based on the updated fuzzy matching set; wherein the obtaining process of the mapping relationship pair comprises: performing word segmentation processing on an original text to obtain at least one word of the original text; intercepting at least one word suffix from the word based on the byte of the word; obtaining a document identifier corresponding to the word suffix, wherein the document corresponding to the document identifier contains the word suffix; fusing the document identifiers corresponding to each word suffix of the word to obtain a document identifier set corresponding to the word, wherein the document identifiers corresponding to each word suffix of the word are sequentially added to the document identifier set, and the document identifiers corresponding to each word suffix of the word are contained in the document identifier set; establishing a mapping relationship between the word and the document identifier set to obtain the mapping relationship pair of the word.
2. The method of claim 1, wherein, The updating of the fuzzy matching set based on the second adjacent word of the target word comprises: when the word prefix of the second adjacent word of the target word contains the to-be-fuzzy-matching word, obtaining the document identifier corresponding to the second adjacent word of the target word based on the mapping relationship pair; adding the document identifier corresponding to the second adjacent word of the target word to the fuzzy matching set; taking the second adjacent word of the target word as a new target word, returning to execute the step of obtaining the document identifier corresponding to the second adjacent word of the target word based on the mapping relationship pair until the word prefix of the second adjacent word of the target word does not contain the to-be-fuzzy-matching word.
3. The method of claim 1, wherein, The intercepting of at least one word suffix from the word based on the byte of the word comprises: intercepting at least one word suffix from the word based on the byte of the word, wherein the byte length of the word suffix is not less than a preset byte length.
4. The method of claim 1, wherein, After the establishment of the mapping relationship between the word and the document identifier set to obtain the mapping relationship pair of the word, the method further comprises: storing the mapping relationship pair corresponding to each word in a multi-level storage area according to a preset arrangement order of the words. The target document identifier corresponding to the target word segmentation is obtained based on the target word segmentation and the mapping relationship pair, and the target document identifier corresponds to a document containing the target word segmentation. The mapping relationship pair corresponding to the target word segmentation is extracted from the multi-level storage area, and the target document identifier corresponding to the target word segmentation is obtained based on the extracted mapping relationship pair.
5. The method of claim 4, wherein, The mapping relationship pair corresponding to each word segmentation is stored in the multi-level storage area according to the preset arrangement order of the word segmentation. A current storage area in which the mapping relationship pair needs to be stored is determined from the multi-level storage area. The mapping relationship pair corresponding to each word segmentation is stored in the current storage area according to the preset arrangement order of the word segmentation. When the current storage area meets a preset condition, the mapping relationship pair stored in the current storage area is stored in a next-level storage area of the current storage area. The next-level storage area is taken as the current storage area, and the step of storing the mapping relationship pair stored in the current storage area in the next-level storage area of the current storage area when the current storage area meets the preset condition is returned to be executed.
6. The method of claim 4, wherein, The target word segmentation is determined from the preset word set based on the word to be fuzzily matched. The target word segmentation is determined from the preset word set based on the word to be fuzzily matched.
7. The method of claim 1, wherein, The target word segmentation is determined from the preset word set based on the word to be fuzzily matched through binary search. It comprises:
8. A text fuzzy matching apparatus, characterized by, The first acquisition unit is used for acquiring a word to be fuzzily matched. The determination unit is used for determining a target word segmentation from a preset word set based on the word to be fuzzily matched, wherein the preset word set comprises at least one word segmentation, the word prefix of the target word segmentation contains the word to be fuzzily matched, and the word prefix of the first adjacent word segmentation of the target word segmentation does not contain the word to be fuzzily matched, the word segmentations in the preset word set are sorted in a preset manner, and the word prefix is a word obtained by intercepting the first byte to the jth byte of the word segmentation, j being a positive integer not greater than the byte length of the intercepted word segmentation. The second acquisition unit is used for obtaining a target document identifier corresponding to the target word segmentation based on the target word segmentation and a mapping relationship pair, the target document identifier corresponding to a document containing the target word segmentation, and the mapping relationship pair comprising a mapping relationship between the word segmentation and the document identifier. The adding unit is used for adding the target document identifier to a fuzzy matching set of the word to be fuzzily matched, and the fuzzy matching set comprises document identifiers matched by the word to be fuzzily matched. The updating unit is used for updating the fuzzy matching set based on the second adjacent word segmentation of the target word segmentation. The third acquisition unit is used for obtaining a fuzzy matching result of the word to be fuzzily matched based on the updated fuzzy matching set. The word segmentation unit is used for performing word segmentation processing on an original text to obtain at least one word segmentation of the original text. The intercepting unit is used for intercepting at least one word suffix from the word segmentation based on the byte of the word segmentation. A fourth obtaining unit, configured to obtain a document identifier corresponding to the word suffix, wherein a document corresponding to the document identifier contains the word suffix; An establishing unit, configured to fuse the document identifiers corresponding to the word suffixes of the segmented word to obtain a document identifier set corresponding to the segmented word, wherein the document identifiers corresponding to the word suffixes of the segmented word are sequentially added to the document identifier set, and the document identifiers corresponding to the word suffixes of the segmented word are contained in the document identifier set; and a mapping relationship between the segmented word and the document identifier set is established to obtain a mapping relationship pair of the segmented word.
9. An electronic device, comprising: An apparatus, comprising a memory and a processor; the memory stores a plurality of instructions, and the processor loads the instructions to perform the steps in the text fuzzy matching method of any one of claims 1 to 7.
10. A storage medium, characterized by A storage medium, wherein a computer program is stored on the storage medium, and the computer program is executed by a processor to implement the steps in the text fuzzy matching method of any one of claims 1 to 7.
Citation Information
Patent Citations
Method and device for displaying target text
CN108363682A
Data storage method, terminal equipment and computer readable storage medium
CN110597855A