NatLibFi/Annif

REST API method for listing vocabularies and their metadata

juhoinkinen opened this issue · 1 comments

Currently the Annif REST API has /v1/projects endpoint for getting a list of available projects. This is needed e.g. in web UI usage for populating the projects menu.

At Finto AI there is also the menu for suggestions language, which sets the language of the suggestions labels independently of the used project. If/when the Northern Sami will be added to the labels language menu (NatLibFi/FintoAI#18 (comment)), allowed because now YSO has labels in Sami in addition to Finnish, Swedish and English, there should be a way in Annif API to inform Finto AI which label languages should be selectable depending on the selected project.

For example, YKL/PLC and KAUNO do not support Sami, and trying to get labels in Sami when using those projects, an JS error occurs. The selectable languages could ofc be hard-coded in Finto AI JS code, but a better approach would be to have /v1/languages endpoint in Annif API, which would give the same information as annif list-vocabs CLI command, notably the supported languages per project:

Vocabulary ID  Languages    Size   Loaded
-----------------------------------------
yso            en,fi,se,sv  38586  True  
ykl            en,fi,sv     2406   True  
kauno          en,fi,sv     31138  True 

Also, the endpoint could also offer some metadata of the language, for example URLs to "homepages" of the vocabularies, which are now hard-coded in Finto AI JS source. (Well, for vocabularies served at finto.fi, instead of hard-coding the URL, the mapping could just use appending <vocabId> to https://finto.fi/... but a more general solution would be better.)

Also, the endpoint could also offer some metadata of the language, for example URLs to "homepages" of the vocabularies, which are now hard-coded in Finto AI JS source. (Well, for vocabularies served at finto.fi, instead of hard-coding the URL, the mapping could just use appending <vocabId> to https://finto.fi/... but a more general solution would be better.)

The (optional) vocabulary metadata could be stored in a file named vocabs.cfg or vocabs.toml, which would be in line with the project configurations file projects.{cfg,toml}.

In addition to a URLs, there could be also some free-form description for each vocabulary section.

I think @osma already had an idea to add a free-form description for each project too (in the projects configuration file?).