Base
SemanticKGConstructionBase
Bases: KGConstructionBase
Starting from the layout json, we will have several different ways to extract entities and relationships from the documents
The task will typically into two parts: - Named Entity Recognition: extract entities from the text - input can be: entity list, ontology, or just description - Relationship Extraction: extract relationships between entities
Input will be an array of layout json files, output will be another json with entities and relationships extracted
Source code in Docs2KG/kg_construction/semantic_kg/base.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
|
construct_kg(input_data)
Construct a semantic knowledge graph from input data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
input_data
|
Any
|
Input data to construct the knowledge graph |
required |
Source code in Docs2KG/kg_construction/semantic_kg/base.py
98 99 100 101 102 103 104 105 |
|
load_layout_kg(layout_kg_path)
staticmethod
Load the layout knowledge graph from a file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
layout_kg_path
|
Path
|
Path to the layout knowledge graph file |
required |
Returns:
Name | Type | Description |
---|---|---|
dict |
dict
|
Layout knowledge graph |
Source code in Docs2KG/kg_construction/semantic_kg/base.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
|
update_layout_kg(layout_kg_path, layout_kg)
staticmethod
Update the layout knowledge graph in a file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
layout_kg_path
|
Path
|
Path to the layout knowledge graph file |
required |
layout_kg
|
dict
|
Layout knowledge graph to update |
required |
Source code in Docs2KG/kg_construction/semantic_kg/base.py
86 87 88 89 90 91 92 93 94 95 96 |
|