Dealing with redirects and disambiguations in Wiki Viewer

Dealing with redirects and disambiguations in Wiki Viewer
0.0 0

#1

Nearly completed this project the only problem is how to deal with redirects and disambiguations showing up in the json object.obviously this has to do with the api url

var url = “https://en.wikipedia.org/w/api.php?action=opensearch&search=” + searchTerm + “&limit=5&format=json&callback=?”;

Could anyone give me some advice please …thanks!


#2

I don’t know if this is a fatal flaw, but I can see why you think of it as less than ideal. Relooking at mine, I see that it does the same thing. I can imagine two solutions:

  1. Live with it. What’s wrong with a disambiguation page? Maybe I might have it check to see if the info string is ends in “may refer to:” and if it does, replace it with “(disambiguation page)” to be more clear.

  2. If you really, really hate disambiguation pages, you could get one extra result from your api request and if the first description ends with “may refer to:” then slice it off the array.


#3

I wouldn’t say its a fatal flaw,but it seems to me that it doesn’t really achieve the basic function of the wiki viewer.
Keep thinking that must be a easier way then making a regex that checks the array content.
Will have to look through the api documentation again-should be fun.


#4

I don’t know - I like disambiguation pages.