ArffDatasetAdapter implements IDatasetDeserializer<ILabeledDataset<ILabeledInstance>> { protected static KVStore parseRelation(final String line) { KVStore metaData = new KVStore(); String relationDescription = line.substring(EArffItem.RELATION.getValue().length()).trim(); if (relationDescription.startsWith("'") && relationDescription.endsWith("'")) { String[] relationNameAndOptions = line.substring(line.indexOf('\'') + 1, line.lastIndexOf('\'')).split(SEPARATOR_RELATIONNAME); metaData.put(K_RELATION_NAME, relationNameAndOptions[0].trim()); if (relationNameAndOptions.length > 1) { OptionsParser optParser = new OptionsParser(relationNameAndOptions[1]); metaData.put(K_CLASS_INDEX, optParser.get(F_CLASS_INDEX)); } } else { metaData.put(K_RELATION_NAME, relationDescription); } return metaData; } ArffDatasetAdapter(final boolean sparseMode, final IDatasetDescriptor datasetDescriptor);  ArffDatasetAdapter(final boolean sparseMode);  ArffDatasetAdapter(); IAttribute getAttributeWithName(final IFileDatasetDescriptor datasetFile, final String nameOfAttribute); ILabeledDataset<ILabeledInstance> deserializeDataset(final IFileDatasetDescriptor datasetFile, final String nameOfClassAttribute); ILabeledDataset<ILabeledInstance> deserializeDataset(final IFileDatasetDescriptor datasetDescriptor, final int columnWithClassIndex); @Override ILabeledDataset<ILabeledInstance> deserializeDataset(final IDatasetDescriptor datasetDescriptor); ILabeledDataset<ILabeledInstance> deserializeDataset(); static ILabeledDataset<ILabeledInstance> readDataset(final File datasetFile); static ILabeledDataset<ILabeledInstance> readDataset(final boolean sparseMode, final File datasetFile); static ILabeledDataset<ILabeledInstance> readDataset(final boolean sparseMode, final File datasetFile, final int columnWithClassIndex); static void serializeDataset(final File arffOutputFile, final ILabeledDataset<? extends ILabeledInstance> data); static final String V_MISSING_VALUE; static final String K_RELATION_NAME; static final String K_CLASS_INDEX; }
@Test public void testParseRelation() { KVStore store = ArffDatasetAdapter.parseRelation(RELATION_STRING); assertEquals("The class index could not be read correctly", CLASS_INDEX, (int) store.getAsInt(ArffDatasetAdapter.K_CLASS_INDEX)); assertEquals("The relation name could not be extracted correctly", RELATION_NAME, store.getAsString(ArffDatasetAdapter.K_RELATION_NAME)); }