Exporting the Word List from a User Dictionary

From NeoWiki

(Difference between revisions)
Jump to: navigation, search
Revision as of 02:41, 2 February 2009 (edit)
Sardisson (Talk | contribs)
(add info about importing into Mac OS X user dictionary)
← Previous diff
Revision as of 17:58, 18 March 2009 (edit) (undo)
Sardisson (Talk | contribs)
(Importing Words into the Mac OS X User Dictionary - add script from yoxi)
Next diff →
Line 19: Line 19:
# Spell-check the file in TextEdit and learn the words. # Spell-check the file in TextEdit and learn the words.
-Tools like [http://www.pariahware.com/dictionaryeditor.php Dictionary Editor] or [http://www.twoamsoftware.com/?q=dc/about Dictionary Cleaner] may also be useful for transferring words into the Mac OS X dictionary.+===Alternate Methods of Adding Large Word Lists to the Mac OS X User Dictionary===
 + 
 +Instead of manually spell-checking the list of words exported from NeoOffice, tools like [http://www.pariahware.com/dictionaryeditor.php Dictionary Editor], [http://www.twoamsoftware.com/?q=dc/about Dictionary Cleaner], or custom scripts may also be useful for transferring words into the Mac OS X dictionary.
 + 
 +[[User:yoxi|yoxi]] has [http://trinity.neooffice.org/modules.php?name=Forums&file=viewtopic&t=7127 pointed out] a Perl script that will take a text file of one-word-per-line as input and turn it into a format that you can paste straight into your <code>~/Library/Spelling/<language code></code> file.
 + 
 +After a restart, all those new terms will be recognised by the spell-checker alongside the ones you've already added.
 + 
 +To use, paste the script into a new plain text file, save it as '''dictify''', and run it from the command line, e.g. <code>./dictify input.file > output.file</code> (where <code>input.file</code> is the one-word-per-line file).
 + 
 +<pre>#!/usr/bin/perl -w
 + 
 +# This script reads a list of strings (one per line) from STDIN
 +# or from the files supplied as command-line arguments
 +# and outputs those strings to STDOUT separated by zeros.
 +# Cameron Hayne (macdev@hayne.net) June 2005
 + 
 +# cl format is ./dictify input.file > output.file where input.file has one word per line
 +# paste contents of output.file into ~/Library/Spelling/en_GB - TextWrangler etc. show the invisibles
 + 
 +my $zerobyte = pack("B8", 0);
 +while (<>)
 +{
 +chomp();
 +print "$_$zerobyte";
 +}</pre>
<!--{{botlangbarEN|[[Fr:Installer_des_Dictionnaires|Français]] [[It:Attivare_i_dizionari_e_configurare_il_controllo_ortografico|Italiano]]}}--> <!--{{botlangbarEN|[[Fr:Installer_des_Dictionnaires|Français]] [[It:Attivare_i_dizionari_e_configurare_il_controllo_ortografico|Italiano]]}}-->
[[Category:Tips and Hints]][[Category:NeoOffice]] [[Category:Tips and Hints]][[Category:NeoOffice]]

Revision as of 17:58, 18 March 2009

You may wish to export the contents of your NeoOffice user dictionary at some point, for instance to sync the contents of this dictionary with your Mac OS X user dictionary.

“Exporting” the User Dictionary

When spell-checking a document, you have the option of adding unrecognized words to a user dictionary. The default user dictionary is standard.dic. If you want to export these words, you can do so as follows:

  1. Locate the dictionary file. It can be found at the following path (where ~ represents your home folder):
    • NeoOffice 2.2.x: ~/Library/Preferences/NeoOffice-2.2/user/wordbook/standard.dic
    • NeoOffice 3.x: ~/Library/Preferences/NeoOffice-3.0/user/wordbook/standard.dic
  2. Copy this file to the Desktop or another location
  3. Edit the name of this file (the copy) so that the extension reads .txt
  4. Open this .txt file in NeoOffice (if asked which filter to use, chose UTF).
  5. You will see a list of words separated by # characters. You can use a global search and replace to format the file as you need to.
  6. You may also need to remove some hard page returns.

Importing Words into the Mac OS X User Dictionary

  1. Follow the steps above to create a list of words from the NeoOffice user dictionary.
  2. Save the list of words (e.g. as a text file)
  3. Open the file in TextEdit
  4. Spell-check the file in TextEdit and learn the words.

Alternate Methods of Adding Large Word Lists to the Mac OS X User Dictionary

Instead of manually spell-checking the list of words exported from NeoOffice, tools like Dictionary Editor, Dictionary Cleaner, or custom scripts may also be useful for transferring words into the Mac OS X dictionary.

has pointed out a Perl script that will take a text file of one-word-per-line as input and turn it into a format that you can paste straight into your ~/Library/Spelling/<language code> file.

After a restart, all those new terms will be recognised by the spell-checker alongside the ones you've already added.

To use, paste the script into a new plain text file, save it as dictify, and run it from the command line, e.g. ./dictify input.file > output.file (where input.file is the one-word-per-line file).

#!/usr/bin/perl -w

# This script reads a list of strings (one per line) from STDIN
# or from the files supplied as command-line arguments
# and outputs those strings to STDOUT separated by zeros.
# Cameron Hayne (macdev@hayne.net) June 2005

# cl format is ./dictify input.file > output.file where input.file has one word per line
# paste contents of output.file into ~/Library/Spelling/en_GB - TextWrangler etc. show the invisibles

my $zerobyte = pack("B8", 0);
while (<>)
{
chomp();
print "$_$zerobyte";
}
Personal tools