public static double dotProduct(FeatureVector fv1, FeatureVector fv2){
        if (fv1==null||fv2==null) return 0.0;
        if(fv1.size()>fv2.size()){
            FeatureVector temp = fv2;
            fv2 = fv1;
            fv1 = temp;
        }
        Iterator<Integer> it = fv1.getKey();
        double sum = 0.0;
        while(it.hasNext()){
            int key = it.next();
            sum += fv1.get(key)*fv2.get(key);
        }
        return sum;
    }