StringLocator (original) (raw)
java.lang.Object
- weka.core.AttributeLocator
- weka.core.StringLocator
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<AttributeLocator>, RevisionHandler
public class StringLocator
extends AttributeLocator
This class locates and records the indices of String attributes, recursively in case of Relational attributes. The indices are normally used for copying the Strings from one Instances object to another.
Version: Revision:6226Revision: 6226 Revision:6226
Author:
fracpete (fracpete at waikato dot ac dot nz)
See Also:
Attribute.STRING, Attribute.RELATIONAL, Serialized Form
Constructor Summary
Constructors
Constructor and Description StringLocator(Instances data) initializes the StringLocator with the given data StringLocator(Instances data, int[] indices) Initializes the AttributeLocator with the given data. StringLocator(Instances data, int fromIndex, int toIndex) Initializes the StringLocator with the given data. Method Summary
All Methods Static Methods Instance Methods Concrete Methods
Modifier and Type Method and Description static void copyStringValues(Instance instance, boolean instSrcCompat,Instances srcDataset,AttributeLocator srcLoc,Instances destDataset,AttributeLocator destLoc) Takes string values referenced by an Instance and copies them from a source dataset to a destination dataset. static void copyStringValues(Instance inst,Instances destDataset,AttributeLocator strAtts) Copies string values contained in the instance copied to a new dataset. java.lang.String getRevision() Returns the revision string. * ### Methods inherited from class weka.core.[AttributeLocator](../../weka/core/AttributeLocator.html "class in weka.core") `[compareTo](../../weka/core/AttributeLocator.html#compareTo-weka.core.AttributeLocator-), [equals](../../weka/core/AttributeLocator.html#equals-java.lang.Object-), [getActualIndex](../../weka/core/AttributeLocator.html#getActualIndex-int-), [getAllowedIndices](../../weka/core/AttributeLocator.html#getAllowedIndices--), [getAttributeIndices](../../weka/core/AttributeLocator.html#getAttributeIndices--), [getData](../../weka/core/AttributeLocator.html#getData--), [getLocator](../../weka/core/AttributeLocator.html#getLocator-int-), [getLocatorIndices](../../weka/core/AttributeLocator.html#getLocatorIndices--), [getType](../../weka/core/AttributeLocator.html#getType--), [toString](../../weka/core/AttributeLocator.html#toString--)` * ### Methods inherited from class java.lang.Object `getClass, hashCode, notify, notifyAll, wait, wait, wait`
Constructor Detail
* #### StringLocator public StringLocator([Instances](../../weka/core/Instances.html "class in weka.core") data) initializes the StringLocator with the given data Parameters: `data` \- the data to work on * #### StringLocator public StringLocator([Instances](../../weka/core/Instances.html "class in weka.core") data, int fromIndex, int toIndex) Initializes the StringLocator with the given data. Checks only the given range. Parameters: `data` \- the data to work on `fromIndex` \- the first index to inspect (including) `toIndex` \- the last index to check (including) * #### StringLocator public StringLocator([Instances](../../weka/core/Instances.html "class in weka.core") data, int[] indices) Initializes the AttributeLocator with the given data. Checks only the specified attribute indices. Parameters: `data` \- the data to work on `indices` \- the attribute indices to check
Method Detail
* #### copyStringValues public static void copyStringValues([Instance](../../weka/core/Instance.html "class in weka.core") inst, [Instances](../../weka/core/Instances.html "class in weka.core") destDataset, [AttributeLocator](../../weka/core/AttributeLocator.html "class in weka.core") strAtts) Copies string values contained in the instance copied to a new dataset. The Instance must already be assigned to a dataset. This dataset and the destination dataset must have the same structure. Parameters: `inst` \- the Instance containing the string values to copy. `destDataset` \- the destination set of Instances `strAtts` \- an AttributeLocator containing the indices of any string attributes in the dataset. * #### copyStringValues public static void copyStringValues([Instance](../../weka/core/Instance.html "class in weka.core") instance, boolean instSrcCompat, [Instances](../../weka/core/Instances.html "class in weka.core") srcDataset, [AttributeLocator](../../weka/core/AttributeLocator.html "class in weka.core") srcLoc, [Instances](../../weka/core/Instances.html "class in weka.core") destDataset, [AttributeLocator](../../weka/core/AttributeLocator.html "class in weka.core") destLoc) Takes string values referenced by an Instance and copies them from a source dataset to a destination dataset. The instance references are updated to be valid for the destination dataset. The instance may have the structure (i.e. number and attribute position) of either dataset (this affects where references are obtained from). Only works if the number of string attributes is the same in both indices (implicitly these string attributes should be semantically same but just with shifted positions). Parameters: `instance` \- the instance containing references to strings in the source dataset that will have references updated to be valid for the destination dataset. `instSrcCompat` \- true if the instance structure is the same as the source, or false if it is the same as the destination (i.e. which of the string attribute indices contains the correct locations for this instance). `srcDataset` \- the dataset for which the current instance string references are valid (after any position mapping if needed) `srcLoc` \- an AttributeLocator containing the indices of string attributes in the source datset. `destDataset` \- the dataset for which the current instance string references need to be inserted (after any position mapping if needed) `destLoc` \- an AttributeLocator containing the indices of string attributes in the destination datset. * #### getRevision public java.lang.String getRevision() Returns the revision string. Specified by: `[getRevision](../../weka/core/RevisionHandler.html#getRevision--)` in interface `[RevisionHandler](../../weka/core/RevisionHandler.html "interface in weka.core")` Overrides: `[getRevision](../../weka/core/AttributeLocator.html#getRevision--)` in class `[AttributeLocator](../../weka/core/AttributeLocator.html "class in weka.core")` Returns: the revision