Text retrieval method, system and equipment and storage medium
The ant colony algorithm is used to establish and differentiate the ant colony, and calculate the pheromone matrix for path optimization, solving the problem of low accuracy caused by the difference between search terms and text in the text search device, achieving more efficient and accurate text retrieval.
Patent Information
- Application Number
- CN202510417449.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-03
- Publication Date
- 2025-08-15
AI Technical Summary
In the prior art, the text search device causes differences between the search terms and the text in the text to be searched through literal matching, resulting in low search accuracy.
Ant colony algorithm is used to obtain the first keyword sequence and the first preset index library of the text to be retrieved, ant colony is established, and differentiated it, calculate the pheromone matrix, and perform path optimization to improve retrieval efficiency and hit rate.
The most suitable search keywords are selected through the ant colony algorithm, which improves the accuracy and efficiency of text retrieval.
Smart Images

Figure CN120492605A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field related to text retrieval, and in particular to a text retrieval method, system, device and storage medium. Background Art
[0002] As the amount of information and data increases, users have higher and higher expectations and requirements for the ability to retrieve and extract information from text. For example, users expect to be able to directly obtain the exact related information corresponding to the search term through retrieval or search.
[0003] In the related art, a text retrieval device for performing text retrieval can obtain text corresponding to a search term from a text to be retrieved by literal matching.
[0004] However, there may be certain differences between the search terms and the texts corresponding to the search terms in the text to be retrieved, which leads to the disadvantage of low accuracy of text retrieval. Summary of the Invention
[0005] The present invention aims to at least solve the technical problems existing in the prior art. To this end, the present invention provides a text retrieval method, system, device and storage medium, which can improve retrieval efficiency and retrieval hit rate.
[0006] A first aspect of the present invention provides a text retrieval method comprising the following steps:
[0007] Obtaining a first keyword sequence and a first preset index library of the text to be retrieved;
[0008] Establishing an ant colony based on a first keyword and a second keyword, wherein the first keyword is a keyword to be searched in the first keyword sequence contained in a search text, the second keyword is a second keyword to be searched in the first keyword sequence not contained in the search text, and the first preset index library contains the search text;
[0009] Differentiating the ant colony to obtain a differentiated ant colony;
[0010] The ant colony after differentiation performs pheromone calculation by using an ant colony algorithm to obtain a pheromone matrix;
[0011] Path optimization is performed according to the pheromone matrix to obtain a search result of the text to be searched.
[0012] The control method according to the embodiment of the present invention has at least the following beneficial effects:
[0013] The method obtains a first keyword sequence and a first preset index library of a text to be retrieved; establishes an ant colony based on the first keyword and the second keyword, wherein the first keyword is the keyword to be retrieved in the first keyword sequence contained in the retrieval text, and the second keyword is the second keyword to be retrieved in the first keyword sequence not contained in the retrieval text, and the first preset index library contains the retrieval text; differentiates the ant colony to obtain a differentiated ant colony; performs pheromone calculation on the differentiated ant colony using an ant colony algorithm to obtain a pheromone matrix; performs path optimization based on the pheromone matrix to obtain a retrieval result of the text to be retrieved. The present application selects the text that best matches the retrieval keyword through the ant colony algorithm, thereby improving the retrieval efficiency and the retrieval hit rate.
[0014] According to some embodiments of the present invention, obtaining a first keyword sequence and a first preset index library of the text to be searched includes:
[0015] Obtain the original keyword sequence of the text to be retrieved and the original index library containing all texts;
[0016] Differentiating the original keyword sequence into a second keyword sequence for which text must be retrieved and a first keyword sequence for which text must not be retrieved;
[0017] The text of the original index library is screened according to the second keyword sequence to obtain the first preset index library.
[0018] According to some embodiments of the present invention, the dividing the original keyword sequence into a second keyword sequence for which text must be retrieved and a first keyword sequence for which text does not need to be retrieved comprises:
[0019] Determine the word frequency of each keyword in the original keyword sequence in the text to be searched;
[0020] Obtaining, for each keyword in the original keyword sequence, the number of first texts containing the keyword in the original index library;
[0021] Calculating a ratio value based on the number of the first texts and the total number of texts in the original index library;
[0022] Calculate the corresponding weight value of each keyword according to the proportion value and the word frequency corresponding to each keyword;
[0023] According to the weight value and a preset screening threshold, the original keyword sequence is divided into a second keyword sequence for which text must be retrieved and a first keyword sequence for which text does not need to be retrieved.
[0024] According to some embodiments of the present invention, screening the text of the original index library according to the second keyword sequence to obtain the first preset index library includes:
[0025] The texts containing all the keywords in the second keyword sequence in the original index library are filtered out to obtain the first preset index library.
[0026] According to some embodiments of the present invention, the ant colony algorithm is used to calculate pheromone after differentiation, and the calculation formula of the pheromone matrix is obtained as follows:
[0027]
[0028] τ ij (t+1)=(1-ρ)τ ij (t)+Δτ ij
[0029]
[0030] in, is the probability of the kth ant in the tth generation moving from city i to city j, ω is the importance of pheromone, is the relative importance of the heuristic factor, τ ij (t) is the pheromone from city i to city j in the tth generation of ants, n ij (t) is the inspiration factor from city i to city j in the tth generation of ants, J k (i) is the city that ant k can currently choose, d ij (t) is the distance from city i to city j, △τ ij is the sum of pheromones left by m ant pairs on the path from city i to city j, is the pheromone left by the kth ant on the path from city i to city j, Q is the total pheromone of the kth ant, ρ is the pheromone dilution degree with a value between 0 and 1, L k is the total distance of the path traveled by the kth ant.
[0031] According to some embodiments of the present invention, performing path optimization according to the pheromone matrix to obtain the search result of the text to be searched includes:
[0032] Perform path optimization according to the pheromone matrix to obtain the optimal path and all other paths;
[0033] Calculation is performed based on the optimal path, all other paths, and a preset ratio to obtain a search result for the text to be searched.
[0034] According to some embodiments of the present invention, the step of differentiating the ant colony to obtain a differentiated ant colony includes:
[0035] Differentiating the first keyword into a positive ant colony and differentiating the second keyword into a negative ant colony;
[0036] Differentiation is performed based on the positive ant colony and the negative ant colony to obtain the differentiated ant colony.
[0037] A second aspect of the present invention provides a text retrieval system, the text retrieval system comprising:
[0038] A data acquisition module, configured to acquire a first keyword sequence and a first preset index library of a text to be retrieved;
[0039] an ant colony establishing module, configured to establish an ant colony based on a first keyword and a second keyword, wherein the first keyword is a keyword to be searched in the first keyword sequence contained in a search text, the second keyword is a second keyword to be searched in the first keyword sequence not contained in the search text, and the first preset index library contains the search text;
[0040] An ant colony differentiation module, used for differentiating the ant colony to obtain a differentiated ant colony;
[0041] a pheromone calculation module, configured to calculate pheromones using an ant colony algorithm according to the differentiated ant colony to obtain a pheromone matrix;
[0042] The retrieval result output module is used to perform path optimization according to the pheromone matrix to obtain the retrieval result of the text to be retrieved.
[0043] This system obtains a first keyword sequence and a first preset index library of a text to be retrieved; establishes an ant colony based on the first keyword and the second keyword, wherein the first keyword is the keyword to be retrieved in the first keyword sequence contained in the retrieval text, the second keyword is the second keyword to be retrieved in the first keyword sequence not contained in the retrieval text, and the first preset index library contains the retrieval text; differentiates the ant colony to obtain a differentiated ant colony; performs pheromone calculation on the differentiated ant colony using an ant colony algorithm to obtain a pheromone matrix; performs path optimization based on the pheromone matrix to obtain a retrieval result of the text to be retrieved. This application uses the ant colony algorithm to select the text that best matches the retrieval keyword, thereby improving retrieval efficiency and retrieval hit rate.
[0044] According to a third aspect of the present invention, a text retrieval electronic device is provided, comprising at least one control processor and a memory for communicating with the at least one control processor; the memory stores instructions that can be executed by the at least one control processor, and the instructions are executed by the at least one control processor to enable the at least one control processor to execute the above-mentioned text retrieval method.
[0045] According to a fourth aspect of the present invention, a computer-readable storage medium is provided. The computer-readable storage medium stores computer-executable instructions, and the computer-executable instructions are used to enable a computer to execute the above-mentioned text retrieval method.
[0046] It should be noted that the beneficial effects between the second to fourth aspects of the present invention and the prior art are the same as the beneficial effects between the above-mentioned text retrieval system and the prior art, and will not be described in detail here.
[0047] Additional aspects and advantages of the present invention will be set forth in part in the description which follows and, in part, will be obvious from the description which follows, or may be learned by practice of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] The above and / or additional aspects and advantages of the present invention will become apparent and readily understood from the following description of the embodiments with reference to the accompanying drawings, in which:
[0049] Figure 1 is a flow chart of a text retrieval method according to an embodiment of the present invention;
[0050] Figure 2 is a schematic structural diagram of an embodiment of a text retrieval system provided by this application;
[0051] Figure 3 It is a structural diagram of an embodiment of the electronic device provided by this application. DETAILED DESCRIPTION
[0052] The following describes embodiments of the present invention in detail. Examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are intended only to explain the present invention and are not to be construed as limiting the present invention.
[0053] In the description of the present invention, if there is a description of first, second, etc., it is only for the purpose of distinguishing technical features, and cannot be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features or implicitly indicating the order of the indicated technical features.
[0054] In the description of the present invention, it should be understood that descriptions involving orientation, such as the orientation or positional relationship indicated by up, down, etc., are based on the orientation or positional relationship shown in the accompanying drawings, and are only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as a limitation on the present invention.
[0055] In the description of the present invention, it should be noted that, unless otherwise clearly defined, terms such as setting, installing, and connecting should be understood in a broad sense, and technicians in the relevant technical field can reasonably determine the specific meanings of the above terms in the present invention based on the specific content of the technical solution.
[0056] As the amount of information and data increases, users have higher and higher expectations and requirements for the ability to retrieve and extract information from text. For example, users expect to be able to directly obtain the exact related information corresponding to the search term through retrieval or search.
[0057] In the related art, a text retrieval device for performing text retrieval can obtain text corresponding to a search term from a text to be retrieved by literal matching.
[0058] However, there may be certain differences between the search terms and the texts corresponding to the search terms in the text to be retrieved, which leads to the disadvantage of low accuracy of text retrieval.
[0059] In order to solve the above technical defects, the embodiments of the present application provide a text retrieval method, system, device and storage medium.
[0060] See Figure 1 , is a flow chart of a text retrieval method provided by an embodiment of the present application, the method is applied to an electronic device, which may be a server, etc. Figure 1 As shown, the text retrieval method includes:
[0061] Step S101: Obtain a first keyword sequence and a first preset index library of a text to be searched;
[0062] Step S102: establishing an ant colony based on a first keyword and a second keyword, wherein the first keyword is a keyword to be searched in a first keyword sequence included in a search text, the second keyword is a second keyword to be searched in the first keyword sequence not included in the search text, and the first preset index library includes the search text;
[0063] Step S103: Differentiate the ant colony to obtain a differentiated ant colony;
[0064] Step S104: pheromone calculation is performed based on the differentiated ant colony using an ant colony algorithm to obtain a pheromone matrix;
[0065] Step S105: Optimize the path according to the pheromone matrix to obtain the search result of the text to be searched.
[0066] Specifically, the first keyword sequence and the first preset index library of the text to be searched obtained in the above step S101 can be:
[0067] Keyword extraction: Extracting keywords from text; this can be achieved through various algorithms, such as:
[0068] Supervised keyword extraction: keyword extraction is regarded as a binary classification problem, which requires well-labeled training corpus to train the model.
[0069] Semi-supervised keyword extraction: Only a small amount of training data is required, and then the model is used to extract keywords from new text and perform manual filtering.
[0070] Unsupervised method: This method does not require manually annotated corpus, and uses certain methods to discover important words in the text as keywords.
[0071] Choose an appropriate keyword extraction algorithm: For Chinese text, common algorithms include TF-IDF, TextRank, and Word2Vec word clustering. TF-IDF calculates word weights by calculating word frequency (TF) and inverse document frequency (IDF). TextRank, based on PageRank, uses a co-occurrence window to construct a keyword.
[0072] The method obtains a first keyword sequence and a first preset index library of a text to be retrieved; establishes an ant colony based on the first keyword and the second keyword, wherein the first keyword is the keyword to be retrieved in the first keyword sequence contained in the retrieval text, and the second keyword is the second keyword to be retrieved in the first keyword sequence not contained in the retrieval text, and the first preset index library contains the retrieval text; differentiates the ant colony to obtain a differentiated ant colony; performs pheromone calculation on the differentiated ant colony using an ant colony algorithm to obtain a pheromone matrix; performs path optimization based on the pheromone matrix to obtain a retrieval result of the text to be retrieved. The present application selects the text that best matches the retrieval keyword through the ant colony algorithm, thereby improving the retrieval efficiency and the retrieval hit rate.
[0073] In some embodiments, searching the first keyword sequence and the first preset index library of the text in step S101 includes:
[0074] Step S201: Obtain the original keyword sequence of the text to be searched and the original index library containing all texts;
[0075] Step S202: The original keyword sequence is divided into a second keyword sequence for which the text must be searched and a first keyword sequence for which the text does not need to be searched;
[0076] Step S203: Screen the text of the original index library according to the second keyword sequence to obtain a first preset index library.
[0077] Specifically, this embodiment divides the keywords into a second keyword sequence that must be included in the retrieved text and a first keyword sequence that the text does not necessarily include, and screens the original index library to filter out the text containing all the keywords in the second keyword sequence to obtain the first preset index library, thereby improving the accuracy of the retrieval.
[0078] In some embodiments, in step S202, the original keyword sequence is divided into a second keyword sequence for which text must be retrieved and a first keyword sequence for which text does not need to be retrieved, including:
[0079] Step S301: determining the word frequency of each keyword in the original keyword sequence in the text to be searched;
[0080] Step S302: Obtain, for each keyword in the original keyword sequence, the number of first texts containing the keyword in the original index library;
[0081] Step S303: Calculate a ratio value based on the number of first texts and the total number of texts in the original index library;
[0082] Step S304: Calculate the corresponding weight value of each keyword according to its corresponding proportion value and word frequency;
[0083] Step S305 : Based on the weight value and the preset screening threshold, the original keyword sequence is divided into a second keyword sequence for which the text must be searched and a first keyword sequence for which the text does not need to be searched.
[0084] Specifically, this embodiment calculates the corresponding weight value of each keyword based on its corresponding proportion value and word frequency, and divides the original keyword sequence into a second keyword sequence that the text must be retrieved and a first keyword sequence that the text does not need to be retrieved through the weight value and the preset screening threshold, thereby improving the accuracy of the data and thus improving the accuracy and efficiency of the retrieval.
[0085] In some embodiments, in step S203, the text of the original index library is screened according to the second keyword sequence to obtain a first preset index library, including:
[0086] Step S401: Filter out texts containing all keywords in the second keyword sequence in the original index library to obtain a first preset index library.
[0087] Specifically, this embodiment improves the accuracy and efficiency of retrieval by screening out texts containing all the keywords in the second keyword sequence in the original index library.
[0088] In some embodiments, in step S104, pheromone calculation is performed based on the differentiated ant colony using an ant colony algorithm, and the calculation formula for the pheromone matrix is:
[0089]
[0090] τ ij (t+1)=(1-ρ)τ ij (t)+Δτ ij
[0091]
[0092] in, is the probability of the kth ant in the tth generation moving from city i to city j, ω is the importance of pheromone, is the relative importance of the heuristic factor, τ ij (t) is the pheromone from city i to city j in the tth generation of ants, n ij (t) is the inspiration factor from city i to city j in the tth generation of ants, J k (i) is the city that ant k can currently choose, d ij (t) is the distance from city i to city j, △τ ij is the sum of pheromones left by m ant pairs on the path from city i to city j, is the pheromone left by the kth ant on the path from city i to city j, Q is the total pheromone of the kth ant, ρ is the pheromone dilution degree with a value between 0 and 1, L k is the total distance of the path traveled by the kth ant.
[0093] According to some embodiments of the present invention, in step S105, path optimization is performed based on the pheromone matrix to obtain a search result for the text to be searched, including:
[0094] Step S501: Optimize the path according to the pheromone matrix to obtain the optimal path and all other paths;
[0095] Step S502: Calculate based on the optimal path, all other paths and the preset ratio to obtain the search result of the text to be searched.
[0096] According to some embodiments of the present invention, in step S103, differentiating the ant colony to obtain a differentiated ant colony includes:
[0097] Step S601: Differentiate the first keyword into a positive ant colony and the second keyword into a negative ant colony;
[0098] Step S602: Differentiate the positive ant colony and the negative ant colony to obtain a differentiated ant colony.
[0099] Specifically, to facilitate understanding by those skilled in the art, a set of best embodiments are provided below:
[0100] 1. Data Acquisition
[0101] Obtain the first keyword sequence and the first preset index library of the text to be searched, specifically:
[0102] Obtain the original keyword sequence of the text to be retrieved and the original index library containing all texts;
[0103] The original keyword sequence is divided into a second keyword sequence that the text must be searched for and a first keyword sequence that the text does not need to be searched for, specifically:
[0104] Determine the word frequency of each keyword in the original keyword sequence in the text to be searched;
[0105] Obtain, for each keyword in the original keyword sequence, the number of first texts containing the keyword in the original index library;
[0106] Calculate a ratio value based on the number of first texts and the total number of texts in the original index library;
[0107] Calculate the corresponding weight value of each keyword based on its corresponding proportion value and word frequency;
[0108] According to the weight value and the preset screening threshold, the original keyword sequence is divided into a second keyword sequence for which the text must be retrieved and a first keyword sequence for which the text does not need to be retrieved.
[0109] The text of the original index library is filtered according to the second keyword sequence to obtain the first preset index library, which is specifically:
[0110] The texts containing all the keywords in the second keyword sequence in the original index library are filtered out to obtain a first preset index library.
[0111] 2. Ant colony establishment:
[0112] An ant colony is established based on a first keyword and a second keyword, wherein the first keyword is a keyword to be searched in a first keyword sequence contained in a search text, the second keyword is a second keyword to be searched in the first keyword sequence not contained in the search text, and the first preset index library contains the search text.
[0113] 3. Ant colony differentiation:
[0114] The ant colony is differentiated to obtain the differentiated ant colony, specifically:
[0115] Differentiate the first keyword into a positive ant colony and the second keyword into a negative ant colony;
[0116] Differentiation is performed based on the positive ant colony and the negative ant colony to obtain the differentiated ant colony.
[0117] 4. Pheromone Matrix Calculation:
[0118] According to the ant colony algorithm after differentiation, the pheromone matrix is obtained by calculating the pheromone through the ant colony algorithm. The calculation formula of the pheromone matrix is as follows:
[0119]
[0120] τ ij (t+1)=(1-ρ)τ ij (t)+Δτ ij
[0121]
[0122] in, is the probability of the kth ant in the tth generation moving from city i to city j, ω is the importance of pheromone, is the relative importance of the heuristic factor, τ ij (t) is the pheromone from city i to city j in the tth generation of ants, n ij (t) is the inspiration factor from city i to city j in the tth generation of ants, J k (i) is the city that ant k can currently choose, d ij (t) is the distance from city i to city j, △τ ij is the sum of pheromones left by m ant pairs on the path from city i to city j, is the pheromone left by the kth ant on the path from city i to city j, Q is the total pheromone of the kth ant, ρ is the pheromone dilution degree with a value between 0 and 1, L k is the total distance of the path traveled by the kth ant.
[0123] 5. Text retrieval:
[0124] Optimize the path based on the pheromone matrix to obtain the search results of the text to be searched, specifically:
[0125] Perform path optimization according to the pheromone matrix to obtain the optimal path and all other paths;
[0126] Calculation is performed based on the optimal path, all other paths, and a preset ratio to obtain a search result for the text to be searched.
[0127] In addition, refer to Figure 2 One embodiment of the present invention provides a text retrieval system, including a data acquisition module 1100, an ant colony establishment module 1200, an ant colony differentiation module 1300, a pheromone calculation module 1400, and a retrieval result output module 1500, wherein:
[0128] The data acquisition module 1100 is used to acquire a first keyword sequence and a first preset index library of the text to be searched;
[0129] The ant colony establishment module 1200 is configured to establish an ant colony based on a first keyword and a second keyword, wherein the first keyword is a keyword to be searched in a first keyword sequence included in a search text, the second keyword is a second keyword to be searched in the first keyword sequence not included in the search text, and the first preset index library includes the search text;
[0130] The ant colony differentiation module 1300 is used to differentiate the ant colony to obtain a differentiated ant colony;
[0131] The pheromone calculation module 1400 is used to calculate pheromones using an ant colony algorithm based on the differentiated ant colony to obtain a pheromone matrix;
[0132] The search result output module 1500 is used to perform path optimization according to the pheromone matrix to obtain the search result of the text to be searched.
[0133] This system obtains a first keyword sequence and a first preset index library of a text to be retrieved; establishes an ant colony based on the first keyword and the second keyword, wherein the first keyword is the keyword to be retrieved in the first keyword sequence contained in the retrieval text, the second keyword is the second keyword to be retrieved in the first keyword sequence not contained in the retrieval text, and the first preset index library contains the retrieval text; differentiates the ant colony to obtain a differentiated ant colony; performs pheromone calculation on the differentiated ant colony using an ant colony algorithm to obtain a pheromone matrix; performs path optimization based on the pheromone matrix to obtain a retrieval result of the text to be retrieved. This application uses the ant colony algorithm to select the text that best matches the retrieval keyword, thereby improving retrieval efficiency and retrieval hit rate.
[0134] It should be noted that this system embodiment and the above-mentioned method embodiment are based on the same inventive concept, so the relevant content of the above-mentioned method embodiment is also applicable to this system embodiment and will not be repeated here.
[0135] Figure 3 A schematic diagram of the hardware structure of text retrieval provided in an embodiment of the present application is shown.
[0136] The text retrieval device may include a processor 301 and a memory 302 storing computer program instructions.
[0137] Specifically, the processor 301 may include a central processing unit (CPU), or an application-specific integrated circuit (ASIC), or may be configured to implement one or more integrated circuits of the embodiments of the present application.
[0138] The memory 302 may include a large capacity memory for data or instructions. By way of example and not limitation, the memory 302 may include a hard disk drive (HDD), a floppy disk drive, a flash memory, an optical disk, a magneto-optical disk, a magnetic tape, or a universal serial bus (USB) drive, or a combination of two or more of these. Where appropriate, the memory 302 may include removable or non-removable (or fixed) media. Where appropriate, the memory 302 may be inside or outside the integrated gateway disaster recovery device. In a specific embodiment, the memory 302 is a non-volatile solid-state memory.
[0139] In some embodiments, the memory 302 may include read-only memory (ROM), random access memory (RAM), magnetic disk storage media devices, optical storage media devices, flash memory devices, electrical, optical, or other physical / tangible memory storage devices. Thus, generally, the memory includes one or more tangible (non-transitory) computer-readable storage media (e.g., memory devices) encoded with software including computer-executable instructions, and when the software is executed (e.g., by one or more processors), it is operable to perform the operations described with reference to the method according to an aspect of the present disclosure.
[0140] The processor 301 implements any one of the text retrieval methods in the above embodiments by reading and executing computer program instructions stored in the memory 302 .
[0141] In one example, the text retrieval device may further include a communication interface 303 and a bus 310. Figure 3 As shown, the processor 301 , the memory 302 , and the communication interface 303 are connected via a bus 310 and communicate with each other.
[0142] The communication interface 303 is mainly used to implement communication between various modules, devices, units and / or equipment in the embodiments of the present application.
[0143] Bus 310 comprises hardware, software or both, and the parts of text retrieval device are coupled to each other.For example, and not limitation, bus can comprise accelerated graphics port (AGP) or other graphics bus, enhanced industry standard architecture (EISA) bus, front side bus (FSB), hypertransport (HT) interconnection, industry standard architecture (ISA) bus, infinite bandwidth interconnection, low pin count (LPC) bus, memory bus, micro channel architecture (MCA) bus, peripheral component interconnection (PCI) bus, PCI-Express (PCI-X) bus, serial advanced technology attachment (SATA) bus, video electronics standard association local (VLB) bus or other suitable bus or two or more above these combinations.In suitable situation, bus 310 can comprise one or more buses.Although the present application embodiment describes and shows specific bus, the application considers any suitable bus or interconnection.
[0144] The text retrieval device can execute the text retrieval method in the embodiment of the present application based on the three-dimensional design model, thereby realizing the combination of Figure 1 and Figure 2 Described text retrieval method and system.
[0145] In addition, in conjunction with the text retrieval method in the above embodiments, the present application embodiment may provide a computer storage medium for implementation. The computer storage medium stores computer program instructions; when the computer program instructions are executed by a processor, any one of the text retrieval methods in the above embodiments is implemented.
[0146] It should be understood that the present application is not limited to the specific configurations and processes described above and illustrated in the figures. For the sake of brevity, a detailed description of known methods is omitted here. In the above embodiments, several specific steps are described and illustrated as examples. However, the method process of the present application is not limited to the specific steps described and illustrated. Those skilled in the art can make various changes, modifications, and additions, or change the order of the steps after understanding the spirit of the present application.
[0147] The functional blocks shown in the above block diagram can be implemented as hardware, software, firmware or a combination thereof. When implemented in hardware, they can be, for example, electronic circuits, application specific integrated circuits (ASICs), appropriate firmware, plug-ins, function cards, etc. When implemented in software, the elements of the present application are programs or code segments that are used to perform the required tasks. Programs or code segments can be stored in machine-readable media, or transmitted on a transmission medium or a communication link by a data signal carried in a carrier wave. "Machine-readable media" can include any medium capable of storing or transmitting information. Examples of machine-readable media include electronic circuits, semiconductor memory devices, ROMs, flash memories, erasable ROMs (EROMs), floppy disks, CD-ROMs, optical disks, hard disks, optical fiber media, radio frequency (RF) links, etc. The code segments can be downloaded via computer networks such as the Internet, intranets, etc.
[0148] It should also be noted that the exemplary embodiments mentioned in this application describe some methods or systems based on a series of steps or devices. However, this application is not limited to the order of the above steps. In other words, the steps can be performed in the order mentioned in the embodiments, or in a different order, or several steps can be performed simultaneously.
[0149] Aspects of the present disclosure have been described above with reference to the flowcharts and / or block diagrams of the methods, devices (systems) and computer program products according to the embodiments of the present disclosure. It should be understood that each box in the flowchart and / or block diagram and the combination of each box in the flowchart and / or block diagram can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer or other programmable data processing device to produce a machine so that these instructions executed by the processor of the computer or other programmable data processing device enable the implementation of the function / action specified in one or more boxes of the flowchart and / or block diagram. Such a processor can be, but is not limited to, a general-purpose processor, a special-purpose processor, a special application processor or a field programmable logic circuit. It is also understood that each box in the block diagram and / or flowchart and the combination of the boxes in the block diagram and / or flowchart can also be implemented by dedicated hardware that performs the specified function or action, or can be implemented by a combination of dedicated hardware and computer instructions.
[0150] The above description is only a specific embodiment of the present application. Those skilled in the art will clearly understand that for the convenience and brevity of description, the specific working processes of the systems, modules and units described above can refer to the corresponding processes in the aforementioned method embodiments, and will not be repeated here. It should be understood that the scope of protection of the present application is not limited thereto. Any person skilled in the art can easily think of various equivalent modifications or replacements within the technical scope disclosed in the present application, and these modifications or replacements should be included in the scope of protection of the present application.
Claims
1. A text retrieval method, characterized in that: The text retrieval method comprises: Obtaining a first keyword sequence and a first preset index library of the text to be retrieved; Establishing an ant colony based on a first keyword and a second keyword, wherein the first keyword is a keyword to be searched in the first keyword sequence contained in a search text, the second keyword is a second keyword to be searched in the first keyword sequence not contained in the search text, and the first preset index library contains the search text; Differentiating the ant colony to obtain a differentiated ant colony; The ant colony after differentiation performs pheromone calculation by using an ant colony algorithm to obtain a pheromone matrix; Path optimization is performed according to the pheromone matrix to obtain a search result of the text to be searched.
2. A text retrieval method according to claim 1, characterized in that: The step of obtaining a first keyword sequence and a first preset index library of the text to be retrieved includes: Obtain the original keyword sequence of the text to be retrieved and the original index library containing all texts; Differentiating the original keyword sequence into a second keyword sequence for which text must be retrieved and a first keyword sequence for which text must not be retrieved; The text of the original index library is screened according to the second keyword sequence to obtain the first preset index library.
3. A text retrieval method according to claim 2, characterized in that: The step of dividing the original keyword sequence into a second keyword sequence for which text must be retrieved and a first keyword sequence for which text must not be retrieved comprises: Determine the word frequency of each keyword in the original keyword sequence in the text to be searched; Obtaining, for each keyword in the original keyword sequence, the number of first texts containing the keyword in the original index library; Calculating a ratio value based on the number of the first texts and the total number of texts in the original index library; Calculate the corresponding weight value of each keyword according to the proportion value and the word frequency corresponding to each keyword; According to the weight value and a preset screening threshold, the original keyword sequence is divided into a second keyword sequence for which text must be retrieved and a first keyword sequence for which text does not need to be retrieved.
4. A text retrieval method according to claim 2, characterized in that: The step of screening the text of the original index library according to the second keyword sequence to obtain the first preset index library includes: The texts containing all the keywords in the second keyword sequence in the original index library are filtered out to obtain the first preset index library.
5. A text retrieval method according to claim 2, characterized in that: The ant colony after differentiation performs pheromone calculation using the ant colony algorithm, and the calculation formula of the pheromone matrix is obtained as follows: t ij (t+1)=(1-ρ)τ ij (t)+Δτ ij in, is the probability of the kth ant in the tth generation moving from city i to city j, ω is the importance of pheromone, θ is the relative importance of the heuristic factor, τ ij (t) is the pheromone from city i to city j in the tth generation of ants, n ij (t) is the inspiration factor from city i to city j in the tth generation of ants, J k (i) is the city that ant k can currently choose, d ij (t) is the distance from city i to city j, △τ ij is the sum of pheromones left by m ant pairs on the path from city i to city j, is the pheromone left by the kth ant on the path from city i to city j, Q is the total pheromone of the kth ant, ρ is the pheromone dilution degree with a value between 0 and 1, L k is the total distance of the path traveled by the kth ant.
6. A text retrieval method according to claim 1, characterized in that: The performing path optimization according to the pheromone matrix to obtain the search result of the text to be searched includes: Perform path optimization according to the pheromone matrix to obtain the optimal path and all other paths; Calculation is performed based on the optimal path, all other paths, and a preset ratio to obtain a search result for the text to be searched.
7. A text retrieval method according to claim 1, characterized in that: The step of differentiating the ant colony to obtain a differentiated ant colony comprises: Differentiating the first keyword into a positive ant colony and differentiating the second keyword into a negative ant colony; Differentiation is performed based on the positive ant colony and the negative ant colony to obtain the differentiated ant colony.
8. A text retrieval system, characterized in that: The text retrieval system comprises: A data acquisition module, configured to acquire a first keyword sequence and a first preset index library of a text to be retrieved; an ant colony establishing module, configured to establish an ant colony based on a first keyword and a second keyword, wherein the first keyword is a keyword to be searched in the first keyword sequence contained in a search text, the second keyword is a second keyword to be searched in the first keyword sequence not contained in the search text, and the first preset index library contains the search text; An ant colony differentiation module, used for differentiating the ant colony to obtain a differentiated ant colony; a pheromone calculation module, configured to calculate pheromones using an ant colony algorithm according to the differentiated ant colony to obtain a pheromone matrix; The retrieval result output module is used to perform path optimization according to the pheromone matrix to obtain the retrieval result of the text to be retrieved.
9. A text retrieval device, characterized in that: It includes at least one control processor and a memory for communicating with the at least one control processor; the memory stores instructions that can be executed by the at least one control processor, and the instructions are executed by the at least one control processor to enable the at least one control processor to execute a text retrieval method as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, and the computer-executable instructions are used to enable a computer to execute the text retrieval method according to any one of claims 1 to 7.