http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/a52655ac/Squiggly/main/ASDocExamples/com/adobe/linguistics/spelling/Examples/Air/UserDictionaryExample/src/UserDictionaryExample.mxml ---------------------------------------------------------------------- diff --git a/Squiggly/main/ASDocExamples/com/adobe/linguistics/spelling/Examples/Air/UserDictionaryExample/src/UserDictionaryExample.mxml b/Squiggly/main/ASDocExamples/com/adobe/linguistics/spelling/Examples/Air/UserDictionaryExample/src/UserDictionaryExample.mxml new file mode 100644 index 0000000..d628280 --- /dev/null +++ b/Squiggly/main/ASDocExamples/com/adobe/linguistics/spelling/Examples/Air/UserDictionaryExample/src/UserDictionaryExample.mxml @@ -0,0 +1,132 @@ +<?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. + +--> +<!--- +* @exampleText The following UserDictionaryExample MXML demonstrates how to use the Squiggly user dictionary API to add/remove words and to save to/load from a file. +* +* Note: to make this example work properly, please make sure you have the proper dictionary file in the specified folder +* and put the Squiggly library(AdobeSpellingEngine.swc) in your libs folder. It must be an AIR project for the File class to work. +--> +<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" horizontalAlign="left" initialize="init()"> +<mx:Script> + <![CDATA[ + + + import com.adobe.linguistics.spelling.HunspellDictionary; + import com.adobe.linguistics.spelling.SpellChecker; + import com.adobe.linguistics.spelling.UserDictionary; + + + private var ud:UserDictionary; + private var _newdict:HunspellDictionary = new HunspellDictionary(); + private var sp:SpellChecker; + private function init():void { + _newdict.addEventListener(Event.COMPLETE, handleLoadComplete); + _newdict.load("dictionaries/en_US/en_US.aff", "dictionaries/en_US/en_US.dic"); + } + + private function handleLoadComplete(evt:Event):void + { + sp = new SpellChecker(_newdict); + } + + private function checkWord():void { + if( sp.checkWord( inputWord.text ) ) + result.text = "Result:correct"; + else + result.text = "Result:wrong"; + } + + public function updateWordList():void + { + wordList.text = ""; + + var wl:Vector.<String> = ud.wordList; + for each(var w:String in wl) + { + wordList.text += w + "\n"; + } + + } + + + public function loadDict():void + { + var inFile:File = File.desktopDirectory; + inFile = inFile.resolvePath(filename.text); + if (inFile.exists) + { + var inStream:FileStream = new FileStream(); + inStream.open(inFile, FileMode.READ); + ud = new UserDictionary(inStream.readObject() as Vector.<String>); + inStream.close(); + result1.text = "File loaded"; + } + else + { + ud = new UserDictionary(); + result1.text = "File created"; + } + updateWordList(); + sp.addUserDictionary(ud); + } + + public function saveDict():void + { + var outFile:File = File.desktopDirectory; + outFile = outFile.resolvePath(filename.text); + var outStream:FileStream = new FileStream(); + outStream.open(outFile, FileMode.WRITE); + outStream.writeObject(ud.wordList); + outStream.close(); + result1.text = "File saved" + } + + public function addWord():void + { + ud.addWord(word.text); + updateWordList(); + } + + public function removeWord():void + { + ud.removeWord(word.text); + updateWordList(); + } + + ]]> +</mx:Script> + <mx:HBox> + <mx:TextInput id="filename" text="mywords.ud"/> + <mx:Button id="load" label="Load/New dictionary" click="loadDict()" /> + <mx:Button id="save" label="Save dictionary" click="saveDict()" /> + <mx:Label id="result1" text="Result:"/> + </mx:HBox> + <mx:HBox> + <mx:TextInput id="word" text="myword"/> + <mx:Button id="add" label="Add Word" click="addWord()" /> + <mx:Button id="remove" label="Remove word" click="removeWord()" /> + <mx:Label id="result2" text="Result:"/> + </mx:HBox> + <mx:TextArea id="wordList" height="100" width="100"/> + + <mx:TextInput id="inputWord" text ="test" keyUp="checkWord()"/> + <mx:Button id="check" label="Check Word" click="checkWord()" /> + <mx:Label id ="result" text="Result:"/> +</mx:WindowedApplication>
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/a52655ac/Squiggly/main/ASDocExamples/com/adobe/linguistics/spelling/Examples/Flex/CheckWord/src/CheckWord.mxml ---------------------------------------------------------------------- diff --git a/Squiggly/main/ASDocExamples/com/adobe/linguistics/spelling/Examples/Flex/CheckWord/src/CheckWord.mxml b/Squiggly/main/ASDocExamples/com/adobe/linguistics/spelling/Examples/Flex/CheckWord/src/CheckWord.mxml new file mode 100644 index 0000000..3db2705 --- /dev/null +++ b/Squiggly/main/ASDocExamples/com/adobe/linguistics/spelling/Examples/Flex/CheckWord/src/CheckWord.mxml @@ -0,0 +1,68 @@ +<?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. + +--> +<!--- +* @exampleText The following CheckWord MXML demonstrates how a word is checked by using Squiggly API. +* Note that the results from this example may differ based on dictionary file. +* +* The following steps are taken: +* <ol> +* <li>A <code>SpellingDictionary</code> object is created </li> +* <li>A <code>SpellChecker</code> object is created </li> +* <li>In the mx:application tag, add a function call to <code>init</code> for <code>applicationComplete</code> </li> +* <li>Create <code>init</code> function body: in the body, add an event listener for <code>SpellingDictionary</code> object. +* Then create a <code>URLRequest</code> object to specify the url of dictionary file. Then call the <code>SpellingDictionary</code> +* object <code>load</code> method to load the dictionary from disk or remote URL. +* </li> +* <li> Finish the <code>handleLoadComplete</code> function to attach the <code>SpellingDictionary</code> object to a <code>SpellChecker</code> object</li> +* <li> Add a function to call the <code>CheckWord</code> method of <code>SpellChecker</code> object to verify the correctness of a word. </li> +* <li>Add related MXML component tag and related property. </li> +* </ol> +* +* Note: to make this example work properly, please make sure you have the proper dictionary file in the specified folder +* and put the Squiggly library(AdobeSpellingEngine.swc) in your libs folder. Please see the reference "How to generate Squiggly dictionary". +--> +<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="horizontal" applicationComplete="init()"> +<mx:Script> + <![CDATA[ + import com.adobe.linguistics.spelling.*; + + private var _newdict:HunspellDictionary = new HunspellDictionary(); + private var sp:SpellChecker; + private function init():void { + _newdict.addEventListener(Event.COMPLETE, handleLoadComplete); + _newdict.load("dictionaries/en_US/en_US.aff", "dictionaries/en_US/en_US.dic"); + } + private function handleLoadComplete(evt:Event):void + { + sp = new SpellChecker(_newdict); + } + + private function checkWord():void { + if( sp.checkWord( inputWord.text ) ) + result.text = "Result:correct"; + else + result.text = "Result:wrong"; + } + + ]]> +</mx:Script> + <mx:TextInput id="inputWord" text ="test" keyUp="checkWord()"/> + <mx:Label id ="result" text="Result:"/> +</mx:Application> http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/a52655ac/Squiggly/main/ASDocExamples/com/adobe/linguistics/spelling/Examples/Flex/ConfigExample/src/ConfigExample.mxml ---------------------------------------------------------------------- diff --git a/Squiggly/main/ASDocExamples/com/adobe/linguistics/spelling/Examples/Flex/ConfigExample/src/ConfigExample.mxml b/Squiggly/main/ASDocExamples/com/adobe/linguistics/spelling/Examples/Flex/ConfigExample/src/ConfigExample.mxml new file mode 100644 index 0000000..f5c1b50 --- /dev/null +++ b/Squiggly/main/ASDocExamples/com/adobe/linguistics/spelling/Examples/Flex/ConfigExample/src/ConfigExample.mxml @@ -0,0 +1,77 @@ +<?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. + +--> +<!--- +* @exampleText The following ConfigExample MXML demonstrates the use of ResourceTable.setResource method and SpellingConfiguration class. +* Note that the results from this example may differ based on dictionary file. +* +* The following steps are taken: +* <ol> +* <li>Create a <code>ResourceTable</code> object.</li> +* <li>Map different locales with their resources using <code>ResourceTable.setResource</code> method </li> +* <li>Set <code>SpellingConfiguration.resourceTable</code> equal to the resource table object created above.</li> +* <li>Create some text areas and call<code> SpellUI.enableSpelling</code> method for spell check.</li> +* <li>Spell check is now done using resource set by resource table and AdobeSpellingConfig.xml is ignored.</li> +* </ol> +* +* Note: to make this example work properly, please make sure you have the proper dictionary file in the specified folder +* and put the Squiggly library(AdobeSpellingFramework.swc and AdobeSpellingUI.swc) in your libs folder. Please see the reference "How to generate Squiggly dictionary". +--> +<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" viewSourceURL="srcview/index.html" applicationComplete="init()"> + <mx:Script> + <![CDATA[ + import com.adobe.linguistics.spelling.SpellUI; + import com.adobe.linguistics.spelling.framework.SpellingConfiguration; + import com.adobe.linguistics.spelling.framework.ResourceTable; + + + public function init():void + { + var resourceTable:ResourceTable = new ResourceTable(); + resourceTable.setResource("en_US", {rule:"data/en_US.aff", dict:"data/en_US.dic"}); + resourceTable.setResource("es_ES", {rule:"data/es_ES.aff", dict:"data/es_ES.dic"}); + SpellingConfiguration.resourceTable = resourceTable; + } + public function spellEnglish():void + { + SpellUI.enableSpelling(ta_en,"en_US"); + } + public function spellSpanish():void + { + SpellUI.enableSpelling(ta_es,"es_ES"); + } + + ]]> + </mx:Script> + + <mx:Label text="ConfigExample.mxml Spell checks using SpellingConfiguration class. Does not need AdobeSpellingConfig.xml" fontSize="20"/> + + + + <mx:TextArea id="ta_en" width="50%" height="20%" + text="I know Enlish. Use the context menu to see the suggestions of the missbelled word. " /> + <mx:Button label="Spell English" id="b1" click="spellEnglish()"/> + + <mx:TextArea id="ta_es" width="50%" height="20%" + text="Sé esbañol. Utilice el menú contextual para ver las sugerencias de la palabra mal eskrita. " /> + <mx:Button label="Spell Spanish" id="b2" click="spellSpanish()"/> + +</mx:Application> + + http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/a52655ac/Squiggly/main/ASDocExamples/com/adobe/linguistics/spelling/Examples/Flex/ContextMenuWithResource/locale/en_US/SquigglyContextMenu.properties ---------------------------------------------------------------------- diff --git a/Squiggly/main/ASDocExamples/com/adobe/linguistics/spelling/Examples/Flex/ContextMenuWithResource/locale/en_US/SquigglyContextMenu.properties b/Squiggly/main/ASDocExamples/com/adobe/linguistics/spelling/Examples/Flex/ContextMenuWithResource/locale/en_US/SquigglyContextMenu.properties new file mode 100644 index 0000000..9881a48 --- /dev/null +++ b/Squiggly/main/ASDocExamples/com/adobe/linguistics/spelling/Examples/Flex/ContextMenuWithResource/locale/en_US/SquigglyContextMenu.properties @@ -0,0 +1,19 @@ +# 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. + +# locale/en_US/SquigglyContextMenu.properties +add=Add to dictionary +enable=Enable spelling +disable=Disable spelling http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/a52655ac/Squiggly/main/ASDocExamples/com/adobe/linguistics/spelling/Examples/Flex/ContextMenuWithResource/locale/es_ES/SquigglyContextMenu.properties ---------------------------------------------------------------------- diff --git a/Squiggly/main/ASDocExamples/com/adobe/linguistics/spelling/Examples/Flex/ContextMenuWithResource/locale/es_ES/SquigglyContextMenu.properties b/Squiggly/main/ASDocExamples/com/adobe/linguistics/spelling/Examples/Flex/ContextMenuWithResource/locale/es_ES/SquigglyContextMenu.properties new file mode 100644 index 0000000..cbe3de2 --- /dev/null +++ b/Squiggly/main/ASDocExamples/com/adobe/linguistics/spelling/Examples/Flex/ContextMenuWithResource/locale/es_ES/SquigglyContextMenu.properties @@ -0,0 +1,19 @@ +# 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. + +# locale/es_ES/SquigglyContextMenu.properties +add=Añadir al diccionario +enable=Revisar ortografÃa +disable=Ignorar ortografÃa http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/a52655ac/Squiggly/main/ASDocExamples/com/adobe/linguistics/spelling/Examples/Flex/ContextMenuWithResource/src/ContextMenuWithResource.mxml ---------------------------------------------------------------------- diff --git a/Squiggly/main/ASDocExamples/com/adobe/linguistics/spelling/Examples/Flex/ContextMenuWithResource/src/ContextMenuWithResource.mxml b/Squiggly/main/ASDocExamples/com/adobe/linguistics/spelling/Examples/Flex/ContextMenuWithResource/src/ContextMenuWithResource.mxml new file mode 100644 index 0000000..44d6080 --- /dev/null +++ b/Squiggly/main/ASDocExamples/com/adobe/linguistics/spelling/Examples/Flex/ContextMenuWithResource/src/ContextMenuWithResource.mxml @@ -0,0 +1,74 @@ +<?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. + +--> +<!--- +* @exampleText The following ContextMenuWithResource MXML demonstrates how to localize your spelling context menu with Flex resource when using Squiggly UI components. +* +* <ol> +* <li> Call Squiggly <code>SpellUI.enableSpelling</code> method to enable spell checking when application is initialized.</li> +* <li> Once the locale ComboBox is changed, change localeChain and call updateContextMenuForLocaleChange() function. For more info on localization with resource, see http://livedocs.adobe.com/flex/3/html/help.html?content=l10n_1.html </li> +* <li> In updateContextMenuForLocaleChange(), create an associative array object with proper keys and values by getting resource from SquigglyContextMenu resource. </li> +* <li> Call Squiggly <code>SpellUI.setSpellingMenuEntries</code> method to customize the menu. </li> +* </ol> +* +* Note: to make this example work properly, please make sure you have the proper dictionary files and AdobeSpellingConfig.xml file in the specified folder +* and put the Squiggly libraries (both AdobeSpellingEngine.swc and AdobeSpellingUI.swc) in you libs folder. +* +--> +<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" initialize="init();"> + <mx:Script> + <![CDATA[ + + import com.adobe.linguistics.spelling.SpellUI; + + [Bindable] + private var uiLocales:Array = ["en_US", "es_ES" ]; + + private function uiLocaleChange():void + { + resourceManager.localeChain = [ localeComboBox.selectedItem ]; + updateContextMenuForLocaleChange(); + } + + private function updateContextMenuForLocaleChange():void + { + var contextMenu:Object = + {add:resourceManager.getString('SquigglyContextMenu', 'add'), + enable:resourceManager.getString('SquigglyContextMenu', 'enable'), + disable:resourceManager.getString('SquigglyContextMenu', 'disable')}; + SpellUI.setSpellingMenuEntries(contextMenu); + } + + private function init():void + { + SpellUI.enableSpelling(ta, "en_US"); + } + ]]> + </mx:Script> + + <mx:Metadata> + [ResourceBundle("SquigglyContextMenu")] + </mx:Metadata> + <mx:Label text="Example for contextMenu customization with resource" fontSize="30"/> + <mx:HBox> + <mx:Text text="Locale for Squiggly contextMenu" color="blue"/> + <mx:ComboBox id="localeComboBox" dataProvider="{uiLocales}" change="uiLocaleChange()"/> + </mx:HBox> + <mx:TextArea id="ta" width="50%" height="50%" fontSize="30" y="50" text="Sé esbañol. Utilice el menú contextual para ver las sugerencias de la palabra mal eskrita."/> +</mx:Application> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/a52655ac/Squiggly/main/ASDocExamples/com/adobe/linguistics/spelling/Examples/Flex/CustomContextMenu/src/CustomContextMenu.mxml ---------------------------------------------------------------------- diff --git a/Squiggly/main/ASDocExamples/com/adobe/linguistics/spelling/Examples/Flex/CustomContextMenu/src/CustomContextMenu.mxml b/Squiggly/main/ASDocExamples/com/adobe/linguistics/spelling/Examples/Flex/CustomContextMenu/src/CustomContextMenu.mxml new file mode 100644 index 0000000..41db081 --- /dev/null +++ b/Squiggly/main/ASDocExamples/com/adobe/linguistics/spelling/Examples/Flex/CustomContextMenu/src/CustomContextMenu.mxml @@ -0,0 +1,59 @@ +<?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. + +--> +<!--- +* @exampleText The following CustomContextMenu MXML demonstrates how to customize your spelling context menu when using Squiggly UI components. +* +* +* <ol> +* <li> +* Create an associative array object with proper keys and values. +* </li> +* <li> +* Call Squiggly <code>SpellUI.setSpellingMenuEntries</code> method to customize the menu. We recommend using this API with resource bundle rather than using hard coded string. +* </li> +* <li> +* Call Squiggly <code>SpellUI.enableSpelling</code> method to enable spell checking. +* </li> +* </ol> +* +* Note: to make this example work properly, please make sure you have the proper dictionary files and AdobeSpellingConfig.xml file in the specified folder +* and put the Squiggly libraries (both AdobeSpellingEngine.swc and AdobeSpellingUI.swc) in you libs folder. +--> +<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" initialize="init();"> + <mx:Script> + <![CDATA[ + + import com.adobe.linguistics.spelling.SpellUI; + + public function init():void + { + // This is just for example code purpose, we recommend using this with resource bundle rather than using hard coded string. + var spanishEntries:Object = {enable:"Revisar ortografÃa", disable:"Ignorar ortografÃa", add:"Añadir al diccionario"}; + var result:Boolean = SpellUI.setSpellingMenuEntries(spanishEntries); + if (result == false) trace("Error customizing contextMenu, default menu will be used"); + + SpellUI.enableSpelling(ta, "en_US"); + } + ]]> + </mx:Script> + + <mx:Label text="Example for Spanish contextMenu" fontSize="30"/> + <mx:TextArea id="ta" width="50%" height="50%" fontSize="30" y="50"/> +</mx:Application> http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/a52655ac/Squiggly/main/ASDocExamples/com/adobe/linguistics/spelling/Examples/Flex/GetSuggestion/src/GetSuggestion.mxml ---------------------------------------------------------------------- diff --git a/Squiggly/main/ASDocExamples/com/adobe/linguistics/spelling/Examples/Flex/GetSuggestion/src/GetSuggestion.mxml b/Squiggly/main/ASDocExamples/com/adobe/linguistics/spelling/Examples/Flex/GetSuggestion/src/GetSuggestion.mxml new file mode 100644 index 0000000..912e502 --- /dev/null +++ b/Squiggly/main/ASDocExamples/com/adobe/linguistics/spelling/Examples/Flex/GetSuggestion/src/GetSuggestion.mxml @@ -0,0 +1,84 @@ +<?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. + +--> +<!--- +* @exampleText The following GetSuggestion MXML demonstrates how to get the suggestion list for a mispelled word by using Squiggly API. +* Note that the results from this example may differ based on dictionary file. +* +* The following steps are taken: +* <ol> +* <li>A <code>SpellingDictionary</code> object is created </li> +* <li>A <code>SpellChecker</code> object is created </li> +* <li>In the mx:application tag, add a functon call to <code>init</code> for <code>applicationComplete</code> </li> +* <li>Create <code>init</code> function body: in the body, add a event listener for <code>SpellingDictionary</code> object. +* Then create a <code>URLRequest</code> object to specify the url of dictionary file. Then call the <code>SpellingDictionary</code> +* object <code>load</load> method to load the dictionary from disk or remote URL.</li> +* <li> Finish the <code>handleLoadComplete</code> function to attach the <code>SpellingDictionary</code> object to a <code>SpellChecker</code> object</li> +* <li> Add a function to call the <code>CheckWord</code> method of <code>SpellChecker</code> object to verify the correctness of a word. </li> +* </li> +* <li> For the mispelled word from last step, call the <code>getSuggestions</code> method of <code>SpellChecker</code> object to query the suggestion list +* </li> +* <li>Add related MXML component tag and related property. +* </li> +* </ol> +* +* Note: to make this example work properly, please make sure you have the proper dictionary file in the specified folder +* and put the Squiggly library(AdobeSpellingEngine.swc) in you libs folder. Please see the reference "How to generate Squiggly dictionary". +--> +<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" applicationComplete="init()" horizontalAlign="left"> +<mx:Script> + <![CDATA[ + import com.adobe.linguistics.spelling.*; + + private var _newdict:HunspellDictionary = new HunspellDictionary(); + private var sp:SpellChecker; + private function init():void { + _newdict.addEventListener(Event.COMPLETE, handleLoadComplete); + _newdict.load("dictionaries/en_US/en_US.aff", "dictionaries/en_US/en_US.dic"); + } + private function handleLoadComplete(evt:Event):void + { + sp = new SpellChecker(_newdict); + } + + private function checkWord():void { + suggestions.text= ""; + if( sp.checkWord( inputWord.text ) ) { + result.text = "Result:correct"; + } + else { + result.text = "Result:wrong"; + var sugeestionArr:Array= sp.getSuggestions(inputWord.text); + if (sugeestionArr != null) { + for ( var i:int=0;i< sugeestionArr.length; i++ ) { + suggestions.text= suggestions.text + sugeestionArr[i] + "\n"; + } + } + } + } + + ]]> +</mx:Script> + <mx:HBox> + <mx:TextInput id="inputWord" text ="test" keyUp="checkWord()"/> + <mx:Button id="check" label="Check Word" click="checkWord()" /> + <mx:Label id ="result" text="Result:"/> + </mx:HBox> + <mx:TextArea id="suggestions" height="300" width="100"/> +</mx:Application> http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/a52655ac/Squiggly/main/ASDocExamples/com/adobe/linguistics/spelling/Examples/Flex/SpellingServiceEsg/src/SpellingServiceEsg.mxml ---------------------------------------------------------------------- diff --git a/Squiggly/main/ASDocExamples/com/adobe/linguistics/spelling/Examples/Flex/SpellingServiceEsg/src/SpellingServiceEsg.mxml b/Squiggly/main/ASDocExamples/com/adobe/linguistics/spelling/Examples/Flex/SpellingServiceEsg/src/SpellingServiceEsg.mxml new file mode 100644 index 0000000..c51e4ac --- /dev/null +++ b/Squiggly/main/ASDocExamples/com/adobe/linguistics/spelling/Examples/Flex/SpellingServiceEsg/src/SpellingServiceEsg.mxml @@ -0,0 +1,98 @@ +<?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. + +--> +<!--- +* @exampleText The following SpellingServiceEsg MXML demonstrates the use of SpellingService class. +* Note that the results from this example may differ based on dictionary file. +* +* The following steps are taken: +* <ol> +* <li>A <code>ResourceTable</code> object is created and locales are mapped to file URLs.</li> +* <li><code>SpellingService</code> object is created and initialized</li> +* <li><code>SpellingServicecheckWord</code> method is used to check word and output is displayed</li> +* <li>A <code>UserDictionary</code> object is created and a word is added to it.</li> +* <li>A word is added to the user dictionary which in turn is added to SpellingService Object using <code>SpellingService.addUserDictionary</code> method.</li> +* <li> <code>SpellingService.checkWord</code> API is again called.</li> +* <li>The userDictionary is removed using <code>SpellingService.removeUserDictionary</code> method.</li> +* </ol> +* +* Note: to make this example work properly, please make sure you have the proper dictionary file in the specified folder +* and put the Squiggly library(AdobeSpellingEngine.swc) in your libs folder. Please see the reference "How to generate Squiggly dictionary". +--> +<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" + xmlns:s="library://ns.adobe.com/flex/spark" + xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" initialize="init();"> + <fx:Declarations> + <!-- Place non-visual elements (e.g., services, value objects) here --> + </fx:Declarations> + <fx:Script> + <![CDATA[ + import com.adobe.linguistics.spelling.framework.*; + import com.adobe.linguistics.spelling.*; + + private var spellingService:SpellingService = null; + + private function init():void { + result.text += "AdobeSpellingServiceFramework tests\n===================\n"; + result.text += "Setting SpellingConfiguration and initializing SpellingService ...\n"; + + var resourceTable:ResourceTable = new ResourceTable(); + resourceTable.setResource("en_US", {rule:"data/en_US.aff", dict:"data/en_US.dic"}); + SpellingConfiguration.resourceTable = resourceTable; + + spellingService = new SpellingService("en_US"); + spellingService.addEventListener(Event.COMPLETE, spellingServiceReady); + spellingService.init(); + } + + private function spellingServiceReady(e:Event):void { + result.text += "SpellingService ready for use\n"; + + result.text += "Checking \"hello\" ... " + spellingService.checkWord("hello") + "\n"; + result.text += "Checking \"heello\" ... " + spellingService.checkWord("heello") + "\n"; + result.text += "Getting suggestions for \"heello\" ... " + spellingService.getSuggestions("heello") + "\n"; + + + var ud:UserDictionary = new UserDictionary(); + result.text += "Adding \"heello\" to UserDictionary ..." + ud.addWord("heello") + "\n"; + result.text += "Adding UserDicitonary to SpellingService ..." + spellingService.addUserDictionary(ud) +"\n"; + result.text += "Checking \"heello\" again, expect true ..." + spellingService.checkWord("heello") + "\n"; + + result.text += "Removing \"heello\" from UserDictionary ..." + ud.removeWord("heello") + "\n" + result.text += "Checking \"heello\" again, expect false ..." + spellingService.checkWord("heello") + "\n"; + + result.text += "Number of UserDictionary, expect 1 ..." + spellingService.userDictionaries.length + "\n"; + + var ud2:UserDictionary = new UserDictionary(); + result.text += "Adding UserDicitonary 2 to SpellingService ..." + spellingService.addUserDictionary(ud2) +"\n"; + result.text += "Adding \"heello\" to UserDictionary 2 ..." + ud2.addWord("heello") + "\n"; + result.text += "Checking \"heello\" again, expect true ..." + spellingService.checkWord("heello") + "\n"; + result.text += "Number of UserDictionary, expect 2 ..." + spellingService.userDictionaries.length + "\n"; + + spellingService.removeUserDictionary(ud); + spellingService.removeUserDictionary(ud2); + result.text += "Checking \"heello\" again after removing all UserDictionaries, expect false ..." + spellingService.checkWord("heello") + "\n"; + result.text += "Number of UserDictionary, expect 0 ..." + spellingService.userDictionaries.length + "\n"; + + } + + ]]> + </fx:Script> + <mx:Text id="result"/> +</s:Application> http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/a52655ac/Squiggly/main/ASDocExamples/com/adobe/linguistics/spelling/Examples/Flex/SpellingServiceExample/src/AdobeSpellingFrameworkExample.mxml ---------------------------------------------------------------------- diff --git a/Squiggly/main/ASDocExamples/com/adobe/linguistics/spelling/Examples/Flex/SpellingServiceExample/src/AdobeSpellingFrameworkExample.mxml b/Squiggly/main/ASDocExamples/com/adobe/linguistics/spelling/Examples/Flex/SpellingServiceExample/src/AdobeSpellingFrameworkExample.mxml new file mode 100644 index 0000000..0fc24f3 --- /dev/null +++ b/Squiggly/main/ASDocExamples/com/adobe/linguistics/spelling/Examples/Flex/SpellingServiceExample/src/AdobeSpellingFrameworkExample.mxml @@ -0,0 +1,80 @@ +<?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. + +--> +<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" + xmlns:s="library://ns.adobe.com/flex/spark" + xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" initialize="init();"> + <fx:Declarations> + <!-- Place non-visual elements (e.g., services, value objects) here --> + </fx:Declarations> + <fx:Script> + <![CDATA[ + import com.adobe.linguistics.spelling.framework.*; + import com.adobe.linguistics.spelling.*; + + private var spellingService:SpellingService = null; + + private function init():void { + result.text += "AdobeSpellingServiceFramework tests\n===================\n"; + result.text += "Setting SpellingConfiguration and initializing SpellingService ...\n"; + + var resourceTable:ResourceTable = new ResourceTable(); + resourceTable.setResource("en_US", {rule:"data/en_US.aff", dict:"data/en_US.dic"}); + SpellingConfiguration.resourceTable = resourceTable; + + spellingService = new SpellingService("en_US"); + spellingService.addEventListener(Event.COMPLETE, spellingServiceReady); + spellingService.init(); + } + + private function spellingServiceReady(e:Event):void { + result.text += "SpellingService ready for use\n"; + + result.text += "Checking \"hello\" ... " + spellingService.checkWord("hello") + "\n"; + result.text += "Checking \"heello\" ... " + spellingService.checkWord("heello") + "\n"; + result.text += "Getting suggestions for \"heello\" ... " + spellingService.getSuggestions("heello") + "\n"; + + + var ud:UserDictionary = new UserDictionary(); + result.text += "Adding \"heello\" to UserDictionary ..." + ud.addWord("heello") + "\n"; + result.text += "Adding UserDicitonary to SpellingService ..." + spellingService.addUserDictionary(ud) +"\n"; + result.text += "Checking \"heello\" again, expect true ..." + spellingService.checkWord("heello") + "\n"; + + result.text += "Removing \"heello\" from UserDictionary ..." + ud.removeWord("heello") + "\n" + result.text += "Checking \"heello\" again, expect false ..." + spellingService.checkWord("heello") + "\n"; + + result.text += "Number of UserDictionary, expect 1 ..." + spellingService.userDictionaries.length + "\n"; + + var ud2:UserDictionary = new UserDictionary(); + result.text += "Adding UserDicitonary 2 to SpellingService ..." + spellingService.addUserDictionary(ud2) +"\n"; + result.text += "Adding \"heello\" to UserDictionary 2 ..." + ud2.addWord("heello") + "\n"; + result.text += "Checking \"heello\" again, expect true ..." + spellingService.checkWord("heello") + "\n"; + result.text += "Number of UserDictionary, expect 2 ..." + spellingService.userDictionaries.length + "\n"; + + spellingService.removeUserDictionary(ud); + spellingService.removeUserDictionary(ud2); + result.text += "Checking \"heello\" again after removing all UserDictionaries, expect false ..." + spellingService.checkWord("heello") + "\n"; + result.text += "Number of UserDictionary, expect 0 ..." + spellingService.userDictionaries.length + "\n"; + + } + + ]]> + </fx:Script> + <mx:Text id="result"/> +</s:Application> http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/a52655ac/Squiggly/main/ASDocExamples/com/adobe/linguistics/spelling/Examples/Flex/SquigglyUIExample/src/SquigglyUIExample.mxml ---------------------------------------------------------------------- diff --git a/Squiggly/main/ASDocExamples/com/adobe/linguistics/spelling/Examples/Flex/SquigglyUIExample/src/SquigglyUIExample.mxml b/Squiggly/main/ASDocExamples/com/adobe/linguistics/spelling/Examples/Flex/SquigglyUIExample/src/SquigglyUIExample.mxml new file mode 100644 index 0000000..0c4fcef --- /dev/null +++ b/Squiggly/main/ASDocExamples/com/adobe/linguistics/spelling/Examples/Flex/SquigglyUIExample/src/SquigglyUIExample.mxml @@ -0,0 +1,55 @@ +<?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. + +--> +<!--- +* @exampleText The following SquigglyUIExample MXML demonstrates how to use Squiggly UI API to easily integrate Squiggly with your own UI component. +* +* Note that the results from this example may differ based on dictionary file. +* +* Only one line code is needed: +* <ol> +* <li> +* Call Squiggly <code>SpellUI.enableSpelling</code> method to attach the <code>TextArea</code> component and the dictionary file. +* </li> +* </ol> +* +* Note: to make this example work properly, please make sure you have the proper dictionary files and AdobeSpellingConfig.xml file in the specified folder +* and put the Squiggly libraries (both AdobeSpellingEngine.swc and AdobeSpellingUI.swc) in your libs folder. +--> +<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical"> +<mx:Script> + <![CDATA[ + import com.adobe.linguistics.spelling.SpellUI; + + private function enableFeature():void { + SpellUI.enableSpelling(textArea, "en_US"); + } + private function disableFeature() :void { + SpellUI.disableSpelling(textArea); + + } + ]]> +</mx:Script> + + <mx:TextArea id="textArea" width="20%" height="20%" fontSize="30" text="Spell cheecking in TextArea "/> + <mx:Button id="tt1" label="disable Feature" click="disableFeature()" /> + <mx:Button id="tt2" label="enable Feature" click="enableFeature()" /> + +</mx:Application> + http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/a52655ac/Squiggly/main/ASDocExamples/com/adobe/linguistics/spelling/Examples/Flex/SquigglyUIExample/src/SquigglyUIexampleDictload.mxml ---------------------------------------------------------------------- diff --git a/Squiggly/main/ASDocExamples/com/adobe/linguistics/spelling/Examples/Flex/SquigglyUIExample/src/SquigglyUIexampleDictload.mxml b/Squiggly/main/ASDocExamples/com/adobe/linguistics/spelling/Examples/Flex/SquigglyUIExample/src/SquigglyUIexampleDictload.mxml new file mode 100644 index 0000000..01bb825 --- /dev/null +++ b/Squiggly/main/ASDocExamples/com/adobe/linguistics/spelling/Examples/Flex/SquigglyUIExample/src/SquigglyUIexampleDictload.mxml @@ -0,0 +1,79 @@ +<?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:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical"> --> +<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" + xmlns:s="library://ns.adobe.com/flex/spark" + xmlns:mx="library://ns.adobe.com/flex/mx" + xmlns:popup="popup.*" + minWidth="955" minHeight="600" > + <!-- creationComplete="startRotation()" viewSourceURL="srcview/index.html"--> + <fx:Script> + <![CDATA[ + import com.adobe.linguistics.spelling.SpellUI; + /*//------------------------ + //thread variable + private var thread:PseudoThread; + //this is a thread function added + private function launchThread():void + { + thread = new PseudoThread(systemManager, enableFeature); + thread.addEventListener("threadComplete", threadCompleteHandler); + } + //a do nothing fucntion + private function threadCompleteHandler(event:Event):void + { + } + //--------------------------*/ + private function enableFeature():void { + /* var str1:String="C:/p4_garuda1890_ugoyal-xp/esg/users/ravi/squiggly/main/ASDocExamples/com/adobe/linguistics/spelling/Examples/Flex/SquigglyUIExample/"; + var str2:String="AdobeSpellingConfig.xml"; + //result.text=str1+ta.text; + SpellUI.spellingConfigURL =str1+str2;*/ + SpellUI.enableSpelling(textArea, "pt_PT"); + } + private function disableFeature() :void { + SpellUI.disableSpelling(textArea); + + } + + + //-------------------------------- + /* private function startRotation():void //add this above + { + addEventListener("enterFrame", enterFrameHandler); + } + + private function enterFrameHandler(event:Event):void + { + //trace("enterFrame"); + rbutton.rotation += 14; + } + //---------------------------*/ + ]]> + </fx:Script> + <s:layout> + <s:VerticalLayout/> + </s:layout> + + <mx:TextArea id="textArea" width="20%" height="20%" fontSize="30" text="Spell cheecking in TextArea "/> + <mx:Button id="tt1" label="disable Feature" click="disableFeature()" /> + <mx:Button id="tt2" label="enable Feature" click="enableFeature()" /> +<!-- <mx:Button id="rbutton" label="Rotating Button"/> --> +</s:Application> \ No newline at end of file
