Esempio n. 1
0
 public void writeLocalFeatures(Instance instance, BufferedWriter writer) throws IOException {
   boolean useGlobalFeatures = params.getUseGlobalFeatures();
   params.setUseGlobalFeatures(false);
   for (int i = 0; i < instance.size(); i++) {
     SparseFeatureVector localFv =
         calculateFeature(
             instance,
             instance.getGoldLabel(),
             i,
             instance.getSequence().get(i).getNegativeClassLabel());
     localFv.compact();
     LabelUnit label = instance.getGoldLabel().getLabel(i);
     writer.append(label.toString());
     Map<Integer, Double> fvMap = new TreeMap<Integer, Double>();
     for (VectorEntry entry : localFv.getFeatureVectors().get(0).getSv()) {
       fvMap.put(entry.index(), entry.get());
     }
     for (Entry<Integer, Double> fvEntry : fvMap.entrySet()) {
       writer.append(" ");
       writer.append(String.valueOf(fvEntry.getKey()));
       writer.append(":");
       writer.append(String.valueOf(fvEntry.getValue()));
     }
     writer.append("\n");
   }
   writer.flush();
   params.setUseGlobalFeatures(useGlobalFeatures);
 }
Esempio n. 2
0
 public static LabelUnit getNegativeClassLabelUnit() {
   return new WordLabelUnit(O, Parameters.getNegativeClassLabel());
 }
Esempio n. 3
0
 @Override
 public boolean isNegative() {
   return this.type.equals(Parameters.getNegativeClassLabel());
 }