Python wikipedia.page drops letter h

Viewed 68

So I'm currently trying to find the similarities of a given number of words. For that I wanted to get the content of the corresponding Wikipedia pages and search for words that all these pages have in common (minus of course words like articles and so on).

I am searching on the German Wikipedia page and one of the words is "Rhein" (the river Rhine). But for some reason, wikipedia.page("Rhein") gives me the disambiguation page for "rein". wikipedia.search("Rhein") shows the correct pages, but .page() or .content() do not.

Any explanation for this?

import wikipedia

wikipedia.set_lang("de")

try:
  print(wikipedia.page("Rhein"))
except wikipedia.exceptions.DisambiguationError as e:
  print(e.options)

Output in my Jupyter notbeook:

['Rein AG', 'Rein (Gemeinde Gratwein-Straßengel)', 'Stift Rein', 'Rein in Taufers', 'Rein (Adelsgeschlecht)', 'Reinheit', 'Reiner Reim', 'Adolf Rein', 'Andrew Rein', 'Anette Rein', 'Anna Rein-Wuhrmann', 'Antje von Rein', 'Bernhard Rein', 'Christian Rein', 'Conrad Rein', 'Daniel Rein', 'Dorothea Rein', 'Emil Rein', 'Erich Rein', 'Ernst Rein', 'Friedrich Karl Rein', 'Gerhard Rein (Mineraloge)', 'Gerhard Rein (Journalist)', 'Gerhard Rein (Mathematiker)', 'Hans Rein (Elektrotechniker)', 'Hans Rein (Kanute)', 'Hans Rein', 'Harald Rein', 'Heinz Rein', 'Herbert Rein', 'Hermann Rein', 'Hermann von Rein', 'Jewgeni Borissowitsch Rein', 'Johannes Justus Rein', 'Jonas Rein', 'Karl Rein', 'Kathrin Claudia Rein', 'Kurt Rein', 'Manfred Rein', 'Marianne Rein', 'Martin Rein', 'Paul Rein', 'Siegfried Rein', 'Steffen Rein', 'Torald Rein', 'Torolf Rein', 'Trine Rein', 'Udo Rein', 'Walter Rein', 'Wilhelm Rein', 'Wilhelm Rein (Philologe)', 'Rain', 'Reyn', 'Rhein (Begriffsklärung)']

Funny enough: wikipedia.page("Rhine") works fine.

1 Answers

There is a bug in the wikipedia package. If you call wikipedia.page("Rhein"), it first checks if it can find alternative spellings. For "Rhein" it finds "Rein" and then returns you the result for "Rein". Looking for alternative spellings is a nice option, but it would be better if it is only enabled when no results are found for the original spelling.

You can avoid this issue by writing:

wikipedia.page("Rhein", auto_suggest=False)
Related