Skip to content

Instantly share code, notes, and snippets.

@robgon-art
Created May 8, 2022 21:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robgon-art/92237f1f92af32ceb4aaca4533339cfe to your computer and use it in GitHub Desktop.
Save robgon-art/92237f1f92af32ceb4aaca4533339cfe to your computer and use it in GitHub Desktop.
Check if a similar title exists in Wikipedia
import wikipedia
def check_in_wiki(name):
name_parts = name.split()
wiki_results = wikipedia.search(name)
for w in wiki_results:
w = w.lower()
match_all_parts = True
for n in name_parts:
n = n.lower()
if n == "the" or n == "a":
continue
if n not in w:
match_all_parts = False
break
if match_all_parts:
return True
return False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment