Knowledge Graph Update Method, Device, and Computer Equipment

By generating and executing graph query statements, obtaining target entity information and relationship information, and generating target knowledge graphs, the problem of cumbersome and time-consuming update process in the existing technology is solved, and efficient and accurate knowledge graph updates are achieved.

CN114328965BActive Publication Date: 2025-06-27LENOVO (BEIJING) LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111655790.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-30
Publication Date
2025-06-27
Estimated Expiration
2041-12-30

AI Technical Summary

Technical Problem

When updating the knowledge graph, the process of the prior art is cumbersome, time-consuming and labor-intensive, the update efficiency is inefficient and resources are wasted.

Method used

By obtaining the original knowledge graph, target ontology file and configuration rule file, using the graph query template to generate graph query statements, executing the query statement to obtain target entity information and relationship information, and generating the target knowledge graph.

Benefits of technology

It realizes the efficiency and accuracy of knowledge graph updates, reduces the consumption of manpower and time resources, and improves the robustness and agility of updates.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114328965B_ABST
    Figure CN114328965B_ABST
Patent Text Reader

Abstract

This application proposes a knowledge graph update method, apparatus, and computer device. This application establishes mappings of classes and relationships between ontologies at the ontology level, and configures a configuration rule file that at least includes entity category mappings and relationship mappings between the original ontology file and the target ontology file of the original knowledge graph, reducing the complexity of rule writing and enhancing the robustness of the graph update function. And according to the image query template, at least based on the content of the configuration rule file, generate graph query statements to query the original knowledge graph. Based on the graph query results, accurately obtain the target entity information and target relationship information under the target ontology, and generate the target knowledge graph in this field, realizing the manipulation of data from the ontology level, without the need for professional technicians to write the code of the target knowledge graph, saving labor costs, shortening the iteration cycle, and reducing the implementation threshold.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application mainly relates to the field of computer technology, and more specifically, to a method and apparatus for updating a knowledge graph and a computer device. Background Art

[0002] With the development and application of Internet and artificial intelligence technologies, in the face of the explosive growth of network data content, the Knowledge Graph, with its excellent semantic processing technology and open processing capabilities, has been widely used in fields such as intelligent search, intelligent question answering, information recommendation, content distribution, data analysis and mining, to display the development process and structural relationships of knowledge in various graphical ways.

[0003] Among them, a knowledge graph is usually based on data in a target domain to construct an ontology model for that target domain, that is, a semantic data model composed of classes, relationships, and attributes, and thus the creation of the knowledge graph is realized accordingly. Therefore, once the ontology model undergoes a structural change, in order to ensure that the graph data matches the ontology model, it is usually necessary to recreate the knowledge graph based on the changed ontology model.

[0004] It can be seen that the current method of updating the original knowledge graph by recreating the knowledge graph is cumbersome, time-consuming and laborious, with low update efficiency and resource waste. Summary of the Invention

[0005] In view of this, this application proposes a method for updating a knowledge graph, including:

[0006] Obtain the original knowledge graph, target ontology file, and configuration rule file of any domain; wherein, the configuration rule file at least includes entity category mapping and relationship mapping between the original ontology file of the original knowledge graph and the target ontology file;

[0007] According to the graph query template, generate a graph query statement for the original knowledge graph at least based on the configuration rule file;

[0008] Execute the graph query statement, and obtain the target entity information and target relationship information under the target ontology file according to the obtained graph query result;

[0009] Generate the target knowledge graph of the domain according to the target entity information and the target relationship information.

[0010] Optionally, the step of generating a graph query statement for the original knowledge graph according to the graph query template and at least based on the configuration rule file includes:

[0011] Retrieve the graph query template; wherein, the graph query template is configured according to the graph query language and includes a pending writing area with multiple pending query conditions; the pending query conditions are used to indicate the corresponding ontology information in the configured rule file written in the pending writing area, the ontology information includes at least the entity category mapping and the relationship mapping, and the multiple pending query conditions include at least a pending query attribute condition and a pending query relationship condition;

[0012] Obtain the target query conditions for the original knowledge graph according to the ontology information included in the configured rule file indicated by each of the multiple pending query conditions; the target query conditions include at least a target query attribute condition and a target query relationship condition,

[0013] Generate a graph query statement for the original knowledge graph by using the obtained target query conditions.

[0014] Optionally, if the multiple pending query conditions further include a duplicate removal condition and / or a query constraint condition for indicating whether the query results are to be de-duplicated, obtaining the target query conditions for the original knowledge graph according to the ontology information included in the configured rule file indicated by each of the multiple pending query conditions includes:

[0015] Obtain the target query attribute condition and the target query relationship condition for the original knowledge graph respectively according to the entity category mapping and the relationship mapping; wherein, the entity category includes at least one attribute; and,

[0016] Obtain the target duplicate removal condition for the original knowledge graph according to the duplicate removal field of the query results in the configured rule file; and / or

[0017] Obtain the target query constraint condition for the original knowledge graph according to the entity category mapping and the relationship mapping; the target query constraint condition can characterize the constraints in the attribute dimension, the entity category dimension and the relationship dimension.

[0018] Optionally, obtaining the target query constraint condition for the original knowledge graph according to the entity category mapping and the relationship mapping includes:

[0019] Obtain a first constraint condition and a second constraint condition according to the entity category mapping; wherein, the first constraint condition is used to indicate the corresponding entity names of the entities in different classes queried in the original ontology file; the second constraint condition is used to indicate that the attributes of each class in the target ontology file come from the first class with this attribute in the original ontology file;

[0020] Obtain a third constraint condition according to the inter-class relationship in the relationship mapping; the third constraint condition is used to indicate querying entity pairs with the inter-class relationship.

[0021] The first constraint condition, the second constraint condition, and the third constraint condition constitute a target query constraint condition for the original knowledge graph.

[0022] Optionally, the graph query statement includes an entity query statement and a relationship query statement; when executing the graph query statement, according to the obtained graph query result, obtain the target entity information and target relationship information under the target ontology file, including:

[0023] Execute the entity query statement to obtain an entity query result.

[0024] According to the entity query result, obtain the target entity information under the target ontology file.

[0025] Execute the relationship query statement to obtain a relationship query result.

[0026] According to the relationship query result and the target entity information, obtain the target relationship information under the target ontology file.

[0027] Optionally, in the process of obtaining the target entity information under the target ontology file according to the entity query result, it further includes:

[0028] According to the entity query result, obtain the entity key data between the target knowledge graph to be generated and the original knowledge graph; the entity key data includes the entity mapping between the target knowledge graph and the original knowledge graph.

[0029] Cache the entity key data and the target entity information.

[0030] The obtaining of the target relationship information under the target ontology file according to the relationship query result and the target entity information includes:

[0031] Retrieve the entity key data and the target entity information.

[0032] According to the relationship query result, the target entity information, and the entity key data, generate the target relationship information under the target ontology file.

[0033] Optionally, the obtaining of the target relationship information under the target ontology text according to the relationship query result and the target entity information further includes:

[0034] If the relationship query result indicates that there is an entity pair in the original knowledge graph that meets the target query constraint conditions, obtain the first relationship information between the entity pair based on the corresponding entity mapping in the cached key data of the entity;

[0035] If the relationship query result indicates that the second relationship in the target ontology file depends on the entity category in the original knowledge graph, map the entities in the dependent entity category to the corresponding second relationship that is dependent;

[0036] Use the target query constraint conditions to obtain the second relationship information between the entity pairs after mapping processing;

[0037] The obtained first relationship information and the second relationship information constitute the target relationship information under the target ontology text.

[0038] Optionally, generating a graph query statement for the original knowledge graph according to the graph query template, at least based on the configuration rule file, includes:

[0039] Obtain the ontology identification information in the original ontology file and / or the target text file;

[0040] According to the graph query template, generate a graph query statement for the original knowledge graph based on the entity category mapping, the relationship mapping, and the ontology identification information;

[0041] And / or, the generation method of the configuration rule file includes:

[0042] In response to a structure update request of the original ontology file in any field, generate a configuration rule file based on the original ontology file and the updated target ontology file;

[0043] Send the configuration rule file to the server or a specified terminal device.

[0044] This application also proposes a knowledge graph update device, including:

[0045] A data acquisition module, configured to acquire the original knowledge graph, the target ontology file, and the configuration rule file in any field; wherein, the configuration rule file at least includes an entity category mapping and a relationship mapping between the original ontology file of the original knowledge graph and the target ontology file;

[0046] A graph query statement generation module, configured to generate a graph query statement for the original knowledge graph according to the graph query template, at least based on the configuration rule file;

[0047] A target knowledge data acquisition module, configured to execute the graph query statement, and obtain target entity information and target relationship information under the target ontology file according to the obtained graph query result;

[0048] A target knowledge graph generation module, configured to generate a target knowledge graph of the domain according to the target entity information and the target relationship information.

[0049] The present application also provides a computer device, including:

[0050] A communication interface;

[0051] A memory, configured to store a program for implementing the knowledge graph update method as described above;

[0052] A processor, configured to load and execute the program stored in the memory to implement the knowledge graph update method as described above.

[0053] It can be seen that the present application provides a knowledge graph update method, device and computer device. In the scenario where the structure of the ontology file in any domain changes and the original knowledge graph needs to be updated, the present application will obtain a configuration rule file that at least includes the entity category mapping and relationship mapping between the original ontology file and the target ontology file of the original knowledge graph. Compared with writing business rules from the data level, the present application establishes the mapping of classes and relationships between ontologies from the ontology level, reduces the complexity of rule writing, and enhances the robustness of the graph update function. Then, according to the image query template, at least based on the content of the configuration rule file, a graph query statement will be generated to query the original knowledge graph. According to the graph query result, the target entity information and target relationship information under the target ontology will be accurately obtained, and the target knowledge graph of the domain will be generated, realizing the manipulation of data from the ontology level, without writing the code of the target knowledge graph, shortening the iteration cycle, and reducing the implementation threshold. BRIEF DESCRIPTION OF THE DRAWINGS

[0054] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings required for the description of the embodiments or the prior art. Obviously, the drawings in the following description are only the embodiments of the present application. For those of ordinary skill in the art, other drawings can be obtained according to the provided drawings without creative efforts.

[0055] Figure 1 A schematic hardware structure diagram of an optional example of a computer device applicable to the knowledge graph update method proposed in the present application;

[0056] Figure 2 A schematic system architecture diagram of an optional application scenario applicable to the knowledge graph update method proposed in the present application;

[0057] Figure 3 A schematic flowchart of an alternative example of the knowledge graph update method proposed in this application;

[0058] Figure 4 A schematic flowchart of another alternative example of the knowledge graph update method proposed in this application;

[0059] Figure 5 A schematic flowchart of another alternative example of the knowledge graph update method proposed in this application;

[0060] Figure 6 A schematic structural diagram of an alternative example of the knowledge graph update device proposed in this application. Detailed implementation manners

[0061] Regarding the content described in the background art section, in the scenario where the structure of the ontology file in any field changes and the original knowledge graph needs to be updated, it is not desired to consume a large amount of human and time resources to recreate the knowledge graph under the new ontology. Instead, business rules are proposed to be written to achieve the transformation of the graph, that is, by adding logical rules, directly changing the entities and relationships in the original knowledge graph. However, this update method is only applicable when the ontology changes slightly. Compared with recreating the knowledge graph, it can reduce human and time resources. However, when the ontology changes greatly, the complexity of the required business rules will increase exponentially, resulting in the cost of writing business rules being higher than recreating the knowledge graph.

[0062] In order to further improve the above knowledge graph update method, so that in the scenario where the ontology in any field changes slightly or greatly, the knowledge graph after the ontology structure change can be obtained quickly and accurately. Therefore, this application proposes to analyze the change situation of the ontology file, map the ontology to describe the relationship and transformation between the original knowledge graph and the required target knowledge graph at the concept level, and accurately implement the changes at the ontology concept level to each entity and each relationship at the data level, ensuring the accuracy of the conversion from the original knowledge graph to the target knowledge graph.

[0063] Among them, for the structural change of the ontology file, this application can adopt a simple syntax structure and ontology mapping method to pre-write a configuration rule file for recording the change situation of the ontology file, so that the content of the configuration rule file is much less than directly writing the complete business rule content, reducing the human and time cost consumption of writing the configuration rule file and having stronger readability.

[0064] Moreover, for the graph query statements used in the process of knowledge graph transformation, this application can call a preset general graph query template and automatically fill in the corresponding empty slots in the graph query template according to the content included in the preset configuration rule file to automatically generate the required image query statements. Compared with the implementation method of manually writing graph query statements for the original knowledge graph in the current field, this implementation method of using a general graph query template in this application to automatically generate graph query statements by the execution program only needs to focus on the mapping rules and is independent of specific scenario projects and services. It has better generality and realizes the transformation of the entire data layer with zero code, greatly reducing the human and time resources consumed by manually writing a large number of graph query statements, avoiding the problem of update failure caused by errors in manually writing graph query statements, and improving the update efficiency and reliability.

[0065] Next, the technical solutions in the embodiments of the present application will be clearly and completely described with reference to the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present application.

[0066] Refer to Figure 1 , which is a schematic hardware structure diagram of an optional example of a computer device applicable to the knowledge graph update method proposed in this application. In practical applications, the computer device can be a terminal device with data processing capabilities or a server. Among them, the terminal device can include but is not limited to: electronic devices such as smart phones, tablet computers, robots, and desktop computers; the server can be an independent physical server, a service cluster composed of multiple physical servers, or a cloud server supporting cloud computing services. This application does not limit the product type of the computer device and can flexibly select the product of the computer device for executing the knowledge graph update method according to the scenario requirements.

[0067] As Figure 1 shown, the computer device can include but is not limited to: a communication interface 11, a memory 12, and a processor 13, where:

[0068] The number of the communication interface 11, the memory 12, and the processor 13 can be at least one, and the number and type of these components can be determined according to the functional requirements of the computer device for the application scenario. Usually, the communication interface 11, the memory 12, and the processor 13 can be connected to a communication bus to realize data communication with each other. This application does not limit the specific connection method of each component and can be determined according to the situation.

[0069] The communication interface 11 may include a data interface of a communication module capable of implementing data interaction using a wireless communication network. The communication module may include, but is not limited to, a WIFI module, a 5G / 6G (Fifth Generation Mobile Communication Network / Sixth Generation Mobile Communication Network) module, a GPRS module, a GSM module, etc.; so that the computer device can implement a communication connection with other devices through an appropriate communication module according to application requirements, and realize data interaction between different devices; of course, the communication interface 11 may also include interfaces such as a USB interface and a serial / parallel port for implementing data interaction between internal components of the computing device, which will not be elaborated in this embodiment of the present application.

[0070] The memory 12 can be used to store a program for implementing the knowledge graph update method proposed in this application. According to needs, it can also store intermediate parameters or update result data generated during the knowledge graph update process, data obtained from other devices, etc. It can be understood that, as Figure 2 shown in the schematic diagram of the application scenario system architecture, these data can also be sent to an independent database for storage, and this application does not limit the data storage implementation method. The processor 13 can load and execute the program stored in the memory 12 to implement the knowledge graph update method proposed in this application. The implementation process can refer to the description of the corresponding method embodiment below, which will not be elaborated in this embodiment.

[0071] In the embodiment of the present application, the memory 12 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device or other volatile solid-state storage devices. The processor 13 can be a central processing unit (CPU), an application-specific integrated circuit (ASIC), a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, etc. This application does not limit the types of each memory 12 and each processor 13 required by the computer device, and it can be determined according to the situation.

[0072] It should be understood that Figure 1 the structure of the computer device shown does not constitute a limitation to the computer device in the embodiment of the present application. In practical applications, the computer device may include more components than Figure 1 shown, or combine some components, such as a display module, an antenna, a power module, etc., which can be determined according to functional requirements and will not be listed one by one in this application.

[0073] Refer to Figure 3, which is a schematic flowchart of an optional example of the knowledge graph update method proposed in this application. In practical applications, the knowledge graph update method can be executed by a server or a terminal device. In some application scenarios, it can also be implemented in cooperation with the server and the terminal device. As Figure 3 shown, the method may include:

[0074] Step S31, obtaining the original knowledge graph, the target ontology file, and the configuration rule file of any domain;

[0075] Combined with the above description of the technical solution of this application, when the business planning, application, etc. in any domain change, causing the structural change of its original ontology file (i.e., the ontology model), such as the change of entity categories, category attributes, entity relationships, etc., after obtaining the target ontology file with a new structure, in order to obtain a new knowledge graph and better provide business services in this domain, business personnel, developers, etc. can write a configuration rule file based on the concept layer mapping relationship between the new and old ontologies according to the requirements of the rule file writing, and the implementation method is not limited.

[0076] Since the knowledge graph is composed of entities and relationships, the transformed target knowledge graph needs to be generated in the order of entities and relationships. Therefore, when writing the configuration rule file, this application can define the mapping of entity categories and relationships between the new and old ontologies without considering how the classes and relationships in the original ontology file are transformed, such as defining the mapping of entity categories and relationships between the new and old ontologies based on the known structural changes. In this way, in the process of transforming the original knowledge graph into the target original knowledge graph, the entities and relationships required to form the target knowledge graph can be traced back based on this mapping.

[0077] Therefore, the pre-written configuration rule file of this application can at least include: the entity category mapping and relationship mapping between the original ontology file and the target ontology file of the original knowledge graph. The content of each of these two mappings can be determined based on the changed content of the ontology in this domain, and the embodiments of this application do not elaborate on this here. It should be noted that the configuration rule file may also include other content determined based on business requirements, etc. This application does not limit the content and its representation form of the configuration rule file.

[0078] Combined with the above description of the technical solution of the present application, the above entity category mapping, that is, the class mapping between the new and old ontologies, and the relationship mapping between the new and old ontologies can include constraints in multiple dimensions, to illustrate whether there are corresponding existences of the classes and relationships in the target ontology file in the original ontology file, and what the forms of existence are, so that the graph query statements generated accordingly later can accurately locate the entities and relationships in the data layer, and realize the manipulation of data from the ontology level. Therefore, the configuration rule file obtained in the present application, which contains the mapping from the ontology concept layer, has the ability to guide data, and the implementation process can refer to the description of the corresponding part below.

[0079] Moreover, for the writing of the above configuration rule file, without the need for professional programming skills, anyone who understands how the original ontology file is transformed can complete it. For example, business personnel, management personnel, etc. can directly write it and report it to the computer device. It can be said that it is basically non-technical, leaving more time for the writing and modification of complex ontology files at the structural end. Compared with professional technical personnel spending a long time writing the business rules of the entire target ontology file from the data level, the present application starts from the ontology file, establishes the mapping between classes and relationships between ontologies, and can avoid defining operations such as addition, deletion, and modification. While reducing the complexity of writing the configuration rule file, it increases the robustness of the deformation function, enabling the writer to complete the writing of the configuration rule file in a very short time (such as one day, etc.), achieving the effects of saving manpower and time costs, improving agility, and lowering the threshold for rule writing.

[0080] Step S32, according to the graph query template, generate graph query statements for the original knowledge graph at least based on the configuration rule file;

[0081] Since the correct query statement is the guarantee of the reliability of graph transformation, and the knowledge graph contains a large amount of content, in order to realize the transformation of the original knowledge graph, it is necessary to construct multiple graph query statements such as entity query statements and relationship query statements to determine the entity information and relationship information in the target knowledge graph. For these graph query statements, if they are manually written by developers, it is very easy to cause the failure or inaccuracy of knowledge graph update due to writing errors. Therefore, in order to improve the generation efficiency, accuracy, and reliability of graph query statements, the present application hopes to automatically assemble accurate and unambiguous graph query statements with as little rule information as possible.

[0082] According to the above analysis, this application can pre-configure a graph query template with general characteristics, that is, applicable to graph queries in any field, based on the composition characteristics of various graph query statements and graph query requirements, etc. This application places no restrictions on the content and its representation form of this graph query template. When it is necessary to generate a graph query statement for a certain original knowledge graph, this graph query template can be directly called. Subsequently, the content of the configuration rule file constructed according to the ontology changes in the field to which the original knowledge graph belongs can be directly filled in the corresponding positions of this graph query template, or based on the content of the configuration rule file, the content required for the corresponding positions of the graph query template can be obtained and then filled in, so as to obtain a graph query statement for the original knowledge graph in the current field, without manual writing, greatly saving human and time resources and ensuring the accuracy and reliability of the generated graph query statements.

[0083] It can be understood that in order to query graph information such as each type of entity and each type of relationship contained in the original knowledge graph, multiple graph query statements can be generated accordingly. When generating each graph query statement, the graph query template can be called for generation. The difference lies in the different content in the configuration rule file relied on during the generation process. This application does not give detailed examples one by one here.

[0084] In addition, in order to identify that the graph information to be queried is defined by a certain enterprise, when generating a graph query statement, information that can achieve this identification purpose can also be obtained and used as the prefix information of the graph query statement, and combined with the ontology mapping content included in the configuration rule file to generate a graph search statement. Among them, this prefix information can be extracted from the original ontology file or the target ontology file, or it can be written into the configuration rule file when writing the configuration rule file. When generating a graph query statement in this way, it can be directly generated based on the configuration rule file and the graph query template, without the need to extract the content of the ontology file, but it is not limited to these two implementation methods proposed in this application.

[0085] In still other embodiments, an enterprise can also develop graph query templates applicable to various businesses of the enterprise. Compared with the graph query templates applicable to various fields of each enterprise, in this embodiment, the above-mentioned prefix information with fixed content can be added to the graph query template of the enterprise. In this way, during the process of changing the ontology file of a certain business of the enterprise and needing to perform transformation processing on the original knowledge graph to obtain the target knowledge graph, graph query statements for the original knowledge graph of a certain field business provided by the enterprise can also be directly generated based on the pre-written configuration rule file containing the mapping between the old and new ontologies and the graph query template of the enterprise. The implementation process is not elaborated in the embodiments of this application. It can be seen that this processing method of configuring corresponding graph query templates for different enterprises can also achieve the technical effects of improving processing efficiency, accuracy, and reliability compared with the processing method of manually writing graph query statements.

[0086] Step S33: Execute the graph query statement, and based on the obtained graph query result, obtain the target entity information and target relationship information under the target ontology file;

[0087] Step S34: Based on the target entity information and target relationship information, construct the target knowledge graph of this field.

[0088] Following the above description, the embodiments of this application implement the transformation of the original knowledge graph. It is necessary to prepare a configuration rule file and directly call the general graph query template to make the query of the original knowledge graph and the generation of the target entity information and target relationship information not be additionally modified with the differences of specific tasks, saving labor costs. Each update only requires updating the configuration rule file, improving the code reuse rate. After the ontology is updated, the iteration of the knowledge graph data can be quickly completed, that is, shortening the iteration cycle. In addition, when it is necessary to record the iteration process, this application can back up the ontology file and configuration rule file used for each update, that is, realizing lightweight backup, with small occupied space and low redundancy, and at the same time realizing the separation of the program and data.

[0089] In the embodiments of this application, by executing the program implementing the knowledge graph update method, all graph query statements for the original knowledge graph are automatically generated, and the graph query statements are automatically executed to query the graph information of the original knowledge graph. The implementation process of obtaining the graph query result of each graph query statement can generate multiple graph query statements synchronously by different threads executing the above Step S32 to improve efficiency. Of course, these multiple graph query statements can also be generated sequentially, and this application does not limit the generation order of multiple graph query statements. Subsequently, for the execution of multiple graph query statements, they can also be executed synchronously to improve efficiency, or one or part of the graph query statements can be executed sequentially each time, which can be determined according to the situation, such as combined with the available resources of the computer device.

[0090] Among them, when executing each graph query statement to query the original knowledge graph, the obtained graph query result is usually represented in the form of a string for the target entity information or target relationship information, and it is necessary to convert it into the target entity information or target relationship information under the target ontology file to construct the target knowledge graph. This application does not elaborate on the conversion processing method of the graph query result.

[0091] In summary, in the case where the ontology file changes, this application can realize the transformation from the original knowledge graph to the target knowledge graph through the ontology file and the configuration rule file used to illustrate the conceptual layer mapping between the original ontology file and the target ontology file, improving the update efficiency and reliability of the knowledge graph.

[0092] Refer to Figure 4, which is a schematic flowchart of another optional example of the knowledge graph update method proposed in this application. This embodiment can be an optional refined implementation method of the knowledge graph update method described above, but is not limited to the refined implementation method described in this embodiment, and this method can still be executed by a computer device, such as Figure 4 As shown, the method may include:

[0093] Step S41, obtain the original knowledge graph, the target ontology file, and the configuration rule file of any domain;

[0094] Among them, the configuration rule file can at least include entity category mapping and relationship mapping between the original ontology file and the target ontology file of the original knowledge graph, etc. The implementation method of step S41 can refer to the description of the corresponding part of the above embodiment, and this embodiment will not be elaborated.

[0095] Combined with the above description of the configuration rule file, since it is written based on the idea of traceability, it is equivalent to writing an ontology file and its simple annotations, making its file size order of magnitude equivalent to that of the ontology file. If directly writing business rules for the knowledge graph, not only the mapping of the ontology concept layer needs to be considered, but also the data level needs to be considered, whether there is a relationship defined in the ontology file between entities, and based on this, judge what operations to perform next, resulting in complex conditional branches, not only leading to a large number of written business rules, but also high reading and later maintenance costs. The content of the configuration rule file obtained in this application realizes the decoupling of ontology and data, only focuses on the ontology level, and greatly reduces the writing difficulty of the configuration rule file and the human and time costs spent.

[0096] In some embodiments, the generation method of the above configuration rule file may include but is not limited to: the terminal device responds to the structure update request of the original ontology file of any domain, generates a configuration rule file according to the original ontology file and the updated target ontology file, and sends the configuration rule file to the server or a specified terminal device. This application does not limit the storage location and method of the generated configuration rule file. It can be directly sent to the above computer device, or uploaded to other devices on the enterprise system platform or stored locally on the terminal device, so that the computer device can retrieve the required configuration rule file from it.

[0097] Step S42, retrieve the graph query template;

[0098] In the embodiments of the present application, a graph query template with general characteristics can be configured according to a graph query language. To ensure that the graph query statements generated accordingly can relatively comprehensively and accurately query the target entity information and target relationship information of the target knowledge graph from the original knowledge graph, the graph query template can include multiple write areas for pending query conditions. Among them, the pending query conditions can be used to indicate the corresponding ontology information in the configuration rule file written in the corresponding pending write area, that is, to indicate which content in the configuration rule file is written into which pending write area of the pending query condition, or to indicate the content to be written based on which content, etc., so that the graph query statements can be automatically generated accordingly in the future.

[0099] Among them, the ontology information indicated by the above pending query conditions can at least include the above entity category mapping and relationship mapping, and the multiple pending query conditions in the graph query template can at least include a pending query attribute condition and a pending query relationship condition, which are respectively used to indicate the content to be filled in the corresponding write area according to the corresponding type of ontology mapping in the configuration rule file. The present application does not limit the above multiple pending query conditions and the relationships between them, as well as the format requirements for the written content in the corresponding write area, which can be determined according to the situation.

[0100] Exemplarily, assume that an optional instance of the basic composition content of the configuration rule file is as follows:

[0101]

[0102] It can be seen that the above instance is a configuration rule file in yaml format, which defines how to generate entities of the ProductLine type under the target ontology file. Among them, class can represent the class under the target ontology. The above instance shows that the content of the configuration rule file described by it is defined around the ProductLine class. data_property can represent all the properties owned by this class in the target ontology file, as well as the mapping between this property and the properties in the original ontology file, and all the key-value pairs of data_property form <property_list>. As in the above instance, the ProductLine class has two properties: brand and productLine. The brand property comes from the brand property under the Brand class in the original ontology file; the productLine property comes from the productLine property under the ProductLine class in the original ontology file. Although they have the same name, they exist in different ontology files and represent different meanings.

[0103] In practical applications, the above-mentioned graph query template can be pre-stored in a database or other shared devices. In this way, in any scenario where an enterprise needs to change the ontology file of any domain business it owns, the computer device can directly retrieve the general graph query template from the shared device.

[0104] Step S43: According to the ontology information in the configuration rule files indicated by the multiple pending query conditions included in the graph query template, obtain the target query conditions for the original knowledge graph.

[0105] Following the above analysis of the graph query template, from the content of each pending query condition included in the graph query template, it can be known which ontology information needs to be extracted from the configuration rule file and written into the area to be written of this pending query condition to obtain the corresponding target query condition. From the type of the pending query condition described above, the obtained target query conditions can at least include target query attribute conditions and target query relationship conditions. Of course, according to application requirements, other query conditions can also be included, such as query constraint conditions for querying the original knowledge graph, etc., which can be determined according to the content of the graph query template and the configuration rule file.

[0106] In some embodiments, the present application can respectively obtain the target query attribute conditions and target query relationship conditions for the original knowledge graph according to the entity category mapping and relationship mapping included in the configuration rule file, and the implementation process is not elaborated in the present application.

[0107] It can be understood that for each pending query condition included in the graph query template, it is not necessarily possible to generate the target query conditions corresponding to the original knowledge graph. According to the query condition generation method described above, if the content indicated by one or more pending query conditions is not included in the configuration rule file, it is impossible to fill in the content in the area to be written of this pending query condition, and thus the corresponding target query conditions cannot be obtained.

[0108] Step S44: Use the obtained target query conditions to generate entity query statements and relationship query statements for the original knowledge graph.

[0109] Combined with the above description of the graph query statements, in the process of the execution program automatically generating these two types of graph query statements, namely entity query statements and relationship query statements, one or more generated target query conditions and the above prefix information can be combined to form the corresponding entity query statement or relationship query statement according to the format requirements of the query statements. The generation process of each graph query statement in the present application is not elaborated. It can be understood that for different graph query statements, the content of the target query conditions used is often different, and the number of the generated entity query statements and relationship query statements is often multiple, which can be determined according to the situation.

[0110] As described above for the prefix information, it can be the ontology identification information in the original ontology file and / or the target text file. Therefore, when generating the graph query statement, the ontology identification information can be obtained, and according to the graph query template, based on the above entity category mapping, relationship mapping, and ontology identification information, a graph query statement for the original knowledge graph can be generated, such as the above multiple entity query statements and multiple relationship query statements. The content of the obtained ontology identification information is not limited in this application. Exemplarily, such as http: / / example.org, the URI prefix of the original ontology file can also be represented by onto_srcsuo, and rdf.type represents the W3C standard predicate, etc.

[0111] It should be noted that this application does not limit the generation order of the above entity query statements and relationship query statements. Since the relationship query of the knowledge graph requires the use of the entity query results of the knowledge graph, the entity query statement needs to be executed first. Therefore, in order to improve the processing efficiency, this application can generate the entity query statement first and then execute it directly. During this process, the relationship query statement can be generated and executed directly. Of course, the graph query statements can also be generated simultaneously.

[0112] Step S45, execute the entity query statement to obtain the entity query result;

[0113] Since the entity query statement can be composed of one or more of the above target query attribute conditions, and the target query attribute conditions can be obtained according to the entity category mapping in the configuration rule file. The entity category mapping refers to the class mapping between the old and new ontologies. Since the class of an entity is composed of attributes (attribution / datatype property), the essence of the class mapping can be the mapping of attributes. For each attribute of the class under the new ontology (i.e., the target ontology), according to the changes between the old and new ontologies, it can be defined from which one or which category of attributes of the old ontology (i.e., the original ontology file) this attribute is transformed; for the newly generated class and its included attributes, it can be explained how this class is generated, etc.

[0114] Therefore, executing the entity query statement generated based on the above entity category mapping usually includes multiple entity query statements for querying each entity that conforms to the entity category mapping in the original knowledge graph. In this way, by executing all the generated entity query statements, the respective entity query results can be obtained, which are also the return results of the graph query language and can be a list composed of the values of the defined full variables (such as classes, attributes, etc.), namely <preproty_list> and <class_list>.

[0115] Among them, <preproty_list> can be an attribute variable, which can be the key of data_property in the configuration rule file written in order, with a prefix added to distinguish classes. For the above example, the string "<prop_brand>prop_productLine" can be generated and written into the graph query template. <class_list> can be a class variable, which is the first half of the value of data_property in the configuration rule file written in order (i.e., the part before →). If a class in a certain original ontology file appears multiple times, it needs to be written repeatedly to ensure that the number of <class_list> variables is the same as that of <preproty_list>. A prefix can be added to distinguish properties. For the example, the string "<cls_Brand>cls_ProductLine" can be generated and written into the graph query template.

[0116] Based on the above analysis, when executing the graph query statement containing the above content, the obtained entity query result can be:

[0117]

[0118]

[0119] Step S46: According to the entity query result, obtain the key entity data between the target knowledge graph to be generated and the original knowledge graph, as well as the target entity information under the target ontology file;

[0120] In the embodiment of the present application, following the above example, based on the return result of a group of <preproty_list>, the target entities in the target knowledge graph can be generated. Based on the return result of <class_list>, it can be indicated that the target entity is generated by the entities in the original knowledge graph. Accordingly, an entity mapping between the original knowledge graph and the target knowledge graph, such as an entity URI (Uniform Resource Identifier) mapping, is generated and stored as key entity data. At the same time, the target entity information in the required target knowledge graph can also be determined.

[0121] It can be seen that according to the above query method for the original knowledge graph, through one entity query statement, all the target entity information of a class under the target ontology file can be generated, and the implementation process is not elaborated in this application. It should be noted that regarding the implementation method of obtaining the target entity information under the target ontology file based on the entity query result, it includes but is not limited to the implementation method recorded in step 46 of this embodiment, and can be adaptively adjusted according to the business requirements of different fields. This application does not give examples and elaborate here.

[0122] Step S47, cache the entity key data and the target entity information;

[0123] For the caching of the entity key data and the target entity information, it can be implemented by the memory of the computer device itself, or the computer device can send it to the database for storage. This application does not limit the data storage implementation method.

[0124] Step S48, execute the relationship query statement to obtain the relationship query result;

[0125] In the embodiments of this application, the relationship query statement can be composed of one or more target query relationship conditions, and the target query relationship conditions can be determined according to the relationship mapping included in the above configuration rule file. Among them, in order to obtain the target relationship information under the target ontology file, this relationship mapping defines the relationship name of the target relationship information under the original ontology file, or the classes involved in the original ontology file. If the name of the relationship in the original ontology file is defined, it means that this is the same as the above entity category mapping rule, and there is also a mapping of this relationship between the original ontology file and the target ontology file. In this way, the target relationship information of this type can be generated through the steps of generating the target entity information.

[0126] If the defined rule is a class, it means that this relationship does not exist in the original knowledge graph. In this case, it may be that the entities of a certain class in the original knowledge graph are split into multiple classes, or it may be a newly added relationship purely. It is necessary to determine the entity pairs (i.e., the head and tail entities) to establish the relationship through the entity URI mapping between the original knowledge graph and the target knowledge graph (which saves which URIs in the original knowledge graph participate in the generation of the target knowledge graph URIs, and which target knowledge graph URIs a certain URI in the original knowledge graph participates in the establishment).

[0127] Therefore, in this application, according to the above relationship mapping, it can be ensured that each target query relationship condition included in the relationship query statement can accurately and completely explain how to obtain the target relationship information of the target knowledge graph based on the data of the original knowledge graph. The relationship query result obtained by executing this relationship query statement is directly obtained from the original knowledge graph. However, as analyzed above, a certain type of relationship in the target ontology file may not exist in the original ontology file. In this case, the subsequent steps can be executed, that is, combined with the entity URI mapping obtained by the entity query to more accurately obtain the target relationship information.

[0128] It should be noted that after obtaining the relationship query result, this application does not limit the implementation method of how to obtain the target relationship information under the target ontology file according to the relationship query result and the target entity information, including but not limited to the implementation methods recorded in the following steps, and can be adaptively adjusted according to different application requirements.

[0129] Step S49, retrieve the entity key data and target entity information;

[0130] Step S410, generate the target relationship information under the target ontology file based on the relationship query result, target entity information, and entity key data;

[0131] Continuing from the above description of the changes in the original ontology, there is a mapping between the target ontology file and the original ontology file. Exemplarily, the relationship mapping content is as follows:

[0132]

[0133] The query of the target relationship information is similar to that of the target entity information. To establish a relationship named hasProductProject in the target knowledge graph, during the query process, it is necessary to query all head and tail entity pairs that satisfy this relationship from the original knowledge graph. For this, when defining the relationship mapping in the configuration file, it is usually defined first that the hasProductProject relationship comes from hasProductSeries in the original ontology file. In this way, by parsing the relationship mapping in the configuration rule file, a graph query statement for implementing the hasProductProject relationship query can be generated. Here, it can be a relationship query statement, as follows:

[0134] SELECT <cls_ProductLine> cls_ProductSeries WHERE {

[0135] <cls_ProductLine rdf:type onto_src:ProductLine>

[0136] <cls_ProductSeries rdf:type onto_src:ProductSeries>

[0137] <cls_ProductLine onto_src:has ProductSeries> cls_ProductSeries

[0138] }

[0139] After that, the relationship query result obtained by executing the above example relationship query statement may include: the head and tail entity pairs with the hasProductSeries relationship in the original knowledge graph. Combining the above description of the relationship mapping content, the present application can also map the found head and tail entity pairs into the head and tail entity pairs in the target knowledge graph based on the entity key data (i.e., entity URI mapping) constructed during the entity query process, that is, obtain the target relationship in the target knowledge graph.

[0140] It can be understood that in the above example, since the hasProductSeries class entity in the original knowledge graph is mapped not only to the ProductProject class entity in the target knowledge graph, but also possibly to other class entities in the target knowledge graph. Therefore, this application needs to perform category screening on the obtained entity pairs, and establish a target relationship named hasProductProject for the head and tail entity pairs of the screened target knowledge graph until all target relationship information is obtained.

[0141] In some other embodiments, the target relationships defined in the target knowledge graph may not exist in the original knowledge graph. For such a situation, the relationship mappings in the configuration rule file defined in this application may include:

[0142]

[0143] From the content of the relationship mapping described in the above example, it can be seen that it does not contain the "src_relation" field, and only the "src_class" field exists, indicating that the head and tail entity pairs of this relationship only depend on the class. As the example content shows that the ProductProject class entity and the ProductSeries class entity under the target ontology file both come from the ProductSeries entity under the original ontology file. In this case, the generated relationship query statement can be:

[0144] SELECT <cls_ProductSeries>cls_ProductSeries WHERE{

[0145] <cls_ProductSeries rdf:type onto_src:ProductSeries>

[0146] <cls_ProductSeries rdf:type onto_src:ProductSeries>

[0147] }

[0148] It can be seen that when executing the relational query statement of the example, a relational query structure is obtained. That is, the <class_list> returned can be entity pairs formed by all ProductSeries entities in the original knowledge graph with themselves. When mapping to the entity URIs of the target knowledge graph, the result corresponding to the first cls_ProductSeries variable is mapped to the entity of the ProductSeries category in the target knowledge graph. Then, a relationship named hasProductSeries is established for the head and tail entity pairs of the filtered target knowledge graph to complete the establishment of the target relationship information and ensure the integrity and accuracy of the obtained target relationship information.

[0149] Step S411: Construct the target knowledge graph of this domain from the target entity information and the target relationship information, and output the target knowledge graph.

[0150] According to the method described above, after obtaining the target entity information and the target relationship information, the target knowledge graph under the target ontology can be directly constructed. For example, after converting the target entity information and the target relationship information into the knowledge graph format and exporting it, according to actual needs, the files of the target knowledge graph in formats such as csv, nt, and ttl are sent to the database for storage, so that the subsequent client can obtain the required business query results based on the target knowledge graph. This application does not limit the file format and storage method of the target knowledge graph and can be determined according to the situation.

[0151] Refer to Figure 5 , which is a schematic flowchart of another optional example of the knowledge graph update method proposed in this application. This embodiment can be another optional refined implementation method of the knowledge graph update method described above, including a refined description of the content of the graph query template and the process of obtaining the graph query statement, including but not limited to the implementation method described in this embodiment. As Figure 5 shown, the method may include:

[0152] Step S51: Obtain the original knowledge graph, the target ontology file, and the configuration rule file of any domain, and retrieve the graph query template;

[0153] Regarding the content of the entity category mapping and relationship mapping included in the configuration rule file, reference can be made to the corresponding part of the above embodiment, and this embodiment will not be elaborated.

[0154] For a general graph query template, in combination with the context description content, the multiple pending query conditions it contains may include pending query attribute conditions and pending query relationship conditions. In addition, it may also include a duplicate removal condition for indicating whether to remove duplicates from the query results, and / or a query constraint condition. In the embodiments of the present application, the case where the multiple pending query conditions in the graph query template include these four conditions is taken as an example for illustration. For graph query templates composed of other condition combinations, the implementation process of automatically generating graph query statements using them is similar, and the present application does not give detailed examples one by one.

[0155] Based on this, by way of example, the above graph query template can be formulated using a graph query language such as SPARQL language, and can be in accordance with but not limited to the following content graph query template:

[0156] SELECT <ifdistinct><preproty_list><class_list>WHERE{<condition_list>}

[0157] Among them, <ifdistinct>It can represent the above duplicate removal conditions, indicating whether the graph query results obtained by executing the graph query statement generated therefrom need to be de-duplicated; <preproty_list> can represent that the graph query results must return all attribute lists; <class_list> can represent that the graph query results must return all class entity URI lists; <condition_list> can represent the constraint condition list for querying the original knowledge graph by executing the graph query statement.

[0158] Step S52: According to the entity category mapping and relationship mapping included in the configuration rule file, determine the content to be written in the area to be written for the pending attribute conditions and pending query relationship conditions included in the graph query template, so as to obtain the target query attribute conditions and target query relationship conditions for the original knowledge graph.

[0159] Regarding the implementation process of step S52, reference can be made to the description of the corresponding part of the above embodiment, and details are not described herein. Among them, the entity category (i.e., class) in the entity category mapping can include at least one attribute. Regarding the construction method and content of the entity category mapping and relationship mapping, reference can be made to the description of the corresponding part of the above embodiment.

[0160] Step S53: According to the duplicate removal field of the query results included in the configuration rule file, determine the content to be written in the area to be written for the pending duplicate removal conditions included in the graph query template, so as to obtain the target duplicate removal conditions for the original knowledge graph.

[0161] Step S54: According to the entity category mapping and relationship mapping included in the configuration rule file, determine the content to be written in the area to be written for the pending query constraint conditions included in the graph query template, so as to obtain the target query constraint conditions for the original knowledge graph.

[0162] Taking the above-listed configuration rule file and graph query template example as an explanation, in the process of obtaining the target duplicate removal conditions, it is possible to determine whether it is necessary to de-duplicate the direct query results when executing the graph query statement generated therefrom according to the content of the distinct field in the configuration rule file. If the distinct field is true, "DISTINCT" can be written in the area to be written for the pending duplicate removal conditions in the graph query template; if the distinct field is false, it means that de-duplication is not required, and an empty string can be written in the area to be written for the pending duplicate removal conditions.

[0163] Similarly, in the process of obtaining the target query constraint conditions, the constraint conditions for generating query variables can be determined from multiple aspects according to the actual situation. Optionally, this application can obtain the first constraint condition and the second constraint condition based on the entity category mapping; among them, the first constraint condition can be used to indicate the corresponding entity names of the entities in different classes to be queried in the original ontology file, that is to say, in the target query constraint conditions, the complete names (which can be in URI format) of the query class variables (such as <class_list> above) in the original ontology file can be specified. Exemplarily, if there are two class variables, the first constraint condition in the generated target query constraint conditions can be the following string content:

[0164] <cls_Brand rdf:type onto_src:Brand>

[0165] <cls_ProductLine rdf:type onto_src:ProductLine>

[0166] Among them, onto_srcsuo represents the URI prefix of the original ontology file, and rdf.type represents the W3C standard predicate. Therefore, when performing the original knowledge graph query based on the two target query constraint conditions represented by these two strings, all entities of the category Brand and all entities of the category ProductLine can be found in the original knowledge graph, and the return results of cls_Brand and cls_ProductLine can both be in URI format.

[0167] For the above-mentioned second constraint condition, it can be used to indicate that the attributes of each class in the target ontology file come from the first class with this attribute in the original ontology file, that is to say, in the process of querying the original knowledge graph, it is necessary to inversely deduce which class variables should have which mathematics according to the attribute variables, and their attribute values are returned as results. For example, given that the brand attribute of the ProductLine class in the target ontology file should come from the Brand attribute under the Brand class in the original ontology file, and the productLine attribute should come from the productLine attribute under the ProductLine class in the original ontology file, the second constraint condition that can be generated is:

[0168] <cls_Brand onto_src:brand>pror_brand

[0169] <cls_ProductLine onto_src:ProductLine>pror_productLine

[0170] In addition, during the process of obtaining the target query constraint conditions, the present application can also obtain the third constraint condition according to the inter-class relationship in the relationship mapping; the third constraint condition can be used to indicate querying entity pairs with such inter-class relationship, for supplementing the above first constraint condition and second constraint condition. Exemplarily, if there is a relationship of Brand-[hasProductLine]→ProductLine in the original ontology file, that is, in the original knowledge graph, between a Brand entity and a ProductLine entity, there may be a hasProductLine relationship, and it points from Brand to ProductLine. The third constraint condition constructed for this can include: <cls_Brand onto_src:hasProductLine>cls_productLine. This means that the returned attribute variables must satisfy the above constraint relationship in the original graph and cannot be a simple Cartesian product combination. In this way, the first constraint condition, the second constraint condition, and the third constraint condition will constitute the target query constraint conditions for the original knowledge graph, and taking this as a query condition for constructing the graph query statement and executing the graph query statement of this content can greatly reduce the amount of query result data and improve the query efficiency and accuracy.

[0171] Step S55, according to the obtained target query attribute conditions, target query relationship conditions, target duplicate removal conditions, and target query constraint conditions, constitute a graph query statement for the original knowledge graph;

[0172] Combined with the above description of the graph query statement and the description content of the configuration rule file exemplified in the above embodiments, the ProductLine class in the target ontology file is composed of the entity information of two classes in the original knowledge graph. If the target query constraint condition is not added in the construction of the graph query statement, assuming there are m Brand entities and n ProductLine entities in the original knowledge graph data, after the Cartesian product operation, the target knowledge graph will query m*n ProductLine entities, which does not conform to the actual situation. Therefore, the present application proposes to add the constraint of the relationship from Brand to ProductLine in the original ontology file to the graph query statement and then execute the query step. The query result can be the <preproty_list> return result, that is, a group of (brand, productLine) is all the entities that should be generated for the ProductLine class in the target knowledge graph.

[0173] It should be noted that for the target query constraint condition "src_relation", it usually objectively exists, rather than being determined by humans whether to add it. In the area to be written in the graph query template with the to-be-query constraint condition, the content of the configuration rule file can be analyzed according to the method described above to determine the content of this area to be written and obtain the target query constraint condition.

[0174] Optionally, if it is determined that a certain class in the target ontology file comes from multiple classes in the original ontology file, these classes in the original ontology file can be automatically traversed, and the existing relationships can be added to the area to be written in the to-be-query constraint condition. If there are no relationships and there are multiple classes in the target ontology file, then the number of entities in the target knowledge graph of these classes will be the Cartesian product of the number of entities in each relevant entity category in the original knowledge graph.

[0175] Exemplarily, the graph query statement generated by the program according to the configuration rule file and the ontology identification information can be the following string content, but is not limited thereto:

[0176] SELECT <prop_brand> prop_ProductLine <cls_Brand> cls_ProductLine WHERE {

[0177] <cls_Brand rdf:type onto_src:Brand>

[0178] <cls_ProductLine rdf:type onto_src:ProductLine>

[0179] <cls_Brand onto_src:brand> prop_brand

[0180] <cls_ProductLine onto_src:ProductLine> prop_productLine

[0181] <cls_Brand onto_src:hasProductLine> cls_ProductLine

[0182] }

[0183] Step S56, execute the graph query statement, and obtain the target entity information and target relationship information under the target ontology file according to the obtained graph query result;

[0184] Step S57, generate the target knowledge graph of this field according to the target entity information and target relationship information.

[0185] Regarding the implementation process of steps S55 - S57, reference can be made to the description of the corresponding part in the above - mentioned embodiment, and details will not be elaborated in this embodiment.

[0186] In some embodiments, in combination with the above - mentioned descriptions of relationship mapping and target constraint conditions, the method for obtaining the above - mentioned target relationship information may include:

[0187] If the obtained relationship query result indicates that there is an entity pair in the original knowledge graph that meets the target query constraint conditions, the first relationship information between the entity pair can be obtained based on the corresponding entity mapping in the cached entity key data; if the relationship query result indicates that the second relationship in the target ontology file depends on the entity category in the original knowledge graph, the entities in the entity category on which it depends are mapped to the corresponding second relationship on which it depends. Then, the second relationship information between the entity pairs after mapping processing can be obtained by using the target query constraint conditions; the target relationship information under the target ontology text is composed of the obtained first relationship information and second relationship information, and the implementation process is not elaborated in this application.

[0188] In summary, in the process of generating a graph query statement for the original knowledge graph according to the configuration rule file and the general graph query template in the embodiments of this application, the query constraint conditions existing in the mapping between the original ontology file and the target ontology file are fully considered, improving the query efficiency and accuracy of the original knowledge graph.

[0189] Refer to Figure 6 , which is a schematic structural diagram of an optional example of the knowledge graph update device proposed in this application. As Figure 6 shown, the device may include:

[0190] A data acquisition module 61, configured to acquire the original knowledge graph, the target ontology file, and the configuration rule file of any domain; wherein, the configuration rule file at least includes entity category mapping and relationship mapping between the original ontology file of the original knowledge graph and the target ontology file;

[0191] A graph query statement generation module 62, configured to generate a graph query statement for the original knowledge graph according to the graph query template and at least based on the configuration rule file;

[0192] A target knowledge data acquisition module 63, configured to execute the graph query statement and obtain the target entity information and target relationship information under the target ontology file according to the obtained graph query result;

[0193] A target knowledge graph generation module 64, configured to generate a target knowledge graph of the domain according to the target entity information and the target relationship information.

[0194] Optionally, the above - mentioned graph query statement generation module 62 may include:

[0195] A graph query template retrieval unit for retrieving a graph query template;

[0196] Wherein, the graph query template is configured according to a graph query language and includes a pending writing area with multiple pending query conditions; the pending query conditions are used to indicate the corresponding ontology information in the configuration rule file written in the pending writing area, and the ontology information at least includes the entity category mapping and the relationship mapping, and the multiple pending query conditions at least include a pending query attribute condition and a pending query relationship condition;

[0197] A target query condition obtaining unit for obtaining a target query condition for the original knowledge graph according to the ontology information included in the configuration rule file indicated by each of the multiple pending query conditions; the target query condition at least includes a target query attribute condition and a target query relationship condition,

[0198] A graph query statement generating unit for generating a graph query statement for the original knowledge graph by using the obtained target query condition.

[0199] In some embodiments, if the multiple pending query conditions in the graph query template may further include a duplicate removal condition and / or a query constraint condition for indicating whether to remove duplicates from the query result, the above target query condition obtaining unit may include:

[0200] An attribute relationship condition obtaining unit for respectively obtaining a target query attribute condition and a target query relationship condition for the original knowledge graph according to the entity category mapping and the relationship mapping; wherein, the entity category includes at least one attribute; and,

[0201] A duplicate removal condition obtaining unit for obtaining a target duplicate removal condition for the original knowledge graph according to the duplicate removal field of the query result in the configuration rule file; and / or

[0202] A query constraint condition obtaining unit for obtaining a target query constraint condition for the original knowledge graph according to the entity category mapping and the relationship mapping; the target query constraint condition can represent constraints in the attribute dimension, the entity category dimension, and the relationship dimension.

[0203] Optionally, the above query constraint condition obtaining unit may include:

[0204] A first obtaining unit for obtaining a first constraint condition and a second constraint condition according to the entity category mapping;

[0205] Wherein, the first constraint condition is used to indicate the corresponding entity names of the entities in different classes queried in the original ontology file; the second constraint condition is used to indicate that the attributes of each class in the target ontology file come from the first class with the attribute in the original ontology file.

[0206] A second obtaining unit, configured to obtain a third constraint condition according to the inter-class relationship in the relationship mapping; the third constraint condition is used to indicate querying entity pairs having the inter-class relationship.

[0207] A target query constraint condition forming unit, configured to form a target query constraint condition for the original knowledge graph from the first constraint condition, the second constraint condition, and the third constraint condition.

[0208] In still other embodiments, the above graph query statement includes an entity query statement and a relationship query statement. Based on this, the above target knowledge data obtaining module 63 may include:

[0209] An entity query result obtaining unit, configured to execute the entity query statement to obtain an entity query result.

[0210] A target entity information obtaining unit, configured to obtain target entity information under the target ontology file according to the entity query result.

[0211] A relationship query result obtaining unit, configured to execute the relationship query statement to obtain a relationship query result.

[0212] A target relationship information obtaining unit, configured to obtain target relationship information under the target ontology file according to the relationship query result and the target entity information.

[0213] Optionally, the above target knowledge data obtaining module 63 may further include:

[0214] An entity key data obtaining unit, configured to obtain entity key data between the target knowledge graph to be generated and the original knowledge graph according to the entity query result; the entity key data includes entity mapping between the target knowledge graph and the original knowledge graph.

[0215] A data caching unit, configured to cache the entity key data and the target entity information.

[0216] Based on this, the above target relationship information obtaining unit may include:

[0217] A data retrieval unit, configured to retrieve the entity key data and the target entity information.

[0218] A target relationship information generation unit, configured to generate target relationship information under the target ontology file according to the relationship query result, the target entity information, and the entity key data.

[0219] Optionally, the above-mentioned target relationship information obtaining unit may further include:

[0220] A first relationship information obtaining unit, configured to, when the relationship query result indicates that there is an entity pair that meets the target query constraint condition in the original knowledge graph, obtain first relationship information between the entity pair according to the corresponding entity mapping in the cached entity key data;

[0221] An entity mapping processing unit, configured to, when the relationship query result indicates that a second relationship in the target ontology file depends on an entity category in the original knowledge graph, map entities in the dependent entity category to the corresponding second relationship that is dependent;

[0222] A second relationship information obtaining unit, configured to use the target query constraint condition to obtain second relationship information between the entity pairs after mapping processing;

[0223] A target relationship information composition unit, configured to compose the target relationship information under the target ontology text from the obtained first relationship information and the second relationship information.

[0224] In still other embodiments, the above-mentioned graph query statement generation module 62 may include:

[0225] An ontology identification information acquisition unit, configured to acquire ontology identification information in the original ontology file and / or the target text file;

[0226] A graph query statement generation unit, configured to generate a graph query statement for the original knowledge graph according to a graph query template, based on the entity category mapping, the relationship mapping, and the ontology identification information;

[0227] And / or, the method for generating the configuration rule file includes:

[0228] A configuration rule file generation unit, in response to a structure update request of the original ontology file in any domain, generates a configuration rule file according to the original ontology file and the updated target ontology file;

[0229] A configuration rule file sending unit, configured to send the configuration rule file to a server or a specified terminal device.

[0230] It should be noted that all kinds of modules, units, etc. in the above device embodiments can be stored in the memory as program modules, and the above program modules stored in the memory are executed by the processor to implement corresponding functions. For the functions implemented by each program module and its combination, and the achieved technical effects, reference can be made to the description of the corresponding part of the above method embodiments, and details will not be repeated in this embodiment.

[0231] The present application also provides a computer-readable storage medium on which a computer program can be stored. The computer program can be called and loaded by a processor to implement each step of the knowledge graph update method described in the above embodiments. The implementation process can refer to the description of the corresponding part of the above method embodiments, and details will not be repeated in this embodiment.

[0232] Finally, it should be noted that in the above embodiments, unless the context clearly indicates an exception, words such as "a", "one", "a kind of" and / or "the" do not specifically refer to the singular, but may also include the plural. Generally speaking, the terms "include" and "comprise" only indicate the inclusion of the clearly identified steps and elements, and these steps and elements do not constitute an exclusive list. The method or device may also include other steps or elements. An element defined by the statement "including one..." does not exclude the existence of another identical element in the process, method, commodity or device including the element.

[0233] Among them, in the description of the embodiments of the present application, unless otherwise specified, " / " means "or". For example, A / B can mean A or B; "and / or" herein is only a description of the association relationship of the associated objects, indicating that three relationships can exist. For example, A and / or B can mean: A exists alone, A and B exist simultaneously, and B exists alone. In addition, in the description of the embodiments of the present application, "a plurality of" means two or more than two.

[0234] Terms involved in the present application such as "first", "second", etc. are only for descriptive purposes, used to distinguish one operation, unit or module from another operation, unit or module, and do not necessarily require or imply any such actual relationship or order between these units, operations or modules. And it cannot be understood as indicating or implying relative importance or implicitly indicating the quantity of the indicated technical features. Thus, features defined with "first", "second" may explicitly or implicitly include one or more of such features.

[0235] In addition, the various embodiments in this specification are described in a progressive or parallel manner. Each embodiment focuses on the differences from other embodiments. For the same or similar parts among the various embodiments, reference can be made to each other. For the devices, computer equipment, and media disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the description is relatively simple. For the relevant parts, reference can be made to the description in the method section.

[0236] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present application. Various modifications to these embodiments will be obvious to those skilled in the art. The general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but rather will be accorded the widest scope consistent with the principles and novel features disclosed herein.< / ifdistinct> < / ifdistinct>

Claims

1. A method for updating a knowledge graph, comprising: Obtaining an original knowledge graph, a target ontology file, and a configuration rule file in any domain; wherein, the configuration rule file at least includes an entity category mapping and a relationship mapping between the original ontology file of the original knowledge graph and the target ontology file; Generating a graph query statement for the original knowledge graph according to a graph query template and at least based on the configuration rule file; Executing the graph query statement, and obtaining target entity information and target relationship information under the target ontology file according to the obtained graph query result; Generating a target knowledge graph of the domain according to the target entity information and the target relationship information.

2. The method according to claim 1, wherein the generating a graph query statement for the original knowledge graph according to a graph query template and at least based on the configuration rule file includes: Invoking a graph query template; wherein, the graph query template is configured according to a graph query language and includes a to-be-written area with multiple to-be-determined query conditions; the to-be-determined query conditions are used to indicate the corresponding ontology information in the configuration rule file written in the to-be-written area, the ontology information at least includes the entity category mapping and the relationship mapping, and the multiple to-be-determined query conditions at least include a to-be-determined query attribute condition and a to-be-determined query relationship condition; Obtaining a target query condition for the original knowledge graph according to the ontology information included in the configuration rule file indicated by each of the multiple to-be-determined query conditions; the target query condition at least includes a target query attribute condition and a target query relationship condition, Generating a graph query statement for the original knowledge graph by using the obtained target query condition.

3. The method according to claim 2, if the multiple to-be-determined query conditions further include a duplicate removal condition and / or a query constraint condition for indicating whether the query result is de-duplicated, the obtaining a target query condition for the original knowledge graph according to the ontology information included in the configuration rule file indicated by each of the multiple to-be-determined query conditions includes: Respectively obtaining a target query attribute condition and a target query relationship condition for the original knowledge graph according to the entity category mapping and the relationship mapping; wherein, the entity category includes at least one attribute; and, Obtaining a target duplicate removal condition for the original knowledge graph according to the duplicate removal field of the query result in the configuration rule file; and / or Obtaining a target query constraint condition for the original knowledge graph according to the entity category mapping and the relationship mapping; the target query constraint condition can represent constraints in the attribute dimension, entity category dimension, and relationship dimension.

4. The method according to claim 3, wherein the obtaining a target query constraint condition for the original knowledge graph according to the entity category mapping and the relationship mapping includes: Obtain a first constraint condition and a second constraint condition according to the entity category mapping; wherein, the first constraint condition is used to indicate the corresponding entity names of the entities in different classes queried in the original ontology file; the second constraint condition is used to indicate that the attributes of each class in the target ontology file come from the first class with the attribute in the original ontology file. Obtain a third constraint condition according to the inter-class relationship in the relationship mapping; the third constraint condition is used to indicate querying entity pairs with the inter-class relationship. The first constraint condition, the second constraint condition and the third constraint condition constitute a target query constraint condition for the original knowledge graph.

5. The method according to claim 3 or 4, wherein the graph query statement includes an entity query statement and a relationship query statement; when executing the graph query statement, obtain target entity information and target relationship information under the target ontology file according to the obtained graph query result, including: Execute the entity query statement to obtain an entity query result. Obtain target entity information under the target ontology file according to the entity query result. Execute the relationship query statement to obtain a relationship query result. Obtain target relationship information under the target ontology file according to the relationship query result and the target entity information.

6. The method according to claim 5, in the process of obtaining target entity information under the target ontology file according to the entity query result, further includes: Obtain entity key data between the target knowledge graph to be generated and the original knowledge graph according to the entity query result. The entity key data includes entity mapping between the target knowledge graph and the original knowledge graph. Cache the entity key data and the target entity information. The obtaining of the target relationship information under the target ontology file according to the relationship query result and the target entity information includes: Retrieve the entity key data and the target entity information. Generate target relationship information under the target ontology file according to the relationship query result, the target entity information and the entity key data.

7. The method according to claim 6, the obtaining of the target relationship information under the target ontology file according to the relationship query result and the target entity information further includes: If the relationship query result indicates that there is an entity pair in the original knowledge graph that meets the target query constraint condition, obtain first relationship information between the entity pair according to the corresponding entity mapping in the cached entity key data. If the relationship query result indicates that a second relationship in the target ontology file depends on the entity category in the original knowledge graph, map the entities in the dependent entity category to the corresponding second relationship being depended on. Use the target query constraint condition to obtain second relationship information between the entity pairs after mapping processing. The obtained first relationship information and second relationship information constitute the target relationship information in the target ontology text.

8. The method according to any one of claims 1-4, wherein generating a graph query statement for the original knowledge graph according to the graph query template and at least based on the configuration rule file includes: Obtaining ontology identification information in the original ontology file and / or the target ontology file; Generating a graph query statement for the original knowledge graph according to the graph query template, based on the entity category mapping, the relationship mapping, and the ontology identification information; And / or, the method for generating the configuration rule file includes: Responding to a structure update request of the original ontology file in any domain, and generating a configuration rule file based on the original ontology file and the updated target ontology file; Sending the configuration rule file to a server or a specified terminal device.

9. A knowledge graph update device, comprising: A data acquisition module, configured to acquire an original knowledge graph, a target ontology file, and a configuration rule file in any domain; wherein the configuration rule file at least includes an entity category mapping and a relationship mapping between the original ontology file of the original knowledge graph and the target ontology file; A graph query statement generation module, configured to generate a graph query statement for the original knowledge graph according to the graph query template and at least based on the configuration rule file; A target knowledge data acquisition module, configured to execute the graph query statement and obtain target entity information and target relationship information under the target ontology file according to the obtained graph query result; A target knowledge graph generation module, configured to generate a target knowledge graph of the domain based on the target entity information and the target relationship information.

10. A computer device, comprising: A communication interface; A memory, configured to store a program for implementing the knowledge graph update method according to any one of claims 1-8; A processor, configured to load and execute the program stored in the memory to implement the knowledge graph update method according to any one of claims 1-8.

Citation Information

Patent Citations

  • Knowledge graph construction method and device, information penetration method and system

    CN111813956A

  • Knowledge graph construction method and device, computing equipment and storage medium

    CN112434811A