Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,6 @@ src/patterns/data/**/*.txt
src/patterns/pattern_owl_seed.txt
src/patterns/all_pattern_terms.txt

# End of ODK-managed rules
# End of ODK-managed rules
# Local rules
src/ontology/agro-terms.csv
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

Infrastructure and tooling changes to the AgrO repository. Ontology content releases are tagged `vYYYY-MM-DD` on GitHub.

## feat-73-terms-csv: Release a CSV of AgrO terms

### Added
- `agro-terms.csv` release file: one row per non-obsolete AgrO class with ID, label, definition, parent labels and exact synonyms. It's for agronomists and developers who don't use OWL tools ([#73](https://github.com/AgriculturalSemantics/agro/issues/73)). It's built from the reasoned full release, so parents include inferred superclasses, and it lists only `AGRO_` classes, which leaves out imported upper-level classes. Multiple parents or synonyms are separated by `|`.
- `src/sparql/agro-terms-table.sparql`: the query behind the CSV.
- `agro.Makefile`: an `agro-terms.csv` rule, added to `ASSETS` and `RELEASE_ASSETS` so `make prepare_release` builds it and copies it to the repository root.

## fix-183-agronomic-fertilizer: Fix agronomic fertilizer definition typo

### Fixed
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ AgrO is managed with the [Ontology Development Kit (ODK)](https://github.com/INC
| `src/ontology/agro-idranges.owl` | ID ranges allocated to each editor |
| `src/ontology/agro.Makefile` | Project-specific Makefile overrides (`Makefile` is generated by ODK; do not edit it) |
| `agro.owl`, `agro.obo`, `agro-base.*`, `imports/` | Release files. Do not edit these by hand. |
| `agro-terms.csv` | Release file: one row per AgrO term (ID, label, definition, parents, synonyms) for use without OWL tools |

Run the commands below from `src/ontology`.

Expand Down Expand Up @@ -62,6 +63,8 @@ Build a release and copy it to the repository root:
sh run.sh make prepare_release
```

To rebuild only the term table, run `sh run.sh make agro-terms.csv IMP=false PAT=false MIR=false`.

Regenerate the ODK-managed files after changing `agro-odk.yaml` or upgrading ODK:

```bash
Expand Down
12 changes: 12 additions & 0 deletions src/ontology/agro.Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,15 @@
##
## If you need to customize your Makefile, make
## changes here rather than in the main Makefile

# ----------------------------------------
# agro-terms.csv: flat table of AgrO terms for non-ontologists (#73)
# ----------------------------------------
# Built from the full release so parents include inferred superclasses.
# Only AGRO_ classes are listed, which leaves out imported upper-level classes.

agro-terms.csv: agro.owl $(SPARQLDIR)/agro-terms-table.sparql
$(ROBOT) query --input $< --format csv --query $(SPARQLDIR)/agro-terms-table.sparql $@

ASSETS += agro-terms.csv
RELEASE_ASSETS += agro-terms.csv
28 changes: 28 additions & 0 deletions src/sparql/agro-terms-table.sparql
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# One row per non-obsolete AgrO class: ID, label, definition, parent labels
# and exact synonyms. Used to build agro-terms.csv for non-ontologists.
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX oio: <http://www.geneontology.org/formats/oboInOwl#>
PREFIX IAO: <http://purl.obolibrary.org/obo/IAO_>

SELECT ?id ?label ?definition
(GROUP_CONCAT(DISTINCT ?parent_label; separator="|") AS ?parents)
(GROUP_CONCAT(DISTINCT ?synonym; separator="|") AS ?synonyms)
WHERE {
?cls a owl:Class ;
rdfs:label ?label_literal .
FILTER(STRSTARTS(STR(?cls), "http://purl.obolibrary.org/obo/AGRO_"))
FILTER NOT EXISTS { ?cls owl:deprecated true }
BIND(REPLACE(STR(?cls), "^http://purl.obolibrary.org/obo/AGRO_", "AGRO:") AS ?id)
BIND(STR(?label_literal) AS ?label)
OPTIONAL { ?cls IAO:0000115 ?def_literal . BIND(STR(?def_literal) AS ?definition) }
OPTIONAL {
?cls rdfs:subClassOf ?parent .
?parent rdfs:label ?parent_label_literal .
FILTER(isIRI(?parent))
BIND(STR(?parent_label_literal) AS ?parent_label)
}
OPTIONAL { ?cls oio:hasExactSynonym ?syn_literal . BIND(STR(?syn_literal) AS ?synonym) }
}
GROUP BY ?id ?label ?definition
ORDER BY ?id
Loading