.TITLE: Mapping raw data to recognized characters


Summary:

In the Microsoft Software Library, there is a sample called Parser.  
This is a Windows for Pens sample that demonstrates how to parse 
through the SYmbol Element (SYE) array of the SYmbol Graph (SYG) 
structure (using the SYmbol Values (SYVs) and the SYmbol 
Correspondence (SYC) arrays where appropriate). The intention 
of the sample is to determine the strokes that are associated 
with the recognized characters.

More Information:

The Parser sample is designed around the following main parts 
of the Windows for Pen system:  the "best guess" array of SYVs, 
the hpendata and the SYE in the SYG structure.  During a single 
recognition session, all the "ink", vector based x,y coordinates 
of the user's input, is stored in the HPENDATA structure of the 
RCRESULT structure.  The lpsyv field, of the RCRESULT structure, 
also contains the "best guess" array of symbol values that the 
system "thinks" that the ink represents.  This "best guess" 
array can be used in conjunction with the array of SYEs in the 
symbol graph and the coorespondence structure to isolate individual 
characters in the ink, and associate them with their corresponding 
ink "strokes" or partial "strokes" in the hpendata structure 

SYG's, SYV's, SYE's and SYC structures are typically the most 
difficult and confusing components of the Windows for Pens 
architecture.  The structures are all interrelated and it 
is necessary to parse one array even as another is being 
similarly parsed.  The Parser sample attempts to illustrate 
how this parsing mechanism works in a clear and fairly simple 
manner.  For more information on SYG's, SYV's, SYE's and SYC's 
please see the Windows for Pens online help file or hardcopy 
guide in the Windows 3.1 Software Development Kit.

The Parser sample is built on the architecture of the View 
sample (This sample can be found in the software library.  
It is also another Windows for Pens sample, that demonstrates 
slow drawing, automatic positioning of text strings returned 
as the "best guess" from the recognizer, and dynamically 
sizing the text string with a matching TrueType font. The 
View sample returns a TrueType sized string of text based 
on the entire hpendata, and uses the bounding rectangle of 
the entire ink data to size the font for the string.  The 
Parser sample is different.  As mentioned above it walks 
the SYE array of the SYG structure looking for the iSyc 
values so the SYC structure can be used to find the 
individual data strokes for the characters in the HPENDATA 
structure.    For example, the letter "t" will typically 
consist of two strokes; though the strokes are not 
necessarily sequential in the HPENDATA structure, 
the cross of the "t" could be done after a number 
of other letters are written.  The SYC will reference 
both strokes and give an index into the HPENDATA so that 
they can be retrieved.

Once the parser sample associates the "best guess" array 
of symbol values to the raw data in the HPENDATA structure, 
the raw data points are then used to determine the "size" 
of the user's input.  Once the size is known, a TrueType 
font is selected.  The size and position of each individual 
character, input by the user, is independent of  all the 
other characters and is displayed as such.  Note that, in 
order for this sample to function properly an "Arial" font 
should be present on the system.

Notes:

The Parser sample currently only displays (as text) up 
to 10 characters, irrespective of how many characters 
are "written" with the ink.  This limitation can be changed 
if the MAXCHARMAP value in the convert.h header file is changed.  
The sample, when DisplayAsText is selected, will also display 
the SYE array in the upper left hand corner of the client area, 
so the user can see the results of the recognition process.

The Parser sample requires the Windows for Pens Computing  
or the Windows 3.1 Pen Extensions to be installed.  The 
Extensions are available from the 3.1 Windows Software 
Development Kit.  The Windows for Pens environment is available 
only from Windows for Pens OEMs 
(Original Equipment Manufacturers).
