AttributeError: 'Token' object has no attribute 'values'. when using Bind

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

AttributeError: 'Token' object has no attribute 'values'. when using Bind

Pascal
Hi,

Thanks for the nice library. I'm quite new to SparQL and I'm running into an error with BIND when running the following query in owlready.
"""
    SELECT DISTINCT ?id ?name ?hrId ?standardId
    WHERE {
        ?id rdf:type lo1:LearningObjective_1_0 .
        {
            ?id olc:isRequirementFor cs1:standard_01hnya576ceqq8h85m8ezg5h8g .
            BIND (cs1:standard_01hnya576ceqq8h85m8ezg5h8g AS ?standardId)
        }
        UNION
        {
            ?subS aoc:directPartOf cs1:standard_01hnya576ceqq8h85m8ezg5h8g .
            ?id olc:isRequirementFor ?subS .
            BIND (?subS AS ?standardId)
        }
        ?id rdfs:label ?name .
        ?id loc:humanReadableId ?hrId .
    }
"""

The same query works if I remove the variable binding.

Also, the query with BIND works when using SnapSparQL in Protege 5 when I add an additional str() around the bind variable. I tried adding the same str() around it in owlready but it didn't change anything.

The last error line is:
"""
.venv/lib/python3.11/site-packages/owlready2/sparql/parser.py", line 1319, in _get_ordered_vars
    _var_found(self.var.values, vars, ordered_vars)
               ^^^^^^^^^^^^^^^
AttributeError: 'Token' object has no attribute 'values'. Did you mean: 'value'?
"""

Am I doing something wrong here? Help would be greatly appreciated.

Best,
Pascal
Reply | Threaded
Open this post in threaded view
|

Re: AttributeError: 'Token' object has no attribute 'values'. when using Bind

Jiba
Administrator
Hi,

Thank you for reporting this problem, there was indeed an error (values instead of value).

I fixed the problem in the development version of Owlready2 on Bitbucket.

Jiba