A method and apparatus for ranking documents
By segmenting the query statement and building an offline thesaurus, and ranking documents based on the density evaluation of fragments, the problem of inaccurate recall results in the prior art is solved, and higher recall accuracy is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- BEIJING XUEZHITU NETWORK TECH
- Filing Date
- 2022-03-24
- Publication Date
- 2026-06-05
AI Technical Summary
In existing technologies, using the distance between two adjacent words in a query statement within a document as a density evaluation criterion leads to inaccurate recall results.
By segmenting the query statement into words, an offline vocabulary is established, the score of segment matching is determined, and the value of the first parameter is determined based on a preset mapping relationship, which is used to sort candidate documents.
The accuracy of the recall results has been improved by scoring and filtering fragments based on their density features within the document, thus solving the problem of inaccurate recall results.
Smart Images

Figure CN114625859B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of information retrieval, and in particular to a method and apparatus for sorting documents. Background Technology
[0002] Elasticsearch (ES) is a distributed, highly scalable, and real-time search and data analysis engine that can be used to search various documents. One of the most crucial aspects of document search using ES is recall. Recall refers to the process of efficiently retrieving a set of candidate documents related to the input query. Current technologies suffer from inaccurate recall results due to using the distance between two adjacent words in the query as a measure of closeness. Summary of the Invention
[0003] The purpose of this application is to provide a document sorting method and apparatus, which solves the technical problem in the prior art where the recall results are inaccurate due to using the distance between two adjacent words in a query statement in a document as a density evaluation criterion. The specific technical solution is as follows:
[0004] In a first aspect of this application, a document sorting method is provided, the method comprising: performing word segmentation on a query statement to obtain N segments; determining M segments matching the N segments from a preset offline vocabulary, and scores corresponding to the M segments respectively; wherein the offline vocabulary includes multiple target candidate segments and scores corresponding to the multiple target candidate segments, N is a positive integer, and M is a positive integer less than or equal to N; determining first parameter values corresponding to the M segments based on the scores corresponding to the M segments respectively and a preset mapping relationship; wherein the preset mapping relationship is used to characterize the mapping relationship between the scores of the segments and the first parameter, and the first parameter value is used to characterize the matching of words separated by parameter value distances with the query segment; and sorting multiple candidate documents based on the M segments and the first parameter value.
[0005] In a second aspect of this application, a document sorting apparatus is also provided. The apparatus includes: a first processing module for segmenting a query statement into N segments; a first determining module for determining M segments matching the N segments from a preset offline vocabulary, and scores corresponding to the M segments respectively; wherein the offline vocabulary includes multiple target candidate segments and scores corresponding to the multiple target candidate segments, N is a positive integer, and M is a positive integer less than or equal to N; a second determining module for determining first parameter values corresponding to the M segments based on the scores corresponding to the M segments and a preset mapping relationship; wherein the preset mapping relationship is used to characterize the mapping relationship between the scores of the segments and the first parameter, and the first parameter value is used to characterize the matching of words separated by parameter value distances with the query segment; and a sorting module for sorting multiple candidate documents based on the M segments and the first parameter value.
[0006] In a third aspect of this application, an electronic device is also provided, including a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus; the memory is used to store computer programs; and the processor is used to implement the steps of the method described in the first aspect when executing the program stored in the memory.
[0007] In a fourth aspect of this application, a computer-readable storage medium is also provided, wherein instructions are stored therein, which, when executed on a computer, cause the computer to perform the document sorting method described in the first aspect above.
[0008] This application can be applied to the field of information retrieval to optimize ES recall results. The document sorting method and apparatus provided in this application involve: segmenting a query statement into N segments; determining M segments matching the N segments from a preset offline vocabulary, along with scores corresponding to each of the M segments; wherein the offline vocabulary includes multiple target candidate segments and scores corresponding to the multiple target candidate segments, where N is a positive integer and M is a positive integer less than or equal to N; determining first parameter values corresponding to the M segments based on their scores and a preset mapping relationship; wherein the preset mapping relationship characterizes the mapping relationship between the segment scores and the first parameter, and the first parameter value characterizes the matching of words separated by a parameter value distance with the query segment; and sorting multiple candidate documents based on the M segments and the first parameter value. In other words, by establishing an offline vocabulary to evaluate the density of words in the document library and matching them with the query word, this solves the technical problem in the prior art where the distance between two adjacent words in the query statement in the document is used as the density evaluation standard, resulting in inaccurate recall results. Attached Figure Description
[0009] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the accompanying drawings used in the description of the embodiments or the prior art will be briefly introduced below.
[0010] Figure 1 This is one of the flowcharts for document sorting methods in the embodiments of this application;
[0011] Figure 2 This is the second flowchart of the document sorting method in the embodiments of this application;
[0012] Figure 3 This is the third flowchart of the document sorting method in the embodiments of this application;
[0013] Figure 4 This is the fourth flowchart of the document sorting method in the embodiments of this application;
[0014] Figure 5 This is the fifth flowchart of the document sorting method in the embodiments of this application;
[0015] Figure 6 This is a flowchart illustrating an example of a document sorting method in this application.
[0016] Figure 7 This is one of the schematic diagrams of the document sorting device in the embodiments of this application;
[0017] Figure 8 This is a second schematic diagram of the document sorting device structure in the embodiments of this application;
[0018] Figure 9 This is the third schematic diagram of the document sorting device structure in the embodiments of this application;
[0019] Figure 10 This is the fourth schematic diagram of the document sorting device structure in the embodiments of this application;
[0020] Figure 11 This is the fifth schematic diagram of the document sorting device structure in the embodiments of this application;
[0021] Figure 12 This is a schematic diagram of the structure of the electronic device in the embodiments of this application. Detailed Implementation
[0022] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0023] In the following description, suffixes such as "module" and "unit" used to denote elements are used only for the purposes of this application and have no specific meaning in themselves. Therefore, "module" and "component" can be used interchangeably.
[0024] The technical solutions of the embodiments of this application will be described below with reference to the accompanying drawings. The embodiments of this application provide a document sorting method, such as... Figure 1 As shown, the method includes the following steps:
[0025] Step 102: Perform word segmentation on the query statement to obtain N segments;
[0026] It should be noted that word segmentation refers to the process of recombining a continuous sequence of characters into a semantically independent sequence of words according to certain rules. This includes word segmentation methods based on string matching, word segmentation methods based on understanding, and word segmentation methods based on statistics. N is a positive integer. A segment can refer to a word or a single character. In an example, the query "knowledge graph" is segmented to obtain two segments: "knowledge" and "graph".
[0027] Step 104: Determine M segments that match N segments from a preset offline vocabulary list, and the scores corresponding to each of the M segments; wherein, the offline vocabulary list includes multiple target candidate segments and the scores corresponding to the multiple target candidate segments, N is a positive integer, and M is a positive integer less than or equal to N;
[0028] It should be noted that the segments in the offline vocabulary are determined based on documents in the offline document library, and are scored according to the characteristics of the corresponding segments.
[0029] Step 106: Determine the first parameter value corresponding to each of the M segments based on their respective scores and a preset mapping relationship; wherein, the preset mapping relationship is used to characterize the mapping relationship between the scores of the segments and the first parameter, and the first parameter value is used to characterize the matching of words separated by parameter values with the segment to be queried;
[0030] It's important to note that the first parameter value refers to the slop value when performing phrase matching in Elasticsearch. Phrase matching is used to match documents containing the correct order of phrase occurrences without any other phrases inserted between them. In Elasticsearch, phrase matching is performed using Domain Specific Language (DSL) statements. Elasticsearch provides a complete query DSL based on JSON to define queries. In the first example, using "knowledge graph" for phrase matching requires that "graph" appear one position after "knowledge" in the matched document; documents containing only "graph knowledge" cannot be matched. The slop value depends on the minimum number of word shifts required to obtain the query phrase; a smaller slop value indicates higher phrase density and a higher score. In the second example, when the query phrase is "solution," with the first parameter value of 1, "solution" is obtained by shifting one word... The word "solution" can be obtained by using the second word, so "solution" can match the query segment; in the third example, when the query segment is "knowledge graph", the document must contain the segment "knowledge graph" for a match to be made when the first parameter value is 0; mapping refers to the relationship between elements in two sets of elements; in the fourth example, the score corresponding to the segment "knowledge graph" is 10, the score corresponding to the segment "knowledge construction graph" is 5, the first parameter value corresponding to the segment "knowledge graph" determined by the preset mapping relationship is 1, and the first parameter value corresponding to the segment "knowledge construction graph" determined by the preset mapping relationship is 2.
[0031] Step 108: Sort multiple candidate documents based on M fragments and the first parameter value.
[0032] Through steps 102 to 108 of this embodiment, the query statement is segmented to obtain N segments; M segments matching the N segments are determined from a preset offline vocabulary, along with scores corresponding to each of the M segments; wherein the offline vocabulary includes multiple target candidate segments and scores corresponding to the multiple target candidate segments, N is a positive integer, and M is a positive integer less than or equal to N; the first parameter value corresponding to the M segments is determined based on the scores corresponding to the M segments and a preset mapping relationship; wherein the preset mapping relationship is used to characterize the mapping relationship between the segment score and the first parameter, and the first parameter value is used to characterize the matching of words separated by parameter value distance with the query segment; multiple candidate documents are sorted based on the M segments and the first parameter value; that is, by establishing an offline vocabulary to evaluate the density of words in the document library and match them with the query words, the technical problem of inaccurate recall results caused by using the distance between two adjacent words in the query statement in the document as the density evaluation standard in the prior art is solved.
[0033] In an optional embodiment of this application, before determining the M segments that match the N segments from a preset offline vocabulary, and the scores corresponding to the M segments, in step 104 of this application, as follows: Figure 2 As shown, it includes:
[0034] Step 202: Obtain the offline document library;
[0035] Step 204: Perform word segmentation on the documents in the offline document library to obtain the first word segmentation result, which includes multiple candidate segments;
[0036] It should be noted that word segmentation of a document refers to converting continuous sentences into a set of Chinese words, which can be done using a word segmenter; the first word segmentation result is obtained by combining several adjacent Chinese words.
[0037] Step 206: Calculate the scores corresponding to the multiple candidate segments;
[0038] It should be noted that calculating multiple candidate segments refers to performing offline segment mining on documents in the document library, scoring the segments based on their features, and storing them in an offline vocabulary.
[0039] Step 208: Select multiple target candidate segments from multiple candidate segments whose scores are greater than the first preset threshold.
[0040] It should be noted that the first preset threshold can be set according to user needs or the scores of candidate segments. In one example, if the density of segments with scores below 5 is too low, where density refers to the closeness between candidate segments, then the first preset threshold can be set to 5, and only candidate segments with scores above 5 can be selected as target candidate segments.
[0041] As can be seen, the document sorting method provided in this application sorts and filters documents based on the density characteristics of fragments in offline documents, which not only considers the distance of fragments in the document, but also improves the accuracy of recall.
[0042] The document sorting method provided in this application embodiment involves calculating scores for multiple candidate segments in step 206, such as... Figure 3 As shown, it includes:
[0043] Step 302: Calculate the first feature value corresponding to the candidate segment based on the mutual information between points;
[0044] It should be noted that inter-point mutual information is a statistical measure used to measure the strength of the correlation between two specific events; the larger the value of inter-point mutual information, the stronger the correlation between the two events, and the smaller the value of inter-point mutual information, the weaker the correlation between the two events.
[0045] Step 304: Calculate the second feature value corresponding to the candidate fragment based on information entropy;
[0046] It should be noted that information entropy is a measure of information content. The higher the information entropy on both sides of a segment, the greater the information content on both sides of the segment, the richer the words that can be combined on both sides of the segment, and the closer it is to a phrase that can be used independently.
[0047] Step 306: Calculate the third feature value corresponding to the candidate segment based on word frequency;
[0048] It should be noted that word frequency refers to the number of times a particular segment appears in a document. The credibility of a segment can be determined by examining its word frequency. The higher the frequency of a segment, the higher the probability that the words and characters in the segment can be used as fixed collocations, and the more credible it is.
[0049] Step 308: Calculate the fourth feature value corresponding to the candidate segment based on inverse document frequency;
[0050] It should be noted that the inverse document frequency (IVF), also known as the inverse document frequency, is the reciprocal of the document frequency.
[0051] Step 310: Determine the score corresponding to the candidate segment based on the first feature value, the second feature value, the third feature value, and the fourth feature value.
[0052] It should be noted that the first, second, third, and fourth feature values are normalized to the same order of magnitude, and the normalized first, second, third, and fourth feature values are added together to obtain the score corresponding to the candidate segment.
[0053] As can be seen, the document sorting method provided in this application sorts documents based on inter-point mutual information, information entropy, word frequency, and inverse document frequency to score the density of segments in the document, making the recall results of ES more accurate.
[0054] The document sorting method provided in this application embodiment, step 302, which involves calculating the first feature value corresponding to the candidate segment based on inter-point mutual information, includes:
[0055] The first feature value corresponding to the candidate fragment is calculated using the following formula:
[0056] PMI(x,y)=P(y|x) / P(x);
[0057] Where x and y are phrases in the candidate fragments, PMI refers to the probability of y appearing when x appears; P(y|x) refers to the probability of x and y appearing together; P(x) refers to the probability of x appearing.
[0058] As can be seen, the document sorting method provided in this application embodiment can calculate the inter-point mutual information between segments using a formula to determine whether two segments are sufficiently close together.
[0059] The document sorting method provided in this application embodiment, including step 304 which involves calculating the second feature value corresponding to the candidate segment based on information entropy, includes:
[0060] The second feature value corresponding to the candidate fragment is calculated using the following formula, where the second feature value is E. L and E R The smaller value in:
[0061]
[0062]
[0063] Among them, E L This refers to left entropy, E R 'z' refers to right entropy; 'z' refers to the context of candidate phrase W; 'a' refers to the word to the left of candidate phrase W; 'b' refers to the word to the right of candidate phrase W; 'N' refers to missing context, 'aW' refers to missing preceding context, and 'Wb' refers to missing following context.
[0064] As can be seen, the document sorting method provided in this application embodiment can determine the information entropy of a fragment through a formula, and examine whether the fragment is independent and whether it is a commonly used phrase.
[0065] The document sorting method provided in this application embodiment, in step 310, involves determining the scores corresponding to candidate segments based on the first feature value, second feature value, third feature value, and fourth feature value, such as... Figure 4 As shown, it includes:
[0066] Step 402: Normalize the first eigenvalue, second eigenvalue, third eigenvalue, and fourth eigenvalue;
[0067] It should be noted that normalizing the first, second, third, and fourth eigenvalues means processing them into values of the same order of magnitude.
[0068] Step 404: Summing the normalized first feature value, the normalized second feature value, the normalized third feature value, and the normalized fourth feature value yields the score corresponding to the candidate segment.
[0069] As can be seen, the document sorting method provided in this application sorts documents based on inter-point mutual information, information entropy, word frequency, and inverse document frequency to score the density of segments in the document, making the recall results of ES more accurate.
[0070] The document sorting method provided in this application embodiment involves sorting multiple candidate documents based on M fragments and a first parameter value in step 108, such as... Figure 5 As shown, it includes:
[0071] Step 502: Select multiple candidate documents from multiple target documents; wherein, each candidate document includes M segments, and the first parameter value corresponding to each of the M segments is less than or equal to a preset threshold.
[0072] Step 504: Sort the multiple candidate documents based on the first parameter value.
[0073] It should be noted that the sorting can be such that candidate documents with larger first parameter values are sorted first, or candidate documents with larger first parameter values are sorted last.
[0074] As can be seen, the document sorting method provided in this application embodiment can obtain candidate documents with high to low or low to high density by setting query fragments and corresponding slop values.
[0075] In one exemplary embodiment of this application, the query statement for the document sorting method provided in this application embodiment is "knowledge graph," and the flowchart is as follows: Figure 7 As shown, the steps in this embodiment of the application include:
[0076] Step 601: Perform word segmentation on the query "knowledge graph" to obtain two segments: "knowledge" and "graph".
[0077] Step 602: Obtain the offline document library;
[0078] Step 603: Perform word segmentation on the documents in the offline document library to obtain the first word segmentation result, which includes "knowledge graph" and "knowledge construction graph".
[0079] Step 604: Based on the mutual information between points, calculate the first feature value of the candidate segment "knowledge graph" as 20 and the first feature value of the segment "knowledge construction graph" as 10;
[0080] Step 605: Calculate the second feature value of the candidate fragment "knowledge graph" based on information entropy. The value is 30, and the second feature value of the fragment "knowledge construction graph" is 15.
[0081] Step 606: Based on word frequency, the third feature value corresponding to the candidate segment "knowledge graph" is 30, and the third feature value corresponding to the candidate segment "knowledge construction graph" is 15;
[0082] Step 607: Calculate the fourth feature value of the candidate segment "knowledge graph" based on inverse document frequency. The fourth feature value of the candidate segment "knowledge construction graph" is 40.
[0083] Step 608: Normalize the first, second, third, and fourth feature values corresponding to the candidate fragment "knowledge graph" to obtain a normalized first feature value of 4, a normalized second feature value of 6, a normalized third feature value of 6, and a normalized fourth feature value of 8; normalize the first, second, third, and fourth feature values corresponding to the candidate fragment "knowledge construction graph" to obtain a normalized first feature value of 2, a normalized second feature value of 3, a normalized third feature value of 3, and a normalized fourth feature value of 4.
[0084] Step 609: Sum the normalized first feature value, normalized second feature value, normalized third feature value, and normalized fourth feature value to obtain the score corresponding to the candidate segment. The candidate segment "knowledge graph" scores 24, and the candidate segment "knowledge construction graph" scores 12.
[0085] Step 610: The first preset threshold is 10. Candidate segments "knowledge graph" and "knowledge construction graph" with scores greater than 10 are identified as target candidate segments.
[0086] Step 611: The segments that match the two segments "knowledge" and "graph" are the target candidate segments "knowledge graph" and "knowledge construction graph";
[0087] Step 612: Determine the first parameter value of the target candidate segment "knowledge graph" as 1 and the first parameter value of the target candidate segment "knowledge construction graph" as 2 through the preset mapping relationship;
[0088] Step 613: The smaller the value of the first parameter, the higher the ranking. In the recall results, documents containing the target candidate fragment "knowledge graph" are ranked ahead of documents containing the target candidate fragment "knowledge construction graph".
[0089] As can be seen, the document sorting method provided in this application can evaluate the density of words in the document library by establishing an offline thesaurus and match them with the query words, thereby solving the technical problem in the prior art that the recall results are inaccurate due to the use of the distance between two adjacent words in the query statement in the document as the density evaluation standard.
[0090] This application provides a document sorting device, such as... Figure 7 As shown, the device includes:
[0091] The first processing module 72 is used to perform word segmentation on the query statement to obtain N segments;
[0092] The first determining module 74 is used to determine M segments that match N segments from a preset offline vocabulary list, as well as the scores corresponding to the M segments respectively; wherein, the offline vocabulary list includes multiple target candidate segments and scores corresponding to the multiple target candidate segments, N is a positive integer, and M is a positive integer less than or equal to N;
[0093] The second determining module 76 is used to determine the first parameter value corresponding to the M segments based on the scores corresponding to the M segments and the preset mapping relationship; wherein, the preset mapping relationship is used to characterize the mapping relationship between the scores of the segments and the first parameter, and the first parameter value is used to characterize the matching of words separated by parameter value distance with the segment to be queried;
[0094] The sorting module 78 is used to sort multiple candidate documents based on M fragments and a first parameter value.
[0095] The document sorting apparatus provided in this application performs word segmentation on the query statement through a first processing module to obtain N segments; a first determining module determines M segments that match the N segments from a preset offline lexicon, as well as the scores corresponding to the M segments; wherein the offline lexicon includes multiple target candidate segments and scores corresponding to the multiple target candidate segments, N is a positive integer, and M is a positive integer less than or equal to N; a second determining module determines the first parameter value corresponding to the M segments based on the scores corresponding to the M segments and a preset mapping relationship; wherein the preset mapping relationship is used to characterize the mapping relationship between the segment score and the first parameter, and the first parameter value is used to characterize the matching of words separated by parameter value distance with the query segment; and a sorting module sorts multiple candidate documents based on the M segments and the first parameter value; that is, by establishing an offline lexicon to evaluate the density of words in the document library and match them with the query words, the technical problem of inaccurate recall results caused by using the distance between two adjacent words in the query statement in the document as the density evaluation standard in the prior art is solved.
[0096] This application provides a document sorting device, such as... Figure 8 As shown, the device also includes:
[0097] Module 82 is used to retrieve offline document libraries;
[0098] The second processing module 84 is used to perform word segmentation on the documents in the offline document library to obtain the first word segmentation result, wherein the first word segmentation result includes multiple candidate segments;
[0099] The third processing module 86 is used to calculate multiple candidate segments and obtain scores corresponding to each candidate segment.
[0100] The filtering module 88 is used to filter out multiple target candidate segments from multiple candidate segments whose scores are greater than a first preset threshold.
[0101] In optional embodiments of this application, the third processing module 86 provided in this application embodiment, such as Figure 9 As shown, it includes:
[0102] The first calculation unit 902 is used to calculate the first feature value corresponding to the candidate segment based on the mutual information between points;
[0103] The second calculation unit 904 is used to calculate the second feature value corresponding to the candidate fragment based on information entropy;
[0104] The third calculation unit 906 is used to calculate the third feature value corresponding to the candidate segment based on word frequency;
[0105] The fourth calculation unit 908 is used to calculate the fourth feature value corresponding to the candidate fragment based on the inverse document frequency;
[0106] The determining unit 910 is used to determine the score corresponding to the candidate segment based on the first feature value, the second feature value, the third feature value, and the fourth feature value.
[0107] In an optional embodiment of this application, the first calculation unit 902 provided in this application includes: a first calculation subunit, used to calculate the first feature value corresponding to the candidate fragment using the following formula:
[0108] PMI(x,y)=P(y|x) / P(x);
[0109] Where x and y are phrases in the candidate fragments, PMI refers to the probability of y appearing when x appears; P(y|x) refers to the probability of x and y appearing together; P(x) refers to the probability of x appearing.
[0110] In an optional embodiment of this application, the second calculation unit 904 provided in this application includes: a second calculation subunit, used to calculate a second feature value corresponding to a candidate fragment using the following formula, wherein the second feature value is E. L and E R The smaller value in:
[0111]
[0112]
[0113] Among them, E L This refers to left entropy, E R 'z' refers to right entropy; 'z' refers to the context of candidate phrase W; 'a' refers to the word to the left of candidate phrase W; 'b' refers to the word to the right of candidate phrase W; 'N' refers to missing context, 'aW' refers to missing preceding context, and 'Wb' refers to missing following context.
[0114] In optional embodiments of this application, the determining unit 910 provided in this application embodiment, such as Figure 10 As shown, it includes:
[0115] The first processing subunit 1002 is used to normalize the first feature value, the second feature value, the third feature value, and the fourth feature value;
[0116] The second processing subunit 1004 sums the normalized first feature value, the normalized second feature value, the normalized third feature value, and the normalized fourth feature value to obtain the score corresponding to the candidate segment.
[0117] In optional embodiments of this application, the sorting module 78 provided in this application embodiment, such as Figure 11 As shown, it includes:
[0118] The filtering unit 1102 is used to filter out multiple candidate documents from multiple target documents; wherein, the candidate documents include M fragments, and the first parameter value corresponding to the M fragments is less than or equal to a preset threshold.
[0119] The sorting unit 1104 is used to sort multiple candidate documents based on the first parameter value.
[0120] This application also provides an electronic device, such as... Figure 12 As shown, it includes a processor 1201, a communication interface 1202, a memory 1203, and a communication bus 1204. The processor 1201, the communication interface 1202, and the memory 1203 communicate with each other through the communication bus 1204.
[0121] Memory 1203 is used to store computer programs;
[0122] Processor 1201, when executing the program stored in memory 1203, implements... Figure 1 The methods and steps described, and their functions and effects Figure 1 The methods and steps are the same as those in the previous section, so they will not be repeated here.
[0123] The communication bus mentioned in the above terminal can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. This communication bus can be divided into address bus, data bus, control bus, etc. For ease of representation, Figure 12 The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.
[0124] The communication interface is used for communication between the aforementioned terminal and other devices.
[0125] The memory may include random access memory (RAM) or non-volatile memory, such as at least one disk storage device. Optionally, the memory may also be at least one storage device located remotely from the aforementioned processor.
[0126] The processors mentioned above can be general-purpose processors, including central processing units (CPUs), network processors (NPs), etc.; they can also be digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.
[0127] In another embodiment provided in this application, a computer-readable storage medium is also provided, which stores instructions that, when executed on a computer, cause the computer to perform any of the document sorting methods described in the above embodiments.
[0128] In another embodiment provided in this application, a computer program product containing instructions is also provided, which, when run on a computer, causes the computer to perform any of the document sorting methods described in the above embodiments.
[0129] In the above embodiments, implementation can be achieved entirely or partially through software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented entirely or partially in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid state disk (SSD)).
[0130] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0131] The various embodiments in this specification are described in a related manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, the system embodiments are basically similar to the method embodiments, so the description is relatively simple; relevant parts can be referred to the descriptions of the method embodiments.
[0132] The above description is merely a preferred embodiment of this application and is not intended to limit the scope of protection of this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application are included within the scope of protection of this application.
Claims
1. A method for sorting documents, characterized in that, include: The query statement is segmented into N segments; From a preset offline vocabulary, M segments matching the N segments are determined, along with scores corresponding to each of the M segments. The offline vocabulary includes multiple target candidate segments and scores corresponding to those segments, where N is a positive integer and M is a positive integer less than or equal to N. The target candidate segments are those with scores greater than a first preset threshold. The scores of the candidate segments are determined as follows: a first feature value is calculated based on inter-point mutual information; a second feature value is calculated based on information entropy; a third feature value is calculated based on word frequency; a fourth feature value is calculated based on inverse document frequency; and the score of the candidate segment is determined based on the first, second, third, and fourth feature values. The first parameter value corresponding to each of the M segments is determined based on the scores corresponding to the M segments and a preset mapping relationship. The preset mapping relationship characterizes the mapping relationship between the segment score and the first parameter value, and the first parameter value characterizes the matching of words separated by the parameter value distance with the query segment. The first parameter value refers to the slop value when using ES for phrase matching. The slop value depends on the minimum number of word moves required to obtain the query segment; a smaller slop value indicates higher segment density and a higher corresponding score. The multiple candidate documents are sorted based on the M fragments and the first parameter value.
2. The method according to claim 1, characterized in that, Before determining M segments that match the N segments from a preset offline vocabulary, and the scores corresponding to each of the M segments, the method further includes: Get offline document library; The documents in the offline document library are segmented into words to obtain a first segmentation result; wherein the first segmentation result includes the plurality of candidate segments; Calculate the scores corresponding to the multiple candidate segments to obtain scores for each of the multiple candidate segments; Select multiple target candidate segments from the multiple candidate segments whose scores are greater than a first preset threshold.
3. The method according to claim 1, characterized in that, The calculation of the first feature value corresponding to the candidate segment based on inter-point mutual information includes: The first feature value corresponding to the candidate fragment is calculated using the following formula: ; Wherein, x and y are phrases in the candidate segment, and PMI refers to the probability of y occurring given that x occurs; This refers to the probability that x and y occur together; This refers to the probability of x occurring.
4. The method according to claim 1, characterized in that, Calculating the second feature value corresponding to the candidate fragment based on information entropy includes: The second feature value corresponding to the candidate fragment is calculated using the following formula, where the second feature value is E. L and E R The smaller value in: Wherein, E L This refers to left entropy, the E mentioned above. R "W" refers to right entropy; "z" refers to the context of the candidate phrase "W"; "a" refers to the word to the left of the candidate phrase "W"; "b" refers to the word to the right of the candidate phrase "W"; "N" refers to missing context; "aW" refers to missing preceding context; and "Wb" refers to missing following context.
5. The method according to claim 1, characterized in that, Determining the score corresponding to the candidate segment based on the first feature value, the second feature value, the third feature value, and the fourth feature value includes: The first feature value, the second feature value, the third feature value, and the fourth feature value are normalized. The score corresponding to the candidate segment is obtained by summing the normalized first feature value, the normalized second feature value, the normalized third feature value, and the normalized fourth feature value.
6. The method according to claim 2, characterized in that, The sorting of multiple candidate documents based on the M fragments and the first parameter value includes: The plurality of candidate documents are selected from a plurality of target documents; wherein the candidate documents include the M segments, and the first parameter value corresponding to the M segments is less than or equal to a preset threshold; The candidate documents are sorted based on the first parameter value.
7. A document sorting device, characterized in that, include: The first processing module is used to segment the query statement into N segments; A first determining module is used to determine M segments that match the N segments from a preset offline vocabulary, and the scores corresponding to the M segments respectively; wherein the offline vocabulary includes multiple target candidate segments and the scores corresponding to the multiple target candidate segments, where N is a positive integer and M is a positive integer less than or equal to N; wherein the target candidate segments are candidate segments with scores greater than a first preset threshold, and the scores of the candidate segments are determined by: calculating a first feature value corresponding to the candidate segment based on inter-point mutual information; calculating a second feature value corresponding to the candidate segment based on information entropy; calculating a third feature value corresponding to the candidate segment based on word frequency; calculating a fourth feature value corresponding to the candidate segment based on inverse document frequency; and determining the score corresponding to the candidate segment based on the first feature value, the second feature value, the third feature value, and the fourth feature value. The second determining module is used to determine the first parameter value corresponding to the M segments based on the scores corresponding to the M segments and a preset mapping relationship; wherein, the preset mapping relationship is used to characterize the mapping relationship between the segment score and the first parameter, and the first parameter value is used to characterize the matching of words separated by the parameter value distance with the query segment; the first parameter value refers to the slop value when using ES for phrase matching, the size of the slop value depends on the minimum number of word moves required to obtain the query segment, the smaller the slop value, the higher the segment density, and the higher the corresponding score; The sorting module is used to sort multiple candidate documents based on the M fragments and the first parameter value.
8. An electronic device, characterized in that, It includes a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus; Memory, used to store computer programs; A processor, when executing a program stored in memory, implements the method of any one of claims 1-6.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the method as described in any one of claims 1-6.