Annif API - GET

20 views
Skip to first unread message

Parthasarathi Mukhopadhyay

unread,
Mar 5, 2022, 1:47:10 PMMar 5
to Annif Users

Dear all

I am a new user of Annif here (just installed it in my Ubuntu 20.04 lnux box).

I would like to have possible subject headings suggestions from Annif through API for an OpenRefine project on the basis of Abstract fields. I was trying something like this -


but receiving error 405 (Method is not allowed).

Does it support GET ? If yes, what will be the right API syntax?

Regards

Parthasarathi Mukhopadhyay
Kalyani University, West Bengal, India


Osma Suominen

unread,
Mar 7, 2022, 4:12:14 AMMar 7
to annif...@googlegroups.com
Hello,

Great that you got Annif running!

The "suggest" method only supports POST requests, not GET. For the right
syntax and some hints and pointers, check out this exercise of the Annif
tutorial on the REST API:

https://github.com/NatLibFi/Annif-tutorial/blob/master/exercises/07_rest_api.md

Hope this helps! If you get the API working with OpenRefine, please
share your solution here because I think it would be interesting for
others too.

Best,
Osma
> --
> You received this message because you are subscribed to the Google
> Groups "Annif Users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to annif-users...@googlegroups.com
> <mailto:annif-users...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/annif-users/3d3813de-0aff-473b-b262-d36445f9e754n%40googlegroups.com
> <https://groups.google.com/d/msgid/annif-users/3d3813de-0aff-473b-b262-d36445f9e754n%40googlegroups.com?utm_medium=email&utm_source=footer>.

--
Osma Suominen
D.Sc. (Tech), Information Systems Specialist
National Library of Finland
P.O. Box 15 (Unioninkatu 36)
00014 HELSINGIN YLIOPISTO
Tel. +358 50 3199529
osma.s...@helsinki.fi
http://www.nationallibrary.fi

Parthasarathi Mukhopadhyay

unread,
Mar 7, 2022, 10:21:36 AMMar 7
to Osma Suominen, annif...@googlegroups.com
Thanks Osma for the kind explanation.
I really appreciate the tutorials materials available here: https://github.com/NatLibFi/Annif-tutorial/tree/master/exercises.
These are invaluable resources. It took only 10 minutes for me (as a library professional) to install, configure and run Annif by following these awesome resources.

I'll raise the issue in the OpenRefine forum real soon and get back to this forum with the result.

Have you noticed this beautiful OA paper (related to Annif) - https://www.tandfonline.com/doi/pdf/10.1080/01639374.2021.2014011?needAccess=true ?

Regards

Parthasarathi




To unsubscribe from this group and stop receiving emails from it, send an email to annif-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/annif-users/3198704a-5065-da3c-e715-9a7c95603b46%40helsinki.fi.

Osma Suominen

unread,
Mar 8, 2022, 8:36:38 AMMar 8
to Parthasarathi Mukhopadhyay, annif...@googlegroups.com
Hello Parthasarathi,

Thank you for the praise and kind words! Glad to know that you found the
tutorial useful.

Yes, I'm aware of the paper. Jim Hahn also gave a presentation about the
project at the SWIB21 conference in December. The recording is available
here: https://www.youtube.com/watch?v=RheGZhu13bs

Best,
Osma

Parthasarathi Mukhopadhyay kirjoitti 7.3.2022 klo 17.21:
> Thanks Osma for the kind explanation.
> I really appreciate the tutorials materials available here:
> https://github.com/NatLibFi/Annif-tutorial/tree/master/exercises
> <https://github.com/NatLibFi/Annif-tutorial/tree/master/exercises>.
> <mailto:annif-users%2Bunsu...@googlegroups.com>
> > <mailto:annif-users...@googlegroups.com
> <mailto:annif-users%2Bunsu...@googlegroups.com>>.
> <https://groups.google.com/d/msgid/annif-users/3d3813de-0aff-473b-b262-d36445f9e754n%40googlegroups.com?utm_medium=email&utm_source=footer
> <https://groups.google.com/d/msgid/annif-users/3d3813de-0aff-473b-b262-d36445f9e754n%40googlegroups.com?utm_medium=email&utm_source=footer>>.
>
> --
> Osma Suominen
> D.Sc. (Tech), Information Systems Specialist
> National Library of Finland
> P.O. Box 15 (Unioninkatu 36)
> 00014 HELSINGIN YLIOPISTO
> Tel. +358 50 3199529
> osma.s...@helsinki.fi <mailto:osma.s...@helsinki.fi>
> http://www.nationallibrary.fi <http://www.nationallibrary.fi>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Annif Users" group.
> To unsubscribe from this group and stop receiving emails from it,
> send an email to annif-users...@googlegroups.com
> <mailto:annif-users%2Bunsu...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/annif-users/3198704a-5065-da3c-e715-9a7c95603b46%40helsinki.fi
> <https://groups.google.com/d/msgid/annif-users/3198704a-5065-da3c-e715-9a7c95603b46%40helsinki.fi>.

Parthasarathi Mukhopadhyay

unread,
Mar 12, 2022, 1:20:25 PMMar 12
to Osma Suominen, annif...@googlegroups.com
I got a half solution for this issue.

If we use python/jython option in OpenRefine like (need to wait 2/3 minutes to get the result):

import urllib2
url = "http://api.annif.org/v1/projects/yso-en/suggest"
data = "text=" + value.encode("utf-8") + "&limit=10&threshold=0.3"
post = urllib2.urlopen(url, data)
response = post.read()
return response

It is giving me results in Preview as per my expectation (against the abstract fields of a dataset containing journal papers).

Screenshot from 2022-03-12 22-41-20.png
But I can't figure it out why it is not getting stored against a column after clicking on "OK".

Regards

Parthasarathi Mukhopadhyay

unread,
Mar 15, 2022, 11:10:36 AMMar 15
to annif...@googlegroups.com
Finally the problem of integration of Annif and OpeRefine is solved.

The same POST request can do the tick but we need to select >> Add Column based on this column.

Previously, I was selecting wrongly the Add column by fetching URLs, which is not allowed in OpenRefine for POST requests.

Screenshot from 2022-03-15 20-32-55.png
It will then load suggestions through the Annif API in the designated column. The following GREL will extract labels/descriptors -

forEach(value.parseJson().results,v,v.label).join("\n")

The result is -

Screenshot from 2022-03-15 20-26-36.png

Hope this will help someone with similar needs.

Best regards


Reply all
Reply to author
Forward
0 new messages