UB-Mannheim / RaiseWikibase

Knowledge graph construction: Fast inserts into a Wikibase instance
https://ub-mannheim.github.io/RaiseWikibase/
MIT License
45 stars 7 forks source link

claim() and mainsnak() expect "snak()" as parameter #14

Closed MHuberFaust closed 2 years ago

MHuberFaust commented 2 years ago

Me again :)

I worked through the examples and found this:

claim() and mainsnak() expect "snak()" as parameter, but snak() returns a dictionary.

I adjusted the parameters to accept a dictionary to fix it on my end.

Please let me know wether you change the code or the Readme.

Best, Michael

PS: Thanks for this library, it helps a lot!

shigapov commented 2 years ago

I am not sure whether I understood you correctly.

Claim() function has the following arguments:

def claim(prop='', mainsnak=snak(), qualifiers=[], references=[]):

Mainsnak() function has these arguments:

def mainsnak(prop='', snak=snak(), qualifiers=[], references=[]):

So mainsnak()-function has parameter snak with default value equal to the returned value of the snak()-function which is indeed a dictionary. See snak()-function.

Could you share your example to clarify what you mean?

MHuberFaust commented 2 years ago

Sorry, it is indeed confusing.

Without trying to reproduce the error message (I will do it, when the following does not help). It said something like "dictionary is not callable".

claim() and mainsnak() did not accept a dictionary as input for the argument "mainsnak"/"snak". I changed:

def mainsnak(prop='', snak=snak(), qualifiers=[], references=[]):

to:

def mainsnak(prop='', snak={}, qualifiers=[], references=[]):

and it worked fine. I don not know the inner workings of python enough to explain why, though.

I ran it via a jupyter notebook, don't know if that is relevant.

shigapov commented 2 years ago

It would be good to see the whole minimal example starting from import of functions and ending with the error message.

shigapov commented 2 years ago

I am closing this, @MHuberFaust, but feel free to reopen if it will repeat.