@Test public void processNominal() { String windy = "windy"; String breezy = "breezy"; ARFFModel model = new MapBackedARFFModel(); model.addNominal(windy, breezy, 77); model.addNominal(windy, "strong", 23); model.addNominal(windy, "nuking", 55); Map<String, Map<String, Integer>> nominalMap = model.getNominalMap(); assertEquals(1, nominalMap.size()); Map<String, Integer> windyValues = nominalMap.get(windy); assertEquals(77, windyValues.get(breezy).intValue()); }
protected double processNominal(String label, String data) { double result; Map<String,Integer> classes = nominalMap.get(label); if (classes != null) { Integer ord = classes.get(ARFFType.removeQuotes(data)); if (ord != null) { result = ord; } else { throw new IllegalStateException("Invalid nominal: " + data + " for label: " + label); } } else { throw new IllegalArgumentException("Invalid nominal label: " + label + " Data: " + data); } return result; }
MapBackedARFFModel implements ARFFModel { protected double processNominal(String label, String data) { double result; Map<String,Integer> classes = nominalMap.get(label); if (classes != null) { Integer ord = classes.get(ARFFType.removeQuotes(data)); if (ord != null) { result = ord; } else { throw new IllegalStateException("Invalid nominal: " + data + " for label: " + label); } } else { throw new IllegalArgumentException("Invalid nominal label: " + label + " Data: " + data); } return result; } }
MapBackedARFFModel implements ARFFModel { protected double processNominal(String label, String data) { double result; Map<String,Integer> classes = nominalMap.get(label); if (classes != null) { Integer ord = classes.get(ARFFType.removeQuotes(data)); if (ord != null) { result = ord; } else { throw new IllegalStateException("Invalid nominal: " + data + " for label: " + label); } } else { throw new IllegalArgumentException("Invalid nominal label: " + label + " Data: " + data); } return result; } MapBackedARFFModel();  MapBackedARFFModel(Map<String,Long> words, long wordCount, Map<String,Map<String,Integer>> nominalMap); }
MapBackedARFFModel implements ARFFModel { protected double processNominal(String label, String data) { double result; Map<String,Integer> classes = nominalMap.get(label); if (classes != null) { Integer ord = classes.get(ARFFType.removeQuotes(data)); if (ord != null) { result = ord; } else { throw new IllegalStateException("Invalid nominal: " + data + " for label: " + label); } } else { throw new IllegalArgumentException("Invalid nominal label: " + label + " Data: " + data); } return result; } MapBackedARFFModel();  MapBackedARFFModel(Map<String,Long> words, long wordCount, Map<String,Map<String,Integer>> nominalMap); @Override String getRelation(); @Override void setRelation(String relation); @Override double getValue(String data, int idx); static boolean isNumeric(String str); @Override Map<String,Integer> getLabelBindings(); Map<Integer,ARFFType> getTypeMap(); Map<Integer,DateFormat> getDateMap(); @Override Map<String,Map<String,Integer>> getNominalMap(); @Override Map<String,Long> getWords(); @Override Integer getNominalValue(String label, String nominal); @Override void addNominal(String label, String nominal, int idx); @Override DateFormat getDateFormat(Integer idx); @Override void addDateFormat(Integer idx, DateFormat format); @Override Integer getLabelIndex(String label); @Override void addLabel(String label, Integer idx); @Override ARFFType getARFFType(Integer idx); @Override void addType(Integer idx, ARFFType type); @Override long getWordCount(); @Override int getLabelSize(); }
MapBackedARFFModel implements ARFFModel { protected double processNominal(String label, String data) { double result; Map<String,Integer> classes = nominalMap.get(label); if (classes != null) { Integer ord = classes.get(ARFFType.removeQuotes(data)); if (ord != null) { result = ord; } else { throw new IllegalStateException("Invalid nominal: " + data + " for label: " + label); } } else { throw new IllegalArgumentException("Invalid nominal label: " + label + " Data: " + data); } return result; } MapBackedARFFModel();  MapBackedARFFModel(Map<String,Long> words, long wordCount, Map<String,Map<String,Integer>> nominalMap); @Override String getRelation(); @Override void setRelation(String relation); @Override double getValue(String data, int idx); static boolean isNumeric(String str); @Override Map<String,Integer> getLabelBindings(); Map<Integer,ARFFType> getTypeMap(); Map<Integer,DateFormat> getDateMap(); @Override Map<String,Map<String,Integer>> getNominalMap(); @Override Map<String,Long> getWords(); @Override Integer getNominalValue(String label, String nominal); @Override void addNominal(String label, String nominal, int idx); @Override DateFormat getDateFormat(Integer idx); @Override void addDateFormat(Integer idx, DateFormat format); @Override Integer getLabelIndex(String label); @Override void addLabel(String label, Integer idx); @Override ARFFType getARFFType(Integer idx); @Override void addType(Integer idx, ARFFType type); @Override long getWordCount(); @Override int getLabelSize();  }