openfoodfacts / openfoodfacts-server

Open Food Facts database, API server and web interface - 🐪🦋 Perl, CSS and JS coders welcome 😊 For helping in Python, see Robotoff or taxonomy-editor
http://openfoodfacts.github.io/openfoodfacts-server/
GNU Affero General Public License v3.0
653 stars 383 forks source link

Understanding JSON taxonomy fields #892

Open aleene opened 7 years ago

aleene commented 7 years ago

The API allows to inspect how OFF interprets taxonomy based fields. A taxonomy based field consist of one or more tags (one or more words tied together). This information could be used by the user to suggest improvements to taxonomies. I would like to support this in my app, but before that it must be clear what information the API offers.

Any taxonomy based field presents its data in the json in three variants. An example for categories:

"categories":"Boissons,Boissons gazeuses,Eaux,Eaux minérales,Eaux gazeuses,Eaux minérales gazeuses,Boissons non sucrées"
"categories_tags":["en:beverages","en:carbonated-drinks","en:waters","en:mineral-waters","en:carbonated-waters","en:carbonated-mineral-waters","en:non-sugared-beverages"]
"categories_hierarchy":["en:beverages", "en:carbonated-drinks", "en:waters", "en:mineral-waters", "en:carbonated-waters", "en:carbonated-mineral-waters", "en:non-sugared-beverages"]

These three fields are in this example very similar. I (want to) interpret them as:

In my app I support the viewing of these different fields. By double tapping you can cycle through them. It would be nice if these fields have actual meaning.

stephanegigandet commented 7 years ago

categories_hierarchy is a re-ordering of categories_tags, with the "level" of the entries as the sort key. The level is how deep the category is from one of the roots.

categories is what the user entered last in the form, but what is shown on the form to the user when the page is edited is the content of categories_hierarchy, in the language of the interface.

aleene commented 7 years ago

The difference between _hierarchy and _tags seems not very useful, especially when it is not possible to identify the tops of the trees. I like to know how off uses to interpret and extend what has been entered by the user. This can be used to give suggestions to the editors of taxonomies.

aleene commented 7 years ago

I will have to incorporate the taxonomies and do my own processing.

stephanegigandet commented 6 years ago

The new taxonomy exports may help: https://github.com/openfoodfacts/openfoodfacts-server/issues/1126

aleene commented 6 years ago

I will play wiith the json-versions.