RCL: Recognition Configuration Language

RCL stands for Recognition Configuration Language. It is a package for configuring groups of recognizers using a declarative XML-based language. This package is throw-away code since it will later be absorbed into something more general.

RCL is useful for several reasons:

Basic Usage

RCL consists of hierarchies of "scene" and "stroke" recognizers. Scene recognizers can contain other scene recognizers, stroke recognizers can contain stroke recognizers.  Scene recognizers can contain stroke recognizers, but the stroke recognizers are automatically adapted by the parser using the StrokeSceneRecognizer class.  The recognizers are built using "builder" objects, so the command:

<recognizer>
   
<builderDecls>
        <builder name="CalligrapherRecognizer" 
                class="diva.sketch.calligrapher.CalligrapherRecognizer"
                builder="diva.sketch.calligrapher.CalligrapherBuilder"/>
    </builderDecls>

    <sceneRecognizer class="CalligrapherRecognizer">
        <param name="systemDict" value="ps.voc"/>
        <param name="userDict" value="user.voc"/>
    </sceneRecognizer>
</recognizer>

will create a CalligrapherRecognizer object with the given parameters.  The builderDecls clause states that the class CalligrapherBuilder will actually build the CalligrapherRecognizer.

Here is a more complex example that references two external files:

<recognizer>
    <bulderDecls ref="system.xml"/>
    <sceneRecognizer class="PPTParser">
        <sceneRecognizer class="VotingSceneRecognizer">
            <strokeRecognizer class="VotingStrokeRecognizer">
                <strokeRecognizer class="ScribbleRecognizer"/>
                <strokeRecognizer class="BasicStrokeRecognizer">
                    <param name="trainingFile" value="shapes.tc"/>
                </strokeRecognizer>
            </strokeRecognizer>
            <sceneRecognizer ref="TextRecognizer.xml"/>
        </sceneRecognizer>
    </sceneRecognizer>
</recognizer>

In this example, "system.xml" contains aliases for the builders of each of the classes in this file, and "TextRecognizer.xml" contains another hierarchical recognizer configuration.

Adding New Recognizers

It is simple to add a new recognizer to RCL.  There are several cases:

If the recognizer is a StrokeRecognizer that has no parameters, add a ClassBuilder alias to the aliases file.  For instance:

<builder name="ScribbleRecognizer class="diva.sketch.toolbox.ScribbleRecognizer" builder="diva.sketch.rcl.ClassBuilder"/>

This alias instructs ClassBuilder to build the recognizer based on its class name.

If the recognizer is a scene recognizer that uses a single scene recognizer as its child and has no parameters, add a SceneClassBuilder alias to the aliases file.  For instance:

<builder name="PPTParser" class="pptest.PPTParser" builder="diva.sketch.rcl.SceneClassBuilder"/>

Otherwise, build your own RCLBuilder that does the right thing for your class.  For instance:

<builder name="CalligrapherRecognizer" class="diva.sketch.calligrapher.CalligrapherRecognizer" builder="diva.sketch.calligrapher.CalligrapherBuilder"/>

public class CalligrapherBuilder implements RCLBuilder {
    public Object build(List children, Map params, String config) throws Exception {
        String systemDict = (String)params.get("systemDict");
        String userDict = (String)params.get("userDict");
        return new CalligrapherRecognizer(systemDict, userDict);
    }
}

Future Work

RCL is an exploratory programming exercise.  It may grow into a more powerful configuration language that also componentizes the interpretation and behavior of sketch-based programs.  It may go away entirely.  In the meantime, here are some concrete deficiencies of RCL that I intend to fix: