Pages: 1
Print
Author Topic: Obtaining and Using Hunspell Compatible Dictionaries with XMetaL Author  (Read 6082 times)
Derek Read
Program Manager (XMetaL)
Administrator
Member

Posts: 2513



WWW
« on: February 27, 2013, 06:19:22 PM »

Products:
XMetaL Author Enterprise version 8.0 and up
XMetaL Author Essential version 8.0 and up
XMAX version 8.0 and up (Writing Tools)

Hunspell Spell Checking Engine:
To give clients more spell checking options, in addition to the 30 languages included with the XMetaL Author spell checker, the 8.0 release now integrates an additional spell checking engine called Hunspell. This allows XMetaL Author to use Hunspell compatible dictionary files to extend or replace the out of the box spell checking functionality for languages of your choice and to add support for additional languages if available.

This new feature should be useful to anyone that finds the current spell checking for a particular language in XMetaL Author lacking or for people that need to spell check languages that are not directly supported. It should also allow more advanced users to create their own Hunspell compatible spell checking dictionaries using tools related to the Hunspell and related projects.

This means you can now do the following:
  • Use any of the 30 supported languages just as you have with previous versions of XMetaL Author.
  • Add a Hunspell compatible dictionary for a supported language and use it together with the existing spell checking for that language. The list of words and the rules from the built-in engine will be combined with the Hunspell list and rules.
  • Add a Hunspell compatible dictionary for a supported language and disable the existing spell checking for that language. Only the list of words and rules from the Hunspell files will be used.
  • Add a new language that is not included as part of the 30 existing spell checking languages.

User Word Lists:
The existing "user word list" functionality (the "Add to Dictionary" feature) continues to function as it always has with the original spell checking engine. To keep things simple, the same system of .UWL files is used to keep track of words you add even when a Hunspell compatible dictionary is being used (.UWL files are "per language" not "per dictionary", with each language supporting more than one dictionary file).

Obtaining Compatible Files:
Any current Hunspell dictionary file should be compatible. These files come with .DIC and .AFF file extensions, with the .DIC file being the primary file and the .AFF file being an additional file required for many languages (the first file is essentially the list of words while the secondary file is essentially a set of rules).

The Hunspell engine also supports languages that work with the MySpell engine (Hunspell is based on the MySpell engine) however, JustSystems has not tested any MySpell compatible files and so we are unable to say whether they can be used with the version of Hunspell that we have incorporated into XMetaL Author.

The files for each language are typically maintained by different individuals or projects (usually people or organizations that specialize in specific languages) and so each can have its own documentation and possibly a EULA and rules for use. For this reason you must currently download your own copy of the files for a particular language.

Sources:
Potential sources for Hunspell compatible files include the following:

Extracting:
If the files you obtain are .DIC and .AFF files then you can use them directly. However, these files are often included as part of a larger package designed to work with specific software. In that case you may need to extract the .DIC and .AFF files from the package.

The .OXT Format - Open Office and LibreOffice extension files:

These files are packaged with an .OXT file extension and cannot be used directly with XMetaL Author. However, .OXT files are .ZIP files, so their contents are easily extracted.
If you obtain an .OXT file you can extract the .DIC and .AFF files as follows. You will not need any other files from the package.
  • Find the .OXT file you downloaded.
  • Change the file extension from .OXT to .ZIP.
  • Use Windows zip file extraction tool (built into Windows Explorer's right click menu) or your favourite file compression tool (Winzip, 7-zip, etc) to extract the contents.
  • The structure of the extracted content will vary by language so you will need to browse the extracted files (and folders if any) to locate the .DIC and .AFF file. Note that a .AFF is not always required and some languages may not include one.

The .XPI Format - Mozilla Thunderbird add-on files:

These files are packaged with an .XPI file extension and cannot be used directly with XMetaL Author. However, .XPI files are .ZIP files, so their contents can be extracted.
If you obtain an .XPI file you can extract the .DIC and .AFF files as follows. You will not need any other files from the package.
  • Find the .XPI file you downloaded.
  • Change the file extension from .XPI to .ZIP.
  • Use Windows zip file extraction tool (built into Windows Explorer's right click menu) or your favourite file compression tool (Winzip, 7-zip, etc) to extract the contents.
  • The structure of the extracted content will vary by language so you will need to browse the extracted files (and folders if any) to locate the .DIC and .AFF file. Note that some languages may not need a .AFF file.

Configuring the spell checker to use a Hunspell compatible dictionary
Once you have a compatible .DIC file (and .AFF file if provided) use the following the procedure to configure XMetaL Author to use them.
  • Copy the Hunspell compatible dictionary file(s) to a computer with XMetaL Author installed.
    You may place these files in any folder on your computer.
    Note: For XMetaL Author to locate and use an .AFF file it must have the same name and be in the same folder as the .DIC file. Depending on the files you receive this might mean having to rename the .AFF file.
  • Launch XMetaL Author.
  • Open any XML or SGML document in Tags On or Normal view (a document must be open to enable the Spell Checker).
  • Open the spell checker dialog (labelled "Writing Tools" because it also supports a thesaurus for some built-in languages) by selecting Tools > Spell Checker. If you are prompted to close the spell checker click the "No" button.
  • Perform the following substeps only if the language is NOT in the list of spell checking languages:
    • Open the "Select Language" dialog by clicking Options > Language.
    • Click the "Add..." button.
    • Type a new "Language Code" and "Description" and click OK. You may invent these yourself. The only requirement is that the Language Code is not already used by a default language.
    • From the "Language" list, select the new entry for the "Language Code" you just created.
    • Enable (check) the "Save as default Writing Tools language" checkbox.
    • Click OK.
    • A dialog titled "Unsupported Language..." should appear.
    • In that dialog click the "Find File..." button then browse to and select the .DIC file then click the "Open" button. A dialog labelled Main Word Lists should be opened with the path to your .DIC file highlighted and enabled.
    • Close the Main Word Lists dialog.
    • Close the Writing Tools dialog.

    Perform the following substeps only if the language is ALREADY in the list of spell checking languages:
    • Open the "Main Word Lists" dialog by clicking Options > Main Word Lists.
    • Click the "Add List..." button then browse to and select your Hunspell compatible .DIC file.
    • (optional) Disable (deselect the checkbox) any files you do not wish to use for spell checking for this language. XMetaL Author will use all enabled files when looking for a match.
    • Close the Main Word Lists dialog.
    • Close the Writing Tools dialog.
  • Restart XMetaL Author to start spell checking with the newly added Hunspell dictionary.

Most of the time you will want to set the language you have added a Hunspell dictionary for to be the "default Writing Tools" language. However, there are other ways to spell check (using xml:lang and APIs) so this is not necessarily the case for everyone. Refer to the XMetaL Author Help for information on additional spell checker functionality, including support for xml:lang. Refer to the XMetaL Developer Programmers Guide for information on APIs that can be used to alter spell checking functionality.

External References:
« Last Edit: March 14, 2016, 12:02:03 PM by Derek Read » Logged
Pages: 1
Print
Jump to:  

email us