org.apache.mahout.utils.vectors
Class VectorHelper
java.lang.Object
org.apache.mahout.utils.vectors.VectorHelper
public final class VectorHelper
- extends Object
Method Summary |
static String |
buildJson(Iterable<Pair<String,Double>> iterable)
|
static String |
buildJson(Iterable<Pair<String,Double>> iterable,
StringBuilder bldr)
|
static List<Pair<Integer,Double>> |
firstEntries(Vector vector,
int maxEntries)
|
static String[] |
loadTermDictionary(org.apache.hadoop.conf.Configuration conf,
String filePattern)
Read a dictionary in SequenceFile generated by
DictionaryVectorizer |
static String[] |
loadTermDictionary(File dictFile)
Read in a dictionary file. |
static List<Pair<Integer,Double>> |
topEntries(Vector vector,
int maxEntries)
|
static List<Pair<String,Double>> |
toWeightedTerms(Collection<Pair<Integer,Double>> entries,
String[] dictionary)
|
static String |
vectorToCSVString(Vector vector,
boolean namesAsComments)
|
static void |
vectorToCSVString(Vector vector,
boolean namesAsComments,
Appendable bldr)
|
static String |
vectorToJson(Vector vector,
String[] dictionary,
int maxEntries,
boolean sort)
|
static String |
vectorToSortedString(Vector vector,
String[] dictionary)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
vectorToCSVString
public static String vectorToCSVString(Vector vector,
boolean namesAsComments)
throws IOException
- Throws:
IOException
buildJson
public static String buildJson(Iterable<Pair<String,Double>> iterable)
buildJson
public static String buildJson(Iterable<Pair<String,Double>> iterable,
StringBuilder bldr)
vectorToSortedString
public static String vectorToSortedString(Vector vector,
String[] dictionary)
topEntries
public static List<Pair<Integer,Double>> topEntries(Vector vector,
int maxEntries)
firstEntries
public static List<Pair<Integer,Double>> firstEntries(Vector vector,
int maxEntries)
toWeightedTerms
public static List<Pair<String,Double>> toWeightedTerms(Collection<Pair<Integer,Double>> entries,
String[] dictionary)
vectorToJson
public static String vectorToJson(Vector vector,
String[] dictionary,
int maxEntries,
boolean sort)
vectorToCSVString
public static void vectorToCSVString(Vector vector,
boolean namesAsComments,
Appendable bldr)
throws IOException
- Throws:
IOException
loadTermDictionary
public static String[] loadTermDictionary(File dictFile)
throws IOException
- Read in a dictionary file. Format is:
term DocFreq Index
- Throws:
IOException
loadTermDictionary
public static String[] loadTermDictionary(org.apache.hadoop.conf.Configuration conf,
String filePattern)
- Read a dictionary in
SequenceFile
generated by
DictionaryVectorizer
- Parameters:
filePattern
- /dictionary.file-*
Copyright © 2008-2012 The Apache Software Foundation. All Rights Reserved.