Пример #1
0
 /* (non-Javadoc)
  * @see SketchMaster.system.Recogniziers.RecognizierSystem#addCategoryExample(int, java.lang.Object)
  */
 @Override
 public void addCategoryExample(int i, Object ink) {
   String temp;
   if (Categories.contains(i)) temp = Categories.get(i);
   else temp = CurrentCategory;
   //    (InkInterface)
   //	logger.info("addint the  exmaple of "+i+"  "+CurrentCategory);
   if (ink instanceof SegmentCluster) {
     //		   logger.info("addding ............"+ink);
     SegmentCluster segment = (SegmentCluster) ink;
     SegmentClusterFeatureSet example = new SegmentClusterFeatureSet();
     example.setSegmentCluster(segment);
     example.initAll();
     SVMFeatureSet feats = example.computeSVMFeatures();
     trainSet.addPositiveExample(temp, feats);
     if (Interactive) TrainSetStrokes.addPositiveExample(temp, segment.getStrokeInSymbol());
     //	  logger.info("  SVM  adding example "+temp);
     // segment.
     trained = false;
   }
 }
Пример #2
0
  private void addCategoryNegativeExample(int i, SegmentCluster ink) {
    String currentCategory;
    if (Categories.contains(i)) currentCategory = Categories.get(i);
    else currentCategory = CurrentCategory;
    //    (InkInterface)
    //   if (ink instanceof  SegmentCluster) {
    SegmentCluster segment = (SegmentCluster) ink;
    SegmentClusterFeatureSet example = new SegmentClusterFeatureSet();
    example.setSegmentCluster(segment);
    example.initAll();
    SVMFeatureSet feats = example.computeSVMFeatures();
    String temp;
    for (int j = 0; j < Categories.size(); j++) {
      temp = Categories.get(j);
      if (!temp.equals(currentCategory)) trainSet.addNegativeExample(temp, feats);
      if (Interactive) TrainSetStrokes.addNegativeExample(temp, ink.getStrokeInSymbol());
    }

    logger.info("  SVM  adding -ve example for  " + currentCategory);
    // segment.
    trained = false;
    //  }
  }