Created
May 8, 2022 21:07
-
-
Save robgon-art/92237f1f92af32ceb4aaca4533339cfe to your computer and use it in GitHub Desktop.
Check if a similar title exists in Wikipedia
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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