Query Graph Construction Method, Device, Storage Medium, and Electronic Device

By converting the attribute graph model into a resource description framework model and using neural language program technology and graph algorithm to construct the target query graph model, the resource description framework model solves the complex and error-prone problems for the attribute graph separately, and simplifies and improves the efficiency and accuracy of query graph construction.

CN115114441BActive Publication Date: 2025-07-08BEIJING XUEZHITU NETWORK TECH
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202210351234.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-04-02
Publication Date
2025-07-08
Estimated Expiration
2042-04-02

AI Technical Summary

Technical Problem

In the prior art, the resource description framework model has a complex and error-prone method for the attribute graph, which leads to inconvenient query graph construction process.

Method used

The attribute graph model is converted into a resource description framework model, and the target query graph model is constructed through entity and intent mapping, and finally converted into an attribute graph model, using neural language program technology and graph algorithm to optimize the processing process.

Benefits of technology

The query graph construction process is simplified, processing efficiency and accuracy are improved, and the validity and reliability of query results are ensured.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115114441B_ABST
    Figure CN115114441B_ABST
Patent Text Reader

Abstract

The present invention discloses a query graph construction method, apparatus, storage medium, and electronic device. The method includes: obtaining a first property graph model and a search query sentence, where the search query sentence is used to search for search results in the first property graph model; converting the first property graph model into a Resource Description Framework (RDF) model; mapping the entities and intents of the search query sentence into the RDF model to obtain entity mapping labels and intent mapping labels; constructing a target query graph model from the RDF model according to the RDF model, entity mapping labels, and intent mapping labels; converting the target query graph model into a target property graph model, where the target property graph model is the search result corresponding to the search query sentence. The present invention solves the technical problem that the method of separately processing and then fusing attributes in the RDF model is complex and error-prone.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computers, and in particular, to a query graph construction method, device, storage medium, and electronic device. Background Art

[0002] Natural language graph search, combining natural language processing technology and knowledge graph technology, can help users obtain knowledge conveniently and accurately. Most existing graph searches are based on the RDF (Resource Description Framework) graph model. The RDF structure is simple, with only nodes and edges, directly corresponding to the "graph data structure", which is convenient for running various graph algorithms. Most publicly available knowledge graph datasets are also published in the form of RDF graphs. In the prior art, the query graph construction method of RDF is directly applied to the property graph. The nodes and edges of RDF respectively correspond to the entities and relationships of the property graph, and then the attributes of the entities and relationships are processed separately to obtain the final result. However, when directly applied to the property graph, the effect often decreases. The separate processing and then fusion of attributes are very complex and error-prone. Summary of the Invention

[0003] Embodiments of the present invention provide a query graph construction method, device, storage medium, and electronic device, so as to at least solve the technical problem that the method of separately processing and then fusing attributes in the resource description framework model is complex and error-prone.

[0004] According to one aspect of the embodiments of the present invention, a query graph construction method is provided, including: obtaining a first property graph model and a search query sentence, where the search query sentence is used to search for a search result in the first property graph model; converting the first property graph model into a resource description framework model; mapping the entities and intents of the search query sentence into the resource description framework model to obtain entity mapping labels and intent mapping labels; constructing a target query graph model from the resource description framework model according to the resource description framework model, the entity mapping labels, and the intent mapping labels; and converting the target query graph model into a target property graph model, where the target property graph model is the search result corresponding to the search query sentence.

[0005] According to another aspect of the embodiments of the present invention, a query graph construction device is provided, including: an acquisition module, configured to acquire a first property graph model and a search query sentence, wherein the search query sentence is used to search for search results in the first property graph model; a first conversion module, configured to convert the first property graph model into a Resource Description Framework (RDF) model; a mapping module, configured to map the entities and intents of the search query sentence into the RDF model to obtain entity mapping tags and intent mapping tags; a construction module, configured to construct a target query graph model from the RDF model according to the RDF model, the entity mapping tags, and the intent mapping tags; a second conversion module, configured to convert the target query graph model into a target property graph model, where the target property graph model is the search result corresponding to the search query sentence.

[0006] As an optional example, the first conversion module includes: a first conversion unit, configured to convert the entities of the first property graph model into the nodes of the RDF model; a second conversion unit, configured to convert the relationships of the first property graph model into the edges of the RDF model; a third conversion unit, configured to convert the properties of the first property graph model into the nodes and edges of the RDF model, wherein all the nodes and edges of the RDF model are represented by triple names.

[0007] As an optional example, the first conversion module further includes: a fourth conversion unit, configured to convert the relationships with properties in the first property graph model into virtual nodes of the RDF model.

[0008] As an optional example, the mapping module includes: an acquisition unit, configured to acquire the entities and the intents from the search query sentence through Neuro-Linguistic Programming (NLP) technology; a mapping unit, configured to map the entities and the intents onto the nodes of the RDF model to obtain the entity mapping tags and the intent mapping tags.

[0009] As an optional example, the construction module includes: a marking unit, configured to mark target entity nodes and target intent nodes in the RDF model according to the entity mapping tags and the intent mapping tags to obtain target nodes; a searching unit, configured to search for subgraphs containing the target nodes in the RDF model to obtain target subgraphs; a filtering unit, configured to obtain a target query graph model by filtering the target subgraphs, wherein the target query graph model includes target entity nodes and target intent nodes.

[0010] As an optional example, the above screening unit includes: a processing subunit, configured to use the three-segment names of all points in the above target subgraph as the first phrase; a conversion subunit, configured to convert the above search query sentence into a second phrase; a calculation subunit, configured to calculate the similarity coefficient between the above first phrase and the above second phrase; and a determination subunit, configured to determine the above target subgraph whose above similarity coefficient is greater than or equal to a threshold as the target query graph model.

[0011] As an optional example, it is characterized in that the above construction module further includes: a fifth conversion unit, configured to convert the target intent point of the above target query graph model into an entity of the above target attribute graph model; a sixth conversion unit, configured to convert the target entity point and the corresponding edge of the above target query graph model into an attribute of the above target attribute graph model; and a seventh conversion unit, configured to convert the edge of the above target query graph model into a relationship of the above target attribute graph model.

[0012] According to another aspect of the embodiments of the present invention, there is also provided a storage medium, in which a computer program is stored, and wherein, when the computer program is run by a processor, it executes the above query graph construction method.

[0013] According to another aspect of the embodiments of the present invention, there is also provided an electronic device, including a memory and a processor, wherein a computer program is stored in the above memory, and the above processor is configured to execute the above query graph construction method through the above computer program.

[0014] In the process that the above video multi-modal classification method of the present application can be used for knowledge-enhanced retrieval of information retrieval technology, in the embodiments of the present invention, a first attribute graph model and a search query sentence are acquired, wherein the above search query sentence is used to search for search results in the above first attribute graph model; the above first attribute graph model is converted into a Resource Description Framework (RDF) model; the entities and intents of the above search query sentence are mapped into the above RDF model to obtain entity mapping labels and intent mapping labels; a target query graph model is constructed from the above RDF model, the above entity mapping labels, and the above intent mapping labels; and the above target query graph model is converted into a target attribute graph model, wherein the above target attribute graph model is the search result corresponding to the above search query sentence. Since in the above method, by converting the first attribute graph model into an RDF model, constructing a target query graph model from the RDF model according to the search query sentence, and finally converting the target query graph model into a target attribute graph model to obtain the search result corresponding to the search query sentence, the purpose of conveniently applying existing graph algorithms, being easy to implement, and ensuring good effects is achieved, and further the technical problem that the method of separately processing and then fusing attributes in the RDF model is complex and error-prone is solved. Description of the Drawings

[0015] The accompanying drawings described herein are used to provide a further understanding of the present invention and constitute a part of this application. The schematic embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation to the present invention. In the drawings:

[0016] Figure 1 is a flowchart of an optional query graph construction method according to an embodiment of the present invention;

[0017] Figure 2 is a first property graph model diagram before conversion of an optional query graph construction method according to an embodiment of the present invention;

[0018] Figure 3 is a Resource Description Framework model diagram after conversion of an optional query graph construction method according to an embodiment of the present invention;

[0019] Figure 4 is a target query graph model diagram of an optional query graph construction method according to an embodiment of the present invention;

[0020] Figure 5 is a target property graph model diagram of an optional query graph construction method according to an embodiment of the present invention;

[0021] Figure 6 is a schematic structural diagram of an optional query graph construction apparatus according to an embodiment of the present invention;

[0022] Figure 7 is a schematic diagram of an optional electronic device according to an embodiment of the present invention. Detailed Embodiments

[0023] In order to enable those skilled in the art of this technology to better understand the solutions of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without making creative efforts shall fall within the scope of protection of the present invention.

[0024] It should be noted that the terms "first", "second", etc. in the description, claims and above-mentioned drawings of the present invention are used to distinguish similar objects, and do not necessarily have to be used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged under appropriate circumstances, so that the embodiments of the present invention described here can be implemented in an order other than those illustrated or described here. In addition, the terms "comprising" and "having" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device comprising a series of steps or units does not necessarily have to be limited to those steps or units clearly listed, but may include other steps or units not clearly listed or inherent to these processes, methods, products or devices.

[0025] According to a first aspect of an embodiment of the present invention, there is provided a query graph construction method. Optionally, as Figure 1 shown, the above method includes:

[0026] S102, obtaining a first attribute graph model and a search query sentence, where the search query sentence is used to search for search results in the first attribute graph model;

[0027] S104, converting the first attribute graph model into a Resource Description Framework (RDF) model;

[0028] S106, mapping the entities and intents of the search query sentence into the Resource Description Framework model to obtain entity mapping labels and intent mapping labels;

[0029] S108, constructing a target query graph model from the Resource Description Framework model, entity mapping labels and intent mapping labels in the Resource Description Framework model;

[0030] S110, converting the target query graph model into a target attribute graph model, where the target attribute graph model is the search result corresponding to the search query sentence.

[0031] Optionally, in this embodiment, the first attribute graph model is a knowledge graph model, which represents the graph by entities, relationships, attributes, and labels. The commonly used query languages are Cypher and Gremlin. The Resource Description Framework (RDF) model is another knowledge graph model, which represents the graph by nodes and edges and is usually stored in the form of "triples" (node - edge - node). The commonly used query language is SPARQL. A search query sentence is a question used to search in the first attribute graph, such as "What is Zhang San's community address?" The target attribute graph model is the search result corresponding to the search query sentence. The intention is the main purpose in the search query sentence. Usually, a search query sentence has one intention. In a complex query sentence, there can be multiple intentions. An entity is a restrictive condition in the search query sentence. Usually, a search query sentence has multiple entities. For example, in the search query sentence "What is Zhang San's community address?", the intention is the main purpose "community address", and the entity is the restrictive condition "Zhang San". The target query graph model is the corresponding search result constructed in the RDF model according to the search query sentence and belongs to a part of the RDF model. The target query graph model and the RDF model are a kind of knowledge graph model.

[0032] Optionally, in this embodiment, obtain a search query sentence and a first attribute graph model of the search object for searching. Convert the first attribute graph model into an RDF model according to certain rules. After conversion, the relationship in the first attribute graph model maintains its original direction. Because the RDF model has a simple structure, it is convenient to run various graph algorithms and better implement graph search. According to the entities and intentions in the search query sentence, map to obtain the entity mapping label and intention mapping label in the RDF model. Construct a target query graph model in the RDF model according to the entity mapping label and intention mapping label. The target query graph model is the search result in the form of the RDF model corresponding to the search query sentence. Convert the target query graph model into a target attribute graph model according to certain rules to obtain the search result of the knowledge graph model in the form of an attribute graph corresponding to the search query sentence. The conversion between ontology graphs can conveniently apply existing graph algorithms, which is easy to implement and ensures good results.

[0033] Optionally, in this embodiment, by converting the first attribute graph model into an RDF model, constructing a target query graph model from the RDF model according to the search query sentence, and finally converting the target query graph model into a target attribute graph model, the search result corresponding to the search query sentence is obtained, thereby achieving the purpose of conveniently applying existing graph algorithms, being easy to implement, and ensuring good results, and further solving the technical problem that the method of separately processing and then fusing attributes in the RDF model is complex and error - prone.

[0034] As an optional example, converting the first attribute graph model into an RDF model includes;

[0035] Convert the entities of the first property graph model into nodes of the Resource Description Framework (RDF) model;

[0036] Convert the relationships of the first property graph model into edges of the RDF model;

[0037] Convert the properties of the first property graph model into nodes and edges of the RDF model, where all nodes and edges of the RDF model are represented by three-part names.

[0038] Optionally, in this embodiment, the first property graph model includes entities, relationships, and properties, and the RDF model includes nodes and edges. Convert the entities of the first property graph model into nodes of the RDF model, convert the relationships of the first property graph model into edges of the RDF model, convert one property of the first property graph model into one node connected to one edge, and represent all nodes and edges by three-part names. The three-part name is kind-type-property. For example, Figure 2 、 3 As shown, the entities of the first property graph model can be one or more, which are "community", "employee", and "company" respectively. The relationships can be one or more, which are "live in" and "work for" respectively. The properties can be one or more. The properties of the entity "community" are "name", "address", "property company", and "construction time". Among them, "name" is the title property of the entity "community". Convert the entity "community" of the first property graph model into a node of the RDF model and represent it by the three-part name "Entily (entity) / community, name", which is identified as the Entily kind. Convert the relationship "live in" of the first property graph model into an edge of the RDF model and represent it by the three-part name "Relation (relationship) / live in / *", which is identified as the Relation kind. The third part of its name can usually be omitted. Convert the property "address" of the entity "community" of the first property graph model into one node connected to one edge and represent it by the three-part names "Value (value) / community / address" and "Property (property) / community / address" respectively, which are identified as the Value kind and the Property kind. Finally, the RDF model is obtained.

[0039] As an optional example, the above method further includes:

[0040] Convert the relationships with properties in the first property graph model into virtual nodes of the RDF model.

[0041] Optionally, in this embodiment, the relationships of the first property graph model can carry properties. For example, Figure 2As shown, the relationship "reside" has the attributes "start: 2010" and "end: 2021". Replace the relationship "reside" with the attribute "start: 2010" in the first attribute graph model with a virtual point in the Resource Description Framework model, and use a three - part name to represent it as "Relation / reside / start", identified as the Relation type.

[0042] As an optional example, map the entities and intents of the search query sentence to the Resource Description Framework model, and the obtained entity mapping labels and intent mapping labels include:

[0043] Obtain entities and intents from the search query sentence through Neuro - Linguistic Programming techniques;

[0044] Map the entities and intents to the points in the Resource Description Framework model to obtain entity mapping labels and intent mapping labels.

[0045] Optionally, in this embodiment, Neuro - Linguistic Programming techniques are a process of influencing one's own and others' physical and mental states through language, or others influencing oneself through language, with mutual influence. Entities "Zhang San" and intent "community address" can be obtained from the search query sentence "What is Zhang San's community address" through Neuro - Linguistic Programming techniques. Map the entities and intents to the points in the Resource Description Framework model to obtain the entity mapping label "Entity / staff / name" and the intent mapping label "Value / community / address".

[0046] As an optional example, construct a target query graph model from the Resource Description Framework model, entity mapping labels, and intent mapping labels in the Resource Description Framework model, including:

[0047] Mark the target entity point and target intent point in the Resource Description Framework model according to the entity mapping label and intent mapping label to obtain the target points;

[0048] Find the sub - graph containing the target points in the Resource Description Framework model to obtain the target sub - graph;

[0049] Obtain the target query graph model by filtering the target sub - graph, where the target query graph model includes the target entity point and the target intent point.

[0050] Optionally, in this embodiment, according to the entity mapping tag "Entity / Employee / Name" and the intent mapping tag "Value / Community / Address", the corresponding target entity point "Entity / Employee / Name" and target intent point "Value / Community / Address" are marked in the Resource Description Framework model. A target subgraph containing the target entity point "Entity / Employee / Name" and the target intent point "Value / Community / Address" is searched for in the Resource Description Framework model as a candidate target query graph model, where the marked target points must be on the target subgraph, and the unmarked target points may be on the target subgraph. The target subgraph should contain as few unmarked target points as possible, and the most suitable target subgraph is determined as the target query graph model through screening.

[0051] As an optional example, obtaining the target query graph model by screening the target subgraph includes:

[0052] Taking the three-segment names of all points in the target subgraph as the first phrase;

[0053] Converting the search query into a second phrase;

[0054] Calculating the similarity coefficient between the first phrase and the second phrase;

[0055] Determining the target subgraph with a similarity coefficient greater than or equal to the threshold as the target query graph model.

[0056] Optionally, in this embodiment, taking the three-segment names of all points in the target subgraph as the first phrase and the search query as the second phrase, calculating the similarity coefficient between the first phrase and the second phrase. For example, the similarity coefficient between the first phrase and the second phrase of the target subgraph is 0.9, and the threshold is set to 0.85. At this time, the similarity coefficient 0.9 is greater than the threshold 0.85, and the target subgraph is determined as the target query graph model.

[0057] As an optional example, the above method further includes:

[0058] Converting the target intent point of the target query graph model into an entity of the target attribute graph model;

[0059] Converting the target entity point and the corresponding edges of the target query graph model into attributes of the target attribute graph model;

[0060] Converting the edges of the target query graph model into relationships of the target attribute graph model.

[0061] Optionally, in this embodiment, converting the target query graph model into a target attribute graph model, such as Figure 4 、 5As shown, the search query sentence is "employees of a certain company living in a certain district of a certain city". The target intent point "Enyily / employee / name" of the target query graph model is converted into the entity "employee" and the title attribute "name" of the target attribute graph model. The target entity point "Value / community / address" and the corresponding edge "Property / community / address" of the target query graph model are converted into the attribute "address: Chaoyang, Beijing" of the target attribute graph model. The edge "Relation / live / *" of the target query graph model is converted into the relationship "live" of the target attribute graph model. Finally, the target attribute graph model is obtained.

[0062] Optionally, an example is combined for illustration. The present invention relates to a method for constructing a query graph. Through structural mapping conversion, a part of the structural information of the first attribute graph model (source structure) is converted into points and edges of the Resource Description Framework model (target structure), and the obtained Resource Description Framework model is lossless with respect to the source structural information. Apply graph algorithms on the Resource Description Framework model to construct the target query graph model. Finally, perform reverse conversion to obtain the target attribute graph model.

[0063] The first step: Ontology graph conversion:

[0064] 1. Define business title attributes. According to the business scenario, specify an attribute of an entity as the title attribute, and this attribute occupies the original entity after conversion. For example, for the employee entity, there are attributes such as name, gender, age, ID number, etc. The graph search query sentence can be "How old is Zhang San this year". From a business perspective, the name can best represent the logical meaning of this entity and can be selected as the title attribute. For the ID number, although it can uniquely identify the entity, it has less business relevance than the name, so the ID number will not be preferentially selected as the title attribute.

[0065] 2. Convert the first attribute graph model to the Resource Description Framework model. The entities of the first attribute graph model are mapped to the points of the Resource Description Framework model, the relationships of the first attribute graph model are mapped to the edges of the Resource Description Framework model, and an attribute on the first attribute graph model is mapped to one point and one edge of the Resource Description Framework model. The points and edges of the Resource Description Framework model are represented by three-segment names. The 1st, 2nd, and 3rd of the three-segment names can be called category, type, and attribute respectively. The type corresponds to the entity and relationship types of the attribute graph, and the attribute corresponds to the attributes of the attribute graph. 'Category' is a classification one level higher than 'type'. There are four categories in the three-segment name:

[0066] 1) Entity / entity type / title attribute: The point converted from the title attribute, identified as the Entity category;

[0067] 2) Value / entity or relationship type / attribute name: The points converted from other attributes except the title attribute, identified as the Value category;

[0068] 3) Relation / Relationship type / *: The edge converted from the relationship, identified as the Relation class. The third segment is usually ignored and is marked with * here;

[0069] 4) Property / Entity or relationship type / Property name: The edge converted from the property, identified as the Property type.

[0070] Among them, after conversion, the relationship maintains its original direction, and the property can be converted into an undirected edge or, according to business requirements, be given a direction.

[0071] 3. Convert the relationships with properties in the first property graph model to virtual nodes in the Resource Description Framework model.

[0072] An example of ontology graph conversion is as Figure 2 、 3 shown. Figure 2 is the first property graph model diagram before conversion, Figure 3 is the Resource Description Framework model diagram after conversion.

[0073] The second step: Identify entities and intents from the search query sentence through NLP (Natural Language Processing) technology and map them to the points in the converted Resource Description Framework model to obtain entity mapping labels and intent mapping labels. For example:

[0074] Search query sentence: The community address of Zhang San;

[0075] Entity: (Zhang San, type: person's name);

[0076] Intent: Community address;

[0077] Entity type - person's name, mapped to the point in the converted Resource Description Framework model to obtain the entity mapping label Entity / Staff / Name;

[0078] Intent type - community address, mapped to the point in the converted Resource Description Framework model to obtain the intent mapping label Value / Community / Address.

[0079] The third step: Target query graph construction:

[0080] 1. In the Resource Description Framework model, mark the target entity points and target intent points. There are usually multiple target entity points, and usually one target intent point. There may also be multiple target intent points in complex query sentences. The marked target entity points are attached with entity values. For example, if a person's name entity is recognized, the point marking information is: (Target entity point, Entity / Staff / Name, Zhang San). The target intent point is the target point to be queried, and the value is unknown. The marking information is: (Target intent point, Value / Community / Address);

[0081] 2. Find the subgraphs that contain the intention points and entity points, and the subgraph search satisfies the following:

[0082] a) The points marked in the first step must be in the subgraph;

[0083] b) The unmarked points can also be in the subgraph;

[0084] c) The subgraph should contain as few unmarked points as possible;

[0085] d) There can be multiple candidates for the subgraph.

[0086] Examples of available methods for subgraph search:

[0087] a) Steiner tree, ignoring the relationship direction of the Resource Description Framework model, running the Steiner tree algorithm on an undirected graph, and the obtained tree structure can be used as the target query graph model.

[0088] b) For each pair of marked points, find the shortest path, and the subgraph after all paths are connected can be used as the target query graph model.

[0089] c) Breadth-first traversal, starting from a marked point, performing breadth-first traversal outward (i.e., traversing 1 hop first, then 2 hops,... until the maximum hop count threshold), obtaining paths. If there are unvisited marked points on the path, branch from that point and continue breadth-first traversal until all marked points are visited. The obtained traversal paths can be used as the target query graph.

[0090] 3. Subgraph screening. According to business requirements, specify screening rules to select the target query graph models with high probabilities.

[0091] Example of screening method: Take the three-segment names of all points in the target query graph model as the first phrase, and the search query sentence as the second phrase, and calculate the Jaccard similarity coefficient between the first phrase and the second phrase as the screening score. Retain the target query graph models with scores higher than a certain threshold.

[0092] The first phrase can select words from (point value + three-segment relationship name):

[0093] A = ["a certain district in a certain city", "community", "address", "live", "work", "a certain company"]

[0094] The second phrase:

[0095] B = ["a certain company", "live in", "a certain district in a certain city", "employee"]

[0096] Calculate the Jaccard similarity coefficient between the above two phrases, which is the intersection-over-union ratio: Jaccard score = count(A ∩ B) / count(A ∪ B).

[0097] Step 4: Convert the target query graph model into a target property graph model. Centering on the nodes of the Entity type, collect the nodes of the Value type connected through the Property type, and summarize them into the entities of the target property graph model, while retaining the marking information.

[0098] Search query sentence: Employees of a certain company living in a certain district of a certain city.

[0099] The target query graph model is as Figure 4 shown, and the conversion to the target property graph model is as Figure 5 shown.

[0100] The target property graph model can be easily converted into various query statements and then sent to the graph database for query. For example, it can be represented by Neo4j-cypher as:

[0101] MATCH (n1:Community {address: ’a certain district of a certain city’})-[lives]-(n2:Employee)-[works]-(n3:Company {name: ’a certain company’}) RETURN n2.

[0102] It should be noted that for the foregoing method embodiments, for the sake of simple description, they are all expressed as a series of action combinations. However, those skilled in the art should know that the present invention is not limited by the described action sequence, because according to the present invention, certain steps can be performed in other sequences or simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily essential to the present invention.

[0103] According to another aspect of the embodiments of the present application, there is also provided a query graph construction device, as Figure 6 shown, including:

[0104] An acquisition module 602, configured to acquire a first property graph model and a search query sentence, where the search query sentence is used to search for a search result in the first property graph model;

[0105] A first conversion module 604, configured to convert the first property graph model into a Resource Description Framework (RDF) model;

[0106] A mapping module 606, configured to map the entities and intents of the search query sentence to the Resource Description Framework model to obtain entity mapping labels and intent mapping labels;

[0107] A construction module 608, configured to construct a target query graph model from the Resource Description Framework model according to the entity mapping labels and the intent mapping labels;

[0108] The second conversion module 610 is used to convert the target query graph model into a target attribute graph model, where the target attribute graph model is the search result corresponding to the search query sentence.

[0109] Optionally, in this embodiment, the first attribute graph model is a knowledge graph model, which represents the graph by entities, relationships, attributes, and labels. The commonly used query languages are Cypher and Gremlin. The Resource Description Framework (RDF) model is another knowledge graph model, which represents the graph by nodes and edges and is usually stored in the form of "triples" (node - edge - node). The commonly used query language is SPARQL. The search query sentence is a question used to search in the first attribute graph, such as "What is Zhang San's community address?" The target attribute graph model is the search result corresponding to the search query sentence. The intention is the main purpose in the search query sentence. Usually, a search query sentence has one intention, and a complex query sentence may include multiple intentions. The entity is the restrictive condition in the search query sentence. Usually, a search query sentence has multiple entities. For example, in the search query sentence "What is Zhang San's community address?", the intention is the main purpose "community address", and the entity is the restrictive condition "Zhang San". The target query graph model is the corresponding search result constructed according to the search query sentence in the RDF model and belongs to a part of the RDF model. The target query graph model and the RDF model are a kind of knowledge graph model.

[0110] Optionally, in this embodiment, the search query sentence and the first attribute graph model used for searching are obtained. The first attribute graph model is converted into the RDF model according to certain rules. After conversion, the relationships in the first attribute graph model maintain their original directions because the RDF model has a simple structure, which is convenient for running various graph algorithms and better realizes graph search. According to the entities and intentions in the search query sentence, the entity mapping label and the intention mapping label are obtained in the RDF model. The target query graph model is constructed in the RDF model according to the entity mapping label and the intention mapping label. The target query graph model is the search result in the form of the RDF model corresponding to the search query sentence. The target query graph model is converted into the target attribute graph model according to certain rules to obtain the search result of the knowledge graph model in the form of an attribute graph corresponding to the search query sentence. The conversion between ontology graphs can conveniently apply existing graph algorithms, which is easy to implement and ensures good results.

[0111] Optionally, in this embodiment, by converting the first attribute graph model into the RDF model, constructing the target query graph model from the RDF model according to the search query sentence, and finally converting the target query graph model into the target attribute graph model, the search result corresponding to the search query sentence is obtained, thereby achieving the purpose of conveniently applying existing graph algorithms, being easy to implement, and ensuring good results, and further solving the technical problem that the method of separately processing and then fusing attributes in the RDF model is complex and error - prone.

[0112] As an optional example, the first conversion module includes;

[0113] A first conversion unit for converting the entities of the first property graph model into nodes of the Resource Description Framework (RDF) model;

[0114] A second conversion unit for converting the relationships of the first property graph model into edges of the RDF model;

[0115] A third conversion unit for converting the properties of the first property graph model into nodes and edges of the RDF model, wherein all the nodes and edges of the RDF model are represented by a three - part name.

[0116] Optionally, in this embodiment, the first property graph model includes entities, relationships, and properties, and the RDF model includes nodes and edges. The entities of the first property graph model are converted into nodes of the RDF model, the relationships of the first property graph model are converted into edges of the RDF model, and one property of the first property graph model is converted into one node connected to one edge, and all the nodes and edges are represented by a three - part name. The three - part name is kind - type - property. For example, Figure 2 , 3 As shown, there can be one or more entities in the first property graph model, which are "community, employee, company" respectively. There can be one or more relationships, which are "live in", "work for" respectively. There can be one or more properties. The properties of the entity "community" are "name", "address", "property company", "construction time". Among them, "name" is the title property of the entity "community". The entity "community" of the first property graph model is converted into a node of the RDF model and represented by the three - part name "Entily(entity) / community, name", and the identifier is the Entily kind. The relationship "live in" of the first property graph model is converted into an edge of the RDF model and represented by the three - part name "Relation(relationship) / live in / *", and the identifier is the Relation kind. The third part of its name can usually be omitted. The property "address" of the entity "community" of the first property graph model is converted into one node connected to one edge of the RDF model and represented by the three - part names "Value(value) / community / address" and "Property(property) / community / address" respectively, and the identifiers are the Value kind and the Property kind. Finally, the RDF model is obtained.

[0117] As an optional example, the first conversion module further includes:

[0118] A fourth conversion unit for converting the relationships with properties in the first property graph model into virtual nodes of the RDF model.

[0119] Optionally, in this embodiment, the relationships in the first attribute graph model can carry attributes. For example, Figure 2 as shown, the relationship "lives in" carries the attributes "Start: 2010" and "End: 2021". Replace the relationship "lives in" with the attribute "Start: 2010" in the first attribute graph model with a virtual point of the Resource Description Framework model, and use a three-segment name to represent it as "Relation / lives in / Start", identified as the Relation type.

[0120] As an optional example, the mapping module includes:

[0121] An acquisition unit for acquiring entities and intents from the search query sentence through neuro-linguistic programming technology;

[0122] A mapping unit for mapping the entities and intents to points of the Resource Description Framework model to obtain entity mapping labels and intent mapping labels.

[0123] Optionally, in this embodiment, neuro-linguistic programming technology is a process of influencing one's own and others' physical and mental states through language, or others influencing oneself through language. Entities "Zhang San" and intent "community address" can be obtained from the search query sentence "What is Zhang San's community address" through neuro-linguistic programming technology. Map the entities and intents to points of the Resource Description Framework model to obtain the entity mapping label "Entity / staff / name" and the intent mapping label "Value / community / address".

[0124] As an optional example, the construction module includes:

[0125] A marking unit for marking the target entity point and the target intent point in the Resource Description Framework model according to the entity mapping label and the intent mapping label to obtain the target point;

[0126] A search unit for searching for a subgraph containing the target point in the Resource Description Framework model to obtain the target subgraph;

[0127] A filtering unit for obtaining the target query graph model by filtering the target subgraph, where the target query graph model includes the target entity point and the target intent point.

[0128] Optionally, in this embodiment, according to the entity mapping label "Entity / Employee / Name" and the intent mapping label "Value / Community / Address", the corresponding target entity point "Entity / Employee / Name" and target intent point "Value / Community / Address" are marked in the Resource Description Framework model. Then, in the Resource Description Framework model, a target subgraph that contains the target entity point "Entity / Employee / Name" and the target intent point "Value / Community / Address" is searched for as a candidate target query graph model. Among them, the marked target points must be on the target subgraph, and the unmarked target points can be on the target subgraph. The target subgraph should contain as few unmarked target points as possible. The most satisfying target subgraph is obtained through screening and determined as the target query graph model.

[0129] As an optional example, the screening unit includes:

[0130] A processing subunit, configured to use the three-segment names of all points in the target subgraph as the first phrase;

[0131] A conversion subunit, configured to convert the search query sentence into a second phrase;

[0132] A calculation subunit, configured to calculate the similarity coefficient between the first phrase and the second phrase;

[0133] A determination subunit, configured to determine the target subgraph with a similarity coefficient greater than or equal to the threshold as the target query graph model.

[0134] Optionally, in this embodiment, the three-segment names of all points in the target subgraph are used as the first phrase, and the search query sentence is used as the second phrase to calculate the similarity coefficient between the first phrase and the second phrase. For example, the similarity coefficient between the first phrase and the second phrase of the target subgraph is 0.9, and the threshold is set to 0.85. At this time, the similarity coefficient 0.9 is greater than the threshold 0.85, and the target subgraph is determined as the target query graph model.

[0135] As an optional example, it is characterized in that the construction module further includes:

[0136] A fifth conversion unit, configured to convert the target intent point of the target query graph model into an entity of the target attribute graph model;

[0137] A sixth conversion unit, configured to convert the target entity point and the corresponding edge of the target query graph model into an attribute of the target attribute graph model;

[0138] A seventh conversion unit, configured to convert the edge of the target query graph model into a relationship of the target attribute graph model.

[0139] Optionally, in this embodiment, the target query graph model is converted into a target attribute graph model, as Figure 4 、 5As shown, the search query sentence is "employees of a certain company living in a certain district of a certain city". The target intent point "Enyily / employee / name" of the target query graph model is converted into the entity "employee" and the title attribute "name" of the target attribute graph model. The target entity point "Value / community / address" of the target query graph model and the corresponding edge "Property / community / address" are converted into the attribute "address: Chaoyang, Beijing" of the target attribute graph model. The edge "Relation / live / *" of the target query graph model is converted into the relationship "live" of the target attribute graph model. Finally, the target attribute graph model is obtained.

[0140] For other examples of this embodiment, please refer to the above examples and will not be elaborated here.

[0141] Figure 7 is a structural block diagram of an optional electronic device according to an embodiment of the present application, as Figure 7 shown, including a processor 702, a communication interface 704, a memory 706, and a communication bus 708. Among them, the processor 702, the communication interface 704, and the memory 706 complete mutual communication through the communication bus 708, where,

[0142] The memory 706 is used to store computer programs;

[0143] When the processor 702 is used to execute the computer program stored on the memory 706, the following steps are implemented:

[0144] Obtain a first attribute graph model and a search query sentence, where the search query sentence is used to search for search results in the first attribute graph model;

[0145] Convert the first attribute graph model into a Resource Description Framework (RDF) model;

[0146] Map the entities and intents of the search query sentence into the Resource Description Framework model to obtain entity mapping labels and intent mapping labels;

[0147] Construct a target query graph model from the Resource Description Framework model, entity mapping labels, and intent mapping labels in the Resource Description Framework model;

[0148] Convert the target query graph model into a target attribute graph model, where the target attribute graph model is the search result corresponding to the search query sentence.

[0149] Optionally, in this embodiment, the above communication bus may be a PCI (Peripheral Component Interconnect) bus, an EISA (Extended Industry Standard Architecture) bus, or the like. The communication bus may be divided into an address bus, a data bus, a control bus, etc. For the sake of convenience of representation, Figure 7 only a thick line is used to represent it in Figure 7 , but it does not mean that there is only one bus or one type of bus. The communication interface is used for communication between the above electronic device and other devices.

[0150] The memory may include a RAM and may also include a non-volatile memory, for example, at least one disk memory. Optionally, the memory may also be at least one storage device located far from the aforementioned processor.

[0151] As an example, the above memory 706 may but is not limited to include the acquisition module 602, the first conversion module 604, the mapping module 606, the construction module 608, and the second conversion module 610 in the above query graph construction device. In addition, it may also include but is not limited to other module units in the above request processing device, which will not be elaborated in this example.

[0152] The above processor may be a general-purpose processor, which may include but is not limited to: a CPU (Central Processing Unit), an NP (Network Processor), etc.; it may also be a DSP (Digital Signal Processing), an ASIC (Application Specific Integrated Circuit), an FPGA (Field-Programmable Gate Array), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.

[0153] Optionally, specific examples in this embodiment may refer to the examples described in the above embodiment, and will not be elaborated here.

[0154] Those of ordinary skill in the art can understand that Figure 7The structure shown is only illustrative. The device implementing the above query graph construction method may be a terminal device, which may be a smart phone (such as an Android phone, an iOS phone, etc.), a tablet computer, a personal digital assistant, and terminal devices such as Mobile Internet Devices (MID), PAD, etc. Figure 7 It does not limit the structure of the above electronic device. For example, the electronic device may further include more or fewer components (such as a network interface, a display device, etc.) than those shown Figure 7 in the figure, or have a different configuration from that shown Figure 7 in the figure.

[0155] Those of ordinary skill in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructing the hardware related to the terminal device through a program, and the program can be stored in a computer-readable storage medium. The storage medium may include: a flash drive, a ROM, a RAM, a magnetic disk, or an optical disc, etc.

[0156] According to another aspect of the embodiments of the present invention, there is also provided a computer-readable storage medium storing a computer program, wherein the computer program, when run by a processor, executes the steps in the above query graph construction method.

[0157] Optionally, in this embodiment, those of ordinary skill in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructing the hardware related to the terminal device through a program, and the program can be stored in a computer-readable storage medium. The storage medium may include: a flash drive, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disc, etc.

[0158] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.

[0159] If the integrated unit in the above embodiments is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in the above computer-readable storage medium. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for causing one or more computer devices (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention.

[0160] In the above embodiments of the present invention, the descriptions of the respective embodiments each have their own emphasis. For the parts not detailed in a certain embodiment, reference may be made to the relevant descriptions of other embodiments.

[0161] In several embodiments provided by the present application, it should be understood that the disclosed client can be implemented in other ways. Among them, the device embodiments described above are merely illustrative. For example, the division of the units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed coupling or direct coupling or communication connection between each other can be through some interfaces, and the indirect coupling or communication connection of the units or modules can be in an electrical or other form.

[0162] The units described as separate components may or may not be physically separated. The components displayed as units may or may not be physical units, that is, they can be located in one place or distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0163] In addition, in each embodiment of the present invention, the functional units can be integrated in a processing unit, or each unit can exist physically alone, or two or more units can be integrated in one unit. The above integrated units can be implemented in the form of hardware or in the form of software functional units.

[0164] The above are only the preferred embodiments of the present invention. It should be noted that for those of ordinary skill in the art, without departing from the principle of the present invention, several improvements and refinements can be made, and these improvements and refinements should also be regarded as the protection scope of the present invention.

Claims

1. A query graph construction method, characterized in that, Including: Obtain a first attribute graph model and a search query sentence, where the search query sentence is used to search for a search result in the first attribute graph model, and the first attribute graph model is a knowledge graph model represented by entities, relationships, attributes, and labels; Convert the first attribute graph model into a Resource Description Framework (RDF) model; Map the entities and intents of the search query sentence into the RDF model to obtain entity mapping labels and intent mapping labels; Construct a target query graph model from the RDF model, the entity mapping labels, and the intent mapping labels; Convert the target query graph model into a target attribute graph model, where the target attribute graph model is the search result corresponding to the search query sentence; Among them, the conversion of the first attribute graph model into the RDF model includes: converting the entities of the first attribute graph model into nodes of the RDF model; converting the relationships of the first attribute graph model into edges of the RDF model; converting the attributes of the first attribute graph model into nodes and edges of the RDF model, where all nodes and edges of the RDF model are represented by triple names. The method further includes: converting the relationships with attributes in the first attribute graph model into virtual nodes of the RDF model.

2. The method according to claim 1, characterized in that, The mapping of the entities and intents of the search query sentence into the RDF model to obtain entity mapping labels and intent mapping labels includes: Obtain the entities and the intents from the search query sentence through Neuro-Linguistic Programming (NLP) technology; Map the entities and the intents to the nodes of the RDF model to obtain the entity mapping labels and the intent mapping labels.

3. The method according to claim 1, wherein The construction of the target query graph model from the RDF model, the entity mapping labels, and the intent mapping labels includes: Mark target entity nodes and target intent nodes in the RDF model according to the entity mapping labels and the intent mapping labels to obtain target nodes; Find a subgraph containing the target nodes in the RDF model to obtain a target subgraph; Obtain the target query graph model by filtering the target subgraph, where the target query graph model includes target entity nodes and target intent nodes.

4. The method according to claim 3, wherein The obtaining of the target query graph model by filtering the target subgraph includes: Taking the triple names of all nodes in the target subgraph as a first phrase; Converting the search query sentence into a second phrase; Calculating the similarity coefficient between the first phrase and the second phrase; Determining the target subgraph with the similarity coefficient greater than or equal to a threshold as the target query graph model.

5. The method according to claim 3, characterized in that, The method further includes: Converting the target intent nodes of the target query graph model into entities of the target attribute graph model; Converting the target entity nodes and the corresponding edges of the target query graph model into attributes of the target attribute graph model; Converting the edges of the target query graph model into relationships of the target attribute graph model.

6. A query graph construction device, characterized in that, Including: An acquisition module, configured to acquire a first attribute graph model and a search query sentence, where the search query sentence is used to search for a search result in the first attribute graph model, and the first attribute graph model is a knowledge graph model represented by entities, relationships, attributes, and labels; A first conversion module, configured to convert the first attribute graph model into a Resource Description Framework (RDF) model; A mapping module, configured to map the entities and intents of the search query sentence into the RDF model to obtain entity mapping labels and intent mapping labels; A construction module, configured to construct a target query graph model from the RDF model according to the RDF model, the entity mapping labels, and the intent mapping labels; A second conversion module, configured to convert the target query graph model into a target attribute graph model, where the target attribute graph model is the search result corresponding to the search query sentence; Wherein, the conversion of the first attribute graph model into the RDF model includes: converting the entities of the first attribute graph model into the nodes of the RDF model; converting the relationships of the first attribute graph model into the edges of the RDF model; converting the attributes of the first attribute graph model into the nodes and edges of the RDF model, where all the nodes and edges of the RDF model are represented by triple names, and the method further includes: converting the relationships with attributes in the first attribute graph model into the virtual nodes of the RDF model.

7. A computer-readable storage medium storing a computer program, characterized in that, The computer program, when run by a processor, executes the method according to any one of claims 1 to 5.

8. An electronic device, comprising a memory and a processor, characterized in that A computer program is stored in the memory, and the processor is configured to execute the method according to any one of claims 1 to 5 through the computer program.

Citation Information

Patent Citations

  • Information acquisition method and device, electronic equipment and computer readable storage medium

    CN111368049A