Converting 3rd-party user dictionaries to TX Spell .NET

ckrause

Well-known member
Joined
Oct 9, 2009
Messages
87
Programming Experience
5-10
One of the key principles designing TX Spell .NET was the support for open dictionary formats. TX Spell .NET fully supports the OpenOffice.org Hunspell dictionaries which gives you access to more then 80 dictionaries out-of-the-box.

txspell_dictionary_converter.png


The TX Spell .NET user dictionaries are simple text-based word list files with an encoding indicator at the beginning. This easy concept allows you to create your own user dictionaries without a special dictionary manager (which, of course, is shipped with TX Spell .NET as well). The internal processing and handling of all dictionaries makes this possible.

No proprietary format is required to store the dictionaries. Internally, both dictionaries are converted into a high-performance dictionary that makes the performance outstanding. That implies that it doesn`t matter which format you choose to create your own dictionaries - internally, they have the same performance.

We got many requests regarding other 3rd-party dictionaries and how to convert them into a TX Spell .NET compatible format. Most vendors offer a possibility to export the user dictionaries as text files. They can be directly used in TX Spell .NET when adding the encoding at the beginning as the first entry. For example:

SET iso-8859-1

We started a project to convert various dictionary formats directly into a TX Spell .NET compatible format.

Currently, TX Spell .NET Dictionary Converter is able to convert the following dictionary formats to TX Spell .NET`s *.txd format:

- ComponentOne® SpellChecker (*.dct)
- Keyoti RapidSpell (*.dict)
- TX Text Control® RapidSpell (*.dict)

You can download the dictionary converter here:

TX Spell .NET Dictionary Converter (TXSpell_DicConverter.zip)


About TX Text Control:

TX Text Control was originally released in 1991, since then more than 50,000 copies have been sold. Starting off as a single, small DLL, TX Text Control has made its way through 16-bit DLL and VBX versions to today`s Enterprise edition with its .NET and ActiveX components. The recent addition to the family, TX Text Control .NET Server, offers all of TX Text Control advanced word processing functionality in an easy-to-use server-side .NET component. Customers benefit from these years of experience, large user base, and at the same time, appreciate developing with a mature, reliable product.

Contact Informations:

support@textcontrol.com

North & South America:
Phone: +1 704-370-0110
Phone: +1 877-462-4772 (toll free)

Europe:
Phone: +49 (0)421 42 70 67 10

Asia Pacific:
Phone: +886 2-2797-8508
 
TX Spell .NET: Creating custom context menus

Using context menus in TX Spell .NET is very simple: When connected to TX Text Control, the built-in context menu works out-of-the-box without implementing a single line of code. TX Text Control automatically replaces the default context menu with the built-in spell checking context menu.

But sometimes, you need to build your own menu or you want to combine two context menus. For this purpose, TX Text Control provides the property SpellCheckContextMenuStrip. This property specifies the context menu which is used when the end-user right-clicks a misspelled word.

In the Opening event of the context menu strip, we simply need to get the misspelled word at the current mouse position using the MisspelledWords.GetItem method in order to create the suggestions using TX Spell .NET's Check method. Each suggestion is used to create a new ToolStripMenuItem dynamically that is added to the custom context menu.

private void contextMenuStrip1_Opening(object sender, CancelEventArgs e)
{
// clear all items from the context menu
contextMenuStrip1.Items.Clear();

// get the conversion rate twips vs. pixel
int dpi = (int)(1440 / textControl1.CreateGraphics().DpiX);

// get the location of the mouse
Point location = new Point(
(int)(textControl1.PointToClient(MousePosition).X * dpi),
(int)(textControl1.PointToClient(MousePosition).Y * dpi));

// get the misspelled word at the mouse locaion
word = textControl1.MisspelledWords.GetItem(location);

if (word == null)
return;

txSpellChecker1.CreateSuggestions(word.Text);

// fill up the context menu
foreach (Suggestion suggestion in txSpellChecker1.Suggestions)
{
ToolStripMenuItem item = new ToolStripMenuItem(suggestion.Text);
// attach the click handler
item.Click += new EventHandler(item_Click);

contextMenuStrip1.Items.Add(item);
}

if (contextMenuStrip1.Items.Count == 0)
contextMenuStrip1.Items.Add("No suggestions found.");
}

Finally, on clicking a menu item, the misspelled word is replaced with the selected suggestion text:

void item_Click(object sender, EventArgs e)
{
// replace the misspelled word with the clicked suggestion
textControl1.MisspelledWords.Remove(word, ((ToolStripMenuItem)sender).Text);
}

Download the Visual Studio 2008 project here. At least a TX Text Control .NET for Windows Forms 17.0 trial version and a TX Spell .NET for Windows Forms trial version is required. Happy coding!


About TX Text Control:

TX Text Control was originally released in 1991, since then more than 50,000 copies have been sold. Starting off as a single, small DLL, TX Text Control has made its way through 16-bit DLL and VBX versions to today's Enterprise edition with its .NET and ActiveX components. The recent addition to the family, TX Text Control .NET Server, offers all of TX Text Control advanced word processing functionality in an easy-to-use server-side .NET component. Customers benefit from these years of experience, large user base, and at the same time, appreciate developing with a mature, reliable product.

Contact Informations:

support@textcontrol.com

North & South America:
Phone: +1 704-370-0110
Phone: +1 877-462-4772 (toll free)

Europe:
Phone: +49 (0)421 42 70 67 10

Asia Pacific:
Phone: +886 2-2797-8508
 
Back
Top