|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectdiva.sketch.parser2d.ParsingSceneRecognizer
public class ParsingSceneRecognizer
A grammar-driven scene recognizer that incrementally parses the scene as new tokens are added. Unlike standard parsers, this parser understands the ambiguity in drawings that are imperfectly recognized and simultaneously considers all possible interpretations of the scene. This makes the parser less efficient than a typical string parser, but the parser utilizes incrementality and smart data structures help with the performance.
The grammar is expressed as an array of rules, and the rules are indexed inside the parser according to the types of tokens that they consume. This means that every time a token is added to the scene, the appropriate rules are retrieved from the index and the rest of the required tokens are searched for in the database. All permutations of possible matches are fed to a rule, and if the rule matches, the resulting token is fed back into the process.
Grammar2D
Constructor Summary | |
---|---|
ParsingSceneRecognizer(SceneRecognizer child,
Grammar2D grammar)
Construct a new parser with the specified grammar rules, that uses the given child recognizer to perform lower-level recognition. |
Method Summary | |
---|---|
static void |
debug(String s)
Debugging output. |
Grammar2D |
getGrammar()
Return the grammar that is used to perform the parsing. |
protected SceneDeltaSet |
handleDeltas(SceneDeltaSet deltas,
Scene db)
Handle any deltas that may have occurred in the scene from the addition, modification, or completion of strokes/sessions to the scene database. |
SceneDeltaSet |
parse(CompositeElement e,
Scene db)
Perform a recursive, incremental parse of the element in the given scene, adding the results to the given delta set. |
SceneDeltaSet |
sessionCompleted(StrokeElement[] session,
Scene db)
Pass the "session started" information to the child recognizer and handle the results if there are changes in the scene. |
SceneDeltaSet |
strokeCompleted(StrokeElement stroke,
Scene db)
Pass the "stroke completed" information to the child recognizer and handle the results if there are changes in the scene. |
SceneDeltaSet |
strokeModified(StrokeElement stroke,
Scene db)
Pass the "stroke modified" information to the child recognizer and handle the results if there are changes in the scene. |
SceneDeltaSet |
strokeStarted(StrokeElement stroke,
Scene db)
Pass the "stroke started" information to the child recognizer and handle the results if there are changes in the scene. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ParsingSceneRecognizer(SceneRecognizer child, Grammar2D grammar)
Method Detail |
---|
public Grammar2D getGrammar()
public SceneDeltaSet strokeStarted(StrokeElement stroke, Scene db)
strokeStarted
in interface SceneRecognizer
public SceneDeltaSet strokeModified(StrokeElement stroke, Scene db)
strokeModified
in interface SceneRecognizer
public SceneDeltaSet strokeCompleted(StrokeElement stroke, Scene db)
strokeCompleted
in interface SceneRecognizer
public SceneDeltaSet sessionCompleted(StrokeElement[] session, Scene db)
sessionCompleted
in interface SceneRecognizer
protected SceneDeltaSet handleDeltas(SceneDeltaSet deltas, Scene db)
public SceneDeltaSet parse(CompositeElement e, Scene db)
public static void debug(String s)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |