Examples of JsonVectorAdapter


Examples of org.apache.mahout.math.JsonVectorAdapter

  }

  @Override
  public DistanceMeasure deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) {
    GsonBuilder builder = new GsonBuilder();
    builder.registerTypeAdapter(Vector.class, new JsonVectorAdapter());
    Gson gson = builder.create();
    JsonObject obj = json.getAsJsonObject();
    String klass = obj.get("class").getAsString();
    String model = obj.get("model").getAsString();
    ClassLoader ccl = Thread.currentThread().getContextClassLoader();
View Full Code Here

Examples of org.apache.mahout.math.JsonVectorAdapter

  public abstract String getIdentifier();

  @Override
  public String asJsonString() {
    GsonBuilder gBuilder = new GsonBuilder();
    gBuilder.registerTypeAdapter(VECTOR_TYPE, new JsonVectorAdapter());
    Gson gson = gBuilder.create();
    return gson.toJson(this, this.getClass());
  }
View Full Code Here

Examples of org.apache.mahout.math.JsonVectorAdapter

  }

  @Override
  public String asFormatString() {
    GsonBuilder gBuilder = new GsonBuilder();
    gBuilder.registerTypeAdapter(VECTOR_TYPE, new JsonVectorAdapter());
    Gson gson = gBuilder.create();
    return gson.toJson(this, MeanShiftCanopy.class);
  }
View Full Code Here

Examples of org.apache.mahout.math.JsonVectorAdapter

                               Type type,
                               JsonSerializationContext context) {
    // now register the builders for matrix / vector
    GsonBuilder builder = new GsonBuilder();
    builder.registerTypeAdapter(Matrix.class, new JsonMatrixAdapter());
    builder.registerTypeAdapter(Vector.class, new JsonVectorAdapter());
    Gson gson = builder.create();
    // create a model
    JsonObject json = new JsonObject();
    // first, we add the model
    json.add(MODEL, new JsonPrimitive(gson.toJson(model)));
View Full Code Here

Examples of org.apache.mahout.math.JsonVectorAdapter

                                     Type type,
                                     JsonDeserializationContext context) throws JsonParseException {
    // register the builders for matrix / vector
    GsonBuilder builder = new GsonBuilder();
    builder.registerTypeAdapter(Matrix.class, new JsonMatrixAdapter());
    builder.registerTypeAdapter(Vector.class, new JsonVectorAdapter());
    Gson gson = builder.create();
    // now decode the original model
    JsonObject obj = json.getAsJsonObject();
    String modelString = obj.get(MODEL).getAsString();
    NaiveBayesModel model = gson.fromJson(modelString, NaiveBayesModel.class);
View Full Code Here

Examples of org.apache.mahout.math.JsonVectorAdapter

  private static final Logger log = LoggerFactory.getLogger(JsonClusterAdapter.class);
 
  @Override
  public JsonElement serialize(DirichletCluster src, Type typeOfSrc, JsonSerializationContext context) {
    GsonBuilder builder = new GsonBuilder();
    builder.registerTypeAdapter(Vector.class, new JsonVectorAdapter());
    Gson gson = builder.create();
    JsonObject obj = new JsonObject();
    obj.add("total", new JsonPrimitive(src.getTotalCount()));
    obj.add("modelClass", new JsonPrimitive(src.getModel().getClass().getName()));
    obj.add("modelJson", new JsonPrimitive(gson.toJson(src)));
View Full Code Here

Examples of org.apache.mahout.math.JsonVectorAdapter

  @Override
  public DirichletCluster deserialize(JsonElement json,
                                         Type typeOfT,
                                         JsonDeserializationContext context) {
    GsonBuilder builder = new GsonBuilder();
    builder.registerTypeAdapter(Vector.class, new JsonVectorAdapter());
    Gson gson = builder.create();
    JsonObject obj = json.getAsJsonObject();
    double total = obj.get("total").getAsDouble();
    String klass = obj.get("modelClass").getAsString();
    String modelJson = obj.get("modelJson").getAsString();
View Full Code Here

Examples of org.apache.mahout.math.JsonVectorAdapter

  private static final Logger log = LoggerFactory.getLogger(JsonClusterModelAdapter.class);
 
  @Override
  public JsonElement serialize(Cluster src, Type typeOfSrc, JsonSerializationContext context) {
    GsonBuilder builder = new GsonBuilder();
    builder.registerTypeAdapter(Vector.class, new JsonVectorAdapter());
    Gson gson = builder.create();
    JsonObject obj = new JsonObject();
    obj.add("class", new JsonPrimitive(src.getClass().getName()));
    obj.add("model", new JsonPrimitive(gson.toJson(src)));
    return obj;
View Full Code Here

Examples of org.apache.mahout.math.JsonVectorAdapter

 
  @Override
  public Cluster deserialize(JsonElement json, Type typeOfT,
                              JsonDeserializationContext context) {
    GsonBuilder builder = new GsonBuilder();
    builder.registerTypeAdapter(Vector.class, new JsonVectorAdapter());
    Gson gson = builder.create();
    JsonObject obj = json.getAsJsonObject();
    String klass = obj.get("class").getAsString();
    String model = obj.get("model").getAsString();
    ClassLoader ccl = Thread.currentThread().getContextClassLoader();
View Full Code Here

Examples of org.apache.mahout.math.JsonVectorAdapter

  public HmmModel deserialize(JsonElement json, Type type,
                              JsonDeserializationContext context) {
    // register the builders for matrix / vector
    GsonBuilder builder = new GsonBuilder();
    builder.registerTypeAdapter(Matrix.class, new JsonMatrixAdapter());
    builder.registerTypeAdapter(Vector.class, new JsonVectorAdapter());
    Gson gson = builder.create();
    // now decode the original model
    JsonObject obj = json.getAsJsonObject();
    String modelString = obj.get(MODEL).getAsString();
    HmmModel model = gson.fromJson(modelString, HmmModel.class);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.