poldracklab / cogat

MIT License
1 stars 3 forks source link

API search query shouldn't be case insensitive #125

Open vsoch opened 6 years ago

vsoch commented 6 years ago

When I use the python wrapper (or API directly) to retrieve a task by name, the case probably shouldn't be a variable. For example:

from cognitiveatlas.api import get_task

# This doesn't work
task = get_task(name="stroop")

but that's because I was asking for the wrong thing, the full name includes "task"

image

But I'm still stupid, because this doesn't work either:

task = get_task(name="stroop task")

Doh. I needed to capitalize it! Here is the working query:

task = get_task(name="Stroop task")
# http://cognitiveatlas.org/api/v-alpha/task?name=Stroop%20task
# Result Includes:<pandas:data frame><json:dict><txt:str><url:str>

Phew! Because that's literally the only one I can ever remember. In retrospect, I might have searched for it first:

from cognitiveatlas.api import search
query = search('stroop')

# http://cognitiveatlas.org/api/v-alpha/search?q=stroop
# Result Includes:<pandas:data frame><json:dict><txt:str><url:str>

And then realized I have 11 variations!

len(query.json)
11

Anyway, aside from picking the one that I like, I think it makes sense that "stroop task" return equivalent to "Stroop Task" to "Stroop task." This could be implemented as a wrapper in cogat-python, but given that other endpoints are going to use the same core endpoints, it would make more sense to do the fix universally.