Read-only mirror of https://github.com/blw-ofag-ufag/agricheck — Bundesamt für Landwirtschaft. Issues & pull requests at the source.
  • Turtle 48.4%
  • R 30.6%
  • Python 19.9%
  • Shell 1.1%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Damian Oswald 69a781f864
Merge pull request #65 from blw-ofag-ufag/search-function-fixes
Change search function to only consider data in selected language
2026-06-24 13:04:46 +02:00
.github/workflows Add GitHub action runner for tests 2026-04-24 11:55:05 +02:00
docs Merge pull request #65 from blw-ofag-ufag/search-function-fixes 2026-06-24 13:04:46 +02:00
rdf Move 'Environment' to another group 2026-05-08 17:13:51 +02:00
scripts Remove possible outcome integration from Acontrol (not needed by Agricheck) 2026-06-02 17:46:16 +02:00
tests Add YAML validation test 2026-04-24 11:53:32 +02:00
.gitattributes Create .gitattributes 2025-09-25 11:49:06 +02:00
.gitignore Add YAML validation test 2026-04-24 11:53:32 +02:00
.nojekyll Add nojekyll file 2025-04-05 15:33:38 +02:00
LICENSE.md Add remark about *Urheberrecht* 2026-01-05 13:57:20 +01:00
README.md Remove removal of duplicates based on string similarity 2026-04-22 16:14:19 +02:00
requirements.txt Add YAML validation test 2026-04-24 11:53:32 +02:00

AGRICHECK

The current multitude of inspections in both the private and public sectors represents a significant administrative burden for farms in Switzerland. With over 5000 inspection points1 and more than 20 different inspection programs, the system lacks a user-friendly coordination. Existing processes are neither very digitized nor harmonized, leading to redundancies and inefficiencies for both farmers and authorities.

The goal of agricheck is to first collect and harmonize inspection points from both the private and public agricultural sector, and second to provide a simple web application for farmers to quickly search and navigate these inspection points.

The data

The data from various sources is standardized and freely provided in the RDF format via the linked data service LINDAS by the Federal Archive. Here's an example example inspection point as a linked data object on LINDAS.

The data of agricheck is organized hierarchically. Here are the links to the top-level collections:

The data model

The data model was written using OWL, the web ontology language. It is not only used as a map to write queries, but also for a automatic reasoning process. You can inspect the data model here.

Run data integration pipeline

To run the data integration from excel or XML files to standardized RDF turtle files, do the following:

  1. Add variables to .env

    USER=lindas-foag
    PASSWORD=********
    GRAPH=https://lindas.admin.ch/foag/crops
    ENDPOINT=https://stardog.cluster.ldbar.ch/lindas
    
  2. Add all relevant excel data sheets to the /data folder.

  3. Start a virtual environment and install libraries:

    python -m venv venv
    source venv/bin/activate  # On Windows use: venv\Scripts\activate
    pip install -r requirements.txt
    
  4. Run the ETL pipeline

    sh scripts/pipeline.sh
    
  5. Check out the results on LINDAS.

Step 3 executes the R scripts for data conversion (acontrol.R, bioinspecta.R and mutterkuh.R...) as well as the data validation, reasoning and merging validate-syntax.py and reason.py.

Cleaning duplicate descriptions

Note

This feature is deactivated for now. Needs some revisions.

In the source data, some inspection points contain a schema:description value that is nearly identical to their schema:name. Unfortunately, this is often the case for one language but not another, which leads to weird fallback langauge behavior. To fix this, the similarity is measured using the normalized Levenshtein distance, which computes the number of single-character edits (insertions, deletions, substitutions) needed to transform one string into the other. The raw distance is then divided by the maximum string length, which makes the metric length-agnostic and comparable across strings of different sizes:

\text{Normalized Levenshtein}(a, b) = \frac{\text{Levenshtein}(a, b)}{\max\left(\lvert a \rvert, \lvert b \rvert\right)}

If the normalized distance between schema:name and schema:description is ≤ 0.1, the description is considered redundant and removed from the RDF graph. This cleaning process is implemented in the Python script scripts/remove-redundancy.py, and the resulting graph is re-serialized to Turtle.

Example queries


  1. Here, an inspection point is a specific, verifiable criterion within an agricultural control program used to assess a farm's compliance with a particular regulation or standard. ↩︎