Keyword-based RDF aggregation query method
By constructing an aggregation dictionary and query conversion algorithm, the accuracy and efficiency issues of aggregation operation queries in RDF data are solved, and efficient aggregation operation support and structured query result generation are achieved.
Patent Information
- Application Number
- CN202011006567.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-09-23
- Publication Date
- 2025-09-16
- Estimated Expiration
- 2040-09-23
AI Technical Summary
Existing RDF data keyword query methods are difficult to effectively handle aggregation operations, resulting in inaccurate and inefficient query results and unable to fully utilize the rich query operations of SPARQL.
A keyword-based RDF aggregation query method is provided. By constructing an aggregation dictionary and a query conversion algorithm, the matching between keywords and aggregation intent keywords is judged, and the query structure graph is expanded on the RDF pattern graph. The query intent score is calculated and converted into a SPARQL query statement to obtain accurate aggregation operation results.
It improves the accuracy and efficiency of keyword queries on RDF data, can process queries containing aggregation operations, and generate structured query results containing aggregation operations to meet real-time retrieval needs.
Smart Images

Figure CN114253998B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to a keyword-based RDF aggregation query method. Background Art
[0002] With the widespread application of semantic web, knowledge graph and other technologies in various fields, the graph structure data involved in semantic web, knowledge graph and other technologies are also widely used. These graph structure data are generally represented by Resource Description Framework (RDF). [1] ,Yago [2] ,Freebase [3] Users can use graph-structured data to convert general document retrieval into knowledge retrieval, thereby improving the relevance between search results and user query intent and avoiding the display of irrelevant information.
[0003] When searching RDF data, most users choose to write and execute SPARQL, a standard query language recommended by the W3C organization. However, SPARQL has complex syntax and requires users to have a certain amount of prior knowledge of the schema information of the original data graph to write SPARQL statements, which makes it difficult for users to obtain the required information from RDF data. These problems have led scholars to study keyword queries or natural language question queries on RDF data. [4-8] Among them, keyword query of RDF data is closer to the user's daily search habits and is concise and easy to use. However, the keyword input of this method lacks the necessary dependency information in the sentence, making it more difficult to understand the user's query intention than natural language.
[0004] At present, the research on keyword query methods for RDF data can be divided into two categories: [9] One type is direct query, which is to first match the keyword to the elements on the original data graph, and then obtain the minimum substructure covering all matching elements by searching the entire data graph and directly use it as the query result. [10-12] The second type is query conversion, which first converts keyword queries into structured queries that match intent, and then executes the statements through the existing query engine to obtain the final results. [13-15] .
[0005] In direct query methods, due to the huge size of the original data graph, it takes a long time to retrieve matching graph elements, which cannot meet the requirements of real-time retrieval or higher graph retrieval efficiency. Therefore, how to effectively index the data graph or construct a small-scale summary graph to improve the efficiency of graph data retrieval has become a research focus. Among them, the literature
[16] proposed a method to obtain a set of graph patterns based on the similarity between adjacent nodes within several hops of each graph element and use the obtained graph pattern as the summary of the original data graph while considering the diversity of the summary; the literature
[17] stores the category corresponding to each entity and the keyword used to describe its attribute value in the same node to achieve data graph compression and reduce the search space; BLINKS
[18] Pre-calculate all correspondences between nodes and keywords in the graph, as well as the shortest path information between nodes, to build a keyword-node list and the matching between each node and the keywords it contains; EASE
[19] First, a distance matrix of all nodes is constructed based on the data information, and then the distance matrix is used to pre-calculate the distance between the Steiner graph and the keyword.
[0006] In the query transformation method, since the algorithm does not directly return the query answer, it only needs to determine the relationship between elements to accurately understand the query intent, so there is no need to query the entire data graph. The query transformation method makes full use of the structural information contained in the RDF pattern graph, expands the pattern graph through keyword elements, and then searches on the expanded pattern graph to obtain a subgraph containing all key elements. Reference
[14] obtains the graph elements that the keyword may indicate through the inverted index, and extracts the pattern information as a summary graph to achieve efficient determination of the retrieval intent. The query intent determination process of reference
[13] is similar to that of reference
[14] , but the context information of a set of keywords in each query is considered when sorting the results, which improves the relevance of the results and enhances the sorting effect. Reference
[11] divides the input keywords into all possible subsequences, then labels each subsequence according to the type of the original data, and finally determines the query intent through the cost of constructing the semantic structure. Reference
[20] combines the two input contents of keywords and SPARQL statements, and uses keywords to enhance the expressive power of the original structured query. Reference
[21] also considered the diversity of retrieval results. By designing a similarity measurement strategy between query intents, the candidate results were restricted to ensure the diversity of information contained in the final results.
[0007] There are algorithms that have been studied on relational databases to support queries with aggregated keywords. For example: SQAK
[22] By restricting special words such as num and max to match aggregation operations, and using the reserved keyword WITH to determine candidate query interpretations, it is finally converted to a subset of SQL, rSQL; PowerQ
[23] The annotation graph model is obtained through the support of user interaction information and converted into SQL query; Reference
[24] determines the user query intention through the dependency relationship in the sentence; TBSL
[25] The corresponding SPARQL template is determined by the semantic representation of the question, and then the named entities are added to the slots.
[0008] While both direct query and query transformation support general keyword queries, direct query methods can only return elements that exist in the graph as query results. Query transformation only produces query statements containing the query pattern, failing to fully utilize the rich query operations supported by SPARQL and neglecting support for statistical information queries. Furthermore, since user-entered keywords may match both aggregation operations and general graph elements, existing relational database algorithms supporting aggregation operations restrict the interpretation of specific keywords such as max and count. This results in these keywords being assumed to always indicate corresponding aggregation operations, thus affecting the diversity and accuracy of candidate query interpretations.
[0009] [1]Jens Lehmann,Robert Isele,Max Jakob.DBpedia-A Large-scale,Multilingual Knowledge Base Extracted from Wikipedia[J].Semantic Web,2014,6(2).
[0010] [2]Kurt D.Bollacker,Colin Evans,Praveen Paritosh.Freebase:Acollaboratively created graph database for structuring human knowledge[C] / / Proceedings of the ACM SIGMOD International Conference on Management of Data,SIGMOD 2008,Vancouver,BC,Canada,June 10-12,2008.ACM, 2008.
[0011] [3]Suchanek FM,Kasneci G,Weikum G.YAGO:A Core of Semantic KnowledgeUnifying WordNet and Wikipedia[C] / / 16th International World Wide WebConference WWW,pp.697-706,2007.
[0012] [4]Hu S,Zou L,Yu JX,et al.Answering Natural Language Questions bySubgraph Matching over Knowledge Graphs[J].IEEE Transactions on Knowledge andData Engineering,2018,30(5):824-837.
[0013] [5]Shan Y,Li M,Chen Y.Constructing target-aware results for keywordsearch on knowledge graphs[J].Data&Knowledge Engineering,2017:S0169023X17300563.
[0014] [6]Y.Yang,D.Agrawal,HVJagadish,AKHTung and S.Wu,"An EfficientParallel Keyword Search Engine on Knowledge Graphs,"2019IEEE 35th International Conference on Data Engineering(ICDE),Macao,Macao,2019,pp.338-349.
[0015] [7]International Review, New York.Introduction to the OAN Diagnostic Information System [J].Revised,2018.
[0016] [8]Yoghourdjian,Hrag et al.“Top-k Keyword Search over Wikipedia-basedRDF Knowledge Graphs.” KDIR(2017).
[0017] [9] Du Fang, Chen Yueguo, Du Xiaoyong. A review of RDF data query processing technology[J]. Journal of Software, 2013(06):62-82.
[0018]
[10] Zou, Lei, Huang, Ruizhe, Wang, Haixun. Natural language questionanswering over RDF: a graph data driven approach [M]. ACM, 2014.
[0019]
[11] Han S, Zou L, Yu JX, et al. Proceedings of the 2017ACM on Conferenceon Information and Knowledge Management,-CIKM\"17-Keyword Search on RDFGraphs-A Query Graph Assembly Approach[J].2017:227-236.
[0020]
[12] Li Huiying, Qu Yuzhong. KREAG: A keyword query method for RDF data based on entity triple association graph [J]. Chinese Journal of Computers, 2011(05):67-77.
[0021]
[13] Wen Y, Jin Y, Yuan X.KAT:Keywords-to-SPARQL Translation Over RDFGraphs[M] / / Database Systems for Advanced Applications. Springer, Cham, 2018.
[0022]
[14] Tran T, Wang H, Rudolph S, et al.Top-k Exploration of QueryCandidates for Efficient Keyword Search on Graph-Shaped(RDF)Data*[C] / / DataEngineering,2009.ICDE'09.IEEE 25th International Conference on.IEEE,2009.(T)
[0023]
[15] Pound J,Hudek A K,Ilyas I F,et al.Interpreting keyword queriesover web knowledge bases[C] / / Proceedings of the 21st ACM internationalconference on Information and knowledge management.ACM,2012.
[0024]
[16] Song Q,Wu Y,Lin P,et al.Mining Summaries for Knowledge GraphSearch[C] / / 2016 IEEE 16th International Conference on Data Mining(ICDM).IEEE,2018:1-1.
[0025]
[17] W.Le,F.Li,A.Kementsietsidis and S.Duan,"Scalable Keyword Searchon Large RDF Data,"in IEEE Transactions on Knowledge and Data Engineering,vol.26,no.11,pp.2774-2788,Nov.2014,doi:10.1109 / TKDE.2014.2302294.
[0026]
[18] He H,Wang H,Yang J,et al.BLINKS:ranked keyword searches on graphs[C] / / Proceedings of the ACM SIGMOD International Conference on Management ofData,Beijing,China,June 12-14,2007.ACM,2007.
[0027]
[19] Li G,Ooi B C,Feng J,et al.EASE:An effective 3-in-1 keyword searchmethod for unstructured,semi-structured and structured data[C] / / Acm SigmodInternational Conference on Management of Data.ACM,2008.
[0028]
[20] Peng P,Zou L,Qin Z.Answering Top-K Query Combined Keywords andStructural Queries on RDF Graphs[J].Information Systems,2017,67.
[0029]
[21] Wang Y,Zhong M,Zhu Y,et al.Diversified Top-k Keyword QueryInterpretation on Knowledge Graphs[C] / / Asia-Pacific Web(APWeb)and Web-AgeInformation Management(WAIM)Joint Conference on Web and Big Data.Springer,Cham,2017.
[0030]
[22] Eep Tata,Guy M.Lohman.SQAK:doing more with keywords[C] / / AcmSigmod International Conference on Management of Data.ACM,2008.
[0031]
[23] Z.Zeng,M.L.Lee,T.W.Ling,PowerQ:an interactive keyword searchengine for aggregate queries on relational databases,in:Proceedings of the19th International Conference on Extending Database Technology(EDBT),2016,pp.596–599.
[0032]
[24] Hu X,Dang D,Yao Y,et al.Natural Language Aggregate Query over RDFData[J].information sciences,2018:S0020025516310611.
[0033]
[25] C.Unger, L.Bühmann, J.Lehmann, Template-based question answering over RDF data, in: Proceedings of The International Conference on World WideWeb (WWW'12), 2012, pp.639–648. Summary of the Invention
[0034] To solve the above problems, the present invention provides a method for performing query conversion on multiple keywords input by users, including aggregation operations, making full use of statistical information and the rich query operations in SPARQL. The present invention adopts the following technical solutions:
[0035] The present invention provides a keyword-based RDF aggregation query method, which is used to obtain corresponding query results for a keyword group input by a user and containing multiple keywords on an RDF pattern graph containing multiple graph elements and an aggregation dictionary through SPARQL query syntax query, and is characterized in that it includes the following steps: step S1, matching and processing the keyword group based on the RDF pattern graph and the aggregation dictionary to obtain multiple graph element groups corresponding to the keyword group and setting them as key element groups and aggregation information; step S2, obtaining corresponding candidate query interpretations according to the key element groups and the aggregation information; step S3, expanding on the RDF pattern graph according to the key element groups and the candidate query interpretations to obtain a query structure graph; step S4, obtaining multiple candidate query intentions corresponding to the keyword group according to the query structure graph and the aggregation information, and using a predetermined intention score calculation method to calculate the candidate query intentions in turn to obtain query intention scores, and sorting based on the query intention scores to obtain a query scoring sequence; step S5, using a query conversion algorithm to convert a predetermined number of candidate query intentions with the highest query intention scores in the query scoring sequence into corresponding SPARQL query statements and executing them in turn to obtain all query results, Among them, step S1 also includes the following sub-steps: step S1-1, judging whether the keyword matches the aggregation intention keyword in the aggregation dictionary; step S1-2, judging whether the keyword matches the graph element in the RDF pattern graph when the keyword matches the aggregation intention keyword, and setting the keyword as a candidate aggregation keyword when it is judged to be matched; step S1-3, calculating the aggregation probability that the candidate aggregation keyword is the aggregation keyword using a predetermined aggregation intention calculation rule; step S1-4, judging whether the aggregation probability exceeds a threshold, and setting the candidate aggregation keyword as the aggregation keyword when it exceeds, and recording the position of the aggregation keyword in the keyword group as the aggregation keyword position; step S1-5, when the aggregation probability exceeds the threshold, obtaining aggregation information according to the aggregation keyword position; step S1-6, matching according to the keyword in the RDF pattern graph, obtaining multiple graph elements matching the keyword and setting them as key elements; step S1-7, judging whether the last keyword is completed, and repeating steps S1-1 to S1-6 when it is judged to be not; step S1-8, when the last keyword is completed, obtaining a key element group containing all key elements and aggregation information corresponding to all aggregation keywords.
[0036] The keyword-based RDF aggregation query method provided by the present invention may also have such a technical feature, wherein the aggregation dictionary contains at least multiple aggregation intention keywords and aggregation categories corresponding to the aggregation intention keywords, and the aggregation categories are obtained by classifying all aggregation operations according to the differences in the aggregation operations in the SPARQL query syntax.
[0037] The keyword-based RDF aggregation query method provided by the present invention may also have the following technical features, wherein the aggregation intention calculation rule is:
[0038]
[0039] Where k i is a candidate aggregation keyword, n is the number of all keywords contained in the keyword group, j∈{1,2,3,...,n}, i is the position of the candidate aggregation keyword, S(k i ) is the candidate aggregation keyword k i The inverse of the distance to the matching key element, LevDis(k i ,ele) is represented as the candidate aggregation keyword k i The edit distance from the literal value of the matched key element, It is represented as candidate aggregation keyword k i The sum of the distances between the corresponding key element and other key elements in the keyword group on the RDF pattern graph, P(op|k i ) is the aggregation probability corresponding to the candidate aggregation keyword.
[0040] The keyword-based RDF aggregation query method provided by the present invention may also have the following technical features, wherein the aggregation categories are divided into direct aggregation and indirect aggregation, and the intention score calculation method includes the following steps: Step E1, judging whether the aggregation category corresponding to the aggregation keyword belongs to direct aggregation or indirect aggregation; Step E2, when it is judged to belong to direct aggregation, calculating the direct aggregation score Score(A)' of the aggregation information A according to formula (2):
[0041]
[0042] Where operation is the query aggregation operation type, and ST is the search object. In step E3, when it is determined to be indirect aggregation, the indirect aggregation score Score(A)″ of the aggregate information A is calculated according to formula (3):
[0043]
[0044] Where AT is the aggregation object, and Path(AT→ST).length is the length of the path between the aggregation object AT and the element corresponding to the search object ST. In step E4, the score of the query structure graph G is calculated according to formula (4):
[0045]
[0046] Where G is the query structure graph; Step E5, calculate the query intent score of candidate query intent I according to formula (5):
[0047] Score(I)=Score(G)+(1-α)Score(A) (5)
[0048] Where α is the harmonic parameter, Score(A)∈[Score(A)′, Score(A)″].
[0049] Functions and effects of the invention
[0050] According to the keyword-based RDF aggregation query method of the present invention, since all aggregation operations in the SPARQL query syntax are classified to obtain multiple aggregation categories and an aggregation dictionary corresponding to the aggregation categories and aggregation intention keywords is constructed, it provides support for converting keyword queries into SPARQL query statements with aggregation operations.
[0051] Furthermore, by judging whether the keyword matches the aggregation intent keyword and then judging whether the graph element matches the candidate aggregation keyword, the situation where the keyword matches both the graph element and the aggregation category is taken into account, thereby improving the diversity and accuracy of the candidate query interpretation.
[0052] Furthermore, since the query structure graph corresponding to the aggregated keywords is obtained by expanding the RDF pattern graph according to the key elements and combining the candidate query interpretation, the statistical information is fully utilized.
[0053] Finally, due to the use of the query conversion algorithm to convert a predetermined number of candidate query intentions with the highest query intent scores in the query scoring sequence into corresponding SPARQL query statements, and the query statements are executed in sequence to obtain the query results, the final query results not only include the query statements of the query pattern but also include structured query results containing aggregation operations, making keyword queries on RDF data more efficient and the query results more accurate.
[0054] The keyword-based RDF aggregation query method of the present invention supports general keyword queries and keyword queries with aggregation operations, can improve the accuracy and efficiency of queries, and can be applied to the keyword query field of graph structure data on the Internet. For example: a user inputs a keyword query Q1={num,student,university0} with an aggregation operation to express "query the number of students in university0" and Q2={Article,max,volume} which may be a keyword query with an aggregation operation or a general keyword query, to express "query the article with the largest number of volumes". The query intent indicated by num / max is correctly parsed. At the same time, the keyword "max" in Q2 may indicate an aggregation operation of the MAX or TOP1 type, and may also match a person named "MaxRobert", and the corresponding query intent is "the number of volumes of articles published by scholar max". BRIEF DESCRIPTION OF THE DRAWINGS
[0055] Figure 1 Flowchart of a keyword-based RDF aggregation query method according to an embodiment of the present invention;
[0056] Figure 2 Flowchart of a keyword-based RDF aggregation query method according to an embodiment of the present invention;
[0057] Figure 3 Schematic diagram of the inverted index structure according to an embodiment of the present invention;
[0058] Figure 4 An efficiency graph for inverted index construction according to an embodiment of the present invention;
[0059] Figure 5 A graph showing the conversion accuracy of keyword queries according to an embodiment of the present invention; and
[0060] Figure 6 This is a graph showing the time consumption of keyword query conversion according to an embodiment of the present invention. DETAILED DESCRIPTION
[0061] In order to make the technical means, creative features, objectives and effects of the present invention easier to understand, the keyword-based RDF aggregation query method of the present invention is described in detail below with reference to embodiments and drawings.
[0062] <Example>
[0063] Figure 1 A flowchart of a keyword-based RDF aggregation query method according to an embodiment of the present invention; and
[0064] Figure 2 The flowchart of the keyword-based RDF aggregation query method according to an embodiment of the present invention is shown.
[0065] like Figure 1 as well as Figure 2 As shown, the keyword-based RDF aggregation query method includes the following steps:
[0066] Step S1: Match and process the keyword group based on the RDF pattern graph and the aggregation dictionary to obtain multiple graph element groups corresponding to the keyword group and set them as key element groups and aggregation information.
[0067] Wherein, step S1 also includes the following sub-steps:
[0068] Step S1-1, determining whether the keyword matches the aggregation intention keyword in the aggregation dictionary.
[0069] The aggregation dictionary contains at least a plurality of aggregation intent keywords and aggregation categories corresponding to the aggregation intent keywords.
[0070] Aggregation categories are obtained by classifying all aggregation operations into multiple aggregation categories based on the different aggregation operations in the SPARQL query syntax.
[0071] In this embodiment, the aggregation operations in the SPARQL query syntax include count, groupby, etc. The aggregation intent keywords in the aggregation dictionary are commonly used keywords with aggregation operations.
[0072] All aggregation operations are divided into categories such as COUNT, TOP1, TOPN_G>, >, EQU, TOPN_G<, <, AVG, MAX, MIN, and SUM.
[0073] Among them, COUNT, MAX, MIN, and SUM are direct aggregations, and the remaining clustering categories are indirect aggregations.
[0074] In this embodiment, during the classification of aggregation operations, comparative or superlative indications of aggregation operation terms are discovered. These special aggregation intent keywords, in addition to indicating the aggregation operation, also provide information for subsequent keyword matching with graph elements in the RDF schema. Therefore, after obtaining the corresponding aggregation type for the comparative or superlative aggregation intent keywords, the prototype terms of these aggregation intent keywords are added to the general keyword set for subsequent keyword matching with graph elements in the RDF schema.
[0075] When the keyword matches the aggregation intention keyword in the aggregation dictionary, go to step S1-2; when the keyword does not match the aggregation intention keyword in the aggregation dictionary, go to step S1-5.
[0076] Step S1-2: determine whether the keyword matches the graph element in the RDF pattern graph, and set the keyword as a candidate aggregation keyword if it is determined to be matched.
[0077] In this embodiment, the RDF pattern graph is a graph that only retains category nodes and relationship edges between categories.
[0078] When the keyword matches the graph element, go to step S1-3. When the keyword does not match the graph element, set the keyword as the aggregate keyword and record the position of the aggregate keyword in the keyword group as the aggregate keyword position, and then go to step 1-6.
[0079] Step S1-3, using a predetermined aggregation intention calculation rule to calculate the aggregation probability that the candidate aggregation keyword is the aggregation keyword.
[0080] The calculation rules for aggregate intent are as follows:
[0081]
[0082] Where k i is a candidate aggregation keyword, n is the number of all keywords contained in the keyword group, j∈{1,2,3,...,n}, i is the position of the candidate aggregation keyword, S(k i ) is the candidate aggregation keyword k i The inverse of the distance to the matching key element, LevDis(k i ,ele) is represented as the candidate aggregation keyword k i The edit distance from the literal value of the matched key element, It is represented as candidate aggregation keyword k i The sum of the distances between the corresponding key element and other key elements in the keyword group on the RDF pattern graph, P(op|k i ) is the aggregation probability corresponding to the candidate aggregation keyword.
[0083] Step S1-4: determine whether the aggregation probability exceeds a threshold, and if so, set the candidate aggregation keyword as the aggregation keyword, and record the position of the aggregation keyword in the keyword group as the aggregation keyword position.
[0084] In this embodiment, the threshold is set to 1 / 3.
[0085] Step S1-5: when the aggregation probability exceeds a threshold, obtaining aggregation information according to the aggregation keyword position.
[0086] In this embodiment, the aggregation information A is defined as A=(operation, ST, AT), where operation is the aggregation category, ST is the retrieval object, and AT is the aggregation object, which is used to limit ST and AT to be elements included in the query graph G. A can be null.
[0087] Among them, when the keyword does not match the aggregation intent keyword in the aggregation dictionary, A is null; when the aggregation probability does not exceed the threshold, A is null.
[0088] In this embodiment, when an aggregation keyword appears, the getAgg function is used to obtain the aggregation information A. The specific steps are:
[0089] For each key element group c, if aggType is MAX / MIN, check whether there is a category before the aggregation keyword. If there is a category, change aggType to TOP1. For key element groups belonging to the TOP1 type, determine whether the object after the aggregation keyword has a numeric attribute and classify it as TOP1_G or TOP1. After determining the aggregation category to which the aggregation keyword belongs, obtain information about the query object and the aggregation object. Specific scenarios can be divided into the following:
[0090] 1) When the aggregation type is {AVG, MAX, MIN, SUM}, the attribute label after the aggregation keyword position is the query object, and the aggregation object is null.
[0091] 2) When the aggregation type is COUNT, all category elements in the key element group may be query objects and correspond to different aggregation information. The aggregation object is null.
[0092] 3) The aggregation type belongs to {>,<,EQU}. The query object is the category element before the aggregation operation. The aggregation object is described in the form of XY, where X is the corresponding aggregation attribute element or category information, and Y is the literal value after the aggregation operation.
[0093] 4) When the aggregation type is TOP1, if there is no category information before the aggregation keyword position, the query object ST is the category node after the aggregation keyword position, and AT is the attribute label corresponding to the aggregation keyword position; otherwise, the query object is the category element before the aggregation keyword position, and the aggregation object is the category or attribute label after the aggregation keyword position.
[0094] 5) When the aggregation type is TOPN_G, the query object ST is the category element before the aggregation keyword position, and the aggregation object AT is the category after the aggregation keyword position - the literal after the aggregation keyword position.
[0095] When no keyword is set as the aggregate keyword after judging all the keywords in the keyword group, the aggregate information A is null, and the candidate query interpretation is directly obtained based on the key element group.
[0096] Step S1-6: Matching is performed in the RDF pattern graph according to the keyword, and multiple graph elements matching the keyword are obtained and set as key elements.
[0097] In this embodiment, in order to quickly obtain graph elements that match keywords, a specific graph element storage structure is designed, and a mapping table corresponding to keywords and graph elements is constructed.
[0098] Because the keywords entered by users are generally used to describe an entity through the values corresponding to attributes such as name and title, the keywords will be matched to the attribute value nodes, category nodes and relationship labels of key elements, that is, Therefore, each element in the RDF pattern graph is pre-stored in a defined data structure (class, property, value), where class is the category information corresponding to the element, property is the edge label, and value is the attribute value.
[0099] Figure 3 Schematic diagram of the inverted index structure according to an embodiment of the present invention.
[0100] In order to match the keywords with some information in the graph elements, the present invention pre-constructs the inverted index of the keywords. The inverted index structure of the keyword elements is as follows: Figure 3 shown.
[0101] When building an inverted index, each graph element is considered a document, and categories, attribute labels, and literals are used as terms to build the index.
[0102] In the process of matching keywords with graph elements in the RDF pattern graph, the edit distance between the keyword and the index item string is calculated to obtain the similarity between the keyword and the query term. For the graph elements matching the keyword, the index structure is returned as the matched element, and the candidate query interpretation is obtained.
[0103] Step S1-7, determining whether the last keyword is completed, and repeating steps S1-1 to S1-5 if the determination is no.
[0104] Step S1-8: When the last keyword is completed, a key element group including all key elements and aggregation information corresponding to all aggregated keywords are obtained.
[0105] In this embodiment, the user inputs a keyword group Q containing n keywords = {k1, k2, ..., kn For each keyword, multiple graph elements that match the keyword in the RDF schema are set as key elements. A keyword corresponds to a set of key elements M i (including key nodes and key edges), a set of all possible key elements of a keyword group is C = M1×M2×...×M n ,Right now c={m1,m2,...,m n}, and m i ∈M i , that is, a group of keyword groups corresponds to multiple key element groups.
[0106] Step S2: Obtain corresponding candidate query explanations based on the key element group and the aggregated information.
[0107] In this embodiment, a candidate query interpretation E1 is defined as E1 = (c, A), where C is a set of key element groups and A is the aggregate information corresponding to the key element groups. Each key element combination has a corresponding candidate query interpretation. Multiple candidate query interpretations are obtained based on all key element groups C included in the set of key element groups C.
[0108] Step S3: Expand the RDF schema graph according to the key element group and the candidate query interpretation to obtain a query structure graph.
[0109] Among them, when the aggregation type corresponding to the aggregation keyword belongs to {>, <, EQU}, the aggregation operation will affect the connectivity of the query structure graph, so at this time the query is divided into two parts, the graphs are expanded separately, and the aggregation operation is used to connect them.
[0110] When the Expand function is used to expand the RDF pattern graph, a subgraph containing all key element groups is first obtained according to the key element groups and the input maximum query distance max, and then the subgraph is expanded.
[0111] During graph expansion, starting from the key elements, the graph is expanded according to the structure in the RDF schema until the connected elements are reached, resulting in the corresponding vertex query structure V. Finally, the literal elements in the query structure graph are expanded according to their attributes and literal values to obtain the edge query structure graph E. Combining the vertex query structure V with the edge query structure graph E yields the query structure graph G (i.e., G = (V, E)).
[0112] The query structure graph may be a subgraph of the RDF pattern graph, or may be a plurality of subgraphs connected by comparison operators.
[0113] Step S4, obtain multiple candidate query intentions corresponding to the keyword group based on the query structure diagram and aggregation information, and use a predetermined intention score calculation method to calculate the candidate query intentions in turn to obtain query intention scores, and sort them based on the query intention scores to obtain a query scoring sequence.
[0114] The candidate query intent refers to the query target described by the keyword group input by the user.
[0115] The intention score calculation method includes the following steps:
[0116] Step E1, determining whether the aggregation category corresponding to the aggregation keyword is direct aggregation or indirect aggregation;
[0117] In step E2, when it is determined that the information belongs to direct aggregation, the direct aggregation score Score(A)' of the aggregated information A is calculated according to formula (2):
[0118]
[0119] In the formula, operation is the query aggregation operation type, ST is the retrieval object;
[0120] In step E3, when it is determined that the information A is indirectly aggregated, the indirect aggregation score Score(A)″ of the aggregated information A is calculated according to formula (3):
[0121]
[0122] Where AT is the aggregation object, Path(AT→ST).length is the length of the path between the elements corresponding to the aggregation object AT and the search object ST;
[0123] Step E4: Calculate the score of the query structure graph G according to formula (4):
[0124]
[0125] Where G is the query structure graph;
[0126] Step E5: Calculate the query intent score of candidate query intent I according to formula (5):
[0127] Score(I)=Score(G)+(1-α)Score(A) (5)
[0128] Where α is the harmonic parameter, Score(A)∈[Score(A)′, Score(A)″].
[0129] In this embodiment, in the process of obtaining aggregated intent, the candidate query explanation El, the summary graph Gs, and the maximum distance max are input, and the final output is a candidate query intent set.
[0130] Step S5: using a query conversion algorithm, convert a predetermined number of candidate query intentions with the highest query intention scores in the query scoring sequence into corresponding SPARQL query statements and execute them in sequence to obtain all query results.
[0131] In this embodiment, after obtaining the candidate query intent, the query structure graph corresponding to the candidate query intent is converted to obtain the query statement corresponding to the candidate query intent.
[0132] For each triple<t1,property,t2> When the key element is a class or a "Literal" node, a variable var is bound to it and <? var,rdf:type,class> is added to the query statement; if the key element is an attribute edge, a triple is added to the set.<variable(v1),property,v2> , where the function variable is used to obtain the bound variable; if the key element is a relationship edge connecting two category nodes, then add the triple<variable(v1),property,variable(v2)> ; If the edge label of the key element is a comparison symbol (>, <, =), add a filter statement to filter the results.
[0133] The conversion of key elements containing aggregation information is as follows: For TOP1 aggregation operations, use group by to modify the ST variable after the WHERE clause, then add order by desc / asc count(variable(AT)), and finally use limit 1 to return the object ranked first in the result. For TOPN aggregation operations, use group by to modify the ST variable, then add having(count(variable(AT))) to filter the results. For direct aggregation operations such as MAX / MIN, add operation(ST) restrictions in the SELECT clause to constrain the results to be returned and express the corresponding query semantics. For example, SELECT MAX(?x) returns the result with the largest value corresponding to the position ?x.
[0134] In this embodiment, a group of keyword combinations input by the user corresponds to multiple candidate query intentions, and the candidate query intentions are defined as I = (G, A), where G is a query structure diagram used to describe the semantic relationship between query contents, and A is aggregated information.
[0135] In order to verify that the keyword-based RDF aggregation query method proposed in this invention has better search effect, the following experiment is conducted:
[0136] This method was implemented using the Eclipse programming environment and Java Virtual Machine version 1.8. RDF data was stored and managed using Jena. The runtime environment was a Core i5 CPU 3.10MHz, 8GB of RAM, and Windows 7 x64. The experimental data used were the Lehigh University open benchmark dataset (LUBM) and the 2005 DBLP data in RDF format. For the LUBM dataset, the code generated RDF data containing 1.27 million triples.
[0137] Figure 4 This is an efficiency graph for inverted index construction according to an embodiment of the present invention.
[0138] When building an inverted index for the LUMB and DBLP datasets, the index file size and build time are as follows: Figure 4 shown.
[0139] from Figure 4 It can be seen that the index file size is significantly smaller than the original data file size, and the time cost of index construction is low, which verifies that matching graph elements through inverted index can improve retrieval efficiency.
[0140] In order to verify the query accuracy of the keyword-based RDF aggregation query method proposed in the present invention, 10 keyword groups are randomly given for experimentation. The 10 keyword groups include general keyword queries and keyword group queries with corresponding aggregation operations such as max and count.
[0141] This experiment uses the mean reciprocal rank (MRR), a commonly used evaluation indicator in the field of information retrieval, to evaluate the accuracy of query results:
[0142]
[0143] Where k is the ranking of the correct answer in the returned results. For example, the MRR value is highest when the correct answer is ranked first, and the MRR value is 1. If the results do not contain the correct intent, the MRR value is 0.
[0144] Figure 5 This is a graph of keyword query conversion accuracy according to an embodiment of the present invention.
[0145] like Figure 5 As shown, L1-L5 are queries on the dataset LUBM, D1-D5 are queries on the dataset DBLP, and the black part is the keyword-based RDF aggregation query method proposed in this invention (i.e. Figure 5The MRR value of PowerKTS in the above example is shown in gray. The MRR value of the traditional algorithm KAT (i.e. Figure 5 The MRR value of KAT in .
[0146] from Figure 5 It can be clearly seen that the MRR values of L1, L3 and L5 of the traditional algorithm KAT on the dataset LUBM are 0, while the PowerKTS algorithm of the present invention has MRR values on the dataset LUBM, and 4 of them have MRR values of 1; on the dataset DBLP, the MRR values of D2, D4 and D5 of the PowerKTS algorithm of the present invention are 1, and the MRR values of D1 and D3 are 0.5, while the MRR value of D1-D3 of the traditional algorithm KAT is 0.
[0147] In summary, the PowerKTS algorithm of the present invention can correctly process the keywords of query statistical information, return the corresponding candidate query intent, and achieve a higher accuracy rate; while KAT only matches the aggregated keywords with the graph elements, cannot correctly parse the candidate query intent, has a lower query accuracy rate, and cannot meet normal use.
[0148] Figure 6 This is a graph showing the time consumption of keyword query conversion according to an embodiment of the present invention.
[0149] In order to verify the query efficiency of the keyword-based RDF aggregation query method proposed in the present invention, the query time of 10 groups of keyword groups in the query accuracy verification phase was recorded and obtained as follows: Figure 6 The time consumption of keyword query conversion.
[0150] like Figure 6 As shown, the black part is the keyword-based RDF aggregation query method proposed by the present invention (i.e. Figure 6 The gray one is the time consumption of the traditional algorithm KAT (i.e. Figure 6 L1-L5 are queries on the LUBM dataset, and D1-D5 are queries on the DBLP dataset.
[0151] from Figure 6 It can be seen that the PowerKTS algorithm takes slightly longer than the traditional algorithm KAT. Analysis shows that the reason for this phenomenon is that the PowerKTS algorithm needs to determine whether it is an aggregate query and obtain aggregate information before converting a given keyword query. In addition, the scale of the RDF pattern graph is small, which leads to the overall PowerKTS algorithm taking slightly longer than the traditional algorithm KAT. However, the difference between the time consumption of the PowerKTS algorithm of the present invention and that of the traditional algorithm KAT is very small. Compared with the traditional algorithm KAT, which only needs to directly query and convert given keywords, the PowerKTS algorithm of the present invention has better query efficiency.
[0152] Example Function and Effect
[0153] According to the keyword-based RDF aggregation query method provided by the above embodiment, since all aggregation operations in the SPARQL query syntax are classified to obtain multiple aggregation categories and an aggregation dictionary corresponding to the aggregation categories and aggregation intention keywords is constructed, it provides support for converting keyword queries into SPARQL query statements with aggregation operations.
[0154] Furthermore, by judging whether the keyword matches the aggregation intent keyword and then judging whether the graph element matches the candidate aggregation keyword, the situation where the keyword matches both the graph element and the aggregation category is taken into account, thereby improving the diversity and accuracy of the candidate query interpretation.
[0155] Furthermore, since the query structure graph corresponding to the aggregated keywords is obtained by expanding the RDF pattern graph according to the key elements and combining the candidate query interpretation, the statistical information is fully utilized.
[0156] Finally, due to the use of the query conversion algorithm to convert a predetermined number of candidate query intentions with the highest query intent scores in the query scoring sequence into corresponding SPARQL query statements, and the query statements are executed in sequence to obtain the query results, the final query results not only include the query statements of the query pattern but also include structured query results containing aggregation operations, making keyword queries on RDF data more efficient and the query results more accurate.
[0157] The above embodiments are only used to illustrate specific implementations of the present invention, and the present invention is not limited to the description scope of the above embodiments.
[0158] In the above embodiment, when determining whether the aggregation probability exceeds a threshold, the threshold is set to 1 / 3. In actual applications, the threshold may be adjusted continuously according to actual conditions and effects to set an optimal threshold.
Claims
1. A keyword-based RDF aggregation query method for obtaining corresponding query results for a keyword group containing multiple keywords input by a user by querying an RDF pattern graph containing multiple graph elements and an aggregation dictionary using SPARQL query syntax, characterized in that: The steps include: Step S1, matching and processing the keyword group based on the RDF pattern graph and the aggregation dictionary to obtain multiple graph element groups corresponding to the keyword group and setting them as key element groups and aggregation information; Step S2, obtaining corresponding candidate query interpretations based on the key element group and the aggregated information; Step S3, expanding the RDF schema graph according to the key element group and the candidate query interpretation to obtain a query structure graph; Step S4, obtaining multiple candidate query intents corresponding to the keyword group based on the query structure diagram and the aggregated information, calculating the candidate query intents in sequence using a predetermined intent score calculation method to obtain query intent scores, and sorting the candidate query intents based on the query intent scores to obtain a query scoring sequence; Step S5: using a query conversion algorithm to convert a predetermined number of candidate query intentions with the highest query intention scores in the query scoring sequence into corresponding SPARQL query statements and executing them in sequence to obtain all the query results. Wherein, the step S1 further includes the following sub-steps: Step S1-1, determining whether the keyword matches the aggregation intent keyword in the aggregation dictionary; Step S1-2, when the keyword matches the aggregation intention keyword, determining whether the keyword matches the graph element in the RDF pattern graph, and setting the keyword as a candidate aggregation keyword when it is determined to be matched; Step S1-3, calculating the aggregation probability that the candidate aggregation keyword is the aggregation keyword using a predetermined aggregation intention calculation rule; Step S1-4, determining whether the aggregation probability exceeds a threshold, and if so, setting the candidate aggregation keyword as the aggregation keyword, and recording the position of the aggregation keyword in the keyword group as the aggregation keyword position; Step S1-5, when the aggregation probability exceeds a threshold, obtaining aggregation information according to the aggregation keyword position; Step S1-6, matching the RDF pattern graph according to the keyword, obtaining a plurality of graph elements matching the keyword and setting them as key elements; Step S1-7, determining whether the last keyword is completed, and repeating steps S1-1 to S1-6 if the determination is no; Step S1-8: When the last keyword is completed, the key element group including all the key elements and the aggregation information corresponding to all the aggregation keywords are obtained.
2. The keyword-based RDF aggregation query method according to claim 1, characterized in that: in, The aggregation dictionary at least includes a plurality of aggregation intent keywords and aggregation categories corresponding to the aggregation intent keywords. The aggregation categories are obtained by classifying all the aggregation operations according to the differences of the aggregation operations in the SPARQL query syntax to obtain multiple aggregation categories.
3. The keyword-based RDF aggregation query method according to claim 1, characterized in that: in, The aggregation intention calculation rule is: Where k i is the candidate aggregation keyword, n is the number of all the keywords contained in the keyword group, j∈{1,2,3,...,n}, i is the position of the candidate aggregation keyword, S(k i ) is the candidate aggregation keyword k i The inverse of the distance from the key element to the match, LevDis(k i ,ele) is represented as the candidate aggregation keyword k i The edit distance between the literal value of the key element and the matching key element, It is represented as the candidate aggregation keyword k i The sum of the distances between the corresponding key element and other key elements in the keyword group on the RDF pattern graph, P(op|k i ) is the aggregation probability corresponding to the candidate aggregation keyword.
4. The keyword-based RDF aggregation query method according to claim 2, Its characteristics are: The aggregation categories are divided into direct aggregation and indirect aggregation. The intention score calculation method includes the following steps: Step E1, determining whether the aggregation category corresponding to the aggregation keyword belongs to direct aggregation or indirect aggregation; Step E2: When it is determined that the information A belongs to the direct aggregation, the direct aggregation score Score(A)' of the aggregation information A is calculated according to formula (2): Where operation is the type of aggregation operation to be queried, and ST is the retrieval object; Step E3: When it is determined that the information A belongs to the indirect aggregation, the indirect aggregation score Score(A)″ of the aggregation information A is calculated according to formula (3): Where AT is the aggregation object, Path(AT→ST).length is the length of the path between the element corresponding to the aggregation object AT and the search object ST; Step E4, calculate the score of the query structure graph G according to formula (4): Where G is the query structure graph; Step E5: Calculate the query intent score of the candidate query intent I according to formula (5): Score(I)=Score(G)+(1-α)Score(A) (5) Where α is the harmonic parameter, Score(A)∈[Score(A)′, Score(A)″].
Citation Information
Patent Citations
Spark Streaming-based streaming RDF data multi-keyword parallel search method
CN108509543A
Method for querying keywords in federated RDF database
CN108804580A