A knowledge graph fuzzy query method
By fuzzy extension of SPARQL1.1 syntax, f-SPARQL1.1 syntax is proposed, which solves the fuzzy query problem of RDF data model under aggregation, and provides a flexible fuzzy membership function setting method, achieving efficient knowledge graph Fuzzy query and qualitative preference analysis.
Patent Information
- Application Number
- CN202210151393.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-02-17
- Publication Date
- 2025-02-21
- Estimated Expiration
- 2042-02-17
AI Technical Summary
The existing RDF data model has not been effectively solved in the fuzzy query under the aggregation situation, and the setting process of fuzzy membership functions has not been paid enough attention, which has led to difficulties in actual implementation and flexible migration of fuzzy query.
By fuzzy extension of SPARQL1.1 syntax, f-SPARQL1.1 syntax is proposed, which supports fuzzy aggregation query and qualitative preference settings, and provides automated, semi-automated and customized fuzzy membership function setting methods to lower the operation threshold and improve flexibility sex.
It realizes the ability to fuzzy query on the knowledge graph, supports fuzzy aggregation operations and qualitative preference settings, simplifies the setting process of fuzzy membership functions, and improves the flexibility and accuracy of the query.
Smart Images

Figure CN114706901B_ABST
Abstract
Description
Technical Field
[0001] The present invention discloses a fuzzy query method for knowledge graphs. The main data model of the knowledge graph is the RDF (Resource Description Framework) model. The present invention performs fuzzy syntax expansion on the standard query language SPARQL of RDF and uses fuzzy set theory to explain its syntax operation principle, and pays attention to the setting method of fuzzy membership function, and provides three methods for setting fuzzy membership function. The present invention is in the field of fuzzy query of knowledge graphs. Background Art
[0002] The knowledge graph was first proposed by Google in 2012. It is usually composed of entities and relationships. Famous large-scale knowledge graphs such as WikiData, DBpedia, FreeBase, etc. have been widely used in various downstream tasks, such as intelligent question-answering systems and recommendation systems. Knowledge graphs act as knowledge bases in most intelligent tasks and are the brain and core of the tasks. Therefore, knowledge graph query and exploration tasks, as an important means of acquiring knowledge, have received widespread attention. In daily natural language use, fuzzy terms are usually included, and it is even more common to include fuzzy terms in query statements. Using fuzzy terms is an imprecise way of expression unique to humans, and using fuzzy terms in queries is more in line with natural language habits. Therefore, the discussion of fuzzy situations in query expressions has been widely discussed in relational database models. With the rise of the semantic web, data models such as XML (Extensible Markup Language) and RDF (Resource Description Framework) have emerged one after another. In recent years, the application of fuzzy queries on NoSQL databases has also received more and more attention. The fuzzy query task of data is usually carried out from two aspects. One is to fuzzify the data model itself, provide a fuzzy extension and define the query method, and the other is to expand the data query language through fuzzy syntax and convert it into an accurate query with the help of fuzzy set theory. The present invention uses the latter method to realize the fuzzy query of knowledge graph. RDF is a main data representation model of knowledge graph, SPARQL is the standard query language of RDF, and SPARQL1.1 is an upgraded version after 2013. The present invention proposes fuzzy SPARQL1.1 (f-SPARQL1.1) syntax by fuzzy extension of SPARQL1.1 syntax for fuzzy query of knowledge graph.
[0003] The present invention uses the form of FILTER(?XθFT)[WITHα] to express fuzzy query, which is based on previous work. SPARQL1.1 newly introduces the function of value aggregation. Through the counting (COUNT), summing (SUM), minimum (MIN), maximum (MAX) and average (AVG) operators, database instances can be counted and summarized. Aggregation is a very useful operation in database query language. In the past fuzzy query work of relational databases, fuzzy aggregation operations have also been discussed and studied. However, fuzzy queries under aggregation have not been considered in the query work of precise RDF data models. Therefore, the present invention supplements the fuzzy extension of aggregation query for the fuzzy extension of SPARQL, and realizes the ability to perform aggregation operations after grouping data using fuzzy terms, as well as aggregation operations on fuzzy sets. Preference queries are usually divided into quantitative preference queries and qualitative preference queries. The quantitative preference method defines the fuzzy query results through an atomic scoring function, and then sorts the answers according to the score. In the past, quantitative preference queries were mostly used in preference queries, while the qualitative preference setting method uses a set of preference relationships defined by the user, uses the Pareto standard to filter out a part of the data set, and only returns the optimal data measured by the Pareto standard. This type of query is usually called SkyLine query. Skyline queries are widely used in the field of precise queries on relational data and RDF, and recently there has also been research on Skyline queries for knowledge graphs. Therefore, the present invention introduces qualitative preference settings into fuzzy queries. Different from precise qualitative preference queries, the qualitative preference queries designed in this article are only for fuzzy items.
[0004] The fuzzy set theory proposed by Zadeh is the main theoretical support in the field of fuzzy query. The fuzzy membership function is a means of describing fuzzy terms and a bridge between fuzzy terms and precise value expressions. Therefore, the fuzzy membership function plays a vital role in the fuzzy query process. However, the current SPARQL fuzzy query extension method does not pay much attention to the establishment process of the fuzzy membership function, which brings difficulties to the actual implementation and flexible migration of fuzzy queries. Therefore, in view of this problem, the present invention designs a visual interface that defines the membership function required for fuzzy terms, and provides users with three modes of setting membership functions: automatic, semi-automatic, and customized. Users can set membership functions through these three methods. The visual interface further reduces the operation threshold, and the customized membership function mode can set a membership function that is more in line with the user's personality.
[0005] In summary, the present invention makes the following contributions: It supplements fuzzy aggregation query and qualitative preference setting method for SPARQL1.1 syntax, proposes a fuzzy extended grammar f-SPARQL1.1 for knowledge graph fuzzy query, and provides a conversion algorithm for converting f-SPARQL1.1 into executable SPARQL syntax. In addition, it provides three modes for establishing fuzzy membership functions and implements a visual query interface. Summary of the invention
[0006] Purpose of the invention: The purpose of the present invention is to provide a fuzzy query method for a knowledge graph, so as to realize fuzzy query on the knowledge graph.
[0007] Technical solution: In order to achieve the above-mentioned purpose, the present invention proposes a fuzzy query method for knowledge graphs. The present invention extends the fuzzy syntax of the standard query language SPARQL, which is the main data model of the knowledge graph, RDF data model, and focuses on the fuzzy membership function setting of fuzzy queries, providing three fuzzy membership function setting modes: automatic, semi-automatic, and customized. In addition, the fuzzy query language proposed by the method is explained to explain how the syntax works. The specific technical solution of the present invention includes the following contents:
[0008] (1) Analyze and summarize the previous fuzzy query methods and languages for precise RDF data. The previous fuzzy query methods are mainly implemented in the form of FILTER(?XθFT)[WITHα], where the main function of FILTER in SPARQL query statements is conditional filtering, where ?X is a variable, θ represents an operator, which can be greater than, less than, equal to, etc., or "Between and", and θ can also be a fuzzy operator, which is the fuzzification of the above operators, such as "close to", "not less than", "not greater than", etc. FT is a fuzzy term, such as "elderly", "young people", etc. Fuzzy terms are not only the above fuzzy words, but also include modifiers such as "very old".
[0009] (2) In view of the lack of fuzzy aggregation functions in the precise RDF data model, the aggregation operations for fuzzy sets are supplemented, and the fuzzy query syntax is supplemented as shown in Table 1. This paper provides fuzzy syntax extension support for COUNT, SUM, AVG, MIN, and MAX aggregation functions. Its extension form is the same as the fuzzy extension form of f-SPARQL: [AGG_FUNCTION](?xθFT)[withα], where [AGG_FUNCTION] represents a function among fCOUNT, fSUM, fAVG, fMIN, and fMAX, FT represents a fuzzy term, α is the minimum membership degree that satisfies the condition, and is used to convert fuzzy query statements using fuzzy cut set theory, and θ represents an operator. Table 1 explains their meanings respectively. Ordinary aggregation functions can only perform aggregation operations on precise sets, while the aggregation functions in Table 1 can perform aggregation operations on fuzzy sets, and calculate the number of items, average value, maximum value, minimum value, etc. For example, when asking "How many elderly people are there in this data set?", the following query statement can be used.
[0010] Table 1 SPARQL aggregation function fuzzy extension
[0011]
[0012] (3) The fuzzy grouping syntax is supplemented. The aggregation function is actually based on GROUP BY. In the past, GROUP BY was usually followed by the precise attributes of the data. For example, the query "the number of people of each gender in the data set" is to group the data according to the precise attribute of gender. However, the GROUB BY discussed in the invention is followed by fuzzy attributes and classified according to fuzzy terms. For example, "query the number of people of each age group in the data set" should be grouped according to the fuzzy terms "young people, middle-aged people, and elderly people" and then queried. For the classified set, fuzzy aggregation operations and ordinary aggregation operations can be performed again. The role of having is to filter the grouped data. This method defines the syntax shown in Table 2.
[0013] Table 2 Fuzzy grouping related fuzzy extension grammar
[0014]
[0015] In Table 2, the lingTrans function is the key to converting precise data into fuzzy terms. If fuzzy grouping is to be performed, the precise data must first be converted into fuzzy terms through the lingTrans function and then grouped. lingFew, lingMost, and lingAbstract are syntactic sugars that can perform fast grouping and aggregation operations. The function of lingFew is: receive the given parameters, perform fuzzy grouping on the given parameters, the grouping result is the fuzzy term, and return the fuzzy term with the least amount of data in the group and the corresponding membership. For example, given the parameter "age" for fuzzy grouping, fuzzy terms such as "elderly", "middle-aged", and "youth" will first be formed. If the number of data sets in the group "youth" is the least, "youth" and the corresponding membership will be returned. The function of the lingMost function is opposite to that of the lingFew function. It returns the fuzzy term with the largest amount of data in the group after fuzzy grouping and the corresponding membership. The function lingAbstract is a superposition of the functions of lingMost and lingFew. It can simultaneously return the two fuzzy terms with the largest and smallest number in the group after fuzzy grouping, thus forming a simple summary.
[0016] The input [s,p] of the function lingTrans([s,p],value,α) is the subject and predicate. The corresponding fuzzy membership function can be located through the subject and predicate, and then the fuzzy transformation is performed. The function provides the function of converting the value value into all fuzzy terms whose fuzzy term membership corresponding to [s,p] exceeds a. If it does not exist, None is returned. The function also returns the membership of value corresponding to this fuzzy term. The function provided by the lingTrans(mfId,value,α) function is the same as that of the lingTrans([s,p],value,α) function in Table 2, but the input parameters are different. mfId (Membership FunctionsId) is the ID of the fuzzy membership function group, and [s,p] can locate multiple groups of fuzzy membership functions, that is, there is a one-to-many association between [s,p] and mfId. When the parameter of lingTrans is ([s,p],value,α), the return result is the fuzzy terms that meet the conditions in all groups, while when the lingTrans function takes (mfId,value,α) as a parameter, it can only return the fuzzy terms in a set represented by mfId and return the results that meet the conditions.
[0017] In the input parameters of the function lingFew(s,p1,p2,…,α), s represents the subject, p1 and p2 represent the predicates or attributes. They are variable parameters and at least one should be provided. α is the threshold, which is a floating point number between 0 and 1. The function of α is to filter out the data whose attribute membership is less than α so that it does not participate in the analysis. The filtered data is considered invalid data. The function fgroup bylabel can realize the grouping of the column where value is located according to the fuzzy terms corresponding to [s,p] or mfId. There can be multiple groups of label functions after fgroup by, which is similar to the ordinary group by grouping, and the Cartesian product of fuzzy terms is used as the standard for grouping. Using fgroup by can solve the problem of "querying the average age of each age stage in the data set". fhaving corresponds to having in SPARQL, and can filter the results after grouping by fuzzy terms.
[0018] (4) Supplementary qualitative preference settings, there are two tuples t1 = (u1, u2, ...., u n ),t2=(u1,u2,....,u n ), t1, t2 represent two pieces of data selected from the query results, u i For attributes, define t1>t2 in the Pareto criterion as t1 is better than t2, when the attributes of all dimensions in t1 are better than or equal to the corresponding attributes in t2, and at least one dimension attribute in t1 is strictly better than the corresponding attribute in t2, expressed in mathematical language:
[0019]
[0020] Using this preference setting method can help users get the target answer more accurately and filter out useless data. This paper applies BNL (block-nested-loops) to process qualitative preference analysis. After using qualitative preferences, there are usually multiple query results. The display order of these results is combined with the Top-K algorithm. The weighted average membership is calculated by multiplying the weight and the membership, and the results are sorted in descending order according to the weighted average membership. The preference syntax used in this invention is as follows:
[0021] FUZZYQPREFER? x1? x2…(w1,w2).
[0022] (5) Focusing on the setting method of fuzzy membership function, automatic, semi-automatic, and customized fuzzy membership function setting methods are provided. The user provides the subject and predicate of the membership function. The system divides the subject and predicate query data into three fuzzy sets of "low", "medium", and "high" according to the distribution of the subject and predicate query data in the knowledge graph, and then uses the triangular membership function establishment method to establish the fuzzy membership function. In the semi-automatic setting of membership function mode, the user is allowed to specify the range of the fuzzy domain, the number of fuzzy term domains, the corresponding fuzzy terms, and the shape of the fuzzy membership function. The system provides triangular, trapezoidal and other membership functions. In the customized mode, the user needs to set the maximum value, minimum value and fuzzy term of this membership function, and set the membership function for this fuzzy term by hand-drawing. This method gives the user absolute freedom. The user can fully control the shape of the fuzzy membership function they want. In addition, the user can also set the fuzzy membership function through a customized function expression.
[0023] (6) An explanation is given for the above-mentioned aggregation function syntax and fuzzy grouping algorithm for fuzzy sets. The algorithm for fuzzy sets is completed by converting it into f-SPARQL syntax, while the syntax for fuzzy grouping requires obtaining the answer set and then using the fuzzy membership function to convert it into a post-grouping operation.
[0024] Beneficial effects: The present invention provides a fuzzy query method for knowledge graphs, which enables users to use fuzzy terms in natural sentences to query knowledge graphs. The method also provides three methods for setting fuzzy membership functions, which enable users to set fuzzy membership methods through different methods and set fuzzy membership functions that better meet user needs. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] Figure 1 RDF data model;
[0026] Figure 2 The relationship between [s,p] and mfId and the fuzzy membership function;
[0027] Figure 3 Automatically establish fuzzy membership functions;
[0028] Figure 4 Semi-automatic establishment of fuzzy membership functions;
[0029] Figure 5 Manually set the membership function form;
[0030] Figure 6 Workflow of the present invention. DETAILED DESCRIPTION
[0031] In order to enable those skilled in the art to better understand the technical problems, technical solutions and technical effects in the present invention, the present invention is further described below in conjunction with the accompanying drawings.
[0032] The present invention performs fuzzy query on the knowledge graph data model, and represents the RDF model for the main data of the knowledge graph. Figure 1 As shown, RDF is a set of triples (s, p, o), where s represents a subject and has a unique HTTP URI with a unique id, o is an object, and p is a predicate, representing an attribute or a relationship. (s, p, o) can be expressed as a relationship p between s and o or as s having the attribute p of o. The structured query language of RDF is SPARQL. The present invention provides a fuzzy extension of SPARQL aggregation function, a fuzzy grouping extension of SPARQL, a qualitative preference analysis, and three fuzzy membership function setting methods. Next, the technical implementation process of the method is specifically described.
[0033] (1) First, the conversion algorithm of the fuzzy extended grammar in Table 1 is explained. Specifically, the fuzzy aggregation function is converted into a general aggregation function, and then the main content of the aggregation function is converted. The form of FILTER(?XθFT)[WITHα] is added to the matching body of SPARQL. The specific algorithm is shown in Algorithm 1.
[0034]
[0035] (2) Then explain the syntax described in Table 2 above, and provide an execution algorithm. The input [s, p] of the function lingTrans([s, p], value, α) is the subject and predicate. The corresponding fuzzy membership function can be located through the subject and predicate, and then fuzzy conversion is performed. The function provided is to convert the value value into all fuzzy terms whose fuzzy term membership degree corresponding to [s, p] exceeds α. If it does not exist, None is returned. Not only the fuzzy term is returned, but also the membership degree of value corresponding to this fuzzy term is returned; the function provided by the lingTrans(mfId, value, α) function is the same as the function numbered 1 in Table 3, but the input parameters are different. mfId (Membership Functions Id) is the id of the fuzzy membership function group. Unlike the function numbered 1, [s, p] can locate multiple groups of fuzzy membership functions, that is, [s, p] and mfId are in a one-to-many relationship. The result returned by the function numbered 1 is the fuzzy terms that meet the conditions in all groups, while the function numbered 2 can only return the fuzzy terms in a set represented by mfId, and returns the results that meet the conditions. Figure 2The relationship between [s,p] and mfId and fuzzy membership function is shown, where [huaman,age] is an example of [s,p], representing subject and predicate, and subject and predicate cannot be variables, but should be a certain resource address. Sets {young,old} and so on are multiple sets of fuzzy terms, and each term in the set corresponds to a fuzzy membership function. In the input parameters of the function lingFew(s,p1,p2,…,α), s represents the subject, p1 and p2 represent the predicate or attribute, which are variable parameters and at least one must be filled in, and α is the threshold, which is a floating point number between 0 and 1. The role of α is to filter out the data whose attribute membership of a certain data is less than α so that it does not participate in the analysis, and such data is considered invalid data. The lingFew function can analyze the result set according to the attributes p1 and p2, classify the fuzzy terms according to p1 and p2, and find out what are the characteristics of the data with the smallest proportion. Its characteristics are expressed using fuzzy terms, and the result is returned as the fuzzy term with the smallest proportion and the average membership. The parameters of lingMost, lingAbstract and lingFew have the same meaning. The following is an introduction to the working principle of this syntax.
[0036] The lingTrans function corresponds to a set of fuzzy membership functions {μ A ,μ B μ C ,...}, where A, B, C,... are fuzzy terms. Substitute the input value into the membership function group to obtain the membership degree d a ,d b ,d c ,…compare the size of the membership, and return all fuzzy terms and memberships whose membership values are higher than the set threshold α. lingTrans and lingFew functions and lingMost, lingAbstract are all downstream extensions of SPARQ1.1. The algorithm process is to first obtain the lingTrans expression parameter [s, p] or mfid in the f-SPARQL1.1 query. If the obtained parameter is [s, p], then obtain its corresponding mfId group through [s, p], and then calculate the membership according to the fuzzy terms corresponding to each mfId, and filter out all fuzzy terms and memberships with a membership greater than α, that is, the return form is {(A, d1), (B, d2),...}. Among them, A and B represent fuzzy terms, and d represents membership.
[0037] The function lingAbstract generates a simple summary based on fuzzy grouping, groups the fuzzy terms of the provided features, and analyzes the number of each group. The algorithm flow of lingAbstract is similar to that of lingMost and lingFew, and is the intermediate result of lingMost and lingFew. Therefore, the present invention will explain the algorithm of lingMost. The input of lingMost is (s, p1, p2,…, α). The subject in the input parameter of lingMost and the other predicates in the parameter form a tuple parameter (s, p1), (s, p2),… and the threshold α as the input of the lingTrans function, and the return value R = {(A, d1), (B, d2),...} is obtained. It should be noted that lingTrans may return multiple fuzzy terms with the same membership. When the lingMost input parameter contains only one predicate p i , perform the above operation on each data and merge the set to obtain Set(R), analyze the number of fuzzy terms in each set, and take the fuzzy term with the largest number as the result. When the number of fuzzy terms contained in multiple items is the same, calculate the average distance of the data belonging to this fuzzy term relative to the fuzzy Core, take the result with the closest distance, and return all if they are still the same. The calculation formula (1) of the distance to the Core is the Euclidean distance between the point with the membership degree as the coordinate and the point with the value of 1 in each dimension.
[0038]
[0039] When the lingMost input parameter contains multiple predicates, the processing method is different from the above process. When a piece of data e contains multiple predicates p1, p2, ... p n When multiple groups of fuzzy term results R1, R2, ...R n Then for data e, we need to use a combination of these terms to represent the characteristics of data e, that is, to perform a Cartesian product operation R = R1×R2×...R n , when R1={(term 11 ,d1),(term 12 ,d1)},R2={(term 21 ,d2),(term 22 ,d2)},R3={(term 31 ,d3)}, the result of R1×R2×R3 is shown in (2).
[0040]
[0041] The following processing is similar to the processing method with only one predicate, finding the features with the most fuzzy term characteristics. If the number is the same, the average distance is calculated. Algorithm 2 shows the conversion process in code language. Lines 9-23 are the process of calculating the Cartesian product of attributes.
[0042]
[0043] The processing of f-group by is actually similar to the above process. The processing of lingMost is an actual example of grouping. f-group by is followed by label([s,p],value) to group the fuzzy terms corresponding to [s,p] and mfId. Fuzzy grouping is different from traditional grouping. Traditional grouping has no intersection between groups and is an absolute grouping. However, according to fuzzy term grouping, there may be intersections between groups, because according to fuzzy sets, an element may belong to fuzzy term A or fuzzy term B, but the degree of membership is different.
[0044] To implement fuzzy grouping, first apply the lingTrans function to convert the attributes of the precise data items into fuzzy terms, and input the parameters in label into lingTrans. Note that there may be multiple fuzzy terms, so the grouping should be based on the Cartesian product of these fuzzy attributes, which is consistent with the processing process of the lingMost function mentioned above. After grouping, you can use aggregation functions in these fuzzy sets. fhaving is the screening after fuzzy grouping and aggregation operations, which is converted into precise interval queries using fuzzy set theory. The conversion process is inherited from f-SPARQL work, and then the query results are filtered according to the conditions. For example, "Query the average height of each age group in the data set." The query statement is as follows.
[0045] #FQ#
[0046] select(average(?height)as?avHeight),label('ageMF',?age,0.8)
[0047] where
[0048] {
[0049] ? human ud:height ? height
[0050] ? human ud:age? age
[0051] }fgroup by label('ageMF',?age,0.5)
[0052] fhaving? avHeight='normal'with 0.5
[0053] When the data in the knowledge base is as shown in Table 3, assuming that the membership in the table is calculated based on the membership function, the results after execution are {177, old}, {176, middle}, {172, young}, where the first dimension data is the average height and the second dimension data is the age stage.
[0054] Table 3 Sample data table
[0055]
[0056] (3) The present invention provides three fuzzy membership function setting methods, specifically through Figure 3 , Figure 4 , Figure 5 Indicates. Under the mode of automatically setting the fuzzy membership function, the user provides the subject and predicate of the membership function. The system divides it into three fuzzy sets of "low", "medium" and "high" according to the distribution of the subject and predicate query data in the knowledge graph, and uses the triangular membership function establishment method to establish the fuzzy membership function. According to the subject and predicate provided by the user, the maximum and minimum values obtained are maxV and minV. To establish the fuzzy membership function of "low, medium, and high", it is necessary to divide [maxV, minV] into six parts, each of which has a length of (maxValue-minValue) / 6. The range of the fuzzy term "low" is [minValue, minValue+2x), where [minValue+x, minValue+5x) is the range of the fuzzy term "medium". [minValue+4x, maxValue) is the range of the fuzzy term "high". The fuzzy membership function image divided by the above method is as follows Figure 3 shown.
[0057] In the semi-automatic setting of membership function mode, users are allowed to specify the range of the fuzzy domain, the number of fuzzy term fields, the corresponding fuzzy terms, and the shape of the fuzzy membership function. The system provides triangular, trapezoidal and other membership functions. Provides a visual interface Figure 4 As shown, the left part of the interface allows you to customize the interval size and fuzzy terms and select the shape of the membership function, and the middle part displays the results of selecting the triangular membership function.
[0058] Using semi-automatic creation of membership functions can give users a certain degree of freedom, but it requires users to have a certain understanding of fuzzy set theory. Although the form of semi-automatic creation of membership functions provides users with the option of setting the number of fuzzy intervals, terms and the shape of membership functions, there are still certain limitations. Therefore, we provide users with a completely manual membership function setting mode. In this mode, users need to set the maximum value, minimum value and fuzzy terms described by this membership function, and set the membership function for this fuzzy term by hand-drawing. This method gives users absolute freedom. Users can fully control the shape of the fuzzy membership function they want. In addition, users can also set the fuzzy membership function by customizing the function expression. The setting interface is as follows: Figure 5 As shown in the figure, the drawing board is completed using the Canvas library.
[0059] (4) The above process can be Figure 6 It shows that membership functions can be persisted in the database. Part of the work of f-SPARQL1.1 is done by converting to SPARQL, and the other part is done after querying the knowledge graph results. The rest of this section describes how to convert the grammar extension defined in Chapter 4 into SPARQL1.1.
Claims
1. A knowledge graph fuzzy query method, characterized in that: The steps include: (1) Supplement the fuzzy aggregation function syntax, fuzzy grouping syntax, and qualitative preference analysis syntax for SPARQL fuzzy query of RDF; (2) Propose an execution algorithm for the above fuzzy query grammar; (3) Focusing on the membership function setting of RDF fuzzy query, we propose three interactive models of membership function setting: automatic, semi-automatic and customized, and implement a visual interface; The fuzzy aggregate function syntax proposed in step (1) is a fuzzified form of the aggregate function syntax newly added to SPARQL1.1, and its form is shown in Table 1; Table 1 SPARQL aggregation function fuzzy extension Where, fCOUNT, fSUM, fAVG, fMIN, and fMAX represent the fuzzy extended forms of the aggregation functions COUNT, SUM, AVG, MIN, and MAX, respectively; x is a variable, FT is a fuzzy term, α is the minimum membership degree that satisfies the condition, and is used to convert fuzzy query statements using fuzzy cut set theory; θ represents an operator; The explanation of the fuzzy grouping grammar in step (1) is shown in Table 2; Table 2 Fuzzy grouping related fuzzy extension grammar The input [s,p] of the function lingTrans([s,p],value,α) is the subject and predicate. The corresponding fuzzy membership function is located through the subject and predicate, and then fuzzy conversion is performed. The function provides the function of converting the value value into all fuzzy terms whose fuzzy term membership degree corresponding to [s,p] exceeds α. If it does not exist, None is returned. The function also returns the membership degree of value corresponding to this fuzzy term. The function provided by the lingTrans(mfId,value,α) function is the same as that of the lingTrans([s,p],value,α) function, but the input parameters are different. mfId is the id of the fuzzy membership function group. [s,p] can locate multiple groups of fuzzy membership functions, that is, there is a one-to-many association between [s,p] and mfId. When the parameter of lingTrans is ([s,p],value,α), the return result is the fuzzy terms that meet the conditions in all groups, while when the lingTrans function takes (mfId,value,α) as a parameter, it can only return the fuzzy terms in a set represented by mfId and return the results that meet the conditions. The input parameters of the function lingFew(s,p1,p2,…,α) are s represents the subject, p1 and p2 represent the predicates or attributes, which are variable parameters and at least one should be provided. α is the threshold, which is a floating point number between 0 and 1. The role of α is to filter out the data whose attribute membership is less than α so that it does not participate in the analysis. The filtered data is considered invalid data; the function fgroup by label can realize grouping of the fuzzy terms corresponding to [s,p] or mfId in the column where value is located; fhaving function can filter the results after grouping by fuzzy terms; lingFew, lingMost, lingAbstract is a kind of syntactic sugar that can perform fast grouping and aggregation operations. The function of lingFew is: receive the given parameters, perform fuzzy grouping on the given parameters, the grouping result is the fuzzy term, and return the fuzzy term with the least amount of data in the group and its corresponding membership; the function of lingMost function is opposite to that of lingFew function, and returns the fuzzy term with the most amount of data in the group after fuzzy grouping and its corresponding membership; the function lingAbstract is the superposition of the functions of lingMost and lingFew, and can simultaneously return the two fuzzy terms with the largest and smallest number in the group after fuzzy grouping, thus forming a simple summary; The syntax for qualitative preference analysis in step (1) is as follows: FUZZYQPREFER? x1? x2…(w1,w2) Among them, ?x1?x2 are variables involved in fuzzy query, w1,w2 represent the weights corresponding to ?x1?x2; In step (2), the execution algorithm includes the following steps: (2.1) First, the query statement containing the fuzzy aggregate function is parsed into f-SPARQL, and then the fuzzy aggregate function is converted into an executable SPARQL statement using the f-SPARQL syntax rules; (2.2) The fuzzy grouping function contains the lingTrans syntax, which is executed after converting the fuzzy query syntax into SPARQL syntax and then querying the knowledge graph to obtain the structure. By inputting the numerical value in the result into each fuzzy term, the membership degree corresponding to each fuzzy term is obtained; (2.3) lingFew and lingMost, including lingAbstract, included in Table 2 are all downstream extensions of the lingTrans grammar. The steps are as follows: first, use the lingTrans function to convert the query result into a data entry with fuzzy term features and fuzzy membership. One attribute corresponds to multiple fuzzy terms and memberships. A Cartesian product is performed on a data entry to obtain the fuzzy term combination corresponding to the data, and the combination includes the fuzzy membership; then, the combination with the most and least occurrences in the fuzzy term feature combination is calculated; if the number of occurrences is the same, the distance between the fuzzy term feature combination and the combination core is calculated, and the group with the closest distance is selected as the answer; the distance to the fuzzy term core is calculated using the Euclidean distance formula, and its formula expression is shown in formula (1), where n represents the number of fuzzy terms in a data; after the above calculation, the results of lingMost, lingFew, and lingAbstract are obtained; d i represents the degree of membership; (2.4) The processing process of fgroup by is to first use the lingTrans function to convert the specified characteristics into fuzzy terms. If there are multiple characteristic conversions, the attribute combination is obtained by using the Cartesian product expansion, and the data is grouped according to the attribute combination of the same category; (2.5) The execution process of the qualitative preference analysis algorithm is to sort and filter the results of the data after querying the knowledge graph using the BNL algorithm; The specific steps of step (3) include: (3.1) When the fuzzy membership function is set automatically, the subject and predicate provided by the user are divided into three fuzzy sets: "low", "medium" and "high", and then the fuzzy membership function is established using the triangular membership function establishment method; according to the subject and predicate provided by the user, the maximum and minimum values obtained are maxV and minV respectively. To establish the fuzzy membership function of "low", "medium" and "high", it is necessary to divide [maxV, minV] into six parts, and the length of each part is x = (maxValue-minValue) / 6. The range of the fuzzy term "low" is [minValue, minValue+2x), [minValue+x, minValue+5x) is the range of the fuzzy term "medium"; [minValue+4x, maxValue) is the range of the fuzzy term "high", and the fuzzy membership function image divided by the above method is obtained; (3.2) In the mode of semi-automatic setting of membership functions, the user is allowed to specify the range of the fuzzy domain, the number of fuzzy term domains, the corresponding fuzzy terms, and the shape of the fuzzy membership function; (3.3) Fully manual membership function setting mode: The user needs to set the maximum value, minimum value and fuzzy term of this membership function, and set the membership function for this fuzzy term by hand-drawing; in addition, the user can also set the fuzzy membership function by customizing the function expression; the hand-drawing board is drawn using the Canvas library.