Knowledge graph construction method and device, knowledge graph query method and device, equipment, medium and product
By constructing and optimizing the knowledge graph, the problems of data duplication and inefficiency in traditional knowledge graph maintenance are solved, and more efficient knowledge graph query and maintenance are achieved.
Patent Information
- Application Number
- CN202510362819.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-26
- Publication Date
- 2025-06-27
AI Technical Summary
In traditional knowledge graph maintenance, data duplication and redundancy are caused when multiple graphs share entities, query efficiency is low, and modifying one knowledge graph can easily affect the data of other graphs.
By obtaining the target entity information, connection relationships and target data of the entity based on the target input parameters, the initial knowledge graph is constructed using the graph data structure and optimized its structure to obtain the target knowledge graph.
It improves the query efficiency of the knowledge graph, reduces the number of queries, avoids data duplication and redundancy, and enhances the maintenance stability of the knowledge graph.
Smart Images

Figure CN120218212A_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present disclosure relate to the technical field of knowledge graphs, and in particular, to a method, apparatus, device, medium, and product for constructing and querying a knowledge graph. Background Art
[0002] In traditional knowledge graph maintenance and query, three tables, namely, an entity table, an entity relationship table, and an attribute table, are used for graph maintenance operations. When multiple knowledge graphs use the same entity and other information, it is difficult to maintain. For example, knowledge graph A uses entities 1 and 2, and there is a relationship between entities 1 and 2. Knowledge graph B also uses entity 1 and entity 3, and there is a relationship between entity 1 and entity 3. At this time, whether it is knowledge graph A or knowledge graph B, when entity 1 is queried, entities 2 and 3 will be queried out, resulting in data duplication and redundancy. In traditional knowledge graph maintenance, whenever a new knowledge graph is added or an existing knowledge graph is modified, it is easy to affect the whole situation with one move, and it may affect the data of other knowledge graphs, especially the relationships of each node in each knowledge graph. And in traditional query, when the association levels of each sub-node of the knowledge graph are relatively deep, multiple recursive queries are required. In the case of a relatively complex knowledge graph, the query efficiency is very low, increasing the memory overhead and network latency. Summary of the Invention
[0003] Embodiments of the present disclosure provide a method, apparatus, device, medium, and product for constructing and querying a knowledge graph, which improves the query efficiency of the knowledge graph.
[0004] In a first aspect, a method for constructing a knowledge graph is provided, including:
[0005] Obtaining target entity information, connection relationships, and target data of each entity based on target input parameters; the target input parameters include an entity list, entity types, relationship types, and a data source path; the target entity information is determined based on the entity list; the connection relationships are determined based on the entity types and the relationship types; the target data is the database pointed to by the data source path;
[0006] Determining an initial knowledge graph using a graph data structure based on the target entity information, the connection relationships, and the target data; the nodes of the initial knowledge graph are entities; the edges of the initial knowledge graph are the connection relationships between entities;
[0007] Optimizing the structure of the initial knowledge graph to obtain a target knowledge graph.
[0008] In a second aspect, a method for querying a knowledge graph is provided, including:
[0009] Obtain the target query parameters input by the user; the target query parameters at least include entity type, relationship type, and query depth;
[0010] Construct a query statement based on the target query parameters, and query the target knowledge graph based on the query statement to determine the query result; the query result includes entities and the connection relationships between entities;
[0011] Output the knowledge graph data based on the query result;
[0012] Wherein, the target knowledge graph is obtained based on the knowledge graph construction method described in the first aspect above.
[0013] In a third aspect, there is provided a knowledge graph construction device, including:
[0014] An acquisition module, configured to obtain the target entity information, connection relationship, and target data of each entity based on the target input parameters; the target input parameters include an entity list, entity type, relationship type, and data source path; the target entity information is determined based on the entity list; the connection relationship is determined based on the entity type and the relationship type; the target data is the database pointed to by the data source path;
[0015] An initial knowledge graph determination module, configured to determine an initial knowledge graph using a graph data structure based on the target entity information, the connection relationship, and the target data; the nodes of the initial knowledge graph are entities; the edges of the initial knowledge graph are the connection relationships between entities;
[0016] A target knowledge graph determination module, configured to optimize the structure of the initial knowledge graph to obtain the target knowledge graph.
[0017] In a fourth aspect, there is provided a knowledge graph query device, including:
[0018] A target query parameter determination module, configured to obtain the target query parameters input by the user; the target query parameters at least include entity type, relationship type, and query depth;
[0019] A query result determination module, configured to construct a query statement based on the target query parameters, and query the target knowledge graph based on the query statement to determine the query result; the query result includes entities and the connection relationships between entities;
[0020] A knowledge graph data output module, configured to output the knowledge graph data based on the query result;
[0021] Wherein, the target knowledge graph is obtained based on the knowledge graph construction method described in the first aspect above.
[0022] Fifth aspect, there is provided an electronic device, including:
[0023] at least one processor; and,
[0024] a memory communicatively connected to the at least one processor; wherein,
[0025] the memory stores a computer program executable by the at least one processor, and when the computer program is executed by the at least one processor, the at least one processor is enabled to execute the method for constructing a knowledge graph as described in the first aspect above.
[0026] Sixth aspect, there is provided a computer-readable storage medium, on which a computer program is stored, and when the program is executed by a processor, it implements the method for constructing a knowledge graph as described in the first aspect above, or the method for querying a knowledge graph as described in the second aspect above.
[0027] Seventh aspect, there is provided a computer program product, the computer program product includes a computer program, and when the computer program is executed by a processor, it implements the method for constructing a knowledge graph as described in the first aspect above, or the method for querying a knowledge graph as described in the second aspect above.
[0028] Embodiments of the present disclosure disclose a method, apparatus, device, medium and product for constructing and querying a knowledge graph. The method includes: obtaining target entity information, connection relationships and target data of each entity based on target input parameters; the target input parameters include an entity list, entity types, relationship types and a data source path; the target entity information is determined based on the entity list; the connection relationships are determined based on the entity types and the relationship types; the target data is the database pointed to by the data source path; determining an initial knowledge graph using a graph data structure based on the target entity information, the connection relationships and the target data; the nodes of the initial knowledge graph are entities; the edges of the initial knowledge graph are the connection relationships between entities; optimizing the structure of the initial knowledge graph to obtain a target knowledge graph. The technical solution obtains the target entity information, connection relationships and target data of entities based on target input parameters, and determines an initial knowledge graph using a graph data structure based on the target entity information, connection relationships and target data, and optimizes the initial knowledge graph to obtain a target knowledge graph, improving the query efficiency and reducing the number of queries.
[0029] It should be understood that the content described in this part is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it used to limit the scope of the embodiments of the present disclosure. Other features of the embodiments of the present disclosure will become easily understood through the following description. Description of the Drawings
[0030] To more clearly illustrate the technical solutions in the embodiments of the present disclosure, the following will briefly introduce the accompanying drawings required for the description of the embodiments. Obviously, the accompanying drawings in the following description are only some embodiments of the embodiments of the present disclosure. For those of ordinary skill in the art, without creative efforts, other accompanying drawings can be obtained based on these drawings.
[0031] Figure 1 is a flowchart of a method for constructing a knowledge graph provided in Embodiment 1 of the present disclosure;
[0032] Figure 2 is a flowchart of a method for querying a knowledge graph provided in Embodiment 2 of the present disclosure;
[0033] Figure 3 is a schematic structural diagram of a device for constructing a knowledge graph provided in Embodiment 3 of the present disclosure;
[0034] Figure 4 is a schematic structural diagram of a device for querying a knowledge graph provided in Embodiment 4 of the present disclosure;
[0035] Figure 5 is a schematic structural diagram of an electronic device provided in Embodiment 5 of the present disclosure. Specific Embodiments
[0036] In order to enable those skilled in the art of the present technology to better understand the solutions of the embodiments of the present disclosure, the following will clearly and completely describe the technical solutions in the embodiments of the present disclosure in conjunction with the accompanying drawings in the embodiments of the present disclosure. Obviously, the described embodiments are only a part of the embodiments of the present disclosure, rather than all the embodiments. Based on the embodiments in the embodiments of the present disclosure, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the scope of protection of the embodiments of the present disclosure.
[0037] It should be noted that the terms "first", "second", etc. in the description and claims of the embodiments of the present disclosure and the above accompanying drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged under appropriate circumstances so that the embodiments of the present disclosure described here can be implemented in an order other than those illustrated or described here. In addition, the terms "comprising" and "having" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or device that includes a series of steps or units does not necessarily have to be limited to those steps or units clearly listed, but may include other steps or units not clearly listed or inherent to these processes, methods, products, or devices.
[0038] Embodiment 1
[0039] Figure 1 The following is a flowchart of a method for constructing a knowledge graph provided in the first embodiment of the present disclosure. This embodiment is applicable to the situation of constructing a knowledge graph. This method can be executed by a knowledge graph construction device, which can be implemented in the form of hardware and / or software. The knowledge graph construction device can be configured in an electronic device, and the electronic device includes, but is not limited to, devices with data processing capabilities such as computers, laptops, terminals, and servers. As Figure 1 shown, the method includes:
[0040] S110. Obtain the target entity information, connection relationship, and target data of each entity based on the target input parameters; the target input parameters include an entity list, entity types, relationship types, and a data source path; the target entity information is determined based on the entity list; the connection relationship is determined based on the entity types and relationship types; the target data is the database pointed to by the data source path.
[0041] In this embodiment, an entity is a basic element in a knowledge graph or a graph. The target input parameters can be parameters input by a user, and the target input parameters include an entity list, entity types, relationship types, and a data source path; among them, the entity list can be a list of names or identifiers of entities to be processed. The entity types can include source entities and target entities. A source entity refers to the entity that starts in a relationship. In a directed edge (relationship), the source entity is the starting point of the relationship; a target entity refers to the entity at the end of the relationship. In a directed edge (relationship), the target entity is the object pointed to by the relationship. The data source path can be the storage path or storage location of the data required for constructing the knowledge graph.
[0042] According to the above description, the target entity information can be extracted by traversing the entity list in the target input parameters. The target entity information can include fields such as the name, type, and description of each entity. The connection relationship can be the association relationship between entities, and the connection relationship can also be determined based on the entity types and relationship types. When constructing a knowledge graph, the connection relationship between entities is determined according to the entity types and the preset relationship types. Exemplarily, if entity A is "creator" and entity B is "version", then the possible relationship type between them may be the version created by the creator. The target data can be the database pointed to by the data source path.
[0043] S120. Determine an initial knowledge graph using a graph data structure based on the target entity information, connection relationship, and target data; the nodes of the initial knowledge graph are entities; the edges of the initial knowledge graph are the connection relationships between entities.
[0044] Specifically, after determining the target entity information, connection relationships, and target data, an initial knowledge graph can be determined based on the target entity information, connection relationships, and target data using a graph data structure. A graph is a data structure composed of nodes and edges. In a knowledge graph, the graph data structure is used to represent entities (nodes) and the relationships (edges) between them. In the initial knowledge graph, the nodes of the graph represent entities. A node is the basic unit of the knowledge graph, and each node contains the basic information of the entity, such as the name and type of the entity. In the initial knowledge graph, the edges of the graph represent the relationships between entities. Each edge connects two nodes and usually has a relationship type to describe the semantic association between the two nodes. It should be noted that an edge not only represents the connection between two entities but may also contain the direction of the relationship (directed edge) and the attributes of the relationship.
[0045] S130. Optimize the structure of the initial knowledge graph to obtain the target knowledge graph.
[0046] Specifically, the structure of the initial knowledge graph can be optimized to obtain the target knowledge graph. The optimization can include operations such as denoising, deduplication, and standardization. Denoising includes identifying and deleting incorrect entities or relationships. For example, if the type of an entity is misidentified, it needs to be corrected or deleted. Deduplication includes removing or merging duplicate entities or relationships. For example, if two entities are actually the same object, they need to be merged into one entity to avoid the same entity being recognized multiple times. Standardization can be understood as performing standardization processing on the names, attributes, etc. of entities. Exemplarily, standardization can be removing extra spaces, unifying case; mapping entity types, if the input type is an alias, mapping it to the standard type; cleaning the text of entity descriptions to remove special characters or illegal content to improve the efficiency and readability of the graph.
[0047] It should be explained that after obtaining the target knowledge graph, it can be saved to a pre-set storage location. For example: if it is persistent storage, the data can be saved to a graph database (such as Neo4j) or a relational database (such as MySQL); if it is temporary storage, the data can also be saved as a local file (such as JSON, CSV).
[0048] It should be explained that different target knowledge graphs can be determined based on different target entity information, connection relationships, and target data. Different target knowledge graphs can be interrelated and combined with each other. Different target knowledge graphs can be displayed separately or displayed uniformly based on various combinations. When one of the target knowledge graphs changes, all combined graphs that reference this graph will be updated to the latest graph in real time, and the problem of infinite loops is avoided.
[0049] This embodiment provides a method for constructing a knowledge graph, including: obtaining target entity information, connection relationships, and target data of each entity based on target input parameters; the target input parameters include an entity list, entity types, relationship types, and a data source path; the target entity information is determined based on the entity list; the connection relationships are determined based on the entity types and the relationship types; the target data is the database pointed to by the data source path; determining an initial knowledge graph using a graph data structure based on the target entity information, the connection relationships, and the target data; the nodes of the initial knowledge graph are entities; the edges of the initial knowledge graph are the connection relationships between entities; optimizing the structure of the initial knowledge graph to obtain a target knowledge graph, which realizes the storage of accurate data in the knowledge graph, prevents misoperation of other knowledge graphs, improves the query efficiency of the knowledge graph, and reduces the number of queries.
[0050] As an optional implementation manner of this embodiment, before obtaining the target entity information, connection relationships, and target data of each entity based on the target input parameters, the method for constructing a knowledge graph provided in this embodiment further includes:
[0051] 1) Receiving initial knowledge graph input parameters and determining whether the initial knowledge graph input parameters are correct based on standard parameters.
[0052] Specifically, the initial knowledge graph input parameters input by the user can be received through a user interface (such as a web form, API interface, etc.). The initial knowledge graph input parameters can include information such as a data source path, entity types (source entity, target entity), relationship types (relationships such as creator - created version), and filtering conditions.
[0053] According to the above description, after receiving the initial knowledge graph input parameters, it can be determined whether the initial knowledge graph input parameters are correct based on the standard parameters. Among them, the standard parameters can be pre - set qualified parameters. Determining whether the initial knowledge graph input parameters are correct based on the standard parameters can include: checking whether the initial knowledge graph input parameters are complete based on the standard parameters, for example, whether necessary fields (such as entity names, relationship types, etc.) are included; checking whether the types of the initial knowledge graph input parameters are correct based on the types of the standard parameters, for example, whether the entity name is a string and whether the relationship type is within the predefined range. If the parameters do not meet the requirements, an error prompt can be returned and subsequent operations can be terminated.
[0054] 2) When the initial knowledge graph input parameters are correct, pre - processing the initial knowledge graph input parameters to determine the target input parameters.
[0055] Continuing with the above description, when the initial knowledge graph input parameters are correct, the initial knowledge graph input parameters can be preprocessed to determine the target input parameters. The preprocessing may include parsing and formatting the received initial knowledge graph input parameters to ensure the structuring and consistency of the target input parameters.
[0056] As an optional implementation manner of this embodiment, based on the target input parameters, obtain the target entity information of each entity, including:
[0057] 1) Determine the initial entity information based on the entity list; the initial entity information includes at least the entity name, entity type, and entity description of each entity.
[0058] Specifically, the entity list can be traversed to extract the initial entity information, and the initial entity information includes fields such as the entity name, entity type, and entity description of each entity.
[0059] 2) Perform deduplication processing and standardization processing on the initial entity information to determine the target entity information.
[0060] Specifically, after obtaining the initial entity information, deduplication processing and standardization processing can also be performed on the initial entity information. Deduplication processing is performed on the extracted entities to avoid the same entity being recognized multiple times; the entity names are uniformly standardized, for example, removing extra spaces and unifying the case; the entity types are mapped, and if the input type is an alias, it is mapped to the standard type; text cleaning is performed on the entity descriptions to remove special characters or illegal content.
[0061] Embodiment Two
[0062] Figure 2 The flowchart of a knowledge graph query method provided for Embodiment Two of the present disclosure. This embodiment is applicable to the situation of querying a knowledge graph. This method can be executed by a knowledge graph query device, and the knowledge graph query device can be implemented in the form of hardware and / or software. The knowledge graph query device can be configured in an electronic device, and the electronic device includes, but is not limited to, devices with data processing capabilities such as computers, laptops, terminals, and servers. As Figure 1 shown, this method includes:
[0063] S210. Obtain the target query parameters input by the user; the target query parameters include at least the entity type, relationship type, and query depth.
[0064] Specifically, the target query parameters input by the user can be obtained. The interface can be an API interface. The target query parameters can include: entity type, relationship type, and query depth. Among them, the entity type can be the entity type specified by the user to query, the relationship type can be the query type specified by the user, and the query depth can be the depth of the query specified by the user (such as querying the directly associated entities of the entity or deeper-level associations). The target query parameters can also include entity name and query conditions. Among them, the entity name can be the entity name specified by the user to query, and the query condition can be the relationship type specified by the user to query.
[0065] It should be noted that the received target query parameters can also be verified to ensure that the format and content of the target query parameters are legal.
[0066] S220. Construct a query statement based on the target query parameters, and query the target knowledge graph based on the query statement to determine the query result; the query result includes entities and the connection relationships of the entities.
[0067] Specifically, the received target query parameters can be parsed, and a query statement can be constructed according to the parsed target query parameters; the constructed query statement is sent to the database to query the target knowledge graph to obtain the query result, and the query result can include a set of entities and the connection relationships of the entities. Among them, the target knowledge graph is obtained based on the knowledge graph construction method described in any embodiment of the present disclosure.
[0068] S230. Output knowledge graph data based on the query result.
[0069] Specifically, after obtaining the query result, the knowledge graph data can be output based on the query result.
[0070] This embodiment provides a method for querying a knowledge graph, including: obtaining target query parameters input by a user; the target query parameters at least include entity type, relationship type, and query depth; constructing a query statement based on the target query parameters, and querying a target knowledge graph based on the query statement to determine a query result; the query result includes entities and the connection relationships of the entities; outputting knowledge graph data based on the query result; among them, the target knowledge graph is obtained based on the knowledge graph construction method described in any embodiment of the present disclosure, which improves the query efficiency of the knowledge graph and reduces the number of queries.
[0071] As an optional implementation manner of this embodiment, the outputting the knowledge graph data based on the query result includes:
[0072] 1) Process the query result based on preset query conditions to determine a target query result.
[0073] Specifically, the query results can be processed based on preset query conditions to determine the target query results. The preset query conditions can be pre-set query conditions. Exemplarily, the query results can be filtered according to the query conditions specified by the user (such as time range, attribute value range).
[0074] 2) Perform semantic optimization processing on the target query results based on business requirements, and output knowledge graph data based on the target query results after semantic optimization processing.
[0075] Specifically, the processed target query results can be further combined and calculated based on business requirements: for example, the target query results can be summarized; semantic processing can also be performed on the target query results to make it easy for users to understand.
[0076] Embodiment III
[0077] Figure 3 is a schematic structural diagram of a knowledge graph construction device provided in Embodiment III of the present disclosure; as Figure 3 shown, the device includes: an acquisition module 310, an initial knowledge graph determination module 320, and a target knowledge graph determination module 330.
[0078] Among them, the acquisition module 310 is used to obtain the target entity information, connection relationship, and target data of each entity based on the target input parameters; the target input parameters include an entity list, entity type, relationship type, and data source path; the target entity information is determined based on the entity list; the connection relationship is determined based on the entity type and the relationship type; the target data is the database pointed to by the data source path;
[0079] The initial knowledge graph determination module 320 is used to determine an initial knowledge graph using a graph data structure based on the target entity information, the connection relationship, and the target data; the nodes of the initial knowledge graph are entities; the edges of the initial knowledge graph are the connection relationships between entities;
[0080] The target knowledge graph determination module 330 is used to optimize the structure of the initial knowledge graph to obtain a target knowledge graph.
[0081] Embodiment III of the present disclosure provides a knowledge graph construction device, which realizes the storage of accurate data in the knowledge graph, prevents misoperation of other knowledge graphs, and improves the query efficiency of the knowledge graph.
[0082] Furthermore, the device further includes:
[0083] a receiving module, configured to receive initial knowledge graph input parameters and determine whether the initial knowledge graph input parameters are correct based on standard parameters;
[0084] A preprocessing module, configured to preprocess the initial knowledge graph input parameters to determine the target input parameters when the initial knowledge graph input parameters are correct.
[0085] Further, the acquisition module 310 is further configured to:
[0086] Determine initial entity information based on the entity list; the initial entity information includes at least the entity name, entity type, and entity description of each entity;
[0087] Perform deduplication processing and standardization processing on the initial entity information to determine the target entity information.
[0088] The knowledge graph construction device provided by the embodiments of the present disclosure can execute the knowledge graph construction method provided by any embodiment of the present disclosure, and has corresponding functional modules and beneficial effects for executing the method.
[0089] Embodiment 4
[0090] Figure 4 It is a schematic structural diagram of a knowledge graph query device provided by Embodiment 4 of the present disclosure; as Figure 4 shown, the device includes: a target query parameter determination module 410, a query result determination module 420, and a knowledge graph data output module 430.
[0091] Among them, the target query parameter determination module 410 is configured to obtain the target query parameters input by the user; the target query parameters include at least an entity type, a relationship type, and a query depth;
[0092] The query result determination module 420 is configured to construct a query statement based on the target query parameters, and query the target knowledge graph based on the query statement to determine a query result; the query result includes entities and the connection relationships of the entities;
[0093] The knowledge graph data output module 430 is configured to output knowledge graph data based on the query result;
[0094] Among them, the target knowledge graph is obtained based on the knowledge graph construction method described in any embodiment of the embodiments of the present disclosure.
[0095] Embodiment 4 of the present disclosure provides a knowledge graph query device, which improves the query efficiency of the knowledge graph.
[0096] Further, the knowledge graph data output module 430 is further configured to:
[0097] Process the query result based on a preset query condition to determine a target query result;
[0098] Semantically optimize the target query result based on business requirements, and output knowledge graph data based on the semantically optimized target query result.
[0099] The knowledge graph query device provided by the embodiments of the present disclosure can execute the knowledge graph query method provided by any embodiment of the embodiments of the present disclosure, and has corresponding functional modules and beneficial effects for executing the method.
[0100] Embodiment Five
[0101] Figure 5 FIG. shows a schematic structural diagram of an electronic device 10 that can be used to implement the embodiments of the present disclosure. The electronic device is intended to represent various forms of digital computers, such as, for example, a laptop computer, a desktop computer, a workbench, a personal digital assistant, a server, a blade server, a mainframe computer, and other suitable computers. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the embodiments of the present disclosure described and / or claimed herein.
[0102] As Figure 5 shown, the electronic device 10 includes at least one processor 11, and a memory communicatively connected to the at least one processor 11, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc. Among them, the memory stores a computer program executable by the at least one processor. The processor 11 can execute various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 into the random access memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. The input / output (I / O) interface 15 is also connected to the bus 14.
[0103] Multiple components in the electronic device 10 are connected to the I / O interface 15, including: an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a disk, an optical disc, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0104] The processor 11 may be various general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microprocessor, etc. The processor 11 executes the various methods and processes described above, such as the method for constructing a knowledge graph or the method for querying a knowledge graph.
[0105] In some embodiments, the method for constructing a knowledge graph or the method for querying a knowledge graph may be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as the storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or installed onto the electronic device 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the method for constructing a knowledge graph or the method for querying a knowledge graph described above may be executed. Alternatively, in other embodiments, the processor 11 may be configured to execute the method for constructing a knowledge graph or the method for querying a knowledge graph in any other suitable manner (e.g., by means of firmware).
[0106] The various embodiments of the systems and techniques described above in this document may be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-a-chip (SOCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include: being implemented in one or more computer programs, which may be executed and / or interpreted on a programmable system including at least one programmable processor, the programmable processor may be a special or general-purpose programmable processor, and may receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit the data and instructions to the storage system, the at least one input device, and the at least one output device.
[0107] The computer program for implementing the method of the embodiments of the present disclosure may be written in any combination of one or more programming languages. These computer programs may be provided to the processor of a general-purpose computer, a special-purpose computer, or other programmable data processing devices, such that when the computer program is executed by the processor, the functions / operations specified in the flowchart and / or block diagram are implemented. The computer program may be executed entirely on the machine, partially on the machine, as an independent software package partially on the machine and partially on a remote machine, or entirely on a remote machine or server.
[0108] In the context of the embodiments of the present disclosure, a computer-readable storage medium may be a tangible medium that can contain or store a computer program for use by or in connection with an instruction execution system, apparatus, or device. The computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. Alternatively, the computer-readable storage medium may be a machine-readable signal medium. More specific examples of the machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0109] To provide for interaction with a user, the systems and techniques described herein can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or a trackball) by which the user can provide input to the electronic device. Other kinds of devices can also be used to provide for interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0110] The systems and techniques described herein can be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer having a graphical user interface or a web browser through which the user can interact with an implementation of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.
[0111] A computing system may include a client and a server. The client and the server are generally far from each other and usually interact via a communication network. The relationship between the client and the server is created by computer programs running on respective computers and having a client-server relationship with each other. The server can be a cloud server, also known as a cloud computing server or a cloud host, which is a host product in the cloud computing service system, solving the defects of difficult management and weak business scalability existing in traditional physical hosts and VPS services.
[0112] It should be understood that various forms of the processes shown above can be used, with steps reordered, added, or deleted. For example, the steps recited in the embodiments of the present disclosure can be executed in parallel, sequentially, or in a different order, as long as the desired results of the technical solutions of the embodiments of the present disclosure can be achieved, and no limitations are imposed herein.
[0113] The above specific embodiments do not constitute a limitation on the protection scope of the embodiments of the present disclosure. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the embodiments of the present disclosure shall be included within the protection scope of the embodiments of the present disclosure.
[0114] The embodiments of the present disclosure also provide a computer program product, including a computer program and / or instructions, which, when executed by a processor, implement the method for constructing a knowledge graph or the method for querying a knowledge graph provided in any embodiment of the present application.
[0115] In the process of implementing the computer program product, computer program code for performing the operations of the embodiments of the present disclosure can be written in one or more programming languages or combinations thereof. The programming languages include object-oriented programming languages such as Java, Smalltalk, and C++, and also include conventional procedural programming languages such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, executed as an independent software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer can be connected to the user's computer through any type of network - including a local area network (LAN) or a wide area network (WAN) - or can be connected to an external computer (for example, by using an Internet service provider to connect through the Internet).
[0116] Note that the above is only the preferred embodiment of the present disclosure and the applied technical principles. Those skilled in the art will understand that the embodiments of the present disclosure are not limited to the specific embodiments here, and various obvious changes, re-adjustments and substitutions can be made by those skilled in the art without departing from the protection scope of the embodiments of the present disclosure. Therefore, although the embodiments of the present disclosure have been described in more detail through the above embodiments, the embodiments of the present disclosure are not limited to the above embodiments only. Without departing from the concept of the embodiments of the present disclosure, more other equivalent embodiments can be included, and the scope of the embodiments of the present disclosure is determined by the scope of the appended claims.
Claims
1. A method for constructing a knowledge graph, characterized in that: include: Obtain target entity information, connection relationships, and target data for each entity based on target input parameters; The target input parameters include entity list, entity type, relationship type and data source path; The target entity information is determined based on the entity list; the connection relationship is determined based on the entity type and the relationship type; The target data is the database pointed to by the data source path; Based on the target entity information, the connection relationship and the target data, determining an initial knowledge graph using a graph data structure; The nodes of the initial knowledge graph are entities; the edges of the initial knowledge graph are connection relationships between entities; The structure of the initial knowledge graph is optimized to obtain a target knowledge graph.
2. The method according to claim 1, characterized in that Before acquiring target entity information, connection relationship and target data of each entity based on the target input parameter, the method further includes: Receiving initial knowledge graph input parameters, and determining whether the initial knowledge graph input parameters are correct based on standard parameters; When the initial knowledge graph input parameters are correct, the initial knowledge graph input parameters are preprocessed to determine the target input parameters.
3. The method according to claim 2, characterized in that Gets target entity information for each entity based on the target input parameter, including: Determine initial entity information based on the entity list; the initial entity information at least includes an entity name, an entity type and an entity description of each entity; The initial entity information is deduplicated and standardized to determine the target entity information.
4. A knowledge graph query method, characterized in that: include: Get the target query parameters entered by the user; The target query parameters include at least entity type, relationship type and query depth; Constructing a query statement based on the target query parameters, and querying the target knowledge graph based on the query statement to determine the query result; The query result includes entities and connection relationships between entities; Outputting knowledge graph data based on the query result; Wherein, the target knowledge graph is obtained based on the knowledge graph construction method described in claims 1-3.
5. The method according to claim 4, characterized in that The outputting the knowledge graph data based on the query result includes: Processing the query results based on preset query conditions to determine target query results; The target query result is semantically optimized based on business needs, and the knowledge graph data is output based on the semantically optimized target query result.
6. A device for constructing a knowledge graph, characterized in that: include: An acquisition module, used to acquire target entity information, connection relationship and target data of each entity based on target input parameters; The target input parameters include entity list, entity type, relationship type and data source path; The target entity information is determined based on the entity list; the connection relationship is determined based on the entity type and the relationship type; The target data is the database pointed to by the data source path; An initial knowledge graph determination module, used to determine the initial knowledge graph using a graph data structure based on the target entity information, the connection relationship and the target data; The nodes of the initial knowledge graph are entities; the edges of the initial knowledge graph are connection relationships between entities; The target knowledge graph determination module is used to optimize the structure of the initial knowledge graph to obtain the target knowledge graph.
7. A knowledge graph query device, characterized in that: include: A target query parameter determination module is used to obtain the target query parameters input by the user; The target query parameters include at least entity type, relationship type and query depth; A query result determination module, used to construct a query statement based on the target query parameters, and query the target knowledge graph based on the query statement to determine the query result; The query result includes entities and connection relationships between entities; A knowledge graph data output module, used to output knowledge graph data based on the query result; Wherein, the target knowledge graph is obtained based on the knowledge graph construction method described in claims 1-3.
8. An electronic device, characterized in that: include: at least one processor; as well as, a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the knowledge graph construction method as described in any one of claims 1-3, or the knowledge graph query method as described in claims 4-5.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, it implements the knowledge graph construction method as described in any one of claims 1-3, or the knowledge graph query method as described in claims 4-5.
10. A computer program product, characterized in that The computer program product includes a computer program, which, when executed by a processor, implements the knowledge graph construction method as described in any one of claims 1-3, or the knowledge graph query method as described in claims 4-5.