Welcome to palaso.org
Website of the Payap Language Software Development Group
An enchant provider for LIFT
Author cambell | 13.05.2008 | Category WeSay
We wanted to allow users to edit their dictionary and use that same dictionary for spell checking. Since WeSay uses LIFT as the file format for the dictionary and keeps that file up to date, all we needed was an enchant provider that can read LIFT files.
I took the spell checking engine I had written a while back, Ascens, and refactored it so that it could read files of various formats. Currently it supports line based and XML based formats. For line based formats, the words are entered one per line. For XML based formats, an XPath expression determines what text from within the file should be selected to constitute correctly spelled words.
Ascens looks for a settings file with the same name as the language identifier that is passed to enchant. Within the settings file, the location of the dictionary and the type of the dictionary are specified. If the type is xml then the xpath expression should be defined.
The following is an example settings file for Ascens referring to a Lift file:
# This is the settings file for Ascens
[Dictionary]
# Type is either xml or line
# for xml you also need to set the XPath
#Type=line
Type=xml
# path to the dictionary
# (can be absolute or relative to the directory that this file is in)
#Path=c:\documents and settings\user\my documents\dictionaries\fr_FR.dic
#Path=fr_FR.dic
Path=..\..\..\My Documents\WeSay\French\French.lift
# XPath gives the Xpath that selects the words to be used as dictionary
# it must all be on a single line
XPath=//entry[not(citation-form/form[@lang='fr'])]/lexical-unit/form[@lang='fr']/text | //entry/citation-form/form[@lang='fr']/text
# this xpath selects the forms with the language id of 'fr' from the
# citation form when there is one and from the lexical unit when
# there is no citation form (it will not select both)
Enchant looks for user Ascens settings files in the following locations:
- The
ascens
subdirectory of the value found in the registry atHKEY_CURRENT_USER\Software\Enchant\Config\Data_Dir
, if there is one. %APPDATA%\enchant\ascens
, where%APPDATA%
is shorthand for theC:\Users\
folder (Windows Vista) or the\AppData\Roaming\ C:\Documents and Settings\
folder (Windows XP/2000).\Application Data\ - The
enchant\ascens
subdirectory of the directory value found in the registry atHKEY_CURRENT_USER\Software\Enchant\Config\Home_Dir
, if there is one. %USERPROFILE%\enchant\ascens
, where%USERPROFILE%
is shorthand for theC:\Users\
folder (Windows Vista) or theC:\Documents and Settings\
folder (Windows XP/2000).
Enchant looks for shared Ascens settings files in the following locations:
- Using the value found in the registry at
HKEY_CURRENT_USER\Software\Enchant\ascens\Data_Dir
, if there is one. Otherwise, using the value found in the registry atHKEY_LOCAL_MACHINE\Software\Enchant\ascens\Data_Dir
, if there is one.
, where\share\enchant\ascens
is the location oflibenchant.dll.
Categories
- Developers (1)
- Palaso Library (1)
- Solid (11)
- Spelling (3)
- Typesetting (1)
- Uncategorized (2)
- WeSay (36)