Spell Checker Service

Submitted by Robert Szeleney on Mon, 2006-11-20 12:23.

A spell checker service has been implemented making it very easy to bring spell checking support to your application.

An application which wants to spell check just has to talk with the spell checking service, completely hiding the complex actual spell checking.

A short command line utility example to check a simple word and print suggestions if the word is not correct:

#include "libdcs/libdcs.h"

int main(int argc, char *argv[])

{
	sDCSInterface *pInterface;
	sDCSMessage   *pMessage;
	HRESULT hr;

	int iCorrect;
	int i;
	char str[255];

	char pWord[255];

	printf("Enter word to check: ");

	gets(pWord);

	DCS_RegisterInterface("Application.Spell.Source", &pInterface);

	DCS_AllocMessage(&pMessage, "Check");
	DCS_AddMessageString(pMessage, "Word", pWord);

	hr = DCS_SendMessage(pInterface, "Service.SpellChecker.Requests", pMessage);
	if (hr != S_OK)

	{
		printf("Spell checking service not running.\n");
		exit(1);

	}

	if (DCS_WaitForMessage(pInterface, NULL, &pMessage) == S_OK)

	{
		if (DCS_MessageGetInteger(pMessage, "Correct", &iCorrect) == S_OK)

		{
			if (iCorrect)
				printf("Word is correct.\n");

			else
			{
				printf("Word is not correct. Suggestions:\n");

				DCS_AllocMessage(&pMessage, "Suggestions");

				DCS_AddMessageString(pMessage, "Word", pWord);
				DCS_SendMessage(pInterface, "Service.SpellChecker.Requests", pMessage);

				if (DCS_WaitForMessage(pInterface, NULL, &pMessage) == S_OK)

				{
					i = 0;
					while (1)

					{
						sprintf(str, "Suggestion%d", i);
						if (DCS_MessageGetStringPtr(pMessage, str))

						{
							printf("%s\n", DCS_MessageGetStringPtr(pMessage, str));

							i++;
						}
						else
							break;
					}

				}
			}
		}
	}
}

This utility will output:

Enter word to check: heavn

Word is not correct. Suggestions:
heaven
heaving
Haven
haven
heave
heavy
Havana
having
heavens
Evan
Han
hen
Bevan
Devan
Kevan
heaver
Hahn
have
heaven's

As usual, you can easily disable/enable the service with System Manager.
This service will also be used by SkyOS GUI widgets, making it possible to auto-spell-check text in controls like edit fields and every text editor based on a text control.



ovsJQBQX

MvHDDEu ovsJQBQX

fnbeGW

nabVoMQA fnbeGW