I'm guessing you are using the latest code on the master branch? There
has been a bunch of changes since the last release 0.58 in how
vocabularies are stored and accessed. In particular, the on-disk
vocabulary format was just switched from TSV (a file called "subjects")
to a new CSV format (a file called "subjects.csv"). The code you are
using is attempting to read from the old file "subjects", but the
current Annif code expects a CSV file so reading it fails. See also the
message I just posted here about semantic versioning, which touches on
the same topics - backwards compatibility and changes to the vocabulary
This code is using quite low level Annif internals, which tend to change
frequently. I think it would be better to access projects at a slightly
higher level, through AnnifRegistry. But this all is uncharted territory
as Annif doesn't really try to be a software library with a stable
Python API. If you (or others) have such needs, could you please open an
issue on GitHub and explain what you would like to do with Annif through
Janne kirjoitti 31.8.2022 klo 7.55:
> I'm also interested in using Annif directly in Python code. Since 2019,
> are there any changes in codebase to make this easier?
> I tried the solution above, but it doesn't seem to work anymore as it
> gives an error "yield Subject(uri=annif.util.cleanup_uri(row['uri']),
> KeyError: 'uri'"
> Apparently either CSV library or how Annif reads files have changed somehow.
> On Tuesday, November 19, 2019 at 7:41:00 PM UTC+2 Antony Owino wrote:
> Ah, good to know. Wish I found out about Annif-client earlier. I'll
> give it a try soon and compare esp speed. I managed to integrate
> annif into my script/notebook after looking at the tests. Here it is
> if anyone else would need it.
> frompprint importpprint
> fromannif.suggestion importSuggestionResult,\
> fromannif.corpus importSubjectIndex
> text ="""SOME TEXT HERE AND THERE YOU CAN TRY"""
> project =Object()
> project.analyzer =annif.analyzer.get_analyzer('snowball(english)')
> Tel. +358 50 3199529
> 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
> To view this discussion on the web visit