edu.mit.sketch.chem
Class ChemClassifier

java.lang.Object
  extended by edu.mit.sketch.chem.ChemClassifier

public class ChemClassifier
extends java.lang.Object


Field Summary
 int backtrack
           
 double bondLength
           
 java.lang.String chempath
           
 boolean classifyBonds
           
 java.util.List<StrokeGroup> combinedGroups
           
 StrokeGroup[] forcedGroups
           
 java.lang.String[] interpretations
           
 boolean learnBonds
           
 java.util.ArrayList<java.lang.Double> lineerrors
           
 java.util.ArrayList<java.lang.Double> polyerrors
           
 java.util.ArrayList<Polygon> polygons
           
 java.util.ArrayList<java.lang.Double> polymaxerrors
           
 int recwindow
           
 java.util.List<StrokeGroup> strokeGroups
           
 java.util.List<StrokeData> strokes
           
 boolean template
           
 java.lang.String trainFile
           
 StrokeGroup tryGroup
           
 boolean verbose
           
 
Constructor Summary
ChemClassifier()
           
 
Method Summary
 java.util.List<StrokeGroup> alternatives(StrokeGroup sg)
           
 double avgScore()
           
 StrokeGroup bestCandidate(int index)
           
 double bestCandidateProb(int index)
           
 double calculateBondLength()
          Approximate the average length of bonds in the sketch
 void classify(boolean incremental)
           
 Candidate[][] combineCandidateMatrices(Candidate[][] c1, Candidate[][] c2)
           
 void combineGroups()
           
 void forceInterpretation(StrokeGroup sg)
           
 void interpretCandidates(int startstroke)
           
 void interpretLabels(java.lang.String[] labels)
           
 void interpretStrokes()
          Initial interpretation of special objects such as wedge and hash bonds
 boolean isHashBond(java.util.List<StrokeData> strokes, int i, int s)
          Check whether a sequence of strokes seems like a hashed bond
 boolean isWedgeBond(StrokeData sd1)
          Check whether a sequence of strokes seems like a wedge bond
 void loadTrainFile(java.lang.String drsFile)
           
 double localScore(StrokeGroup sg)
           
 void makeHeader()
           
 boolean overlapGroup(StrokeGroup sg1, StrokeGroup sg2)
           
 void polyFit(boolean incremental)
          Generate polygonal approximations for all strokes
 void reInterpret()
           
 void reset(boolean complete)
           
 void resetTrainFile()
           
 void restoreInterpretation(StrokeGroup sg)
           
 void restoreInterpretations()
           
 void setStrokes(java.util.ArrayList<StrokeData> newstrokes)
           
 void setTrainFile(java.lang.String drsFile)
           
 double standardize(double val, double scale)
          Standardize based on average bond length
 void train(java.lang.String labelfile, boolean append)
           
 void tryInterpretation(StrokeGroup sg)
           
 void unTry()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

polygons

public java.util.ArrayList<Polygon> polygons

polyerrors

public java.util.ArrayList<java.lang.Double> polyerrors

lineerrors

public java.util.ArrayList<java.lang.Double> lineerrors

polymaxerrors

public java.util.ArrayList<java.lang.Double> polymaxerrors

bondLength

public double bondLength

interpretations

public java.lang.String[] interpretations

strokes

public java.util.List<StrokeData> strokes

strokeGroups

public java.util.List<StrokeGroup> strokeGroups

combinedGroups

public java.util.List<StrokeGroup> combinedGroups

forcedGroups

public StrokeGroup[] forcedGroups

tryGroup

public StrokeGroup tryGroup

learnBonds

public boolean learnBonds

classifyBonds

public boolean classifyBonds

verbose

public boolean verbose

backtrack

public int backtrack

recwindow

public int recwindow

chempath

public java.lang.String chempath

trainFile

public java.lang.String trainFile

template

public boolean template
Constructor Detail

ChemClassifier

public ChemClassifier()
Method Detail

setStrokes

public void setStrokes(java.util.ArrayList<StrokeData> newstrokes)

resetTrainFile

public void resetTrainFile()

setTrainFile

public void setTrainFile(java.lang.String drsFile)

loadTrainFile

public void loadTrainFile(java.lang.String drsFile)

makeHeader

public void makeHeader()

train

public void train(java.lang.String labelfile,
                  boolean append)

classify

public void classify(boolean incremental)

combineCandidateMatrices

public Candidate[][] combineCandidateMatrices(Candidate[][] c1,
                                              Candidate[][] c2)

reInterpret

public void reInterpret()

interpretCandidates

public void interpretCandidates(int startstroke)

interpretLabels

public void interpretLabels(java.lang.String[] labels)

combineGroups

public void combineGroups()

bestCandidate

public StrokeGroup bestCandidate(int index)

bestCandidateProb

public double bestCandidateProb(int index)

localScore

public double localScore(StrokeGroup sg)

overlapGroup

public boolean overlapGroup(StrokeGroup sg1,
                            StrokeGroup sg2)

alternatives

public java.util.List<StrokeGroup> alternatives(StrokeGroup sg)

avgScore

public double avgScore()

tryInterpretation

public void tryInterpretation(StrokeGroup sg)

unTry

public void unTry()

forceInterpretation

public void forceInterpretation(StrokeGroup sg)

restoreInterpretation

public void restoreInterpretation(StrokeGroup sg)

restoreInterpretations

public void restoreInterpretations()

interpretStrokes

public void interpretStrokes()
Initial interpretation of special objects such as wedge and hash bonds


isHashBond

public boolean isHashBond(java.util.List<StrokeData> strokes,
                          int i,
                          int s)
Check whether a sequence of strokes seems like a hashed bond


isWedgeBond

public boolean isWedgeBond(StrokeData sd1)
Check whether a sequence of strokes seems like a wedge bond


calculateBondLength

public double calculateBondLength()
Approximate the average length of bonds in the sketch


polyFit

public void polyFit(boolean incremental)
Generate polygonal approximations for all strokes


standardize

public double standardize(double val,
                          double scale)
Standardize based on average bond length


reset

public void reset(boolean complete)