# Spell Check?

**URL:** <https://forum.inductiveautomation.com/t/spell-check/6559>\
**Category:** Ignition\
**Created:** [May 22, 2013, 4:12pm UTC](https://forum.inductiveautomation.com/t/spell-check/6559 "2013-05-22T16:12:21Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![stuartd](https://avatars.discourse-cdn.com/v4/letter/s/ecae2f/32.png) [@stuartd](https://forum.inductiveautomation.com/u/stuartd)\
**Post date:** [May 22, 2013, 4:12pm UTC](https://forum.inductiveautomation.com/t/spell-check/6559/1 "2013-05-22T16:12:21Z")

</div>

So it has been requested from multiple people of the possibility of a spell check for text fields. Is there any way to do this? Or is a feature coming soon that is going to have the ability to have a spell check system done it? Any suggestions for making a spell check?

---

<div class="post-metadata">

**Author:** ![greg.simpson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/greg.simpson/32/3135_2.png) [@greg.simpson](https://forum.inductiveautomation.com/u/greg.simpson)\
**Post date:** [May 22, 2013, 9:59pm UTC](https://forum.inductiveautomation.com/t/spell-check/6559/2 "2013-05-22T21:59:32Z")

</div>

There are no plans for this type of functionality

---

<div class="post-metadata">

**Author:** ![stuartd](https://avatars.discourse-cdn.com/v4/letter/s/ecae2f/32.png) [@stuartd](https://forum.inductiveautomation.com/u/stuartd)\
**Post date:** [May 23, 2013, 2:59pm UTC](https://forum.inductiveautomation.com/t/spell-check/6559/3 "2013-05-23T14:59:01Z")

</div>

Do you know of a way to do it?

---

<div class="post-metadata">

**Author:** ![Carl.Gould](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/carl.gould/32/7262_2.png) [@Carl.Gould](https://forum.inductiveautomation.com/u/Carl.Gould)\
**Post date:** [May 23, 2013, 9:15pm UTC](https://forum.inductiveautomation.com/t/spell-check/6559/4 "2013-05-23T21:15:14Z")

</div>

Sorry, there is no spell check within Ignition. I can’t think of any good way to do this, since the supporting libraries just aren’t there (dictionary, etc)

---

<div class="post-metadata">

**Author:** ![stuartd](https://avatars.discourse-cdn.com/v4/letter/s/ecae2f/32.png) [@stuartd](https://forum.inductiveautomation.com/u/stuartd)\
**Post date:** [May 30, 2013, 5:02pm UTC](https://forum.inductiveautomation.com/t/spell-check/6559/5 "2013-05-30T17:02:13Z")

</div>

Alright, well thank you for your time.

---

<div class="post-metadata">

**Author:** ![jimmylooo](https://avatars.discourse-cdn.com/v4/letter/j/f9ae1b/32.png) [@jimmylooo](https://forum.inductiveautomation.com/u/jimmylooo)\
**Post date:** [January 19, 2015, 4:26pm UTC](https://forum.inductiveautomation.com/t/spell-check/6559/6 "2015-01-19T16:26:01Z")

</div>

So I’ve come up with something that might help you out.

I’ve just started to use this so i may not have all the bugs worked out.

Here is the code that you will need to put in a Script Library:

```auto
import re, collections

def words(text): return re.findall('[a-z]+', text.lower()) 

def train(features):
    model = collections.defaultdict(lambda: 1)
    for f in features:
        model[f] += 1
    return model

NWORDS = train(words(file('//path/big.txt').read()))

alphabet = 'abcdefghijklmnopqrstuvwxyz'

def edits1(word):
   splits = [(word[:i], word[i:]) for i in range(len(word) + 1)]
   deletes = [a + b[1:] for a, b in splits if b]
   transposes = [a + b[1] + b[0] + b[2:] for a, b in splits if len(b)>1]
   replaces = [a + c + b[1:] for a, b in splits for c in alphabet if b]
   inserts = [a + c + b for a, b in splits for c in alphabet]
   return set(deletes + transposes + replaces + inserts)

def known_edits2(word):
    return set(e2 for e1 in edits1(word) for e2 in edits1(e1) if e2 in NWORDS)

def known(words): return set(w for w in words if w in NWORDS)

def correct(word):
    candidates = known([word]) or known(edits1(word)) or known_edits2(word) or [word]
    return max(candidates, key=NWORDS.get)
    
def correctAll(text):
	words = text.split(" ")
	corrections = []
	newWords = []
	retTxt=""
	for word in words:
		corrections=known([word]) or known(edits1(word)) or known_edits2(word) or [word]
		msgCorOpts=""
		idx = 1
		for correction in corrections:
			msgCorOpts += correction
			if len(corrections)>1 and idx < len(corrections):
				msgCorOpts += " or "
			idx+=1
		msgText="<html>Please correct spelling for:<br><br>" + word + "<br><br><normal>This is what I think it should be:<br><br>" + msgCorOpts + "<br>"
		if min(corrections, key=NWORDS.get) != word:
			newWords.append(system.gui.inputBox(msgText,min(corrections, key=NWORDS.get)))
		else:
			newWords.append(word)
	print newWords
	idx = 1
	for word in newWords:
		retTxt += word
		if len(newWords)>1 and idx < len(newWords):
			retTxt += " "
		idx+=1
			
	print retTxt
	return retTxt
```

The big.txt file is just a text file used kinda like a dictionary lookup file. here is the link where I got it: [norvig.com/big.txt](http://norvig.com/big.txt)

Here are also some other files with a list of words to reference:  
[zyzzyva.net/lexicons/](http://zyzzyva.net/lexicons/)

Also here is the link to the page that i based my code:

[norvig.com/spell-correct.html](http://norvig.com/spell-correct.html)

Hope this helps!

Thanks!
