Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Candidates response fails on _dict_cleanup #3

Closed
aolieman opened this issue Jun 29, 2013 · 7 comments
Closed

Candidates response fails on _dict_cleanup #3

aolieman opened this issue Jun 29, 2013 · 7 comments

Comments

@aolieman
Copy link

Hey,

Thanks for writing this nice wrapper. It makes Spotlight calls a lot more convenient!

I'm running into a problem with the candidates response, seemingly only when exactly two candidate URIs are found for a surface form.

>>> text = "Industrial Design at the Technische Universiteit Delft"
>>> compare.throughSpotlight(text, candidate_param)

Traceback (most recent call last):
  File "<pyshell#13>", line 1, in <module>
    compare.throughSpotlight(text, candidate_param)
  File "...\git-code\compare.py", line 44, in throughSpotlight
    spotlight_response = api(text)
  File "build\bdist.win32\egg\spotlight\__init__.py", line 206, in candidates
    for form in pydict['annotation']['surfaceForm']]
  File "build\bdist.win32\egg\spotlight\__init__.py", line 60, in _dict_cleanup
    for key, value in dic.iteritems():
AttributeError: 'unicode' object has no attribute 'iteritems'

With curl:

$ curl -H "accept: application/json" http://spotlight.sztaki.hu:2222/rest/candidates --data "text=Industrial Design at the Technische Universiteit Delft&confidence=0&support=0"
{
   "annotation":{
      "@text":"Industrial Design at the Technische Universiteit Delft",
      "surfaceForm":{
         "@name":"Technische Universiteit Delft",
         "@offset":"25",
         "resource":[
            {
               "@label":"Technische Universiteit Delft",
               "@uri":"Technische_Universiteit_Delft",
               "@contextualScore":"0.9991813164782087",
               "@percentageOfSecondRank":"0.1422872887244497",
               "@support":"3",
               "@priorScore":"2.8799662606192636E-8",
               "@finalScore":"0.8754365122251001",
               "@types":""
            },
            {
               "@label":"Delft University of Technology",
               "@uri":"Delft_University_of_Technology",
               "@contextualScore":"8.186418452925803E-4",
               "@percentageOfSecondRank":"0.0",
               "@support":"521",
               "@priorScore":"5.001541405942121E-6",
               "@finalScore":"0.12456348777489806",
               "@types":"DBpedia:Agent, Schema:Organization, DBpedia:Organisation, Schema:EducationalOrganization, DBpedia:EducationalInstitution, Schema:CollegeOrUniversity, DBpedia:University"
            }
         ]
      }
   }
}

I'm not entirely sure what the conditions are under which _dict_cleanup() fails, but I have only found examples with exactly two candidate URIs. If needed, I can provide you with some more examples.

Any idea what is causing this hiccup?

Cheers,
Alex

@originell
Copy link
Contributor

May I ask which version if spotlight you are running?

@aolieman
Copy link
Author

Of course you may :-)!

Locally I'm fairly certain the version is 0.6.5 and at http://spotlight.sztaki.hu:2222 it should also be 0.6.5. The responses from my local server and the sztaki.hu server are the same.

Doesn't the issue reproduce with your server?

@originell
Copy link
Contributor

Haha no, or at least it was not above our notification threshold oops.

I have a fix which I'm pushing in the next 15 minutes. That happens because in candidates we are assuming that it's a list, which it does not have to be, as your case demonstrates :)

@aolieman
Copy link
Author

That's great, I'll try it right away!
Especially great since your fix is faster than me trying to bypass _dict_cleanup() alltogether ;-)

@originell
Copy link
Contributor

So that should be fixed now! Would not have been that fast if you would not have supplied the raw curl response :) Thanks for that. Hope it works? Waiting for your confirmation!

@aolieman
Copy link
Author

It works like a charm =)! Many thanks for your fast (and late-night) bugfix; I wasn't expecting that!

@originell
Copy link
Contributor

Glad to hear that! Well, I'm recovering a RAID5, so if you encounter any other error tonight, chances are high that I'll be awake and able to fix it ;-)

Have fun with spotlight!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants