[comp.std.internat] Proposal for enhancements to the Macintosh System

jmunkki@santra.UUCP (Juri Munkki) (03/25/88)

This is a repost of an article I posted a few weeks ago. It appears
not to have reached some sites, so I'm crossposting to several groups
this time.

------------

The following file is a proposal for an enhancement to the
Macintosh OS. Please tell me what you think about it.

Remember that this is nothing official and that it has
almost nothing to do with Apple Computer (unless they get
interested, which is what I hope).

I am not an expert on either hyphenation or spelling checkers,
but since no one else has done anything to create a standard
interface, I decided to write preliminary specification for a
small addition to the system file.

Juri Munkki
Helsinki University of Technology Computing Centre
Otakaari 1, Y250A
02150 Espoo

jmunkki@santra.hut.fi
jmunkki@fingate.bitnet

------------


Proposal for a New Macintosh System Service

Introduction

English words tend to be short and hyphenation is not usually 
necessary. Most languages are not as fortunate. The average length of 
Finnish, Swedish and French words is so long that even single-column 
text must often be hyphenated.

Modern word processing applications always have a spelling checker 
and automatic hyphenation. These functions are usually adequate only 
as long as the language being used is English. The Macintosh system 
already provides a set of very useful routines for international 
localization of applications, but there is no standard way to 
localize an application to use foreign hyphenation and proofreading.

The traditional solution has been either to rewrite part of the 
application or to write a general purpose program that works on 
files. Both methods require new work to be done every time a new 
version of the word processor or desktop publishing program is 
released. For this reason, products are released internationally 
months after the program is released in the USA.

This is a proposal to add a new service to the Macintosh operating 
system. The system would provide an interface between any application 
and third party hyphenation modules and spelling checkers. The end-
user will not be aware of any changes in the system until he/she 
copies a special program into the system folder. The American user 
could choose between several spelling checkers and change his/her 
mind later on, if a better product becomes available.

The proposed interface goes beyond simple localization. It allows 
true multilingual word processing. A single document can combine 
several languages. Manuals and school-books are good examples of such 
documents.

Implementation

The interface to the new routines could be added either to the script 
manager or the international utilities package. The interface would 
receive parameters from a program and pass them on to the appropriate 
code resource. Every hyphenation program or spelling checker should 
have a unique ID and name so that any number of them can be used 
simultaneously. The application should be able to request a certain 
resource or ask for the default resource.

The code that actually does the work should be written and sold by 
third parties. Creating a hyphenation routine should be no harder 
than writing a new desk accessory. A single entry point receives 
parameters and returns a result to the interface program.

If a function call is not available in the program, a special error 
message asks the interface to try to satisfy the request. If new 
functions are added to system routines, but an old hyphenation 
program is used, the interface still returns legal results.

Special exception files and dictionaries are managed by the 
hyphenation program. The hyphenation program should come with an 
application that converts between the custom dictionary structure and 
a standard text file dictionary so that user dictionaries can be 
exchanged between programs.



Interfaces, Hyphenation:

Function LoadHyphen(doLoad: boolean; theRAM: longint;
		theProgram: progId) : OSErr;

This function tries to load a hyphenation routine into the 
application heap. If it will take more than TheRAM amount of heap 
space to load the routine, an error is returned. There should be a 
suggested minimum for "TheRam". If doLoad is FALSE, the space used by 
the routines is returned to the heap.

Function HyphWord(textStart: ptr; textLength: longint;
		wordStart: ptr; wordLength, beforeChar: longint;
		Hyphens: HyphListPtr; theProgram: progId) : OSErr;

This routine hyphenates a single word or part of the word. TextStart 
specifies the beginning of readable text. TextLength is the length of 
the readable text. WordStart points to the word to be hyphenated. 
Wordstart should be greater than or equal to textStart. WordLength is 
the length of the word to hyphenate. WordStart+wordLength should be 
less than or equal to textStart+textLength. BeforeChar specifies the 
last possible position for the hyphen. BeforeChar is an offset from 
wordStart.

Hyphens is a pointer to an array of integers. The array should be at 
least 32 integers long and the first item should contain the maximum 
size of the array. Legal hyphen positions are stored in this array. 
The actual number of hyphens is returned in the first item. Following 
items are offsets of possible hyphens from the beginning of the word.

If "polyethylene" was hyphenated as "poly-ethyl-ene", the array would 
look like this: { 2, 4, 10 }. The choice of adding soft hyphens or 
using a custom structure for hyphens is left for the programmer.

Function HyphText(textStart: ptr; textLength: longint;
		Hyphens: HyphListPtr, var lastChar: longint;
		theProgram: progId) : OSErr;

This routine hyphenates long portions of text. The hyphens are 
returned in the array pointed by HyphListPtr. Hyphenation starts from 
offset lastChar. If more hyphens are found that can be stored in the 
array, lastChar will be less than textLength when the function 
returns. The application should then call this routine again after 
processing the hyphens.

Function HyphDialog(defaults: Handle; theProgram: progId) : OSErr;

The hyphenation program should show a dialog box and allow the user 
to change the hyphenation settings. The dialog should be similar in 
purpose to the page setup dialog. The handle should contain some sort 
of signature so that the hyphenation program can recognize it as its 
own.

Function UseHyph(defaults: Handle; theProgram: progId) : OSErr;

The hyphenation routine tries to use the settings in defaults. The 
information in defaults is always validated so that if the program 
calls this routine with an empty handle, it will get the default 
settings in return. These settings can then be used when the file is 
opened later on.




Interfaces, Spelling Checker:

Function LoadSpell(doLoad: boolean; theRAM: longint;
		theProgram: progId) : OSErr;

This function tries to load a spelling checker routine into the 
application heap. If it will take more than TheRAM amount of heap 
space to load the routine, an error should be returned. The minimum 
value for TheRAM should be sufficient to load part of the code into 
memory. If doLoad is FALSE, the space used by the routine is returned 
to the heap.

Function CheckText(theText, fixes: Handle;
		theProgram: progId) : OSErr;

This routine checks the spelling of long portions of text. For every 
misspelled word there is a record in the fixes handle. The record 
contains the offset to the next record, the position and length of 
the error in the original text and the correct spelling. With this 
information, the calling application can fix the spelling while 
retaining all the formatting information of the text. This routine 
will allow the user to add and delete words from custom dictionaries.

Function CheckWord(textStart: ptr; textLength: longint;
		wordStart: ptr; wordLength: longint;
		theProgram: progId) : OSErr;

This routine checks the spelling of a word. If the word is suspected 
to be incorrectly spelled, spellError is returned. This routine 
should be fast, since it is most probably used for interactive 
checking. The calling application might beep or alert the user in 
some way. Slow spelling checkers should do nothing and return noErr.

Function FixSpelling(textStart: Ptr; textLength: longint;
	wordStart: Ptr; wordLength: longint; fix: Handle;
	theProgram: progId) : OSErr;

This routine corrects the spelling of a word. Fix will return the 
correct spelling. This routine will allow the user to add and delete 
words from custom dictionaries. The application should call this 
routine only if the user wants assistance.

Function SpellDialog(defaults: Handle; theProgram: progId) : OSErr;

The spelling checker should show a dialog box allowing the user to 
open custom dictionaries and change settings. The handle should 
contain a signature so that the hyphenation program can recognize it 
as its own.

Function UseSpell(defaults: Handle; theProgram: progId) : OSErr;

The application can store spelling settings in a file. These settings 
can then be used when the file is opened later on. The handle is a 
good place to store the names of opened custom dictionaries.

------------------------------------------------------------------

Juri Munkki
jmunkki@santra.hut.fi
jmunkki@fingate.bitnet