⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 parametertype.java

📁 一个很好的LIBSVM的JAVA源码。对于要研究和改进SVM算法的学者。可以参考。来自数据挖掘工具YALE工具包。
💻 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.operator.parameter;

import edu.udo.cs.yale.tools.LogService;

/** A ParameterType holds information about type, range, and default value of a parameter.
 *  Lists of ParameterTypes are provided by operators.
 *
 *  @version $Id: ParameterType.java,v 2.8 2004/08/27 11:57:42 ingomierswa Exp $
 *  @see edu.udo.cs.yale.operator.Operator#getParameterTypes() */
public abstract class ParameterType implements Comparable {

    /** The key of this parameter. */
    private String key;
    /** The documentation. Used as tooltip text... */
    private String description = "No documentation for this parameter.";
    /** Indicates if this is an parameter only viewable in expert mode. Mandatory parameters
     *  are always viewable. The default value is true. */
    private boolean expert = true;

    /** Creates a new ParameterType. */
    public ParameterType(String key, String description) {
	this.key = key;
	this.description = description;
    }

    /** Returns true if this parameter can only be seen in expert mode. The default implementation 
     *  returns true if the parameter is optional. */
    public boolean isExpert() { 
	return isOptional() && expert;  
    }

    /** Sets if this parameter can be seen in expert mode (true) or beginner mode (false). */
    public void setExpert(boolean expert) {
	this.expert = expert;
    }

    /** Returns true if this parameter is optional. The default implementation returns true. */
    public boolean isOptional() { return true; }

    /** Returns the key. */
    public String getKey() {
	return key;
    }

    /** Returns a short description. */
    public String getDescription() {
	return description;
    }

    /** Sets the short description. */
    public void setDescription(String description) {
	this.description = description;
    }

    /** Returns a human readable description of the range. */
    public abstract String getRange();

    /** For single parameters the value is a String and must be converted to
     *  an Integer, Double, Boolean or String. For lists, value already is a list.
     *  If value is out of range, a corrected value must be returned. */
    public abstract Object checkValue(Object value);

    /** Returns a value that can be used if the parameter is not set. */
    public abstract Object getDefaultValue();

    /** Returns a string representation of this value. */
    public String toString(Object value) {
	if (value == null) return "";
	else return value.toString();
    }

    /** Can be called in order to report an illegal parameter value which is encountered during <tt>checkValue()</tt>. */
    public void illegalValue(Object illegal, Object corrected) {
	LogService.logMessage("Illegal value '"+illegal+"' for parameter '"+key+"' has been corrected to '"+corrected.toString()+"'.",
			      LogService.WARNING);
    }

    /** Writes an xml representation of the given key-value pair. */
    public abstract String getXML(String indent, String key, Object value);

    /** ParameterTypes are compared by key. */
    public int compareTo(Object o) {
	if (!(o instanceof ParameterType)) return 0;
	else return this.key.compareTo(((ParameterType)o).key);
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -