ontometer_corpus.fetchers.okg¶
Open Knowledge Graphs (OKG).
About
Fetches all ontologies catalogued at openknowledgegraphs.com and normalises each result to a FetchRecord. The canonical URL is chosen in the order namespaceURI > sourceRepo > homepage.
Many catalogued URLs are github.com repo pages rather than raw files, and a repo homepage exposes no reliable direct link to the ontology file. Such URLs are resolved to a specific raw ontology file via the GitHub API (repo tree, recursive; see _resolve_github_repo_file). Any other URL that returns HTML is scraped for direct ontology file links.
Unauthenticated GitHub API access is rate-limited, so set GITHUB_TOKEN in the environment for a full run.
Registry API: https://openknowledgegraphs.com/data/ontologies.json
Attributes¶
REGISTRY_NAME = 'OKG'
module-attribute
¶
METADATA_URL = 'https://openknowledgegraphs.com/data/ontologies.json'
module-attribute
¶
REQUEST_DELAY = 0.1
module-attribute
¶
ONTOLOGY_EXTS = {'.owl', '.ttl', '.rdf', '.n3', '.nt', '.jsonld'}
module-attribute
¶
GITHUB_API_ROOT = 'https://api.github.com'
module-attribute
¶
Classes¶
Functions:¶
fetch_okg(session, fail_log, objects_dir, manifest_path, resume=None)
¶
Download all OKG ontologies and return a FetchRecord for every attempt (successes and failures alike).
Parameters¶
session
Shared requests.Session (with retry adapter).
fail_log
Path to the failure log (fetch_failures.log in the corpus directory).
manifest_path
Path to manifest.jsonl; each record is appended as soon as it is produced.
objects_dir
Root of the content-addressed object store for raw ontology files.
resume
Set of source_ids already captured on a previous run; these are skipped.
Returns¶
list[FetchRecord] One record per attempted ontology (status ok/fail).
Source code in ontometer_corpus/fetchers/okg.py
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 | |