Multi-source data-based knowledge graph construction method and device, server and storage medium
By judging the source of data and selecting appropriate extraction methods, we can parse structured and heterogeneous data from multiple data sources, store them in non-relational databases, and establish relational attribute associations. This solves the problem of constructing knowledge graphs with multi-source data and achieves Unified processing and mapping of different types of data.
Patent Information
- Application Number
- CN202310354345.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-04-03
- Publication Date
- 2024-10-15
AI Technical Summary
It is difficult to effectively construct a knowledge graph of data from multiple sources with existing technology. Especially when data sources are diverse and constantly updated, it is difficult to comprehensively utilize them to construct a knowledge graph.
By judging the data source, select the preset data extraction method, extract data from multiple data sources, cache it into the data set, parse structured and heterogeneous data, and store it in a non-relational database, based on the preset graph data The model relationship table and relationship fields establish relationship attribute associations and draw knowledge graphs.
It achieves unified extraction and processing of data from different sources, can draw knowledge maps, adapt to attribute processing of heterogeneous data, and solves the problem of multi-source data construction.
Smart Images

Figure CN118779385A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of knowledge graph technology, and in particular to a method, device, server and storage medium for constructing a knowledge graph based on multi-source data. Background Art
[0002] Business management is based on data objects. As the number of database objects continues to grow, their management and maintenance become increasingly complex. A knowledge graph is a series of diverse graphs that display the development and structural relationships of knowledge. It uses visualization techniques to describe knowledge resources and their carriers, and to mine, analyze, construct, map, and display knowledge and its interconnections. Knowledge graphs can fully explore relationships between data.
[0003] A relational database, a key type of database, uses a relational model to organize data, storing data in rows and columns for easy understanding. A series of rows and columns in a relational database is called a table, and a group of tables constitutes a database. Users retrieve data from a database through queries, which are executable code that restricts access to specific areas of the database. The relational model can be understood as a two-dimensional table model, and a relational database is a data organization consisting of two-dimensional tables and the relationships between them. Relational databases can be used to perform association mining on massive amounts of data, forming knowledge graphs.
[0004] In the process of implementing the present invention, the inventors found that since data comes from a variety of sources, most of which do not come from existing databases, and the content of databases is constantly updated over time, it becomes increasingly difficult to create a knowledge graph. Summary of the Invention
[0005] The embodiments of the present invention provide a method, device, server equipment and storage medium for constructing a knowledge graph based on multi-source data to solve the technical problem in the prior art that multiple source data cannot be comprehensively utilized to construct a knowledge graph.
[0006] In a first aspect, an embodiment of the present invention provides a method for constructing a knowledge graph based on multi-source data, comprising:
[0007] Determine the source of the data and select a preset data extraction method based on the source of the data;
[0008] Extract data from the data source according to the preset data extraction method, and cache the extracted data into the data set;
[0009] Parsing data and corresponding at least two relationship attributes from the data set, the data comprising: structured data and heterogeneous data;
[0010] Storing the data and corresponding relational attributes in a non-relational database;
[0011] According to the preset graph data model relationship table and relationship fields, relationship attribute association relationships are established, and a knowledge graph is drawn based on relationship attribute association relationships, relationship fields and data.
[0012] Furthermore, establishing a relationship attribute association relationship based on the preset graph data model relationship table and relationship fields includes:
[0013] Create one or more relationship tables based on the attribute relationships in the preset graph data model;
[0014] Relationship fields are searched based on the one or more relationship tables, and corresponding data is determined according to the relationship fields.
[0015] Furthermore, extracting data from a data source according to a preset data extraction method includes:
[0016] When the data is network data, segmenting the network data to obtain the part of speech of the segmented words;
[0017] Attributes are added to the words according to the parts of speech to form a standard document format file.
[0018] Furthermore, extracting data from a data source according to a preset data extraction method includes:
[0019] When the data is a spreadsheet file, the spreadsheet file is parsed and read using the task protocol, and data and corresponding attributes are generated using the task id+sheet name combination for each sheet to form a standard document format file.
[0020] Furthermore, extracting data from a data source according to a preset data extraction method includes:
[0021] When the data source is a database, a corresponding query statement is written, and the data in the database is read through the query statement to form a standard document format file.
[0022] In a second aspect, an embodiment of the present invention further provides a device for constructing a knowledge graph based on multi-source data, comprising:
[0023] A judgment module, used to judge the source of the data and select a preset data extraction method according to the source of the data;
[0024] A cache module is used to extract data from a data source according to a preset data extraction method and cache the extracted data into a data set;
[0025] A parsing module, configured to parse data and corresponding at least two relationship attributes from the data set, wherein the data includes: structured data and heterogeneous data;
[0026] A storage module, used for storing the data and corresponding relationship attributes into a non-relational database;
[0027] The drawing module is used to establish relationship attribute association relationships based on the preset graph data model relationship table and relationship fields, and draw a knowledge graph based on the relationship attribute association relationships, relationship fields and data.
[0028] Furthermore, the establishment module includes:
[0029] An establishment unit, used to establish one or more relationship tables according to the attribute relationship in the preset graph data model;
[0030] The determining unit is configured to search for relationship fields based on the one or more relationship tables, and determine corresponding data according to the relationship fields.
[0031] Furthermore, the cache module includes:
[0032] A word segmentation unit, for segmenting the network data when the data is network data, and obtaining the part of speech of the segmented words;
[0033] The adding unit is used to add attributes to the word according to the part of speech to form a standard document format file.
[0034] Furthermore, the cache module includes:
[0035] The combination unit is used to parse and read the spreadsheet file using the task protocol when the data is a spreadsheet file, and generate data and corresponding attributes based on the task id + sheet name combination for each sheet to form a standard document format file.
[0036] Furthermore, the cache module includes:
[0037] The writing unit is used to write corresponding query statements when the data source is a database, read the data in the database through the query statements, and form a standard document format file.
[0038] In a third aspect, an embodiment of the present invention further provides a server, comprising:
[0039] one or more processors;
[0040] a storage device for storing one or more programs;
[0041] When the one or more programs are executed by the one or more processors, the one or more processors implement the method for constructing a knowledge graph based on multi-source data as provided in any of the above embodiments.
[0042] In a fourth aspect, an embodiment of the present invention further provides a storage medium comprising computer-executable instructions, which, when executed by a computer processor, are used to execute any of the methods for constructing a knowledge graph based on multi-source data provided in the above embodiments.
[0043] The method, device, server and storage medium for constructing a knowledge graph based on multi-source data provided by the embodiment of the present invention determine the source of the data and select a preset data extraction method according to the source of the data; extract data from the data source according to the preset data extraction method, and cache the extracted data into a data set; parse data and corresponding at least two relationship attributes from the data set, the data including: structured data and heterogeneous data; store the data and corresponding relationship attributes in a non-relational database; establish relationship attribute association relationships based on the preset graph data model relationship table and relationship fields, and draw a knowledge graph based on the relationship attribute association relationships, relationship fields and data. Data can be extracted according to a set format for data from different sources and cached in a data set, and the corresponding attributes and data are stored together in the database, and a knowledge graph is drawn based on the relationship attribute association relationships. Corresponding data extraction can be performed for different types of data, and data attributes can be processed for heterogeneous data non-relational databases to draw a knowledge graph. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] Other features, objects and advantages of the present invention will become more apparent upon reading the detailed description of non-limiting embodiments made with reference to the following drawings:
[0045] Figure 1 This is a flowchart of a method for constructing a knowledge graph based on multi-source data provided in the first embodiment of the present invention;
[0046] Figure 2 Schematic diagram of the structure of a device for constructing a knowledge graph based on multi-source data provided in the second embodiment of the present invention;
[0047] Figure 3 It is a structural diagram of the server provided in Example 3 of the present invention. DETAILED DESCRIPTION
[0048] The present invention will be further described in detail below with reference to the accompanying drawings and examples. It will be understood that the specific embodiments described herein are intended only to illustrate the present invention and are not intended to limit the present invention. It should also be noted that, for ease of description, the accompanying drawings only illustrate portions relevant to the present invention, not all structures.
[0049] Example 1
[0050] Figure 1 This is a flowchart of a method for constructing a knowledge graph based on multi-source data, provided in Example 1 of the present invention. This embodiment is applicable to situations where effective information extraction from multi-source data is performed to construct a knowledge graph. The method can be executed by a device for constructing a knowledge graph based on multi-source data and can be integrated into a server. Specifically, the method includes the following steps:
[0051] Step 110 , determining the source of the data and selecting a preset data extraction method according to the source of the data.
[0052] In this embodiment, since the data sources are relatively diverse, multiple methods can be used to extract data from different sources.
[0053] Exemplarily, data sources may include: data in an existing database, data transmitted over the network, and data in a spreadsheet file. Different data extraction methods may be determined based on the data source.
[0054] Step 120: extract data from the data source according to a preset data extraction method, and cache the extracted data into a data set.
[0055] In this embodiment, multiple types of data source access can be supported in the form of data import tasks. After the client completes the import task configuration, the task information is pushed to the system server through redis.
[0056] Exemplarily, extracting data from a data source according to a preset data extraction method may include: when the data is network data, segmenting the network data to obtain the part of speech of the segmented words; adding attributes to the words based on the part of speech to form a standard document format file. Data can be accessed via an HTTP interface protocol to obtain data. An API key for interface access is set and a list of data tables provided by the data source is obtained through the protocol. Based on the segmented words and the part of speech after segmentation, corresponding attributes are added.
[0057] The method of extracting data from a data source according to a preset data extraction method may further include: when the data is a spreadsheet file, using a task protocol to parse and read the spreadsheet file, and generating data and corresponding attributes for each sheet using a task id + sheet name combination to form a standard document format file. Selecting an Excel data source file to be imported, transferring it to a file server via NFS and saving it with the task id + original file name as a new file name. Upon receiving the task protocol, parsing and reading the source data file, and generating a data set using a task id + sheet name combination for each sheet, and writing the document data formed by the Excel data into the data set.
[0058] Extracting data from a data source according to a preset data extraction method may also include: when the data source is a database, writing a corresponding query statement, reading the data in the database through the query statement, and forming a standard document format file. Setting a MySQL database link address, access username, and access password to connect to the MySQL database data source. Furthermore, an SQL statement may be written and sent to a system server for execution. The query results of the SQL statement are parsed and a data set is generated using the combination of the import task ID and the query table name, and the document data formed by the return value is written into the data set.
[0059] Step 130: Parse data and corresponding at least two relationship attributes from the data set, wherein the data includes structured data and heterogeneous data.
[0060] To generate model table fields from source data fields, simply select the source data field you want to use and then configure the field configuration for the graph model data table generated from that field. If the field is set as a relationship attribute or both a relationship attribute and an own attribute, you need to select an existing relationship table and its relationship field from the graph data model intermediate library for that field.
[0061] Step 140: Store the data and corresponding relational attributes in a non-relational database.
[0062] Call the graph data generation service, which reads the graph model database and generates a graph database based on the model data tables and the data in the tables. The graph database is a non-relational database.
[0063] Step 150: Establish relationship attribute association relationships based on the preset graph data model relationship table and relationship fields, and draw a knowledge graph based on the relationship attribute association relationships, relationship fields and data.
[0064] Optionally, the establishment of relationship attribute association relationships based on the preset graph data model relationship tables and relationship fields may include: establishing one or more relationship tables based on the attribute relationships in the preset graph data model; searching for relationship fields based on the one or more relationship tables, and determining corresponding data based on the relationship fields. The data association relationships are reflected using relationship tables. All entity tables in the graph model database are traversed, the relationship attributes of each entity table are judged, the relationship attribute field names are parsed, the relationship entities corresponding to the relationship attributes and their own attributes are located, and the relationship direction is determined based on the direction identifier in the relationship attribute field names. A knowledge graph is generated.
[0065] The embodiment of the present invention determines the source of data and selects a preset data extraction method according to the source of the data; extracts data from the data source according to the preset data extraction method, and caches the extracted data into a data set; parses data and corresponding at least two relationship attributes from the data set, the data including: structured data and heterogeneous data; stores the data and corresponding relationship attributes into a non-relational database; establishes relationship attribute associations based on the preset graph data model relationship table and relationship fields, and draws a knowledge graph based on the relationship attribute associations, relationship fields and data. Data can be extracted from data from different sources in a set format and cached in a data set, and the corresponding attributes and data are stored together in the database, and a knowledge graph is drawn based on the relationship attribute associations. Corresponding data extraction can be performed for different types of data, and data attributes can be processed for heterogeneous data non-relational databases to draw a knowledge graph.
[0066] Example 2
[0067] Figure 2 This is a schematic diagram of the structure of a device for constructing a knowledge graph based on multi-source data provided by the second embodiment of the present invention. Figure 2 As shown, the device includes:
[0068] The determination module 210 is used to determine the source of the data and select a preset data extraction method according to the source of the data;
[0069] The cache module 220 is used to extract data from the data source according to a preset data extraction method and cache the extracted data into a data set;
[0070] A parsing module 230 is configured to parse data and corresponding at least two relationship attributes from the data set, wherein the data includes structured data and heterogeneous data;
[0071] A storage module 240 is used to store the data and corresponding relationship attributes in a non-relational database;
[0072] The drawing module 250 is used to establish relationship attribute association relationships based on the preset graph data model relationship table and relationship fields, and draw a knowledge graph based on the relationship attribute association relationships, relationship fields and data.
[0073] The present embodiment provides a device for constructing a knowledge graph based on multi-source data, which determines the source of the data and selects a preset data extraction method according to the source of the data; extracts data from the data source according to the preset data extraction method, and caches the extracted data into a data set; parses data and corresponding at least two relationship attributes from the data set, wherein the data includes: structured data and heterogeneous data; stores the data and corresponding relationship attributes into a non-relational database; establishes relationship attribute associations based on the preset graph data model relationship table and relationship fields, and draws a knowledge graph based on the relationship attribute associations, relationship fields, and data. Data can be extracted from data from different sources in a set format and cached in a data set, and the corresponding attributes and data are stored together in the database, and a knowledge graph is drawn based on the relationship attribute associations. Corresponding data extraction can be performed for different types of data, and data attributes can be processed for heterogeneous data non-relational databases to draw a knowledge graph.
[0074] Based on the above embodiments, the establishment module includes:
[0075] An establishment unit, used to establish one or more relationship tables according to the attribute relationship in the preset graph data model;
[0076] The determining unit is configured to search for relationship fields based on the one or more relationship tables, and determine corresponding data according to the relationship fields.
[0077] Based on the above embodiments, the cache module includes:
[0078] A word segmentation unit, for segmenting the network data when the data is network data, and obtaining the part of speech of the segmented words;
[0079] The adding unit is used to add attributes to the word according to the part of speech to form a standard document format file.
[0080] Based on the above embodiments, the cache module includes:
[0081] The combination unit is used to parse and read the spreadsheet file using the task protocol when the data is a spreadsheet file, and generate data and corresponding attributes based on the task id + sheet name combination for each sheet to form a standard document format file.
[0082] Based on the above embodiments, the cache module includes:
[0083] The writing unit is used to write corresponding query statements when the data source is a database, read the data in the database through the query statements, and form a standard document format file.
[0084] The device for constructing a knowledge graph based on multi-source data provided in an embodiment of the present invention can execute the method for constructing a knowledge graph based on multi-source data provided in any embodiment of the present invention, and has functional modules and beneficial effects corresponding to the execution method.
[0085] Example 3
[0086] Figure 3 This is a schematic diagram of the structure of the server provided in Example 3 of the present invention. Figure 3 A block diagram of an exemplary server 12 suitable for use in implementing embodiments of the present invention is shown. Figure 3 The server 12 shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.
[0087] like Figure 3 As shown, server 12 is implemented as a general-purpose computing device. Components of server 12 may include, but are not limited to, one or more processors or processing units 16, system memory 28, and a bus 18 that connects various system components (including system memory 28 and processing units 16).
[0088] Bus 18 represents one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a processor, or a local bus using any of a variety of bus architectures. Examples of these architectures include, but are not limited to, an Industry Standard Architecture (ISA) bus, a Micro Channel Architecture (MAC) bus, an Enhanced ISA bus, a Video Electronics Standards Association (VESA) local bus, and a Peripheral Component Interconnect (PCI) bus.
[0089] The server 12 typically includes a variety of computer system readable media. These media can be any available media that can be accessed by the server 12, including volatile and non-volatile media, removable and non-removable media.
[0090] System memory 28 may include computer system readable media in the form of volatile memory, such as random access memory (RAM) 30 and / or cache 32. Server 12 may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, storage system 34 may be configured to read and write non-removable, non-volatile magnetic media ( Figure 3 Not shown, often called a "hard drive"). Although Figure 3Not shown, a magnetic disk drive for reading and writing to a removable non-volatile magnetic disk (e.g., a "floppy disk"), and an optical disk drive for reading and writing to a removable non-volatile optical disk (e.g., a CD-ROM, DVD-ROM, or other optical media) may be provided. In these cases, each drive may be connected to bus 18 via one or more data media interfaces. System memory 28 may include at least one program product having a set (e.g., at least one) of program modules configured to perform the functions of various embodiments of the present invention.
[0091] A program / utility 40 having a set (at least one) of program modules 42 may be stored, for example, in system memory 28. Such program modules 42 include, but are not limited to, an operating system, one or more application programs, other program modules, and program data, each of which, or some combination thereof, may include an implementation of a network environment. Program modules 42 generally perform the functions and / or methods of the embodiments described herein.
[0092] The server 12 may also communicate with one or more external devices 14 (e.g., a keyboard, pointing device, display 24, etc.), one or more devices that enable a user to interact with the server 12, and / or any device that enables the server 12 to communicate with one or more other computing devices (e.g., a network card, a modem, etc.). Such communication may occur via an input / output (I / O) interface 22. Furthermore, the server 12 may communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network such as the Internet) via a network adapter 20. As shown, the network adapter 20 communicates with the other modules of the server 12 via a bus 18. It should be understood that, although not shown, other hardware and / or software modules may be used in conjunction with the server 12, including but not limited to microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0093] The processing unit 16 executes various functional applications and data processing by running programs stored in the system memory 28, such as implementing the method for constructing a knowledge graph based on multi-source data provided in an embodiment of the present invention.
[0094] Example 4
[0095] Embodiment 4 of the present invention also provides a storage medium containing computer-executable instructions, which, when executed by a computer processor, are used to execute any of the methods for constructing a knowledge graph based on multi-source data provided in the above embodiments.
[0096] The computer storage medium of the embodiment of the present invention may adopt any combination of one or more computer-readable media. The computer-readable medium may be a computer-readable signal medium or a computer-readable storage medium. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or component, or any combination thereof. More specific examples (a non-exhaustive list) of computer-readable storage media include: an electrical connection with one or more wires, a portable computer disk, 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 disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In this document, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device.
[0097] A computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, which carries computer-readable program code. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium that can transmit, propagate, or transport a program for use by or in conjunction with an instruction execution system, apparatus, or device.
[0098] Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
[0099] Computer program code for performing the operations of the present invention may be written in one or more programming languages, or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a stand-alone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may 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 may be connected to an external computer (e.g., through the Internet using an Internet service provider).
[0100] Note that the above are only preferred embodiments of the present invention and the technical principles employed. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and that various obvious changes, readjustments, and substitutions can be made by those skilled in the art without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in detail through the above embodiments, the present invention is not limited to the above embodiments and may include many other equivalent embodiments without departing from the concept of the present invention. The scope of the present invention is determined by the scope of the appended claims.
Claims
1. A method for constructing a knowledge graph based on multi-source data, characterized in that: include: Determine the source of the data, and select a preset data extraction method according to the source of the data; Extract data from the data source according to the preset data extraction method, and cache the extracted data into the data set; Parsing data and corresponding at least two relationship attributes from the data set, the data comprising: structured data and heterogeneous data; storing the data and corresponding relational attributes in a non-relational database; According to the preset graph data model relationship table and relationship fields, relationship attribute association relationships are established, and a knowledge graph is drawn based on relationship attribute association relationships, relationship fields and data.
2. The method according to claim 1, characterized in that: The establishing of a relationship attribute association relationship based on a preset graph data model relationship table and relationship fields includes: Establish one or more relationship tables based on the attribute relationships in the preset graph data model; The relationship fields are searched based on the one or more relationship tables, and corresponding data is determined according to the relationship fields.
3. The method according to claim 1, characterized in that: The extracting data from the data source according to the preset data extraction method includes: When the data is network data, segmenting the network data to obtain the part of speech of the segmented words; Attributes are added to the words according to the parts of speech to form a standard document format file.
4. The method according to claim 1, characterized in that: The extracting data from the data source according to the preset data extraction method includes: When the data is a spreadsheet file, the spreadsheet file is parsed and read using the task protocol, and data and corresponding attributes are generated in a combination of task id+sheet name for each sheet to form a standard document format file.
5. The method according to claim 1, characterized in that The extracting data from the data source according to the preset data extraction method includes: When the data source is a database, a corresponding query statement is written, and the data in the database is read through the query statement to form a standard document format file.
6. A device for constructing a knowledge graph based on multi-source data, characterized in that: include: A determination module, used to determine the source of the data and select a preset data extraction method according to the source of the data; A cache module is used to extract data from a data source according to a preset data extraction method and cache the extracted data into a data set; A parsing module, used to parse data and corresponding at least two relationship attributes from the data set, wherein the data includes: structured data and heterogeneous data; A storage module, used for storing the data and corresponding relational attributes into a non-relational database; The drawing module is used to establish relationship attribute association relationships according to the preset graph data model relationship table and relationship fields, and draw a knowledge graph based on the relationship attribute association relationships, relationship fields and data.
7. The device according to claim 6, characterized in that The establishment module comprises: An establishing unit, used to establish one or more relationship tables according to the attribute relationship in the preset graph data model; The determination unit is used to search for the relationship field based on the one or more relationship tables, and determine the corresponding data according to the relationship field.
8. A server, characterized in that: The server comprises: one or more processors; A storage device for storing one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the method for constructing a knowledge graph based on multi-source data as described in claims 1-5.
9. A storage medium containing computer executable instructions, characterized in that: The computer executable instructions, when executed by a computer processor, are used to execute the method for constructing a knowledge graph based on multi-source data as described in any one of claims 1-5.
