org.apache.mahout.utils.clustering
Class JsonClusterWriter

java.lang.Object
  extended by org.apache.mahout.utils.clustering.AbstractClusterWriter
      extended by org.apache.mahout.utils.clustering.JsonClusterWriter
All Implemented Interfaces:
Closeable, ClusterWriter

public class JsonClusterWriter
extends AbstractClusterWriter

Dump cluster info to JSON formatted lines. Heavily inspired by ClusterDumperWriter.java and CSVClusterWriter.java


Field Summary
 
Fields inherited from class org.apache.mahout.utils.clustering.AbstractClusterWriter
clusterIdToPoints, measure, writer
 
Constructor Summary
JsonClusterWriter(Writer writer, Map<Integer,List<WeightedPropertyVectorWritable>> clusterIdToPoints, DistanceMeasure measure, int numTopFeatures, String[] dictionary)
           
 
Method Summary
 List<Object> getPoints(Cluster cluster, String[] dictionary)
          Create a List of HashMaps containing Vector point information
 List<Object> getTopFeaturesList(Vector vector, String[] dictionary, int numTerms)
          Create a List of HashMaps containing top terms information
 void write(ClusterWritable clusterWritable)
          Generate HashMap with cluster info and write as a single JSON formatted line
 
Methods inherited from class org.apache.mahout.utils.clustering.AbstractClusterWriter
close, getClusterIdToPoints, getTopFeatures, getTopTerms, getWriter, write, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JsonClusterWriter

public JsonClusterWriter(Writer writer,
                         Map<Integer,List<WeightedPropertyVectorWritable>> clusterIdToPoints,
                         DistanceMeasure measure,
                         int numTopFeatures,
                         String[] dictionary)
Method Detail

write

public void write(ClusterWritable clusterWritable)
           throws IOException
Generate HashMap with cluster info and write as a single JSON formatted line

Throws:
IOException

getTopFeaturesList

public List<Object> getTopFeaturesList(Vector vector,
                                       String[] dictionary,
                                       int numTerms)
Create a List of HashMaps containing top terms information

Returns:
List

getPoints

public List<Object> getPoints(Cluster cluster,
                              String[] dictionary)
Create a List of HashMaps containing Vector point information

Returns:
List

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