ncbi / GeneGPT

Code and data for GeneGPT.
https://arxiv.org/abs/2304.09667
Other
370 stars 24 forks source link

is it correct in the call_api(url) function to replace " " with "+"? #7

Open lonelyhwy opened 3 months ago

lonelyhwy commented 3 months ago

In main.py, the function call_api. There is a statement: url = url.replace(' ', '+') I have tried the example URL in Demonstration 1 (Dm. 1). https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=gene&retmax=5&retmode=json&sort=relevance&term=LMP10. It seems correct(result is same as Demonstration 1)

Then if I add a between "?" and "db" in this URL, and use the call_api() function. It will be replaced like this: https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?+db=gene&retmax=5&retmode=json&sort=relevance&term=LMP10 Then the result is not the same as Demonstration 1.

So I want to know why you want to replace " " with "+"? Thanks

Andy-jqa commented 3 months ago

URLs cannot contain spaces. URL encoding normally replaces a space with a plus (+) sign or with %20.

lonelyhwy commented 3 months ago

I know. But replacing spaces with "+" cannot give you the right answer in the E-utils APIs. Why not replace it with ""(empty) ?

Andy-jqa commented 3 months ago

That might cause parsing issues for the API? If you don't have spaces between words sometimes the service returns nothing.