Automatic construction method of traditional Chinese medicine knowledge graph based on node splitting and node shrinking
By applying node splitting and shrinking techniques in ancient Chinese medicine books, the knowledge graph is constructed, and the problem of multiple meanings and multiple words in ancient Chinese medicine books is solved, and the rapid and accurate knowledge graph construction is achieved, simplifying the creation steps and reducing the Labor costs.
Patent Information
- Application Number
- CN202411814895.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-11
- Publication Date
- 2025-01-10
- Estimated Expiration
- 2044-12-11
AI Technical Summary
The existing knowledge graph construction method is difficult to apply to ancient Chinese books, especially because the grammar in ancient Chinese books is different from modern Chinese, resulting in the problem of multiple meanings and synonyms of multiple words. Existing natural language processing methods such as dictionary semantic disambiguation and Deep learning models are complex in computing and difficult to guarantee accuracy.
Using a method based on node splitting and node shrinking, by constructing a node shrinking splitting table, automates the processing of ancient Chinese medicine texts, creates nodes and establishes relationships, and uses Neo4j database to build a knowledge graph, simplify the steps of creating knowledge graphs, and solves the multiple meanings and multiple words of one word. Synonym question.
It quickly and simply handles node shrinkage and splitting operations in ancient Chinese medicine books, ensures the accuracy and rationality of the fine-grained nodes of the knowledge graph, reduces labor costs, and improves processing efficiency.
Smart Images

Figure CN119294501A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the interdisciplinary research field of traditional Chinese medicine and computer technology, and relates to a method for automatically constructing a traditional Chinese medicine knowledge graph based on node splitting and node contraction. Background Art
[0002] Knowledge Graph is an important branch technology of artificial intelligence. It is a structured semantic knowledge base used to describe concepts and their relationships in the physical world in symbolic form. Its basic components are "entity-relationship-entity" triples, as well as entities and their related attribute-value pairs. Entities are connected to each other through relationships to form a network of knowledge structures. Knowledge graphs are widely used in the field of natural language processing (NLP), such as semantic search, intelligent question and answer, and decision support. They have become an important driving force for the development of artificial intelligence. The knowledge graph architecture is divided into three parts: the first part is the acquisition of source data, that is, obtaining useful resource information from various types of data; the second part is knowledge fusion, which is used to associate knowledge from multiple data sources and expand the scope of knowledge; the third part is knowledge computing and knowledge application. Knowledge computing is the main way to output knowledge graph capabilities, while knowledge application is to combine knowledge graphs with specific fields or businesses to improve business efficiency in various fields.
[0003] With the development of knowledge graph technology and the introduction of smart medicine and precision medicine, artificial intelligence technology has gradually been applied in the field of traditional Chinese medicine. Medical knowledge graphs have shown increasingly important application value, such as in the representation, integration, and reasoning of traditional Chinese medicine knowledge. For example, Treatise on Febrile and Miscellaneous Diseases is a classic work of traditional Chinese medicine for the treatment of exogenous febrile diseases and internal injuries. The construction of the knowledge graph of Treatise on Febrile and Miscellaneous Diseases extracts key elements such as diseases, medication indications, and prescriptions to form structured data, which is a necessary research method for knowledge retrieval, query, and knowledge reasoning.
[0004] However, the currently commonly used knowledge graph construction methods are not fully applicable to the content of ancient Chinese medical books, such as "Treatise on Febrile and Miscellaneous Diseases". This is because the grammar in ancient Chinese medical books is different from the grammar of modern Chinese. For example, the word "headache and neck pain" mentioned therein is actually a polysemous word, that is, it contains two meanings of "headache and neck pain", and cannot be treated as just one node; at the same time, there are also a large number of multi-word synonymous expressions in Chinese medical classics, such as "body pain" and "body pain" have the same meaning. If they are separated as two nodes, it will lead to knowledge redundancy. At present, the commonly used processing methods for natural language processing are dictionary-based semantic disambiguation and semantic-based entity disambiguation. These methods are not suitable for the use scenarios of ancient Chinese medical books, and require the training of deep learning models, with high computational complexity and difficult to guarantee accuracy. Therefore, a new knowledge graph construction method is needed to solve the above problems. Summary of the invention
[0005] In order to solve the above problems, the first object of the present invention is to provide a method for automatically constructing a traditional Chinese medicine knowledge graph based on node splitting and node contraction.
[0006] To achieve the above object, the present invention adopts the following technical solutions: Step S1, segmenting the text of ancient Chinese medical books, and then annotating the text after segmentation with entities and relationships to obtain annotated data; Step S2: Obtaining clause data, entity annotation data and relationship annotation data from the annotation data; Step S3: establishing a node contraction and splitting table according to the entity annotation data; the node contraction and splitting table includes the entity name and entity type to be contracted or split, the node contraction instruction, and the node splitting instruction; Step S4, creating a node for the entity according to the node contraction and splitting table: first determine whether the entity name exists in the node contraction and splitting table, if not, create a regular node, if yes, then determine whether the type of the entity is consistent with the entity type in the node contraction and splitting table, and whether there is a corresponding node contraction instruction or node splitting instruction, if yes, create a contraction node or a split node, if not, create a regular node; Step S5: establishing relationships for nodes according to the relationship annotation data; Step S6: Import the created nodes and relationships into the Neo4j database to complete the construction of the knowledge graph.
[0007] Furthermore, the annotation data in step S1 includes the annotation start position of the entity, the annotation end position of the entity, the entity name, the entity type and the entity number, as well as the sending relationship node number, the receiving relationship node number and the relationship name.
[0008] Furthermore, the entities include diseases, indications, and prescriptions, and the relationships include manifestations, prescriptions, and contraindications.
[0009] Furthermore, when the node splitting command is executed, assuming that node A is connected to node D, node A is automatically split into node B and node C, node A abandons creation, and nodes B and C establish connections with node D respectively.
[0010] Furthermore, when executing the node shrink command, assuming that the E node and the F node have the same meaning and are both connected to the G node, after the node shrinks, the F node abandons creation and merges into the E node. At this time, there is only a connection between the E node and the G node.
[0011] Furthermore, when executing a node splitting command, the node index needs to be adjusted to ensure the accuracy of subsequent node indexes.
[0012] The second object of the present invention is to provide a system for automatically constructing a TCM knowledge graph based on node splitting and node contraction, comprising the following modules: The extraction module is used to extract entities and relations in the text of ancient Chinese medical books; A node creation module is used to create a node contraction and splitting table, and create nodes for entities according to the node contraction and splitting table; The construction module is used to determine the relationship between nodes and construct the knowledge graph of the Treatise on Febrile Diseases system.
[0013] A third object of the present invention is to provide an electronic device, comprising a processor and a memory, wherein the memory stores machine executable instructions that can be executed by the processor, and the processor executes the machine executable instructions to implement the above method.
[0014] The fourth object of the present invention is to provide a machine-readable storage medium, characterized in that the machine-readable storage medium stores machine-executable instructions, and when the machine-executable instructions are called and executed by a processor, the machine-executable instructions prompt the processor to implement the above method.
[0015] Since the present invention adopts node contraction and node splitting technology and automatic program control technology, the following beneficial effects can be obtained: The present invention applies node contraction and node splitting technology to the knowledge graph to solve the problems of polysemy and synonymy of multiple words in ancient Chinese medical books (such as "Treatise on Febrile and Miscellaneous Diseases"). The method is simple and fast. It only needs to build and maintain a node contraction and splitting table to quickly implement node contraction and node splitting operations in the knowledge graph, which simplifies the knowledge graph creation steps and ensures reasonable and accurate knowledge node granularity. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] Figure 1 It is the core method flow chart of the present invention.
[0017] Figure 2 It is a schematic diagram of the node shrinkage technology proposed by the present invention.
[0018] Figure 3 It is a schematic diagram of the node splitting technology proposed in the present invention.
[0019] Figure 4 It is a knowledge graph of "Treatise on Febrile and Miscellaneous Diseases" created based on the technical method proposed in the present invention. DETAILED DESCRIPTION
[0020] The present invention is further described below in conjunction with embodiments and drawings.
[0021] like Figure 1As shown, the present invention provides a method for automatically constructing a traditional Chinese medicine knowledge graph based on node splitting and node contraction. The core idea is to parse the json format file generated by the wizard annotation assistant through a Python program, extract entity data and relationship data, use the entity number as an index, first create entity nodes in the neo4j database, and then establish the relationship between nodes.
[0022] The technical scheme of the method of the present invention is described below using Treatise on Febrile and Miscellaneous Diseases as an example.
[0023] First, we use the Elf Annotation Assistant to perform word segmentation and relationship annotation on the text of "Treatise on Febrile and Miscellaneous Diseases". Here we set 3 tags: disease, indication and prescription; 3 relationships: manifestation, prescription and contraindication. The specific composition of entities and relationships includes: disease-manifestation->indication, indication-prescription->prescription, indication-contraindication->prescription. The Elf Annotation Assistant can realize the rapid annotation of the above entities and relationships. After the entity and relationship annotation is completed, use Python programming to import the annotation data of the Elf Annotation Assistant into the neo4j database to realize the automatic construction of the knowledge graph. The Python program is actually a connector and data converter between the annotated data set and the neo4j database.
[0024] Specifically: Export the annotation file <Treatise on Febrile and Miscellaneous Diseases.json> from the Wizard Annotation Assistant. This file includes all the articles of Treatise on Febrile and Miscellaneous Diseases; the annotation start position, annotation end position, entity name, entity type and entity ID of the annotation entity; the issuing relationship node ID, receiving relationship node ID and relationship name of the annotation relationship.
[0025] Read the "content" data of <Treatise on Febrile and Miscellaneous Diseases.json>. Content includes all the articles of the original Treatise on Febrile and Miscellaneous Diseases. Each article ends with "\r\n". The specific format is: "Differentiation of the Pulse and Symptoms of Taiyang Disease and Its Treatment (Part 1)\r\n1. Taiyang disease has floating pulse, stiff neck and pain, and aversion to cold.\r\n……\r\n".
[0026] Read the "outputs">>"annotation">>"T" data of <Shang Han Za Bing Lun.json>. These data are entity annotation data, and the specific format is: {"type": "T", "name": "disease", "value": "Tai Yang Zhi Wei Bing", "start": 14, "end": 19, "attributes": [], "id": 1}.
[0027] Read the "outputs">>"annotation">>"R" data of <Shang Han Za Bing Lun.json>. These data are relational annotation data, and the specific format is: {"name": "Prescription", "from": 3978, "to": 3979, "arg1": "Arg1", "arg2": "Arg2"}.
[0028] Set up three memories to store the entity ID, entity annotation start position and entity annotation end position respectively. IDs, STARTs and ENDs. Because each entity ID, annotation start position and annotation end position are unique, their indexes in the three memories are consistent.
[0029] Use the dictionary query function to obtain the entity list T and relationship list R from the three-level index (output >> annotation >> category).
[0030] The annotated original text articles of "Treatise on Febrile and Miscellaneous Diseases" are loaded into the article list. The present invention allows loading only one article at a time or loading multiple articles at the same time. Loading only one article can facilitate the inspection of annotation omissions and errors. Loading multiple articles at the same time can discover more associations between entities, and is also a key calculation step for building a complete knowledge graph in the neo4j database.
[0031] Iterate the "content" data of <Shang Han Za Bing Lun.json> word by word, segment the text based on " \n", and calculate all the annotated entities contained in the text, recorded as T1.
[0032] Maintain a data table df_sd for node contraction and node splitting. During the construction of the knowledge graph, the program determines the splitting and contraction of nodes based on the node contraction and splitting data table.
[0033] Create a drawing area G in the neo4j database and clean up the workspace.
[0034] Establish a loop for t in T1: create nodes for entities. Two levels of conditional judgment are required when creating nodes: the first level: meet the node contraction and splitting conditions; meet the general creation conditions; the second level: meet the node contraction conditions, meet the node splitting conditions.
[0035] Create a node that meets the node contraction conditions. First-level condition judgment: The entity name is in the original name list of the node splitting and contracting table and the number is 1. Second-level condition judgment: The corresponding node contraction information unit in df_sd has information, the node splitting information unit has no information, and the node type is consistent with the corresponding type in df_sd. Then it is determined that the node meets the node contraction conditions and the node contraction operation can be performed. Figure 2The specific operation of node shrinking of the present invention is demonstrated.
[0036] Create a node that meets the node splitting conditions. The first-level judgment conditions are the same as above. The second-level condition judgment: the corresponding node contraction information unit in df_sd is empty, the node splitting information unit has information, and the node type is consistent with the corresponding type in df_sd. Node splitting will destroy the entity index, so when performing node splitting, it is necessary to adjust the node index as needed to ensure the accuracy of subsequent node indexes. Here, add the regulation factor regulator to adjust the node index according to the number of node splits. Regulator changes with the node splitting event, regulator = regulator + the number of node splits this time – 1. The global index is i + regulator, and the node splitting index is i + regulator + j. Figure 3 The specific operation of node splitting of the present invention is demonstrated.
[0037] The node is created if the normal conditions are met. If the entity name is not in the original name list of the node splitting and contraction table, the node is created normally.
[0038] In the knowledge graph, nodes of the same type and name are allowed to be created only once. A node list ARRAY needs to be maintained to enforce this rule.
[0039] Create a node information storage unit df_info to store the created node information. The nodes displayed in the knowledge graph are marked with "YES", and the nodes not displayed in the knowledge graph are marked with "NO". df_info includes the old ID, new ID, node type, node name, node information dictionary, whether it is displayed in the knowledge graph, etc. It is used to ensure the accurate creation of node relationships in the future.
[0040] Create a loop for r in R: Create node connections. Here we need to consider the case of node splitting, so we need to add conditional judgment. If the relationship sending node and the relationship receiving node are both the same, the relationship is created normally, otherwise the relationship is created according to the node splitting rule.
[0041] Determine the relationship sending node and the relationship receiving node through the old ID in r, determine the node ID of the sending relationship and the node ID of the receiving relationship according to the node information dictionary in df_info, and draw the relationship connection in the knowledge graph.
[0042] Figure 4The knowledge graph of "Treatise on Febrile Diseases" created based on the technical method of the present invention is demonstrated. In this task, it is necessary to create 2482 nodes (based on labeled data), explicitly create 674 nodes (created in the neo4j database), create 1064 relationships, perform 164 node splits and 323 node shrinks, and the total time consumption is 20.1178 seconds. This proves that the method of the present invention reduces labor costs when processing unstructured data of ancient Chinese medical books, and can flexibly and conveniently handle a large number of polysemy and synonymy problems, ensuring that the knowledge graph has a clear knowledge granularity.
[0043] The above embodiments are the basic principles, main features and advantages of the present invention. The present invention only illustrates the technical aspects and does not limit the protection scope of the present invention. Some improvements made according to the above embodiments are within the protection scope of the present invention.
Claims
1. A method for automatically constructing a TCM knowledge graph based on node splitting and node contraction, characterized in that: The method comprises the following steps: Step S1, segmenting the text of ancient Chinese medical books, and then annotating the text after segmentation with entities and relationships to obtain annotated data; Step S2: Obtaining clause data, entity annotation data and relationship annotation data from the annotation data; Step S3: establishing a node contraction and splitting table according to the entity annotation data; the node contraction and splitting table includes the entity name and entity type to be contracted or split, the node contraction instruction, and the node splitting instruction; Step S4, creating a node for the entity according to the node contraction and splitting table: first determine whether the entity name exists in the node contraction and splitting table, if not, create a regular node, if yes, then determine whether the type of the entity is consistent with the entity type in the node contraction and splitting table, and whether there is a corresponding node contraction instruction or node splitting instruction, if yes, create a contraction node or a split node, if not, create a regular node; Step S5: establishing relationships for nodes according to the relationship annotation data; Step S6: Import the created nodes and relationships into the Neo4j database to complete the construction of the knowledge graph.
2. The method for automatically constructing a TCM knowledge graph based on node splitting and node contraction according to claim 1, characterized in that: The article data includes all text data, the entity annotation data includes the entity name, entity type, entity digital label, and the location of the entity in the text data, and the relationship annotation data includes the relationship type and the entity digital label of the relationship connection.
3. The method for automatically constructing a TCM knowledge graph based on node splitting and node contraction according to claim 1, characterized in that: The entity types include diseases, indications, and prescriptions, and the relationships include manifestations, prescriptions, and contraindications.
4. The method for automatically constructing a TCM knowledge graph based on node splitting and node contraction according to claim 1, characterized in that: When the node splitting command is executed, assuming that node A is connected to node D, node A is automatically split into node B and node C. Node A is abandoned, and nodes B and C establish connections with node D respectively.
5. The method for automatically constructing a TCM knowledge graph based on node splitting and node contraction according to claim 4, characterized in that: When executing a node split command, the node index needs to be adjusted to ensure the accuracy of subsequent node indexes.
6. The method for automatically constructing a TCM knowledge graph based on node splitting and node contraction according to claim 1, characterized in that: When executing the node shrink command, assuming that the E node and the F node have the same meaning and are both connected to the G node, after the node shrinks, the F node is abandoned and merged into the E node. At this time, there is only a connection between the E node and the G node.
7. A system for automatically constructing a TCM knowledge graph based on node splitting and node contraction to implement the method according to any one of claims 1 to 6, Includes the following modules: The extraction module is used to extract entities and relations in the text of ancient Chinese medical books; A node creation module is used to create a node contraction and splitting table, and create nodes for entities according to the node contraction and splitting table; The construction module is used to determine the relationship between nodes and construct the knowledge graph of the Treatise on Febrile Diseases system.
8. An electronic device, comprising a processor and a memory, wherein the memory stores machine executable instructions that can be executed by the processor, and the processor executes the machine executable instructions to implement the method according to any one of claims 1 to 6.
9. A machine-readable storage medium, characterized in that: The machine-readable storage medium stores machine-executable instructions. When the machine-executable instructions are called and executed by a processor, the machine-executable instructions prompt the processor to implement the method described in any one of claims 1-6.
Citation Information
Patent Citations
Method and system for constructing emergency knowledge graph based on Chinese word segmentation technology
CN111191051A
Knowledge graph generation method and device, relation mining method and device, equipment and medium
CN111324643A
Medical knowledge graph construction method
CN111639190A
Semantic culture robot system
CN112199959A
Construction method of knowledge graph of traditional Chinese medicine and ethnic medicine
CN112800244A