Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update hangman.py #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

Oshino-MeMe
Copy link

Hi Derek, Levi here. When Bear and myself were at your presentation, thanks again for that, we came across two issues in your hangman game so we decided to dig in and try and fix it. We just replaced the " ' "/" é " with " "/" e ". We felt that getting rid of the offending words seemed to be the best course of action for the problem but aren't knowledgeable enough yet lol. .

Hi Derek, Levi here. When Bear and myself were at your presentation, thanks again for that, we came across two issues in your hangman game so we decided to dig in and try and fix it. We just replaced the " ' "/" é " with " "/" e ". We felt that getting rid of the offending words seemed to be the best course of action for the problem but aren't knowledgeable enough yet lol. We also want to try and get the guessed word to print if the guesses run out but that's going to have to wait till tomorrow cause he has homework and my brain already feels fried lol.
@derekmoyes
Copy link
Owner

I like the idea, but note that since you are changing only the print command inside the debug block, you are only preventing the display of those words, not removing them from the word list, which means they might still come up.

I hadn't originally considered there might be apostrophe or accented characters, so I'll hand it back to you, I'd love to see you come up with a solution!

@Oshino-MeMe
Copy link
Author

So.... I'm stuck, went down the rabbit hole trying to find a better solution to this instead of just removing them. Apparently, and I'm sure I'll butcher this explanation, the root of the problem stems from trying to manipulate a natural language with a logical. Did some digging and found NLTK (natural language tool kit) and started playing around with that. I had to strip everything from the original program just to make it easier to work with.

First I got it to tokenize, then I got it to porterstemmer, that didn't work as it just cuts off the end of the word, then I got it to lemmatize the word, but that only kind of works and I'm not sure why.

Here's what I have working and I feel like I've exhausted my research abilities as I don't know how to word my google-fu at this point and feel stuck.

import nltk
from nltk.stem import WordNetLemmatizer
from nltk.tokenize import sent_tokenize, word_tokenize

word_file = "/usr/share/dict/words"

wnl = WordNetLemmatizer()
text = open(word_file).read().replace("'","").replace("é","e")
tokenization = nltk.word_tokenize(text)
for w in tokenization:

print(w, wnl.lemmatize(w)) 

Any thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants