1

python pyenchant library (and so c enchant) allows to check whether a word is spelled correctly http://pythonhosted.org/pyenchant/api/enchant.html

import enchant
enchant.Dict("en_US").check("house")

where does the US dictionary come from? does it contain also proper nouns, such as Microsoft or John? is it possible to check if a given word is a noun (but not a proper noun) and spelled correctly? so, something like:

check("house") -> true
check("houses") -> true
check("Microsoft") -> false
check("keiujr") -> false
David Portabella
  • 12,390
  • 27
  • 101
  • 182

2 Answers2

0

The us_EN dictionary contains words you’d find in a dictionary - so no proper nouns. This means you don’t want to spellcheck capitalized words other than at the beginning of a sentence when spell checking. This isn't ideal, but should work for many cases. It is also possible to add a dictionary of proper nouns to the provided dictionary.

rjurney
  • 4,824
  • 5
  • 41
  • 62
0

You can use nltk and pyspellchecker for this task. Parts-of-Speech (POS) tagging using nltk can be used to find out what kind of a word it is.

You can read more about the tags here-https://www.ling.upenn.edu/courses/Fall_2003/ling001/penn_treebank_pos.html

Pyspellchecker's unknown function can be used to find out whether or not the given word is spelled correctly.

import nltk 
!pip install pyspellchecker
from spellchecker import SpellChecker
spell = SpellChecker()


def check(list_words):
tagged = nltk.pos_tag(list_words) 
for i in range(0,len(tagged)):
    if(tagged[i][1] not in ['NN','NNS']):
        print("False:",tagged[i][0])
    else:
        if(spell.unknown([tagged[i][0]])):
            print("False:",tagged[i][0])
        else:
            print("True:",tagged[i][0])

list_words =['house','houses','Microsoft','keiujr']
check(list_words)

Output for the above code would be.

True: house

True: houses

False: Microsoft

False: keiujr

theamar961
  • 11
  • 3