Data storage method based on knowledge graph and construction method of knowledge graph
Technical Field
The invention relates to the technical field of knowledge graphs, in particular to a data storage method based on a knowledge graph.
Background
Big data refers to massive, high growth rate and diverse information assets. Nowadays, the application of big data is more and more, and electronic commerce, O2O, logistics distribution and the like are comprehensively improved and optimized through big data analysis, and the judgment of consumer behaviors, the prediction of product sales volume, accurate marketing range and the supply of inventory. With the development of big data technology, the requirements of people on data are not limited to massive traditional data, data workers and scientists begin to look at the value of exploring deeper data, and knowledge maps are produced.
Knowledge map (Knowledge Graph) is a series of different graphs displaying Knowledge development process and structure relationship in the book intelligence field, describing Knowledge resources and carriers thereof by using visualization technology, mining, analyzing, constructing, drawing and displaying Knowledge and mutual relation between Knowledge resources and Knowledge carriers. At present, the research and development center of gravity of knowledge maps focuses on how to make data visualization better and how to realize a stronger map calculation method, so that a plurality of visualization map layouts with standard definitions, such as hierarchical layouts, gravimetry layouts, grid layouts and the like, appear, and the map platform has thinking and calculation capabilities due to the support of classical map calculations such as Pagerank, LPA and the like. The knowledge graph is really an important two-aspect technology in the knowledge graph field, but the knowledge aims at spreading, copying, sharing and cooperation, the current knowledge graph is independently constructed by different application persons based on own application, and the spreading and sharing of the knowledge graph are lacked, so that the efficiency of constructing the knowledge graph is low.
Disclosure of Invention
The invention aims to provide a data storage method based on a knowledge graph, so as to enhance the spreading property and the sharing property of the knowledge graph and further improve the construction efficiency of the knowledge graph.
In order to achieve the above object, the embodiments of the present invention provide the following technical solutions:
a data storage method based on knowledge graph includes the following steps:
acquiring the loaded node and edge data in the current canvas from the gallery, and backing up to obtain the backup data of the knowledge graph displayed in the current canvas;
updating the backup data according to the operation of a user on the knowledge graph displayed in the current canvas;
and acquiring and storing the position information of each node in the knowledge graph displayed in the current canvas.
According to the method, the nodes and the side data of the knowledge graph displayed in the current canvas are backed up, and each operation of the user is recorded at the same time, the updated backup data each time is the data corresponding to the new knowledge graph obtained after each operation of the user, namely, the new knowledge graph obtained after each operation is stored, so that the stored knowledge graph can be called directly later, reconstruction is avoided, and then the construction efficiency of the knowledge graph can be improved.
In the above method, after updating the backup data, the method further includes: and storing the knowledge graph displayed in the current canvas in a picture format. In another aspect, the method further comprises the steps of: and saving the knowledge graph displayed in the current canvas in a thumbnail mode, and displaying the knowledge graph in a display column of a current display interface of the display equipment.
And each obtained new knowledge graph is stored in a picture format, so that the appearance of the knowledge graph is saved, and the knowledge graph is convenient for a user to check when being called.
The method further comprises the following steps: and when the updated backup data is called, acquiring corresponding data from the gallery, verifying the updated backup data with the data called from the gallery, and if the updated backup data is not consistent with the data called from the gallery, updating the updated backup data to keep the updated backup data consistent with the data called from the gallery. Through verification, the map snapshot is kept consistent with the data of the map library on the basis of keeping user operation, and error report caused by abnormal nodes or edges appearing at the front end is avoided.
The method further comprises the following steps: after the verification is finished, the method also comprises the following steps: and displaying the knowledge graph corresponding to the called updated backup data in the current canvas, and updating the called updated backup data according to the operation of the knowledge graph displayed in the current canvas by a user.
On the other hand, the embodiment of the invention also provides another implementation method of data storage based on the knowledge graph, which comprises the following steps:
determining a part of nodes and edges selected by a user from a knowledge graph displayed by a current canvas;
acquiring node and edge data corresponding to part of nodes and edges selected by a user from a gallery, and backing up to obtain backup data;
updating the backup data according to the operation of the user on the selected partial nodes and edges;
and acquiring and storing the position information of the part of nodes selected by the user.
In the method, the data of partial nodes and edges selected by the user are stored, namely, a complete knowledge graph is divided into smaller units, and each smaller unit is stored, so that other users can use the knowledge graph more flexibly, the required smaller unit can be obtained without deleting the knowledge graph of a larger unit (such as the knowledge graph stored by the method), and the construction efficiency of the knowledge graph is further improved.
On the other hand, the embodiment of the invention provides a method for constructing a knowledge graph, which comprises the following steps:
calling a knowledge graph selected by a user, and displaying the knowledge graph selected by the user in a current canvas; the knowledge graph selected by the user is obtained by storing the knowledge graph selected by the user by any method;
and receiving and executing an operation instruction of the user on the knowledge graph displayed in the current canvas to obtain a new knowledge graph.
In still another aspect, the present invention also provides a computer-readable storage medium including computer-readable instructions, which, when executed, cause a processor to perform the operations of the method described in the present invention.
In another aspect, an embodiment of the present invention also provides an electronic device, including: a memory storing program instructions; and the processor is connected with the memory and executes the program instructions in the memory to realize the steps of the method in the embodiment of the invention.
Compared with the prior art, the data storage method provided by the invention has the advantages that any user operating the knowledge graph can conveniently multiplex the graph operated by the predecessor, all the operation processes and the calculation processes can be retained without damage, further operation and mining can be continuously carried out on the basis, the construction efficiency of the knowledge graph is greatly improved, and the user operation is facilitated.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings needed to be used in the embodiments will be briefly described below, it should be understood that the following drawings only illustrate some embodiments of the present invention and therefore should not be considered as limiting the scope, and for those skilled in the art, other related drawings can be obtained according to the drawings without inventive efforts.
FIG. 1 is a flow chart of the method of data preservation based on knowledge-graphs provided in example 1.
Fig. 2 is a schematic diagram of a thumbnail of the knowledge-graph saved in embodiment 1 shown in a display interface.
FIG. 3 is a flow chart of the method for data preservation based on knowledge-graph provided in example 2.
Fig. 4a and 4b are schematic diagrams respectively showing the knowledge graph mentioned in embodiment 2 on a display interface.
Fig. 5 is a block diagram showing the components of the electronic apparatus described in the embodiment.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. The components of embodiments of the present invention generally described and illustrated in the figures herein may be arranged and designed in a wide variety of different configurations. Thus, the following detailed description of the embodiments of the present invention, presented in the figures, is not intended to limit the scope of the invention, as claimed, but is merely representative of selected embodiments of the invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments of the present invention without making any creative effort, shall fall within the protection scope of the present invention.
Before describing the process of the present invention, a description will be given of several definitions of terms involved.
Canvas: and displaying a view area of the map.
Side: refers to the line between two points, one line representing a relationship, as shown in fig. 4 a.
Side data: the attribute values of the relationship, e.g., the start node, terminate the end node.
Example 1
Fig. 1 is a flowchart of a data saving method based on a knowledge graph provided in the embodiment, and except for a definite logical relationship, there is no precedence between each step in the execution order.
Specifically, referring to fig. 1, the method for storing data based on a knowledge graph provided in this embodiment includes the following steps:
and S10, acquiring the loaded node and edge data in the current canvas from the gallery, and backing up to obtain the backup data (json data) of the knowledge graph shown in the current canvas. The backup data here is stored separately, i.e. not in the gallery.
And S20, updating the backup data according to the operation of the user on the knowledge graph displayed in the current canvas.
The operation includes deleting or adding nodes, when nodes are deleted or added, corresponding nodes and side data are changed, at the moment, backup data are changed correspondingly, and data corresponding to a new knowledge graph obtained after user operation can be stored. The operation here refers to each operation performed by the user, for example, deleting one node, and for example, deleting another node, each operation process of the user is recorded, and the corresponding data change is updated accordingly.
When the user deletes or adds the nodes, the nodes and the edge data in the graph library are correspondingly updated. In this step, the backup data obtained in step S10 is updated, so that the backup data is consistent with the data in the gallery, and error reporting caused by abnormal nodes or edges occurring at the front end when the stored knowledge graph is called is avoided.
The gallery stores the full data of the knowledge graph, namely all the node and edge data of the whole knowledge graph system, and the backup data stored in the method is the node and edge data corresponding to the knowledge graph displayed on the current canvas after each operation of a user. By storing the node and the edge data corresponding to the knowledge graph obtained by each operation of the user, the new user can conveniently and directly, quickly and efficiently call the data when constructing the knowledge graph.
In a more preferable embodiment, the method further includes step S30: and acquiring and storing the position information of each node in the knowledge graph displayed in the current canvas. It is easy to understand that the position information here is based on the current canvas, that is, based on the pre-established coordinate system, the position coordinates of each node are recorded and saved so as to obtain the structure of the knowledge-graph.
When the node and the side data of the knowledge graph (obtained after user operation) in the current canvas are stored, the position information of each node in the knowledge graph is stored at the same time, the stored knowledge graph can be displayed in the canvas completely and nondestructively through the position information, the node and the side data, and when a new user constructs the new knowledge graph, the graph stored by the previous user can be directly taken out, so that the construction efficiency of the new main view graph is further improved, and the user operation is facilitated.
With continued reference to fig. 1, in a further refinement, the method further includes step S40: and storing the knowledge graph displayed in the current canvas in a picture format. Alternatively, the knowledge graph displayed in the current canvas is saved in the form of a thumbnail and displayed in a display bar of the current display interface of the display device, for example, as shown in fig. 2. In fig. 2, the atlas shown at the lower part in the display interface is the stored knowledge atlas, and the knowledge atlas shown at the upper part is the knowledge atlas displayed in the current canvas.
For the newly generated knowledge graph, the node and the side data of the newly generated knowledge graph are stored, the position information of each node of the newly generated knowledge graph is stored, and the appearance structure of the newly generated knowledge graph is also stored in a picture form, so that the newly generated knowledge graph is convenient for a user to visually check, the user can find the required existing knowledge graph more quickly, the construction efficiency of the new knowledge graph is further accelerated, and the user operation is more convenient.
In a more optimized scheme, when the node and the edge data corresponding to the stored knowledge graph are called, the corresponding data (namely the same knowledge graph structure) are simultaneously obtained from the graph library, the two data are verified, whether the two data are consistent or not is judged, and if the two data are not consistent, the node and the edge data corresponding to the stored knowledge graph are updated to keep the data consistent with the data called from the graph library. If the two are consistent, no processing is performed.
If the user constructs the knowledge graph based on the data in the gallery, then in step S10, the node and edge data are obtained from the gallery; if the user further operates on the basis of the stored knowledge graph, the user selects the required stored knowledge graph, then the node and the side data corresponding to the knowledge graph are taken out, the knowledge graph is displayed in the current canvas, and the node and the side data corresponding to the knowledge graph are updated according to the operation of the user on the knowledge graph displayed in the current canvas. That is to say, the knowledge graph generated after each operation of the user and the corresponding node and edge data thereof are recorded, so that the knowledge graph displayed in the canvas is maintained.
By the data saving method, a user can perform any operation in the knowledge graph (which can be called a graph snapshot) saved by a previous person, the operation process is recorded by the system, and the graph data is verified before the next use. The dynamic circulation process enables the map snapshot to become a workflow capable of being operated by multiple persons in a cooperative manner, and has the characteristics of being capable of being propagated, reused and cooperated.
Example 2
In this embodiment, a data saving method according to another embodiment is provided. Specifically, referring to fig. 3, the method for storing data based on a knowledge graph provided in this embodiment includes the following steps:
s100, determining a part of nodes and edges selected by a user from the knowledge graph displayed by the current canvas. As shown in fig. 4a, when the user needs to save part of the nodes and edges in the knowledge-graph, the part of the nodes and edges that need to be saved are selected by means of checking or circling, as shown in the circle of fig. 4 a.
And S200, acquiring the node and edge data corresponding to part of the nodes and edges selected by the user from the gallery, and backing up to obtain backup data. That is, the data of the partial node and the edge selected by the user is saved, so that the data can be directly called out when other users or the user uses the data next time.
And S300, acquiring and storing the position information of the part of nodes selected by the user. That is, the position information of the node selected by the user is stored, so that the user can not only call the corresponding node and side data, but also call the position information when using, so as to directly reproduce the stored local knowledge graph on the canvas, namely, the structure storage of the local knowledge graph is realized.
And S400, storing the partial nodes and edges selected by the user in the form of thumbnails or original images. Namely, the structural appearance formed by the selected partial nodes and edges is stored, so that the user can visually check the structural appearance when calling.
The above method implements saving of data, structure and shape of the partial node and edge selected by the user, and when the user performs further operation on the basis of the partial node and edge selected by the user, for example, deleting one of the nodes (as shown in fig. 4a and 4 b), the data of the partial node and edge after operation may also be saved at this time. That is, the above method further comprises the steps of: and updating the backup data obtained in the step S200 according to the operation of the user on the selected partial nodes and edges.
Similarly, to ensure consistency of the backup data with the gallery data, when the backup data (i.e., the saved local knowledge graph) is called, the called data also needs to be checked. Accordingly, the above method may further comprise the steps of: when the backup data or the updated backup data is called in step S200, corresponding data is acquired from the gallery, and the backup data or the updated backup data is verified against the data called from the gallery, and if not, the backup data or the updated backup data is updated to keep the same as the data called from the gallery.
Similarly, when the user operates the called knowledge graph, the knowledge graph operated by the user may also be saved, so the method may further include the steps of: and after the verification is finished, displaying the knowledge graph corresponding to the data which is called or updated after being called (when the called data is inconsistent with the gallery data) in the current canvas, and updating the data which is called or updated after being called according to the operation of the user on the knowledge graph displayed in the current canvas.
The method in embodiment 1 is to store all the node and edge data, structure and shape of the knowledge graph shown in the current canvas, and the method in this embodiment is to store part of the node and edge data, structure and shape of the knowledge graph shown in the canvas, and is implemented based on the same inventive concept, and the related points in this embodiment are also referred to the corresponding description in embodiment 1.
Example 3
Based on the data storage method described in the above embodiment 1 or embodiment 2, a new construction method of the knowledge graph can be implemented, that is, the method includes:
calling a knowledge graph selected by a user, and displaying the knowledge graph selected by the user in a current canvas;
and receiving and executing an operation instruction of the user on the knowledge graph displayed in the current canvas to obtain a new knowledge graph.
When a user constructs the knowledge graph, the stored knowledge graph can be called at any link of the whole construction process, such as the middle link of the construction graph. The new map construction method can still be explained here with the aid of fig. 4 a.
When a user needs to call the stored knowledge graph after constructing a part of the knowledge graph (such as a picture structure outside a circle in a canvas shown in fig. 4 a), clicking the knowledge graph (such as the knowledge graph below the display page shown in fig. 4a, which contains 4 nodes and 3 edges) to call the nodes, the edge data and the position information of each node of the knowledge graph from the backup database, and then displaying a spatial structure composed of the called nodes, the edge data and the position information in the current canvas, such as the structure shown in the circle in fig. 4 a. The user is to combine the called knowledge graph with the constructed knowledge graph, so as to receive the splicing instruction of the user, and splice the corresponding node of the called knowledge graph with the corresponding node of the constructed knowledge graph to obtain a new knowledge graph, such as the structure shown in the canvas of fig. 4 a.
As shown in fig. 5, the present embodiment also provides an electronic device, which may include a processor 51 and a memory 52, wherein the memory 52 is coupled to the processor 51. It is noted that this diagram is exemplary and that other types of structures may be used in addition to or in place of this structure to implement data extraction, report generation, communication, or other functionality.
As shown in fig. 5, the electronic device may further include: an input unit 53, a display unit 54, and a power supply 55. It is to be noted that the electronic device does not necessarily have to comprise all the components shown in fig. 5. Furthermore, the electronic device may also comprise components not shown in fig. 5, reference being made to the prior art.
The processor 51, also sometimes referred to as a controller or operational control, may comprise a microprocessor or other processor device and/or logic device, the processor 51 receiving input and controlling operation of the various components of the electronic device.
The memory 52 may be one or more of a buffer, a flash memory, a hard drive, a removable medium, a volatile memory, a non-volatile memory, or other suitable devices, and may store the configuration information of the processor 51, the instructions executed by the processor 51, the recorded table data, and other information. The processor 51 may execute a program stored in the memory 52 to realize information storage or processing, or the like. In one embodiment, a buffer memory, i.e., a buffer, is also included in the memory 52 to store the intermediate information.
Embodiments of the present invention further provide a computer readable instruction, where when the instruction is executed in an electronic device, the program causes the electronic device to execute the operation steps included in the method of the present invention.
Embodiments of the present invention further provide a storage medium storing computer-readable instructions, where the computer-readable instructions cause an electronic device to execute the operation steps included in the method of the present invention.
Those of ordinary skill in the art will appreciate that the elements and algorithm steps of the examples described in connection with the embodiments disclosed herein may be embodied in electronic hardware, computer software, or combinations of both, and that the components and steps of the examples have been described in a functional general in the foregoing description for the purpose of illustrating clearly the interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention.
The integrated unit, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention essentially or partially contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product stored in a storage medium and including instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
Those of ordinary skill in the art will appreciate that the various illustrative modules described in connection with the embodiments disclosed herein may be implemented as electronic hardware, computer software, or combinations of both, and that the various illustrative components and steps have been described above generally in terms of their functionality in order to clearly illustrate the interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention.
In the several embodiments provided in the present application, it should be understood that the disclosed system may be implemented in other ways. For example, the above-described system embodiments are merely illustrative, and for example, the division of the modules is merely a logical division, and in actual implementation, there may be other divisions, for example, multiple modules or components may be combined or integrated into another system, or some features may be omitted, or not implemented.
The above description is only for the specific embodiments of the present invention, but the scope of the present invention is not limited thereto, and any person skilled in the art can easily conceive of the changes or substitutions within the technical scope of the present invention, and all the changes or substitutions should be covered within the scope of the present invention.