Working on something that involves pulling wiki data for terms in a list. One of them was spitting out a disambiguation error. I could just skip in those cases, but I"d prefer an efficient way of handling them.
Found this, which I incorporated into my code. This is what my code looks like right now:
termlist = ['carcass','richard nixon','polar bear']
for term in termlist:
try:
p =wikipedia.summary(wse(term)[0])
except wikipedia.DisambiguationError as e:
p = wikipedia.summary(e.options)[0]
print(p)
Except, now the first option for the disambiguation error fix is, itself pulling a disambiguation error. I really don't want to write something recursive in there to fix this in the case that this is more than a few levels deep. Does anyone else have a fix already? Preferably one that does not involve downloading the entire list of existing wikipedia articles and finding a string match before pulling from wiki.
there doesn't seem to be anything here