Disclosure of Invention
The invention provides a fuzzy query method, a device, equipment, a medium and a product, which are used for solving the problem that the existing fuzzy query mode cannot be suitable for fuzzy query with relative quantifier.
The first aspect of the present invention provides a fuzzy query method, including:
acquiring a fuzzy query statement to be identified;
performing semantic recognition on the fuzzy query statement to be recognized and splitting the fuzzy query statement to be recognized into a plurality of terms with fuzzy semantics and a plurality of terms with definite semantics; the semantic-specific words are consistent with entities corresponding to nodes in a graph database; the words with fuzzy semantics comprise relative quantifiers;
determining a preset membership function and a preset membership range threshold value which are matched with each term with the fuzzy semantics;
determining a local definite query range corresponding to the words with fuzzy semantics according to each preset membership function and the corresponding preset membership range threshold;
determining a global explicit query range corresponding to the fuzzy query statement according to each local explicit query range, the explicit semantic terms adjacent to the relative quantifier and other explicit semantic terms;
and querying target data from the graph database according to the global explicit query range.
Further, the method as described above, the other explicit semantic terms include query target entities;
determining a global explicit query range corresponding to the fuzzy query statement according to each local explicit query range, the explicit semantic terms adjacent to the relative quantifier, and the other explicit semantic terms, including:
determining the total number of correlation nodes required for query corresponding to nodes in a graph database matched with a query target entity; wherein the correlation nodes required for query are nodes in the graph database corresponding to the words with definite semantics adjacent to the relative quantifier;
determining the total number of associated nodes required by the query as a local explicit query range of the words with explicit semantics adjacent to the relative quantifier;
determining data contained in nodes in the database corresponding to the other clear semantic terms as local clear query ranges of the other clear semantic terms;
and determining the local explicit query range of each term with fuzzy semantics, the local explicit query range of the term with the fuzzy semantics adjacent to the relative quantifier and the local explicit query range of the term with other explicit semantics as the global explicit query range corresponding to the fuzzy query statement.
Further, the method as described above, the term with fuzzy semantics further includes: a tone operator;
the determining a local explicit query range corresponding to a term with fuzzy semantics according to each preset membership function and a corresponding preset membership range threshold includes:
if the words with the fuzzy semantics are tone operators, determining a preset membership range threshold matched with the tone operators as a first membership range threshold;
determining a first initial query range according to the first membership range threshold and a preset membership function matched with the tone operator;
and performing defuzzification processing on the first initial query range to determine a local explicit query range corresponding to the mood operator.
Further, in the above method, if the term with the fuzzy semantics is a relative quantifier, the determining a local explicit query range corresponding to the term with the fuzzy semantics according to each of the preset membership functions and the corresponding preset membership range threshold includes:
determining a preset membership range threshold matched with the relative quantifier as a second membership range threshold; the preset membership function matched with the relative quantifier is a linear membership function;
determining a second initial query range according to the second membership range threshold and the linear membership function;
and performing defuzzification processing on the second initial query range by adopting a reverse method to determine a local explicit query range corresponding to the relative quantifier.
Further, the method as described above, the term with fuzzy semantics further includes: fuzzification operators;
the determining a local explicit query range corresponding to a term with fuzzy semantics according to each preset membership function and a corresponding preset membership range threshold includes:
if the words with the fuzzy semantics are fuzzification operators, determining a preset membership range threshold matched with the fuzzification operators as a third membership range threshold;
determining matched adjusting parameters and words of definite semantics adjacent to the fuzzification operator in the fuzzy query statement according to a preset membership function matched with the fuzzification operator;
and inputting the adjusting parameters and the clear semantic words adjacent to the fuzzification operator in the fuzzy query statement into a preset membership function matched with the fuzzification operator by taking the third membership range threshold as a boundary condition so as to output a local clear query range corresponding to the fuzzification operator.
Further, in the method as described above, the preset membership function matched with the blurring operator is:
wherein x represents a certain value in a local explicit query range corresponding to the fuzzification operator, y represents a term of explicit semantics adjacent to the fuzzification operator, and δ represents an adjustment parameter.
A second aspect of the present invention provides an apparatus for fuzzy query, including:
the acquisition module is used for acquiring the fuzzy query statement to be identified;
the semantic recognition module is used for performing semantic recognition on the fuzzy query statement to be recognized and splitting the fuzzy query statement to be recognized into a plurality of terms with fuzzy semantics and a plurality of terms with definite semantics; the semantic-specific words are consistent with entities corresponding to nodes in a graph database; the words with fuzzy semantics comprise relative quantifiers;
the function determining module is used for determining a preset membership function matched with each term with the fuzzy semantics and a preset membership range threshold;
the local range determining module is used for determining a local definite query range corresponding to the words with the fuzzy semantics according to each preset membership function and the corresponding preset membership range threshold;
a global scope determining module, configured to determine a global explicit query scope corresponding to the fuzzy query statement according to each local explicit query scope, the explicit semantic terms adjacent to the relative quantifier, and the other explicit semantic terms;
and the query module is used for querying the target data from the graph database according to the global explicit query range.
Further, the apparatus as described above, the other semantic-specific terms include query target entities;
the global scope determination module is specifically configured to:
determining the total number of correlation nodes required for query corresponding to nodes in a graph database matched with a query target entity; wherein the correlation nodes required for query are nodes in the graph database corresponding to the words with definite semantics adjacent to the relative quantifier; determining the total number of associated nodes required by the query as a local explicit query range of the words with explicit semantics adjacent to the relative quantifier; determining data contained in nodes in the database corresponding to the other clear semantic terms as local clear query ranges of the other clear semantic terms; and determining the local explicit query range of each term with fuzzy semantics, the local explicit query range of the term with the fuzzy semantics adjacent to the relative quantifier and the local explicit query range of the term with other explicit semantics as the global explicit query range corresponding to the fuzzy query statement.
Further, the apparatus as described above, the term with fuzzy semantics further includes: a tone operator;
the local range determination module is specifically configured to:
if the words with the fuzzy semantics are tone operators, determining a preset membership range threshold matched with the tone operators as a first membership range threshold; determining a first initial query range according to the first membership range threshold and a preset membership function matched with the tone operator; and performing defuzzification processing on the first initial query range to determine a local explicit query range corresponding to the mood operator.
Further, in the apparatus described above, if the term with fuzzy semantics is a relative quantifier, the local range determining module is specifically configured to:
determining a preset membership range threshold matched with the relative quantifier as a second membership range threshold; the preset membership function matched with the relative quantifier is a linear membership function; determining a second initial query range according to the second membership range threshold and the linear membership function; and performing defuzzification processing on the second initial query range by adopting a reverse method to determine a local explicit query range corresponding to the relative quantifier.
Further, the apparatus as described above, the term with fuzzy semantics further includes: fuzzification operators;
the local range determination module is specifically configured to:
if the words with the fuzzy semantics are fuzzification operators, determining a preset membership range threshold matched with the fuzzification operators as a third membership range threshold; determining matched adjusting parameters and words of definite semantics adjacent to the fuzzification operator in the fuzzy query statement according to a preset membership function matched with the fuzzification operator; and inputting the adjusting parameters and the clear semantic words adjacent to the fuzzification operator in the fuzzy query statement into a preset membership function matched with the fuzzification operator by taking the third membership range threshold as a boundary condition so as to output a local clear query range corresponding to the fuzzification operator.
Further, in the apparatus as described above, the preset membership function matched with the blurring operator is:
wherein x represents a certain value in a local explicit query range corresponding to the fuzzification operator, y represents a term of explicit semantics adjacent to the fuzzification operator, and δ represents an adjustment parameter.
A third aspect of the present invention provides an electronic device comprising: a processor, and a memory communicatively coupled to the processor;
the memory stores computer-executable instructions;
the processor executes computer-executable instructions stored by the memory to implement the fuzzy query method of any one of the first aspect.
A fourth aspect of the present invention provides a computer-readable storage medium having stored therein computer-executable instructions for implementing the fuzzy query method of any one of the first aspects when executed by a processor.
A fifth aspect of the invention provides a computer program product comprising a computer program which, when executed by a processor, implements the fuzzy query method of any one of the first aspects.
The invention provides a fuzzy query method, a device, equipment, a medium and a product, wherein the method comprises the following steps: acquiring a fuzzy query statement to be identified; performing semantic recognition on the fuzzy query statement to be recognized and splitting the fuzzy query statement to be recognized into a plurality of terms with fuzzy semantics and a plurality of terms with definite semantics; the semantic-specific words are consistent with entities corresponding to nodes in a graph database; the words with fuzzy semantics comprise relative quantifiers; determining a preset membership function and a preset membership range threshold value which are matched with each term with the fuzzy semantics; determining a local definite query range corresponding to the words with fuzzy semantics according to each preset membership function and the corresponding preset membership range threshold; determining a global explicit query range corresponding to the fuzzy query statement according to each local explicit query range, the explicit semantic terms adjacent to the relative quantifier and other explicit semantic terms; and querying target data from the graph database according to the global explicit query range. The fuzzy query method of the invention carries out semantic recognition on a fuzzy query sentence to be recognized and splits the fuzzy query sentence into a plurality of words with fuzzy semantics and a plurality of words with definite semantics. And presetting matched membership functions and membership range thresholds aiming at the relative quantifier so as to determine a local explicit query range corresponding to the relative quantifier. And then, determining a global definite query range corresponding to the fuzzy query statement by combining the definite semantic terms adjacent to the relative quantifier, each local definite query range and other definite semantic terms, thereby realizing the fuzzy query containing the relative quantifier.
Detailed Description
Reference will now be made in detail to the exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, like numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present invention. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the invention, as detailed in the appended claims.
The technical solution of the present invention will be described in detail below with specific examples. The following several specific embodiments may be combined with each other, and details of the same or similar concepts or processes may not be repeated in some embodiments. Embodiments of the present invention will be described below with reference to the accompanying drawings.
For clear understanding of the technical solutions of the present application, first, the related terms related to the technical solutions are explained.
Fuzzy set and membership functions:
by a fuzzy subset a on the domain of discourse U is meant:
all have mu
A(x)∈[0,1]Corresponds to it, wherein
A(x) A membership function called fuzzy subset a, or membership degree of x to fuzzy subset a.
I.e. by mapping:
a fuzzy subset a of the universe of discourse U is determined.
The membership function is a quantitative description of the fuzzy concept, correctly determines the membership function and is the basis for solving the practical problem by applying the fuzzy set theory. Typical fuzzy distributions are ladder, exponential, normal, linear, power function, sinusoidal, and the like.
Alpha truncation:
membership function mu corresponding to all elements x in universe UA(x) One set in which none of the values of (a) is less than a is called an alpha truncated set of the fuzzy set a.
Where α is the confidence level (threshold). A fuzzy set can be converted into a normal set by using alpha truncation.
Tone operator:
in fuzzy theory, what's in natural language "The terms "comparing", "very", "slightly" etc. are to be regarded as an operator, called the mood operator Hλ. The mood operator limits the fuzzy semantics from the degree, and changes the membership degree of the fuzzy semantics at different levels, for example, the fuzzy semantics 'high' can be expressed as 'very high', 'relatively high', 'high in some point' and the like. The mood operator is a transformation, namely: hλA(X)=[A(X)]λ. When lambda is>When 1, call HλIs a centralized operator. When lambda is<When 1, call HλIs a scatter operator. In general H4Denotes "extremely", H2Denotes "very", H0.75Denotes "comparison", H0.5Indicating a "point".
Words with fuzzy semantics such as "about", "nearly", "almost", etc. are often placed before an exact word or linguistic variable, indicating a fuzzy range, which is called the fuzzification operator.
Degree of conformity of the fuzzy set:
fuzzy queries on fuzzy data can be represented by the degree of conformity of the fuzzy sets. Let A and B be two fuzzy sets on the universe of discourse U, and μAAnd muBRespectively their membership functions. The degree of conformity of a and B defines:
degree of conformity of a ═ u-B ═ max { μ { (u) }A(x),μB(x)}
The coincidence degree of A and B is min [ mu ]A(x),μB(x)}
The degree of conformity of A is 1-muA(x)
For a clearer understanding of the technical solutions of the present application, the prior art solutions are described in detail. When the database is subjected to fuzzy query, the conventional method is to perform fuzzy matching, and the matching needs to be performed in combination with a regular expression and is very limited. Expressions that are ambiguous in natural languages like "relatively high" and "somewhat low" cannot be handled. In order to solve the problem of the fuzzy query, a lot of research is carried out at home and abroad by using a fuzzy mathematical theory.
First, most current research is focused on relational databases, but as the age of big data comes, the amount of data grows exponentially, and the data format starts to move to unstructured data. Relational databases have been difficult to construct, store and process for such enormous amounts of data. The graph database such as the Neo4j graph database does not need to store structured data in a table, but only needs to connect all nodes through relations, store the nodes in the form of a network, and form a large graph through the relations, so that addition and deletion and searching of data nodes and relations are very easy.
However, the current fuzzy query method for the graph database does not consider the relative quantifier such as "most" and "almost no" representing the set proportion, and therefore, the method cannot be applied to the fuzzy query with the relative quantifier.
Therefore, aiming at the problem that the fuzzy query mode in the prior art cannot be suitable for fuzzy query with relative quantifier, the inventor finds that in order to solve the problem, a membership function matched with the relative quantifier can be preset, and after a plurality of researches and trials, the inventor finds that the linear membership function is more suitable for the relative quantifier. Meanwhile, when determining the global explicit query range containing the relative quantifier, the method is different from the fuzzy query method in the prior art.
Specifically, a fuzzy query sentence to be recognized is obtained, and semantic recognition is performed on the fuzzy query sentence to be recognized, so that the fuzzy query sentence to be recognized is split into a plurality of terms with fuzzy semantics and a plurality of terms with definite semantics. Semantic-specific terms are consistent with entities corresponding to nodes in the graph database. Words with fuzzy semantics include relative quantifiers. And then determining a preset membership function and a preset membership range threshold which are matched with each term with fuzzy semantics, and determining a local definite query range corresponding to the term with the fuzzy semantics according to each preset membership function and the corresponding preset membership range threshold. And finally, determining a global definite query range corresponding to the fuzzy query statement according to each local definite query range, the definite semantic terms adjacent to the relative quantifier and other definite semantic terms to query target data, thereby realizing fuzzy query including the relative quantifier.
The inventor proposes a technical scheme of the application based on the creative discovery.
An application scenario of the fuzzy query method provided by the embodiment of the present invention is described below. As shown in fig. 1, 1 is an electronic device, 2 is a terminal device, and 3 is a graph database cluster. The network architecture of the application scenario corresponding to the fuzzy query method provided by the embodiment of the invention comprises the following steps: electronic device 1, terminal device 2 and graph database cluster 3. The database cluster 3 includes a plurality of database databases, such as a database a and a database B … database N, and the terminal device 2 may be an electronic device such as a computer, a server, a mobile phone, etc.
When a user needs to perform a fuzzy query, a fuzzy query sentence, such as an actor including a certain movie in about 1997, can be sent to the electronic device 1 through the terminal device 2. When the electronic device 1 receives the fuzzy query sentence sent by the terminal device 2, performing semantic recognition on the fuzzy query sentence to be recognized, and splitting the fuzzy query sentence to be recognized into a plurality of terms with fuzzy semantics and a plurality of terms with definite semantics. Wherein the semantic-specific terms are consistent with the entities corresponding to the nodes in the graph database. Words with fuzzy semantics include relative quantifiers.
Meanwhile, the electronic device 1 determines a preset membership function and a preset membership range threshold value which are matched with each term with the fuzzy semantics, and determines a local definite query range corresponding to the term with the fuzzy semantics according to each preset membership function and the corresponding preset membership range threshold value. Finally, the electronic device 1 determines a global explicit query range corresponding to the fuzzy query statement according to each local explicit query range, the explicit term adjacent to the relative quantifier, and the other explicit term, so as to query the target data from the map database according to the global explicit query range. Assuming that the target data is located in a graph database a in the graph database cluster 3, the target data will be acquired from the graph database a. After inquiring the target data, the electronic device 1 feeds the target data back to the terminal device 2 for the user to view and process.
The embodiments of the present invention will be described with reference to the accompanying drawings.
Fig. 2 is a schematic flow chart of an fuzzy query method according to a first embodiment of the present invention, and as shown in fig. 2, in this embodiment, an execution subject of the embodiment of the present invention is a fuzzy query apparatus, and the fuzzy query apparatus may be integrated in an electronic device. The fuzzy query method provided by the embodiment includes the following steps:
the graph database stores unstructured data, and based on the directed graph theory, the graph database has three elements:
and (3) node: nodes can define attributes and types for individual records within graph data.
The relationship is as follows: one edge connecting nodes, there is a direction.
The attributes are as follows: also called values of data, where both nodes and relationships may have attributes.
Step S101, acquiring a fuzzy query statement to be identified.
In this embodiment, the fuzzy query sentence is, for example, about 1997 movies, about 40-year-old actors who have played about 5 movies more, and most music is movies composed by a certain music production company. The fuzzy query statement to be recognized may be input by a user through a user terminal, or directly input through an electronic device that may execute a fuzzy query method, which is not limited in this embodiment.
Step S102, performing semantic recognition on the fuzzy query sentence to be recognized, and splitting the fuzzy query sentence to be recognized into a plurality of terms with fuzzy semantics and a plurality of terms with definite semantics. Semantic-specific terms are consistent with entities corresponding to nodes in the graph database. Words with fuzzy semantics include relative quantifiers.
In this embodiment, semantic recognition is performed on the fuzzy query statement to be recognized, so that each term in the fuzzy query statement, for example, a movie in about 1997, can be determined, and a term with fuzzy semantics, a term with explicit semantics, a movie in 1997, can be recognized. If the query sentence is a fuzzy query sentence containing relative terms, such as a film written by a certain music production company for the vast majority of music, the term music with fuzzy semantics and the most significant relative terms, a certain music production company and a film can be identified.
Data are stored in the graph database according to nodes, and words with definite semantics are generally consistent with entities corresponding to the nodes in the graph database, namely, the movies, the music and a certain music production company can be stored as the node data of the graph database.
And step S103, determining preset membership functions and preset membership range thresholds matched with the words with the fuzzy semantics.
In this embodiment, the words with fuzzy semantics are divided into a plurality of types, such as a fuzzification operator, a mood operator, a relative quantifier, and the like, and a matched membership function is preset for each word with fuzzy semantics. If the tone operator can adopt a parabola-type membership function, the fuzzification operator can adopt a similar fuzzy relation function, and the relative quantifier can adopt a linear membership function, etc. Meanwhile, the same words with fuzzy semantics can also adopt different membership functions, and the numerical values of the membership functions can also be different.
The preset membership range threshold is a range for determining a membership for the membership function, and since the value of the membership function is between 0 and 1, when the preset membership range threshold is set to be 0.5, the range of the membership function less than or equal to 0.5 represents an alpha truncated set of the fuzzy set. The local unambiguous query range corresponding to the term with fuzzy semantics can be determined by the alpha intercept.
And step S104, determining a local definite query range corresponding to the words with fuzzy semantics according to each preset membership function and the corresponding preset membership range threshold.
According to each preset membership function and the corresponding preset membership range threshold, an alpha cut set representing the fuzzy set can be determined, and the alpha cut set is assumed to be the range of the membership function less than or equal to 0.5, and the membership function is mumost(x) 2x, it may be determined that x is less than or equal to 0.25 is the determined local unambiguous query range.
Step S105, determining a global definite query range corresponding to the fuzzy query sentence according to each local definite query range, the definite semantic terms adjacent to the relative quantifier and other definite semantic terms.
In this embodiment, after each local explicit query range is determined, the data of the graph database node corresponding to the semantic term can be obtained by the semantic term, so as to determine the data range in the graph database to be queried, that is, the global explicit query range. Meanwhile, when the words with fuzzy semantics contain relative quantifier, the data range may not be stored as nodes in the graph database, and the global explicit query range to be searched may need to acquire partial data from the nodes of the graph database and combine the partial data, so as to obtain the data range in the graph database to be queried. Thus, there is a need to combine explicit terms adjacent to relative quantifiers with other explicit terms to determine a global explicit query scope.
For example, the fuzzy query sentence is a movie with most of actors having experience, the database stores data according to two nodes of the actors and the movie, most of the relative quantifier needs to consider direct association between the actors and the movie, that is, the number of the actors in the movie needs to be considered, but the database does not have the data nodes of the actors in the movie, so that data corresponding to the number of the actors needs to be determined through the two nodes of the actors and the movie, and the global clear query scope is determined.
And step S106, inquiring target data from the graph database according to the global explicit inquiry range.
In this embodiment, after determining the global explicit query scope, for example, in 1990 and 1995, movies with three actors can be queried from the graph database through the global explicit query scope.
The embodiment of the invention provides a fuzzy query method, which comprises the following steps: and acquiring the fuzzy query statement to be identified. And performing semantic recognition on the fuzzy query sentence to be recognized, and splitting the fuzzy query sentence to be recognized into a plurality of words with fuzzy semantics and a plurality of words with definite semantics. Semantic-specific terms are consistent with entities corresponding to nodes in the graph database. Words with fuzzy semantics include relative quantifiers. And determining a preset membership function and a preset membership range threshold value which are matched with each term with fuzzy semantics. And determining a local definite query range corresponding to the words with fuzzy semantics according to each preset membership function and the corresponding preset membership range threshold. And determining a global definite query range corresponding to the fuzzy query statement according to each local definite query range, the definite semantic terms adjacent to the relative quantifier and other definite semantic terms. Target data is queried from a graph database according to a global explicit query scope.
The fuzzy query method of the invention carries out semantic recognition on a fuzzy query sentence to be recognized and splits the fuzzy query sentence into a plurality of words with fuzzy semantics and a plurality of words with definite semantics. And presetting matched membership functions and membership range thresholds aiming at the relative quantifier so as to determine a local explicit query range corresponding to the relative quantifier. Then, the terms with definite semantics adjacent to the relative quantifier, each local definite query range and other terms with definite semantics are combined to determine a global definite query range corresponding to the fuzzy query statement, so that the fuzzy query including the relative quantifier is realized.
Fig. 3 is a schematic flow chart of an fuzzy query method according to a second embodiment of the present invention, and as shown in fig. 3, the fuzzy query method according to this embodiment is further refined based on the fuzzy query method according to the previous embodiment of the present invention. The fuzzy query method provided by the present embodiment includes the following steps.
Step S201, a fuzzy query statement to be identified is acquired.
In this embodiment, the implementation manner of step 201 is similar to that of step 101 in the previous embodiment of the present invention, and is not described in detail here.
Step S202, performing semantic recognition on the fuzzy query sentence to be recognized, and splitting the fuzzy query sentence to be recognized into a plurality of terms with fuzzy semantics and a plurality of terms with definite semantics.
In this embodiment, the implementation manner of step 202 is similar to that of step 102 in the previous embodiment of the present invention, and is not described herein again.
Step S203, determining preset membership functions and preset membership range thresholds matched with the words with fuzzy semantics.
In this embodiment, the implementation manner of step 203 is similar to that of step 103 in the previous embodiment of the present invention, and is not described in detail here.
And S204, determining a local definite query range corresponding to the words with fuzzy semantics according to each preset membership function and the corresponding preset membership range threshold.
In this embodiment, the implementation manner of step 204 is similar to that of step 104 in the previous embodiment of the present invention, and is not described in detail here.
Words with fuzzy semantics may include mood operators, relative quantifiers, obfuscation operators, and the like.
Optionally, in this embodiment, if the word with the fuzzy semantics is a tone operator, determining a preset membership range threshold matched with the tone operator as the first membership range threshold.
And determining a first initial query range according to the first membership range threshold and a preset membership function matched with the tone operator.
And performing defuzzification processing on the first initial query range to determine a local definite query range corresponding to the tone operator.
Meanwhile, if the words with the fuzzy semantics are relative quantifiers, determining a preset membership range threshold matched with the relative quantifiers as a second membership range threshold. The preset membership functions matched with the relative quantifier are linear membership functions.
And determining a second initial query range according to the second membership range threshold and the linear membership function.
And performing defuzzification processing on the second initial query range by adopting a reverse method to determine a local definite query range corresponding to the relative quantifier.
And if the words with the fuzzy semantics are fuzzification operators, determining a preset membership range threshold value matched with the fuzzification operators as a third membership range threshold value.
And determining the matched adjusting parameters and the words with definite semantics adjacent to the fuzzification operator in the fuzzy query statement according to the preset membership functions matched with the fuzzification operator.
And inputting the adjusting parameters and the words with definite semantics adjacent to the fuzzification operator in the fuzzy query statement into a preset membership function matched with the fuzzification operator by taking the third membership range threshold as a boundary condition so as to output a local definite query range corresponding to the fuzzification operator.
Illustratively, a movie with a fuzzy query statement of about 1998 and a vast majority of actors experienced is exemplified.
Semantic recognition of the fuzzy query sentence can determine that the words with fuzzy semantics are "about", "most", "very experienced", and the words with clear semantics are "1998", "actor", "movie".
"about" belongs to the fuzzification operator such as "movie shown in about 1998", where 1998 is a specific value, but adding about fuzzifies this word. For the fuzzification operator of "about," the range of the fuzzification can be adjusted using a similar fuzzy relation function in the membership function. The similar fuzzy relation function is as follows:
wherein x represents a certain value in the local explicit query range corresponding to the fuzzification operator, y represents the explicit semantic word adjacent to the fuzzification operator, i.e. 1998, and δ represents the tuning parameter (δ > 0).
Assuming that the membership range threshold here is 0.5, i.e. E (x, y) ≧ 0.5, the specific range calculated is:
in this example, assume δ is 10, the queryThe year is about 1998, and the fuzzy query can be converted into a local unambiguous query ranging from 1990 to 2006.
"most" belongs to relative quantifier, for relative linguistic quantifier, a simple linear membership function is used, as shown in fig. 4, with the horizontal axis being proportion and the vertical axis being degree of membership:
where x represents a ratio satisfying the condition in the grouping, it is generally considered that the ratio exceeds 5/6 and must be "most" and the degree of membership is set to 1. Selecting a membership range threshold value alpha as 0.9, and defuzzifying by an inverse method, so that the fuzzy condition of 'most' can be converted into a local definite query range: x is more than or equal to 0.8.
"very empirical" is a mood operator, using a parabolic membership function:
where x represents the total number of movies the actor has participated in, it is generally considered that if the total number of movies participated in is more than 4, it is certain that "it is empirical", and thus the membership degree is set to 1. The threshold α is chosen to be 16/25, and by defuzzification using the inverse method, the "very empirical" result can be converted into a local unambiguous query range: x is more than or equal to 3.
The local explicit query scope obtained from the above three parts and the final query scope obtained by combining terms with explicit semantics, that is, the global explicit query scope is:
in the year of the epilogue, between 1990 and 2006, the actors now have performed at least three movies, grouped with movies having a percentage equal to or greater than 0.8 that meet the screening criteria.
Since the attribute of the total number of actors is not contained in the database, the attribute is needed to be used in the query. In this embodiment, the graph database is illustrated as Neo4 j. In the Neo4j graph database, since the Cypher statement does not support nested queries like SQL statements, the data of the total number of actors corresponding to a movie can be obtained by using the length statements to obtain the number of associations between the movie and the actors, and then the value of the attribute is added in batches by using the SET statement.
Finally, the required data is queried in the graph database by a global explicit query scope.
So far, by splitting a complex fuzzy query statement and defuzzifying the complex fuzzy query statement based on different membership functions and alpha cut sets, a global definite query range of the fuzzy query statement is obtained. By grouping and aggregating the WITH sentences of the graph database and setting the attribute in SET (Single-SET event) batch, the problem that Cypher sentences in the graph database do not support non-node nested query is solved, and thus the grouping fuzzy query of the Neo4j graph database is realized.
Step S205, determining the total number of the correlation nodes needed for query corresponding to the nodes in the graph database matched with the query target entity. Wherein, other words with clear semantics comprise: and querying the target entity. The required associated nodes for query are nodes in the graph database corresponding to the words with definite semantics adjacent to the relative quantifier.
In this embodiment, the query target entity is an entity that the user wants to query, for example, if the user wants to query bicycles produced in 81 years, the bicycles are the query target entity.
If the fuzzy query statement is a bicycle with the color of green in most bicycle areas, the query target entity is a bicycle, and data are stored in the map database according to the nodes of the bicycles. The total number of the required associated nodes is queried as the bicycle area color.
Step S206, determining the total number of the associated nodes required by the query as a local explicit query range of the words with explicit semantics adjacent to the relative quantifier.
In this embodiment, the relative quantifier represents a proportional relationship, and therefore, the data range to be queried includes a data attribute of the number of association nodes required for querying, which corresponds to the query target entity, and therefore, the total number of association nodes required for querying is determined as a local explicit query range of an explicit term adjacent to the relative quantifier.
Step S207, determining data contained in nodes in the database corresponding to other clear semantic terms as local clear query ranges of other clear semantic terms.
Step S208, determining the local explicit query range of each term with fuzzy semantics, the local explicit query range of the term with explicit semantics adjacent to the relative quantifier and the local explicit query range of the term with other explicit semantics as the global explicit query range corresponding to the fuzzy query statement.
In this embodiment, the global explicit query range is composed of a local explicit query range of terms with fuzzy semantics and a local explicit query range of terms with explicit semantics.
Step S209, query the target data from the graph database according to the global explicit query scope.
In this embodiment, the implementation manner of step 209 is similar to that of step 106 in the previous embodiment of the present invention, and is not described here again.
Fig. 5 is a schematic structural diagram of an fuzzy query apparatus according to a third embodiment of the present invention, as shown in fig. 5, in this embodiment, the fuzzy query apparatus 300 includes:
an obtaining module 301, configured to obtain a fuzzy query statement to be identified.
The semantic recognition module 302 is configured to perform semantic recognition on the to-be-recognized fuzzy query statement and split the to-be-recognized fuzzy query statement into a plurality of words with fuzzy semantics and a plurality of words with explicit semantics. Semantic-specific terms are consistent with entities corresponding to nodes in the graph database. Words with fuzzy semantics include relative quantifiers.
And the function determining module 303 is configured to determine a preset membership function and a preset membership range threshold, where the preset membership function and the preset membership range threshold are matched with each term with the fuzzy semantics.
A local range determining module 304, configured to determine a local explicit query range corresponding to the term with the fuzzy semantics according to each preset membership function and the corresponding preset membership range threshold.
A global scope determining module 305, configured to determine a global explicit query scope corresponding to the fuzzy query statement according to each local explicit query scope, the explicit terms adjacent to the relative quantifier, and other explicit terms.
And the query module 306 is used for querying the target data from the graph database according to the global explicit query range.
The fuzzy query apparatus provided in this embodiment may execute the technical solution of the method embodiment shown in fig. 2, and the implementation principle and technical effect thereof are similar to those of the method embodiment shown in fig. 2, and are not described in detail herein.
The fuzzy query device provided by the invention further refines the fuzzy query device on the basis of the fuzzy query device provided by the previous embodiment.
Optionally, in this embodiment, other terms with definite semantics include the query target entity.
The global scope determination module is specifically configured to:
and determining the total number of the correlation nodes required by the query corresponding to the nodes in the graph database matched with the query target entity. The related nodes required for query are nodes in the graph database corresponding to the words with definite semantics adjacent to the relative quantifier. The total number of associated nodes required for the query is determined as the local unambiguous query range of the terms of unambiguous semantics adjacent to the relative quantifier. And determining data contained in nodes in the database corresponding to other clear semantic terms as local clear query ranges of other clear semantic terms. And determining the local explicit query range of each term with fuzzy semantics, the local explicit query range of the term with the fuzzy semantics adjacent to the relative quantifier and the local explicit query range of the term with other explicit semantics as the global explicit query range corresponding to the fuzzy query statement.
Optionally, in this embodiment, the term with fuzzy semantics further includes: and (5) tone operators.
The local range determination module is specifically configured to:
and if the words with the fuzzy semantics are the tone operators, determining a preset membership range threshold matched with the tone operators as a first membership range threshold. And determining a first initial query range according to the first membership range threshold and a preset membership function matched with the tone operator. And performing defuzzification processing on the first initial query range to determine a local definite query range corresponding to the tone operator.
Optionally, in this embodiment, if the word with the fuzzy semantics is a relative quantifier, the local range determining module is specifically configured to:
and determining the preset membership range threshold matched with the relative quantifier as a second membership range threshold. The preset membership functions matched with the relative quantifier are linear membership functions. And determining a second initial query range according to the second membership range threshold and the linear membership function. And performing defuzzification processing on the second initial query range by adopting a reverse method to determine a local definite query range corresponding to the relative quantifier.
Optionally, in this embodiment, the term with fuzzy semantics further includes: and (5) blurring an operator.
The local range determination module is specifically configured to:
and if the words with the fuzzy semantics are fuzzification operators, determining a preset membership range threshold value matched with the fuzzification operators as a third membership range threshold value. And determining the matched adjusting parameters and the words with definite semantics adjacent to the fuzzification operator in the fuzzy query statement according to the preset membership functions matched with the fuzzification operator. And inputting the adjusting parameters and the words with definite semantics adjacent to the fuzzification operator in the fuzzy query statement into a preset membership function matched with the fuzzification operator by taking the third membership range threshold as a boundary condition so as to output a local definite query range corresponding to the fuzzification operator.
Optionally, in this embodiment, the preset membership function matched with the fuzzification operator is:
wherein x represents a certain value in a local explicit query range corresponding to the fuzzification operator, y represents a term of explicit semantics adjacent to the fuzzification operator, and δ represents an adjustment parameter.
The fuzzy query apparatus provided in this embodiment may execute the technical solutions of the method embodiments shown in fig. 2 to fig. 4, and the implementation principles and technical effects thereof are similar to those of the method embodiments shown in fig. 2 to fig. 4, and are not described in detail herein.
The invention also provides an electronic device, a computer readable storage medium and a computer program product according to the embodiments of the invention.
As shown in fig. 6, fig. 6 is a schematic structural diagram of an electronic device according to a fourth embodiment of the present invention. Electronic devices are intended for various forms of digital computers, such as laptops, desktops, workstations, personal digital assistants, blade servers, mainframes, and other appropriate computers. The components shown herein, their connections and relationships, and their functions, are meant to be exemplary only, and are not meant to limit implementations of the inventions described and/or claimed herein.
As shown in fig. 6, the electronic apparatus includes: a processor 401, a memory 402. The various components are interconnected using different buses and may be mounted on a common motherboard or in other manners as desired. The processor may process instructions for execution within the electronic device.
The memory 402 is a non-transitory computer readable storage medium provided by the present invention. The memory stores instructions executable by the at least one processor to cause the at least one processor to perform the fuzzy query method provided by the present invention. The non-transitory computer-readable storage medium of the present invention stores computer instructions for causing a computer to execute the fuzzy query method provided by the present invention.
The memory 402, which is a non-transitory computer readable storage medium, may be used to store non-transitory software programs, non-transitory computer executable programs, and modules, such as program instructions/modules corresponding to the fuzzy query method in the embodiment of the present invention (for example, the obtaining module 301, the semantic identifying module 302, the function determining module 303, the local scope determining module 304, the global scope determining module 305, and the query module 306 shown in fig. 5). The processor 401 executes various functional applications and data processing of the electronic device by running non-transitory software programs, instructions and modules stored in the memory 402, that is, implements the fuzzy query method in the above method embodiments.
Meanwhile, the present embodiment also provides a computer product, and when instructions in the computer product are executed by a processor of the electronic device, the electronic device is enabled to execute the fuzzy query method of the above embodiment.
Other embodiments of the invention will be apparent to those skilled in the art from consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the embodiments of the invention following, in general, the principles of the embodiments of the invention and including such departures from the present disclosure as come within known or customary practice within the art to which the embodiments of the invention pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of embodiments of the invention being indicated by the following claims.
It is to be understood that the embodiments of the present invention are not limited to the precise arrangements described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of embodiments of the invention is limited only by the appended claims.