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

📄 template.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.gui;

import java.io.File;
import java.io.IOException;
import java.io.FileReader;
import java.io.BufferedReader;
import java.io.PrintWriter;
import java.io.FileWriter;
import java.util.List;
import java.util.LinkedList;
import java.util.Iterator;

/** A template experiment consisting of name, short description, a name for an experiment file and a
 *  list parameters given as String pairs (operator, key).
 *  Templates must look like this:
 *  <pre>
 *  one line for the name
 *  one line of html description
 *  one line for the experiment file name
 *  Rest of the file: some important parameters in the form operatorname.parametername
 *  </pre> */
public class Template {

    private String name = "unnamed";
    private String description = "none";
    private String configFile;
    private List parameters = new LinkedList();
    private File templateFile = null;

    public Template() {}

    public Template(File file) throws IOException {
	this.templateFile = file;
	BufferedReader in = new BufferedReader(new FileReader(templateFile));
	name        = in.readLine();
	description = in.readLine();
	configFile  = in.readLine();
	String line = null;
	while ((line = in.readLine()) != null) {
	    parameters.add(line.split("\\."));
	}
	in.close();
    }

    public Template(String name, String description, String configFile, List parameters) {
	this.name = name;
	this.description = description;
	this.configFile = configFile;
	this.parameters = parameters;
    }

    public File getFile() {
	return templateFile;
    }

    public String getFilename() {
	return configFile;
    }

    public String getName() {
	return name;
    }

    public String getDescription() {
	return description;
    }

    public List getParameters() {
	return parameters;
    }

    public String toHTML() {
	return "<b>"+name+"</b><br />"+description;
    }

    public void save(File file) throws IOException {
	PrintWriter out = new PrintWriter(new FileWriter(file));
	out.println(name);
	out.println(description);
	out.println(configFile);
	Iterator i = parameters.iterator();
	while (i.hasNext()) {
	    String[] pair = (String[])i.next();
	    out.println(pair[0] + "." + pair[1]);
	}
	out.close();
    }
}

⌨️ 快捷键说明

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