codeforIATI / iati-ideas

💡 Ideas for new codeforIATI projects and blogs
https://ideas.codeforiati.org
0 stars 0 forks source link

[IDEA] Validator with brains #4

Open matmaxgeds opened 5 years ago

matmaxgeds commented 5 years ago

Rationale

The validator is currently limited to giving feedback on things that operate within the realm of the standard, and rules that can be written about IATI elements e.g. you use this element in this way if you also have this element.

Validator with brains is about giving higher level data quality feedback - and to do so, it needs to pull in external data and to be able to 'think'. For example: 'Is this activity published in one of the national languages of the recipient'? To do this requires determining the language used for the activity, and comparing it to a list of national languages linked from the recipient-country data.

As many aspects of this process are shared (looping through IATI data, presenting feedback), they should be built once.

Proposal

A validator that loops through IATI data, provides different data entry points, and handles the error reporting etc, but that supports scripts which follow a standardised format, e.g. activity input, code to run, defined 'answer' returned.

In the example above, the script would state that it need elements X and Y from each activity and the validator would loop through the IATI data, and for each activity identified, trigger the script, passing the elements requested, before waiting for a returned answer, then compiling the returns and presenting them to the user.

For the example above:

<data-required>/activities/activity/description, /activities/activity/recipient-country
<return type>binary
<return options>valid/not valid
<return-aggregation>allowed
<script-language>python
<script-requirements>langdetect
<script>
from langdetect import detect
for each recipient-country = X
scrape https://en.wikipedia.org/wiki/List_of_official_languages_by_country_and_territory for X, return national language
if detect("description") = X
then return valid, else return invalid.......
</script>

Other things I would like to try: