A knowledge graph-based file search method and system
By using a knowledge graph-based file search method, data classification and logical reasoning are employed to identify user intent and generate a list of conditional keywords. This solves the problem that existing systems cannot identify user intent and improves the accuracy and rationality of search results.
Patent Information
- Application Number
- CN202211493075.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-25
- Publication Date
- 2026-07-10
- Estimated Expiration
- 2042-11-25
AI Technical Summary
The existing system cannot identify the user's search intent, and the search results do not meet the user's needs.
A knowledge graph-based file search method is adopted. By identifying user intent through data classification and logical reasoning, a list of conditional keywords is generated. File retrieval is performed using graph database queries and ElasticSearch to generate query results.
It improves the ability to identify user intent and the rationality of document scores, making the search results more in line with user needs and intent.
Smart Images

Figure CN115757738B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of knowledge graphs, and more specifically to a document search method and system based on knowledge graphs. Background Technology
[0002] Knowledge graphs are a data storage method based on graph databases, constructing knowledge networks through a node-relationship-node pattern. With the development of artificial intelligence technology, using knowledge graph search to answer or solve problems has become a trend. In practical work, files are often an important way to carry content; therefore, using knowledge graphs to quickly retrieve files is a very important application. Currently, file retrieval is mainly based on keyword searches, and the system cannot intelligently recognize user intent. Therefore, a file retrieval method that is closer to user intent is needed to solve this problem. Summary of the Invention
[0003] The technical problem this invention aims to solve is that the system cannot recognize the meaning and intent of the user's input search phrases, resulting in search results that do not meet the user's needs or match their intent. This invention provides a knowledge graph-based file search method and system. It employs data classification, logical reasoning to identify the user's intent, and further processing through graph database queries to obtain more accurate search keywords. A conditional scoring mechanism is used, generating a list of conditional keywords through logical reasoning and further determining the conditional keywords through graph database queries. These methods improve the ability to identify user intent and the rationality of file scoring, thereby making the search results more consistent with the user's needs and intent, thus overcoming the shortcomings of existing technologies.
[0004] To solve the above-mentioned technical problems, the present invention provides the following technical solutions:
[0005] Firstly, a knowledge graph-based file search method includes the following steps:
[0006] Step 1: Obtain entity and relation data from the knowledge graph, classify them, and save them as categorized data;
[0007] Step 2: Obtain the phrase to be retrieved, and process the classification data to obtain the keywords and their type data in the phrase;
[0008] Step 3: Generate a query statement based on the keywords and their type data, query the query statement in the graph database to obtain the query results, and generate a search term set list and a condition term set list based on the query results according to the rules;
[0009] Step 4: Perform a file search on the words in the search term list in Elasticsearch to obtain search result data. Calculate a word score based on the score of each word in the search result data. Calculate a file score based on the word scores in the conditional term list.
[0010] Step 5: Sort the file scores in reverse order to obtain the top K files that are most relevant to the phrase.
[0011] The above-mentioned knowledge graph-based file search method, wherein the knowledge graph in step 1 is established by importing text data into a graph database created using neo4j;
[0012] The entity and relationship data in the knowledge graph are categorized according to the label data type, concept data type, instance data type, relationship data type, attributekey data type, and attributevalue data type and then saved as the categorized data.
[0013] The classification data is the jieba external dictionary file;
[0014] In step 2, after obtaining the phrase to be retrieved, it is loaded into the jieba external dictionary file, and the phrase is segmented and filtered using the jieba word segmentation toolkit to obtain the keywords and their type data.
[0015] The aforementioned knowledge graph-based file search method includes text data comprising entity and relation data.
[0016] In the above-mentioned knowledge graph-based file search method, if the data type of the entity and relation data in step 1 is attributevalue, then the attributekey data type corresponding to the attributevalue data type is distinguished by adding a letter to its end.
[0017] In the above-mentioned knowledge graph-based file search method, the data type of the keyword obtained in step 2 is included in the label data type, the concept data type, the instance data type, the relationship data type, the attributekey data type, and the attributevalue data type.
[0018] The above-mentioned knowledge graph-based file search method, in step 3, obtains two keywords from the keyword and type data, denoted as word1 and word2, and processes them according to the following rules to generate the query statement. The query statement is then queried in the graph database to obtain the query results as result1 and result2 or result1. Based on the query results, the search term set list is generated according to the following rules:
[0019] If both word1 and word2 are of instance data type, then result1 is the set of all node names that can form a one-degree relationship with the node named word2, including the node named word1 and its aliases; result2 is the set of all node names that can form a one-degree relationship with the node named word1, including the node named word2 and its aliases.
[0020] If both word1 and word2 are of type concept, then result1 is the set of the node with the name word1, its aliases, and the names of all nodes that have a first-degree relationship with the node with the name word1, and all nodes that have a first-degree relationship with the node with the name word2. result2 is the set of the node with the name word2, its aliases, and the names of all nodes that have a first-degree relationship with the node with the name word2, and all nodes that have a first-degree relationship with the node with the name word1.
[0021] If word1 is an instance data type and word2 is a concept data type, then result1 is the set of all node names that can form a first-degree relationship with the node named word1 and its aliases, and result2 is the set of all node names that can form a first-degree relationship with the node named word2 and its aliases, and the set of all node names that can form a first-degree relationship with the node named word2 and its aliases.
[0022] If word1 is a label data type and word2 is an instance data type, then result1 is the set of all node names that can form a one-degree relationship with the node with the data type word1, where the node with the node name word2 is a label data type.
[0023] If word1 is a label data type and word2 is a concept data type, then result1 is the set of all node names that can form a one-degree relationship with the node with the data type word1, where the node with the node name word2 is a label data type.
[0024] If word1 is of label data type and word2 is of relationship data type, then result1 is the set of all node names that can form a word2 relationship with a node of data type word1;
[0025] If word1 is a label data type and word2 is an attributekey data type, then result1 is the collection of all values corresponding to the attribute word2 of the node with data type word1;
[0026] If word1 is a label data type and word2 is an attribute value data type, then result1 is the collection of all nodes whose attribute values for word2 in the node of data type word1 contain the name of word2.
[0027] If word1 is a relationship data type and word2 is an instance data type, then result1 is the set of all node names that have a relationship with the node named word2 and are related to word1.
[0028] If word1 is a relationship data type and word2 is a concept data type, then result1 is the set of all node names that have a relationship with word1 to the node named word2.
[0029] If word1 is of type attributekey and word2 is of type instance, then result1 is the collection of all values of the node named word2 whose attribute is word1.
[0030] If word1 is of type attributekey and word2 is of type concept, then result1 is the collection of all values of the node named word2 whose attribute is word1.
[0031] If word1 is an attributekey data type and word2 is an attributevalue data type, then result1 is a collection of all node names with the attribute word1 and the value word2.
[0032] If the data types of word1 and word2 are not among those listed above, then result1 takes word1 and word2 themselves and their aliases;
[0033] The search term list includes a main set and a subset;
[0034] If result1 and result2 are obtained, then the main set is the intersection of result1 and result2, and the subset is the union of result1 and result2 minus the intersection of result1 and result2.
[0035] If result1 is obtained, then the main set is result1 and the subset is empty;
[0036] In step 3, two keywords from the keyword and type data are obtained and denoted as word1 and word2. These keywords are then processed according to the following rules to generate the query statement. The query statement is then used to query the graph database to obtain the query results as result3 and result4 or result3, as follows:
[0037] If word1 and word2 are both of the concept data type, then result3 is the set of the node with the name word1, its aliases, and the names of all nodes that have a first-degree relationship with the node with the name word1, and all node names that can have a first-degree relationship with the node with the name word2; result4 is the set of the node with the name word2, its aliases, and the names of all nodes that have a first-degree relationship with the node with the name word2, and all node names that can have a first-degree relationship with the node with the name word1.
[0038] If word1 is of instance data type and word2 is of concept data type, then result3 is the set of all node names that can form a first-degree relationship with the node named word1 and its aliases, and result4 is the set of all node names that can form a first-degree relationship with the node named word2 and its aliases, and the set of all node names that can form a first-degree relationship with the node named word2 and its aliases.
[0039] If word1 is a label data type and word2 is an instance data type, then result3 is the set of all node names that can form a one-degree relationship between the node with the node name word2 and the node with the data type word1.
[0040] If word1 is a label data type and word2 is a concept data type, then result3 is the set of all node names that can form a one-degree relationship between the node with the node name word2 and the node with the data type word1.
[0041] If word1 is a label data type and word2 is a relationship data type, then result3 is the set of all node names that can form a word2 relationship with the node of data type word1; result4 is the set of all node names among the nodes of data type word1 that can form a word2 relationship with other nodes.
[0042] If word1 is a label data type and word2 is an attributekey data type, then result3 is the set of all values corresponding to the attribute word2 of the node with data type word1, and result4 is the set of all node names containing the attribute word2 in the node with data type word1.
[0043] If word1 is a label data type and word2 is an attribute value data type, then result3 is the collection of all nodes whose attribute values for word2 in the node with data type word1 contain the name of word2.
[0044] If word1 is a relationship data type and word2 is an instance data type, then result3 is the set of all node names that have a relationship with word1 to the node named word2.
[0045] If word1 is a relationship data type and word2 is a concept data type, then result3 is the set of all node names that have a relationship with word1 to the node named word2.
[0046] If word1 is of type attributekey and word2 is of type instance, then result3 is the collection of all values of the node named word2 and the node attributed to word1.
[0047] If word1 is of type attributekey and word2 is of type concept, then result3 is the collection of all values of the node named word2 and the node attributed to word1.
[0048] If word1 is an attributekey data type and word2 is an attributevalue data type, then result3 is a collection of all node names with the attribute word1 and the value word2.
[0049] If the data types of word1 and word2 are not among those listed above, then result3 takes word1 itself and its aliases, and result4 takes word2 itself and its aliases;
[0050] The condition term list contains two term sets, denoted as condition1 and condition2 respectively. The rules for generating the condition term list based on the query results are as follows:
[0051] If word1 is a label data type and word2 is an instance data type, then condition1 takes result3 and word1 itself and its aliases, and condition2 takes word2 itself and its aliases.
[0052] If word1 is a label data type and word2 is a concept data type, then condition1 takes result3 and word1 itself and its aliases, and condition2 takes word2 itself and its aliases.
[0053] If word1 is a label data type and word2 is a relationship data type, then condition1 takes result3 and word1 itself, and condition2 takes result4.
[0054] If word1 is a label data type and word2 is an attribute value data type, then condition1 takes result3 and condition2 takes word2 itself.
[0055] If word1 is of relationship data type and word2 is of instance data type, then condition1 takes result3, and condition2 takes word2 itself and its aliases.
[0056] If word1 is of relationship data type and word2 is of concept data type, then condition1 takes result3, and condition2 takes word2 itself and its aliases.
[0057] If word1 is of type attributekey and word2 is of type instance, then condition1 takes result3 and condition2 takes word2 itself and its alias.
[0058] If word1 is of type attributekey and word2 is of type concept, then condition1 takes result3 and condition2 takes word2 itself and its aliases.
[0059] If word1 is an attributekey data type and word2 is an attributevalue data type, then condition1 takes result3 and condition2 takes word2 itself.
[0060] If the data types of word1 and word2 are not among those listed above, then condition1 takes result3 and condition2 takes result4.
[0061] The above-mentioned knowledge graph-based file search method includes step 4 as follows:
[0062] Weights are set for the label data type, the concept data type, the instance data type, the relationship data type, the attributekey data type, and the attributevalue data type, respectively.
[0063] The words in the search term list are searched separately in ElasticSearch using the match_phrase command for file titles and file content, and the resulting search results are denoted as es_result1 and es_result2.
[0064] Iterate through es_result1 and es_result2, and calculate the vocabulary score for each word based on its data type. The calculation formula is as follows:
[0065]
[0066] Where, score is the vocabulary score. es The es score is the number of words segmented (n = 1 if a word cannot be segmented), and w is the weight of the data type.
[0067] Set different weights for es_result1 and es_result2, denoted as w. title and w content .
[0068] The weighted score for each document is calculated using the following formula:
[0069] file_score=∑scorees_result1 *w title +∑score es_result2 *w content ;
[0070] Where file_score is the weighted score of the file, and score es_result1 The score is the score given to the words in the document title. es_result2 The score is given for the words in the document content;
[0071] Calculate the file score. If a word from condition1 appears in either es_result1 or es_result2, then condition1 is satisfied; if a word from condition2 appears in both es_result1 and es_result2, then condition2 is satisfied. For each condition satisfied, count the number of satisfied conditions. satisfied Add 1, the formula is as follows:
[0072]
[0073] Where final_file_score is the file score, and count is... satisfied To satisfy the condition number, n total This is the total condition number.
[0074] Secondly, a knowledge graph-based file search system includes a data processing module, a retrieval phrase analysis and processing module, a search term set list and condition term set list generation module, and an ElasticSearch module.
[0075] The data processing module is used to acquire entity and relation data in the knowledge graph, classify them, and save them as classified data.
[0076] The retrieval phrase analysis and processing module is used to obtain the phrase to be retrieved and the classification data, and to process the classification data to obtain the keywords and their type data in the phrase;
[0077] The search term set list and condition term set list generation module is used to generate query statements based on the keywords and their type data, and is also used to query the query statements in the graph database to obtain query results, and to generate search term set list and condition term set list based on the query results according to rules.
[0078] The ElasticSearch module is used to perform file searches on the words in the search term set list in ElasticSearch to obtain search result data. It is also used to calculate a word score based on the score of each word in the search result data, and to calculate a file score based on the word score based on the condition term set list.
[0079] The data processing module is also used to sort the file scores in reverse order to obtain the top K files that are most relevant to the phrase.
[0080] Thirdly, a chip comprising: a processor for retrieving and running a computer program from a memory, causing a device having the chip mounted to perform: the method as described in any one of the first aspects.
[0081] The technical solution provided by the knowledge graph-based file search method and system of the present invention, as described above, has the following technical effects:
[0082] The method employs data classification, followed by logical reasoning to identify user intent, and further processing through graph database queries to obtain more precise search keywords. It also utilizes a conditional scoring mechanism, generating a list of conditional keywords through logical reasoning and further determining the conditional keywords through graph database queries. These methods improve the ability to identify user intent and the rationality of document scores, thereby making the search results more aligned with user needs and intent. Attached Figure Description
[0083] Figure 1 This is a flowchart of a knowledge graph-based file search method according to the present invention;
[0084] Figure 2 This is a structural diagram of a knowledge graph-based file search system according to the present invention.
[0085] The reference numerals in the attached figures are as follows:
[0086] Data processing module 100, retrieval phrase analysis and processing module 200, search term set list and condition term set list generation module 300, and ElasticSearch module 400. Detailed Implementation
[0087] In order to make the technical means, inventive features, objectives and effects of the invention easy to understand, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to specific illustrations. Obviously, the described embodiments are some embodiments of the present invention, but not all embodiments.
[0088] Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0089] It should be noted that the structures, proportions, sizes, etc., illustrated in the accompanying drawings of this specification are only used to complement the content disclosed in the specification for those skilled in the art to understand and read, and are not intended to limit the conditions under which the present invention can be implemented. Therefore, they have no substantial technical significance. Any modifications to the structure, changes in the proportions, or adjustments to the size, without affecting the effects and objectives that the present invention can produce, should still fall within the scope of the technical content disclosed in the present invention.
[0090] Furthermore, the terms such as "upper," "lower," "left," "right," "middle," and "one" used in this specification are merely for clarity of description and are not intended to limit the scope of the invention. Any changes or adjustments to their relative relationships, without substantially altering the technical content, should also be considered within the scope of the invention.
[0091] like Figure 1 As shown, in a first aspect, a first embodiment, a document search method based on a knowledge graph includes the following steps:
[0092] Step 1: Obtain entity and relation data from the knowledge graph, classify them, and save them as categorized data;
[0093] Step 2: Obtain the phrase to be retrieved, and process the categorized data to obtain the keywords and their types in the phrase;
[0094] Step 3: Generate a query statement based on keywords and their data types, query the query statement in the graph database to obtain the query results, and generate a search term set list and a condition term set list based on the query results according to the rules.
[0095] Step 4: Perform a file search on the words in the search term list in ElasticSearch to obtain the search results data. Calculate the word score based on the score of each word in the search results data. Calculate the file score based on the word scores according to the conditional term list.
[0096] Step 5: Sort the file scores in reverse order to get the top K files that are most relevant to the phrase.
[0097] The above-mentioned knowledge graph-based file search method, in step 1, establishes the knowledge graph by importing text data into a graph database created using Neo4j;
[0098] The entity and relation data in the knowledge graph are categorized and stored as categorized data according to the label, concept, instance, relationship, attributekey, and attributevalue data types. The label data type is a collection of all node types, the relationship data type is a collection of all relation types, the concept and instance data types are collections of node names (the specific division is customized according to the meaning of the node type), and the attributekey and attributevalue data types represent the collection of node attribute key names and attribute values, respectively.
[0099] The categorization data is from an external dictionary file named jieba;
[0100] In step 2, after obtaining the phrase to be searched, it is loaded into the jieba external dictionary file, and the phrase to be searched is segmented and filtered using the jieba word segmentation toolkit to obtain keywords and their type data.
[0101] The above-mentioned knowledge graph-based file search method includes text data containing entity and relation data.
[0102] In the above-mentioned knowledge graph-based file search method, if the data type of entity and relation data in step 1 is attributevalue, then the attributekey data type corresponding to the attributevalue data type is distinguished by adding a letter to its end.
[0103] In the above-mentioned knowledge graph-based file search method, the data types of the keywords obtained in step 2 are included in the label data type, concept data type, instance data type, relationship data type, attributekey data type, and attributevalue data type.
[0104] The above-mentioned knowledge graph-based file search method involves obtaining two keywords, denoted as word1 and word2, from the keyword and type data in step 3. These keywords are then processed according to the following rules to generate a query statement. The query statement is then used to search the graph database to obtain query results as result1 and result2 or result1. Based on the query results, a search term set list is generated according to the following rules:
[0105] If both word1 and word2 are of instance data type, then result1 is the set of all node names that can form a one-degree relationship with the node named word2, including the node named word1 and its aliases; result2 is the set of all node names that can form a one-degree relationship with the node named word1, including the node named word2 and its aliases.
[0106] If both word1 and word2 are of type concept, then result1 is the set of the node with the name word1, its aliases, and the names of all nodes that have a first-degree relationship with the node with the name word1, and all nodes that have a first-degree relationship with the node with the name word2. result2 is the set of the node with the name word2, its aliases, and the names of all nodes that have a first-degree relationship with the node with the name word2, and all nodes that have a first-degree relationship with the node with the name word1.
[0107] If word1 is an instance data type and word2 is a concept data type, then result1 is the set of all node names that can form a first-degree relationship with the node named word1 and its aliases, and result2 is the set of all node names that can form a first-degree relationship with the node named word2 and its aliases, and the set of all node names that can form a first-degree relationship with the node named word2 and its aliases.
[0108] If word1 is a label data type and word2 is an instance data type, then result1 is the set of all node names that can form a one-degree relationship with the node with the data type word1, where the node with the node name word2 is a label data type.
[0109] If word1 is a label data type and word2 is a concept data type, then result1 is the set of all node names that can form a one-degree relationship with the node with the data type word1, where the node with the node name word2 is a label data type.
[0110] If word1 is of label data type and word2 is of relationship data type, then result1 is the set of all node names that can form a word2 relationship with a node of data type word1;
[0111] If word1 is a label data type and word2 is an attributekey data type, then result1 is the collection of all values corresponding to the attribute word2 of the node with data type word1;
[0112] If word1 is a label data type and word2 is an attribute value data type, then result1 is the collection of all nodes whose attribute values for word2 in the node of data type word1 contain the name of word2.
[0113] If word1 is a relationship data type and word2 is an instance data type, then result1 is the set of all node names that have a relationship with the node named word2 and are related to word1.
[0114] If word1 is a relationship data type and word2 is a concept data type, then result1 is the set of all node names that have a relationship with word1 to the node named word2.
[0115] If word1 is of type attributekey and word2 is of type instance, then result1 is the collection of all values of the node named word2 whose attribute is word1.
[0116] If word1 is of type attributekey and word2 is of type concept, then result1 is the collection of all values of the node named word2 whose attribute is word1.
[0117] If word1 is an attributekey data type and word2 is an attributevalue data type, then result1 is a collection of all node names with the attribute word1 and the value word2.
[0118] If the data types of word1 and word2 are not among those listed above, then result1 takes word1 and word2 themselves and their aliases;
[0119] The search term list includes a main set and subsets;
[0120] If we obtain result1 and result2, then the main set is the intersection of result1 and result2, and the subset is the union of result1 and result2 minus the intersection of result1 and result2.
[0121] If result1 is obtained, then the main set is result1 and the subset is empty;
[0122] In step 3, the two keywords obtained from the keyword and type data are denoted as word1 and word2. These keywords are then processed according to the following rules to generate a query statement. The query statement is then used to query the graph database to obtain the query results as result3 and result4, or result3, according to the following rules:
[0123] If word1 and word2 are both of the concept data type, then result3 is the set of the node with the name word1, its aliases, and the names of all nodes that have a first-degree relationship with the node with the name word1, and all node names that can have a first-degree relationship with the node with the name word2; result4 is the set of the node with the name word2, its aliases, and the names of all nodes that have a first-degree relationship with the node with the name word2, and all node names that can have a first-degree relationship with the node with the name word1.
[0124] If word1 is of instance data type and word2 is of concept data type, then result3 is the set of all node names that can form a first-degree relationship with the node named word1 and its aliases, and result4 is the set of all node names that can form a first-degree relationship with the node named word2 and its aliases, and the set of all node names that can form a first-degree relationship with the node named word2 and its aliases.
[0125] If word1 is a label data type and word2 is an instance data type, then result3 is the set of all node names that can form a one-degree relationship between the node with the node name word2 and the node with the data type word1.
[0126] If word1 is a label data type and word2 is a concept data type, then result3 is the set of all node names that can form a one-degree relationship between the node with the node name word2 and the node with the data type word1.
[0127] If word1 is a label data type and word2 is a relationship data type, then result3 is the set of all node names that can form a word2 relationship with the node of data type word1; result4 is the set of all node names among the nodes of data type word1 that can form a word2 relationship with other nodes.
[0128] If word1 is a label data type and word2 is an attributekey data type, then result3 is the set of all values corresponding to the attribute word2 of the node with data type word1, and result4 is the set of all node names containing the attribute word2 in the node with data type word1.
[0129] If word1 is a label data type and word2 is an attribute value data type, then result3 is the collection of all nodes whose attribute values for word2 in the node with data type word1 contain the name of word2.
[0130] If word1 is a relationship data type and word2 is an instance data type, then result3 is the set of all node names that have a relationship with word1 to the node named word2.
[0131] If word1 is a relationship data type and word2 is a concept data type, then result3 is the set of all node names that have a relationship with word1 to the node named word2.
[0132] If word1 is of type attributekey and word2 is of type instance, then result3 is the collection of all values of the node named word2 and the node attributed to word1.
[0133] If word1 is of type attributekey and word2 is of type concept, then result3 is the collection of all values of the node named word2 and the node attributed to word1.
[0134] If word1 is an attributekey data type and word2 is an attributevalue data type, then result3 is a collection of all node names with the attribute word1 and the value word2.
[0135] If the data types of word1 and word2 are not among those listed above, then result3 takes word1 itself and its aliases, and result4 takes word2 itself and its aliases;
[0136] The condition term list contains two terms, denoted as condition1 and condition2. The rules for generating the condition term list based on the query results are as follows:
[0137] If word1 is a label data type and word2 is an instance data type, then condition1 takes result3 and word1 itself and its aliases, and condition2 takes word2 itself and its aliases.
[0138] If word1 is a label data type and word2 is a concept data type, then condition1 takes result3 and word1 itself and its aliases, and condition2 takes word2 itself and its aliases.
[0139] If word1 is a label data type and word2 is a relationship data type, then condition1 takes result3 and word1 itself, and condition2 takes result4.
[0140] If word1 is a label data type and word2 is an attribute value data type, then condition1 takes result3 and condition2 takes word2 itself.
[0141] If word1 is of relationship data type and word2 is of instance data type, then condition1 takes result3, and condition2 takes word2 itself and its aliases.
[0142] If word1 is of relationship data type and word2 is of concept data type, then condition1 takes result3, and condition2 takes word2 itself and its aliases.
[0143] If word1 is of type attributekey and word2 is of type instance, then condition1 takes result3 and condition2 takes word2 itself and its alias.
[0144] If word1 is of type attributekey and word2 is of type concept, then condition1 takes result3 and condition2 takes word2 itself and its aliases.
[0145] If word1 is an attributekey data type and word2 is an attributevalue data type, then condition1 takes result3 and condition2 takes word2 itself.
[0146] If the data types of word1 and word2 are not among those listed above, then condition1 takes result3 and condition2 takes result4.
[0147] The above-mentioned knowledge graph-based file search method includes step 4 as follows:
[0148] Weights are set for label, concept, instance, relationship, attributekey, and attributevalue data types respectively.
[0149] The words in the search term list are searched separately in ElasticSearch using the match_phrase command for file titles and file content. The resulting search results are denoted as es_result1 and es_result2.
[0150] Iterate through es_result1 and es_result2, and calculate the vocabulary score for each word based on its data type. The calculation formula is as follows:
[0151]
[0152] Where, score is the vocabulary score. es The es score is the number of words segmented (n = 1 if a word cannot be segmented), and w is the weight of the data type.
[0153] Set different weights for es_result1 and es_result2, denoted as w. title and w content .
[0154] The weighted score for each document is calculated using the following formula:
[0155] file_score=∑score es_result1 *w title +∑score es_result2 *w content ;
[0156] Where file_score is the weighted score of the file, and score es_result1 The score is the score given to the words in the document title. es_result2 The score is given for the words in the document content;
[0157] Calculate the file score. If a word from condition1 appears in either es_result1 or es_result2, then condition1 is satisfied; if a word from condition2 appears in both es_result1 and es_result2, then condition2 is satisfied. For each condition satisfied, count the number of satisfied conditions. satisfied Add 1, the formula is as follows:
[0158]
[0159] Where final_file_score is the file score, and count is... satisfied To satisfy the condition number, n total This is the total condition number.
[0160] like Figure 2 As shown, in a second aspect, a second embodiment, a knowledge graph-based file search system includes a data processing module 100, a retrieval phrase analysis and processing module 200, a search term set list and condition term set list generation module 300, and an ElasticSearch module 400.
[0161] The data processing module 100 is used to acquire entity and relation data from the knowledge graph, classify them, and save them as classified data;
[0162] The retrieval phrase analysis and processing module 200 is used to obtain the phrases to be retrieved and the classification data, and to process the classification data to obtain the keywords and their type data in the phrases;
[0163] The module for generating search term lists and condition term lists is used to generate query statements based on keywords and their types of data. It is also used to query the query statements in the graph database to obtain query results. Furthermore, it is used to generate search term lists and condition term lists based on the query results according to rules.
[0164] The ElasticSearch module 400 is used to perform file searches in ElasticSearch for words in the search term list to obtain search results data. It is also used to calculate word scores based on the scores of each word in the search results data, and to calculate file scores based on word scores in the condition term list.
[0165] The data processing module 100 is also used to sort the file scores in reverse order to obtain the top K files that are most relevant to the phrase.
[0166] Thirdly, a chip, comprising: a processor for retrieving and running a computer program from memory, causing a device on which the chip is mounted to perform: the method of any of the first aspects.
[0167] In summary, the knowledge graph-based file search method and system of this invention employs data classification, then uses logical reasoning to identify user intent, and further processes the graph database query to obtain more accurate search keywords; it also employs a conditional scoring mechanism, using logical reasoning to generate a list of conditional keywords, and further determining the conditional keywords through a graph database query; these methods improve the ability to identify user intent and the rationality of file scores, thereby making the search results more in line with user needs and intent.
[0168] The specific embodiments of the invention have been described above. It should be understood that the invention is not limited to the specific embodiments described above, and the devices and structures not described in detail should be understood to be implemented in a manner common to the art; those skilled in the art can make various modifications or alterations within the scope of the claims, and make several simple deductions, variations or substitutions, which do not affect the substantive content of the invention.
Claims
1. A document search method based on knowledge graphs, characterized in that, Includes the following steps: Step 1: Obtain entity and relation data from the knowledge graph, classify them, and save them as categorized data; Step 2: Obtain the phrase to be retrieved, and process the classification data to obtain the keywords and their type data in the phrase; Step 3: Generate a query statement based on the keywords and their type data, query the query statement in the graph database to obtain the query results, and generate a search term set list and a condition term set list based on the query results according to the rules; Step 4: Perform a file search on the words in the search term list in Elasticsearch to obtain search result data. Calculate a word score based on the score of each word in the search result data. Calculate a file score based on the word scores in the conditional term list. Step 5: Sort the file scores in reverse order to obtain the top K files that are most relevant to the phrase.
2. The document search method based on knowledge graphs as described in claim 1, characterized in that, The knowledge graph described in step 1 is built by importing text data into a graph database created using neo4j; The entity and relationship data in the knowledge graph are categorized according to the label data type, concept data type, instance data type, relationship data type, attributekey data type, and attributevalue data type and then saved as the categorized data. The classification data is the jieba external dictionary file; In step 2, after obtaining the phrase to be retrieved, it is loaded into the jieba external dictionary file, and the phrase is segmented and filtered using the jieba word segmentation toolkit to obtain the keywords and their type data.
3. The document search method based on knowledge graphs as described in claim 2, characterized in that, The text data includes entity and relation data.
4. The document search method based on knowledge graphs as described in claim 3, characterized in that, In step 1, if the data type of the entity and relation data is attributevalue, then the attributekey data type corresponding to the attributevalue data type is distinguished by adding a letter to its end.
5. The document search method based on knowledge graphs as described in claim 4, characterized in that, The data type of the keyword obtained in step 2 is included in the label data type, the concept data type, the instance data type, the relationship data type, the attributekey data type, and the attributevalue data type.
6. The document search method based on knowledge graphs as described in claim 5, characterized in that, In step 3, two keywords from the keyword and type data are obtained and denoted as word1 and word2. These keywords are then processed according to the following rules to generate the query statement. The query statement is then used to query the graph database to obtain the query results as result1 and result2 or result1. Based on the query results, the search term set list is generated according to the following rules: If both word1 and word2 are of instance data type, then result1 is the set of all node names that can form a one-degree relationship with the node named word2, including the node named word1 and its aliases; result2 is the set of all node names that can form a one-degree relationship with the node named word1, including the node named word2 and its aliases. If both word1 and word2 are of type concept, then result1 is the set of the node with the name word1, its aliases, and the names of all nodes that have a first-degree relationship with the node with the name word1, and all nodes that have a first-degree relationship with the node with the name word2. result2 is the set of the node with the name word2, its aliases, and the names of all nodes that have a first-degree relationship with the node with the name word2, and all nodes that have a first-degree relationship with the node with the name word1. If word1 is an instance data type and word2 is a concept data type, then result1 is the set of all node names that can form a first-degree relationship with the node named word1 and its aliases, and result2 is the set of all node names that can form a first-degree relationship with the node named word2 and its aliases, and the set of all node names that can form a first-degree relationship with the node named word2 and its aliases. If word1 is a label data type and word2 is an instance data type, then result1 is the set of all node names that can form a one-degree relationship with the node with the data type word1, where the node with the node name word2 is a label data type. If word1 is a label data type and word2 is a concept data type, then result1 is the set of all node names that can form a one-degree relationship with the node with the data type word1, where the node with the node name word2 is a label data type. If word1 is of label data type and word2 is of relationship data type, then result1 is the set of all node names that can form a word2 relationship with a node of data type word1; If word1 is a label data type and word2 is an attributekey data type, then result1 is the collection of all values corresponding to the attribute word2 of the node with data type word1; If word1 is a label data type and word2 is an attribute value data type, then result1 is the collection of all nodes whose attribute values for word2 in the node of data type word1 contain the name of word2. If word1 is a relationship data type and word2 is an instance data type, then result1 is the set of all node names that have a relationship with the node named word2 and are related to word1. If word1 is a relationship data type and word2 is a concept data type, then result1 is the set of all node names that have a relationship with word1 to the node named word2. If word1 is of type attributekey and word2 is of type instance, then result1 is the collection of all values of the node named word2 whose attribute is word1. If word1 is of type attributekey and word2 is of type concept, then result1 is the collection of all values of the node named word2 whose attribute is word1. If word1 is an attributekey data type and word2 is an attributevalue data type, then result1 is a collection of all node names with the attribute word1 and the value word2. If the data types of word1 and word2 are not among those listed above, then result1 takes word1 and word2 themselves and their aliases; The search term list includes a main set and a subset; If result1 and result2 are obtained, then the main set is the intersection of result1 and result2, and the subset is the union of result1 and result2 minus the intersection of result1 and result2. If result1 is obtained, then the main set is result1 and the subset is empty; In step 3, two keywords from the keyword and type data are obtained and denoted as word1 and word2. These keywords are then processed according to the following rules to generate the query statement. The query statement is then used to query the graph database to obtain the query results as result3 and result4 or result3, as follows: If word1 and word2 are both of the concept data type, then result3 is the set of the node with the name word1, its aliases, and the names of all nodes that have a first-degree relationship with the node with the name word1, and all node names that can have a first-degree relationship with the node with the name word2; result4 is the set of the node with the name word2, its aliases, and the names of all nodes that have a first-degree relationship with the node with the name word2, and all node names that can have a first-degree relationship with the node with the name word1. If word1 is of instance data type and word2 is of concept data type, then result3 is the set of all node names that can form a first-degree relationship with the node named word1 and its aliases, and result4 is the set of all node names that can form a first-degree relationship with the node named word2 and its aliases, and the set of all node names that can form a first-degree relationship with the node named word2 and its aliases. If word1 is a label data type and word2 is an instance data type, then result3 is the set of all node names that can form a one-degree relationship between the node with the node name word2 and the node with the data type word1. If word1 is a label data type and word2 is a concept data type, then result3 is the set of all node names that can form a one-degree relationship between the node with the node name word2 and the node with the data type word1. If word1 is a label data type and word2 is a relationship data type, then result3 is the set of all node names that can form a word2 relationship with the node of data type word1; result4 is the set of all node names among the nodes of data type word1 that can form a word2 relationship with other nodes. If word1 is a label data type and word2 is an attributekey data type, then result3 is the set of all values corresponding to the attribute word2 of the node with data type word1, and result4 is the set of all node names containing the attribute word2 in the node with data type word1. If word1 is a label data type and word2 is an attribute value data type, then result3 is the collection of all nodes whose attribute values for word2 in the node with data type word1 contain the name of word2. If word1 is a relationship data type and word2 is an instance data type, then result3 is the set of all node names that have a relationship with word1 to the node named word2. If word1 is a relationship data type and word2 is a concept data type, then result3 is the set of all node names that have a relationship with word1 to the node named word2. If word1 is of type attributekey and word2 is of type instance, then result3 is the collection of all values of the node named word2 and the node attributed to word1. If word1 is of type attributekey and word2 is of type concept, then result3 is the collection of all values of the node named word2 and the node attributed to word1. If word1 is an attributekey data type and word2 is an attributevalue data type, then result3 is a collection of all node names with the attribute word1 and the value word2. If the data types of word1 and word2 are not among those listed above, then result3 takes word1 itself and its aliases, and result4 takes word2 itself and its aliases; The condition term list contains two term sets, denoted as condition1 and condition2 respectively. The rules for generating the condition term list based on the query results are as follows: If word1 is a label data type and word2 is an instance data type, then condition1 takes result3 and word1 itself and its aliases, and condition2 takes word2 itself and its aliases. If word1 is a label data type and word2 is a concept data type, then condition1 takes result3 and word1 itself and its aliases, and condition2 takes word2 itself and its aliases. If word1 is a label data type and word2 is a relationship data type, then condition1 takes result3 and word1 itself, and condition2 takes result4. If word1 is a label data type and word2 is an attribute value data type, then condition1 takes result3 and condition2 takes word2 itself. If word1 is of relationship data type and word2 is of instance data type, then condition1 takes result3, and condition2 takes word2 itself and its aliases. If word1 is of relationship data type and word2 is of concept data type, then condition1 takes result3, and condition2 takes word2 itself and its aliases. If word1 is of type attributekey and word2 is of type instance, then condition1 takes result3 and condition2 takes word2 itself and its alias. If word1 is of type attributekey and word2 is of type concept, then condition1 takes result3 and condition2 takes word2 itself and its aliases. If word1 is an attributekey data type and word2 is an attributevalue data type, then condition1 takes result3 and condition2 takes word2 itself. If the data types of word1 and word2 are not among those listed above, then condition1 takes result3 and condition2 takes result4.
7. The document search method based on knowledge graphs as described in claim 6, characterized in that, The specific method for step 4 is as follows: Weights are set for the label data type, the concept data type, the instance data type, the relationship data type, the attributekey data type, and the attributevalue data type, respectively. The words in the search term list are searched separately in ElasticSearch using the match_phrase command for file titles and file content, and the resulting search results are denoted as es_result1 and es_result2. Iterate through es_result1 and es_result2, and calculate the vocabulary score for each word based on its data type. The calculation formula is as follows: Where, score is the vocabulary score. es The es score is the number of words segmented (n = 1 if a word cannot be segmented), and w is the weight of the data type. Set different weights for es_result1 and es_result2, denoted as w. title and w content; The weighted score for each document is calculated using the following formula: file_score=∑score es_result1 *w title +∑score es_result2 *w content ; Where file_score is the weighted score of the file, and score es_result1 The score is the score given to the words in the document title. es_result2 The score is given for the words in the document content; Calculate the file score. If a word from condition1 appears in either es_result1 or es_result2, then condition1 is satisfied; if a word from condition2 appears in both es_result1 and es_result2, then condition2 is satisfied. For each condition satisfied, count the number of satisfied conditions. satisfied Add 1, the formula is as follows: Where final_file_score is the file score, and count is... satisfied To satisfy the condition number, n total This is the total condition number.
8. A knowledge graph-based file search system, characterized in that, It includes a data processing module, a search phrase analysis and processing module, a search term set list and condition term set list generation module, and an ElasticSearch module. The data processing module is used to acquire entity and relation data in the knowledge graph, classify them, and save them as classified data. The retrieval phrase analysis and processing module is used to obtain the phrase to be retrieved and the classification data, and to process the classification data to obtain the keywords and their type data in the phrase; The search term set list and condition term set list generation module is used to generate query statements based on the keywords and their type data, and is also used to query the query statements in the graph database to obtain query results, and to generate search term set list and condition term set list based on the query results according to rules. The ElasticSearch module is used to perform file searches on the words in the search term set list in ElasticSearch to obtain search result data. It is also used to calculate a word score based on the score of each word in the search result data, and to calculate a file score based on the word score based on the condition term set list. The data processing module is also used to sort the file scores in reverse order to obtain the top K files that are most relevant to the phrase.
9. A chip, characterized in that, Includes: a processor for retrieving and running a computer program from memory, causing a device on which the chip is mounted to perform: the method as described in any one of claims 1-7.
Citation Information
Patent Citations
File management method based on user-defined graph
CN110750995A
Semantic entity relation detection classifier training
US20170068903A1