ods_to_rdf¶
ods_to_rdf
¶
Generate compass.ttl and vocab.ttl from a use-case source-data.ods.
Pin rows carry their own id and link by id in a links column; a link's
predicate follows what it points at, so there is no mapping to configure.
Concepts never link out: a tag is recorded on the pin that carries it, so a
region is on the map only because some pin points at it.
The use-case subdirectory under src/ontology/ is selected by
COMPASS_USE_CASE (default oceancare).
turtle-generator/ods_to_rdf.py regenerate
turtle-generator/ods_to_rdf.py --check exit 1 if the committed files are stale
Subject order, predicate order and float precision are all pinned, so unchanged input produces byte-identical output.
SheetError
¶
Bases: Exception
A defect in the tables that the operator must resolve.
Problems(items=list())
dataclass
¶
Collects every defect in one pass, so a run reports all of them at once.
Fallbacks(counts=dict())
dataclass
¶
Counts German cells that were empty and took the English text instead.
_resolve_use_case()
¶
Return COMPASS_USE_CASE from the environment or repo .env.
Source code in src/turtle-generator/ods_to_rdf.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | |
display(path)
¶
Repo-relative where possible, absolute otherwise, so messages never crash.
Source code in src/turtle-generator/ods_to_rdf.py
190 191 192 193 194 195 | |
_cell_text(cell)
¶
A cell's value, preferring the stored number over its displayed form.
Source code in src/turtle-generator/ods_to_rdf.py
227 228 229 230 231 232 233 234 | |
_row_values(row, width)
¶
Expand a row's cells, honouring the repeat counts spreadsheets pack with.
Source code in src/turtle-generator/ods_to_rdf.py
237 238 239 240 241 242 243 244 245 | |
read_table(name, columns)
¶
Read one sheet of the workbook, requiring exactly the expected header.
Source code in src/turtle-generator/ods_to_rdf.py
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 | |
index_terms(concepts, pins, problems)
¶
Map every id to the dimension or class it belongs to.
Source code in src/turtle-generator/ods_to_rdf.py
303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 | |
parse_links(row, kinds, problems)
¶
Resolve a links cell into objects grouped by the predicate they become.
Source code in src/turtle-generator/ods_to_rdf.py
336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 | |
number(row, column, problems, kind)
¶
Validate a numeric cell, reporting rather than raising on a bad value.
Source code in src/turtle-generator/ods_to_rdf.py
358 359 360 361 362 363 364 365 366 367 368 | |
bilingual(row, column, fallbacks)
¶
The English and German text of a <column>_en / <column>_de pair.
An empty German cell takes the English text, so a German reader never gets a blank where an English one gets prose. Each substitution is counted, so a missing translation stays visible instead of silently shipping.
Source code in src/turtle-generator/ods_to_rdf.py
409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 | |
order_key(triple)
¶
Total order over a subject's triples: predicate, then language, then value.
Source code in src/turtle-generator/ods_to_rdf.py
508 509 510 511 512 513 514 515 516 517 518 519 520 521 | |
generate(fallbacks=None)
¶
The two Turtle files. Pass a Fallbacks to learn which translations are missing.
Source code in src/turtle-generator/ods_to_rdf.py
618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 | |