Last active
July 12, 2022 19:51
-
-
Save mattWoolly/a236f2736dc3ee294196e66b593892ff to your computer and use it in GitHub Desktop.
Outside Spell Check
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 re | |
import requests | |
import hashlib | |
# GET document from Outside server | |
r = requests.get('https://outside-interview.herokuapp.com/document') | |
# Split document into list, using whitespace or - for seperator | |
list = re.split(r"\s+|-", r.text) | |
# Declare empty list | |
misspelled_words = [] | |
# Iterate through list of words | |
for i in list: | |
# Sanitize each word to remove unneeded punctuation | |
i_clean = re.sub(r'[.,"\-?:!;]', '', i) | |
url = "https://outside-interview.herokuapp.com/spelling/"+str(i_clean) | |
# GET request for word against the Outside spelling API | |
response = requests.get(url) | |
response_code = response.status_code | |
# Check if word is misspelled based on status code | |
if response_code == 404: | |
# Check if the string has a value | |
if i_clean: | |
# If all conditionals are met, add misspelled word to the list | |
misspelled_words.append(i_clean) | |
# Concatenate string | |
misspelled_string = "".join(misspelled_words) | |
# MD5 encode | |
md5_result = hashlib.md5(misspelled_string.encode()) | |
# Print hexdigest of MD5 encoded list with email domain | |
print(md5_result.hexdigest()+"@outsideinc.com") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment