////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////// buildDictionary - created by Mike Cardeiro | mcardeiro@yahoo.com ///////////////////////////////// ////////------------------------------------------------------------------------////////////////////////////////////////////////| // | // This script will build a dictionary directory structure for use with the spellCheck script | // | // You should remove any old dictionary elements before creating a new one | // | // The script will build the dictionary structure in the same location as this script, which should be in the | // "spellCheckFiles/" directory | // | // In order to build a dictionary structure, you need a master list with all the words for the dictionary on a seperate | // lines | // | // Do not have any blank lines in the file, this will cause the dictionary to noy build properly | // | // The dictionary directory holds a directory for each letter in the alphabet. within each of those directories | // are text files with a number as its name. the files contain all words that are that length starting with | // that letter. for example "dictionary/a/3.txt" would contain ant, are, aim and so on. | // | | // | //------------------------------------------------------------------------------------------------------------------------------| // USE AT YOUR OWN RISK. I HAVE CODED THIS FOR FUN AND TO HELP OUT AT WORK. IF YOUR COMPUTER BLOWS UP...I DIDN'T DO IT! | // let me know of any problems or suggestions, my email is at the top. | //______________________________________________________________________________________________________________________________| dicFolder = Folder('dictionary').create() if(!dicFolder){ alert('Could not create new dictionary directory\nYou need to remove the old dictionary directory before running this script'); }else{ path = Folder(dicFolder).path; masterFilePath = fileGetDialog('Open the master list to create the dictionary structure','*'); masterFile = File(masterFilePath); masterFile.open(); userDic = File(path+'/dictionary/userWords.txt'); userDic.open("w"); userDic.close(); for(x = 0; x<26; ++x){ breakList(String.fromCharCode(97 + x)); } } function breakList(letter) { folderPath = path +'/dictionary/' + letter; list = new Array; maxLength = 0; Folder(folderPath).create(); // create letter folder while(word = masterFile.readln()){ //////read contents of dictionart into array list word = word.toLowerCase(); if(word[0] == letter){ //word starts with the target letter if(list[word.length]){ list[word.length].push(word); }else{ list[word.length] = new Array(word); } } } for(t = 1; t < list.length; ++t){ if(list[t]){ letterFile = File(folderPath + '/' + t + '.txt'); letterFile.open("w"); for(y = 0; y < list[t].length; ++y){ letterFile.writeln(list[t][y]); } letterFile.close(); } } masterFile.seek(0); }