Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
The Waikato Environment for Knowledge Analysis (WEKA), a machine
learning workbench. This is the stable version. Apart from bugfixes, this version
does not receive any other updates.
/*
* 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 3 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, see .
*/
/*
* RenameAttribute.java
* Copyright (C) 2009-2012 University of Waikato, Hamilton, New Zealand
*
*/
package weka.filters.unsupervised.attribute;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Enumeration;
import java.util.Vector;
import weka.core.Attribute;
import weka.core.Capabilities;
import weka.core.Capabilities.Capability;
import weka.core.Instance;
import weka.core.Instances;
import weka.core.Option;
import weka.core.Range;
import weka.core.RevisionUtils;
import weka.core.Utils;
import weka.filters.SimpleStreamFilter;
/**
* This filter is used for renaming attribute names.
* Regular expressions can be used in the matching and replacing.
* See Javadoc of java.util.regex.Pattern class for more information:
* http://java.sun.com/javase/6/docs/api/java/util/regex/Pattern.html
*
*
*
* Valid options are:
*
*
*
* -find <regexp>
* The regular expression that the attribute names must match.
* (default: ([\s\S]+))
*
*
*
* -replace <string>
* The string to replace the regular expression of matching attributes with.
* Cannot be used in conjunction with '-remove'.
* (default: $0)
*
*
*
* -remove
* In case the matching string needs to be removed instead of replaced.
* Cannot be used in conjunction with '-replace <string>'.
* (default: off)
*
*
*
* -all
* Replaces all occurrences instead of just the first.
* (default: only first occurrence)
*
*
*
* -R <range>
* The attribute range to work on.
* This is a comma separated list of attribute indices, with "first" and "last" valid values.
* Specify an inclusive range with "-".
* E.g: "first-3,5,6-10,last".
* (default: first-last)
*
*
*
*
* @author fracpete (fracpete at waikato dot ac dot nz)
* @version $Revision: 10215 $
*/
public class RenameAttribute extends SimpleStreamFilter {
/** for serialization. */
private static final long serialVersionUID = 4216491776378279596L;
/** the regular expression that the attribute names have to match. */
protected String m_Find = "([\\s\\S]+)";
/** the regular expression to replace the attribute name with. */
protected String m_Replace = "$0";
/** the attribute range to work on. */
protected Range m_AttributeIndices = new Range("first-last");
/** whether to replace all occurrences or just the first. */
protected boolean m_ReplaceAll = false;
/**
* Returns a string describing this filter.
*
* @return a description of the filter suitable for displaying in the
* explorer/experimenter gui
*/
@Override
public String globalInfo() {
return "This filter is used for renaming attribute names.\n"
+ "Regular expressions can be used in the matching and replacing.\n"
+ "See Javadoc of java.util.regex.Pattern class for more information:\n"
+ "http://java.sun.com/javase/6/docs/api/java/util/regex/Pattern.html";
}
/**
* Returns an enumeration describing the available options.
*
* @return an enumeration of all the available options.
*/
@Override
public Enumeration