Esempio n. 1
0
 public boolean train(DataIter trainData, boolean cachedLabels, boolean collectIds)
     throws Exception {
   // map the y-values in the training set.
   boolean labelsMapped = false;
   if (cachedLabels) {
     labelsMapped = stateMappings(trainData);
   }
   if (dict != null) dict.train(trainData, model.numStates());
   for (WordsInTrain d : otherDicts) {
     d.train(trainData, model.numStates());
   }
   boolean requiresTraining = false;
   for (int f = 0; f < features.size(); f++) {
     if (getFeature(f).requiresTraining()) {
       requiresTraining = true;
       break;
     }
   }
   if (requiresTraining) {
     for (trainData.startScan(); trainData.hasNext(); ) {
       DataSequence seq = trainData.next();
       for (int f = 0; f < features.size(); f++) {
         if (getFeature(f).requiresTraining()) {
           trainFeatureType(getFeature(f), seq);
         }
       }
     }
   }
   if (collectIds) totalFeatures = featureMap.collectFeatureIdentifiers(trainData, maxMemory());
   return labelsMapped;
 };
Esempio n. 2
0
 public void collectAndFreezeFeatures(DataIter trainData) throws Exception {
   featureMap.collectFeatureIdentifiers(trainData, 1);
 }