@Test public void testMulticlassExample() { WriteSVMLightFormat writeSVMLightFormat = new WriteSVMLightFormat(false, false, false); String negOutput = writeSVMLightFormat.writeFeatureExample("2", feats); logger.info(negOutput); assertEquals(EXPECTED_MULTI_FIRST, negOutput); String posOutput = writeSVMLightFormat.writeFeatureExample("whatever", feats2); logger.info(posOutput); assertEquals(EXPECTED_MULTI_SECOND, posOutput); }
public String writeFeatureExample(String label, Collection<Feature> activeFeatures) { int lab = getLabel(label); int[] featIds = new int[activeFeatures.size()]; int index = 0; for (Feature f : activeFeatures) featIds[index++] = featureLex.getFeatureId(f.getName()); Arrays.sort(featIds); StringBuilder bldr = new StringBuilder(); bldr.append(lab); for (int featId : featIds) bldr.append(" ").append(featId).append(":1"); return bldr.toString(); }
WriteSVMLightFormat { public String writeFeatureExample(String label, Collection<Feature> activeFeatures) { int lab = getLabel(label); int[] featIds = new int[activeFeatures.size()]; int index = 0; for (Feature f : activeFeatures) featIds[index++] = featureLex.getFeatureId(f.getName()); Arrays.sort(featIds); StringBuilder bldr = new StringBuilder(); bldr.append(lab); for (int featId : featIds) bldr.append(" ").append(featId).append(":1"); return bldr.toString(); } }
WriteSVMLightFormat { public String writeFeatureExample(String label, Collection<Feature> activeFeatures) { int lab = getLabel(label); int[] featIds = new int[activeFeatures.size()]; int index = 0; for (Feature f : activeFeatures) featIds[index++] = featureLex.getFeatureId(f.getName()); Arrays.sort(featIds); StringBuilder bldr = new StringBuilder(); bldr.append(lab); for (int featId : featIds) bldr.append(" ").append(featId).append(":1"); return bldr.toString(); } WriteSVMLightFormat();  WriteSVMLightFormat(boolean isBinaryTask, boolean hasBias, boolean storeStringValues); }
WriteSVMLightFormat { public String writeFeatureExample(String label, Collection<Feature> activeFeatures) { int lab = getLabel(label); int[] featIds = new int[activeFeatures.size()]; int index = 0; for (Feature f : activeFeatures) featIds[index++] = featureLex.getFeatureId(f.getName()); Arrays.sort(featIds); StringBuilder bldr = new StringBuilder(); bldr.append(lab); for (int featId : featIds) bldr.append(" ").append(featId).append(":1"); return bldr.toString(); } WriteSVMLightFormat();  WriteSVMLightFormat(boolean isBinaryTask, boolean hasBias, boolean storeStringValues); String getLexiconContentsAsString(); void writeLexiconToOutputStream(OutputStream out); String writeFeatureExample(String label, Collection<Feature> activeFeatures); }
WriteSVMLightFormat { public String writeFeatureExample(String label, Collection<Feature> activeFeatures) { int lab = getLabel(label); int[] featIds = new int[activeFeatures.size()]; int index = 0; for (Feature f : activeFeatures) featIds[index++] = featureLex.getFeatureId(f.getName()); Arrays.sort(featIds); StringBuilder bldr = new StringBuilder(); bldr.append(lab); for (int featId : featIds) bldr.append(" ").append(featId).append(":1"); return bldr.toString(); } WriteSVMLightFormat();  WriteSVMLightFormat(boolean isBinaryTask, boolean hasBias, boolean storeStringValues); String getLexiconContentsAsString(); void writeLexiconToOutputStream(OutputStream out); String writeFeatureExample(String label, Collection<Feature> activeFeatures); static final String TRUE_LAB; static final String FALSE_LAB; }