spellcheck.py
h
PYer (2731)

spellcheck.py

This is a python library I coded to generate spelling suggestions. I was going to implement it into a chat robot later but I haven't done it yet. It basically checks for similarity between a typed word and a list of words. It runs throught 3 test cases to compare the order, position, and count of all letters in both words.
I hope you like it, and I'm interested to see what people (if any) create with this! I have supplied a few examples below of code and output:


Other possible results:


You are viewing a single comment. View All
hamzawsome7 (0)

when i run this code on my chatbot, it doesnt work

it looks like this:

import spellcheck
feeling = input("Hi, how are you feeling today? ")
feeling = feeling.lower()
goodfeel = 'cheerful contented delighted ecstatic elated glad joyful joyous jubilant lively merry overjoyed peaceful pleasant pleased thrilled upbeat'.split()

while feeling in goodfeel:
print('Cool...')
break

meant = spellcheck.comp_list(typ, opts, minsim=0.4)
print('Did you mean:', ', '.join(meant))

there are multiple errors including s=that there is a break without a loop. Also after changing the if to a while to solve that problem it says module 'spellcheck' has no attribute 'comp_list'

hamzawsome7 (0)

@hamzawsome7 the current code is:

import spellcheck
feeling = input("Hi, how are you feeling today? ")
feeling = feeling.lower()
goodfeel = 'cheerful contented delighted ecstatic elated glad joyful joyous jubilant lively merry overjoyed peaceful pleasant pleased thrilled upbeat'.split()

while feeling in goodfeel:
print('Cool...')
break

meant = spellcheck.comp_list(feeling, goodfeel, minsim=0.4)
print('Did you mean:', ', '.join(meant))

PYer (2731)

that code doesn't make logical sense. the position of the break does not make any sense. With some editing, I think I made it work like you wanted it to:

import spellcheck
feeling = input("Hi, how are you feeling today? ")
feeling = feeling.lower()
goodfeel = 'cheerful contented delighted ecstatic elated glad joyful joyous jubilant lively merry overjoyed peaceful pleasant pleased thrilled upbeat'.split()

if feeling in goodfeel:
  print('Cool...')
else:
  meant = spellcheck.comp_list(feeling, goodfeel, minsim=0.4)
  print('Did you mean:', ', '.join(meant))

@hamzawsome7