📄 yaleidmapping.java
字号:
/*
* YALE - Yet Another Learning Environment
* Copyright (C) 2001-2004
* Simon Fischer, Ralf Klinkenberg, Ingo Mierswa,
* Katharina Morik, Oliver Ritthoff
* Artificial Intelligence Unit
* Computer Science Department
* University of Dortmund
* 44221 Dortmund, Germany
* email: yale-team@lists.sourceforge.net
* web: http://yale.cs.uni-dortmund.de/
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*/
package edu.udo.cs.yale.example;
import edu.udo.cs.yale.example.Example;
import java.util.HashMap;
import java.util.Iterator;
/** This class implements the mapping between Yale Examples and Ids. Since this is a task which
* is not necessary for the most learning applications, the mapping is not implemented in the standard
* example sets for performance reasons. Please make sure that only a correct mapping is used in a
* Yale experiment and rebuild it if necessary.
*
* @yale.todo Change String ids to double
*
* @author Michael Wurst, Ingo Mierswa
* @version $Id: YaleIdMapping.java,v 1.2 2004/03/24 16:03:17 wurst Exp $
*/
public class YaleIdMapping extends HashMap {
private static YaleIdMapping defaultMapping = new YaleIdMapping();
/** Adds an object to the mapping.
* @param e the example representing the object (has to have an Id).
*/
public void addObject(Example e) {
put(getIdFromExample(e), e);
}
public void addExampleSet(ExampleSet es){
ExampleReader er = es.getExampleReader();
while(er.hasNext())
addObject(er.next());
}
/** Get an example given an id.
* @param id the id
* @return Example
*/
public Example getExampleFromId(String id) {
return (Example)get(id);
}
/** Get an id given an example.
* @param e the example
* @return String
*/
public String getIdFromExample(Example e) {
return e.getIdAsString();
}
/** Get all ids that mapped.
* @return Iterator
*/
public Iterator getAllIds() {
return keySet().iterator();
}
/** Get the default mapping.
* @return YaleIdMapping
*/
public static YaleIdMapping getDefaultMapping() {
return defaultMapping;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -