public void addEntry(String name, String type){ String value = null; if(("i").equals(type)){ int equals = name.indexOf('='); if(equals < 0){ throw new IllegalArgumentException(name); } value = name.substring(equals + 1); name = name.substring(0, equals); } Entry entry = new Entry(name, value, type); addEntry(entry); }
public void addEntry(String name, String type){ String value = null; if(("i").equals(type)){ int equals = name.indexOf('='); if(equals < 0){ throw new IllegalArgumentException(name); } value = name.substring(equals + 1); name = name.substring(0, equals); } Entry entry = new Entry(name, value, type); addEntry(entry); }
static public FeatureMap loadFeatureMap(InputStream is) throws IOException { FeatureMap featureMap = new FeatureMap(); Iterator<String> lines = parseFeatureMap(is); for(int i = 0; lines.hasNext(); i++){ String line = lines.next(); StringTokenizer st = new StringTokenizer(line, "\t"); if(st.countTokens() != 3){ throw new IllegalArgumentException(line); } String id = st.nextToken(); String name = st.nextToken(); String type = st.nextToken(); if(Integer.parseInt(id) != i){ throw new IllegalArgumentException(id); } featureMap.addEntry(name, type); } return featureMap; }
static public FeatureMap loadFeatureMap(InputStream is) throws IOException { FeatureMap featureMap = new FeatureMap(); Iterator<String> lines = parseFeatureMap(is); for(int i = 0; lines.hasNext(); i++){ String line = lines.next(); StringTokenizer st = new StringTokenizer(line, "\t"); if(st.countTokens() != 3){ throw new IllegalArgumentException(line); } String id = st.nextToken(); String name = st.nextToken(); String type = st.nextToken(); if(Integer.parseInt(id) != i){ throw new IllegalArgumentException(id); } featureMap.addEntry(name, type); } return featureMap; }
static private FeatureMap loadFeatureMap(RGenericVector fmap){ RIntegerVector id = (RIntegerVector)fmap.getValue(0); RIntegerVector name = (RIntegerVector)fmap.getValue(1); RIntegerVector type = (RIntegerVector)fmap.getValue(2); if(!name.isFactor() || !type.isFactor()){ throw new IllegalArgumentException(); } FeatureMap featureMap = new FeatureMap(); for(int i = 0; i < id.size(); i++){ if(i != id.getValue(i)){ throw new IllegalArgumentException(); } featureMap.addEntry(name.getFactorValue(i), type.getFactorValue(i)); } return featureMap; }