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?
There are no plans for this type of functionality
Do you know of a way to do it?
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)
Alright, well thank you for your time.
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:
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 + b + 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
Here are also some other files with a list of words to reference:
Also here is the link to the page that i based my code:
Hope this helps!