CN115794869A - Implementation method and device for visual construction and generation of semantic query - Google Patents

Implementation method and device for visual construction and generation of semantic query Download PDF

Info

Publication number
CN115794869A
CN115794869A CN202310045249.3A CN202310045249A CN115794869A CN 115794869 A CN115794869 A CN 115794869A CN 202310045249 A CN202310045249 A CN 202310045249A CN 115794869 A CN115794869 A CN 115794869A
Authority
CN
China
Prior art keywords
query
node
target
graph
condition
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202310045249.3A
Other languages
Chinese (zh)
Inventor
陈鹏飞
刘尧
李翔
刘坤
王强
顾士业
王程珺
秦伟
刘艺
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Big Data Advanced Technology Research Institute
Original Assignee
Beijing Big Data Advanced Technology Research Institute
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Big Data Advanced Technology Research Institute filed Critical Beijing Big Data Advanced Technology Research Institute
Priority to CN202310045249.3A priority Critical patent/CN115794869A/en
Publication of CN115794869A publication Critical patent/CN115794869A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Abstract

The method comprises the steps of responding to a received primitive element operation instruction sent by a terminal, and constructing a query graph based on target graph elements and/or optional components indicated by the primitive element operation instruction; the diagram element operation instruction is generated by the terminal according to the specified operation of the user on the created graphic element and/or the optional component displayed in the interface of the terminal; the optional component is used for providing semantic information of optional query information for a user; generating a target query statement based on target query information corresponding to primitive elements contained in the query graph according to a preset generation rule; outputting a target query statement to a target object; the target object is used for executing the query operation indicated by the query graph based on the target query statement, and the target object comprises a terminal. Therefore, the query sentence is not required to be manually written, and the query difficulty is reduced.

Description

Method and device for realizing semantic query visual construction and generation
Technical Field
The disclosure relates to the technical field of computers, in particular to a method and a device for realizing semantic query visual construction and generation.
Background
With the development of computer technology, data can be retrieved or queried by combining a Resource Description Framework (RDF) and a semantic Web Ontology Language (OWL), or by mapping data into RDF triples by a mapping technique.
In the two query modes, the user is required to input a language specially developed for RDF to realize the query mode, and the user is required to manually write a query statement meeting the language requirement, so that the query threshold is higher, and the query difficulty of a common user with the query requirement is greatly increased.
Disclosure of Invention
The disclosure provides a method and a device for realizing semantic query visual construction and generation, which at least solve the problem of reducing query difficulty. The technical scheme of the disclosure is as follows:
according to a first aspect of the embodiments of the present disclosure, there is provided a method for implementing semantic query visualization construction and generation, including:
in response to receiving a primitive operation instruction sent by a terminal, constructing a query graph based on graph elements and/or optional components indicated by the primitive operation instruction; the primitive element operation instruction is generated by the terminal according to the specified operation of a user on the created primitive elements and/or optional components displayed in the interface of the terminal; the optional component is used for providing semantic information of optional query information for the user;
generating a target query statement based on target query information corresponding to the primitive elements contained in the query graph according to a preset generation rule;
outputting the target query statement to a target object; the target object is used for executing the query operation indicated by the query graph based on the target query statement, and the target object comprises the terminal.
According to a second aspect of the embodiments of the present disclosure, there is provided an implementation apparatus for semantic query visualization construction and generation, including:
the query graph construction module is used for responding to a received primitive element operation instruction sent by a terminal and constructing a query graph based on the graph elements and/or optional components indicated by the graph element operation instruction; the primitive element operation instruction is generated by the terminal according to the specified operation of a user on the created primitive elements and/or optional components displayed in the interface of the terminal; the optional component is used for providing semantic information of optional query information for the user;
the query statement generation module is used for generating a target query statement based on target query information corresponding to the primitive elements contained in the query graph according to a preset generation rule;
the output module is used for outputting the target query statement to a target object; the target object is used for executing the query operation indicated by the query graph based on the target query statement, and the target object comprises the terminal.
According to a third aspect of an embodiment of the present disclosure, there is provided an electronic apparatus including:
a processor;
a memory for storing the processor-executable instructions;
wherein the processor is configured to execute the instructions to implement the method of the first aspect.
According to a fourth aspect of embodiments of the present disclosure, there is provided a storage medium, in which instructions, when executed by a processor of an electronic device, cause the electronic device to perform the method according to the first aspect.
According to a fifth aspect of embodiments of the present disclosure, there is provided a computer program product comprising readable program instructions which, when executed by a processor of an electronic device, cause the electronic device to perform the method according to the first aspect.
The technical scheme provided by the embodiment of the disclosure at least brings the following beneficial effects: in the embodiment of the disclosure, by responding to a received primitive element operation instruction sent by a terminal, a query graph is constructed based on a target graph element and/or an optional component indicated by the graph element operation instruction; the primitive element operation instruction is generated by the terminal according to the specified operation of a user on the created primitive elements and/or optional components displayed in the interface of the terminal; the optional component is used for providing semantic information of optional query information for the user; generating a target query statement based on target query information corresponding to the primitive elements contained in the query graph according to a preset generation rule; outputting the target query statement to a target object; the target object is used for executing the query operation indicated by the query graph based on the target query statement, and the target object comprises the terminal. Therefore, a user can add corresponding graph elements to the query graph through the selectable components on the terminal interface and the displayed created graph elements to form the query graph, and further generate query sentences according to the preset generation rules and the graph elements contained in the query graph.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the disclosure and are not to be construed as limiting the disclosure.
FIG. 1 is a flowchart illustrating a method for implementation of semantic query visualization construction and generation in accordance with an exemplary embodiment;
FIG. 2 is a query graph structure diagram, according to an exemplary embodiment;
FIG. 3 is an interaction sequence diagram illustrating an implementation of semantic query visualization construction and generation in accordance with an illustrative embodiment;
FIG. 4 is a flowchart illustrating another method for implementation of semantic query visualization construction and generation in accordance with an illustrative embodiment;
FIG. 5 is a block diagram illustrating an apparatus for implementing semantic query visualization construction and generation in accordance with an exemplary embodiment.
Detailed Description
In order to make the technical solutions of the present disclosure better understood, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below with reference to the accompanying drawings.
It should be noted that the terms "first," "second," and the like in the description and claims of the present disclosure and in the above-described drawings are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the disclosure described herein are capable of operation in sequences other than those illustrated or otherwise described herein. The implementations described in the exemplary embodiments below do not represent all implementations consistent with the present disclosure. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the disclosure, as detailed in the appended claims.
FIG. 1 is a flowchart illustrating a method for implementing semantic query visualization construction and generation according to an exemplary embodiment, which may include the following steps as shown in FIG. 1:
step 101, in response to receiving a primitive operation instruction sent by a terminal, constructing a query graph based on a graph element and/or an optional component indicated by the primitive operation instruction; the primitive element operation instruction is generated by the terminal according to the specified operation of a user on the created primitive elements and/or optional components displayed in the interface of the terminal; the optional component is used for providing semantic information of optional query information for the user.
The method provided by the embodiment of the present disclosure may be applied to any terminal device, where the user refers to a user with a query requirement, and may be a common user, or a user in the field of computers, and correspondingly, the terminal refers to a terminal used by the user, and may be any terminal device.
The graph elements refer to elements or structures forming a query graph, the selectable components refer to selectable modules displayed to a user through a terminal, and the user can generate a primitive element operation instruction by selecting the graph elements and/or the selectable components. Specifically, the graph element operation instruction refers to an instruction for constructing a query graph, and query graphs constructed according to different graph element operation instructions are different. The above-mentioned designated operation may be a selection operation or an editing operation on the diagram element and/or the selectable component, where the selection operation may be a click operation or a drag operation, and the like, which is not limited in this disclosure.
The optional query information refers to information which can be queried by a user, and different optional query information and corresponding semantic information can be obtained in advance through semantic ontology files (OWL files) in different fields, wherein the fields correspond to the fields related to the used OWL files. In the data query technology, the optional query information may generally include class information, relationship attribute information, and data attribute information, so that a query may be performed by mapping data into Resource Description Framework (RDF) triple information, where one triple may include a subject, a predicate, and an object. Further, the query graph in the embodiment of the present disclosure may adopt an undirected graph data structure, which may include nodes (nodes) and relationships (Edge) between the nodes, which are highly consistent with the characteristics (predicate masters) of the RDF, so that the query on the RDF may be implemented by constructing the query graph.
The semantic information refers to information that can be understood by a general user, and can be obtained in advance through a semantic Ontology file (OWL) corresponding to the optional query information, so that different optional components can be generated through the semantic information of the optional query information, and a user can select an optional component of query logic that the semantic information can express the user needs through the optional component displayed on the terminal display interface. It can be appreciated that the user can learn semantic information of the optional query information through the optional components, thereby allowing the user to focus only on the query logic to add graph elements to the query graph without learning the underlying data information.
Optionally, the currently constructed query graph may be output to a query graph component or a query graph module in the terminal for display, so that the user may view the structure of the currently constructed query graph at any time. Further, the created primitive elements refer to elements that have been added to the query graph before the query graph is finally completed, and it is understood that the user may continue to add or delete primitive elements in the current query graph before the query graph is finally completed.
And 102, generating a target query statement based on target query information corresponding to the primitive elements contained in the query graph according to a preset generation rule.
The step may be executed after the query graph is finally completed, specifically, the step may be executed when a completion instruction of the user is received, or may be executed when a new operation instruction is not received within a preset time period, which is not limited in the embodiment of the present disclosure.
The preset generation rule corresponds to a query statement that a user needs to generate, the target query statement refers to a resource description framework query language, that is, a language developed specifically for RDF, for example, the target query statement may be a SPARQL statement, and accordingly, the preset generation rule refers to a rule that conforms to the SPARQL statement, may include information and a format required for generating the SPARQL statement, and may be understood as a syntax of the target query statement. Further, the target query information refers to optional query information corresponding to semantic information indicated by primitive elements included in the query graph, and it can be understood that since primitive elements in the query graph are added based on a user's designated operation on the optional components, different primitive elements correspond to different designated operations on different optional components, so that semantic information that the user wants to query can be obtained according to the primitive elements in the query graph, and then corresponding target query information can be obtained according to the semantic information.
103, outputting the target query statement to a target object; the target object is used for executing the query operation indicated by the query graph based on the target query statement, and the target object comprises the terminal.
The target object may be any terminal or electronic device having a query requirement, so that the target object may complete a corresponding query operation through a target query statement. Specifically, the target object may be connected to different devices through a network or hardware, so that the target object may be determined through the received query instruction.
To sum up, in the implementation method for visual construction and generation of semantic query provided by the embodiment of the present disclosure, a query graph is constructed based on target graph elements and/or optional components indicated by a graph element operation instruction by responding to a received graph element operation instruction sent by a terminal; the primitive element operation instruction is generated by the terminal according to the specified operation of a user on the created primitive elements and/or optional components displayed in the interface of the terminal; the optional component is used for providing semantic information of optional query information for the user; generating a target query statement based on target query information corresponding to the primitive elements contained in the query graph according to a preset generation rule; outputting the target query statement to a target object; the target object is used for executing the query operation indicated by the query graph based on the target query statement, and the target object comprises the terminal. Therefore, a user can add corresponding graph elements to the query graph through the selectable components on the terminal interface and the displayed created graph elements to form the query graph, and further generate query sentences according to the preset generation rules and the graph elements contained in the query graph.
Optionally, the optional components comprise optional class components; in the operation of constructing the query graph based on the graph elements and/or the optional components indicated by the graph element operation instruction, an embodiment of the present disclosure may specifically include the following steps:
step 201, under the condition that the primitive element operation instruction is a query node adding instruction, creating a query node based on a target class component indicated by the query node adding instruction; the target class component is selected from the optional class components by the user, and the query node is used for representing target class information corresponding to the target class component.
The graph element operation instruction may include a query node adding instruction, a relationship edge adding instruction, and a deleting instruction. The selectable class component is used for providing class information of selectable query information, and is used for representing different classes of data, and for example, when the selectable query information is information in a school database, the class information may include classes of teachers, students and the like.
Specifically, different class components can represent different class information, so that a user can determine a corresponding class component according to the class information to be queried, and further create a corresponding query node for the target class component by selecting the class component as the target class component.
The query node may also be referred to as an instance node, and may be a rectangle or a circle in the query graph, of course, other forms are also possible, and this is not limited in this disclosure. The query node may store therein corresponding target class information for representing an actual query class or query object. Further, since different query nodes correspond to different types of information, the embodiment of the present disclosure may further provide unique identifiers for the different query nodes through static variable counting, and store the unique identifiers into the query nodes.
Illustratively, a user may create query nodes with categories of teachers and query nodes with categories of students in a query graph by selecting class components corresponding to teachers and class components corresponding to students.
Step 202, adding a relation edge between target query nodes indicated by the relation edge adding instruction under the condition that the graph element operation instruction is the relation edge adding instruction, so as to obtain the query graph; the relation edge adding instruction is generated by the terminal according to the selection operation of the user on the target query nodes, and the relation edge is used for representing the relation attribute between the target query nodes; the target query nodes include at least two query nodes selected by the user from the created primitive elements.
The above-mentioned relationship Property (Object Property) may also be referred to as an Object Property, and refers to an association relationship between different query nodes, that is, an association relationship between different types of information. Accordingly, the relationship Edge (Object Edge) may also be referred to as an Object Edge, is used to connect query nodes having an association relationship, and may be in a straight line form.
In particular, since associative relations are typically used to represent relations between at least two categories, a user may generate the above-mentioned relational edges by selecting at least two created query nodes. Specifically, after the user selects any created query node, the query nodes having an association relationship with the selected target query node in the current query graph are traversed to highlight, so that the user can select at least two query nodes as target query nodes by clicking the highlight nodes, and a relationship edge is created between the target query nodes.
Further, since in the RDF data, the class information and the relationship attribute information are represented in the form of triples, that is, the form of a principal and a predicate, and for the relationship attribute, the subject and the object are included, for example, two classes of information, i.e., a teacher and a student, are taken as an example, and a relationship attribute of "guidance" exists between the two classes of information, that is, the teacher guides the student, so that the relationship attribute itself serves as the predicate, the teacher and the student serve as the subject and the object, respectively, so that two ends of the relationship edge are respectively a subject node and an object node, and the relationship edge is used to represent the relationship attribute serving as the predicate.
Further, when any query node selected by the user has multiple relationship attributes, the class component corresponding to the query node may further include an optional relationship attribute component, so that the user may select a target relationship attribute component to be queried from the optional relationship attribute component, and at this time, the embodiment of the present disclosure may select a query node to be queried from all highlighted nodes and generate a corresponding relationship edge by traversing an object value range of the target relationship attribute corresponding to the target relationship attribute component in the query graph and highlighting the query node belonging to the value range. Exemplarily, taking three query nodes including a teacher, a student and a school as an example, a user may select a "teacher" node, at this time, a class component corresponding to the "teacher" may list all relationship attributes of the type of information by displaying an optional relationship attribute component, and the user may highlight a "student" node by clicking a target relationship attribute component corresponding to the "guidance" relationship attribute, so that the user may select the "student" node to construct a relationship edge of the "teacher guiding student".
In an embodiment of the present disclosure, the optional components include an optional class component; creating a query node based on a target class component indicated by the query node adding instruction under the condition that the graph element operation instruction is the query node adding instruction; the target class component is selected from the selectable class components by the user, and the query node is used for representing target class information corresponding to the target class component; adding a relation edge between target query nodes indicated by the relation edge adding instruction under the condition that the graph element operation instruction is the relation edge adding instruction to obtain the query graph; the relation edge adding instruction is generated by the terminal according to the selection operation of the user on the target query nodes, and the relation edge is used for representing the relation attribute between the target query nodes; the target query nodes include at least two query nodes selected by the user from the created primitive elements. Therefore, queryable class information can be provided for a user through the class component, the user can construct query nodes through selecting the class component, meanwhile, relationship edges can be added for at least two query nodes with relationship attributes in the query graph, specific query semantics are formed through the visual query nodes and the relationship edges, the query semantics constructing efficiency is improved, and then the query sentence generating efficiency is improved.
Optionally, the optional components further comprise an optional data attribute component; in the operation of building a query graph based on the graph elements and/or the optional components indicated by the graph element operation instruction, an embodiment of the present disclosure may further include the following steps:
step 301, in a case that the graph element operation instruction is a conditional element adding instruction, creating a first conditional node based on a first query node and a target data attribute component indicated by the conditional element adding instruction; the first query node and the target data attribute component are selected by the user from previously created query nodes and the optional data attribute component; the first condition node is used for representing the query condition of the target attribute information corresponding to the target data attribute component.
The graph element operation instruction may further include a conditional element adding instruction, and the conditional element adding instruction may include a first conditional node adding instruction and a first data edge adding instruction. The optional data attribute component is used for representing different data attribute information corresponding to any type of information, the first query node refers to any query node to which a user wants to add a query condition, and the condition element adding instruction is generated based on the selection operation of the user on the first query node and the target data attribute component.
Specifically, for any type of information, one or more data attributes may be corresponded, which corresponds to different attribute dimensions corresponding to the type of information. For example, "teacher" may correspond to a plurality of data attributes such as "name", "age", and "gender", and data values corresponding to different data attributes may describe class information from different dimensions. Further, the query condition refers to a query condition set for the first query node.
Specifically, the optional data attribute component may provide a condition addition operation for different data attributes, for example, a monocular operation (greater than, less than, equal to, and the like) with a higher use frequency may be provided for a numerical value type, further, a query node selected by a user from primitive elements created in a current query graph may be used as the first query node, at this time, all data attributes of the type of information may be listed in the optional data attribute component, the user selects a corresponding optional data attribute component as a target data attribute component according to a data attribute actually desired to be queried, and a query condition may be added through the condition addition operation provided by the target data attribute component, which is equivalent to a filtering operation, so as to implement a single-attribute filtering query for corresponding target attribute information. Accordingly, the query condition added by the user may be stored in the created first condition node in the form of a character string, and the first condition node may be in the form of a diamond or an irregular polygon, which is not limited in this disclosure.
Step 302, adding a first data edge between the first conditional node and the first query node to obtain the query graph; the first data edge is used for representing the target attribute information.
Specifically, after the first condition node is generated, the first condition node and the first query node may be connected by adding a first data edge, which may indicate that the query condition in the first condition node is set for the class information corresponding to the first query node. Further, the identifier of the first query node as the subject may be stored in the first data field, and the name of the target attribute information as the predicate and the identifier or variable name of the target attribute information as the object may also be stored in the first data field.
Illustratively, the data attribute information corresponding to the "teacher" may be displayed through a selection operation of the user on the "teacher" node, and after receiving an operation that the user adds "less than thirty" to the "age attribute" component, a first condition node including a query condition "age greater than thirty" or "i1d2 > 30" and a first data edge including "i1, age, i1d2" may be generated, where i1 represents an identifier of the "teacher", age represents a name of the target attribute information, and i1d2 represents an identifier of the target attribute information of the "teacher", it should be noted that the different types of information and identifiers of the data attribute information may be generated in advance when the optional query information is acquired, or may be generated synchronously when the node or edge is created, which is not limited by the embodiment of the present disclosure.
In an embodiment of the present disclosure, the optional component further includes an optional data attribute component; creating a first condition node based on a first query node and a target data attribute component indicated by the condition element adding instruction in the case that the graph element operating instruction is the condition element adding instruction; the first query node and the target data attribute component are selected by the user from previously created query nodes and the optional data attribute component; the first condition node is used for representing a query condition of target attribute information corresponding to the target data attribute component; adding a first data edge between the first conditional node and the first query node to obtain the query graph; the first data edge is used for representing the target attribute information. Therefore, the first condition node and the first data edge can be created for the query graph through the optional data attribute component, the query condition is constructed through the visual condition node and the visual data edge, the query limitation on the target attribute information is realized, and the accuracy of query semantic construction is improved.
Optionally, the optional component further includes a filtering component, and the operation of constructing the query graph based on the graph elements and/or the optional components indicated by the graph element operation instruction may further include the following steps in an embodiment of the present disclosure:
step 401, under the condition that the primitive element operation instruction is a filtering element adding instruction, creating a second condition node based on a second query node indicated by the filtering element adding instruction and a filtering condition set in the filtering component; the second query node is selected by the user from previously created query nodes; the second condition node is used for representing the filtering condition set in the filtering component by the user.
The above-mentioned diagram element operation instruction may further include a filter element addition instruction, specifically, the filter element addition instruction may be generated by a user through a specified operation on the filter component, where the specified operation may include an editing operation. The filter component may be used to set filter criteria and may be a text editing component through which a user may edit filter criteria for one or more data attributes. The second query node indicated by the filter element adding instruction refers to a query node involved in the filter condition, and may be one or multiple query nodes.
Specifically, after the second condition node is created, the query condition added by the user may be stored in the created second condition node in a character string form, and the second condition node may also be in a diamond form or an irregular polygon form, which is not limited in this disclosure.
Step 402, adding a second data edge between the second condition node and the second query node to obtain the query graph; the second data edge is used for representing filtering attribute information.
Specifically, when a user adds a filter condition for a plurality of query nodes and a plurality of data attributes through the filter component, a second data edge may be generated according to the class information of the filter condition and the query node involved in the data attribute information, so as to connect the query node and the second condition node.
The filter attribute information refers to data attribute information to which a filter condition set in a filter component is directed, and accordingly, the filter attribute information may be one or a plurality of filter attribute information.
It will be appreciated that when the filter term relates to a plurality of query nodes, there are a plurality of second data edges. Further, an identifier of a second query node as a subject may be stored in the second data edge, and a name of the filter attribute information as a predicate and an identifier or a variable name of the filter attribute information as an object may also be stored in the second data edge. Illustratively, the user may add a filtering condition that "age" of "teacher" minus "age" of "student" is greater than twenty through the filtering component, so as to generate a second condition node including filtering conditions "i1d2-i2d1 > 20", and second data edges respectively including "i1, age, i1d2", "i2, age, i2d2", where i1 represents an identifier of "teacher", i2i represents an identifier of "student", age represents a name of target attribute information, i1d2 represents an identifier of filtering attribute information of "teacher", and i2d2 represents an identifier of filtering attribute information of "student".
In an embodiment of the present disclosure, the optional components further include a filtering component, and in a case that the primitive element operation instruction is a filtering element adding instruction, create a second condition node based on a second query node indicated by the filtering element adding instruction and a filtering condition set in the filtering component; the second query node is selected by the user from previously created query nodes; the second condition node is used for representing the filtering condition set by the user in the filtering component; adding a second data edge between the second condition node and the second query node to obtain the query graph; the second data edge is used for representing filtering attribute information. In this way, the query filtering of the filtering attribute information can be set through the filtering component, and meanwhile, the filtering condition can be displayed in a visual form by adding the second condition node and the second data edge in the query graph, so that a user can visually see the constructed query semantics, and the accuracy of constructing the query semantics is improved.
Optionally, the building a query graph based on the graph elements and/or the optional components indicated by the graph element operation instruction may further include the following steps in an embodiment of the present disclosure:
step 501, in a case that the graph element operation instruction is a node deletion instruction, if a node indicated by the node deletion instruction is not connected to other conditional nodes through a data edge, deleting the node indicated by the node deletion instruction, and deleting the data edge connected to the indicated node to obtain the query graph; the nodes comprise the query node and a condition node; the condition nodes include the first condition node and the second condition node; the data edge comprises the first data edge and the second data edge;
step 502, deleting the relationship side indicated by the relationship side deleting instruction to obtain the query graph under the condition that the graph element operation instruction is the relationship side deleting instruction.
The graph element operation instruction may further include a deletion instruction, and the deletion instruction may further include a node deletion instruction and a relationship edge deletion instruction. Specifically, the optional components may further include a query graph component, which may be formed by a query graph, the initial state of the query graph may be null, and the primitive elements added to the query graph may be displayed to the user through the query graph component, so that in the embodiment of the present disclosure, the primitive elements in the current query graph may be deleted by receiving a selection operation of the user on the graph elements in the query graph component.
Specifically, the node deletion instruction and the relational edge deletion instruction may be generated by a user selecting an existing graph element, when the user selects a deletion node, an edge connected to the node may be deleted together, and both the conditional node and the query node not directly connected to the conditional node support the deletion operation. As indicated in step 501, the node indicated by the node deletion instruction is not connected to other condition nodes through data edges, which means that the query node selected by the user for deletion is not directly connected to any condition node, and it can be understood that, in the embodiment of the present disclosure, the first condition node and the second condition node respectively represent the query condition and the filter condition for the corresponding query node through the first data edge and the second data edge, and therefore, if the query node directly connected to any condition node is deleted, the corresponding condition node is isolated, and the query or filter object corresponding to the query condition or the filter condition of the condition node cannot be confirmed, so that, in the embodiment of the present disclosure, deletion of any condition node and the query node not directly connected to any condition node can be supported.
Furthermore, the operation of deleting the relation edges can be supported, when the user selects the relation edges to delete, only the selected edges are deleted, and the nodes are not deleted. It can be understood that, since the data edge is used to connect the condition node and the query node, if the data edge is deleted, the condition node is isolated, and thus the retrieval object corresponding to the retrieval condition of the condition node cannot be confirmed, the embodiment of the present disclosure may not support the operation of deleting the data edge, and avoid the error of query semantic construction.
In the embodiment of the present disclosure, when the primitive element operation instruction is a node deletion instruction, if a node indicated by the node deletion instruction is not connected to another conditional node through a data edge, deleting the node indicated by the node deletion instruction, and deleting the data edge connected to the indicated node, so as to obtain the query graph; the nodes comprise the query node and a condition node; the condition nodes include the first condition node and the second condition node; the data edge comprises the first data edge and the second data edge; and under the condition that the graph element operation instruction is a relation side deleting instruction, deleting the relation side indicated by the relation side deleting instruction to obtain the query graph. Therefore, when a node deleting instruction or a relation edge deleting instruction is received, the primitive elements indicated by the deleting instruction in the current query graph can be deleted, a user can modify or adjust the current constructed query graph conveniently, and the accuracy of constructing query semantics is improved.
Optionally, before generating the target query statement based on the target query information corresponding to the primitive elements included in the query graph according to the preset generation rule, the embodiment of the present disclosure may further include the following steps:
step 601, when the query graph comprises at least two nodes, acquiring a target node; the target node is a node which is not communicated with other nodes in the query graph; the nodes comprise a query node and a condition node; the condition nodes include a first condition node and a second condition node.
The target node is a node which is not communicated with any node in the current query graph, wherein the node comprises a query node and the first conditional node and the second conditional node. Specifically, any node in the graph can be randomly selected as a root node, the query graph is traversed through a breadth-first traversal algorithm, if all nodes in the graph can be traversed, the root node is communicated with other nodes in the graph, and if all nodes cannot be traversed, the current root node is used as the target node.
And step 602, generating prompt information based on the target node and outputting the prompt information to the terminal, wherein the prompt information is used for reminding the user to adjust the communication relation between the nodes for the target node so as to enable the target node to be communicated with at least one other node.
Specifically, when a target node which is not connected with other nodes exists in the graph, it is indicated that primitive elements in the current query graph are not associated, and the association of the query graph corresponds to query semantics, and when the target node exists in the query graph, it is indicated that the query semantics represented by the current query graph are not smooth, and at this time, a situation which does not conform to the conventional query habit of the user may exist, so that at this time, prompt information can be generated for the target node and output to a terminal, and the user can modify the connection structure of the query graph when receiving the prompt information.
Specifically, the prompt information may be in the form of a connected branch, that is, at least one connected branch may be added between the target node and at least one other node, and the user may select the target branch from the at least one connected branch, so that the target node is connected to the at least one other node through the target branch.
Further, in the embodiment of the present disclosure, after the user finishes modifying each time, the target node may be obtained again until no target node exists in the current query graph.
The embodiment of the present disclosure may specifically include the following steps:
step 603, under the condition that the target node does not exist in the query graph, executing the operation of generating a target query statement according to a preset generation rule and based on target query information corresponding to primitive elements contained in the query graph.
It can be understood that when the target node does not exist in the current query graph, it indicates that the primitive elements in the current query graph are all associated, and the current query semantics are smooth and conform to the conventional thinking habit of a user, so that the operation of analyzing the query graph can be directly performed at this time.
In the embodiment of the disclosure, when the query graph comprises at least two nodes, a target node is obtained; the target node is a node which is not communicated with other nodes in the query graph; the nodes comprise a query node and a condition node; the condition nodes comprise a first condition node and a second condition node; generating prompt information based on the target node and outputting the prompt information to the terminal, wherein the prompt information is used for reminding the user to adjust the communication relation among the nodes for the target node so as to enable the target node to be communicated with at least one other node; the method further comprises the following steps: and under the condition that the target node does not exist in the query graph, executing the operation of generating a target query statement according to a preset generation rule and based on target query information corresponding to the primitive elements contained in the query graph. Therefore, the connectivity of the query graph can be detected by obtaining the target node in the query graph, and when other nodes which are not communicated with other nodes exist in the query graph, the current query graph is adjusted by a user through the prompt information, so that the relevance among all pixels in the query graph is ensured, the continuity of query semantics is ensured, and the accuracy of query semantics construction is improved.
Optionally, the operation of generating the target query statement based on the target query information corresponding to the primitive element included in the query graph according to the preset generation rule may specifically include the following steps:
step 701, according to the preset generation rule, generating a first statement based on the identifier of the query node included in the query graph, and generating an identifier field of the target query statement based on the first statement.
The preset generation rule refers to the grammar of a target query statement, the identification field refers to a Select field, and the identification field contains an identification of information required to be queried by a user and is used for representing an information identification required to be output by the query.
Specifically, since the query node can represent the class information of the query, unique identifiers of all query nodes in the query graph can be obtained, and the obtained identifiers of the query nodes are spliced according to the preset generation rule to generate the first statement. Further, the first statement may be spliced with a specified field of the identification field, so as to obtain the identification field of the target query statement.
Step 702, according to the preset generation rule, generating a second statement based on the identifier of the query node and the target class information corresponding to the query node, and generating a query domain of the target query statement based on the second statement.
The query domain may be a Where domain or a declaration domain, and the query domain may declare a query node in the query graph and indicate a category to which the query node belongs, that is, target class information to which the query node belongs.
Furthermore, the identifier of each query node and the corresponding target type information can be declared to generate a second statement, and the second statements of different query nodes are spliced with the specified field of the query domain to obtain the query domain of the target query statement.
And 703, splicing the identification field and the query field according to the preset generation rule to obtain the target query statement.
Specifically, the target query statement is usually a SPARQL statement, and accordingly, the preset generation rule refers to syntax of the SPARQL statement.
Illustratively, there is one query node uniquely identified as
Figure SMS_1
The class name (target class information) of the Teacher1 is http:// test/myExample/school. Own # Teacher, the target query statement is SPARQL statement for example, and the Select field can be generated as follows: SELECT DISTINCT
Figure SMS_2
Teacher1, generates Where domains as: WHERE great curl
Figure SMS_3
Teacher1 a
Figure SMS_4
. Wherein SELECT DISTINCT is a designated field of the SELECT field, WHERE { } and "a",<>"," are all specified formats and fields of the Where field, to which the word pair is applied
Figure SMS_5
And declaring the target class information corresponding to the Teacher 1.
In the embodiment of the disclosure, a first statement is generated based on the identifier of the query node included in the query graph according to the preset generation rule, and an identifier domain of the target query statement is generated based on the first statement; generating a second statement based on the identifier of the query node and the target class information corresponding to the query node according to the preset generation rule, and generating a query domain of the target query statement based on the second statement; and splicing the identification domain and the query domain according to the preset generation rule to obtain the target query statement. Therefore, through the identification of the query node and the corresponding target class information, the identification domain and the query domain containing the class information to be queried of the query graph can be obtained, the query statement conforming to the syntax of the query statement can be obtained through the preset generation rule, and the query statement conforming to the query semantic is generated while the semantic accuracy of the query graph is ensured.
Optionally, the embodiment of the present disclosure may further include the following steps:
step 801, under the condition that the query graph comprises a query edge, generating a mark statement and an attribute statement based on the query edge in the query graph according to the preset generation rule, adding the mark statement to the mark domain, and adding the attribute statement to the query domain; the query edge includes a relationship edge and a data edge.
The query edge may include a relationship edge and a data edge, and the relationship edge may represent relationship attributes between different query nodes, and the data edge may represent queried data attribute information, so that when the query graph includes the query edge, the relationship attribute information and the data attribute information to be queried may be obtained through the query edge, and declared in the identifier field and the query field, respectively, so that the generated query statement may express information represented by each graph element in the query graph.
Step 802, in a case that the query graph includes a condition node, generating a third statement based on a query condition or a filter condition corresponding to the condition node according to the preset generation rule, and adding the third statement to a filter domain; the condition nodes include a first condition node and a second condition node.
The condition nodes may include a first condition node and a second condition node, and it can be understood that the condition nodes include query conditions or filter conditions, which characterize search conditions in query semantics, so that the query conditions or the filter conditions may be declared in a filter domain of a target query statement, so that the target query statement may express the condition semantics in a query graph.
The Filter field may be a Filter field, and is used to characterize the search condition in the query graph. Specifically, a string of the query condition or the filter condition included in the condition node may be used as a third statement, where one or more query node identifiers may be included, for example:
Figure SMS_6
Teacher1#age -
Figure SMS_7
Student2#age>20, so that the third statement can be spliced with the specified field of the filtering domain to obtain the filtering domain of the target query statement: FILTER (
Figure SMS_8
Teacher1#age -
Figure SMS_9
Student1#age>20 An age attribute in a Teacher1 query node-a retrieval condition in a Student1 query node with an age attribute greater than twenty may be characterized.
The operation of splicing the identification field and the query field according to the preset generation rule may further include the following steps:
step 803, the identification domain, the query domain and the filtering domain are spliced according to the preset generation rule to obtain the target query statement.
Specifically, the filtering domain may be after the query domain, specifically based on the syntax of the query statement, and then after the identification domain, the query domain, and the filtering domain are obtained respectively, the strings of the Select domain, the Where domain, and the Filter domain may be spliced together to form a complete SPARQL statement, that is, the target query statement.
In the embodiment of the present disclosure, when the query graph includes a query edge, according to the preset generation rule, an identifier statement and an attribute statement are generated based on the query edge in the query graph, the identifier statement is added to the identifier field, and the attribute statement is added to the query field; the query edge comprises a relationship edge and a data edge; under the condition that the query graph comprises condition nodes, generating a third statement based on the query condition or the filter condition corresponding to the condition nodes according to the preset generation rule, and adding the third statement to a filter domain; the condition nodes comprise a first condition node and a second condition node; and splicing the identification domain, the query domain and the filtering domain according to the preset generation rule to obtain the target query statement. Therefore, when the query graph comprises the query edges and the condition nodes, the query statement comprising the query conditions or the filtering conditions can be obtained by analyzing the query edges and the condition nodes, so that the target query statement can completely express the representation semantics of all graph elements in the query graph, the query statement conforming to the query semantics is generated, and the accuracy of the query statement is ensured.
Optionally, in the operation of generating the markup statements and the attribute statements based on the query edges in the query graph, an embodiment of the present disclosure may specifically include the following steps:
step 901, generating a first attribute statement based on the identifier of the target query node corresponding to the relationship edge and the relationship attribute between the target query nodes.
It can be understood that the relationship edge may represent the relationship attribute between different query nodes, and in order to ensure the accuracy of query semantics, the relationship attribute between different types of information is necessary information for forming a query statement, so that the identifier and the relationship attribute of the target query node may be obtained through the relationship edge.
Specifically, the relationship attribute between different types of information is usually expressed in the form of a principal and predicate object, and a unique identifier of the principal, a unique identifier of the predicate name, and a unique identifier of the object can be obtained in a relationship edge, where the unique identifier of the principal and the unique identifier of the object are identifiers of two end points (target query nodes) of the relationship edge, and the predicate name refers to the relationship attribute between the two, for example: the subject is identified as
Figure SMS_10
Teacher1, object notation is
Figure SMS_11
Student1, predicate name http:// test/myExample/school. Own # teach, so that a first attribute statement of:'
Figure SMS_12
Teacher1
Figure SMS_13
Figure SMS_14
Student1. "for characterization
Figure SMS_15
Teacher1teach
Figure SMS_16
Student 1's relational attributes.
Step 902, generating the markup statement based on the markup of the target attribute information or the filter attribute information corresponding to the data edge, if the data edge includes the output markup; the data edges include a first data edge and a second data edge.
And 903, generating a second attribute statement based on the target attribute information or the filter attribute information corresponding to the data edge.
The data edges may include a first data edge and a second data edge, which are data edges corresponding to the first condition node and the second condition node, respectively, so that the data attribute information corresponding to the data edges may be target data attribute information corresponding to the first condition node or filter attribute information corresponding to the second condition node. The output identifier is set by receiving a setting instruction of a user, and is used to represent whether to output corresponding target attribute information or filter attribute information, where the output identifier may be true, the non-output identifier may be false, or of course, the output identifier may be in other forms.
Specifically, when the data edge includes the output identifier, it indicates that the query semantics constructed by the user needs to output the data attribute information corresponding to the data edge, and therefore the identifier of the data attribute information needs to be added to the identifier field for declaration, so that the corresponding target attribute information or filtering attribute information can participate in the output of the query result.
Further, the data edge is connected with the corresponding query node, so that the belonging class information of the corresponding target attribute information or the filtering attribute information can be represented, the unique identification and the name of the corresponding data attribute information can be obtained according to the data edge, and the belonging information of the data attribute information can be declared in the query domain, namely the class information to which the corresponding target attribute information or the filtering attribute information belongs.
Illustratively, the identification of the target attribute information or the filter attribute information is
Figure SMS_17
The name of Teacher1# age is http:// test/myExample/school. Own # age, if the output flag is true, then data attribute attribution information can be added in the Where domain, that is, the second attribute statement is: "
Figure SMS_18
Teacher1
Figure SMS_19
Figure SMS_20
Teacher1# age ", since the output flag is true, add in Select field"
Figure SMS_21
Teacher1# age "participates in the output.
In the embodiment of the disclosure, a first attribute statement is generated based on the identifier of the target query node corresponding to the relationship edge and the relationship attribute between the target query nodes; under the condition that the data edges comprise output marks, generating the mark sentences based on the marks of target attribute information or filtering attribute information corresponding to the data edges; the data edges comprise a first data edge and a second data edge; and generating a second attribute statement based on the target attribute information or the filtering attribute information corresponding to the data edge. Therefore, by analyzing the relation edges and the data edges respectively, the query statement can completely express the representation semantics of each graph element in the query graph, generate the query statement conforming to the query semantics, and ensure the accuracy of the query statement.
Optionally, the embodiment of the present disclosure may further include the following steps:
1001, acquiring optional component information based on a preset query body file; the optional component information includes class information, data attribute information, and relationship attribute information.
And step 1002, dividing the data attribute information and the relation attribute information into belonged class information.
And 1003, generating a sorting index file for any one of the types of information based on the data attribute information and the relation attribute information belonging to the type of information.
Step 1004, sending the optional component information and the sorting index file to the terminal, so that the terminal displays the optional components based on the optional component information and the sorting index file.
For the above steps 1001 to 1004, the query ontology file refers to a semantic ontology file (OWL), which includes optional query information and corresponding semantic ontology information, and generally includes class information, data attribute information, and relationship attribute information. The class information defines classes of matters in the ontology and inheritance relationships among the classes, the names are usually in a noun form, such as a school leader, a teacher and students, the school leader is a special teacher and can serve as a subclass of the teacher, the relationship attribute information defines relationships among the classes except the inheritance relationships, the classes are provided with a subject and an object, value ranges are all the classes, the names are mostly verbs, such as teaching, the subject range is the teacher, the object range is the students, and the teaching relationship between the teacher and the students is indicated. The data attribute defines data information of the class, and also has a subject and an object, the value range of the subject is the class, the value range of the object is the data type, names are mostly nouns, such as names, the subject range is teacher and student, the object range is a character string, and the name information indicates that the teacher and the student have corresponding name information. Further, the optional component information refers to optional query information included in the query ontology file, that is, the class information, the data attribute information, and the relationship attribute information.
The dividing refers to dividing the data attribute information and the relationship attribute information into the corresponding class information respectively. It should be noted that, in the OWL file, the class information, the data attribute information, and the relationship attribute information are stored separately, and for the convenience of subsequent query, the information needs to be integrated again, and specifically, the class information, the data attribute information, and the relationship attribute information corresponding to each class may be obtained by integrating according to the class to which the subject of the data attribute information belongs and the class to which the subject and the object of the relationship attribute information belong.
Furthermore, the class information with inheritance relationship can be integrated, the inheritance tree of the class is traversed through the hierarchy, and the attribute information is added to the subclasses in sequence, so that each subclass has all relationship attributes and data attribute information of the parent class.
The sorted index file may be a forward-sorted index file or a reverse-sorted index file, and specifically, the forward-sorted index refers to establishing sorting for data attribute information and relationship attribute information corresponding to a certain type of information, so that for any type of information, all corresponding data attribute information and relationship attribute information can be traversed according to the forward-sorted index. Correspondingly, the inverted index refers to sorting the corresponding class information of a certain attribute information (relationship attribute information or data attribute information), so that any attribute information can be traversed to the corresponding class information according to the inverted index.
Further, since a unique identifier needs to be provided for a data attribute information variable related to query when a query statement is generated, after data attribute information included in each type of information is obtained, a unique identifier is generated for the data attribute of each type of information through self-increment counting for distinguishing different data attribute information of different types of information, and certainly, a unique identifier can also be generated for different relationship attribute information for distinguishing different relationship attribute information.
Further, after the optional component information and the sorting index file are obtained, data attribute information and relationship attribute information corresponding to any type of information can be obtained, so that different optional components can be generated for displaying the optional component information. Specifically, the selectable components may include the selectable class components, the selectable relationship attribute components, the selectable data attribute components, and the filter components described in the foregoing steps, and specifically, the corresponding selectable class components may be initially displayed according to all class information included in the selectable component information, and after a user performs a specific operation on any selectable class component, the corresponding selectable data attribute components and the corresponding selectable relationship attribute components may be displayed according to the data attribute information and the relationship attribute information corresponding to the class information in the sorted index file. The selectable class component can be composed of a class list and a search box, the initial state is to list all classes, and a screening function based on class names and description information is provided through the search box. The optional data attribute component can be composed of a data attribute list and a search box, the initial state is empty, and a screening function based on data attribute names and description information can be provided through the search box so as to obtain corresponding query conditions according to the operation of a user on the search box. The filtering component may be a text editor for a user to manually compose high-level filter terms relating to a plurality of data attributes.
Further, the optional components may further include a query graph component, which may be composed of a query graph composed of classes and conditions as points and attributes as edges, the initial state of the query graph may be null, and the primitive elements added for the query graph may be displayed to the user through the query graph component.
Fig. 2 is a structural diagram of a query graph according to an exemplary embodiment, as shown in fig. 2, the constructed query graph may include nodes and edges, the nodes may further include instance nodes (query nodes) and condition nodes, the edges may further include object edges (relationship edges) and data edges, accordingly, the instance nodes may store unique identifiers and class names of the nodes, the condition nodes may store retrieval conditions composed of one or more data attributes, which may be the aforementioned query conditions or filtering conditions, the object edges may store unique identifiers of subjects, unique identifiers of objects, and predicate names, and the data edges may store unique identifiers of data attributes, names of data attributes, and flags of whether to output.
In the embodiment of the disclosure, optional component information is acquired by querying the body file based on the preset information; the selectable component information comprises class information, data attribute information and relationship attribute information; integrating the class information based on the data attribute information and the class of the relationship attribute information to generate integrated information; generating an inverted index based on the data attribute information and the relationship attribute information contained in the class information; generating an identifier based on data attribute information contained in the class information; and acquiring data organization information based on the identification, the integration information and the inverted index, and sending the data organization information to the terminal so that the terminal displays the optional components based on the data organization information. Therefore, data organization information is obtained by correspondingly processing the data information included in the query body file, the terminal can generate and display optional components corresponding to the query body file through the data organization information containing the identification, the integration information and the inverted index, visual query operation is provided for a user, the user can construct query semantics of the query body file through the generated optional components, query difficulty is reduced, and query efficiency is improved.
Further, in the embodiment of the present disclosure, after the query graph and the target query statement are obtained, the query graph structure and the target query statement may be further stored, specifically, the query graph structure itself is composed of nodes and edges, so that the nodes and the edges only need to be persisted, the persisted nodes may be stored in a file in a serialization manner, the persisted query graph may use a third-party serialization framework, where the display form after serialization mainly includes two types: json format and binary format. The serialization of the json format mainly uses a serialization framework which mainly comprises fastjson and jackson, and the method has the advantages of strong readability after serialization, simple data format and easy reading and writing. The serialization of the binary format mainly uses a serialization framework such as Kyro, protoBuf, hessian and the like, the performance of the serialization process is higher than that of java primary serialization, the serialization result is a binary stream, the serialization speed is high, the occupied storage after the serialization is carried out is small, the information is not plaintext, and the confidentiality is good.
Specifically, the storing of the query statement may be to generate an unique identifier (id) for the query graph, associate the target query statement with the query graph through the id, and store the target query statement in the file, where the file name may use the id as a prefix, so as to facilitate subsequent searching and multiplexing.
Fig. 3 is an interaction sequence diagram of an implementation of semantic query visualization construction and generation according to an exemplary embodiment, which may include a parsing stage, a construction stage, and a saving stage, as shown in fig. 3, where a user shown in the diagram refers to any user with a query requirement, the user may send a corresponding instruction to a web ontology language file parser and a query graph service through a terminal, and the web ontology language file (OWL) parser and the query graph service in the diagram refer to an execution subject of the implementation method of semantic query visualization construction and generation provided by the present disclosure, which may be any terminal device, or may be a back end of a terminal used by the user.
Specifically, as shown in fig. 3, the parsing stage may include requesting parsing of a network ontology language file and successful parsing of metadata, in the building stage, a user may send a graph element operation instruction to the query graph service based on an optional component to build a query graph, and accordingly, the query graph service may return the query graph to the user terminal in real time to display, and when a user request is received to generate a resource description framework query language, generate a corresponding resource description framework query language by parsing the query graph, and return a result of the resource description framework query language to the user. Further, in the saving stage, the user may initiate a request for saving the query graph, the query graph service implements persistence of the query graph and the resource description framework query language by responding to the request, and returns a persistence result to the user terminal, thereby the saving is successful. The resource description framework query language refers to SPARQL language.
FIG. 4 is a flowchart illustrating another implementation method for semantic query visualization construction and generation according to an exemplary embodiment, as shown in FIG. 4, which may include the following steps:
and step 211, preparing a network body language file.
Wherein, the network ontology language file refers to an OWL file.
Step 212, parsing the network ontology language file.
Step 213, extracting metadata of the network ontology language file.
Wherein the step is equivalent to acquiring data organization information.
Step 214, providing visualization operation according to the metadata.
The data organization information is returned to the terminal, and the terminal displays the optional components through the data organization information.
Step 215, the client builds a query graph.
The client refers to a user terminal, and the step refers to constructing a query graph by receiving a primitive operation instruction of the client.
And step 216, judging whether the query graph is communicated, if not, executing step 215 again, and if so, executing step 217.
Specifically, the prompt information may be sent to the terminal, so that the user modifies the connectivity of the query graph based on the prompt information.
Step 217, generating a corresponding resource description framework query language according to the query graph.
The resource description framework query language refers to a SPARQL language, so that the step refers to generating a corresponding SPARQL query statement according to a query graph.
Step 218, saving the query language and the query graph structure of the resource description framework.
It should be noted that, in the semantic technology field, the application domain data formalized information is usually modeled by a Resource Description Framework (RDF) or a semantic web ontology language (OWL), and then the data is retrieved and queried according to the application requirements. The modeling function provided by the semantic web ontology language OWL is very flexible and rich, is suitable for describing an industrial information model, not only has definite and standardized semantics, but also can be used for semantic fusion, query and logical reasoning. RDF is a model framework for describing resource characteristics and relationships between resources, and the framework stores data in triples and can be combined with an OWL ontology to perform efficient query. If the original data volume is too large and the data is updated frequently, huge expenses are brought by converting the latest data into a triple form for materialized storage all the time. At this point, the data may be virtualized into RDF triples using mapping techniques in accordance with ontology-based data access (OBDA) techniques for corresponding semantic queries. In any way, the most common language for semantic query of RDF triple data is SPARQL, which is a query language and data acquisition protocol developed specifically for RDF. In practical application, most users of the ontology semantic model are business experts with knowledge in the application field, and the users usually do not have knowledge and skills in the aspects of computer technology, formal semantic query and the like, so that the good experience of constructing SPARQL query is the basis of efficient semantic query.
In the prior art, the SPARQL query is typically constructed in several ways:
text query editor: the user directly edits the SPARQL text to construct a query, and a part of the editor provides a context sensing function, so that convenience is brought to the SPARQL text editing process of the user. Such systems require semantic queriers to have SPARQL's grammatical knowledge, thus leading to a higher usage threshold and greatly limited ease of use.
And (3) keyword searching: a query is constructed using a plurality of keywords. The method is simple to operate, but has limited expression capability, for example, semantic logic association among a plurality of keywords is difficult to express, so that constructed queries can be greatly different from the query intention of a user, and the query result is not expected.
Natural language query: the query is described using natural language. And a machine learning algorithm is used to automatically identify the corresponding SPARQL semantic query from the natural language. In such query systems, the user experience of building a query is better. However, because of the diversity and ambiguity of natural language, the SPARQL language automatic identification precision is often low, and the supported sentence pattern is limited, so the practicability of the method is not good.
It can be understood that the above methods all have the problem of query difficulty or semantic ambiguity construction, and the interactivity and comprehensibility of constructing queries based on texts are limited by the text form. The implementation method for semantic query visual construction and generation provided by the embodiment of the disclosure can assist users in the business field to efficiently and accurately construct semantic queries in a graphical manner, so that the users only need to concentrate on query semantic logic and do not need to know specific SPARQL syntax, and compared with visualization based on a tree structure, the implementation method for semantic query visual construction with more intuition, accurate semantics and stronger expression capability can be realized.
FIG. 5 is a block diagram illustrating an apparatus for implementing semantic query visualization construction and generation according to an exemplary embodiment, where as shown in FIG. 5, the apparatus 110 may include:
a query graph constructing module 1101, configured to, in response to receiving a primitive operation instruction sent by a terminal, construct a query graph based on a graph element and/or an optional component indicated by the primitive operation instruction; the primitive element operation instruction is generated by the terminal according to the specified operation of a user on the created primitive elements and/or optional components displayed in the interface of the terminal; the optional component is used for providing semantic information of optional query information for the user;
a query statement generation module 1102, configured to generate a target query statement based on target query information corresponding to a primitive element included in the query graph according to a preset generation rule;
an output module 1103, configured to output the target query statement to a target object; the target object is used for executing the query operation indicated by the query graph based on the target query statement, and the target object comprises the terminal.
Optionally, the optional components include optional class components; the query graph constructing module 1101 includes:
the query node construction sub-module is used for creating a query node based on the target class component indicated by the query node adding instruction under the condition that the primitive element operation instruction is the query node adding instruction; the target class component is selected from the optional class components by the user, and the query node is used for representing target class information corresponding to the target class component;
the relation edge construction sub-module is used for adding relation edges among target query nodes indicated by the relation edge adding instructions under the condition that the graph element operation instructions are the relation edge adding instructions so as to obtain the query graph; the relation edge adding instruction is generated by the terminal according to the selection operation of the user on the target query nodes, and the relation edge is used for representing the relation attribute between the target query nodes; the target query nodes include at least two query nodes selected by the user from the created primitive elements.
Optionally, the optional components further comprise an optional data attribute component; the query graph building module 1101 further includes:
a first condition node creating sub-module, configured to create a first condition node based on a first query node and a target data attribute component indicated by the conditional element adding instruction when the graph element operation instruction is the conditional element adding instruction; the first query node and the target data attribute component are selected by the user from previously created query nodes and the optional data attribute component; the first condition node is used for representing a query condition of target attribute information corresponding to the target data attribute component;
a first data edge adding sub-module, configured to add a first data edge between the first condition node and the first query node, to obtain the query graph; the first data edge is used for representing the target attribute information.
Optionally, the optional components further include a filtering component, and the query graph constructing module 1101 further includes:
a second condition node creating sub-module, configured to, when the primitive element operation instruction is a filter element adding instruction, create a second condition node based on a second query node indicated by the filter element adding instruction and a filter condition set in the filter component; the second query node is selected by the user from previously created query nodes; the second condition node is used for representing the filtering condition set by the user in the filtering component;
a second data edge adding submodule, configured to add a second data edge between the second conditional node and the second query node, to obtain the query graph; the second data edge is used for representing filtering attribute information.
Optionally, the query graph building module 1101 further includes:
the node deleting submodule is used for deleting the node indicated by the node deleting instruction and deleting the data edge connected with the indicated node to obtain the query graph if the node indicated by the node deleting instruction is not connected with other condition nodes through the data edge under the condition that the primitive pixel operation instruction is the node deleting instruction; the nodes comprise the query node and a condition node; the condition nodes include the first condition node and the second condition node; the data edge comprises the first data edge and the second data edge;
and the relation edge deleting submodule is used for deleting the relation edge indicated by the relation edge deleting instruction under the condition that the graph element operation instruction is the relation edge deleting instruction so as to obtain the query graph.
Optionally, the apparatus 110 further includes:
a target node obtaining module, configured to obtain a target node when the query graph includes at least two nodes before the query statement generating module generates a target query statement based on target query information corresponding to a primitive element included in the query graph according to a preset generation rule; the target node is a node which is not communicated with other nodes in the query graph; the nodes comprise a query node and a condition node; the condition nodes comprise a first condition node and a second condition node;
a prompt message generation module, configured to generate a prompt message based on the target node and output the prompt message to the terminal, where the prompt message is used to prompt the user to adjust a communication relationship between nodes for the target node, so that the target node is communicated with at least one other node;
the query statement generating module 1102 is specifically configured to, in a case that the target node does not exist in the query graph, execute the operation of generating a target query statement according to a preset generation rule based on target query information corresponding to a primitive element included in the query graph.
Optionally, the query statement generating module 1102 includes:
the first statement generation submodule is used for generating a first statement based on the identification of the query node contained in the query graph according to the preset generation rule and generating an identification domain of the target query statement based on the first statement;
the second statement generation submodule is used for generating a second statement based on the identifier of the query node and the target type information corresponding to the query node according to the preset generation rule, and generating a query domain of the target query statement based on the second statement;
and the splicing module is used for splicing the identification domain and the query domain according to the preset generation rule to obtain the target query statement.
Optionally, the apparatus 110 further comprises:
the mark attribute statement generating module is used for generating a mark statement and an attribute statement based on the query edge in the query graph according to the preset generating rule under the condition that the query graph comprises the query edge, adding the mark statement to the mark domain and adding the attribute statement to the query domain; the query edge comprises a relationship edge and a data edge;
a third statement generation module, configured to generate a third statement based on the query condition or the filter condition corresponding to the condition node according to the preset generation rule when the query graph includes the condition node, and add the third statement to the filter domain; the condition nodes comprise a first condition node and a second condition node;
the splicing module is specifically configured to: and splicing the identification domain, the query domain and the filtering domain according to the preset generation rule to obtain the target query statement.
Optionally, the flag property statement generating module includes:
the first attribute statement generating submodule is used for generating a first attribute statement based on the identification of the target query node corresponding to the relationship edge and the relationship attribute between the target query nodes;
the identification statement generation submodule is used for generating the identification statement based on the identification of the target attribute information or the filtering attribute information corresponding to the data edge under the condition that the data edge comprises an output identification; the data edges comprise a first data edge and a second data edge;
and the second attribute statement generating submodule is used for generating a second attribute statement based on the target attribute information or the filtering attribute information corresponding to the data edge.
Optionally, the apparatus 110 further comprises:
the component information acquisition module is used for acquiring optional component information based on a preset query body file; the optional component information comprises class information, data attribute information and relationship attribute information;
the dividing module is used for dividing the data attribute information and the relation attribute information into the belonged class information;
the sorting index generation module is used for generating a sorting index file for any type of information based on the data attribute information and the relation attribute information belonging to the type of information;
and the optional component display module is used for sending the optional component information and the sorting index file to the terminal so as to enable the terminal to display the optional components based on the optional component information and the sorting index file.
To sum up, the implementation apparatus for visually constructing and generating a semantic query provided by the embodiment of the present disclosure constructs a query graph based on a target graph element and/or an optional component indicated by a graph element operation instruction by responding to the received graph element operation instruction sent by a terminal; the primitive element operation instruction is generated by the terminal according to the specified operation of a user on the created primitive elements and/or optional components displayed in the interface of the terminal; the optional component is used for providing semantic information of optional query information for the user; generating a target query statement based on target query information corresponding to the primitive elements contained in the query graph according to a preset generation rule; outputting the target query statement to a target object; the target object is used for executing the query operation indicated by the query graph based on the target query statement, and the target object comprises the terminal. Therefore, a user can add corresponding graph elements to the query graph through the selectable components on the terminal interface and the created graph elements displayed on the terminal interface, so that the query graph is formed, the query statement is further generated according to the preset generation rules and the graph elements contained in the query graph, and because the selectable components can provide semantic information of the selectable query information for the user, the user does not need to know the bottom information of data and the generation rules of the query statement, the query statement conforming to the preset generation rules can be generated only by focusing on the query semantics, the query statement is not needed to be written manually, the construction and the generation of the query statement based on visualization are realized, and the query difficulty is reduced.
According to an embodiment of the present disclosure, there is provided an electronic apparatus including: a processor, a memory for storing processor executable instructions, wherein the processor is configured to implement the steps of the implementation method for semantic query visualization construction and generation as in any of the above embodiments when executed.
There is further provided, according to an embodiment of the present disclosure, a storage medium, where instructions are executed by a processor of an electronic device, so that the electronic device can perform the steps in the implementation method for semantic query visualization construction and generation as in any of the above embodiments.
There is also provided, according to an embodiment of the present disclosure, a computer program product, which includes readable program instructions, when executed by a processor of an electronic device, enable the electronic device to execute an implementation method for semantic query visualization construction and generation as in any of the above embodiments.
User information (including but not limited to device information of a user, personal information of the user, and the like), related data, and the like, to which the present disclosure relates, are information authorized by the user or authorized by various parties.
Other embodiments of the disclosure will be apparent to those skilled in the art from consideration of the specification and practice of the disclosure disclosed herein. This disclosure is intended to cover any variations, uses, or adaptations of the disclosure following, in general, the principles of the disclosure and including such departures from the present disclosure as come within known or customary practice within the art to which the disclosure pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the disclosure being indicated by the following claims.
It will be understood that the present disclosure is 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 the present disclosure is limited only by the appended claims.

Claims (11)

1. An implementation method for visual construction and generation of semantic queries is characterized by comprising the following steps:
in response to receiving a primitive operation instruction sent by a terminal, constructing a query graph based on graph elements and/or optional components indicated by the graph element operation instruction; the primitive element operation instruction is generated by the terminal according to the specified operation of a user on the created primitive elements and/or optional components displayed in the interface of the terminal; the optional component is used for providing semantic information of optional query information for the user;
generating a target query statement based on target query information corresponding to the primitive elements contained in the query graph according to a preset generation rule;
outputting the target query statement to a target object; the target object is used for executing the query operation indicated by the query graph based on the target query statement, and the target object comprises the terminal.
2. The method of claim 1, wherein the selectable components comprise selectable class components; the building a query graph based on the graph elements and/or the optional components indicated by the graph element operation instructions comprises:
under the condition that the graph element operation instruction is a query node adding instruction, creating a query node based on a target class component indicated by the query node adding instruction; the target class component is selected from the selectable class components by the user, and the query node is used for representing target class information corresponding to the target class component;
adding a relation edge between target query nodes indicated by the relation edge adding instruction under the condition that the graph element operation instruction is a relation edge adding instruction to obtain the query graph; the relation edge adding instruction is generated by the terminal according to the selection operation of the user on the target query nodes, and the relation edge is used for representing the relation attribute between the target query nodes; the target query nodes include at least two query nodes selected by the user from the created primitive elements.
3. The method of claim 2, wherein the optional components further comprise an optional data attribute component; the constructing a query graph based on the graph elements and/or the optional components indicated by the graph element operation instructions further comprises:
under the condition that the graph element operation instruction is a conditional element adding instruction, creating a first conditional node based on a first query node and a target data attribute component indicated by the conditional element adding instruction; the first query node and the target data attribute component are selected by the user from among previously created query nodes and the optional data attribute component; the first condition node is used for representing a query condition of target attribute information corresponding to the target data attribute component;
adding a first data edge between the first conditional node and the first query node to obtain the query graph; the first data edge is used for representing the target attribute information.
4. The method of claim 3, wherein the optional components further comprise a filter component, and wherein building a query graph based on the graph elements and/or optional components indicated by the graph element operation instructions further comprises:
under the condition that the primitive element operation instruction is a filtering element adding instruction, creating a second condition node based on a second query node indicated by the filtering element adding instruction and a filtering condition set in the filtering component; the second query node is selected by the user from previously created query nodes; the second condition node is used for characterizing the filtering condition set by the user in the filtering component;
adding a second data edge between the second condition node and the second query node to obtain the query graph; the second data edge is used for representing filtering attribute information.
5. The method of claim 4, wherein the building a query graph based on graph elements and/or optional components indicated by the graph element operation instructions further comprises:
under the condition that the graph element operation instruction is a node deleting instruction, if the node indicated by the node deleting instruction is not connected with other condition nodes through data edges, deleting the node indicated by the node deleting instruction, and deleting the data edges connected with the indicated node to obtain the query graph; the nodes comprise the query node and a condition node; the condition nodes include the first condition node and the second condition node; the data edge comprises the first data edge and the second data edge;
and under the condition that the graph element operation instruction is a relation side deleting instruction, deleting the relation side indicated by the relation side deleting instruction to obtain the query graph.
6. The method according to any one of claims 1 to 5, wherein before generating the target query statement based on the target query information corresponding to the primitive elements included in the query graph according to the preset generation rule, the method further comprises:
when the query graph comprises at least two nodes, acquiring a target node; the target node is a node which is not communicated with other nodes in the query graph; the nodes comprise a query node and a condition node; the condition nodes comprise a first condition node and a second condition node;
generating prompt information based on the target node and outputting the prompt information to the terminal, wherein the prompt information is used for reminding the user to adjust the communication relation among the nodes for the target node so as to enable the target node to be communicated with at least one other node;
the method further comprises the following steps: and under the condition that the target node does not exist in the query graph, executing the operation of generating a target query statement according to a preset generation rule and based on target query information corresponding to the primitive elements contained in the query graph.
7. The method according to claim 1, wherein generating a target query statement based on target query information corresponding to primitive elements included in the query graph according to a preset generation rule includes:
generating a first statement based on the identifier of the query node contained in the query graph according to the preset generation rule, and generating an identifier field of the target query statement based on the first statement;
generating a second statement based on the identifier of the query node and the target class information corresponding to the query node according to the preset generation rule, and generating a query domain of the target query statement based on the second statement;
and splicing the identification domain and the query domain according to the preset generation rule to obtain the target query statement.
8. The method of claim 7, further comprising:
under the condition that the query graph comprises a query edge, generating an identification statement and an attribute statement based on the query edge in the query graph according to the preset generation rule, adding the identification statement to the identification domain, and adding the attribute statement to the query domain; the query edge comprises a relationship edge and a data edge;
under the condition that the query graph comprises condition nodes, generating a third statement based on the query condition or the filter condition corresponding to the condition nodes according to the preset generation rule, and adding the third statement to a filter domain; the condition nodes comprise a first condition node and a second condition node;
the splicing the identification domain and the query domain according to the preset generation rule comprises:
and splicing the identification domain, the query domain and the filtering domain according to the preset generation rule to obtain the target query statement.
9. The method of claim 8, wherein generating an identify statement and an attribute statement based on a query edge in the query graph comprises:
generating a first attribute statement based on the identification of the target query node corresponding to the relationship edge and the relationship attribute between the target query nodes;
under the condition that the data edges comprise output marks, generating the mark sentences based on the marks of target attribute information or filtering attribute information corresponding to the data edges; the data edges comprise a first data edge and a second data edge;
and generating a second attribute statement based on the target attribute information or the filtering attribute information corresponding to the data edge.
10. The method of claim 1, further comprising:
acquiring optional component information based on a preset query body file; the selectable component information comprises class information, data attribute information and relationship attribute information;
dividing the data attribute information and the relationship attribute information into belonging class information;
for any one of the class information, generating a sorting index file based on the data attribute information and the relation attribute information belonging to the class information;
and sending the optional component information and the sorting index file to the terminal so that the terminal displays the optional components based on the optional component information and the sorting index file.
11. An apparatus for implementing semantic query visualization construction and generation, the apparatus comprising:
the query graph constructing module is used for responding to a received graph element operating instruction sent by a terminal and constructing a query graph based on the graph elements and/or the optional components indicated by the graph element operating instruction; the primitive element operation instruction is generated by the terminal according to the specified operation of a user on the created primitive elements and/or optional components displayed in the interface of the terminal; the optional component is used for providing semantic information of optional query information for the user;
the query statement generation module is used for generating a target query statement based on target query information corresponding to the primitive elements contained in the query graph according to a preset generation rule;
the output module is used for outputting the target query statement to a target object; the target object is used for executing the query operation indicated by the query graph based on the target query statement, and the target object comprises the terminal.
CN202310045249.3A 2023-01-30 2023-01-30 Implementation method and device for visual construction and generation of semantic query Pending CN115794869A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310045249.3A CN115794869A (en) 2023-01-30 2023-01-30 Implementation method and device for visual construction and generation of semantic query

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310045249.3A CN115794869A (en) 2023-01-30 2023-01-30 Implementation method and device for visual construction and generation of semantic query

Publications (1)

Publication Number Publication Date
CN115794869A true CN115794869A (en) 2023-03-14

Family

ID=85429209

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310045249.3A Pending CN115794869A (en) 2023-01-30 2023-01-30 Implementation method and device for visual construction and generation of semantic query

Country Status (1)

Country Link
CN (1) CN115794869A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116842546A (en) * 2023-07-14 2023-10-03 临沂大学 Distributed data access authorization and data service method and device, equipment and medium

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2011053112A1 (en) * 2009-11-02 2011-05-05 Mimos Berhad System and method for visual query of semantic information
CN104572970A (en) * 2014-12-31 2015-04-29 浙江大学 SPARQL inquire statement generating system based on ontology library content

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2011053112A1 (en) * 2009-11-02 2011-05-05 Mimos Berhad System and method for visual query of semantic information
CN104572970A (en) * 2014-12-31 2015-04-29 浙江大学 SPARQL inquire statement generating system based on ontology library content

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116842546A (en) * 2023-07-14 2023-10-03 临沂大学 Distributed data access authorization and data service method and device, equipment and medium

Similar Documents

Publication Publication Date Title
US10332012B2 (en) Knowledge driven solution inference
US10853357B2 (en) Extensible automatic query language generator for semantic data
Varanka et al. The map as knowledge base
US20120239677A1 (en) Collaborative knowledge management
CN111949800A (en) Method and system for establishing knowledge graph of open source project
CN112115252B (en) Intelligent auxiliary writing processing method and device, electronic equipment and storage medium
Heino et al. Developing semantic web applications with the ontowiki framework
US11763095B2 (en) Creating apps from natural language descriptions
CN112507076A (en) Semantic analysis searching method and device and storage medium
US10776351B2 (en) Automatic core data service view generator
US10489024B2 (en) UI rendering based on adaptive label text infrastructure
CN115794869A (en) Implementation method and device for visual construction and generation of semantic query
CN115878818B (en) Geographic knowledge graph construction method, device, terminal and storage medium
Yang et al. User story clustering in agile development: a framework and an empirical study
Xie et al. Research and implementation of automatic question answering system based on ontology
US11816770B2 (en) System for ontological graph creation via a user interface
Liu Construction of a 5G wireless semantic web-assisted English digital learning resource query system
CN113434658A (en) Thermal power generating unit operation question-answer generation method, system, equipment and readable storage medium
CN112988986A (en) Man-machine interaction method, device and equipment
Arbizu Extracting knowledge from documents to construct concept maps
CN111966895B (en) Movie question-answering system construction method, device and system based on Watson dialogue service
US11940964B2 (en) System for annotating input data using graphs via a user interface
Warkotsch Developing a graphical user interface for generating Wikipedia lists with Wikidata
Mäkelä View-based user interfaces for the semantic web
Loskyll et al. UbisEditor 3.0: Collaborative ontology development on the Web

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication

Application publication date: 20230314

RJ01 Rejection of invention patent application after publication