package com.formulasearchengine.mathosphere.mathpd.distances.earthmover;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * Created by Felix Hamborg on 13.12.16.
 */
public class EarthMoverDistanceWrapper {
    public static Signature histogramToSignature(Map<String, Integer> histogram) {
        Signature signature = new Signature();
        Feature[] features = new Feature[histogram.size()];
        double[] weights = new double[histogram.size()];
        List<String> orderedKeys = new ArrayList<>(histogram.keySet());

        for (int i = 0; i < histogram.size(); i++) {
            features[i] = new Feature2D(i, histogram.get(orderedKeys.get(i)));
            weights[i] = 1.0;
        }

        signature.setFeatures(features);
        signature.setWeights(weights);
        signature.setNumberOfFeatures(features.length);

        return signature;
    }


}

@@ -145,16 +145,90 @@
 p;%0A%0A/**%0A
+ * Provides wrapping functionality for invoking the Earth Mover Distance.%0A
  * Creat
@@ -967,12 +967,10 @@
 ;%0A    %7D%0A
-%0A%0A
 %7D%0A

add earthmover distance