org.apache.mahout.utils.vectors.arff
Class MapBackedARFFModel

java.lang.Object
  extended by org.apache.mahout.utils.vectors.arff.MapBackedARFFModel
All Implemented Interfaces:
ARFFModel

public class MapBackedARFFModel
extends Object
implements ARFFModel

Holds ARFF information in Map.


Field Summary
 
Fields inherited from interface org.apache.mahout.utils.vectors.arff.ARFFModel
ARFF_COMMENT, ARFF_SPARSE, ARFF_SPARSE_END, ATTRIBUTE, DATA, RELATION
 
Constructor Summary
MapBackedARFFModel()
           
MapBackedARFFModel(Map<String,Long> words, long wordCount, Map<String,Map<String,Integer>> nominalMap)
           
 
Method Summary
 void addDateFormat(Integer idx, DateFormat format)
           
 void addLabel(String label, Integer idx)
           
 void addNominal(String label, String nominal, int idx)
           
 void addType(Integer idx, ARFFType type)
           
 ARFFType getARFFType(Integer idx)
           
 DateFormat getDateFormat(Integer idx)
           
 Map<Integer,DateFormat> getDateMap()
          Map of Date formatters used
 Map<String,Integer> getLabelBindings()
          The vector attributes (labels in Mahout speak), unmodifiable
 Integer getLabelIndex(String label)
           
 int getLabelSize()
           
 Map<String,Map<String,Integer>> getNominalMap()
          Map nominals to ids.
 Integer getNominalValue(String label, String nominal)
           
 String getRelation()
           
 Map<Integer,ARFFType> getTypeMap()
          The map of types encountered
 double getValue(String data, int idx)
          Convert a piece of String data at a specific spot into a value
 long getWordCount()
          The count of the number of words seen
 Map<String,Long> getWords()
          Immutable map of words to the long id used for those words
static boolean isNumeric(String str)
           
protected  double processDate(String data, int idx)
           
protected  double processNominal(String label, String data)
           
protected static double processNumeric(String data)
           
protected  double processString(String data)
           
 void setRelation(String relation)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MapBackedARFFModel

public MapBackedARFFModel()

MapBackedARFFModel

public MapBackedARFFModel(Map<String,Long> words,
                          long wordCount,
                          Map<String,Map<String,Integer>> nominalMap)
Method Detail

getRelation

public String getRelation()
Specified by:
getRelation in interface ARFFModel

setRelation

public void setRelation(String relation)
Specified by:
setRelation in interface ARFFModel

getValue

public double getValue(String data,
                       int idx)
Convert a piece of String data at a specific spot into a value

Specified by:
getValue in interface ARFFModel
Parameters:
data - The data to convert
idx - The position in the ARFF data
Returns:
A double representing the data

processNominal

protected double processNominal(String label,
                                String data)

processString

protected double processString(String data)

processNumeric

protected static double processNumeric(String data)

isNumeric

public static boolean isNumeric(String str)

processDate

protected double processDate(String data,
                             int idx)

getLabelBindings

public Map<String,Integer> getLabelBindings()
The vector attributes (labels in Mahout speak), unmodifiable

Specified by:
getLabelBindings in interface ARFFModel
Returns:
the map

getTypeMap

public Map<Integer,ARFFType> getTypeMap()
The map of types encountered

Returns:
the map

getDateMap

public Map<Integer,DateFormat> getDateMap()
Map of Date formatters used

Returns:
the map

getNominalMap

public Map<String,Map<String,Integer>> getNominalMap()
Map nominals to ids. Should only be modified by calling ARFFModel.addNominal(String, String, int)

Specified by:
getNominalMap in interface ARFFModel
Returns:
the map

getWords

public Map<String,Long> getWords()
Immutable map of words to the long id used for those words

Specified by:
getWords in interface ARFFModel
Returns:
The map

getNominalValue

public Integer getNominalValue(String label,
                               String nominal)
Specified by:
getNominalValue in interface ARFFModel

addNominal

public void addNominal(String label,
                       String nominal,
                       int idx)
Specified by:
addNominal in interface ARFFModel

getDateFormat

public DateFormat getDateFormat(Integer idx)
Specified by:
getDateFormat in interface ARFFModel

addDateFormat

public void addDateFormat(Integer idx,
                          DateFormat format)
Specified by:
addDateFormat in interface ARFFModel

getLabelIndex

public Integer getLabelIndex(String label)
Specified by:
getLabelIndex in interface ARFFModel

addLabel

public void addLabel(String label,
                     Integer idx)
Specified by:
addLabel in interface ARFFModel

getARFFType

public ARFFType getARFFType(Integer idx)
Specified by:
getARFFType in interface ARFFModel

addType

public void addType(Integer idx,
                    ARFFType type)
Specified by:
addType in interface ARFFModel

getWordCount

public long getWordCount()
The count of the number of words seen

Specified by:
getWordCount in interface ARFFModel
Returns:
the count

getLabelSize

public int getLabelSize()
Specified by:
getLabelSize in interface ARFFModel


Copyright © 2008–2014 The Apache Software Foundation. All rights reserved.