Foundeo

Foundeo Spell Checker returns it's result either as a two dimensional Java Script array, or as a WDDX/XML packet. In either case the underlying data structures are similar.

Consider the string of text "I am speled wrang", if we pass this string of text into the spell checker, it is of course going to notice that "speled", and "wrang" are not spelled correct. For each word that is mispelled, there is going to be a set of suggestions that correspond to that word.
For example...
Mispelled: speled

Suggestions... Mispelled: wrang

Suggestions... Now the spell checker needs to pass which words are mispelled, back to the ColdFusion programmer, and the way it passes it back is based on the FORMAT attribute. In both FORMAT=JavaScript, and FORMAT=WDDX it passes similar data structures back. An array called mispelled which simply contains a list of each word that is mispelled, in order of where they are found in the document. The second data structure passed back, is also an array, but this array is a two dimensional array called suggestions. The suggestions array is keyed such that the first index is a pointer to the index of the mispelled word, in the mispelled array.
Example...

mispelled[0] = "speled"; //the first mispelled word
mispelled[1] = "wrang"; //the second mispelled word
suggestions[0][0] = "spelled"; //the first suggestion for "speled"
suggestions[0][1] = "spieled"; //the second suggestion for "speled"
suggestions[1][0] = "rang"; //the first suggestion for "wrang"

please note the above example shows a zero based indexing language, ColdFusion is a 1 based index (starts at 1 not 0), and JavaScript is zero based.

FORMAT="JavaScript"

The java script output for the above example would look like this...
var numMispelled = 2;
var mispelled = new Array(2);
var suggestions = new Array(2);
mispelled[0] = "speled";
suggestions[0] = new Array(14);
suggestions[0][0] = "spelled";
suggestions[0][1] = "spieled";
suggestions[0][2] = "speed";
suggestions[0][3] = "pealed";
suggestions[0][4] = "pelted";
suggestions[0][5] = "sealed";
suggestions[0][6] = "speeds";
suggestions[0][7] = "speedy";
suggestions[0][8] = "spoiled";
suggestions[0][9] = "spooled";
suggestions[0][10] = "peed";
suggestions[0][11] = "seed";
suggestions[0][12] = "spewed";
suggestions[0][13] = "paled";
mispelled[1] = "wrang";
suggestions[1] = new Array(14);
suggestions[1][0] = "rang";
suggestions[1][1] = "Wang";
suggestions[1][2] = "wrong";
suggestions[1][3] = "wrangle";
suggestions[1][4] = "wring";
suggestions[1][5] = "wrung";
suggestions[1][6] = "range";
suggestions[1][7] = "rangy";
suggestions[1][8] = "twang";
suggestions[1][9] = "Drang";
suggestions[1][10] = "wrangled";
suggestions[1][11] = "wrangler";
suggestions[1][12] = "wrangles";
suggestions[1][13] = "wrongs";


FORMAT="WDDX"


A Sample WDDX output would look like this...
<?xml version='1.0'?>
<!DOCTYPE wddxPacket SYSTEM 'wddx_0100.dtd'>
<wddxPacket version='1.0'>
	<header/>
	<data>
		<struct>
			<var name='numMispelled'>
				<number>2</number>
			</var>
			<var name='mispelled'>
				<array length='2'>
					<string>speled</string>
					<string>wrang</string>
				</array>
			</var>
			<var name='suggestions'>
				<array length='2'>
					<array length='15'>
						<string>spelled</string>
						<string>spieled</string>
						<string>spoiled</string>
						<string>spooled</string>
						<string>spilled</string>
						<string>spiel</string>
						<string>suppled</string>
						<string>see</string>
						<string>spell</string>
						<string>spelt</string>
						<string>supplied</string>
						<string>supple</string>
						<string>sepaloid</string>
						<string>spoil</string>
						<string>spool</string>
					</array>
					<array length='15'>
						<string>rang</string>
						<string>wrong</string>
						<string>wrangle</string>
						<string>wring</string>
						<string>wrung</string>
						<string>wrangled</string>
						<string>wrangler</string>
						<string>wrangles</string>
						<string>wrongs</string>
						<string>ran</string>
						<string>wren</string>
						<string>wrings</string>
						<string>wranglers</string>
						<string>wrangling</string>
						<string>wrongly</string>
					</array>
				</array>
			</var>
		</struct>
	</data>
</wddxPacket>


Please note, that different searchdepths were used to form examples, so results may vary slightly