canon¶
The main turtle-canon
module.
canonize(turtle_file)
¶
The main function for running turtle-canon
.
Workflow: - Validate Turtle file. Check the file integrity, readability, writeability and content. - Parse and sort Turtle file's triples. Parse Turtle file using RDFlib. Retrieve triples, sort them, and generate a new RDFlib Graph
from the sorted triples. - Export ontology as Turtle file. Overwriting loaded Turtle file, i.e., overall the canonization is done in-place.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
turtle_file | Path | str | An absolute path or | required |
Returns:
Type | Description |
---|---|
Path | None | If the file has been changed during the canonization, the Turtle file's |
Path | None | location will be returned, otherwise |
Source code in turtle_canon/canon.py
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 |
|
export_ontology(ontology, filename)
¶
Export an ontology as a Turtle file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ontology | Graph | A loaded ontology. | required |
filename | Path | The Turtle file's fully resolved path to export to. | required |
Returns:
Type | Description |
---|---|
bool | Whether or not the exported ontology changed the file at |
Source code in turtle_canon/canon.py
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
|
sort_ontology(turtle_file)
¶
Load and sort triples in ontology.
A validated Turtle file is expected, hence there are no "unnecessary" sanity checks in this function.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
turtle_file | Path | A valid | required |
Source code in turtle_canon/canon.py
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 122 123 124 125 126 |
|
validate_turtle(turtle_file)
¶
Validate a Turtle file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
turtle_file | Path | str | An absolute path or | required |
Returns:
Type | Description |
---|---|
Path | A |
Source code in turtle_canon/canon.py
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 |
|