http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/fd2bc5a5/Squiggly/main/Tools/AdobeSpellingDictGen/src/UIWord.as
----------------------------------------------------------------------
diff --git a/Squiggly/main/Tools/AdobeSpellingDictGen/src/UIWord.as 
b/Squiggly/main/Tools/AdobeSpellingDictGen/src/UIWord.as
deleted file mode 100644
index 74c32e5..0000000
--- a/Squiggly/main/Tools/AdobeSpellingDictGen/src/UIWord.as
+++ /dev/null
@@ -1,37 +0,0 @@
-////////////////////////////////////////////////////////////////////////////////
-//
-//  Licensed to the Apache Software Foundation (ASF) under one or more
-//  contributor license agreements.  See the NOTICE file distributed with
-//  this work for additional information regarding copyright ownership.
-//  The ASF licenses this file to You under the Apache License, Version 2.0
-//  (the "License"); you may not use this file except in compliance with
-//  the License.  You may obtain a copy of the License at
-//
-//      http://www.apache.org/licenses/LICENSE-2.0
-//
-//  Unless required by applicable law or agreed to in writing, software
-//  distributed under the License is distributed on an "AS IS" BASIS,
-//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-//  See the License for the specific language governing permissions and
-//  limitations under the License.
-//
-////////////////////////////////////////////////////////////////////////////////
-package
-{
-       public class UIWord
-       {
-               public var index:uint;
-               public var word:String;
-               public var meta:String;
-               
-               public function UIWord(inIndex:uint, inWord:String)
-               {
-                       index = inIndex;
-                       word = inWord;
-                       meta = "";
-               }
-       
-       }
-       
-
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/fd2bc5a5/Squiggly/main/Tools/SpellingDictGen/README.txt
----------------------------------------------------------------------
diff --git a/Squiggly/main/Tools/SpellingDictGen/README.txt 
b/Squiggly/main/Tools/SpellingDictGen/README.txt
new file mode 100644
index 0000000..5326ed6
--- /dev/null
+++ b/Squiggly/main/Tools/SpellingDictGen/README.txt
@@ -0,0 +1,16 @@
+Squiggly Dictionary Generator v0.1
+
+README
+===================================
+
+This is a simple AIR application that converts a plain text word list file to 
an Adobe Spelling Dictionary file. 
+
+Here's what each step is doing:
+1. Load a plain text file, each line in the file contains one word, a 
sampleWOrdList.txt is provided
+2. Calculate the metaphone, which will improve spell checker performance and 
result
+3. Generate a Squiggly Dictionary object
+4. Export the the Squiggly Dictionary object to a compressed binary file 
(recommend using *.zwl extension)
+
+Once you have the zwl file, you can use it in your Flex/AIR project.
+
+

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/fd2bc5a5/Squiggly/main/Tools/SpellingDictGen/sample/sampleWordList.txt
----------------------------------------------------------------------
diff --git a/Squiggly/main/Tools/SpellingDictGen/sample/sampleWordList.txt 
b/Squiggly/main/Tools/SpellingDictGen/sample/sampleWordList.txt
new file mode 100644
index 0000000..3c6e8ce
--- /dev/null
+++ b/Squiggly/main/Tools/SpellingDictGen/sample/sampleWordList.txt
@@ -0,0 +1,13 @@
+adobe
+apple
+amazon
+microsoft
+intel
+ibm
+google
+yahoo
+ebay
+vmware
+sun
+orcale
+facebook
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/fd2bc5a5/Squiggly/main/Tools/SpellingDictGen/src/SpellingDictGen-app.xml
----------------------------------------------------------------------
diff --git a/Squiggly/main/Tools/SpellingDictGen/src/SpellingDictGen-app.xml 
b/Squiggly/main/Tools/SpellingDictGen/src/SpellingDictGen-app.xml
new file mode 100644
index 0000000..ecff5e3
--- /dev/null
+++ b/Squiggly/main/Tools/SpellingDictGen/src/SpellingDictGen-app.xml
@@ -0,0 +1,153 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements.  See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License.  You may obtain a copy of the License at
+ 
+ http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ 
+ -->
+<application xmlns="http://ns.adobe.com/air/application/1.5";>
+
+<!-- Adobe AIR Application Descriptor File Template.
+
+       Specifies parameters for identifying, installing, and launching AIR 
applications.
+
+       xmlns - The Adobe AIR namespace: http://ns.adobe.com/air/application/1.5
+                       The last segment of the namespace specifies the version 
+                       of the AIR runtime required for this application to run.
+                       
+       minimumPatchLevel - The minimum patch level of the AIR runtime required 
to run 
+                       the application. Optional.
+-->
+
+       <!-- The application identifier string, unique to this application. 
Required. -->
+       <id>AdobeSpellingDictGen</id>
+
+       <!-- Used as the filename for the application. Required. -->
+       <filename>AdobeSpellingDictGen</filename>
+
+       <!-- The name that is displayed in the AIR application installer. 
+            May have multiple values for each language. See samples or xsd 
schema file. Optional. -->
+       <name>AdobeSpellingDictGen</name>
+
+       <!-- An application version designator (such as "v1", "2.5", or "Alpha 
1"). Required. -->
+       <version>v1</version>
+
+       <!-- Description, displayed in the AIR application installer.
+            May have multiple values for each language. See samples or xsd 
schema file. Optional. -->
+       <!-- <description></description> -->
+
+       <!-- Copyright information. Optional -->
+       <!-- <copyright></copyright> -->
+
+       <!-- Settings for the application's initial window. Required. -->
+       <initialWindow>
+               <!-- The main SWF or HTML file of the application. Required. -->
+               <!-- Note: In Flex Builder, the SWF reference is set 
automatically. -->
+               <content>[This value will be overwritten by Flex Builder in the 
output app.xml]</content>
+               
+               <!-- The title of the main window. Optional. -->
+               <!-- <title></title> -->
+
+               <!-- The type of system chrome to use (either "standard" or 
"none"). Optional. Default standard. -->
+               <!-- <systemChrome></systemChrome> -->
+
+               <!-- Whether the window is transparent. Only applicable when 
systemChrome is none. Optional. Default false. -->
+               <!-- <transparent></transparent> -->
+
+               <!-- Whether the window is initially visible. Optional. Default 
false. -->
+               <!-- <visible></visible> -->
+
+               <!-- Whether the user can minimize the window. Optional. 
Default true. -->
+               <!-- <minimizable></minimizable> -->
+
+               <!-- Whether the user can maximize the window. Optional. 
Default true. -->
+               <!-- <maximizable></maximizable> -->
+
+               <!-- Whether the user can resize the window. Optional. Default 
true. -->
+               <!-- <resizable></resizable> -->
+
+               <!-- The window's initial width. Optional. -->
+               <!-- <width></width> -->
+
+               <!-- The window's initial height. Optional. -->
+               <!-- <height></height> -->
+
+               <!-- The window's initial x position. Optional. -->
+               <!-- <x></x> -->
+
+               <!-- The window's initial y position. Optional. -->
+               <!-- <y></y> -->
+
+               <!-- The window's minimum size, specified as a width/height 
pair, such as "400 200". Optional. -->
+               <!-- <minSize></minSize> -->
+
+               <!-- The window's initial maximum size, specified as a 
width/height pair, such as "1600 1200". Optional. -->
+               <!-- <maxSize></maxSize> -->
+       </initialWindow>
+
+       <!-- The subpath of the standard default installation location to use. 
Optional. -->
+       <!-- <installFolder></installFolder> -->
+
+       <!-- The subpath of the Programs menu to use. (Ignored on operating 
systems without a Programs menu.) Optional. -->
+       <!-- <programMenuFolder></programMenuFolder> -->
+
+       <!-- The icon the system uses for the application. For at least one 
resolution,
+                specify the path to a PNG file included in the AIR package. 
Optional. -->
+       <!-- <icon>
+               <image16x16></image16x16>
+               <image32x32></image32x32>
+               <image48x48></image48x48>
+               <image128x128></image128x128>
+       </icon> -->
+
+       <!-- Whether the application handles the update when a user 
double-clicks an update version
+       of the AIR file (true), or the default AIR application installer 
handles the update (false).
+       Optional. Default false. -->
+       <!-- <customUpdateUI></customUpdateUI> -->
+       
+       <!-- Whether the application can be launched when the user clicks a 
link in a web browser.
+       Optional. Default false. -->
+       <!-- <allowBrowserInvocation></allowBrowserInvocation> -->
+
+       <!-- Listing of file types for which the application can register. 
Optional. -->
+       <!-- <fileTypes> -->
+
+               <!-- Defines one file type. Optional. -->
+               <!-- <fileType> -->
+
+                       <!-- The name that the system displays for the 
registered file type. Required. -->
+                       <!-- <name></name> -->
+
+                       <!-- The extension to register. Required. -->
+                       <!-- <extension></extension> -->
+                       
+                       <!-- The description of the file type. Optional. -->
+                       <!-- <description></description> -->
+                       
+                       <!-- The MIME content type. -->
+                       <!-- <contentType></contentType> -->
+                       
+                       <!-- The icon to display for the file type. Optional. 
-->
+                       <!-- <icon>
+                               <image16x16></image16x16>
+                               <image32x32></image32x32>
+                               <image48x48></image48x48>
+                               <image128x128></image128x128>
+                       </icon> -->
+                       
+               <!-- </fileType> -->
+       <!-- </fileTypes> -->
+
+</application>

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/fd2bc5a5/Squiggly/main/Tools/SpellingDictGen/src/SpellingDictGen.mxml
----------------------------------------------------------------------
diff --git a/Squiggly/main/Tools/SpellingDictGen/src/SpellingDictGen.mxml 
b/Squiggly/main/Tools/SpellingDictGen/src/SpellingDictGen.mxml
new file mode 100644
index 0000000..2399910
--- /dev/null
+++ b/Squiggly/main/Tools/SpellingDictGen/src/SpellingDictGen.mxml
@@ -0,0 +1,210 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+
+-->
+<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml"; 
layout="vertical" width="800" height="600" fontSize="12">
+
+
+       <mx:Script>
+               <![CDATA[
+                       
+                       import com.adobe.linguistics.spelling.utils.WordList;
+                       import 
com.adobe.linguistics.spelling.engine.dictionary.SuseDictionary;
+                       import 
com.adobe.linguistics.spelling.codec.language.MetaPhone;
+                       
+                       // For debug only
+                       private var tsStart:int
+                       private var tsEnd:int;
+                       
+                       // An array with words only
+                       private var basicWordList:Array;
+                       
+                       // A suse dictionary object (hash) as defined in suse 
engine
+                       private var suse:SuseDictionary;
+                       
+                       // An array with index, word, metaphone
+                       [Bindable]
+                       private var advWordList:Array;
+                       
+                       private var src:File = File.applicationDirectory;
+                       private var dest:File = File.applicationDirectory;
+                       
+                       
+                       private function browseInFile():void
+                       {
+                               try {
+                                       src.browseForOpen("Select a TXT file");
+                                       src.addEventListener(Event.SELECT, 
inFileSelected);
+                               } catch (error:Error)
+                               {
+                                       trace("Failed:", error.message);
+                               }
+                       }
+                       
+                       private function inFileSelected(event:Event):void
+                       {       
+                               tsStart = getTimer();
+                               var file:File = event.target as File;
+                               var stream:FileStream = new FileStream();
+                               stream.open(file, FileMode.READ);
+                               var fileData:String = 
stream.readUTFBytes(stream.bytesAvailable);
+                               
+                               if (fileData.charAt(fileData.indexOf("\n")-2) 
== "\r")          //Strange, but happened when generating the text file from mac
+                               {
+                                       basicWordList = 
fileData.split("\r\r\n");
+                               }
+                               else if 
(fileData.charAt(fileData.indexOf("\n")-1) == "\r")
+                               {
+                                       basicWordList = fileData.split("\r\n"); 
                //Windows
+                               }
+                               else 
+                               {
+                                       basicWordList = fileData.split("\n");   
                //Mac and linux
+                               }
+                               
+                               loadTxtInfo.text = file.nativePath + " (" + 
basicWordList.length.toString() + " words, " + file.size.toString() + " bytes)";
+                               loadTxtInfo.setStyle("color", "green");
+                               
+                               // Debug log
+                               tsEnd = getTimer();
+                               debugInfo.text += 
"DebugInfo\n================\n" + "TxtLoaded: "+ file.nativePath + " " + (tsEnd 
- tsStart).toString() + "ms" + "\n";
+                               prepareToShow();
+                       }
+                       
+                       
+                       private function browseOutFile():void
+                       {
+                               try {
+                                       dest.browseForSave("Output ZWL file");
+                                       dest.addEventListener(Event.SELECT, 
outFileSelected);
+                               } catch (error:Error)
+                               {
+                                       trace("Failed:", error.message);
+                               }
+                       }
+                       
+                       private function outFileSelected(event:Event):void
+                       {                               
+                               tsStart = getTimer();
+                               var bytes:ByteArray = new ByteArray();
+                       bytes.writeObject(suse);
+                       bytes.position = 0;
+                       bytes.compress();
+                       bytes.position = 0;
+                       var outFile:File = new File((event.target as 
File).nativePath);
+                       var outStream:FileStream = new FileStream();
+                       outStream.open(outFile, FileMode.WRITE);
+                       outStream.writeBytes(bytes, 0, bytes.length);
+                       outStream.close();
+                       
+                       exportInfo.text = outFile.nativePath + " (" + 
outFile.size.toString() + " bytes)";
+                               exportInfo.setStyle("color", "green");
+                               
+                               // Debug log
+                       tsEnd = getTimer();
+                       debugInfo.text += "\nZwlExported: " + 
outFile.nativePath + " " + (tsEnd - tsStart).toString() + "ms\n";
+                               
+                       }
+                       
+       
+                       
+                       private function prepareToShow():void
+                       {
+                               
+                               advWordList = new Array();
+                               for (var i:uint=0; i<basicWordList.length; i++) 
{
+                                       // In case some empty string are there
+                                       if (basicWordList[i] != "")
+                                               advWordList.push(new UIWord(i, 
basicWordList[i]));
+                               }
+                       }
+                       
+                       private function genMeta():void
+                       {
+
+                               var _metaphone:MetaPhone= new MetaPhone();
+                               tsStart = getTimer();
+                               for (var i:uint=0; i<advWordList.length; i++) {
+                                       advWordList[i].meta = 
_metaphone.meta(advWordList[i].word, 4);
+                               }
+                               genMetaInfo.text = "Metaphone index generated";
+                               genMetaInfo.setStyle("color", "green");
+                               myDataGrid.dataProvider= advWordList;
+                               // Debug log
+                               tsEnd = getTimer();
+                               debugInfo.text += "\nMetaGenerated: " + (tsEnd 
- tsStart).toString() + "ms\n";
+                       }
+                       
+                       private function genSuseDict():void
+                       {
+                               suse = new SuseDictionary();
+                               tsStart = getTimer();
+                               for (var i:uint=0; i<advWordList.length; i++) {
+                                       if 
(suse.MetaPhoneHash[advWordList[i].meta]) {
+                                               
suse.MetaPhoneHash[advWordList[i].meta].insert(advWordList[i].word);
+                                       }
+                                       else {
+                                               if ((advWordList[i].meta == "") 
|| (advWordList[i].meta == "-nde")) continue;
+                                               
suse.MetaPhoneHash[advWordList[i].meta] = new WordList();
+                                               
suse.MetaPhoneHash[advWordList[i].meta].insert(advWordList[i].word);
+                                       }
+                               }
+                               genDictInfo.text = "SquigglyDict object 
generated";
+                               genDictInfo.setStyle("color", "green");
+                               
+                               // Debug log
+                               tsEnd = getTimer();
+                               debugInfo.text += "\nSquigglyDictGenerated: " + 
(tsEnd - tsStart).toString() + "ms\n";  
+                       }
+                       
+               ]]>
+       </mx:Script>
+       <mx:HBox width="100%">
+               <mx:Label text="Squiggly Dictionary Generator v0.1 (txt2zwl)" 
fontSize="25"/>           
+       </mx:HBox>
+       <mx:HBox width="100%">
+               <mx:Button label="1. Load TXT File" click="browseInFile()"/>
+               <mx:HRule visible="false" width="100%"/>
+               <mx:Label id="loadTxtInfo" text="Not loaded" color="red"/>
+       </mx:HBox>
+       <mx:HBox width="100%">
+               <mx:Button label="2. Calculate Metaphone" click="genMeta()"/>
+               <mx:HRule visible="false" width="100%"/>
+               <mx:Label id="genMetaInfo" text="Not calculated" color="red"/>
+       </mx:HBox>
+       <mx:HBox width="100%">
+               <mx:Button label="3. Generate SquigglyDict" 
click="genSuseDict()"/>             
+               <mx:HRule visible="false" width="100%"/>
+               <mx:Label id="genDictInfo" text="Not generated" color="red"/>
+       </mx:HBox>
+       <mx:HBox width="100%">
+               <mx:Button label="4. Export ZWL File" click = 
"browseOutFile()"/>
+               <mx:HRule visible="false" width="100%"/>
+               <mx:Label id="exportInfo" text="Not exported" color="red"/>
+       </mx:HBox>
+       <mx:HBox width="100%" height="100%">
+               <mx:DataGrid height="100%" id="myDataGrid" dataProvider = "{ 
advWordList }" width="70%">
+                       <mx:columns>
+                               <mx:DataGridColumn headerText="Index" 
dataField="index"/>
+                               <mx:DataGridColumn headerText="Word" 
dataField="word"/>
+                               <mx:DataGridColumn headerText="Metaphone" 
dataField="meta"/>
+                       </mx:columns>
+               </mx:DataGrid>
+               <mx:TextArea id="debugInfo" height="100%" width="30%" />
+       </mx:HBox>
+</mx:WindowedApplication>

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/fd2bc5a5/Squiggly/main/Tools/SpellingDictGen/src/UIWord.as
----------------------------------------------------------------------
diff --git a/Squiggly/main/Tools/SpellingDictGen/src/UIWord.as 
b/Squiggly/main/Tools/SpellingDictGen/src/UIWord.as
new file mode 100644
index 0000000..74c32e5
--- /dev/null
+++ b/Squiggly/main/Tools/SpellingDictGen/src/UIWord.as
@@ -0,0 +1,37 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package
+{
+       public class UIWord
+       {
+               public var index:uint;
+               public var word:String;
+               public var meta:String;
+               
+               public function UIWord(inIndex:uint, inWord:String)
+               {
+                       index = inIndex;
+                       word = inWord;
+                       meta = "";
+               }
+       
+       }
+       
+
+}
\ No newline at end of file

Reply via email to