Projects >> Byblo >>f6a1e854f137c9b71f4ed9457d87481ada07f7d7

Chunk
Conflicting content
 */
package uk.ac.susx.mlcl.byblo.measures;

<<<<<<< HEAD
=======
import javax.annotation.CheckReturnValue;
import javax.annotation.concurrent.Immutable;

import uk.ac.susx.mlcl.byblo.weighings.FeatureMarginalsCarrier;
import uk.ac.susx.mlcl.byblo.weighings.MarginalDistribution;
>>>>>>> 5f0ba9177b34449ea27dabdc17fd0793620c7d56
import uk.ac.susx.mlcl.byblo.weighings.Weighting;
import uk.ac.susx.mlcl.lib.Checks;
import uk.ac.susx.mlcl.lib.collect.SparseDoubleVector;
Solution content
 */
package uk.ac.susx.mlcl.byblo.measures;

import javax.annotation.CheckReturnValue;
import javax.annotation.concurrent.Immutable;

import uk.ac.susx.mlcl.byblo.weighings.FeatureMarginalsCarrier;
import uk.ac.susx.mlcl.byblo.weighings.MarginalDistribution;
import uk.ac.susx.mlcl.byblo.weighings.Weighting;
import uk.ac.susx.mlcl.lib.Checks;
import uk.ac.susx.mlcl.lib.collect.SparseDoubleVector;
File
AutoWeightingMeasure.java
Developer's decision
Version 2
Kind of conflict
Import
Chunk
Conflicting content
 * The weighting scheme to use is determined by calling
 * {@link Measure#getExpectedWeighting() }.
 * 

<<<<<<< HEAD * ======= * >>>>>>> 5f0ba9177b34449ea27dabdc17fd0793620c7d56 * @author Hamish I A Morgan <hamish.morgan@sussex.ac.uk> */ @Immutable

Solution content
 * The weighting scheme to use is determined by calling
 * {@link Measure#getExpectedWeighting() }.
 * 

* * @author Hamish I A Morgan <hamish.morgan@sussex.ac.uk> */ @Immutable

File
AutoWeightingMeasure.java
Developer's decision
Version 1
Kind of conflict
Comment
Chunk
Conflicting content
		this.weighting = weighting;
	}

<<<<<<< HEAD
    public AutoWeightingMeasure(Measure delegate, Weighting weighting) {
        super(delegate);
        Checks.checkNotNull("weighting", weighting);
        this.weighting = weighting;
    }
=======
	@Override
	public double similarity(SparseDoubleVector A, SparseDoubleVector B) {
		return getDelegate().similarity(weighting.apply(A), weighting.apply(B));
	}
>>>>>>> 5f0ba9177b34449ea27dabdc17fd0793620c7d56

	public Weighting getWeighting() {
		return weighting;
Solution content
    public AutoWeightingMeasure(Measure delegate, Weighting weighting) {
        super(delegate);
        Checks.checkNotNull("weighting", weighting);
        this.weighting = weighting;
    }

	@Override
	public double similarity(SparseDoubleVector A, SparseDoubleVector B) {
		return getDelegate().similarity(weighting.apply(A), weighting.apply(B));
	}

	public Weighting getWeighting() {
		return weighting;
File
AutoWeightingMeasure.java
Developer's decision
Concatenation
Kind of conflict
Annotation
Method declaration
Chunk
Conflicting content
/**
 * ForwardingMeasure is an abstract super-class to decorators of
 * Measure instances.
<<<<<<< HEAD
 *
 * @param  type of Measure being decorated
 * @author Hamish I A Morgan <hamish.morgan@sussex.ac.uk>
=======
 * 

* * @author Hamish I A Morgan <hamish.morgan@sussex.ac.uk> * @param * type of Measure being decorated >>>>>>> 5f0ba9177b34449ea27dabdc17fd0793620c7d56 */ @Immutable @CheckReturnValue

Solution content
/**
 * ForwardingMeasure is an abstract super-class to decorators of
 * Measure instances.
 *
 * @param  type of Measure being decorated
 * @author Hamish I A Morgan <hamish.morgan@sussex.ac.uk>
 */
@Immutable
@CheckReturnValue
File
ForwardingMeasure.java
Developer's decision
Version 1
Kind of conflict
Comment
Chunk
Conflicting content
@CheckReturnValue
public abstract class ForwardingMeasure implements Measure {

<<<<<<< HEAD
    private final T delegate;

    /**
     * Constructor used by sub-classes.
     *
     * @param delegate The Measure being decorated.
     */
    protected ForwardingMeasure(final T delegate) {
        Checks.checkNotNull("delegate", delegate);
        this.delegate = delegate;
    }

    @Override
    public double similarity(
            final SparseDoubleVector A,
            final SparseDoubleVector B) {
        return delegate.similarity(A, B);
    }

    public final T getDelegate() {
        return delegate;
    }

    @Override
    public double getHomogeneityBound() {
        return delegate.getHomogeneityBound();
    }

    @Override
    public double getHeterogeneityBound() {
        return delegate.getHeterogeneityBound();
    }
=======
	private final T deligate;

	/**
	 * Constructor used by sub-classes.
	 * 

* * @param deligate * The Measure being decorated. */ protected ForwardingMeasure(final T deligate) { Checks.checkNotNull("deligate", deligate); this.deligate = deligate; } @Override public double similarity(final SparseDoubleVector A, final SparseDoubleVector B) { return deligate.similarity(A, B); } public final T getDelegate() { return deligate; } @Override public double getHomogeneityBound() { return deligate.getHomogeneityBound(); } @Override public double getHeterogeneityBound() { return deligate.getHeterogeneityBound(); } >>>>>>> 5f0ba9177b34449ea27dabdc17fd0793620c7d56 @Override public Class getExpectedWeighting() {

Solution content
@CheckReturnValue
public abstract class ForwardingMeasure
        implements Measure {

    private final T delegate;

    /**
     * Constructor used by sub-classes.
     *
     * @param delegate The Measure being decorated.
     */
    protected ForwardingMeasure(final T delegate) {
        Checks.checkNotNull("delegate", delegate);
        this.delegate = delegate;
    }

    @Override
    public double similarity(
            final SparseDoubleVector A,
            final SparseDoubleVector B) {
        return delegate.similarity(A, B);
    }

    public final T getDelegate() {
        return delegate;
    }

    @Override
    public double getHomogeneityBound() {
        return delegate.getHomogeneityBound();
    }

    @Override
    public double getHeterogeneityBound() {
        return delegate.getHeterogeneityBound();
    }
File
ForwardingMeasure.java
Developer's decision
Manual
Kind of conflict
Annotation
Attribute
Comment
Method declaration
Chunk
Conflicting content
		return NullWeighting.class;
	}

<<<<<<< HEAD
    @Override
    public boolean isCommutative() {
        return delegate.isCommutative();
    }

    public boolean equals(ForwardingMeasure other) {
        if (this.delegate != other.delegate
                && (this.delegate == null
                || !this.delegate.equals(other.delegate)))
            return false;
        return true;
    }
=======
	@Override
	public boolean isCommutative() {
		return deligate.isCommutative();
	}

	public boolean equals(ForwardingMeasure other) {
		if (this.deligate != other.deligate
				&& (this.deligate == null || !this.deligate
						.equals(other.deligate)))
			return false;
		return true;
	}
>>>>>>> 5f0ba9177b34449ea27dabdc17fd0793620c7d56

	@Override
	public boolean equals(Object obj) {
Solution content
    @Override
    public boolean isCommutative() {
        return delegate.isCommutative();
    }

    public boolean equals(ForwardingMeasure other) {
        if (this.delegate != other.delegate
                && (this.delegate == null
                || !this.delegate.equals(other.delegate)))
            return false;
        return true;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == this)
            return true;
        if (obj == null || getClass() != obj.getClass())
            return false;
        return equals((ForwardingMeasure) obj);
    }

    @Override
    public int hashCode() {
        return 79 * 5 + (delegate != null ? delegate.hashCode() : 0);
    }

    @Override
    public String toString() {
        return this.getClass().getSimpleName() + "{delegate=" + delegate + '}';
    }
}
File
ForwardingMeasure.java
Developer's decision
Manual
Kind of conflict
Annotation
Method declaration
Chunk
Conflicting content
		return equals((ForwardingMeasure) obj);
	}

<<<<<<< HEAD
    @Override
    public int hashCode() {
        return 79 * 5 + (delegate != null ? delegate.hashCode() : 0);
    }

    @Override
    public String toString() {
        return this.getClass().getSimpleName() + "{delegate=" + delegate + '}';
    }
=======
	@Override
	public int hashCode() {
		return 79 * 5 + (deligate != null ? deligate.hashCode() : 0);
	}

	@Override
	public String toString() {
		return this.getClass().getSimpleName() + "{deligate=" + deligate + '}';
	}
>>>>>>> 5f0ba9177b34449ea27dabdc17fd0793620c7d56
}
Solution content
    @Override
    public int hashCode() {
        return 79 * 5 + (delegate != null ? delegate.hashCode() : 0);
    }

    @Override
    public String toString() {
        return this.getClass().getSimpleName() + "{delegate=" + delegate + '}';
    }
}
File
ForwardingMeasure.java
Developer's decision
Version 1
Kind of conflict
Annotation
Method declaration
Chunk
Conflicting content
/**
 * Measure is a common super-interface to various similarity measure types.
 * 

<<<<<<< HEAD * ======= * >>>>>>> 5f0ba9177b34449ea27dabdc17fd0793620c7d56 * @author Hamish I A Morgan <hamish.morgan@sussex.ac.uk> */ public interface Measure {

Solution content
/**
 * Measure is a common super-interface to various similarity measure types.
 * 

* * @author Hamish I A Morgan <hamish.morgan@sussex.ac.uk> */ public interface Measure {

File
Measure.java
Developer's decision
Version 1
Kind of conflict
Comment
Chunk
Conflicting content
	/**
    @CheckReturnValue

 */
public interface Measure {

<<<<<<< HEAD
    /**
     * Compute the similarity score between the vector operands.
     * 

* * @param A first feature vector * @param B second feature vector * @return similarity of the feature vectors */ @CheckReturnValue double similarity(SparseDoubleVector A, SparseDoubleVector B); /** * Gets the to similarity score that will be produced by this measure when * two vectors are identical. In the case of proximity scores this value * should usually be 0. For distance metrics it is usually +infinity, *

* * @return value indicating vectors are identical */ @CheckReturnValue double getHomogeneityBound(); /** * Gets the similarity score that will be produced by this measure when two * vectors could not be more dissimilar. In the case of proximity scores * this value should usually be 1 or +infinity. For distance metrics it is * usually 0, *

* * @return value indicating vectors are maximally dissimilar */ double getHeterogeneityBound(); /** * Gets the {@link Weighting} scheme that should have been previously * applied to feature vectors before this {@link Measure} implementation is * used. *

* Some measures can operate on pretty much any kind of vector (for example * geometric distance measures). Others require the vectors to take a * particular form. Set theoretic measures {@link Dice} and {@link Jaccard} * require feature weights to be positive, though not binary as one might * expect since multi-set generalizations are implemented. Lin and Weeds * measure expect PMI weighting. *

* * @return weighting scheme that should have been previously applied to * vectors */ @CheckReturnValue Class getExpectedWeighting(); /** * Whether or not the operands can be reversed without changing the * resultant similarity score. *

* Traditionally, similarity measures define a symmetric space but this does * not have to be the case. Symmetric space must be defined by a commutative * similarity measure (where sim(x,y) = sim(y,x)). However, non-symmetric * spaces are possible. In these cases the measure should be marked as * non-commutative. *

* In the case of distance measures, a commutative kernel will define a * true metric, while a non-commutative kernel will not. For * example {@link KLDivergence} is a distance measure while the * {@link LpSpace} variants are true metrics. *

* * @return true if the measure defines a symmetric space, false otherwise */ @CheckReturnValue boolean isCommutative(); ======= /** * Compute the similarity score between the vector operands. *

* * @param A * first feature vector * @param B * second feature vector * @return similarity of the feature vectors */ @CheckReturnValue double similarity(SparseDoubleVector A, SparseDoubleVector B); /** * Gets the to similarity score that will be produced by this measure when * two vectors are identical. In the case of proximity scores this value * should usually be 0. For distance metrics it is usually +infinity, *

* * @return value indicating vectors are identical */ @CheckReturnValue double getHomogeneityBound(); /** * Gets the similarity score that will be produced by this measure when two * vectors could not be more dissimilar. In the case of proximity scores * this value should usually be 1 or +infinity. For distance metrics it is * usually 0, *

* * @return value indicating vectors are maximally dissimilar */ @CheckReturnValue double getHeterogeneityBound(); /** * Gets the {@link Weighting} scheme that should have been previously * applied to feature vectors before this {@link Measure} implementation is * used. *

* Some measures can operate on pretty much any kind of vector (for example * geometric distance measures). Others require the vectors to take a * particular form. Set theoretic measures {@link Dice} and {@link Jaccard} * require feature weights to be positive, though not binary as one might * expect since multi-set generalizations are implemented. Lin and Weeds * measure expect PMI weighting. *

* * @return weighting scheme that should have been previously applied to * vectors */ @CheckReturnValue Class getExpectedWeighting(); * Whether or not the operands can be reversed without changing the * resultant similarity score. *

* Traditionally, similarity measures define a symmetric space but this does * not have to be the case. Symmetric space must be defined by a commutative * similarity measure (where sim(x,y) = sim(y,x)). However, non-symmetric * spaces are possible. In these cases the measure should be marked as * non-commutative. *

* In the case of distance measures, a commutative kernel will define a * true metric, while a non-commutative kernel will not. For * example {@link KLDivergence} is a distance measure while the * {@link LpSpace} variants are true metrics. *

* * @return true if the measure defines a symmetric space, false otherwise */ @CheckReturnValue boolean isCommutative(); >>>>>>> 5f0ba9177b34449ea27dabdc17fd0793620c7d56 }

Solution content
 */
public interface Measure {

    /**
     * Compute the similarity score between the vector operands.
     * 

* * @param A first feature vector * @param B second feature vector * @return similarity of the feature vectors */ @CheckReturnValue double similarity(SparseDoubleVector A, SparseDoubleVector B); /** * Gets the to similarity score that will be produced by this measure when * two vectors are identical. In the case of proximity scores this value * should usually be 0. For distance metrics it is usually +infinity, *

* * @return value indicating vectors are identical */ @CheckReturnValue double getHomogeneityBound(); /** * Gets the similarity score that will be produced by this measure when two * vectors could not be more dissimilar. In the case of proximity scores * this value should usually be 1 or +infinity. For distance metrics it is * usually 0, *

* * @return value indicating vectors are maximally dissimilar */ @CheckReturnValue double getHeterogeneityBound(); /** * Gets the {@link Weighting} scheme that should have been previously * applied to feature vectors before this {@link Measure} implementation is * used. *

* Some measures can operate on pretty much any kind of vector (for example * geometric distance measures). Others require the vectors to take a * particular form. Set theoretic measures {@link Dice} and {@link Jaccard} * require feature weights to be positive, though not binary as one might * expect since multi-set generalizations are implemented. Lin and Weeds * measure expect PMI weighting. *

* * @return weighting scheme that should have been previously applied to * vectors */ @CheckReturnValue Class getExpectedWeighting(); /** * Whether or not the operands can be reversed without changing the * resultant similarity score. *

* Traditionally, similarity measures define a symmetric space but this does * not have to be the case. Symmetric space must be defined by a commutative * similarity measure (where sim(x,y) = sim(y,x)). However, non-symmetric * spaces are possible. In these cases the measure should be marked as * non-commutative. *

* In the case of distance measures, a commutative kernel will define a * true metric, while a non-commutative kernel will not. For * example {@link KLDivergence} is a distance measure while the * {@link LpSpace} variants are true metrics. *

* * @return true if the measure defines a symmetric space, false otherwise */ @CheckReturnValue boolean isCommutative(); }

File
Measure.java
Developer's decision
Version 1
Kind of conflict
Comment
Method interface
Chunk
Conflicting content
 */
package uk.ac.susx.mlcl.byblo.measures.impl;

<<<<<<< HEAD
=======
import javax.annotation.CheckReturnValue;
import javax.annotation.Nullable;

>>>>>>> 5f0ba9177b34449ea27dabdc17fd0793620c7d56
import uk.ac.susx.mlcl.byblo.measures.Measure;
import uk.ac.susx.mlcl.byblo.weighings.FeatureMarginalsCarrier;
import uk.ac.susx.mlcl.byblo.weighings.MarginalDistribution;
Solution content
 */
package uk.ac.susx.mlcl.byblo.measures.impl;

import uk.ac.susx.mlcl.byblo.measures.Measure;
import uk.ac.susx.mlcl.byblo.weighings.FeatureMarginalsCarrier;
import uk.ac.susx.mlcl.byblo.weighings.MarginalDistribution;
File
Confusion.java
Developer's decision
Version 1
Kind of conflict
Import
Chunk
Conflicting content
 * not necessarily the most similar entry to itself.
 * 

* <<<<<<< HEAD * * @author Hamish I A Morgan <hamish.morgan@sussex.ac.uk> * @see JE Weeds (2003) "Measures and Applications of Lexical Distributional * Similarity", which references (Sugawara, Nishimura, Toshioka, Okachi, & * Kaneko, 1985; Essen & Steinbiss, 1992; Grishman & Sterling, 1993; Dagan et * al., 1999; Lapata et al., 2001) * @see Essen, Ute and Volker Steinbiss. 1992. Co-occurrence smoothing for * stochastic language modeling. In Proceedings of ICASSP, volume 1, pages * 161{164. * @see Sugawara, K., M. Nishimura, K. Toshioka, M. Okochi, and T. Kaneko. 1985. * Isolated word recognition using hidden Markov models. In Proceedings of * ICASSP, pages 1--4, Tampa, Florida. IEEE. ======= *

* * @see JE Weeds (2003) "Measures and Applications of Lexical Distributional * Similarity", which references (Sugawara, Nishimura, Toshioka, Okachi, & * Kaneko, 1985; Essen & Steinbiss, 1992; Grishman & Sterling, 1993; Dagan * et al., 1999; Lapata et al., 2001) *

* @see Essen, Ute and Volker Steinbiss. 1992. Co-occurrence smoothing for * stochastic language modeling. In Proceedings of ICASSP, volume 1, pages * 161{164. *

* @see Sugawara, K., M. Nishimura, K. Toshioka, M. Okochi, and T. Kaneko. 1985. * Isolated word recognition using hidden Markov models. In Proceedings of * ICASSP, pages 1--4, Tampa, Florida. IEEE. *

>>>>>>> 5f0ba9177b34449ea27dabdc17fd0793620c7d56 * @see Grishman, Ralph and John Sterling. 1993. Smoothing of automatically * generated selectional constraints. In Human Language Technology, pages * 254{259, San Francisco, California. Advanced Research Projects Agency,

Solution content
 * not necessarily the most similar entry to itself.
 * 

* * * @author Hamish I A Morgan <hamish.morgan@sussex.ac.uk> * @see JE Weeds (2003) "Measures and Applications of Lexical Distributional * Similarity", which references (Sugawara, Nishimura, Toshioka, Okachi, & * Kaneko, 1985; Essen & Steinbiss, 1992; Grishman & Sterling, 1993; Dagan et * al., 1999; Lapata et al., 2001) * @see Essen, Ute and Volker Steinbiss. 1992. Co-occurrence smoothing for * stochastic language modeling. In Proceedings of ICASSP, volume 1, pages * 161{164. * @see Sugawara, K., M. Nishimura, K. Toshioka, M. Okochi, and T. Kaneko. 1985. * Isolated word recognition using hidden Markov models. In Proceedings of * ICASSP, pages 1--4, Tampa, Florida. IEEE. * @see Grishman, Ralph and John Sterling. 1993. Smoothing of automatically * generated selectional constraints. In Human Language Technology, pages * 254{259, San Francisco, California. Advanced Research Projects Agency,

File
Confusion.java
Developer's decision
Version 1
Kind of conflict
Comment
Chunk
Conflicting content
 *      generated selectional constraints. In Human Language Technology, pages
 *      254{259, San Francisco, California. Advanced Research Projects Agency,
 *      Software and Intelligent Systems Technology Oce, Morgan Kaufmann.
<<<<<<< HEAD
=======
 *      

* @author Hamish I A Morgan <hamish.morgan@sussex.ac.uk> >>>>>>> 5f0ba9177b34449ea27dabdc17fd0793620c7d56 */ @CheckReturnValue public class Confusion implements Measure, FeatureMarginalsCarrier {

Solution content
 *      generated selectional constraints. In Human Language Technology, pages
 *      254{259, San Francisco, California. Advanced Research Projects Agency,
 *      Software and Intelligent Systems Technology Oce, Morgan Kaufmann.
 */
@CheckReturnValue
public class Confusion implements Measure, FeatureMarginalsCarrier {
File
Confusion.java
Developer's decision
Version 1
Kind of conflict
Comment
Chunk
Conflicting content
 * Proximity measure calculating proximity as the degree orthogonality between
 * vectors; the cosine of the angle between them.
 * 

<<<<<<< HEAD * ======= * >>>>>>> 5f0ba9177b34449ea27dabdc17fd0793620c7d56 * @author Hamish I A Morgan <hamish.morgan@sussex.ac.uk> */ @Immutable

Solution content
 * Proximity measure calculating proximity as the degree orthogonality between
 * vectors; the cosine of the angle between them.
 * 

* * @author Hamish I A Morgan <hamish.morgan@sussex.ac.uk> */ @Immutable

File
Cosine.java
Developer's decision
Version 1
Kind of conflict
Comment
Chunk
Conflicting content
 */
package uk.ac.susx.mlcl.byblo.measures.impl;

<<<<<<< HEAD
=======
import java.io.Serializable;

import javax.annotation.CheckReturnValue;
import javax.annotation.concurrent.Immutable;

>>>>>>> 5f0ba9177b34449ea27dabdc17fd0793620c7d56
import uk.ac.susx.mlcl.byblo.measures.Measure;
import uk.ac.susx.mlcl.byblo.measures.Measures;
import uk.ac.susx.mlcl.byblo.weighings.Weighting;
Solution content
 */
package uk.ac.susx.mlcl.byblo.measures.impl;

import uk.ac.susx.mlcl.byblo.measures.Measure;
import uk.ac.susx.mlcl.byblo.measures.Measures;
import uk.ac.susx.mlcl.byblo.weighings.Weighting;
File
DotProduct.java
Developer's decision
Version 1
Kind of conflict
Import
Chunk
Conflicting content
 * Proximity measure calculating proximity as the dot product of the vectors.
 * For unit vectors this is equivalent to {@link Cosine }.
 * 

<<<<<<< HEAD * ======= * >>>>>>> 5f0ba9177b34449ea27dabdc17fd0793620c7d56 * @author Hamish I A Morgan <hamish.morgan@sussex.ac.uk> */ @Immutable

Solution content
 * Proximity measure calculating proximity as the dot product of the vectors.
 * For unit vectors this is equivalent to {@link Cosine }.
 * 

* * @author Hamish I A Morgan <hamish.morgan@sussex.ac.uk> */ @Immutable

File
DotProduct.java
Developer's decision
Version 1
Kind of conflict
Comment
Chunk
Conflicting content
import java.io.Serializable;

/**
<<<<<<< HEAD
=======
 * 
 * 
>>>>>>> 5f0ba9177b34449ea27dabdc17fd0793620c7d56
 * @author Hamish I A Morgan <hamish.morgan@sussex.ac.uk>
 */
@Immutable
Solution content
import java.io.Serializable;

/**
 * @author Hamish I A Morgan <hamish.morgan@sussex.ac.uk>
 */
@Immutable
File
Hindle.java
Developer's decision
Version 1
Kind of conflict
Comment
Chunk
Conflicting content
 */
package uk.ac.susx.mlcl.byblo.measures.impl;

<<<<<<< HEAD
=======
import java.io.Serializable;

import javax.annotation.CheckReturnValue;
import javax.annotation.concurrent.Immutable;

>>>>>>> 5f0ba9177b34449ea27dabdc17fd0793620c7d56
import uk.ac.susx.mlcl.byblo.measures.DecomposableMeasure;
import uk.ac.susx.mlcl.byblo.measures.Measures;
import uk.ac.susx.mlcl.byblo.weighings.Weighting;
Solution content
 */
package uk.ac.susx.mlcl.byblo.measures.impl;

import uk.ac.susx.mlcl.byblo.measures.DecomposableMeasure;
import uk.ac.susx.mlcl.byblo.measures.Measures;
import uk.ac.susx.mlcl.byblo.weighings.Weighting;
File
Jaccard.java
Developer's decision
Version 1
Kind of conflict
Import
Chunk
Conflicting content
 * than zero and one) this measures takes a multi-set view of set operations:
 * intersection is the maximum and union is the minimum.
 * 

<<<<<<< HEAD * ======= * >>>>>>> 5f0ba9177b34449ea27dabdc17fd0793620c7d56 * @author Hamish I A Morgan <hamish.morgan@sussex.ac.uk> */ @Immutable

Solution content
 * than zero and one) this measures takes a multi-set view of set operations:
 * intersection is the maximum and union is the minimum.
 * 

* * @author Hamish I A Morgan <hamish.morgan@sussex.ac.uk> */ @Immutable

File
Jaccard.java
Developer's decision
Version 1
Kind of conflict
Comment
Chunk
Conflicting content
/**
 * Distance measure that computes similarity as the Jensen-Shannon divergence.
 * 

<<<<<<< HEAD * ======= * >>>>>>> 5f0ba9177b34449ea27dabdc17fd0793620c7d56 * @author Hamish I A Morgan <hamish.morgan@sussex.ac.uk> */ @Immutable

Solution content
/**
 * Distance measure that computes similarity as the Jensen-Shannon divergence.
 * 

* * @author Hamish I A Morgan <hamish.morgan@sussex.ac.uk> */ @Immutable

File
JensenShannonDivergence.java
Developer's decision
Version 1
Kind of conflict
Comment
Chunk
Conflicting content
    }
=======
		return divergence;
		if (Math.abs(divergence - getHomogeneityBound()) < EPSILON)
			divergence = getHomogeneityBound();

<<<<<<< HEAD
    @Override
    public double similarity(SparseDoubleVector A, SparseDoubleVector B) {
        double divergence = 0;

        int i = 0, j = 0;
        while (i < A.size && j < B.size) {
            if (A.keys[i] < B.keys[j]) {
                divergence += A.values[i] / A.sum;
                i++;
            } else if (A.keys[i] > B.keys[j]) {
                divergence += B.values[j] / B.sum;
                j++;
            } else {
                final double pA = A.values[i] / A.sum;
                final double pB = B.values[j] / B.sum;
                final double lpAvg = log2(pA + pB) - 1.;
                divergence += pA * (log2(pA) - lpAvg);
                divergence += pB * (log2(pB) - lpAvg);
                i++;
                j++;
            }
        }

        while (i < A.size) {
            divergence += A.values[i] / A.sum;
            i++;
        }

        while (j < B.size) {
            divergence += B.values[j] / B.sum;
            j++;
        }

        return divergence / 2.;
	}

	@Override
	public boolean isCommutative() {
		return true;
	}

	@Override
	public double getHomogeneityBound() {
		return 0;
	}
>>>>>>> 5f0ba9177b34449ea27dabdc17fd0793620c7d56

	@Override
	public double getHeterogeneityBound() {
Solution content
    @Override
    public double similarity(SparseDoubleVector A, SparseDoubleVector B) {
        double divergence = 0;

        int i = 0, j = 0;
        while (i < A.size && j < B.size) {
            if (A.keys[i] < B.keys[j]) {
                divergence += A.values[i] / A.sum;
                i++;
            } else if (A.keys[i] > B.keys[j]) {
                divergence += B.values[j] / B.sum;
                j++;
            } else {
                final double pA = A.values[i] / A.sum;
                final double pB = B.values[j] / B.sum;
                final double lpAvg = log2(pA + pB) - 1.;
                divergence += pA * (log2(pA) - lpAvg);
                divergence += pB * (log2(pB) - lpAvg);
                i++;
                j++;
            }
        }

        while (i < A.size) {
            divergence += A.values[i] / A.sum;
            i++;
        }

        while (j < B.size) {
            divergence += B.values[j] / B.sum;
            j++;
        }


        divergence = divergence / 2.;

        // The algorithm introduces a small amount of floating point error, which can lead to result slightly outside
        // the expected bounds. To correct for this we clamp results to the bound when they are within some small value.
        if(Math.abs(divergence - getHeterogeneityBound()) < EPSILON)
            divergence = getHeterogeneityBound();
        if(Math.abs(divergence - getHomogeneityBound()) < EPSILON)
            divergence = getHomogeneityBound();

        return divergence;
    }

    @Override
    public boolean isCommutative() {
        return true;
    }

    @Override
    public double getHomogeneityBound() {
        return 0;
    }

    @Override
    public double getHeterogeneityBound() {
        return 1;
    }

    @Override
    public Class getExpectedWeighting() {
        return PositiveWeighting.class;
    }

    public boolean equals(Object obj) {
        return obj != null && obj.getClass() == this.getClass();
    }

    public int hashCode() {
        return this.getClass().hashCode();
    }

    @Override
    public String toString() {
        return "JS-Divergence";
    }
}
File
JensenShannonDivergence.java
Developer's decision
Manual
Kind of conflict
Annotation
Method declaration
Return statement
Variable
Chunk
Conflicting content
		return PositiveWeighting.class;
	}

<<<<<<< HEAD
    @Override
    public double getHeterogeneityBound() {
        return 1;
    }
=======
	@Override
	public String toString() {
		return "JS-Divergence";
	}
>>>>>>> 5f0ba9177b34449ea27dabdc17fd0793620c7d56

	@Override
	public int hashCode() {
Solution content
    @Override
    public double getHeterogeneityBound() {
        return 1;
    }

    @Override
    public Class getExpectedWeighting() {
        return PositiveWeighting.class;
    }

    public boolean equals(Object obj) {
        return obj != null && obj.getClass() == this.getClass();
    }

    public int hashCode() {
        return this.getClass().hashCode();
    }

    @Override
    public String toString() {
        return "JS-Divergence";
    }
}
File
JensenShannonDivergence.java
Developer's decision
Manual
Kind of conflict
Annotation
Method declaration
Chunk
Conflicting content
 * 

* *

<<<<<<< HEAD * ======= * >>>>>>> 5f0ba9177b34449ea27dabdc17fd0793620c7d56 * @author Hamish I A Morgan <hamish.morgan@sussex.ac.uk> * @see "A New Measure of Rank Correlation." Maurice Kendall (1938). Biometrika * 30 (1–2): 81–89."

Solution content
 * 

* *

* * @author Hamish I A Morgan <hamish.morgan@sussex.ac.uk> * @see "A New Measure of Rank Correlation." Maurice Kendall (1938). Biometrika * 30 (1–2): 81–89."

File
KendallsTau.java
Developer's decision
Version 1
Kind of conflict
Comment
Chunk
Conflicting content
    }
 *      30 (1–2): 81–89."
 */
@CheckReturnValue
<<<<<<< HEAD
public final class KendallsTau
        implements Measure, Serializable {

    private static final long serialVersionUID = 1L;

    private static final Log LOG = LogFactory.getLog(KendallsTau.class);

    /**
     * Default expected minimum dimensionality of vectors ({@value}) if not
     * explicitly set.
     */
    @Nonnegative
    public static final int DEFAULT_MIN_CARDINALITY = 1;

    /**
     * Expected dimensionality of vectors.
     */
    @Nonnegative
    private int minCardinality;

    /**
     * Construct a new instance of {@link KendallsTau } similarity measure.
     * 

* The minCardinality field is initialized to * {@link KendallsTau#DEFAULT_MIN_CARDINALITY}, which is {@value * #DEFAULT_MIN_CARDINALITY} */ public KendallsTau() { this(DEFAULT_MIN_CARDINALITY); } /** * Construct new instance of {@link KendallsTau } similarity measure, * initializing the expected dimensionality of vectors to * minCardinality. *

* * @param minCardinality expected dimensionality of vectors * @throws IllegalArgumentException when minCardinality is * negative */ public KendallsTau(@Nonnegative final int minCardinality) throws IllegalArgumentException { setMinCardinality(minCardinality); if (LOG.isWarnEnabled()) LOG.warn("The KendallsTau proximity measure is extremely " + "inefficient (quadratic on the number of features). " + "Consider using a different measure."); } /** * Get the minimum (usually the actual) cardinality of vectors. *

* * @return expected dimensionality of vectors */ @Nonnegative public final int getMinCardinality() { return minCardinality; } /** * Set the minimum (usually the actual) cardinality of vectors. *

* If the vector cardinality is known before hand, but is not set on the * vectors for some reason, then method can be used to set it globally. *

* * @param minCardinality expected dimensionality of vectors * @throws IllegalArgumentException when minCardinality is * negative */ public final void setMinCardinality(@Nonnegative int minCardinality) throws IllegalArgumentException { if (minCardinality <= 0) throw new IllegalArgumentException(MessageFormat.format( "expecting minCardinality > 0, but found {0}", minCardinality)); this.minCardinality = minCardinality; // A[j] = A.values[aj] /** * Compute the rank correlation score between the vector operands. Larger * values indicate a greater degree of similarity. Specifically the * orientation of this measure is: -1 indicating total disagreement, +1 * indicating total agreement, and ~0 indicating independence. *

* * @param A first feature vector * @param B second feature vector * @return rank correlation of the feature vectors */ @Override public double similarity( final SparseDoubleVector A, final SparseDoubleVector B) { final int N = Math.max(minCardinality, Math.max(A.cardinality, B.cardinality)); final int L = A.size; final int M = B.size; long cordance = 0; long aties = 0; long bties = 0; int intersectionSize = 0; // A double merge operations (one inside the other) the get all pairwise // combinations of non-zero elements in both vectors. This has been // implemented with more-compact but slightly slower merge method, // without trailing accumulators, to help reduce the probability of // errors. int ai = 0, bi = 0; while (ai + bi < L + M) { if (ai < L && (bi == M || A.keys[ai] < B.keys[bi])) { // A[i] = A.values[ai] // B[i] = 0 int aj = 0, bj = 0; while (aj + bj < ai + bi) { if (aj < ai && (bj == bi || A.keys[aj] < B.keys[bj])) { // A[j] = A.values[aj] // B[j] = 0 if (epsilonEquals(A.values[ai], A.values[aj], 0)) ++aties; ++aj; } else if (bj < bi && (aj == ai || B.keys[bj] < A.keys[aj])) { // A[j] = 0 // B[j] = B.values[bj] cordance += signum(A.values[ai]) * signum(-B.values[bj]); ++bj; } else if (aj < ai && bj < bi) { // A[j] = A.values[aj] // B[j] = B.values[bj] if (epsilonEquals(A.values[ai], A.values[aj], 0)) ++aties; else cordance += signum(A.values[ai] - A.values[aj]) * signum(-B.values[bj]); ++aj; ++bj; } else { throw new AssertionError(); } } ++ai; } else if (bi < M && (ai == L || B.keys[bi] < A.keys[ai])) { // A[i] = 0 // B[i] = B.values[bi] int aj = 0, bj = 0; while (aj + bj < ai + bi) { if (aj < ai && (bj == bi || A.keys[aj] < B.keys[bj])) { // B[j] = 0 cordance += signum(-A.values[aj]) * signum(B.values[bi]); ++aj; } else if (bj < bi && (aj == ai || B.keys[bj] < A.keys[aj])) { // A[j] = 0 // B[j] = B.values[bj] if (epsilonEquals(B.values[bi], B.values[bj], 0)) ++bties; ++bj; } else if (aj < ai && bj < bi) { // A[j] = A.values[aj] // B[j] = B.values[bj] if (epsilonEquals(B.values[bi], B.values[bj], 0)) ++bties; else cordance += signum(-A.values[aj]) * signum(B.values[bi] - B.values[bj]); ++aj; ++bj; } else { throw new AssertionError(); } } ++bi; } else if (ai < L && bi < M) { // A[i] = A.values[ai] // B[i] = B.values[bi] int aj = 0, bj = 0; while (aj + bj < ai + bi) { if (aj < ai && (bj == bi || A.keys[aj] < B.keys[bj])) { // A[j] = A.values[aj] // B[j] = 0 if (epsilonEquals(A.values[ai], A.values[aj], 0)) ++aties; else cordance += signum(A.values[ai] - A.values[aj]) * signum(B.values[bi]); ++aj; } else if (bj < bi && (aj == ai || B.keys[bj] < A.keys[aj])) { // A[j] = 0 // B[j] = B.values[bj] if (epsilonEquals(B.values[bi], B.values[bj], 0)) ++bties; else cordance += signum(A.values[ai]) * signum(B.values[bi] - B.values[bj]); ++bj; } else if (aj < ai && bj < bi) { // A[j] = A.values[aj] // B[j] = B.values[bj] if (epsilonEquals(A.values[ai], A.values[aj], 0)) { ++aties; if (epsilonEquals(B.values[bi], B.values[bj], 0)) ++bties; } else if (epsilonEquals(B.values[bi], B.values[bj], 0)) { ++bties; } else { cordance += signum(A.values[ai] - A.values[aj]) * signum(B.values[bi] - B.values[bj]); } ++aj; ++bj; } else { throw new AssertionError(); } } ++intersectionSize; ++ai; ++bi; } else { throw new AssertionError(); } } final int unionSize = (L + M) - intersectionSize; // At this point the numbers can overflow rather easily so move // everything to double precision double d_cordance = cordance; double d_aties = aties; double d_bties = bties; // Features that don't occur in either vector are a similarity // between the two sets. For each feature that they both have there // should be an addition +2 to the sum. // The relationship between these and disjoint features d_cordance += ((N - unionSize) * (double) intersectionSize); // Outside of those in the union all elements are zero add all pairwise // combinations to the ties counters. d_aties += ((N - unionSize) * (double) (N - unionSize - 1)) / 2.0; d_bties += ((N - unionSize) * (double) (N - unionSize - 1)) / 2.0; // We also need to the add the cross-tries between zeros in union, and // everything else d_aties += ((unionSize - L) * (double) (N - unionSize)); d_bties += ((unionSize - M) * (double) (N - unionSize)); // Within the union minus the size of vector, all elements are zero so // add all pairwise combinations d_aties += ((unionSize - L) * (double) (unionSize - L - 1)) / 2.0; d_bties += ((unionSize - M) * (double) (unionSize - M - 1)) / 2.0; final double n0 = ((double) N * (N - 1)) / 2.0; final double denom = Math.sqrt((n0 - d_aties) * (n0 - d_bties)); // Avoid divide-by-0 errors for uniform vectors final double sim = !epsilonEquals(d_cordance, 0) ? d_cordance / denom : 0; if (LOG.isInfoEnabled()) LOG.trace(MessageFormat.format( "n0={0}, ti={1}, tj={2}, conc={3}, denom={4}, sim={5}", n0, d_aties, d_bties, d_cordance, denom, sim)); return sim; } @Override public boolean isCommutative() { return true; } @Override public double getHomogeneityBound() { return +1.0; } /** * The rank correlation score indicating approximate independence between * the vectors. Vectors generated from a uniform random distribution are * likely to have a score close to this value. *

* Considering pulling this up to the {@link Measure } interface. *

* * @return score indicating no positive or negative correlation has been * found. */ public double getIndependenceBound() { return 0.0; } @Override public double getHeterogeneityBound() { return -1.0; } @Override public Class getExpectedWeighting() { return NullWeighting.class; } @Override public String toString() { return "Kendalls-Tau{minCardinality=" + minCardinality + '}'; } public boolean equals(final KendallsTau other) { return this.minCardinality == other.minCardinality; } @Override public boolean equals(final Object obj) { if (obj == this) return true; if (obj == null || getClass() != obj.getClass()) return false; return equals((KendallsTau) obj); } @Override public int hashCode() { return 79 * 5 + this.minCardinality; } ======= public final class KendallsTau implements Measure, Serializable { private static final long serialVersionUID = 1L; private static final Log LOG = LogFactory.getLog(KendallsTau.class); private static boolean WARNING_SHOWN = false; private static final String WARNING_MESSAGE = "The KendallsTau " + "proximity measure is extremely inefficient (quadratic on " + "the number of features). Consider using a different measure."; /** * Default expected minimum dimensionality of vectors ({@value} ) if not * explicitly set. */ @Nonnegative public static final int DEFAULT_MIN_CARDINALITY = 1; /** * Expected dimensionality of vectors. */ @Nonnegative private int minCardinality; /** * Construct a new instance of {@link KendallsTau } similarity measure. *

* The minCardinality field is initialized to * {@link KendallsTau#DEFAULT_MIN_CARDINALITY}, which is * {@value #DEFAULT_MIN_CARDINALITY} */ public KendallsTau() { this(DEFAULT_MIN_CARDINALITY); } /** * Construct new instance of {@link KendallsTau } similarity measure, * initializing the expected dimensionality of vectors to * minCardinality. *

* * @param minCardinality * expected dimensionality of vectors * @throws IllegalArgumentException * when minCardinality is negative */ public KendallsTau(@Nonnegative final int minCardinality) throws IllegalArgumentException { setMinCardinality(minCardinality); if (!WARNING_SHOWN && LOG.isWarnEnabled()) { LOG.warn(WARNING_MESSAGE); WARNING_SHOWN = true; } } /** * Get the minimum (usually the actual) cardinality of vectors. *

* * @return expected dimensionality of vectors */ @Nonnegative public final int getMinCardinality() { return minCardinality; } /** * Set the minimum (usually the actual) cardinality of vectors. *

* If the vector cardinality is known before hand, but is not set on the * vectors for some reason, then method can be used to set it globally. *

* * @param minCardinality * expected dimensionality of vectors * @throws IllegalArgumentException * when minCardinality is negative */ public final void setMinCardinality(@Nonnegative int minCardinality) throws IllegalArgumentException { if (minCardinality <= 0) throw new IllegalArgumentException(MessageFormat.format( "expecting minCardinality > 0, but found {0}", minCardinality)); this.minCardinality = minCardinality; } /** * Compute the rank correlation score between the vector operands. Larger * values indicate a greater degree of similarity. Specifically the * orientation of this measure is: -1 indicating total disagreement, +1 * indicating total agreement, and ~0 indicating independence. *

* * @param A * first feature vector * @param B * second feature vector * @return rank correlation of the feature vectors */ @Override public double similarity(final SparseDoubleVector A, final SparseDoubleVector B) { final int N = Math.max(minCardinality, Math.max(A.cardinality, B.cardinality)); final int L = A.size; final int M = B.size; long cordance = 0; long aties = 0; long bties = 0; int intersectionSize = 0; // A double merge operations (one inside the other) the get all pairwise // combinations of non-zero elements in both vectors. This has been // implemented with more-compact but slightly slower merge method, // without trailing accumulators, to help reduce the probability of // errors. int ai = 0, bi = 0; while (ai + bi < L + M) { if (ai < L && (bi == M || A.keys[ai] < B.keys[bi])) { // A[i] = A.values[ai] // B[i] = 0 int aj = 0, bj = 0; while (aj + bj < ai + bi) { if (aj < ai && (bj == bi || A.keys[aj] < B.keys[bj])) { // A[j] = A.values[aj] // B[j] = 0 if (epsilonEquals(A.values[ai], A.values[aj], 0)) ++aties; ++aj; } else if (bj < bi && (aj == ai || B.keys[bj] < A.keys[aj])) { // A[j] = 0 // B[j] = B.values[bj] cordance += signum(A.values[ai]) * signum(-B.values[bj]); ++bj; } else if (aj < ai && bj < bi) { // A[j] = A.values[aj] // B[j] = B.values[bj] if (epsilonEquals(A.values[ai], A.values[aj], 0)) ++aties; else cordance += signum(A.values[ai] - A.values[aj]) * signum(-B.values[bj]); ++aj; ++bj; } else { throw new AssertionError(); } } ++ai; } else if (bi < M && (ai == L || B.keys[bi] < A.keys[ai])) { // A[i] = 0 // B[i] = B.values[bi] int aj = 0, bj = 0; while (aj + bj < ai + bi) { if (aj < ai && (bj == bi || A.keys[aj] < B.keys[bj])) { // A[j] = A.values[aj] // B[j] = 0 cordance += signum(-A.values[aj]) * signum(B.values[bi]); ++aj; } else if (bj < bi && (aj == ai || B.keys[bj] < A.keys[aj])) { // A[j] = 0 // B[j] = B.values[bj] if (epsilonEquals(B.values[bi], B.values[bj], 0)) ++bties; ++bj; } else if (aj < ai && bj < bi) { // A[j] = A.values[aj] // B[j] = B.values[bj] if (epsilonEquals(B.values[bi], B.values[bj], 0)) ++bties; else cordance += signum(-A.values[aj]) * signum(B.values[bi] - B.values[bj]); ++aj; ++bj; } else { throw new AssertionError(); } } ++bi; } else if (ai < L && bi < M) { // A[i] = A.values[ai] // B[i] = B.values[bi] int aj = 0, bj = 0; while (aj + bj < ai + bi) { if (aj < ai && (bj == bi || A.keys[aj] < B.keys[bj])) { // A[j] = A.values[aj] // B[j] = 0 if (epsilonEquals(A.values[ai], A.values[aj], 0)) ++aties; else cordance += signum(A.values[ai] - A.values[aj]) * signum(B.values[bi]); ++aj; } else if (bj < bi && (aj == ai || B.keys[bj] < A.keys[aj])) { // A[j] = 0 // B[j] = B.values[bj] if (epsilonEquals(B.values[bi], B.values[bj], 0)) ++bties; else cordance += signum(A.values[ai]) * signum(B.values[bi] - B.values[bj]); ++bj; } else if (aj < ai && bj < bi) { // A[j] = A.values[aj] // B[j] = B.values[bj] if (epsilonEquals(A.values[ai], A.values[aj], 0)) { ++aties; if (epsilonEquals(B.values[bi], B.values[bj], 0)) ++bties; } else if (epsilonEquals(B.values[bi], B.values[bj], 0)) { ++bties; } else { cordance += signum(A.values[ai] - A.values[aj]) * signum(B.values[bi] - B.values[bj]); } ++aj; ++bj; } else { throw new AssertionError(); } } ++intersectionSize; ++ai; ++bi; } else { throw new AssertionError(); } } final int unionSize = (L + M) - intersectionSize; // At this point the numbers can overflow rather easily so move // everything to double precision double d_cordance = cordance; double d_aties = aties; double d_bties = bties; // Features that don't occur in either vector are a similarity // between the two sets. For each feature that they both have there // should be an addition +2 to the sum. // The relationship between these and disjoint features d_cordance += ((N - unionSize) * (double) intersectionSize); // Outside of those in the union all elements are zero add all pairwise // combinations to the ties counters. d_aties += ((N - unionSize) * (double) (N - unionSize - 1)) / 2.0; d_bties += ((N - unionSize) * (double) (N - unionSize - 1)) / 2.0; // We also need to the add the cross-tries between zeros in union, and // everything else d_aties += ((unionSize - L) * (double) (N - unionSize)); d_bties += ((unionSize - M) * (double) (N - unionSize)); // Within the union minus the size of vector, all elements are zero so // add all pairwise combinations d_aties += ((unionSize - L) * (double) (unionSize - L - 1)) / 2.0; d_bties += ((unionSize - M) * (double) (unionSize - M - 1)) / 2.0; final double n0 = ((double) N * (N - 1)) / 2.0; final double denom = Math.sqrt((n0 - d_aties) * (n0 - d_bties)); // Avoid divide-by-0 errors for uniform vectors final double sim = !epsilonEquals(d_cordance, 0) ? d_cordance / denom : 0; if (LOG.isInfoEnabled()) LOG.trace(MessageFormat.format( "n0={0}, ti={1}, tj={2}, conc={3}, denom={4}, sim={5}", n0, d_aties, d_bties, d_cordance, denom, sim)); return sim; } @Override public boolean isCommutative() { return true; } @Override public double getHomogeneityBound() { return +1.0; } /** * The rank correlation score indicating approximate independence between * the vectors. Vectors generated from a uniform random distribution are * likely to have a score close to this value. *

* Considering pulling this up to the {@link Measure } interface. *

* * @return score indicating no positive or negative correlation has been * found. */ public double getIndependenceBound() { return 0.0; } @Override public double getHeterogeneityBound() { return -1.0; } @Override public Class getExpectedWeighting() { return NullWeighting.class; } @Override public String toString() { return "Kendalls-Tau{minCardinality=" + minCardinality + '}'; } public boolean equals(final KendallsTau other) { return this.minCardinality == other.minCardinality; } @Override public boolean equals(final Object obj) { if (obj == this) return true; if (obj == null || getClass() != obj.getClass()) return false; return equals((KendallsTau) obj); } @Override public int hashCode() { return 79 * 19 + this.minCardinality; } >>>>>>> 5f0ba9177b34449ea27dabdc17fd0793620c7d56 }

Solution content
 *      30 (1–2): 81–89."
 */
@CheckReturnValue
public final class KendallsTau
        implements Measure, Serializable {

    private static final long serialVersionUID = 1L;

    private static final Log LOG = LogFactory.getLog(KendallsTau.class);

    /**
     * Default expected minimum dimensionality of vectors ({@value}) if not
     * explicitly set.
     */
    @Nonnegative
    public static final int DEFAULT_MIN_CARDINALITY = 1;

    /**
     * Expected dimensionality of vectors.
     */
    @Nonnegative
    private int minCardinality;

    /**
     * Construct a new instance of {@link KendallsTau } similarity measure.
     * 

* The minCardinality field is initialized to * {@link KendallsTau#DEFAULT_MIN_CARDINALITY}, which is {@value * #DEFAULT_MIN_CARDINALITY} */ public KendallsTau() { this(DEFAULT_MIN_CARDINALITY); } /** * Construct new instance of {@link KendallsTau } similarity measure, * initializing the expected dimensionality of vectors to * minCardinality. *

* * @param minCardinality expected dimensionality of vectors * @throws IllegalArgumentException when minCardinality is * negative */ public KendallsTau(@Nonnegative final int minCardinality) throws IllegalArgumentException { setMinCardinality(minCardinality); if (LOG.isWarnEnabled()) LOG.warn("The KendallsTau proximity measure is extremely " + "inefficient (quadratic on the number of features). " + "Consider using a different measure."); } /** * Get the minimum (usually the actual) cardinality of vectors. *

* * @return expected dimensionality of vectors */ @Nonnegative public final int getMinCardinality() { return minCardinality; } /** * Set the minimum (usually the actual) cardinality of vectors. *

* If the vector cardinality is known before hand, but is not set on the * vectors for some reason, then method can be used to set it globally. *

* * @param minCardinality expected dimensionality of vectors * @throws IllegalArgumentException when minCardinality is * negative */ public final void setMinCardinality(@Nonnegative int minCardinality) throws IllegalArgumentException { if (minCardinality <= 0) throw new IllegalArgumentException(MessageFormat.format( "expecting minCardinality > 0, but found {0}", minCardinality)); this.minCardinality = minCardinality; } /** * Compute the rank correlation score between the vector operands. Larger * values indicate a greater degree of similarity. Specifically the * orientation of this measure is: -1 indicating total disagreement, +1 * indicating total agreement, and ~0 indicating independence. *

* * @param A first feature vector * @param B second feature vector * @return rank correlation of the feature vectors */ @Override public double similarity( final SparseDoubleVector A, final SparseDoubleVector B) { final int N = Math.max(minCardinality, Math.max(A.cardinality, B.cardinality)); final int L = A.size; final int M = B.size; long cordance = 0; long aties = 0; long bties = 0; int intersectionSize = 0; // A double merge operations (one inside the other) the get all pairwise // combinations of non-zero elements in both vectors. This has been // implemented with more-compact but slightly slower merge method, // without trailing accumulators, to help reduce the probability of // errors. int ai = 0, bi = 0; while (ai + bi < L + M) { if (ai < L && (bi == M || A.keys[ai] < B.keys[bi])) { // A[i] = A.values[ai] // B[i] = 0 int aj = 0, bj = 0; while (aj + bj < ai + bi) { if (aj < ai && (bj == bi || A.keys[aj] < B.keys[bj])) { // A[j] = A.values[aj] // B[j] = 0 if (epsilonEquals(A.values[ai], A.values[aj], 0)) ++aties; ++aj; } else if (bj < bi && (aj == ai || B.keys[bj] < A.keys[aj])) { // A[j] = 0 // B[j] = B.values[bj] cordance += signum(A.values[ai]) * signum(-B.values[bj]); ++bj; } else if (aj < ai && bj < bi) { // A[j] = A.values[aj] // B[j] = B.values[bj] if (epsilonEquals(A.values[ai], A.values[aj], 0)) ++aties; else cordance += signum(A.values[ai] - A.values[aj]) * signum(-B.values[bj]); ++aj; ++bj; } else { throw new AssertionError(); } } ++ai; } else if (bi < M && (ai == L || B.keys[bi] < A.keys[ai])) { // A[i] = 0 // B[i] = B.values[bi] int aj = 0, bj = 0; while (aj + bj < ai + bi) { if (aj < ai && (bj == bi || A.keys[aj] < B.keys[bj])) { // A[j] = A.values[aj] // B[j] = 0 cordance += signum(-A.values[aj]) * signum(B.values[bi]); ++aj; } else if (bj < bi && (aj == ai || B.keys[bj] < A.keys[aj])) { // A[j] = 0 // B[j] = B.values[bj] if (epsilonEquals(B.values[bi], B.values[bj], 0)) ++bties; ++bj; } else if (aj < ai && bj < bi) { // A[j] = A.values[aj] // B[j] = B.values[bj] if (epsilonEquals(B.values[bi], B.values[bj], 0)) ++bties; else cordance += signum(-A.values[aj]) * signum(B.values[bi] - B.values[bj]); ++aj; ++bj; } else { throw new AssertionError(); } } ++bi; } else if (ai < L && bi < M) { // A[i] = A.values[ai] // B[i] = B.values[bi] int aj = 0, bj = 0; while (aj + bj < ai + bi) { if (aj < ai && (bj == bi || A.keys[aj] < B.keys[bj])) { // A[j] = A.values[aj] // B[j] = 0 if (epsilonEquals(A.values[ai], A.values[aj], 0)) ++aties; else cordance += signum(A.values[ai] - A.values[aj]) * signum(B.values[bi]); ++aj; } else if (bj < bi && (aj == ai || B.keys[bj] < A.keys[aj])) { // A[j] = 0 // B[j] = B.values[bj] if (epsilonEquals(B.values[bi], B.values[bj], 0)) ++bties; else cordance += signum(A.values[ai]) * signum(B.values[bi] - B.values[bj]); ++bj; } else if (aj < ai && bj < bi) { // A[j] = A.values[aj] // B[j] = B.values[bj] if (epsilonEquals(A.values[ai], A.values[aj], 0)) { ++aties; if (epsilonEquals(B.values[bi], B.values[bj], 0)) ++bties; } else if (epsilonEquals(B.values[bi], B.values[bj], 0)) { ++bties; } else { cordance += signum(A.values[ai] - A.values[aj]) * signum(B.values[bi] - B.values[bj]); } ++aj; ++bj; } else { throw new AssertionError(); } } ++intersectionSize; ++ai; ++bi; } else { throw new AssertionError(); } } final int unionSize = (L + M) - intersectionSize; // At this point the numbers can overflow rather easily so move // everything to double precision double d_cordance = cordance; double d_aties = aties; double d_bties = bties; // Features that don't occur in either vector are a similarity // between the two sets. For each feature that they both have there // should be an addition +2 to the sum. // The relationship between these and disjoint features d_cordance += ((N - unionSize) * (double) intersectionSize); // Outside of those in the union all elements are zero add all pairwise // combinations to the ties counters. d_aties += ((N - unionSize) * (double) (N - unionSize - 1)) / 2.0; d_bties += ((N - unionSize) * (double) (N - unionSize - 1)) / 2.0; // We also need to the add the cross-tries between zeros in union, and // everything else d_aties += ((unionSize - L) * (double) (N - unionSize)); d_bties += ((unionSize - M) * (double) (N - unionSize)); // Within the union minus the size of vector, all elements are zero so // add all pairwise combinations d_aties += ((unionSize - L) * (double) (unionSize - L - 1)) / 2.0; d_bties += ((unionSize - M) * (double) (unionSize - M - 1)) / 2.0; final double n0 = ((double) N * (N - 1)) / 2.0; final double denom = Math.sqrt((n0 - d_aties) * (n0 - d_bties)); // Avoid divide-by-0 errors for uniform vectors final double sim = !epsilonEquals(d_cordance, 0) ? d_cordance / denom : 0; if (LOG.isInfoEnabled()) LOG.trace(MessageFormat.format( "n0={0}, ti={1}, tj={2}, conc={3}, denom={4}, sim={5}", n0, d_aties, d_bties, d_cordance, denom, sim)); return sim; } @Override public boolean isCommutative() { return true; } @Override public double getHomogeneityBound() { return +1.0; } /** * The rank correlation score indicating approximate independence between * the vectors. Vectors generated from a uniform random distribution are * likely to have a score close to this value. *

* Considering pulling this up to the {@link Measure } interface. *

* * @return score indicating no positive or negative correlation has been * found. */ public double getIndependenceBound() { return 0.0; } @Override public double getHeterogeneityBound() { return -1.0; } @Override public Class getExpectedWeighting() { return NullWeighting.class; } @Override public String toString() { return "Kendalls-Tau{minCardinality=" + minCardinality + '}'; } public boolean equals(final KendallsTau other) { return this.minCardinality == other.minCardinality; } @Override public boolean equals(final Object obj) { if (obj == this) return true; if (obj == null || getClass() != obj.getClass()) return false; return equals((KendallsTau) obj); } @Override public int hashCode() { return 79 * 5 + this.minCardinality; } }

File
KendallsTau.java
Developer's decision
Version 1
Kind of conflict
Annotation
Attribute
Class signature
Comment
Method declaration
Method invocation
Chunk
Conflicting content
 */
@CheckReturnValue
 * Distance measure that computes similarity as the Kullback–Leibler divergence,
 * with Laplace smoothing.
 * 

<<<<<<< HEAD * ======= * >>>>>>> 5f0ba9177b34449ea27dabdc17fd0793620c7d56 * @author Hamish I A Morgan <hamish.morgan@sussex.ac.uk>

Solution content
 * Distance measure that computes similarity as the Kullback–Leibler divergence,
 * with Laplace smoothing.
 * 

* * @author Hamish I A Morgan <hamish.morgan@sussex.ac.uk> */ @CheckReturnValue

File
KullbackLeiblerDivergence.java
Developer's decision
Version 1
Kind of conflict
Comment
Chunk
Conflicting content
@CheckReturnValue
            } else if (A.keys[i] > B.keys[j]) {
public final class KullbackLeiblerDivergence implements Measure, Serializable {

<<<<<<< HEAD
    private static final long serialVersionUID = 1L;

    /**
     * Default expected minimum dimensionality of vectors ({@value}) if not
     * explicitly set.
     */
    @Nonnegative
    public static final int DEFAULT_MIN_CARDINALITY = 1;

    /**
     * Expected dimensionality of vectors.
     */
    @Nonnegative
    private int minCardinality;

    /**
     * Construct a new instance of {@link KullbackLeiblerDivergence } similarity
     * measure.
     * 

* The minCardinality field is initialized to * {@link KullbackLeiblerDivergence#DEFAULT_MIN_CARDINALITY}, which is * {@value #DEFAULT_MIN_CARDINALITY} */ public KullbackLeiblerDivergence() { this(DEFAULT_MIN_CARDINALITY); } /** * Construct new instance of {@link KullbackLeiblerDivergence } similarity * measure, initializing the expected dimensionality of vectors to * minCardinality. *

* * @param minCardinality expected dimensionality of vectors * @throws IllegalArgumentException when minCardinality is * negative */ public KullbackLeiblerDivergence(@Nonnegative final int minCardinality) throws IllegalArgumentException { setMinCardinality(minCardinality); } /** * Get the minimum (usually the actual) cardinality of vectors. *

* * @return expected dimensionality of vectors */ @Nonnegative public final int getMinCardinality() { return minCardinality; } /** * Set the minimum (usually the actual) cardinality of vectors. *

* If the vector cardinality is known before hand, but is not set on the * vectors for some reason, then method can be used to set it globally. *

* * @param minCardinality expected dimensionality of vectors * @throws IllegalArgumentException when minCardinality is * negative */ public final void setMinCardinality(@Nonnegative int minCardinality) throws IllegalArgumentException { if (minCardinality <= 0) throw new IllegalArgumentException(MessageFormat.format( "expecting minCardinality > 0, but found {0}", minCardinality)); this.minCardinality = minCardinality; } @Override public double similarity(SparseDoubleVector A, SparseDoubleVector B) { final int N = Math.max(minCardinality, Math.max(A.cardinality, B.cardinality)); final double sumA = A.sum + N; final double sumB = B.sum + N; // The smoothed likelyhoods for zero frequency features final double q0 = 1.0 / (A.sum + N); final double r0 = 1.0 / (B.sum + N); final double log_q0 = log2(q0); final double log_r0 = log2(r0); double divergence = 0.0; int i = 0; int j = 0; int intersectionSize = 0; while (i < A.size && j < B.size) { if (A.keys[i] < B.keys[j]) { final double q = (A.values[i] + 1) / sumA; divergence += q * (log2(q) - log_r0); ++i; final double r = (B.values[j] + 1) / sumB; divergence += q0 * (log_q0 - log2(r)); ++j; } else { final double q = (A.values[i] + 1) / sumA; final double r = (B.values[j] + 1) / sumB; divergence += q * (log2(q) - log2(r)); ++i; ++j; ++intersectionSize; } } while (i < A.size) { final double q = (A.values[i] + 1) / sumA; divergence += q * (log2(q) - log_r0); i++; } while (j < B.size) { final double r = (B.values[j] + 1) / sumB; divergence += q0 * (log_q0 - log2(r)); j++; } // Finally add all the divergence components for features that did not // appear in either distribution final int unionSize = A.size + B.size - intersectionSize; divergence += (N - unionSize) * q0 * (log_q0 - log_r0); return divergence; } @Override public boolean isCommutative() { return false; } @Override public double getHomogeneityBound() { return 0; } @Override public double getHeterogeneityBound() { return Double.POSITIVE_INFINITY; } @Override public Class getExpectedWeighting() { return PositiveWeighting.class; } @Override public String toString() { return "KL-Divergence"; } ======= private static final long serialVersionUID = 1L; /** * Default expected minimum dimensionality of vectors ({@value} ) if not * explicitly set. */ @Nonnegative public static final int DEFAULT_MIN_CARDINALITY = 1; /** * Expected dimensionality of vectors. */ @Nonnegative private int minCardinality; /** * Construct a new instance of {@link KullbackLeiblerDivergence } similarity * measure. *

* The minCardinality field is initialized to * {@link KullbackLeiblerDivergence#DEFAULT_MIN_CARDINALITY}, which is * {@value #DEFAULT_MIN_CARDINALITY} */ public KullbackLeiblerDivergence() { this(DEFAULT_MIN_CARDINALITY); } /** * Construct new instance of {@link KullbackLeiblerDivergence } similarity * measure, initializing the expected dimensionality of vectors to * minCardinality. *

* * @param minCardinality * expected dimensionality of vectors * @throws IllegalArgumentException * when minCardinality is negative */ public KullbackLeiblerDivergence(@Nonnegative final int minCardinality) throws IllegalArgumentException { setMinCardinality(minCardinality); } /** * Get the minimum (usually the actual) cardinality of vectors. *

* * @return expected dimensionality of vectors */ @Nonnegative public final int getMinCardinality() { return minCardinality; } /** * Set the minimum (usually the actual) cardinality of vectors. *

* If the vector cardinality is known before hand, but is not set on the * vectors for some reason, then method can be used to set it globally. *

* * @param minCardinality * expected dimensionality of vectors * @throws IllegalArgumentException * when minCardinality is negative */ public final void setMinCardinality(@Nonnegative int minCardinality) throws IllegalArgumentException { if (minCardinality <= 0) throw new IllegalArgumentException(MessageFormat.format( "expecting minCardinality > 0, but found {0}", minCardinality)); this.minCardinality = minCardinality; } @Override public double similarity(SparseDoubleVector A, SparseDoubleVector B) { final int N = Math.max(minCardinality, Math.max(A.cardinality, B.cardinality)); final double sumA = A.sum + N; final double sumB = B.sum + N; // The smoothed likelyhoods for zero frequency features final double q0 = 1.0 / (A.sum + N); final double r0 = 1.0 / (B.sum + N); final double log_q0 = log2(q0); final double log_r0 = log2(r0); double divergence = 0.0; int i = 0; int j = 0; int intersectionSize = 0; while (i < A.size && j < B.size) { if (A.keys[i] < B.keys[j]) { final double q = (A.values[i] + 1) / sumA; divergence += q * (log2(q) - log_r0); ++i; } else if (A.keys[i] > B.keys[j]) { final double r = (B.values[j] + 1) / sumB; divergence += q0 * (log_q0 - log2(r)); ++j; } else { final double q = (A.values[i] + 1) / sumA; final double r = (B.values[j] + 1) / sumB; divergence += q * (log2(q) - log2(r)); ++i; ++j; ++intersectionSize; } } while (i < A.size) { final double q = (A.values[i] + 1) / sumA; divergence += q * (log2(q) - log_r0); i++; } while (j < B.size) { final double r = (B.values[j] + 1) / sumB; divergence += q0 * (log_q0 - log2(r)); j++; } // Finally add all the divergence components for features that did not // appear in either distribution final int unionSize = A.size + B.size - intersectionSize; divergence += (N - unionSize) * q0 * (log_q0 - log_r0); return divergence; } @Override public boolean isCommutative() { return false; } @Override public double getHomogeneityBound() { return 0; } @Override public double getHeterogeneityBound() { return Double.POSITIVE_INFINITY; } @Override public Class getExpectedWeighting() { return PositiveWeighting.class; } @Override public String toString() { return "KL-Divergence"; } public boolean equals(final KullbackLeiblerDivergence other) { return this.minCardinality == other.minCardinality; } @Override public boolean equals(final Object obj) { if (obj == this) return true; if (obj == null || getClass() != obj.getClass()) return false; return equals((KullbackLeiblerDivergence) obj); } @Override public int hashCode() { return 79 * 23 + this.minCardinality; } >>>>>>> 5f0ba9177b34449ea27dabdc17fd0793620c7d56 }

Solution content
@CheckReturnValue
public final class KullbackLeiblerDivergence implements Measure, Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * Default expected minimum dimensionality of vectors ({@value}) if not
     * explicitly set.
     */
    @Nonnegative
    public static final int DEFAULT_MIN_CARDINALITY = 1;

    /**
     * Expected dimensionality of vectors.
     */
    @Nonnegative
    private int minCardinality;

    /**
     * Construct a new instance of {@link KullbackLeiblerDivergence } similarity
     * measure.
     * 

* The minCardinality field is initialized to * {@link KullbackLeiblerDivergence#DEFAULT_MIN_CARDINALITY}, which is * {@value #DEFAULT_MIN_CARDINALITY} */ public KullbackLeiblerDivergence() { this(DEFAULT_MIN_CARDINALITY); } /** * Construct new instance of {@link KullbackLeiblerDivergence } similarity * measure, initializing the expected dimensionality of vectors to * minCardinality. *

* * @param minCardinality expected dimensionality of vectors * @throws IllegalArgumentException when minCardinality is * negative */ public KullbackLeiblerDivergence(@Nonnegative final int minCardinality) throws IllegalArgumentException { setMinCardinality(minCardinality); } /** * Get the minimum (usually the actual) cardinality of vectors. *

* * @return expected dimensionality of vectors */ @Nonnegative public final int getMinCardinality() { return minCardinality; } /** * Set the minimum (usually the actual) cardinality of vectors. *

* If the vector cardinality is known before hand, but is not set on the * vectors for some reason, then method can be used to set it globally. *

* * @param minCardinality expected dimensionality of vectors * @throws IllegalArgumentException when minCardinality is * negative */ public final void setMinCardinality(@Nonnegative int minCardinality) throws IllegalArgumentException { if (minCardinality <= 0) throw new IllegalArgumentException(MessageFormat.format( "expecting minCardinality > 0, but found {0}", minCardinality)); this.minCardinality = minCardinality; } @Override public double similarity(SparseDoubleVector A, SparseDoubleVector B) { final int N = Math.max(minCardinality, Math.max(A.cardinality, B.cardinality)); final double sumA = A.sum + N; final double sumB = B.sum + N; // The smoothed likelyhoods for zero frequency features final double q0 = 1.0 / (A.sum + N); final double r0 = 1.0 / (B.sum + N); final double log_q0 = log2(q0); final double log_r0 = log2(r0); double divergence = 0.0; int i = 0; int j = 0; int intersectionSize = 0; while (i < A.size && j < B.size) { if (A.keys[i] < B.keys[j]) { final double q = (A.values[i] + 1) / sumA; divergence += q * (log2(q) - log_r0); ++i; } else if (A.keys[i] > B.keys[j]) { final double r = (B.values[j] + 1) / sumB; divergence += q0 * (log_q0 - log2(r)); ++j; } else { final double q = (A.values[i] + 1) / sumA; final double r = (B.values[j] + 1) / sumB; divergence += q * (log2(q) - log2(r)); ++i; ++j; ++intersectionSize; } } while (i < A.size) { final double q = (A.values[i] + 1) / sumA; divergence += q * (log2(q) - log_r0); i++; } while (j < B.size) { final double r = (B.values[j] + 1) / sumB; divergence += q0 * (log_q0 - log2(r)); j++; } // Finally add all the divergence components for features that did not // appear in either distribution final int unionSize = A.size + B.size - intersectionSize; divergence += (N - unionSize) * q0 * (log_q0 - log_r0); return divergence; } @Override public boolean isCommutative() { return false; } @Override public double getHomogeneityBound() { return 0; } @Override public double getHeterogeneityBound() { return Double.POSITIVE_INFINITY; } @Override public Class getExpectedWeighting() { return PositiveWeighting.class; } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; KullbackLeiblerDivergence that = (KullbackLeiblerDivergence) o; if (minCardinality != that.minCardinality) return false; return true; } @Override public int hashCode() { return minCardinality; } @Override public String toString() { return "KL-Divergence"; } }

File
KullbackLeiblerDivergence.java
Developer's decision
Manual
Kind of conflict
Annotation
Attribute
Comment
Method declaration
Chunk
Conflicting content
 * For lambda = 0 and lambda = 1 the divergence is always 0, which is
 * meaningless. Hence, lambda must be in the range 0 < lambda < 1.
 * 

<<<<<<< HEAD * ======= * >>>>>>> 5f0ba9177b34449ea27dabdc17fd0793620c7d56 * @author Hamish I A Morgan <hamish.morgan@sussex.ac.uk> */ @CheckReturnValue

Solution content
 * For lambda = 0 and lambda = 1 the divergence is always 0, which is
 * meaningless. Hence, lambda must be in the range 0 < lambda < 1.
 * 

* * @author Hamish I A Morgan <hamish.morgan@sussex.ac.uk> */ @CheckReturnValue

File
LambdaDivergence.java
Developer's decision
Version 1
Kind of conflict
Comment
Chunk
Conflicting content
        return 1.0;
    }
@CheckReturnValue
public final class LambdaDivergence implements Measure, Serializable {

<<<<<<< HEAD
    private static final long serialVersionUID = 1L;

    @Nonnegative
    public static final double DEFAULT_LAMBDA = 0.5;

    @Nonnegative
    private double lambda;

    public LambdaDivergence() {
        setLambda(DEFAULT_LAMBDA);
    }

    public LambdaDivergence(@Nonnegative double lambda) {
        setLambda(lambda);
    }

    @Nonnegative
    public final double getLambda() {
        return lambda;
    }

    public final void setLambda(@Nonnegative double lambda) {
        Checks.checkRangeExcl("lambda", lambda, 0.0, 1.0);
        this.lambda = lambda;
    }

    @Override
    public double similarity(SparseDoubleVector A, SparseDoubleVector B) {
        double divergence = 0.0;

        int i = 0;
        int j = 0;
        while (i < A.size && j < B.size) {
            if (A.keys[i] < B.keys[j]) {
                final double q = A.values[i] / A.sum;
                divergence += lambda * q * (log2(q) - log2(lambda * q));
                ++i;
            } else if (A.keys[i] > B.keys[j]) {
                final double r = B.values[j] / B.sum;
                divergence += (1.0 - lambda) * r
                        * (log2(r) - log2((1.0 - lambda) * r));
                ++j;
            } else {
                final double q = A.values[i] / A.sum;
                final double r = B.values[j] / B.sum;
                final double logAvg = log2(lambda * q + (1.0 - lambda) * r);
                divergence += lambda * q * (log2(q) - logAvg)
                        + (1.0 - lambda) * r * (log2(r) - logAvg);
                ++i;
                ++j;
            }
        }
        while (i < A.size) {
            final double q = A.values[i] / A.sum;
            divergence += lambda * q * (log2(q) - log2(lambda * q));
            i++;
        }
        while (j < B.size) {
            final double r = B.values[j] / B.sum;
            divergence += (1.0 - lambda) * r * (log2(r) - log2(
                    (1.0 - lambda) * r));
            j++;
        }


        return divergence;
    }

    @Override
    public boolean isCommutative() {
        return Measures.epsilonEquals(lambda, 0.5);
    }

    @Override
    public double getHomogeneityBound() {
        return 0;
    }

    @Override
    public double getHeterogeneityBound() {
	@Override

    @Override
    public Class getExpectedWeighting() {
        return PositiveWeighting.class;
    }

    @Override
    public String toString() {
        return "Lambda-Divergence{lambda=" + lambda + '}';
    }
=======
	private static final long serialVersionUID = 1L;

	private static final double EPSILON = 1E-10;
	@Nonnegative
	public static final double DEFAULT_LAMBDA = 0.5;

	@Nonnegative
	private double lambda;

	public LambdaDivergence() {
		setLambda(DEFAULT_LAMBDA);
	}

	public LambdaDivergence(@Nonnegative double lambda) {
		setLambda(lambda);
	}

	@Nonnegative
	public final double getLambda() {
		return lambda;
	}

	public final void setLambda(@Nonnegative double lambda) {
		Checks.checkRangeExcl("lambda", lambda, 0.0, 1.0);
		this.lambda = lambda;
	}

	@Override
	public double similarity(SparseDoubleVector A, SparseDoubleVector B) {
		double divergence = 0.0;

		int i = 0;
		int j = 0;
		while (i < A.size && j < B.size) {
			if (A.keys[i] < B.keys[j]) {
				final double q = A.values[i] / A.sum;
				divergence += lambda * q * (log2(q) - log2(lambda * q));
				++i;
			} else if (A.keys[i] > B.keys[j]) {
				final double r = B.values[j] / B.sum;
				divergence += (1.0 - lambda) * r
						* (log2(r) - log2((1.0 - lambda) * r));
				++j;
			} else {
				final double q = A.values[i] / A.sum;
				final double r = B.values[j] / B.sum;
				final double logAvg = log2(lambda * q + (1.0 - lambda) * r);
				divergence += lambda * q * (log2(q) - logAvg) + (1.0 - lambda)
						* r * (log2(r) - logAvg);
				++i;
				++j;
			}
		}
		while (i < A.size) {
			final double q = A.values[i] / A.sum;
			divergence += lambda * q * (log2(q) - log2(lambda * q));
			i++;
		}
		while (j < B.size) {
			final double r = B.values[j] / B.sum;
			divergence += (1.0 - lambda) * r
					* (log2(r) - log2((1.0 - lambda) * r));
			j++;
		}

		// The algorithm can introduce slight floating point errors so set the
		// divergence to the bound if it's very close
		if (Math.abs(divergence - getHeterogeneityBound()) < EPSILON)
			divergence = getHeterogeneityBound();
		if (Math.abs(divergence - getHomogeneityBound()) < EPSILON)
			divergence = getHomogeneityBound();

		return divergence;
	}

	public boolean isCommutative() {
		return Measures.epsilonEquals(lambda, 0.5);
	}

	@Override
	public double getHomogeneityBound() {
		return 0;
	}

	@Override
	public double getHeterogeneityBound() {
		return 1.0;
	}

	@Override
	public Class getExpectedWeighting() {
		return PositiveWeighting.class;
	}

	@Override
	public String toString() {
		return "Lambda-Divergence{lambda=" + lambda + '}';
	}

	@Override
	public int hashCode() {
		final int prime = 29;
		int result = 1;
		long temp;
		temp = Double.doubleToLongBits(lambda);
		result = prime * result + (int) (temp ^ (temp >>> 32));
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null || getClass() != obj.getClass())
			return false;
		LambdaDivergence other = (LambdaDivergence) obj;
		if (Double.doubleToLongBits(lambda) != Double
				.doubleToLongBits(other.lambda)) {
			return false;
		}
		return true;
	}

>>>>>>> 5f0ba9177b34449ea27dabdc17fd0793620c7d56
}
Solution content
@CheckReturnValue
public final class LambdaDivergence implements Measure, Serializable {

    private static final long serialVersionUID = 1L;

    private static final double EPSILON = 1E-15;

    @Nonnegative
    public static final double DEFAULT_LAMBDA = 0.5;

    @Nonnegative
    private double lambda;

    public LambdaDivergence() {
        setLambda(DEFAULT_LAMBDA);
    }

    public LambdaDivergence(@Nonnegative double lambda) {
        setLambda(lambda);
    }

    @Nonnegative
    public final double getLambda() {
        return lambda;
    }

    public final void setLambda(@Nonnegative double lambda) {
        Checks.checkRangeExcl("lambda", lambda, 0.0, 1.0);
        this.lambda = lambda;
    }

    @Override
    public double similarity(SparseDoubleVector A, SparseDoubleVector B) {
        double divergence = 0.0;

        int i = 0;
        int j = 0;
        while (i < A.size && j < B.size) {
            if (A.keys[i] < B.keys[j]) {
                final double q = A.values[i] / A.sum;
                divergence += lambda * q * (log2(q) - log2(lambda * q));
                ++i;
            } else if (A.keys[i] > B.keys[j]) {
                final double r = B.values[j] / B.sum;
                divergence += (1.0 - lambda) * r
                        * (log2(r) - log2((1.0 - lambda) * r));
                ++j;
            } else {
                final double q = A.values[i] / A.sum;
                final double r = B.values[j] / B.sum;
                final double logAvg = log2(lambda * q + (1.0 - lambda) * r);
                divergence += lambda * q * (log2(q) - logAvg)
                        + (1.0 - lambda) * r * (log2(r) - logAvg);
                ++i;
                ++j;
            }
        }
        while (i < A.size) {
            final double q = A.values[i] / A.sum;
            divergence += lambda * q * (log2(q) - log2(lambda * q));
            i++;
        }
        while (j < B.size) {
            final double r = B.values[j] / B.sum;
            divergence += (1.0 - lambda) * r * (log2(r) - log2(
                    (1.0 - lambda) * r));
            j++;
        }

        // The algorithm introduces a small amount of floating point error, which can lead to result slightly outside
        // the expected bounds. To correct for this we clamp results to the bound when they are within some small value.
        if(Math.abs(divergence - getHeterogeneityBound()) < EPSILON)
            divergence = getHeterogeneityBound();
        if(Math.abs(divergence - getHomogeneityBound()) < EPSILON)
            divergence = getHomogeneityBound();


        return divergence;
    }

    @Override
    public boolean isCommutative() {
        return Measures.epsilonEquals(lambda, 0.5);
    }

    @Override
    public double getHomogeneityBound() {
        return 0;
    }

    @Override
    public double getHeterogeneityBound() {
        return 1.0;
    }

    @Override
    public Class getExpectedWeighting() {
        return PositiveWeighting.class;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        LambdaDivergence that = (LambdaDivergence) o;

        if (Double.compare(that.lambda, lambda) != 0) return false;

        return true;
    }

    @Override
    public int hashCode() {
        long temp = lambda != +0.0d ? Double.doubleToLongBits(lambda) : 0L;
        return (int) (temp ^ (temp >>> 32));
    }

    @Override
    public String toString() {
        return "Lambda-Divergence{lambda=" + lambda + '}';
    }
}
File
LambdaDivergence.java
Developer's decision
Manual
Kind of conflict
Annotation
Attribute
Method declaration
Chunk
Conflicting content
 */
package uk.ac.susx.mlcl.byblo.measures.impl;

<<<<<<< HEAD
=======
import static uk.ac.susx.mlcl.byblo.weighings.Weightings.log2;

import java.io.Serializable;
import java.text.MessageFormat;

import javax.annotation.CheckReturnValue;
import javax.annotation.Nonnegative;

>>>>>>> 5f0ba9177b34449ea27dabdc17fd0793620c7d56
import uk.ac.susx.mlcl.byblo.measures.Measure;
import uk.ac.susx.mlcl.byblo.weighings.Weighting;
import uk.ac.susx.mlcl.byblo.weighings.impl.PositiveWeighting;
Solution content
 */
package uk.ac.susx.mlcl.byblo.measures.impl;

import uk.ac.susx.mlcl.byblo.measures.Measure;
import uk.ac.susx.mlcl.byblo.weighings.Weighting;
import uk.ac.susx.mlcl.byblo.weighings.impl.PositiveWeighting;
File
LeeSkewDivergence.java
Developer's decision
Version 1
Kind of conflict
Import
Chunk
Conflicting content
 * Statistical Language Analysis" Artificial Intelligence and Statistics 2001,
 * pp. 65--72, 2001
 * 

<<<<<<< HEAD * ======= * >>>>>>> 5f0ba9177b34449ea27dabdc17fd0793620c7d56 * @author Hamish I A Morgan <hamish.morgan@sussex.ac.uk> */ @CheckReturnValue

Solution content
 * Statistical Language Analysis" Artificial Intelligence and Statistics 2001,
 * pp. 65--72, 2001
 * 

* * @author Hamish I A Morgan <hamish.morgan@sussex.ac.uk> */ @CheckReturnValue

File
LeeSkewDivergence.java
Developer's decision
Version 1
Kind of conflict
Comment
Chunk
Conflicting content
        int i = 0;
        int j = 0;
@CheckReturnValue
public final class LeeSkewDivergence implements Measure, Serializable {

<<<<<<< HEAD
    private static final long serialVersionUID = 1L;

    @Nonnegative
    public static final double DEFAULT_ALPHA = 0.99;

    @Nonnegative
    private double alpha;

    public LeeSkewDivergence() {
        setAlpha(DEFAULT_ALPHA);
    }

    public LeeSkewDivergence(double alpha) {
        setAlpha(alpha);
    }

    @Nonnegative
    public final double getAlpha() {
        return alpha;
    }

    public final void setAlpha(@Nonnegative double alpha) {
        if(Double.isInfinite(alpha) || Double.isNaN(alpha))
            throw new IllegalArgumentException("alpha");
        Checks.checkRangeExcl("alpha", alpha, 0.0, 1.0);
        this.alpha = alpha;
    }

    @Override
    public double similarity(SparseDoubleVector A, SparseDoubleVector B) {
        double divergence = 0.0;
        while (i < A.size && j < B.size) {
            if (A.keys[i] < B.keys[j]) {
                ++i;
            } else if (A.keys[i] > B.keys[j]) {
                final double r = B.values[j] / B.sum;
                final double logAvg = log2((1 - alpha) * r);
                divergence += r * (log2(r) - logAvg);
                ++j;
            } else {
                final double q = A.values[i] / A.sum;
                final double r = B.values[j] / B.sum;
                final double logAvg = log2(alpha * q + (1 - alpha) * r);
                divergence += r * (log2(r) - logAvg);
                ++i;
                ++j;
            }
        }
        while (j < B.size) {

            final double r = B.values[j] / B.sum;
            final double logAvg = log2((1 - alpha) * r);
            divergence += r * (log2(r) - logAvg);
            j++;
        }

        return divergence;
    }

    @Override
    public boolean isCommutative() {
        return false;
    }

    @Override
    public double getHomogeneityBound() {
        return 0;
    }

    @Override
    public double getHeterogeneityBound() {
        return Double.POSITIVE_INFINITY;
    }

    @Override
    public Class getExpectedWeighting() {
        return PositiveWeighting.class;
    }

    @Override
    public String toString() {
        return MessageFormat.format("LeeSkewDivergence[alpha={0}]", alpha);
    }
=======
	private static final long serialVersionUID = 1L;

	@Nonnegative
	public static final double DEFAULT_ALPHA = 0.99;

	@Nonnegative
	private double alpha;

	public LeeSkewDivergence() {
		setAlpha(DEFAULT_ALPHA);
	}

	public LeeSkewDivergence(double alpha) {
		setAlpha(alpha);
	}

	@Nonnegative
	public final double getAlpha() {
		return alpha;
	}

	public final void setAlpha(@Nonnegative double alpha) {
		Checks.checkNotNaN("alpha", alpha);
		Checks.checkFinite("alpha", alpha);
		Checks.checkRangeExcl("alpha", alpha, 0.0, 1.0);
		this.alpha = alpha;
	}

	@Override
	public double similarity(SparseDoubleVector A, SparseDoubleVector B) {
		double divergence = 0.0;

		int i = 0;
		int j = 0;
		while (i < A.size && j < B.size) {
			if (A.keys[i] < B.keys[j]) {
				++i;
			} else if (A.keys[i] > B.keys[j]) {
				final double r = B.values[j] / B.sum;
				final double logAvg = log2((1 - alpha) * r);
				divergence += r * (log2(r) - logAvg);
				++j;
			} else {
				final double q = A.values[i] / A.sum;
				final double r = B.values[j] / B.sum;
				final double logAvg = log2(alpha * q + (1 - alpha) * r);
				divergence += r * (log2(r) - logAvg);
				++i;
				++j;
			}
		}
		while (j < B.size) {
			final double r = B.values[j] / B.sum;
			final double logAvg = log2((1 - alpha) * r);
			divergence += r * (log2(r) - logAvg);
			j++;
		}
		return divergence;
	}

	@Override
	public boolean isCommutative() {
		return false;
	}

	@Override
	public double getHomogeneityBound() {
		return 0;
	}

	@Override
	public double getHeterogeneityBound() {
		return Double.POSITIVE_INFINITY;
	}

	@Override
	public Class getExpectedWeighting() {
		return PositiveWeighting.class;
	}

	@Override
	public String toString() {
		return MessageFormat.format("LeeSkewDivergence[alpha={0}]", alpha);
	}

	@Override
	public int hashCode() {
		return 31;
	}

	@Override
	public boolean equals(Object obj) {
		return obj == this || (obj != null && getClass() == obj.getClass());
	}
>>>>>>> 5f0ba9177b34449ea27dabdc17fd0793620c7d56
}
Solution content
@CheckReturnValue
public final class LeeSkewDivergence implements Measure, Serializable {

    private static final long serialVersionUID = 1L;

    @Nonnegative
    public static final double DEFAULT_ALPHA = 0.99;

    @Nonnegative
    private double alpha;

    public LeeSkewDivergence() {
        setAlpha(DEFAULT_ALPHA);
    }

    public LeeSkewDivergence(double alpha) {
        setAlpha(alpha);
    }

    @Nonnegative
    public final double getAlpha() {
        return alpha;
    }

    public final void setAlpha(@Nonnegative double alpha) {
        if(Double.isInfinite(alpha) || Double.isNaN(alpha))
            throw new IllegalArgumentException("alpha");
        Checks.checkRangeExcl("alpha", alpha, 0.0, 1.0);
        this.alpha = alpha;
    }

    @Override
    public double similarity(SparseDoubleVector A, SparseDoubleVector B) {
        double divergence = 0.0;

        int i = 0;
        int j = 0;
        while (i < A.size && j < B.size) {
            if (A.keys[i] < B.keys[j]) {
                ++i;
            } else if (A.keys[i] > B.keys[j]) {
                final double r = B.values[j] / B.sum;
                final double logAvg = log2((1 - alpha) * r);
                divergence += r * (log2(r) - logAvg);
                ++j;
            } else {
                final double q = A.values[i] / A.sum;
                final double r = B.values[j] / B.sum;
                final double logAvg = log2(alpha * q + (1 - alpha) * r);
                divergence += r * (log2(r) - logAvg);
                ++i;
                ++j;
            }
        }
        while (j < B.size) {
            final double r = B.values[j] / B.sum;
            final double logAvg = log2((1 - alpha) * r);
            divergence += r * (log2(r) - logAvg);
            j++;
        }

        return divergence;
    }

    @Override
    public boolean isCommutative() {
        return false;
    }

    @Override
    public double getHomogeneityBound() {
        return 0;
    }

    @Override
    public double getHeterogeneityBound() {
        return Double.POSITIVE_INFINITY;
    }

    @Override
    public Class getExpectedWeighting() {
        return PositiveWeighting.class;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        LeeSkewDivergence that = (LeeSkewDivergence) o;

        if (Double.compare(that.alpha, alpha) != 0) return false;

        return true;
    }

    @Override
    public int hashCode() {
        long temp = alpha != +0.0d ? Double.doubleToLongBits(alpha) : 0L;
        return (int) (temp ^ (temp >>> 32));
    }

    @Override
    public String toString() {
        return MessageFormat.format("LeeSkewDivergence[alpha={0}]", alpha);
    }
}
File
LeeSkewDivergence.java
Developer's decision
Manual
Kind of conflict
Annotation
Attribute
Method declaration
Chunk
Conflicting content
import java.io.Serializable;

/**
<<<<<<< HEAD
=======
 * 
 * 
>>>>>>> 5f0ba9177b34449ea27dabdc17fd0793620c7d56
 * @author Hamish I A Morgan <hamish.morgan@sussex.ac.uk>
 */
@Immutable
Solution content
import java.io.Serializable;

/**
 * @author Hamish I A Morgan <hamish.morgan@sussex.ac.uk>
 */
@Immutable
File
Lin.java
Developer's decision
Version 1
Kind of conflict
Comment
Chunk
Conflicting content
import static java.lang.Math.*;

/**
<<<<<<< HEAD
=======
 * 
>>>>>>> 5f0ba9177b34449ea27dabdc17fd0793620c7d56
 * 

Notes

*

*

    Solution content
    import static java.lang.Math.*;
    
    /**
     * 

    Notes

    *

    *

      File
      LpSpaceDistance.java
      Developer's decision
      Version 1
      Kind of conflict
      Comment
      Chunk
      Conflicting content
       * vectors.
       * 

      * <<<<<<< HEAD * ======= *

      * >>>>>>> 5f0ba9177b34449ea27dabdc17fd0793620c7d56 * @author Hamish I A Morgan <hamish.morgan@sussex.ac.uk> */ @CheckReturnValue

      Solution content
       * vectors.
       * 

      * * * @author Hamish I A Morgan <hamish.morgan@sussex.ac.uk> */ @CheckReturnValue

      File
      LpSpaceDistance.java
      Developer's decision
      Version 1
      Kind of conflict
      Comment
      Chunk
      Conflicting content
      @CheckReturnValue
      public final class LpSpaceDistance implements Measure {
      
      <<<<<<< HEAD
          public static final double DEFAULT_POWER = 2;
      
          private static final long serialVersionUID = 1L;
      
          private double power = Double.NaN;
      
          private Measure delegate = null;
      
          public LpSpaceDistance() {
              setPower(DEFAULT_POWER);
          }
      
          public LpSpaceDistance(double power) {
              setPower(power);
          }
      
          public final double getPower() {
              return power;
          }
      
          public final void setPower(final double newPower) {
              if (Double.isNaN(newPower))
                  throw new IllegalArgumentException("newPower is NaN");
              if (power != newPower) {
                  power = newPower;
                  if (Measures.epsilonEquals(power, 0, 0)) {
                      delegate = new HammingDistance();
                  } else if (Measures.epsilonEquals(power, 1, 0)) {
                      delegate = new ManhattanDistance();
                  } else if (Measures.epsilonEquals(power, 2, 0)) {
                      delegate = new EuclideanDistance();
                  } else if (Measures.
                          epsilonEquals(power, Double.POSITIVE_INFINITY, 0)) {
                      delegate = new MaxSpaceDistance();
                  } else if (Measures.
                          epsilonEquals(power, Double.NEGATIVE_INFINITY, 0)) {
                      delegate = new MinSpaceDistance();
                  } else {
                      if (delegate == null || delegate.getClass() != MinkowskiDistance.class)
                          delegate = new MinkowskiDistance();
                  }
              }
          }
      
          @Override
          public double similarity(SparseDoubleVector A, SparseDoubleVector B) {
              return delegate.similarity(A, B);
          }
      
          @Override
          public double getHomogeneityBound() {
              return delegate.getHomogeneityBound();
          }
      
          @Override
          public double getHeterogeneityBound() {
              return delegate.getHeterogeneityBound();
          }
      
          @Override
          @CheckReturnValue
          public Class getExpectedWeighting() {
              return NullWeighting.class;
          }
      
          @Override
          public String toString() {
              return "Lp{" + "p=" + power + '}';
          }
      
          @Override
          public boolean isCommutative() {
              return true;
          }
      
          /**
           * Abstract super class to the various Lp Space metric implementations.
           */
          @Immutable
          @CheckReturnValue
          private static abstract class LpSpaceDelegate implements Measure {
      
              @Override
              public Class getExpectedWeighting() {
                  return NullWeighting.class;
              }
      
              @Override
              public final boolean isCommutative() {
                  return true;
              }
      
              @Override
              public final double getHomogeneityBound() {
                  return 0.0;
              }
      
              @Override
              public final double getHeterogeneityBound() {
                  return Double.POSITIVE_INFINITY;
              }
          }
      
          /**
           * Fallback implementation for arbitrary p-spaces. Not though that it will
           * not produce the correct results of p = -inf, 0, or +inf.
           */
          @CheckReturnValue
          private final class MinkowskiDistance extends LpSpaceDelegate {
      
              private static final long serialVersionUID = 1L;
      
              @Override
              public double similarity(SparseDoubleVector A, SparseDoubleVector B) {
                  double distance = 0;
      
                  int i = 0, j = 0;
                  while (i < A.size && j < B.size) {
                      if (A.keys[i] < B.keys[j]) {
                          distance += pow(A.values[i], power);
                          i++;
                      } else if (A.keys[i] > B.keys[j]) {
                          distance += pow(B.values[j], power);
                          j++;
                      } else {
                          distance += pow(abs(A.values[i] - B.values[j]), power);
                          i++;
                          j++;
                      }
      
                  }
                  while (i < A.size) {
                      distance += pow(A.values[i], power);
                      i++;
                  }
                  while (j < B.size) {
                      distance += pow(B.values[j], power);
                      j++;
                  }
      
                  return Math.pow(distance, 1.0 / power);
              }
          }
      
          /**
           * Implementation of the power-2 space; i.e standard Euclidean space that we
           * are all used to.
           */
          @Immutable
          @CheckReturnValue
          private static final class EuclideanDistance extends LpSpaceDelegate {
      
              private static final long serialVersionUID = 1L;
      
              @Override
              public double similarity(SparseDoubleVector A, SparseDoubleVector B) {
                  double distance = 0;
      
                  int i = 0, j = 0;
                  while (i < A.size && j < B.size) {
                      if (A.keys[i] < B.keys[j]) {
                          distance += A.values[i] * A.values[i];
                          i++;
                      } else if (A.keys[i] > B.keys[j]) {
                          distance += B.values[j] * B.values[j];
                          j++;
                      } else {
                          distance += (A.values[i] - B.values[j])
                                  * (A.values[i] - B.values[j]);
                          i++;
                          j++;
                      }
      
                  }
                  while (i < A.size) {
                      distance += A.values[i] * A.values[i];
                      i++;
                  }
                  while (j < B.size) {
                      distance += B.values[j] * B.values[j];
                      j++;
                  }
      
                  return Math.sqrt(distance);
              }
          }
      
          /**
           * Implementation of the power-1 space; known as Manhattan or taxicab
           * distance.
           */
          @Immutable
          @CheckReturnValue
          private static final class ManhattanDistance extends LpSpaceDelegate {
      
              private static final long serialVersionUID = 1L;
      
              @Override
              public double similarity(SparseDoubleVector A, SparseDoubleVector B) {
                  double distance = 0;
      
                  int i = 0, j = 0;
                  while (i < A.size && j < B.size) {
                      if (A.keys[i] < B.keys[j]) {
                          distance += abs(A.values[i]);
                          i++;
                      } else if (A.keys[i] > B.keys[j]) {
                          distance += abs(B.values[j]);
                          j++;
                      } else {
                          distance += abs(A.values[i] - B.values[j]);
                          i++;
                          j++;
                      }
      
                  }
                  while (i < A.size) {
                      distance += abs(A.values[i]);
                      i++;
                  }
                  while (j < B.size) {
                      distance += abs(B.values[j]);
                      j++;
                  }
      
                  return distance;
              }
          }
      
          /**
           * Implementation of power-zero L space.
           */
          @Immutable
          @CheckReturnValue
          private static final class HammingDistance extends LpSpaceDelegate {
      
              private static final long serialVersionUID = 1L;
      
              @Override
              public double similarity(SparseDoubleVector A, SparseDoubleVector B) {
                  double distance = 0;
      
                  int i = 0, j = 0;
                  while (i < A.size && j < B.size) {
                      if (A.keys[i] < B.keys[j]) {
                          distance += signum(abs(A.values[i]));
                          i++;
                      } else if (A.keys[i] > B.keys[j]) {
                          distance += signum(abs(B.values[j]));
                          j++;
                      } else {
                          distance += signum(abs(A.values[i] - B.values[j]));
                          i++;
                          j++;
                      }
      
                  }
                  while (i < A.size) {
                      distance += signum(abs(A.values[i]));
                      i++;
                  }
                  while (j < B.size) {
                      distance += signum(abs(B.values[j]));
                      j++;
                  }
      
                  return distance;
              }
          }
      
          /**
           * Implementation of power +infinity L-space metric.
           */
          @Immutable
          private static final class MaxSpaceDistance extends LpSpaceDelegate {
      
              private static final long serialVersionUID = 1L;
      
              @Override
              public double similarity(SparseDoubleVector A, SparseDoubleVector B) {
                  double distance = 0;
      
                  int i = 0, j = 0;
                  while (i < A.size && j < B.size) {
                      if (A.keys[i] < B.keys[j]) {
                          distance = max(distance, abs(A.values[i]));
                          i++;
                      } else if (A.keys[i] > B.keys[j]) {
                          distance = max(distance, abs(B.values[j]));
                          j++;
                      } else {
                          distance = max(distance, abs(A.values[i] - B.values[j]));
                          i++;
                          j++;
                      }
                  }
                  while (i < A.size) {
                      distance = max(distance, abs(A.values[i]));
                      i++;
                  }
                  while (j < B.size) {
                      distance = max(distance, abs(B.values[j]));
                      j++;
                  }
                  return distance;
              }
          }
      
          /**
           * Implementation of power -infinity L-space metric.
           */
          @Immutable
          @CheckReturnValue
          private static final class MinSpaceDistance extends LpSpaceDelegate {
      
              private static final long serialVersionUID = 1L;
      
              @Override
              public double similarity(SparseDoubleVector A, SparseDoubleVector B) {
                  double distance = 0;
      
                  int i = 0, j = 0;
                  while (i < A.size && j < B.size) {
                      if (A.keys[i] < B.keys[j]) {
                          distance = min(distance, abs(A.values[i]));
                          i++;
                      } else if (A.keys[i] > B.keys[j]) {
                          distance = min(distance, abs(B.values[j]));
                          j++;
                      } else {
                          distance = min(distance, abs(A.values[i] - B.values[j]));
                          i++;
                          j++;
                      }
                  }
                  while (i < A.size) {
                      distance = min(distance, abs(A.values[i]));
                      i++;
                  }
                  while (j < B.size) {
                      distance = min(distance, abs(B.values[j]));
                      j++;
                  }
      
                  return distance;
              }
          }
      =======
      	public static final double DEFAULT_POWER = 2;
      
      	private static final long serialVersionUID = 1L;
      
      	private double power = Double.NaN;
      
      	private Measure deligate = null;
      
      		@Override
      	public LpSpaceDistance() {
      		setPower(DEFAULT_POWER);
      	}
      
      	public LpSpaceDistance(double power) {
      		setPower(power);
      	}
      
      	public final double getPower() {
      		return power;
      	}
      
      	public final void setPower(final double newPower) {
      		if (Double.isNaN(newPower))
      			throw new IllegalArgumentException("newPower is NaN");
      		if (!Measures.epsilonEquals(power, newPower, 0)) {
      			power = newPower;
      			if (Measures.epsilonEquals(power, 0, 0)) {
      				deligate = new HammingDistance();
      			} else if (Measures.epsilonEquals(power, 1, 0)) {
      				deligate = new ManhattanDistance();
      			} else if (Measures.epsilonEquals(power, 2, 0)) {
      				deligate = new EuclideanDistance();
      			} else if (Measures.epsilonEquals(power, Double.POSITIVE_INFINITY,
      					0)) {
      				deligate = new MaxSpaceDistance();
      			} else if (Measures.epsilonEquals(power, Double.NEGATIVE_INFINITY,
      					0)) {
      				deligate = new MinSpaceDistance();
      			} else {
      				if (deligate == null
      						|| deligate.getClass() != MinkowskiDistance.class)
      					deligate = new MinkowskiDistance();
      			}
      		}
      	}
      
      	@Override
      	public double similarity(SparseDoubleVector A, SparseDoubleVector B) {
      		return deligate.similarity(A, B);
      	}
      
      	@Override
      	public double getHomogeneityBound() {
      		return deligate.getHomogeneityBound();
      	}
      
      	@Override
      	public double getHeterogeneityBound() {
      		return deligate.getHeterogeneityBound();
      	}
      
      	@Override
      	public Class getExpectedWeighting() {
      		return NullWeighting.class;
      	}
      
      	@Override
      	public String toString() {
      		return "Lp{" + "p=" + power + '}';
      	}
      
      	@Override
      	public boolean isCommutative() {
      		return true;
      	}
      
      	/**
      	 * Abstract super class to the various Lp Space metric implementations.
      	 */
      	@Immutable
      	@CheckReturnValue
      	private static abstract class LpSpaceDeligate implements Measure {
      
      		@Override
      		public Class getExpectedWeighting() {
      			return NullWeighting.class;
      		}
      
      		@Override
      		public final boolean isCommutative() {
      			return true;
      		}
      
      		@Override
      		public final double getHomogeneityBound() {
      			return 0.0;
      		}
      
      		@Override
      		public final double getHeterogeneityBound() {
      			return Double.POSITIVE_INFINITY;
      		}
      	}
      
      	/**
      	 * Fallback implementation for arbitrary p-spaces. Not though that it will
      	 * not produce the correct results of p = -inf, 0, or +inf.
      	 */
      	@CheckReturnValue
      	private final class MinkowskiDistance extends LpSpaceDeligate {
      
      		private static final long serialVersionUID = 1L;
      
      		@Override
      		public double similarity(SparseDoubleVector A, SparseDoubleVector B) {
      			double distance = 0;
      
      			int i = 0, j = 0;
      			while (i < A.size && j < B.size) {
      				if (A.keys[i] < B.keys[j]) {
      					distance += pow(A.values[i], power);
      					i++;
      				} else if (A.keys[i] > B.keys[j]) {
      					distance += pow(B.values[j], power);
      					j++;
      				} else {
      					distance += pow(abs(A.values[i] - B.values[j]), power);
      					i++;
      					j++;
      				}
      
      			}
      			while (i < A.size) {
      				distance += pow(A.values[i], power);
      				i++;
      			}
      			while (j < B.size) {
      				distance += pow(B.values[j], power);
      				j++;
      			}
      
      			return Math.pow(distance, 1.0 / power);
      		}
      	}
      
      	/**
      			while (j < B.size) {
      	 * Implementation of the power-2 space; i.e standard Euclidean space that we
      	 * are all used to.
      	 */
      	@Immutable
      	@CheckReturnValue
      	private static final class EuclideanDistance extends LpSpaceDeligate {
      
      		private static final long serialVersionUID = 1L;
      
      		@Override
      		public double similarity(SparseDoubleVector A, SparseDoubleVector B) {
      			double distance = 0;
      
      			int i = 0, j = 0;
      			while (i < A.size && j < B.size) {
      				if (A.keys[i] < B.keys[j]) {
      					distance += A.values[i] * A.values[i];
      					i++;
      				} else if (A.keys[i] > B.keys[j]) {
      					distance += B.values[j] * B.values[j];
      					j++;
      				} else {
      					distance += (A.values[i] - B.values[j])
      							* (A.values[i] - B.values[j]);
      					i++;
      					j++;
      				}
      
      			}
      			while (i < A.size) {
      				distance += A.values[i] * A.values[i];
      				i++;
      			}
      			while (j < B.size) {
      				distance += B.values[j] * B.values[j];
      				j++;
      			}
      
      			return Math.sqrt(distance);
      		}
      	}
      
      	/**
      	 * Implementation of the power-1 space; known as Manhattan or taxicab
      	 * distance.
      	 */
      	@Immutable
      	@CheckReturnValue
      	private static final class ManhattanDistance extends LpSpaceDeligate {
      
      		private static final long serialVersionUID = 1L;
      
      		@Override
      		public double similarity(SparseDoubleVector A, SparseDoubleVector B) {
      			double distance = 0;
      
      			int i = 0, j = 0;
      			while (i < A.size && j < B.size) {
      				if (A.keys[i] < B.keys[j]) {
      					distance += abs(A.values[i]);
      					i++;
      				} else if (A.keys[i] > B.keys[j]) {
      					distance += abs(B.values[j]);
      					j++;
      				} else {
      					distance += abs(A.values[i] - B.values[j]);
      					i++;
      					j++;
      				}
      
      			}
      			while (i < A.size) {
      				distance += abs(A.values[i]);
      				i++;
      			}
      			while (j < B.size) {
      				distance += abs(B.values[j]);
      				j++;
      			}
      
      			return distance;
      		}
      	}
      
      	/**
      	 * Implementation of power-zero L space.
      	 */
      	@Immutable
      	@CheckReturnValue
      	private static final class HammingDistance extends LpSpaceDeligate {
      
      		private static final long serialVersionUID = 1L;
      
      		public double similarity(SparseDoubleVector A, SparseDoubleVector B) {
      			double distance = 0;
      
      			int i = 0, j = 0;
      			while (i < A.size && j < B.size) {
      				if (A.keys[i] < B.keys[j]) {
      					distance += signum(abs(A.values[i]));
      					i++;
      				} else if (A.keys[i] > B.keys[j]) {
      					distance += signum(abs(B.values[j]));
      					j++;
      				} else {
      					distance += signum(abs(A.values[i] - B.values[j]));
      					i++;
      					j++;
      				}
      
      			}
      			while (i < A.size) {
      				distance += signum(abs(A.values[i]));
      				i++;
      			}
      				distance += signum(abs(B.values[j]));
      				j++;
      			}
      
      			return distance;
      		}
      	}
      
      	/**
      	 * Implementation of power +infinity L-space metric.
      	 */
      	@Immutable
      	@CheckReturnValue
      	private static final class MaxSpaceDistance extends LpSpaceDeligate {
      
      		private static final long serialVersionUID = 1L;
      
      		@Override
      		public double similarity(SparseDoubleVector A, SparseDoubleVector B) {
      			double distance = 0;
      
      			int i = 0, j = 0;
      			while (i < A.size && j < B.size) {
      				if (A.keys[i] < B.keys[j]) {
      					distance = max(distance, abs(A.values[i]));
      					i++;
      				} else if (A.keys[i] > B.keys[j]) {
      					distance = max(distance, abs(B.values[j]));
      					j++;
      				} else {
      					distance = max(distance, abs(A.values[i] - B.values[j]));
      					i++;
      					j++;
      				}
      			}
      			while (i < A.size) {
      				distance = max(distance, abs(A.values[i]));
      				i++;
      			}
      			while (j < B.size) {
      				distance = max(distance, abs(B.values[j]));
      				j++;
      			}
      			return distance;
      		}
      	}
      
      	/**
      	 * Implementation of power -infinity L-space metric.
      	 */
      	@Immutable
      	@CheckReturnValue
      	private static final class MinSpaceDistance extends LpSpaceDeligate {
      
      		private static final long serialVersionUID = 1L;
      
      		@Override
      		public double similarity(SparseDoubleVector A, SparseDoubleVector B) {
      			double distance = 0;
      
      			int i = 0, j = 0;
      			while (i < A.size && j < B.size) {
      				if (A.keys[i] < B.keys[j]) {
      					distance = min(distance, abs(A.values[i]));
      					i++;
      				} else if (A.keys[i] > B.keys[j]) {
      					distance = min(distance, abs(B.values[j]));
      					j++;
      				} else {
      					distance = min(distance, abs(A.values[i] - B.values[j]));
      					i++;
      					j++;
      				}
      			}
      			while (i < A.size) {
      				distance = min(distance, abs(A.values[i]));
      				i++;
      			}
      			while (j < B.size) {
      				distance = min(distance, abs(B.values[j]));
      				j++;
      			}
      
      			return distance;
      		}
      	}
      
      	@Override
      	public int hashCode() {
      		return 39;
      	}
      
      	@Override
      	public boolean equals(Object obj) {
      		return obj == this || (obj != null && getClass() == obj.getClass());
      	}
      >>>>>>> 5f0ba9177b34449ea27dabdc17fd0793620c7d56
      }
      Solution content
      @CheckReturnValue
      public final class LpSpaceDistance implements Measure {
      
          public static final double DEFAULT_POWER = 2;
      
          private static final long serialVersionUID = 1L;
      
          private double power = Double.NaN;
      
          private Measure delegate = null;
      
          public LpSpaceDistance() {
              setPower(DEFAULT_POWER);
          }
      
          public LpSpaceDistance(double power) {
              setPower(power);
          }
      
          public final double getPower() {
              return power;
          }
      
          public final void setPower(final double newPower) {
              if (Double.isNaN(newPower))
                  throw new IllegalArgumentException("newPower is NaN");
              if (power != newPower) {
                  power = newPower;
                  if (Measures.epsilonEquals(power, 0, 0)) {
                      delegate = new HammingDistance();
                  } else if (Measures.epsilonEquals(power, 1, 0)) {
                      delegate = new ManhattanDistance();
                  } else if (Measures.epsilonEquals(power, 2, 0)) {
                      delegate = new EuclideanDistance();
                  } else if (Measures.
                          epsilonEquals(power, Double.POSITIVE_INFINITY, 0)) {
                      delegate = new MaxSpaceDistance();
                  } else if (Measures.
                          epsilonEquals(power, Double.NEGATIVE_INFINITY, 0)) {
                      delegate = new MinSpaceDistance();
                  } else {
                      if (delegate == null || delegate.getClass() != MinkowskiDistance.class)
                          delegate = new MinkowskiDistance();
                  }
              }
          }
      
          @Override
          public double similarity(SparseDoubleVector A, SparseDoubleVector B) {
              return delegate.similarity(A, B);
          }
      
          @Override
          public double getHomogeneityBound() {
              return delegate.getHomogeneityBound();
          }
      
          @Override
          public double getHeterogeneityBound() {
              return delegate.getHeterogeneityBound();
          }
      
          @Override
          public Class getExpectedWeighting() {
              return NullWeighting.class;
          }
      
          @Override
          public boolean equals(Object o) {
              if (this == o) return true;
              if (o == null || getClass() != o.getClass()) return false;
      
              LpSpaceDistance that = (LpSpaceDistance) o;
      
              if (Double.compare(that.power, power) != 0) return false;
              if (delegate != null ? !delegate.equals(that.delegate) : that.delegate != null) return false;
      
              return true;
          }
      
          @Override
          public int hashCode() {
              int result;
              long temp;
              temp = power != +0.0d ? Double.doubleToLongBits(power) : 0L;
              result = (int) (temp ^ (temp >>> 32));
              result = 31 * result + (delegate != null ? delegate.hashCode() : 0);
              return result;
          }
      
          @Override
          public String toString() {
              return "Lp{" + "p=" + power + '}';
          }
      
          @Override
          public boolean isCommutative() {
              return true;
          }
      
          /**
           * Abstract super class to the various Lp Space metric implementations.
           */
          @Immutable
          @CheckReturnValue
          private static abstract class LpSpaceDelegate implements Measure {
      
              @Override
              public Class getExpectedWeighting() {
                  return NullWeighting.class;
              }
      
              @Override
              public final boolean isCommutative() {
                  return true;
              }
      
              @Override
              public final double getHomogeneityBound() {
                  return 0.0;
              }
      
              @Override
              public final double getHeterogeneityBound() {
                  return Double.POSITIVE_INFINITY;
              }
          }
      
          /**
           * Fallback implementation for arbitrary p-spaces. Not though that it will
           * not produce the correct results of p = -inf, 0, or +inf.
           */
          @CheckReturnValue
          private final class MinkowskiDistance extends LpSpaceDelegate {
      
              private static final long serialVersionUID = 1L;
      
              @Override
              public double similarity(SparseDoubleVector A, SparseDoubleVector B) {
                  double distance = 0;
      
                  int i = 0, j = 0;
                  while (i < A.size && j < B.size) {
                      if (A.keys[i] < B.keys[j]) {
                          distance += pow(A.values[i], power);
                          i++;
                      } else if (A.keys[i] > B.keys[j]) {
                          distance += pow(B.values[j], power);
                          j++;
                      } else {
                          distance += pow(abs(A.values[i] - B.values[j]), power);
                          i++;
                          j++;
                      }
      
                  }
                  while (i < A.size) {
                      distance += pow(A.values[i], power);
                      i++;
                  }
                  while (j < B.size) {
                      distance += pow(B.values[j], power);
                      j++;
                  }
      
                  return Math.pow(distance, 1.0 / power);
              }
          }
      
          /**
           * Implementation of the power-2 space; i.e standard Euclidean space that we
           * are all used to.
           */
          @Immutable
          @CheckReturnValue
          private static final class EuclideanDistance extends LpSpaceDelegate {
      
              private static final long serialVersionUID = 1L;
      
              @Override
              public double similarity(SparseDoubleVector A, SparseDoubleVector B) {
                  double distance = 0;
      
                  int i = 0, j = 0;
                  while (i < A.size && j < B.size) {
                      if (A.keys[i] < B.keys[j]) {
                          distance += A.values[i] * A.values[i];
                          i++;
                      } else if (A.keys[i] > B.keys[j]) {
                          distance += B.values[j] * B.values[j];
                          j++;
                      } else {
                          distance += (A.values[i] - B.values[j])
                                  * (A.values[i] - B.values[j]);
                          i++;
                          j++;
                      }
      
                  }
                  while (i < A.size) {
                      distance += A.values[i] * A.values[i];
                      i++;
                  }
                  while (j < B.size) {
                      distance += B.values[j] * B.values[j];
                      j++;
                  }
      
                  return Math.sqrt(distance);
              }
          }
      
          /**
           * Implementation of the power-1 space; known as Manhattan or taxicab
           * distance.
           */
          @Immutable
          @CheckReturnValue
          private static final class ManhattanDistance extends LpSpaceDelegate {
      
              private static final long serialVersionUID = 1L;
      
              @Override
              public double similarity(SparseDoubleVector A, SparseDoubleVector B) {
                  double distance = 0;
      
                  int i = 0, j = 0;
                  while (i < A.size && j < B.size) {
                      if (A.keys[i] < B.keys[j]) {
                          distance += abs(A.values[i]);
                          i++;
                      } else if (A.keys[i] > B.keys[j]) {
                          distance += abs(B.values[j]);
                          j++;
                      } else {
                          distance += abs(A.values[i] - B.values[j]);
                          i++;
                          j++;
                      }
      
                  }
                  while (i < A.size) {
                      distance += abs(A.values[i]);
                      i++;
                  }
                  while (j < B.size) {
                      distance += abs(B.values[j]);
                      j++;
                  }
      
                  return distance;
              }
          }
      
          /**
           * Implementation of power-zero L space.
           */
          @Immutable
          @CheckReturnValue
          private static final class HammingDistance extends LpSpaceDelegate {
      
              private static final long serialVersionUID = 1L;
      
              @Override
              public double similarity(SparseDoubleVector A, SparseDoubleVector B) {
                  double distance = 0;
      
                  int i = 0, j = 0;
                  while (i < A.size && j < B.size) {
                      if (A.keys[i] < B.keys[j]) {
                          distance += signum(abs(A.values[i]));
                          i++;
                      } else if (A.keys[i] > B.keys[j]) {
                          distance += signum(abs(B.values[j]));
                          j++;
                      } else {
                          distance += signum(abs(A.values[i] - B.values[j]));
                          i++;
                          j++;
                      }
      
                  }
                  while (i < A.size) {
                      distance += signum(abs(A.values[i]));
                      i++;
                  }
                  while (j < B.size) {
                      distance += signum(abs(B.values[j]));
                      j++;
                  }
      
                  return distance;
              }
          }
      
          /**
           * Implementation of power +infinity L-space metric.
           */
          @Immutable
          @CheckReturnValue
          private static final class MaxSpaceDistance extends LpSpaceDelegate {
      
              private static final long serialVersionUID = 1L;
      
              @Override
              public double similarity(SparseDoubleVector A, SparseDoubleVector B) {
                  double distance = 0;
      
                  int i = 0, j = 0;
                  while (i < A.size && j < B.size) {
                      if (A.keys[i] < B.keys[j]) {
                          distance = max(distance, abs(A.values[i]));
                          i++;
                      } else if (A.keys[i] > B.keys[j]) {
                          distance = max(distance, abs(B.values[j]));
                          j++;
                      } else {
                          distance = max(distance, abs(A.values[i] - B.values[j]));
                          i++;
                          j++;
                      }
                  }
                  while (i < A.size) {
                      distance = max(distance, abs(A.values[i]));
                      i++;
                  }
                  while (j < B.size) {
                      distance = max(distance, abs(B.values[j]));
                      j++;
                  }
                  return distance;
              }
          }
      
          /**
           * Implementation of power -infinity L-space metric.
           */
          @Immutable
          @CheckReturnValue
          private static final class MinSpaceDistance extends LpSpaceDelegate {
      
              private static final long serialVersionUID = 1L;
      
              @Override
              public double similarity(SparseDoubleVector A, SparseDoubleVector B) {
                  double distance = 0;
      
                  int i = 0, j = 0;
                  while (i < A.size && j < B.size) {
                      if (A.keys[i] < B.keys[j]) {
                          distance = min(distance, abs(A.values[i]));
                          i++;
                      } else if (A.keys[i] > B.keys[j]) {
                          distance = min(distance, abs(B.values[j]));
                          j++;
                      } else {
                          distance = min(distance, abs(A.values[i] - B.values[j]));
                          i++;
                          j++;
                      }
                  }
                  while (i < A.size) {
                      distance = min(distance, abs(A.values[i]));
                      i++;
                  }
                  while (j < B.size) {
                      distance = min(distance, abs(B.values[j]));
                      j++;
                  }
      
                  return distance;
              }
          }
      }
      File
      LpSpaceDistance.java
      Developer's decision
      Manual
      Kind of conflict
      Annotation
      Attribute
      Class declaration
      Comment
      Method declaration
      Chunk
      Conflicting content
      import java.io.Serializable;
      
      /**
      <<<<<<< HEAD
      =======
       * 
      >>>>>>> 5f0ba9177b34449ea27dabdc17fd0793620c7d56
       * @author Hamish I A Morgan <hamish.morgan@sussex.ac.uk>
       */
      @Immutable
      Solution content
      import java.io.Serializable;
      
      /**
       * @author Hamish I A Morgan <hamish.morgan@sussex.ac.uk>
       */
      @Immutable
      File
      Overlap.java
      Developer's decision
      Version 1
      Kind of conflict
      Comment
      Chunk
      Conflicting content
      import javax.annotation.CheckReturnValue;
      import javax.annotation.concurrent.Immutable;
      <<<<<<< HEAD
      =======
      
      import uk.ac.susx.mlcl.lib.collect.SparseDoubleVector;
      >>>>>>> 5f0ba9177b34449ea27dabdc17fd0793620c7d56
      
      /**
       * This measure attempts to encapsulate, for each pair of feature vectors A and
      Solution content
      import javax.annotation.CheckReturnValue;
      import javax.annotation.concurrent.Immutable;
      
      /**
       * This measure attempts to encapsulate, for each pair of feature vectors A and
      File
      Precision.java
      Developer's decision
      Version 1
      Kind of conflict
      Import
      Chunk
      Conflicting content
       * Note that recall(x,y) = precision(y,x) so the precision can be calculated by
       * wrapping an instance of RecallMi in the ReversedProximity decorator.
       * 

      <<<<<<< HEAD * ======= * >>>>>>> 5f0ba9177b34449ea27dabdc17fd0793620c7d56 * @author Hamish I A Morgan <hamish.morgan@sussex.ac.uk> */ @Immutable

      Solution content
       * Note that recall(x,y) = precision(y,x) so the precision can be calculated by
       * wrapping an instance of RecallMi in the ReversedProximity decorator.
       * 

      * * @author Hamish I A Morgan <hamish.morgan@sussex.ac.uk> */ @Immutable

      File
      Precision.java
      Developer's decision
      Version 1
      Kind of conflict
      Comment
      Chunk
      Conflicting content
       */
      package uk.ac.susx.mlcl.byblo.measures.impl;
      
      <<<<<<< HEAD
      =======
      import java.io.Serializable;
      
      import javax.annotation.CheckReturnValue;
      import javax.annotation.concurrent.Immutable;
      
      >>>>>>> 5f0ba9177b34449ea27dabdc17fd0793620c7d56
      import uk.ac.susx.mlcl.byblo.measures.DecomposableMeasure;
      import uk.ac.susx.mlcl.byblo.weighings.Weighting;
      import uk.ac.susx.mlcl.byblo.weighings.impl.PositiveWeighting;
      Solution content
       */
      package uk.ac.susx.mlcl.byblo.measures.impl;
      
      import uk.ac.susx.mlcl.byblo.measures.DecomposableMeasure;
      import uk.ac.susx.mlcl.byblo.weighings.Weighting;
      import uk.ac.susx.mlcl.byblo.weighings.impl.PositiveWeighting;
      File
      Recall.java
      Developer's decision
      Version 1
      Kind of conflict
      Import
      Chunk
      Conflicting content
       * Note that recall(x,y) = precision(y,x) so the precision can be calculated by
       * wrapping an instance of RecallMi in the ReversedProximity decorator.
       * 

      <<<<<<< HEAD * ======= * >>>>>>> 5f0ba9177b34449ea27dabdc17fd0793620c7d56 * @author Hamish I A Morgan <hamish.morgan@sussex.ac.uk> */ @Immutable

      Solution content
       * Note that recall(x,y) = precision(y,x) so the precision can be calculated by
       * wrapping an instance of RecallMi in the ReversedProximity decorator.
       * 

      * * @author Hamish I A Morgan <hamish.morgan@sussex.ac.uk> */ @Immutable

      File
      Recall.java
      Developer's decision
      Version 1
      Kind of conflict
      Comment
      Chunk
      Conflicting content
      import java.io.Serializable;
      
      /**
      <<<<<<< HEAD
      =======
       * 
      >>>>>>> 5f0ba9177b34449ea27dabdc17fd0793620c7d56
       * Parameters
       * 

      * β γ Special Case

      Solution content
      import java.io.Serializable;
      
      /**
       * Parameters
       * 

      * β γ Special Case

      File
      Weeds.java
      Developer's decision
      Version 1
      Kind of conflict
      Comment
      Chunk
      Conflicting content
       * arithmetic mean of precision and recall 1 0 precision 0 0 recall 0.5 0
       * unweighted arithmetic mean
       * 

      <<<<<<< HEAD *

      • Weeds, Julie, and David Weir. (December 2005) Co-occurrence * Retrieval: A Flexible Framework for Lexical Distributional Similarity. * Computational Linguistics 31, no. 4: 439-475.
      * ======= *
        *
      • Weeds, Julie, and David Weir. (December 2005) Co-occurrence Retrieval: A * Flexible Framework for Lexical Distributional Similarity. Computational * Linguistics 31, no. 4: 439-475.
      • *
      *

      * >>>>>>> 5f0ba9177b34449ea27dabdc17fd0793620c7d56 * @author Hamish I A Morgan <hamish.morgan@sussex.ac.uk> */ @CheckReturnValue

      Solution content
       * arithmetic mean of precision and recall 1 0 precision 0 0 recall 0.5 0
       * unweighted arithmetic mean
       * 

      *

      • Weeds, Julie, and David Weir. (December 2005) Co-occurrence * Retrieval: A Flexible Framework for Lexical Distributional Similarity. * Computational Linguistics 31, no. 4: 439-475.
      * * @author Hamish I A Morgan <hamish.morgan@sussex.ac.uk> */ @CheckReturnValue
      File
      Weeds.java
      Developer's decision
      Version 1
      Kind of conflict
      Comment
      Chunk
      Conflicting content
      
      	private static final Precision PRECISION = new Precision();
      
      <<<<<<< HEAD
          @Nonnegative
          public static final double DEFAULT_BETA = 0.5;
      
          @Nonnegative
          public static final double DEFAULT_GAMMA = 0.5;
      
          @Nonnegative
          private double beta;
      
          @Nonnegative
          private double gamma;
      
          public Weeds() {
              this(DEFAULT_BETA, DEFAULT_GAMMA);
          }
          public Weeds(@Nonnegative final double beta, @Nonnegative final double gamma) {
              setBeta(beta);
              setGamma(gamma);
          }
      
          public final void setBeta(@Nonnegative final double beta) {
              if (beta < 0.0 || beta > 1.0)
                  throw new IllegalArgumentException(
                          "beta parameter expected in range 0 to 1, but found " + beta);
              this.beta = beta;
          }
      
          public final void setGamma(@Nonnegative final double gamma) {
              if (gamma < 0 || gamma > 1)
                  throw new IllegalArgumentException(
                          "beta parameter expected in range 0 to 1, but found " + gamma);
              this.gamma = gamma;
          }
      
          @Nonnegative
          public final double getBeta() {
              return beta;
          }
      
          @Nonnegative
          public final double getGamma() {
              return gamma;
          }
      
          @Override
          public double similarity(SparseDoubleVector A, SparseDoubleVector B) {
              assert beta >= 0 && beta <= 1;
              assert gamma >= 0 && gamma <= 1;
      
              final double recall = RECALL.similarity(A, B);
              final double precision = PRECISION.similarity(A, B);
      
              // arithmetic mean
              final double am = (beta * precision) + ((1 - beta) * recall);
      
              // harmonic mean (aka F1 score)
              final double hm = (precision + recall) != 0
                      ? (2 * precision * recall) / (precision + recall)
                      : 0;
      
              final double sim = gamma * hm + (1.0 - gamma) * am;
      
              assert sim >= 0.0 && sim <= 1.0;
              return sim;
      
          }
      
          @Override
          public boolean isCommutative() {
              // If gamma = 1.0 then only then harmonic component is used, hense the 
              // measure is symetric. Otherwise some portion of the arithimentic 
              // component is used which is symetric only when beta = 0.5.
              return Measures.epsilonEquals(gamma, 1.0)
                      || Measures.epsilonEquals(beta, 0.5);
          }
      
          @Override
          public double getHomogeneityBound() {
              return 1.0;
          }
      
          @Override
          public double getHeterogeneityBound() {
              return 0.0;
          }
      
          @Override
          public Class getExpectedWeighting() {
              return PositivePMI.class;
          }
      
          @Override
          public String toString() {
              return "Weeds{" + "beta=" + beta + ", gamma=" + gamma + '}';
          }
      
          @Override
          public boolean equals(Object obj) {
              if (obj == null)
                  return false;
              if (getClass() != obj.getClass())
                  return false;
              final Weeds other = (Weeds) obj;
              if (Double.doubleToLongBits(this.beta) != Double.doubleToLongBits(
                      other.beta))
                  return false;
              if (Double.doubleToLongBits(this.gamma) != Double.doubleToLongBits(
                      other.gamma))
                  return false;
              return true;
          }
      
          @Override
          public int hashCode() {
              int hash = 5;
              final long betaBits = Double.doubleToLongBits(this.beta);
              final long gammaBits = Double.doubleToLongBits(this.gamma);
              hash = 37 * hash + (int) (betaBits ^ (betaBits >>> 32));
              hash = 37 * hash + (int) (gammaBits ^ (gammaBits >>> 32));
              return hash;
          }
      =======
      	@Nonnegative
      	public static final double DEFAULT_BETA = 0.5;
      
      	@Nonnegative
      	public static final double DEFAULT_GAMMA = 0.5;
      
      	@Nonnegative
      	private double beta;
      
      	@Nonnegative
      	private double gamma;
      
      	public Weeds() {
      		this(DEFAULT_BETA, DEFAULT_GAMMA);
      	}
      
      	public Weeds(@Nonnegative final double beta, @Nonnegative final double gamma) {
      		setBeta(beta);
      		setGamma(gamma);
      	}
      
      	public final void setBeta(@Nonnegative final double beta) {
      		if (beta < 0.0 || beta > 1.0)
      			throw new IllegalArgumentException(
      					"beta parameter expected in range 0 to 1, but found "
      							+ beta);
      		this.beta = beta;
      	}
      
      	public final void setGamma(@Nonnegative final double gamma) {
      		if (gamma < 0 || gamma > 1)
      			throw new IllegalArgumentException(
      					"beta parameter expected in range 0 to 1, but found "
      							+ gamma);
      		this.gamma = gamma;
      	}
      
      	@Nonnegative
      	public final double getBeta() {
      		return beta;
      	}
      
      	@Nonnegative
      	public final double getGamma() {
      		return gamma;
      	}
      
      	@Override
      	public double similarity(SparseDoubleVector A, SparseDoubleVector B) {
      		assert beta >= 0 && beta <= 1;
      		assert gamma >= 0 && gamma <= 1;
      
      		final double recall = RECALL.similarity(A, B);
      		final double precision = PRECISION.similarity(A, B);
      
      		// arithmetic mean
      		final double am = (beta * precision) + ((1 - beta) * recall);
      
      		// harmonic mean (aka F1 score)
      		final double hm = (precision + recall) != 0 ? (2 * precision * recall)
      				/ (precision + recall) : 0;
      
      		final double sim = gamma * hm + (1.0 - gamma) * am;
      
      		assert sim >= 0.0 && sim <= 1.0;
      		return sim;
      
      	}
      
      	@Override
      	public boolean isCommutative() {
      		// If gamma = 1.0 then only then harmonic component is used, hense the
      		// measure is symetric. Otherwise some portion of the arithimentic
      		// component is used which is symetric only when beta = 0.5.
      		return Measures.epsilonEquals(gamma, 1.0)
      				|| Measures.epsilonEquals(beta, 0.5);
      	}
      
      	@Override
      	public double getHomogeneityBound() {
      		return 1.0;
      	}
      
      	@Override
      	public double getHeterogeneityBound() {
      		return 0.0;
      	}
      
      	@Override
      	public Class getExpectedWeighting() {
      		return PositivePMI.class;
      	}
      
      	@Override
      	public String toString() {
      		return "Weeds{" + "beta=" + beta + ", gamma=" + gamma + '}';
      	}
      
      	@Override
      	public boolean equals(Object obj) {
      		if (obj == null)
      			return false;
      		if (getClass() != obj.getClass())
      			return false;
      		final Weeds other = (Weeds) obj;
      		if (Double.doubleToLongBits(this.beta) != Double
      				.doubleToLongBits(other.beta))
      			return false;
      		if (Double.doubleToLongBits(this.gamma) != Double
      				.doubleToLongBits(other.gamma))
      			return false;
      		return true;
      	}
      
      	@Override
      	public int hashCode() {
      		int hash = 49;
      		final long betaBits = Double.doubleToLongBits(this.beta);
      		final long gammaBits = Double.doubleToLongBits(this.gamma);
      		hash = 37 * hash + (int) (betaBits ^ (betaBits >>> 32));
      		hash = 37 * hash + (int) (gammaBits ^ (gammaBits >>> 32));
      		return hash;
      	}
      >>>>>>> 5f0ba9177b34449ea27dabdc17fd0793620c7d56
      }
      Solution content
          private static final Precision PRECISION = new Precision();
      
          @Nonnegative
          public static final double DEFAULT_BETA = 0.5;
      
          @Nonnegative
          public static final double DEFAULT_GAMMA = 0.5;
      
          @Nonnegative
          private double beta;
      
          @Nonnegative
          private double gamma;
      
          public Weeds() {
              this(DEFAULT_BETA, DEFAULT_GAMMA);
          }
      
          public Weeds(@Nonnegative final double beta, @Nonnegative final double gamma) {
              setBeta(beta);
              setGamma(gamma);
          }
      
          public final void setBeta(@Nonnegative final double beta) {
              if (beta < 0.0 || beta > 1.0)
                  throw new IllegalArgumentException(
                          "beta parameter expected in range 0 to 1, but found " + beta);
              this.beta = beta;
          }
      
          public final void setGamma(@Nonnegative final double gamma) {
              if (gamma < 0 || gamma > 1)
                  throw new IllegalArgumentException(
                          "beta parameter expected in range 0 to 1, but found " + gamma);
              this.gamma = gamma;
          }
      
          @Nonnegative
          public final double getBeta() {
              return beta;
          }
      
          @Nonnegative
          public final double getGamma() {
              return gamma;
          }
      
          @Override
          public double similarity(SparseDoubleVector A, SparseDoubleVector B) {
              assert beta >= 0 && beta <= 1;
              assert gamma >= 0 && gamma <= 1;
      
              final double recall = RECALL.similarity(A, B);
              final double precision = PRECISION.similarity(A, B);
      
              // arithmetic mean
              final double am = (beta * precision) + ((1 - beta) * recall);
      
              // harmonic mean (aka F1 score)
              final double hm = (precision + recall) != 0
                      ? (2 * precision * recall) / (precision + recall)
                      : 0;
      
              final double sim = gamma * hm + (1.0 - gamma) * am;
      
              assert sim >= 0.0 && sim <= 1.0;
              return sim;
      
          }
      
          @Override
          public boolean isCommutative() {
              // If gamma = 1.0 then only then harmonic component is used, hense the 
              // measure is symetric. Otherwise some portion of the arithimentic 
              // component is used which is symetric only when beta = 0.5.
              return Measures.epsilonEquals(gamma, 1.0)
                      || Measures.epsilonEquals(beta, 0.5);
          }
      
          @Override
          public double getHomogeneityBound() {
              return 1.0;
          }
      
          @Override
          public double getHeterogeneityBound() {
              return 0.0;
          }
      
          @Override
          public Class getExpectedWeighting() {
              return PositivePMI.class;
          }
      
          @Override
          public String toString() {
              return "Weeds{" + "beta=" + beta + ", gamma=" + gamma + '}';
          }
      
          @Override
          public boolean equals(Object obj) {
              if (obj == null)
                  return false;
              if (getClass() != obj.getClass())
                  return false;
              final Weeds other = (Weeds) obj;
              if (Double.doubleToLongBits(this.beta) != Double.doubleToLongBits(
                      other.beta))
                  return false;
              if (Double.doubleToLongBits(this.gamma) != Double.doubleToLongBits(
                      other.gamma))
                  return false;
              return true;
          }
      
          @Override
          public int hashCode() {
              int hash = 5;
              final long betaBits = Double.doubleToLongBits(this.beta);
              final long gammaBits = Double.doubleToLongBits(this.gamma);
              hash = 37 * hash + (int) (betaBits ^ (betaBits >>> 32));
              hash = 37 * hash + (int) (gammaBits ^ (gammaBits >>> 32));
              return hash;
          }
      }
      File
      Weeds.java
      Developer's decision
      Version 1
      Kind of conflict
      Annotation
      Attribute
      Method declaration
      Chunk
      Conflicting content
          @Override
          public String toString() {
      <<<<<<< HEAD
              return MessageFormat.format("Bound{{1},{2}}",
                      getLowerBound(), getUpperBound());
      =======
              return MessageFormat.format("Bound[{1},{2}]",
                                          getLowerBound(), getUpperBound());
      >>>>>>> 5f0ba9177b34449ea27dabdc17fd0793620c7d56
          }
      
          private boolean equals(Bound that) {
      Solution content
          @Override
          public String toString() {
              return MessageFormat.format("Bound[{1},{2}]",
                      getLowerBound(), getUpperBound());
          }
      
          private boolean equals(Bound that) {
      File
      Bound.java
      Developer's decision
      Version 2
      Kind of conflict
      Method invocation
      Return statement
      Chunk
      Conflicting content
      import static org.junit.Assert.*;
      
      /**
      <<<<<<< HEAD
      =======
       * 
      >>>>>>> 5f0ba9177b34449ea27dabdc17fd0793620c7d56
       * @author Hamish I A Morgan <hamish.morgan@sussex.ac.uk>
       */
      public class TestConstants {
      Solution content
      import static org.junit.Assert.*;
      
      /**
       * @author Hamish I A Morgan <hamish.morgan@sussex.ac.uk>
       */
      public class TestConstants {
      File
      TestConstants.java
      Developer's decision
      Version 1
      Kind of conflict
      Comment
      Chunk
      Conflicting content
       */
      public class TestConstants {
      
      <<<<<<< HEAD
          public static List> loadFruitVectors() throws IOException {
              final DoubleEnumerating indexDelegate = new DoubleEnumeratingDelegate();
              final FastWeightedTokenPairVectorSource eventSrc =
                      BybloIO.openEventsVectorSource(TEST_FRUIT_EVENTS,
                              DEFAULT_CHARSET, indexDelegate);
              final List> vecs =
                      new ArrayList>();
              while (eventSrc.hasNext())
                  vecs.add(eventSrc.read());
              eventSrc.close();
              return vecs;
          }
      
          private TestConstants() {
          }
      
          public static final File TEST_DATA_DIR = new File(
                  "src/test/resources/uk/ac/susx/mlcl/byblo");
      
          public static final File TEST_FRUIT_DIR = TEST_DATA_DIR;
      
          public static final String FRUIT_NAME = "bnc-gramrels-fruit";
      
          public static final File TEST_FRUIT_INPUT =
                  new File(TEST_FRUIT_DIR, FRUIT_NAME);
      
          public static final File TEST_FRUIT_INPUT_INDEXED =
                  new File(TEST_FRUIT_DIR, FRUIT_NAME + ".indexed");
      
          public static final File TEST_FRUIT_ENTRY_INDEX =
                  new File(TEST_FRUIT_DIR, FRUIT_NAME + ".entry-index");
      =======
      	public static List> loadIndexedFruitVectors()
      			throws IOException {
      		final DoubleEnumerating indexDeligate = new DoubleEnumeratingDeligate();
      		final FastWeightedTokenPairVectorSource eventSrc = BybloIO
      				.openEventsVectorSource(TEST_FRUIT_EVENTS, DEFAULT_CHARSET,
      						indexDeligate);
      		final List> vecs = new ArrayList>();
      		int maxCard = 0;
      		while (eventSrc.hasNext()) {
      			Indexed x = eventSrc.read();
      			maxCard = Math.max(maxCard, x.value().cardinality);
      			vecs.add(x);
      		}
      		eventSrc.close();
      		for (Indexed x : vecs) {
      			x.value().cardinality = maxCard;
      		}
      		
      		
      		return vecs;
      	}
      >>>>>>> 5f0ba9177b34449ea27dabdc17fd0793620c7d56
      
      	public static List loadFruitVectors()
      			throws IOException {
      Solution content
       */
      public class TestConstants {
      
          public static List> loadIndexedFruitVectors()
                  throws IOException {
              final DoubleEnumerating indexDelegate = new DoubleEnumeratingDelegate();
              final FastWeightedTokenPairVectorSource eventSrc = BybloIO
                      .openEventsVectorSource(TEST_FRUIT_EVENTS, DEFAULT_CHARSET,
                              indexDelegate);
              final List> vecs = new ArrayList>();
              int maxCard = 0;
              while (eventSrc.hasNext()) {
                  Indexed x = eventSrc.read();
                  maxCard = Math.max(maxCard, x.value().cardinality);
                  vecs.add(x);
              }
              eventSrc.close();
              for (Indexed x : vecs) {
                  x.value().cardinality = maxCard;
              }
      
      
              return vecs;
          }
      
          public static List loadFruitVectors()
                  throws IOException {
              List> iv = loadIndexedFruitVectors();
              List v = new ArrayList(
                      iv.size());
              for (Indexed x : iv)
                  v.add(x.value());
              return v;
          }
      
          private TestConstants() {
          }
      
          public static final File TEST_DATA_DIR = new File(
                  "src/test/resources/uk/ac/susx/mlcl/byblo");
      
          public static final File TEST_FRUIT_DIR = TEST_DATA_DIR;
      
          public static final String FRUIT_NAME = "bnc-gramrels-fruit";
      
          public static final File TEST_FRUIT_INPUT = new File(TEST_FRUIT_DIR,
                  FRUIT_NAME);
      
          public static final File TEST_FRUIT_INPUT_INDEXED = new File(
                  TEST_FRUIT_DIR, FRUIT_NAME + ".indexed");
      
          public static final File TEST_FRUIT_ENTRY_INDEX = new File(TEST_FRUIT_DIR,
                  FRUIT_NAME + ".entry-index");
      
          public static final File TEST_FRUIT_FEATURE_INDEX = new File(
                  TEST_FRUIT_DIR, FRUIT_NAME + ".feature-index");
      
          public static final File TEST_FRUIT_ENTRIES = new File(TEST_FRUIT_DIR,
                  FRUIT_NAME + ".entries");
      
          public static final File TEST_FRUIT_FEATURES = new File(TEST_FRUIT_DIR,
                  FRUIT_NAME + ".features");
      
          public static final File TEST_FRUIT_EVENTS = new File(TEST_FRUIT_DIR,
                  FRUIT_NAME + ".events");
      
          public static final File TEST_FRUIT_ENTRIES_FILTERED = new File(
                  TEST_FRUIT_ENTRIES.getParentFile(), TEST_FRUIT_ENTRIES.getName()
                  + ".filtered");
      
          public static final File TEST_FRUIT_FEATURES_FILTERED = new File(
                  TEST_FRUIT_FEATURES.getParentFile(), TEST_FRUIT_FEATURES.getName()
                  + ".filtered");
      
          public static final File TEST_FRUIT_EVENTS_FILTERED = new File(
                  TEST_FRUIT_EVENTS.getParentFile(), TEST_FRUIT_EVENTS.getName()
                  + ".filtered");
      
          public static final File TEST_FRUIT_SIMS = new File(TEST_FRUIT_DIR,
                  FRUIT_NAME + ".sims");
      
          public static final File TEST_FRUIT_SIMS_100NN = new File(TEST_FRUIT_DIR,
                  TEST_FRUIT_SIMS.getName() + ".100nn");
      
          public static final File TEST_FRUIT_INDEXED_ENTRIES = new File(
                  TEST_FRUIT_DIR, FRUIT_NAME + ".indexed.entries");
      
          public static final File TEST_FRUIT_SKIPINDEXED_ENTRIES = new File(
                  TEST_FRUIT_DIR, FRUIT_NAME + ".skipindexed.entries");
      
          public static final File TEST_FRUIT_INDEXED_FEATURES = new File(
                  TEST_FRUIT_DIR, FRUIT_NAME + ".indexed.features");
      
          public static final File TEST_FRUIT_SKIPINDEXED_FEATURES = new File(
                  TEST_FRUIT_DIR, FRUIT_NAME + ".skipindexed.features");
      
          public static final File TEST_FRUIT_INDEXED_EVENTS = new File(
                  TEST_FRUIT_DIR, FRUIT_NAME + ".indexed.events");
      
          public static final File TEST_FRUIT_SKIPINDEXED_EVENTS = new File(
                  TEST_FRUIT_DIR, FRUIT_NAME + ".skipindexed.events");
      
          public static final File TEST_FRUIT_INDEXED_SIMS = new File(TEST_FRUIT_DIR,
                  FRUIT_NAME + ".indexed.sims");
      
          public static final File TEST_FRUIT_INDEXED_SIMS_100NN = new File(
                  TEST_FRUIT_DIR, FRUIT_NAME + ".indexed.sims.100nn");
      
          public static final File TEST_OUTPUT_DIR = new File("target/test-out");
      
          public static final File TEST_TMP_DIR = new File(TEST_OUTPUT_DIR, "temp");
      
          public static final Charset DEFAULT_CHARSET = Files.DEFAULT_CHARSET;
      
          ;
      
          static {
              if (!TEST_OUTPUT_DIR.exists() && !TEST_OUTPUT_DIR.mkdir())
                  throw new AssertionError();
              if (!TEST_TMP_DIR.exists() && !TEST_TMP_DIR.mkdir())
                  throw new AssertionError();
          }
      
          static final Random RAND = new Random();
      
          public static File makeTempFile(int size) throws IOException {
              final File file = File.createTempFile(TestConstants.class.getName(),
                      ".tmp");
      
              OutputStream out = null;
              try {
                  out = new BufferedOutputStream(new FileOutputStream(file));
      
                  byte[] data = new byte[1024];
                  RAND.nextBytes(data);
                  int i = 0;
                  while (i < size) {
                      out.write(data, 0, Math.min(data.length, size - i));
                      i += data.length;
                  }
              } finally {
                  if (out != null) {
                      Flushables.flushQuietly(out);
                      Closeables.closeQuietly(out);
                  }
              }
              return file;
          }
      
          public static void assertValidInputFiles(File... files) throws IOException {
              for (File file : files) {
                  assertNotNull("File is null.", file);
                  assertTrue(format("Input file is null: \"{0}\"", file),
                          file != null);
                  assertTrue(format("Input file does not exist: \"{0}\" ", file),
                          file.exists());
                  assertTrue(
                          format("Input file is not a regular file: \"{0}\" ", file),
                          file.isFile());
                  assertTrue(format("Input file is empty: ", file) + file,
                          file.length() > 0);
      
              }
          }
      
          public static void assertValidPlaintextInputFiles(File... files)
                  throws IOException {
              assertValidInputFiles(files);
              for (File file : files) {
                  // The last character should be a newline.
                  RandomAccessFile raf = new RandomAccessFile(file, "r");
                  raf.seek(file.length() - 1);
                  int ch = raf.read();
                  assertEquals(
                          format("Expecting newline chracter at end of inout file: \"{0}\"",
                                  file), ch, '\n');
                  raf.close();
              }
          }
      
          public static void assertValidJDBMInputFiles(File... files)
                  throws IOException {
              for (File file : files) {
                  assertNotNull("File is null.", file);
                  assertTrue(format("Input file is null: \"{0}\"", file),
                          file != null);
      
                  File data = new File(file.getParentFile(), file.getName() + ".d.0");
                  File index = new File(file.getParentFile(), file.getName() + ".i.0");
                  // File trans = new File(file.getParentFile(), file.getName() +
                  // ".t");
      
                  assertValidInputFiles(data, index);
              }
          }
      
          public static void assertValidIndexInputFiles(File... files)
                  throws IOException {
              for (File file : files) {
                  assertNotNull("File is null.", file);
                  assertTrue(format("Input file is null: \"{0}\"", file),
                          file != null);
                  File data = new File(file.getParentFile(), file.getName() + ".d.0");
                  File index = new File(file.getParentFile(), file.getName() + ".i.0");
                  // File trans = new File(file.getParentFile(), file.getName() +
                  // ".t");
      
                  assertValidInputFiles(data, index);
              }
          }
      
          public static void assertValidOutputFiles(File... files) throws IOException {
              for (File file : files) {
                  assertNotNull("File is null.", file);
                  if (file.exists()) {
                      assertTrue(
                              format("Input file is not a regular: \"{0}\"", file),
                              file.isFile());
                      assertTrue(
                              format("Input file is not writeable: \"{0}\"", file),
                              file.canWrite());
                  } else {
                      assertTrue(format("Cannot be created: \"{0}\"", file), file
                              .getParentFile().canWrite());
                  }
              }
          }
      
          public static void assertValidJDBMOutputFiles(File... files)
                  throws IOException {
              for (File file : files) {
                  assertNotNull("File is null.", file);
                  File data = new File(file.getParentFile(), file.getName() + ".d.0");
                  File index = new File(file.getParentFile(), file.getName() + ".i.0");
                  File trans = new File(file.getParentFile(), file.getName() + ".t");
                  assertValidOutputFiles(data, index, trans);
              }
          }
      
          public static void assertSizeGT(File bigger, File smaller)
                  throws IOException {
              assertValidPlaintextInputFiles(bigger, smaller);
              assertTrue(
                      format("\"{0}\" is not smaller than \"{1}\"", smaller, bigger),
                      bigger.length() > smaller.length());
          }
      
          public static void deleteIfExist(File... files) throws IOException {
              for (File file : files) {
                  if (file.exists()) {
                      boolean deleted = file.delete();
                      if (!deleted)
                          throw new IOException("Failed to delete file " + file);
                  }
              }
          }
      
          public static void deleteJDBMIfExist(File... files) throws IOException {
              for (File file : files) {
                  File data = new File(file.getParentFile(), file.getName() + ".d.0");
                  File index = new File(file.getParentFile(), file.getName() + ".i.0");
                  File trans = new File(file.getParentFile(), file.getName() + ".t");
                  deleteIfExist(data, index, trans);
              }
          }
      
          public static File suffix(File file, String suffix) {
              return new File(file.getParentFile(), file.getName() + suffix);
          }
      
      
          public static class InfoProgressListener implements ProgressListener {
      
              private long tick = System.currentTimeMillis();
      
              @Override
              public void progressChanged(final ProgressEvent progressEvent) {
                  System.out.println(MiscUtil.memoryInfoString());
      
                  long newTick = System.currentTimeMillis();
                  double timeDiff = (newTick - tick) / 1000.0d;
                  tick = newTick;
      
                  System.out
                          .println(MessageFormat.format("Tick: {0} seconds", timeDiff));
      
                  //
      //    		MemoryUsage mu = new MemoryUsage();
      //    		mu.add(progressEvent.getSource());
      //    		mu.add(this);
      //    		System.out.println(progressEvent.getSource());
      //    		System.out.println(mu.getInfoString());
      
              }
      
          }
      
      
          /**
           * Routine that creates a large amount of data, that should be the absolute
           * worst case for counting stage of the pipeline. That is data where entries
           * and features only ever appear once, and consequently events also are
           * unique. This causes the counting maps to be at the upper bound of their
           * potential size.
           *
           * @throws IOException
           */
          public static void generateUniqueInstanceData(
                  final File outFile, final int nEntries,
                  final int nFeaturesPerEntry) throws IOException {
              assert nEntries < Integer.MAX_VALUE / nFeaturesPerEntry
                      : "number of events must be less than max_integer";
              final int nEvents = nEntries * nFeaturesPerEntry;
      
              System.out.printf("Generating worst-case data for ExternalCount " +
                      "(nEntries=%d, nFeaturesPerEntry=%d, nEvents=%d)...%n",
                      nEntries, nFeaturesPerEntry, nEvents);
      
              TokenPairSink sink = null;
              try {
                  final DoubleEnumeratingDelegate ded = new DoubleEnumeratingDelegate(
                          Enumerating.DEFAULT_TYPE, true, true, null, null);
      
                  sink = BybloIO.openInstancesSink(outFile, DEFAULT_CHARSET, ded);
      
      
                  for (int entryId = 0; entryId < nEntries; entryId++) {
      
                      final int startId = entryId * nFeaturesPerEntry;
                      final int endId = (entryId + 1) * nFeaturesPerEntry;
      
                      for (int featureId = startId; featureId < endId; featureId++) {
                          sink.write(new TokenPair(entryId, featureId));
      
                          if (featureId % 5000000 == 0 || featureId == nEvents - 1) {
                              System.out.printf("> generated %d of %d events (%.2f%% complete)%n",
                                      featureId, nEvents, (100.0d * featureId) / nEvents);
                          }
                      }
                  }
              } finally {
                  if (sink != null)
                      sink.close();
              }
      
              System.out.println("Generation completed.");
          }
      }
      File
      TestConstants.java
      Developer's decision
      Manual
      Kind of conflict
      Attribute
      Method declaration
      Method invocation
      Chunk
      Conflicting content
      
      	public static final File TEST_FRUIT_DIR = TEST_DATA_DIR;
      <<<<<<< HEAD
          public static final File TEST_FRUIT_ENTRIES_FILTERED =
                  new File(TEST_FRUIT_ENTRIES.getParentFile(), TEST_FRUIT_ENTRIES.
                          getName() + ".filtered");
      
          public static final File TEST_FRUIT_FEATURES_FILTERED =
                  new File(TEST_FRUIT_FEATURES.getParentFile(), TEST_FRUIT_FEATURES.
                          getName() + ".filtered");
      
          public static final File TEST_FRUIT_EVENTS_FILTERED =
                  new File(TEST_FRUIT_EVENTS.getParentFile(),
                          TEST_FRUIT_EVENTS.getName() + ".filtered");
      
          public static final File TEST_FRUIT_SIMS =
                  new File(TEST_FRUIT_DIR, FRUIT_NAME + ".sims");
      
          public static final File TEST_FRUIT_SIMS_100NN =
                  new File(TEST_FRUIT_DIR, TEST_FRUIT_SIMS.getName() + ".100nn");
      
          public static final File TEST_FRUIT_INDEXED_ENTRIES =
                  new File(TEST_FRUIT_DIR, FRUIT_NAME + ".indexed.entries");
      
          public static final File TEST_FRUIT_SKIP_INDEXED_ENTRIES =
                  new File(TEST_FRUIT_DIR, FRUIT_NAME + ".skipindexed.entries");
      
          public static final File TEST_FRUIT_INDEXED_FEATURES =
                  new File(TEST_FRUIT_DIR, FRUIT_NAME + ".indexed.features");
      
          public static final File TEST_FRUIT_SKIP_INDEXED_FEATURES =
                  new File(TEST_FRUIT_DIR, FRUIT_NAME + ".skipindexed.features");
      
          public static final File TEST_FRUIT_INDEXED_EVENTS =
                  new File(TEST_FRUIT_DIR, FRUIT_NAME + ".indexed.events");
      
          public static final File TEST_FRUIT_SKIP_INDEXED_EVENTS =
                  new File(TEST_FRUIT_DIR, FRUIT_NAME + ".skipindexed.events");
      
          public static final File TEST_FRUIT_INDEXED_SIMS =
                  new File(TEST_FRUIT_DIR, FRUIT_NAME + ".indexed.sims");
      
          public static final File TEST_FRUIT_INDEXED_SIMS_100NN =
                  new File(TEST_FRUIT_DIR, FRUIT_NAME + ".indexed.sims.100nn");
      
          public static final File TEST_OUTPUT_DIR = new File("target/test-out");
      
          public static final File TEST_TMP_DIR = new File(TEST_OUTPUT_DIR, "temp");
      
          public static final Charset DEFAULT_CHARSET = Files.DEFAULT_CHARSET;
      
          static {
              if (!TEST_OUTPUT_DIR.exists() && !TEST_OUTPUT_DIR.mkdir())
                  throw new AssertionError();
              if (!TEST_TMP_DIR.exists() && !TEST_TMP_DIR.mkdir())
                  throw new AssertionError();
          }
      
          static final Random RAND = new Random();
      
          public static File makeTempFile(int size) throws IOException {
              final File file = File.createTempFile(
                      TestConstants.class.getName(), ".tmp");
      
              OutputStream out = null;
              try {
                  out = new BufferedOutputStream(new FileOutputStream(file));
      
                  byte[] data = new byte[1024];
                  RAND.nextBytes(data);
                  int i = 0;
                  while (i < size) {
                      out.write(data, 0, Math.min(data.length, size - i));
                      i += data.length;
                  }
              } finally {
                  if (out != null) {
                      Flushables.flushQuietly(out);
                      Closeables.closeQuietly(out);
                  }
              }
              return file;
          }
      
          public static void assertValidInputFiles(File... files) throws IOException {
              for (File file : files) {
                  assertNotNull("File is null.", file);
                  assertTrue(format("Input file does not exist: \"{0}\" ", file),
                          file.exists());
                  assertTrue(
                          format("Input file is not a regular file: \"{0}\" ", file),
                          file.isFile());
                  assertTrue(format("Input file is empty: ", file) + file,
                          file.length() > 0);
      
              }
          }
      
          public static void assertValidPlaintextInputFiles(File... files) throws IOException {
              assertValidInputFiles(files);
              for (File file : files) {
                  // The last character should be a newline.
                  RandomAccessFile raf = new RandomAccessFile(file, "r");
                  raf.seek(file.length() - 1);
                  int ch = raf.read();
                  assertEquals(format(
                          "Expecting newline chracter at end of inout file: \"{0}\"",
                          file), ch, '\n');
                  raf.close();
              }
          }
      
          public static void assertValidJDBMInputFiles(File... files) throws IOException {
              for (File file : files) {
                  assertNotNull("File is null.", file);
      
                  File data = new File(file.getParentFile(), file.getName() + ".d.0");
                  File index = new File(file.getParentFile(), file.getName() + ".i.0");
      //            File trans = new File(file.getParentFile(), file.getName() + ".t");
      
                  assertValidInputFiles(data, index);
              }
          }
      
          public static void assertValidIndexInputFiles(File... files) throws IOException {
              for (File file : files) {
                  assertNotNull("File is null.", file);
                  File data = new File(file.getParentFile(), file.getName() + ".d.0");
                  File index = new File(file.getParentFile(), file.getName() + ".i.0");
      //            File trans = new File(file.getParentFile(), file.getName() + ".t");
      
                  assertValidInputFiles(data, index);
              }
          }
      
          public static void assertValidOutputFiles(File... files) throws IOException {
              for (File file : files) {
                  assertNotNull("File is null.", file);
                  if (file.exists()) {
                      assertTrue(format("Input file is not a regular: \"{0}\"", file),
                              file.isFile());
                      assertTrue(format("Input file is not writable: \"{0}\"", file),
                              file.canWrite());
                  } else {
                      assertTrue(format("Cannot be created: \"{0}\"", file),
                              file.getParentFile().canWrite());
                  }
              }
          }
      
          public static void assertValidJDBMOutputFiles(File... files) throws IOException {
              for (File file : files) {
                  assertNotNull("File is null.", file);
                  File data = new File(file.getParentFile(), file.getName() + ".d.0");
                  File index = new File(file.getParentFile(), file.getName() + ".i.0");
                  File trans = new File(file.getParentFile(), file.getName() + ".t");
                  assertValidOutputFiles(data, index, trans);
              }
          }
      
          public static void assertSizeGT(File bigger, File smaller) throws IOException {
              assertValidPlaintextInputFiles(bigger, smaller);
              assertTrue(
                      format("\"{0}\" is not smaller than \"{1}\"", smaller, bigger),
                      bigger.length() > smaller.length());
          }
      
          public static void deleteIfExist(File... files) throws IOException {
              for (File file : files) {
                  if (file.exists()) {
                      boolean deleted = file.delete();
                      if (!deleted)
                          throw new IOException("Failed to delete file " + file);
                  }
              }
          }
      
          public static void deleteJDBMIfExist(File... files) throws IOException {
              for (File file : files) {
                  File data = new File(file.getParentFile(), file.getName() + ".d.0");
                  File index = new File(file.getParentFile(), file.getName() + ".i.0");
                  File trans = new File(file.getParentFile(), file.getName() + ".t");
                  deleteIfExist(data, index, trans);
              }
          }
      
          public static File suffix(File file, String suffix) {
              return new File(file.getParentFile(), file.getName() + suffix);
          }
      
      
          public static class InfoProgressListener implements ProgressListener {
      
              private long tick = System.currentTimeMillis();
      
              @Override
              public void progressChanged(final ProgressEvent progressEvent) {
                  System.out.println(MiscUtil.memoryInfoString());
      
                  long newTick = System.currentTimeMillis();
                  double timeDiff = (newTick - tick) / 1000.0d;
                  tick = newTick;
      
                  System.out
                          .println(MessageFormat.format("Tick: {0} seconds", timeDiff));
      
                  //
      //    		MemoryUsage mu = new MemoryUsage();
      //    		mu.add(progressEvent.getSource());
      //    		mu.add(this);
      //    		System.out.println(progressEvent.getSource());
      //    		System.out.println(mu.getInfoString());
      
              }
      
          }
      
      
          /**
           * Routine that creates a large amount of data, that should be the absolute
           * worst case for counting stage of the pipeline. That is data where entries
           * and features only ever appear once, and consequently events also are
           * unique. This causes the counting maps to be at the upper bound of their
           * potential size.
           *
           * @throws IOException
           */
          public static void generateUniqueInstanceData(
                  final File outFile, final int nEntries,
                  final int nFeaturesPerEntry) throws IOException {
              assert nEntries < Integer.MAX_VALUE / nFeaturesPerEntry
                      : "number of events must be less than max_integer";
              final int nEvents = nEntries * nFeaturesPerEntry;
      
              System.out.printf("Generating worst-case data for ExternalCount " +
                      "(nEntries=%d, nFeaturesPerEntry=%d, nEvents=%d)...%n",
                      nEntries, nFeaturesPerEntry, nEvents);
      
              TokenPairSink sink = null;
              try {
                  final DoubleEnumeratingDelegate ded = new DoubleEnumeratingDelegate(
                          Enumerating.DEFAULT_TYPE, true, true, null, null);
      
                  sink = BybloIO.openInstancesSink(outFile, DEFAULT_CHARSET, ded);
      
      
                  for (int entryId = 0; entryId < nEntries; entryId++) {
      
                      final int startId = entryId * nFeaturesPerEntry;
                      final int endId = (entryId + 1) * nFeaturesPerEntry;
      
                      for (int featureId = startId; featureId < endId; featureId++) {
                          sink.write(new TokenPair(entryId, featureId));
      
                          if (featureId % 5000000 == 0 || featureId == nEvents - 1) {
                              System.out.printf("> generated %d of %d events (%.2f%% complete)%n",
                                      featureId, nEvents, (100.0d * featureId) / nEvents);
                          }
                      }
                  }
              } finally {
                  if (sink != null)
                      sink.close();
              }
      
              System.out.println("Generation completed.");
          }
      =======
      	public static final String FRUIT_NAME = "bnc-gramrels-fruit";
      
      	public static final File TEST_FRUIT_INPUT = new File(TEST_FRUIT_DIR,
      			FRUIT_NAME);
      
      	public static final File TEST_FRUIT_INPUT_INDEXED = new File(
      			TEST_FRUIT_DIR, FRUIT_NAME + ".indexed");
      
      	public static final File TEST_FRUIT_ENTRY_INDEX = new File(TEST_FRUIT_DIR,
      			FRUIT_NAME + ".entry-index");
      
      	public static final File TEST_FRUIT_FEATURE_INDEX = new File(
      			TEST_FRUIT_DIR, FRUIT_NAME + ".feature-index");
      
      	public static final File TEST_FRUIT_ENTRIES = new File(TEST_FRUIT_DIR,
      			FRUIT_NAME + ".entries");
      
      	public static final File TEST_FRUIT_FEATURES = new File(TEST_FRUIT_DIR,
      			FRUIT_NAME + ".features");
      
      	public static final File TEST_FRUIT_EVENTS = new File(TEST_FRUIT_DIR,
      			FRUIT_NAME + ".events");
      
      	public static final File TEST_FRUIT_ENTRIES_FILTERED = new File(
      			TEST_FRUIT_ENTRIES.getParentFile(), TEST_FRUIT_ENTRIES.getName()
      					+ ".filtered");
      
      	public static final File TEST_FRUIT_FEATURES_FILTERED = new File(
      			TEST_FRUIT_FEATURES.getParentFile(), TEST_FRUIT_FEATURES.getName()
      					+ ".filtered");
      
      	public static final File TEST_FRUIT_EVENTS_FILTERED = new File(
      			TEST_FRUIT_EVENTS.getParentFile(), TEST_FRUIT_EVENTS.getName()
      					+ ".filtered");
      
      	public static final File TEST_FRUIT_SIMS = new File(TEST_FRUIT_DIR,
      			FRUIT_NAME + ".sims");
      
      	public static final File TEST_FRUIT_SIMS_100NN = new File(TEST_FRUIT_DIR,
      			TEST_FRUIT_SIMS.getName() + ".100nn");
      
      	public static final File TEST_FRUIT_INDEXED_ENTRIES = new File(
      			TEST_FRUIT_DIR, FRUIT_NAME + ".indexed.entries");
      
      	public static final File TEST_FRUIT_SKIPINDEXED_ENTRIES = new File(
      			TEST_FRUIT_DIR, FRUIT_NAME + ".skipindexed.entries");
      
      	public static final File TEST_FRUIT_INDEXED_FEATURES = new File(
      			TEST_FRUIT_DIR, FRUIT_NAME + ".indexed.features");
      
      	public static final File TEST_FRUIT_SKIPINDEXED_FEATURES = new File(
      			TEST_FRUIT_DIR, FRUIT_NAME + ".skipindexed.features");
      
      	public static final File TEST_FRUIT_INDEXED_EVENTS = new File(
      			TEST_FRUIT_DIR, FRUIT_NAME + ".indexed.events");
      
      	public static final File TEST_FRUIT_SKIPINDEXED_EVENTS = new File(
      			TEST_FRUIT_DIR, FRUIT_NAME + ".skipindexed.events");
      
      	public static final File TEST_FRUIT_INDEXED_SIMS = new File(TEST_FRUIT_DIR,
      			FRUIT_NAME + ".indexed.sims");
      
      	public static final File TEST_FRUIT_INDEXED_SIMS_100NN = new File(
      			TEST_FRUIT_DIR, FRUIT_NAME + ".indexed.sims.100nn");
      
      	public static final File TEST_OUTPUT_DIR = new File("target/test-out");
      
      	public static final File TEST_TMP_DIR = new File(TEST_OUTPUT_DIR, "temp");
      
      	public static final Charset DEFAULT_CHARSET = Files.DEFAULT_CHARSET;
      
      	;
      
      	static {
      		if (!TEST_OUTPUT_DIR.exists() && !TEST_OUTPUT_DIR.mkdir())
      			throw new AssertionError();
      		if (!TEST_TMP_DIR.exists() && !TEST_TMP_DIR.mkdir())
      			throw new AssertionError();
      	}
      
      	static final Random RAND = new Random();
      
      	public static File makeTempFile(int size) throws IOException {
      		final File file = File.createTempFile(TestConstants.class.getName(),
      				".tmp");
      
      		OutputStream out = null;
      		try {
      			out = new BufferedOutputStream(new FileOutputStream(file));
      
      			byte[] data = new byte[1024];
      			RAND.nextBytes(data);
      			int i = 0;
      			while (i < size) {
      				out.write(data, 0, Math.min(data.length, size - i));
      				i += data.length;
      			}
      		} finally {
      			if (out != null) {
      				Flushables.flushQuietly(out);
      				Closeables.closeQuietly(out);
      			}
      		}
      		return file;
      	}
      
      	public static void assertValidInputFiles(File... files) throws IOException {
      		for (File file : files) {
      			assertNotNull("File is null.", file);
      			assertTrue(format("Input file is null: \"{0}\"", file),
      					file != null);
      			assertTrue(format("Input file does not exist: \"{0}\" ", file),
      					file.exists());
      			assertTrue(
      					format("Input file is not a regular file: \"{0}\" ", file),
      					file.isFile());
      			assertTrue(format("Input file is empty: ", file) + file,
      					file.length() > 0);
      
      		}
      	}
      
      	public static void assertValidPlaintextInputFiles(File... files)
      			throws IOException {
      		assertValidInputFiles(files);
      		for (File file : files) {
      			// The last character should be a newline.
      			RandomAccessFile raf = new RandomAccessFile(file, "r");
      			raf.seek(file.length() - 1);
      			int ch = raf.read();
      			assertEquals(
      					format("Expecting newline chracter at end of inout file: \"{0}\"",
      							file), ch, '\n');
      			raf.close();
      		}
      	}
      
      	public static void assertValidJDBMInputFiles(File... files)
      			throws IOException {
      		for (File file : files) {
      			assertNotNull("File is null.", file);
      			assertTrue(format("Input file is null: \"{0}\"", file),
      					file != null);
      
      			File data = new File(file.getParentFile(), file.getName() + ".d.0");
      			File index = new File(file.getParentFile(), file.getName() + ".i.0");
      			// File trans = new File(file.getParentFile(), file.getName() +
      			// ".t");
      
      			assertValidInputFiles(data, index);
      		}
      	}
      
      	public static void assertValidIndexInputFiles(File... files)
      			throws IOException {
      		for (File file : files) {
      			assertNotNull("File is null.", file);
      			assertTrue(format("Input file is null: \"{0}\"", file),
      					file != null);
      			File data = new File(file.getParentFile(), file.getName() + ".d.0");
      			File index = new File(file.getParentFile(), file.getName() + ".i.0");
      			// File trans = new File(file.getParentFile(), file.getName() +
      			// ".t");
      
      			assertValidInputFiles(data, index);
      		}
      	}
      
      	public static void assertValidOutputFiles(File... files) throws IOException {
      		for (File file : files) {
      			assertNotNull("File is null.", file);
      			if (file.exists()) {
      				assertTrue(
      						format("Input file is not a regular: \"{0}\"", file),
      						file.isFile());
      				assertTrue(
      						format("Input file is not writeable: \"{0}\"", file),
      						file.canWrite());
      			} else {
      				assertTrue(format("Cannot be created: \"{0}\"", file), file
      						.getParentFile().canWrite());
      			}
      		}
      	}
      
      	public static void assertValidJDBMOutputFiles(File... files)
      			throws IOException {
      		for (File file : files) {
      			assertNotNull("File is null.", file);
      			File data = new File(file.getParentFile(), file.getName() + ".d.0");
      			File index = new File(file.getParentFile(), file.getName() + ".i.0");
      			File trans = new File(file.getParentFile(), file.getName() + ".t");
      			assertValidOutputFiles(data, index, trans);
      		}
      	}
      
      	public static void assertSizeGT(File bigger, File smaller)
      			throws IOException {
      		assertValidPlaintextInputFiles(bigger, smaller);
      		assertTrue(
      				format("\"{0}\" is not smaller than \"{1}\"", smaller, bigger),
      				bigger.length() > smaller.length());
      	}
      
      	public static void deleteIfExist(File... files) throws IOException {
      		for (File file : files) {
      			if (file.exists()) {
      				boolean deleted = file.delete();
      				if (!deleted)
      					throw new IOException("Failed to delete file " + file);
      			}
      		}
      	}
      
      	public static void deleteJDBMIfExist(File... files) throws IOException {
      		for (File file : files) {
      			File data = new File(file.getParentFile(), file.getName() + ".d.0");
      			File index = new File(file.getParentFile(), file.getName() + ".i.0");
      			File trans = new File(file.getParentFile(), file.getName() + ".t");
      			deleteIfExist(data, index, trans);
      		}
      	}
      
      	public static File suffix(File file, String suffix) {
      		return new File(file.getParentFile(), file.getName() + suffix);
      	}
      >>>>>>> 5f0ba9177b34449ea27dabdc17fd0793620c7d56
      }
      Solution content
          public static final File TEST_OUTPUT_DIR = new File("target/test-out");
      
          public static final File TEST_TMP_DIR = new File(TEST_OUTPUT_DIR, "temp");
      
          public static final Charset DEFAULT_CHARSET = Files.DEFAULT_CHARSET;
      
          ;
      
          static {
              if (!TEST_OUTPUT_DIR.exists() && !TEST_OUTPUT_DIR.mkdir())
                  throw new AssertionError();
              if (!TEST_TMP_DIR.exists() && !TEST_TMP_DIR.mkdir())
                  throw new AssertionError();
          }
      
          static final Random RAND = new Random();
      
          public static File makeTempFile(int size) throws IOException {
              final File file = File.createTempFile(TestConstants.class.getName(),
                      ".tmp");
      
              OutputStream out = null;
              try {
                  out = new BufferedOutputStream(new FileOutputStream(file));
      
                  byte[] data = new byte[1024];
                  RAND.nextBytes(data);
                  int i = 0;
                  while (i < size) {
                      out.write(data, 0, Math.min(data.length, size - i));
                      i += data.length;
                  }
              } finally {
                  if (out != null) {
                      Flushables.flushQuietly(out);
                      Closeables.closeQuietly(out);
                  }
              }
              return file;
          }
      
          public static void assertValidInputFiles(File... files) throws IOException {
              for (File file : files) {
                  assertNotNull("File is null.", file);
                  assertTrue(format("Input file is null: \"{0}\"", file),
                          file != null);
                  assertTrue(format("Input file does not exist: \"{0}\" ", file),
                          file.exists());
                  assertTrue(
                          format("Input file is not a regular file: \"{0}\" ", file),
                          file.isFile());
                  assertTrue(format("Input file is empty: ", file) + file,
                          file.length() > 0);
      
              }
          }
      
          public static void assertValidPlaintextInputFiles(File... files)
                  throws IOException {
              assertValidInputFiles(files);
              for (File file : files) {
                  // The last character should be a newline.
                  RandomAccessFile raf = new RandomAccessFile(file, "r");
                  raf.seek(file.length() - 1);
                  int ch = raf.read();
                  assertEquals(
                          format("Expecting newline chracter at end of inout file: \"{0}\"",
                                  file), ch, '\n');
                  raf.close();
              }
          }
      
          public static void assertValidJDBMInputFiles(File... files)
                  throws IOException {
              for (File file : files) {
                  assertNotNull("File is null.", file);
                  assertTrue(format("Input file is null: \"{0}\"", file),
                          file != null);
      
                  File data = new File(file.getParentFile(), file.getName() + ".d.0");
                  File index = new File(file.getParentFile(), file.getName() + ".i.0");
                  // File trans = new File(file.getParentFile(), file.getName() +
                  // ".t");
      
                  assertValidInputFiles(data, index);
              }
          }
      
          public static void assertValidIndexInputFiles(File... files)
                  throws IOException {
              for (File file : files) {
                  assertNotNull("File is null.", file);
                  assertTrue(format("Input file is null: \"{0}\"", file),
                          file != null);
                  File data = new File(file.getParentFile(), file.getName() + ".d.0");
                  File index = new File(file.getParentFile(), file.getName() + ".i.0");
                  // File trans = new File(file.getParentFile(), file.getName() +
                  // ".t");
      
                  assertValidInputFiles(data, index);
              }
          }
      
          public static void assertValidOutputFiles(File... files) throws IOException {
              for (File file : files) {
                  assertNotNull("File is null.", file);
                  if (file.exists()) {
                      assertTrue(
                              format("Input file is not a regular: \"{0}\"", file),
                              file.isFile());
                      assertTrue(
                              format("Input file is not writeable: \"{0}\"", file),
                              file.canWrite());
                  } else {
                      assertTrue(format("Cannot be created: \"{0}\"", file), file
                              .getParentFile().canWrite());
                  }
              }
          }
      
          public static void assertValidJDBMOutputFiles(File... files)
                  throws IOException {
              for (File file : files) {
                  assertNotNull("File is null.", file);
                  File data = new File(file.getParentFile(), file.getName() + ".d.0");
                  File index = new File(file.getParentFile(), file.getName() + ".i.0");
                  File trans = new File(file.getParentFile(), file.getName() + ".t");
                  assertValidOutputFiles(data, index, trans);
              }
          }
      
          public static void assertSizeGT(File bigger, File smaller)
                  throws IOException {
              assertValidPlaintextInputFiles(bigger, smaller);
              assertTrue(
                      format("\"{0}\" is not smaller than \"{1}\"", smaller, bigger),
                      bigger.length() > smaller.length());
          }
      
          public static void deleteIfExist(File... files) throws IOException {
              for (File file : files) {
                  if (file.exists()) {
                      boolean deleted = file.delete();
                      if (!deleted)
                          throw new IOException("Failed to delete file " + file);
                  }
              }
          }
      
          public static void deleteJDBMIfExist(File... files) throws IOException {
              for (File file : files) {
                  File data = new File(file.getParentFile(), file.getName() + ".d.0");
                  File index = new File(file.getParentFile(), file.getName() + ".i.0");
                  File trans = new File(file.getParentFile(), file.getName() + ".t");
                  deleteIfExist(data, index, trans);
              }
          }
      
          public static File suffix(File file, String suffix) {
              return new File(file.getParentFile(), file.getName() + suffix);
          }
      
      
          public static class InfoProgressListener implements ProgressListener {
      
              private long tick = System.currentTimeMillis();
      
              @Override
              public void progressChanged(final ProgressEvent progressEvent) {
                  System.out.println(MiscUtil.memoryInfoString());
      
                  long newTick = System.currentTimeMillis();
                  double timeDiff = (newTick - tick) / 1000.0d;
                  tick = newTick;
      
                  System.out
                          .println(MessageFormat.format("Tick: {0} seconds", timeDiff));
      
                  //
      //    		MemoryUsage mu = new MemoryUsage();
      //    		mu.add(progressEvent.getSource());
      //    		mu.add(this);
      //    		System.out.println(progressEvent.getSource());
      //    		System.out.println(mu.getInfoString());
      
              }
      
          }
      
      
          /**
           * Routine that creates a large amount of data, that should be the absolute
           * worst case for counting stage of the pipeline. That is data where entries
           * and features only ever appear once, and consequently events also are
           * unique. This causes the counting maps to be at the upper bound of their
           * potential size.
           *
           * @throws IOException
           */
          public static void generateUniqueInstanceData(
                  final File outFile, final int nEntries,
                  final int nFeaturesPerEntry) throws IOException {
              assert nEntries < Integer.MAX_VALUE / nFeaturesPerEntry
                      : "number of events must be less than max_integer";
              final int nEvents = nEntries * nFeaturesPerEntry;
      
              System.out.printf("Generating worst-case data for ExternalCount " +
                      "(nEntries=%d, nFeaturesPerEntry=%d, nEvents=%d)...%n",
                      nEntries, nFeaturesPerEntry, nEvents);
      
              TokenPairSink sink = null;
              try {
                  final DoubleEnumeratingDelegate ded = new DoubleEnumeratingDelegate(
                          Enumerating.DEFAULT_TYPE, true, true, null, null);
      
                  sink = BybloIO.openInstancesSink(outFile, DEFAULT_CHARSET, ded);
      
      
                  for (int entryId = 0; entryId < nEntries; entryId++) {
      
                      final int startId = entryId * nFeaturesPerEntry;
                      final int endId = (entryId + 1) * nFeaturesPerEntry;
      
                      for (int featureId = startId; featureId < endId; featureId++) {
                          sink.write(new TokenPair(entryId, featureId));
      
                          if (featureId % 5000000 == 0 || featureId == nEvents - 1) {
                              System.out.printf("> generated %d of %d events (%.2f%% complete)%n",
                                      featureId, nEvents, (100.0d * featureId) / nEvents);
                          }
                      }
                  }
              } finally {
                  if (sink != null)
                      sink.close();
              }
      
              System.out.println("Generation completed.");
          }
      }
      File
      TestConstants.java
      Developer's decision
      Combination
      Kind of conflict
      Attribute
      Class declaration
      Comment
      Method declaration
      Method invocation
      Static initializer
      Chunk
      Conflicting content
       */
      package uk.ac.susx.mlcl.byblo.measures.impl;
      
      <<<<<<< HEAD
      import org.junit.BeforeClass;
      import org.junit.Test;
      import uk.ac.susx.mlcl.byblo.Tools;
      =======
      import static uk.ac.susx.mlcl.TestConstants.DEFAULT_CHARSET;
      import static uk.ac.susx.mlcl.TestConstants.TEST_FRUIT_FEATURES;
      
      import java.io.IOException;
      import java.util.Arrays;
      import java.util.List;
      
      import javax.naming.OperationNotSupportedException;
      
      import junit.framework.Assert;
      
      import org.junit.Ignore;
      import org.junit.Test;
      
      import uk.ac.susx.mlcl.TestConstants;
      >>>>>>> 5f0ba9177b34449ea27dabdc17fd0793620c7d56
      import uk.ac.susx.mlcl.byblo.enumerators.DoubleEnumerating;
      import uk.ac.susx.mlcl.byblo.enumerators.DoubleEnumeratingDelegate;
      import uk.ac.susx.mlcl.byblo.enumerators.EnumeratingDelegates;
      Solution content
       */
      package uk.ac.susx.mlcl.byblo.measures.impl;
      
      import org.junit.Ignore;
      import org.junit.Test;
      import uk.ac.susx.mlcl.byblo.enumerators.DoubleEnumerating;
      import uk.ac.susx.mlcl.byblo.enumerators.DoubleEnumeratingDelegate;
      import uk.ac.susx.mlcl.byblo.enumerators.EnumeratingDelegates;
      File
      ConfusionTest.java
      Developer's decision
      Combination
      Kind of conflict
      Import
      Chunk
      Conflicting content
              }
          @Test
      import uk.ac.susx.mlcl.byblo.weighings.MarginalDistribution;
      import uk.ac.susx.mlcl.lib.collect.Indexed;
      import uk.ac.susx.mlcl.lib.collect.SparseDoubleVector;
      <<<<<<< HEAD
      
      import java.io.File;
      import java.util.ArrayList;
      import java.util.List;
      import java.util.Random;
      
      import static org.junit.Assert.*;
      import static uk.ac.susx.mlcl.TestConstants.*;
      import static uk.ac.susx.mlcl.lib.test.ExitTrapper.disableExitTrapping;
      import static uk.ac.susx.mlcl.lib.test.ExitTrapper.enableExistTrapping;
      
      /**
       * @author Hamish I A Morgan <hamish.morgan@sussex.ac.uk>
       */
      public class ConfusionTest {
      
          static Confusion INSTANCE;
      
          static final double EPSILON = 0;
      
          static Random RANDOM;
      
          static List> FRUIT_EVENTS;
      
          @BeforeClass
          public static void setUpClass() throws Exception {
              INSTANCE = new Confusion();
              RANDOM = new Random(1234);
      
              final DoubleEnumerating indexDelegate = new DoubleEnumeratingDelegate();
      
              // Load events
              final FastWeightedTokenPairVectorSource eventSrc =
                      BybloIO.openEventsVectorSource(
                              TEST_FRUIT_EVENTS, DEFAULT_CHARSET, indexDelegate);
              FRUIT_EVENTS = new ArrayList>();
              int card = 0;
              while (eventSrc.hasNext()) {
                  Indexed v = eventSrc.read();
                  FRUIT_EVENTS.add(v);
                  card = Math.max(card, v.value().cardinality);
              }
      
              // Add a completely empty feature vector to test that works
              FRUIT_EVENTS.add(new Indexed(
                      Integer.MAX_VALUE, new SparseDoubleVector(card, 0)));
      
              eventSrc.close();
      
              for (Indexed v : FRUIT_EVENTS) {
                  v.value().cardinality = card;
              }
      
              MarginalDistribution fmd = BybloIO.readFeaturesMarginalDistribution(
                      TEST_FRUIT_FEATURES, DEFAULT_CHARSET,
                      EnumeratingDelegates.toSingleFeatures(indexDelegate));
      
              INSTANCE.setFeatureMarginals(fmd);
          }
      
          public void testCLI() throws Exception {
              System.out.println("testCLI");
      
              File output = new File(TEST_OUTPUT_DIR, FRUIT_NAME + ".Confusion");
      
              deleteIfExist(output);
      
              try {
                  enableExistTrapping();
                  Tools.main(new String[]{
                          "allpairs",
                          "--charset", "UTF-8",
                          "--measure", "confusion",
                          "--input", TEST_FRUIT_EVENTS.toString(),
                          "--input-features", TEST_FRUIT_FEATURES.toString(),
                          "--input-entries", TEST_FRUIT_ENTRIES.toString(),
                          "--output", output.toString()
                  });
              } finally {
                  disableExitTrapping();
      
      
              assertTrue("Output file " + output + " does not exist.", output.exists());
              assertTrue("Output file " + output + " is empty.", output.length() > 0);
          }
      
          @Test
          public void testBothEmptyVectors() throws Exception {
              System.out.println("testBothEmptyVectors");
              int size = 100;
              SparseDoubleVector A = new SparseDoubleVector(size, 0);
              SparseDoubleVector B = new SparseDoubleVector(size, 0);
              double expect = 0;
              double actual = test(A, B);
      
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testOneEmptyVector() throws Exception {
              System.out.println("testOneEmptyVector");
              int size = 100;
              SparseDoubleVector A = new SparseDoubleVector(size, 0);
              SparseDoubleVector B = new SparseDoubleVector(size, size);
              for (int i = 0; i < size; i++)
                  B.set(i, RANDOM.nextDouble());
      
              double expect = 0;
              double actual = test(A, B);
      
              assertEquals(expect, actual, EPSILON);
          }
      //
      //    @Test
      //    public void testSizeOneVectors() throws Exception {
      //        System.out.println("testSizeOneVectors");
      //        int size = 100;
      //        SparseDoubleVector A = new SparseDoubleVector(size, 1);
      //        SparseDoubleVector B = new SparseDoubleVector(size, 1);
      //        A.set(0, 1);
      //        B.set(0, 1);
      //        double expect = INSTANCE.getHomogeneityBound();
      //        double actual = test(A, B);
      //
      //        assertEquals(expect, actual, EPSILON);
      //    }
      
          //    @Test
      //    public void testCardinalityOneVectors() throws Exception {
      //        System.out.println("testCardinalityOneVectors");
      //        SparseDoubleVector A = new SparseDoubleVector(1, 1);
      //        SparseDoubleVector B = new SparseDoubleVector(1, 1);
      //        A.set(0, 1);
      //        B.set(0, 1);
      //        double expect = 1;
      //        double actual = test(A, B);
      //
      //        assertEquals(expect, actual, EPSILON);
      //    }
      //    @Test
      //    public void testSizeTwoVectors() throws Exception {
      //        System.out.println("testSizeTwoVectors");
      //        int size = 100;
      //        SparseDoubleVector A = new SparseDoubleVector(size, 2);
      //        SparseDoubleVector B = new SparseDoubleVector(size, 2);
      //        A.set(0, 1);
      //        A.set(1, 1);
      //        B.set(0, 2);
      //        B.set(1, 2);
      //        A.compact();
      //        B.compact();
      //        double expect = INSTANCE.getHomogeneityBound();
      //        double actual = test(A, B);
      //
      //        assertEquals(expect, actual, EPSILON);
      //    }
      //    @Test
      //    public void testCommutative() throws Exception {
      //        System.out.println("testCommutative");
      //        int size = 100;
      //        SparseDoubleVector A = new SparseDoubleVector(size, size);
      //        SparseDoubleVector B = new SparseDoubleVector(size, size);
      //        for (int i = 0; i < size; i++) {
      //            A.set(i, RANDOM.nextDouble());
      //            B.set(i, RANDOM.nextDouble());
      //        }
      //
      //        double expect = test(A, B);
      //        double actual = test(B, A);
      //        assertEquals(expect, actual, EPSILON);
      //    }
      //    @Test
      //    public void testHomoginiety() throws Exception {
      //        System.out.println("testHomoginiety");
      //        int size = 100;
      //        SparseDoubleVector A = new SparseDoubleVector(size, size);
      //        SparseDoubleVector B = new SparseDoubleVector(size, size);
      //        for (int i = 0; i < size; i++) {
      	}
      //            double value = RANDOM.nextDouble();
      //            A.set(i, value);
      //            B.set(i, value);
      //        }
      //
      //        double expect = INSTANCE.getHomogeneityBound();
      //        double actual = test(A, B);
      //
      //        assertEquals(expect, actual, EPSILON);
      //    }
          @Test
          public void testHeteroginiety() throws Exception {
              System.out.println("testHeteroginiety");
              int size = 100;
              SparseDoubleVector A = new SparseDoubleVector(size, size);
              SparseDoubleVector B = new SparseDoubleVector(size, size);
              for (int i = 0; i < size / 2; i++) {
                  A.set(i * 2, i);
                  B.set(i * 2 + 1, i);
              }
      
              double expect = INSTANCE.getHeterogeneityBound();
              double actual = test(A, B);
      
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testFruitData() throws Exception {
              System.out.println("testFruitData");
              int limit = 5;
      
      
              limit = Math.min(limit, FRUIT_EVENTS.size());
      
              final double[][] results = new double[limit][limit];
              for (int i = 0; i < limit; i++) {
                  for (int j = 0; j < limit; j++) {
                      SparseDoubleVector A = FRUIT_EVENTS.get(i).value();
                      SparseDoubleVector B = FRUIT_EVENTS.get(j).value();
                      results[i][j] = test(A, B);
                  }
              }
          }
      
          @Test
          public void testLargeCardinality() throws Exception {
              System.out.println("testLargeCardinality");
              final int size = 100;
              final SparseDoubleVector A = new SparseDoubleVector(
                      Integer.MAX_VALUE, size);
              final SparseDoubleVector B = new SparseDoubleVector(
                      Integer.MAX_VALUE, size);
              for (int i = 0; i < size; i++) {
                  A.set(RANDOM.nextInt(size * 2), RANDOM.nextDouble());
                  B.set(RANDOM.nextInt(size * 2), RANDOM.nextDouble());
              }
      
              test(A, B);
          }
      
          public static double test(SparseDoubleVector A, SparseDoubleVector B) {
              final double val = INSTANCE.similarity(A, B);
              assertFalse("Similarity is NaN" + " with measure " + INSTANCE,
                      Double.isNaN(val));
              assertFalse("Similarity is " + val + " with measure " + INSTANCE,
                      Double.isInfinite(val));
      
              final double min, max;
              if (INSTANCE.getHeterogeneityBound() < INSTANCE.getHomogeneityBound()) {
                  min = INSTANCE.getHeterogeneityBound();
                  max = INSTANCE.getHomogeneityBound();
              } else {
                  min = INSTANCE.getHomogeneityBound();
                  max = INSTANCE.getHeterogeneityBound();
              }
              assertTrue("expected similarity >= " + min + " but found " + val,
                      val >= min);
              assertTrue("expected similarity <= " + max + " but found " + val,
                      val <= max);
      
      
              if (INSTANCE.isCommutative()) {
                  final double rev = INSTANCE.similarity(B, A);
                  assertEquals("Measure is declared computative, but reversing "
                          + "operands results in a different score.", rev, val,
                          EPSILON);
              }
      =======
      
      /**
       * 
       * @author Hamish I A Morgan <hamish.morgan@sussex.ac.uk>
       */
      public class ConfusionTest extends AbstractMeasureTest {
      
      	@Override
      	Class getMeasureClass() {
      		return Confusion.class;
      
      	@Override
      	String getMeasureName() {
      		return "confusion";
      	}
      
      	@Override
      	Confusion newInstance() {
      		try {
      			Confusion instance = super.newInstance();
      			final DoubleEnumerating indexDeligate = new DoubleEnumeratingDeligate();
      			MarginalDistribution fmd = BybloIO
      					.readFeaturesMarginalDistribution(TEST_FRUIT_FEATURES,
      							DEFAULT_CHARSET, EnumeratingDeligates
      									.toSingleFeatures(indexDeligate));
      			instance.setFeatureMarginals(fmd);
      
      			return instance;
      		} catch (IOException e) {
      			throw new AssertionError(e);
      		}
      
      	}
      
      	@Test
      	@Ignore
      	@Override
      	public void testHomoginiety() {
      		throw new UnsupportedOperationException();
      	}
      
      	@Test
      	@Ignore
      	@Override
      	public void testHomoginiety2() {
      		throw new UnsupportedOperationException();
      	}
      
      	@Test
      	@Ignore
      	@Override
      	public void testSizeOneVectors() {
      		throw new UnsupportedOperationException();
      	}
      
      	@Test
      	@Ignore
      	@Override
      	public void testSizeTwoVectors() {
      		throw new UnsupportedOperationException();
      	}
      
      	@Test
      	@Ignore
      	@Override
      	public void testCardinalityOneVectors() {
      		throw new UnsupportedOperationException();
      	}
      
      	// @Test
      	// @Override
      	// public void testSizeOneVectors() {
      	// System.out.println("testSizeOneVectors");
      	// SparseDoubleVector A = ones(100, 1);
      	// SparseDoubleVector B = ones(100, 1);
      	// Confusion instance = newInstance();
      	// instance.setFeatureMarginals(featureMarginals(A, B));
      	// double expect = instance.getIndependenceBound();
      	// double actual = similarity(instance, A, B);
      	//
      	// Assert.assertEquals(expect, actual, EPSILON);
      	// }
      	//
      	// @Test
      	// @Override
      	// public void testSizeTwoVectors() {
      	// System.out.println("testSizeTwoVectors");
      	// SparseDoubleVector A = ones(100, 2);
      	// SparseDoubleVector B = ones(100, 2);
      	// Confusion instance = newInstance();
      	// instance.setFeatureMarginals(featureMarginals(A, B));
      	// double expect = instance.getIndependenceBound();
      	// double actual = similarity(instance, A, B);
      	//
      	// Assert.assertEquals(expect, actual, EPSILON);
      	// }
      	//
      	// @Test
      	// @Override
      	// public void testCardinalityOneVectors() {
      	// System.out.println("testCardinalityOneVectors");
      	// SparseDoubleVector A = ones(1, 1);
      	// SparseDoubleVector B = ones(1, 1);
      	// Confusion instance = newInstance();
      	// instance.setFeatureMarginals(featureMarginals(A, B));
      	// double expect = instance.getIndependenceBound();
      	// double actual = similarity(instance, A, B);
      	//
      	// Assert.assertEquals(expect, actual, EPSILON);
      	// }
      
      	@Test
      	@Override
      	@Ignore
      	public void testFruitIdentity() {
      		throw new UnsupportedOperationException();
      	}
      
      	// @Test
      	// @Override
      	// public void testFruitData() throws IOException {
      	// System.out.println("testFruitData");
      	// int limit = 5;
      	//
      	// List vecs = TestConstants.loadFruitVectors();
      	//
      	// limit = Math.min(limit, vecs.size());
      	//
      	// Confusion instance = newInstance();
      	// if (instance instanceof FeatureMarginalsCarrier)
      	// ((FeatureMarginalsCarrier) instance)
      	// .setFeatureMarginals(featureMarginals(vecs));
      	//
      	// final double[][] results = new double[limit][limit];
      	// for (int i = 0; i < limit; i++) {
      	// for (int j = 0; j < limit; j++) {
      	// SparseDoubleVector A = vecs.get(i);
      	// SparseDoubleVector B = vecs.get(j);
      	// results[i][j] = similarity(instance, A, B);
      	// }
      	// }
      	//
      	// if (instance.isCommutative()) {
      	// // triangular mirrors should be equal
      	// for (int i = 0; i < limit; i++) {
      	// for (int j = 0; j < limit; j++) {
      	// Assert.assertEquals(results[i][j], results[j][i], EPSILON);
      	// }
      	// }
      	// }
      	// }
      >>>>>>> 5f0ba9177b34449ea27dabdc17fd0793620c7d56
      
      }
      Solution content
      import uk.ac.susx.mlcl.byblo.weighings.MarginalDistribution;
      
      import java.io.IOException;
      
      import static uk.ac.susx.mlcl.TestConstants.DEFAULT_CHARSET;
      import static uk.ac.susx.mlcl.TestConstants.TEST_FRUIT_FEATURES;
      
      /**
       * @author Hamish I A Morgan <hamish.morgan@sussex.ac.uk>
       */
      public class ConfusionTest extends AbstractMeasureTest {
      
          @Override
          Class getMeasureClass() {
              return Confusion.class;
          }
      
          @Override
          String getMeasureName() {
              return "confusion";
          }
      
          @Override
          Confusion newInstance() {
              try {
                  Confusion instance = super.newInstance();
                  final DoubleEnumerating indexDelegate = new DoubleEnumeratingDelegate();
                  MarginalDistribution fmd = BybloIO
                          .readFeaturesMarginalDistribution(TEST_FRUIT_FEATURES,
                                  DEFAULT_CHARSET, EnumeratingDelegates
                                  .toSingleFeatures(indexDelegate));
                  instance.setFeatureMarginals(fmd);
      
                  return instance;
              } catch (IOException e) {
                  throw new AssertionError(e);
              }
      
          }
      
          @Test
          @Ignore
          @Override
          public void testHomoginiety() {
              throw new UnsupportedOperationException();
          }
      
          @Test
          @Ignore
          @Override
          public void testHomoginiety2() {
              throw new UnsupportedOperationException();
          }
      
          @Test
          @Ignore
          @Override
          public void testSizeOneVectors() {
              throw new UnsupportedOperationException();
          }
      
          @Test
          @Ignore
          @Override
          public void testSizeTwoVectors() {
              throw new UnsupportedOperationException();
          }
      
          @Test
          @Ignore
          @Override
          public void testCardinalityOneVectors() {
              throw new UnsupportedOperationException();
          }
      
          // @Test
          // @Override
          // public void testSizeOneVectors() {
          // System.out.println("testSizeOneVectors");
          // SparseDoubleVector A = ones(100, 1);
          // SparseDoubleVector B = ones(100, 1);
          // Confusion instance = newInstance();
          // instance.setFeatureMarginals(featureMarginals(A, B));
          // double expect = instance.getIndependenceBound();
          // double actual = similarity(instance, A, B);
          //
          // Assert.assertEquals(expect, actual, EPSILON);
          // }
          //
          // @Test
          // @Override
          // public void testSizeTwoVectors() {
          // System.out.println("testSizeTwoVectors");
          // SparseDoubleVector A = ones(100, 2);
          // SparseDoubleVector B = ones(100, 2);
          // Confusion instance = newInstance();
          // instance.setFeatureMarginals(featureMarginals(A, B));
          // double expect = instance.getIndependenceBound();
          // double actual = similarity(instance, A, B);
          //
          // Assert.assertEquals(expect, actual, EPSILON);
          // }
          //
          // @Test
          // @Override
          // public void testCardinalityOneVectors() {
          // System.out.println("testCardinalityOneVectors");
          // SparseDoubleVector A = ones(1, 1);
          // SparseDoubleVector B = ones(1, 1);
          // Confusion instance = newInstance();
          // instance.setFeatureMarginals(featureMarginals(A, B));
          // double expect = instance.getIndependenceBound();
          // double actual = similarity(instance, A, B);
          //
          // Assert.assertEquals(expect, actual, EPSILON);
          // }
      
          @Test
          @Override
          @Ignore
          public void testFruitIdentity() {
              throw new UnsupportedOperationException();
          }
      
          // @Test
          // @Override
          // public void testFruitData() throws IOException {
          // System.out.println("testFruitData");
          // int limit = 5;
          //
          // List vecs = TestConstants.loadFruitVectors();
          //
          // limit = Math.min(limit, vecs.size());
          //
          // Confusion instance = newInstance();
          // if (instance instanceof FeatureMarginalsCarrier)
          // ((FeatureMarginalsCarrier) instance)
          // .setFeatureMarginals(featureMarginals(vecs));
          //
          // final double[][] results = new double[limit][limit];
          // for (int i = 0; i < limit; i++) {
          // for (int j = 0; j < limit; j++) {
          // SparseDoubleVector A = vecs.get(i);
          // SparseDoubleVector B = vecs.get(j);
          // results[i][j] = similarity(instance, A, B);
          // }
          // }
          //
          // if (instance.isCommutative()) {
          // // triangular mirrors should be equal
          // for (int i = 0; i < limit; i++) {
          // for (int j = 0; j < limit; j++) {
          // Assert.assertEquals(results[i][j], results[j][i], EPSILON);
          // }
          // }
          // }
          // }
      
      }
      File
      ConfusionTest.java
      Developer's decision
      Manual
      Kind of conflict
      Annotation
      Attribute
      Class signature
      Comment
      If statement
      Import
      Method declaration
      Method invocation
      Method signature
      Variable
      Chunk
      Conflicting content
       */
      package uk.ac.susx.mlcl.byblo.measures.impl;
      
      <<<<<<< HEAD
      import org.junit.BeforeClass;
      import org.junit.Test;
      import uk.ac.susx.mlcl.TestConstants;
      import uk.ac.susx.mlcl.byblo.Tools;
      import uk.ac.susx.mlcl.byblo.enumerators.DoubleEnumerating;
      import uk.ac.susx.mlcl.byblo.enumerators.DoubleEnumeratingDelegate;
      import uk.ac.susx.mlcl.byblo.io.BybloIO;
      import uk.ac.susx.mlcl.byblo.io.FastWeightedTokenPairVectorSource;
      import uk.ac.susx.mlcl.lib.collect.Indexed;
      import uk.ac.susx.mlcl.lib.collect.SparseDoubleVector;
      
      import java.io.Closeable;
      import java.io.File;
      import java.io.IOException;
      import java.util.ArrayList;
      import java.util.List;
      import java.util.Random;
      
      import static org.junit.Assert.*;
      import static uk.ac.susx.mlcl.TestConstants.*;
      import static uk.ac.susx.mlcl.lib.test.ExitTrapper.disableExitTrapping;
      import static uk.ac.susx.mlcl.lib.test.ExitTrapper.enableExistTrapping;
      
      /**
       * @author Hamish I A Morgan <hamish.morgan@sussex.ac.uk>
       */
      public class CosineTest {
      
          static Cosine INSTANCE;
      
          static final double EPSILON = 0;
      
          static Random RANDOM;
      
          @BeforeClass
          public static void setUpClass() throws Exception {
              INSTANCE = new Cosine();
              RANDOM = new Random(1234);
          }
      
          @Test
          public void testCLI() throws Exception {
              System.out.println("testCLI");
      
              File output = new File(TEST_OUTPUT_DIR, FRUIT_NAME + ".Cosine");
              deleteIfExist(output);
      
              try {
                  enableExistTrapping();
                  Tools.main(new String[]{
                          "allpairs",
                          "--charset", "UTF-8",
                          "--measure", "Cosine",
                          "--input", TEST_FRUIT_EVENTS.toString(),
                          "--input-features", TEST_FRUIT_FEATURES.toString(),
                          "--input-entries", TEST_FRUIT_ENTRIES.toString(),
                          "--output", output.toString()
                  });
              } finally {
                  disableExitTrapping();
              }
      
      
              assertTrue("Output file " + output + " does not exist.", output.exists());
              assertTrue("Output file " + output + " is empty.", output.length() > 0);
          }
      
          @Test
          public void testBothEmptyVectors() throws Exception {
              System.out.println("testBothEmptyVectors");
              int size = 100;
              SparseDoubleVector A = new SparseDoubleVector(size, 0);
              SparseDoubleVector B = new SparseDoubleVector(size, 0);
              double expect = 0;
              double actual = test(A, B);
      
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testOneEmptyVector() throws Exception {
              System.out.println("testOneEmptyVector");
              int size = 100;
              SparseDoubleVector A = new SparseDoubleVector(size, 0);
              SparseDoubleVector B = new SparseDoubleVector(size, size);
              for (int i = 0; i < size; i++)
                  B.set(i, RANDOM.nextDouble());
      
              double expect = 0;
              double actual = test(A, B);
      
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testSizeOneVectors() throws Exception {
              System.out.println("testSizeOneVectors");
              int size = 100;
              SparseDoubleVector A = new SparseDoubleVector(size, 1);
              SparseDoubleVector B = new SparseDoubleVector(size, 1);
              A.set(0, 1);
              B.set(0, 1);
              double expect = INSTANCE.getHomogeneityBound();
              double actual = test(A, B);
      
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testCardinalityOneVectors() throws Exception {
              System.out.println("testCardinalityOneVectors");
              SparseDoubleVector A = new SparseDoubleVector(1, 1);
              SparseDoubleVector B = new SparseDoubleVector(1, 1);
              A.set(0, 1);
              B.set(0, 1);
              double expect = 1;
              double actual = test(A, B);
      
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testSizeTwoVectors() throws Exception {
              System.out.println("testSizeTwoVectors");
              int size = 100;
              SparseDoubleVector A = new SparseDoubleVector(size, 2);
              SparseDoubleVector B = new SparseDoubleVector(size, 2);
              A.set(0, 1);
              A.set(1, 1);
              B.set(0, 1);
              B.set(1, 1);
              double expect = INSTANCE.getHomogeneityBound();
              double actual = test(A, B);
      
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testCommutative() throws Exception {
              System.out.println("testCommutative");
              int size = 100;
              SparseDoubleVector A = new SparseDoubleVector(size, size);
              SparseDoubleVector B = new SparseDoubleVector(size, size);
              for (int i = 0; i < size; i++) {
                  A.set(i, RANDOM.nextDouble());
                  B.set(i, RANDOM.nextDouble());
              }
      
              double expect = test(A, B);
              double actual = test(B, A);
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testHomoginiety() throws Exception {
              System.out.println("testHomoginiety");
              int size = 100;
              SparseDoubleVector A = new SparseDoubleVector(size, size);
              SparseDoubleVector B = new SparseDoubleVector(size, size);
              for (int i = 0; i < size; i++) {
                  double value = RANDOM.nextDouble();
                  A.set(i, value);
                  B.set(i, value);
              }
      
              double expect = INSTANCE.getHomogeneityBound();
              double actual = test(A, B);
      
              assertEquals(expect, actual, EPSILON);
          }
      =======
      import static org.junit.Assert.assertEquals;
      
      import org.junit.Test;
      
      import uk.ac.susx.mlcl.lib.collect.SparseDoubleVector;
      
      /**
       * 
       * @author Hamish I A Morgan <hamish.morgan@sussex.ac.uk>
       */
      public class CosineTest extends AbstractMeasureTest {
      >>>>>>> 5f0ba9177b34449ea27dabdc17fd0793620c7d56
      
      	@Override
      	Class getMeasureClass() {
      Solution content
       */
      package uk.ac.susx.mlcl.byblo.measures.impl;
      
      import static org.junit.Assert.assertEquals;
      
      import org.junit.Test;
      
      import uk.ac.susx.mlcl.lib.collect.SparseDoubleVector;
      
      /**
       * 
       * @author Hamish I A Morgan <hamish.morgan@sussex.ac.uk>
       */
      public class CosineTest extends AbstractMeasureTest {
      
      	@Override
      	Class getMeasureClass() {
      File
      CosineTest.java
      Developer's decision
      Version 2
      Kind of conflict
      Annotation
      Attribute
      Class signature
      Comment
      Import
      Method declaration
      Chunk
      Conflicting content
          @Test
       */
      package uk.ac.susx.mlcl.byblo.measures.impl;
      
      <<<<<<< HEAD
      import org.junit.BeforeClass;
      import org.junit.Test;
      import uk.ac.susx.mlcl.TestConstants;
      import uk.ac.susx.mlcl.byblo.Tools;
      import uk.ac.susx.mlcl.lib.collect.Indexed;
      import uk.ac.susx.mlcl.lib.collect.SparseDoubleVector;
      
      import java.io.Closeable;
      import java.io.File;
      import java.io.IOException;
      import java.util.ArrayList;
      import java.util.List;
      import java.util.Random;
      
      import static org.junit.Assert.*;
      import static uk.ac.susx.mlcl.TestConstants.*;
      import static uk.ac.susx.mlcl.lib.test.ExitTrapper.disableExitTrapping;
      import static uk.ac.susx.mlcl.lib.test.ExitTrapper.enableExistTrapping;
      
      /**
       * @author Hamish I A Morgan <hamish.morgan@sussex.ac.uk>
       */
      public class DiceTest {
      
          static Dice INSTANCE;
      
          static final double EPSILON = 0;
      
          static Random RANDOM;
      
          @BeforeClass
          public static void setUpClass() throws Exception {
              INSTANCE = new Dice();
              RANDOM = new Random(1234);
          }
      
          @Test
          public void testCLI() throws Exception {
              System.out.println("testCLI");
      
              File output = new File(TEST_OUTPUT_DIR, FRUIT_NAME + ".Dice");
              deleteIfExist(output);
      
              try {
                  enableExistTrapping();
                  Tools.main(new String[]{
                          "allpairs",
                          "--charset", "UTF-8",
                          "--measure", "Dice",
                          "--input", TEST_FRUIT_EVENTS.toString(),
                          "--input-features", TEST_FRUIT_FEATURES.toString(),
                          "--input-entries", TEST_FRUIT_ENTRIES.toString(),
                          "--output", output.toString()
                  });
              } finally {
                  disableExitTrapping();
              }
      
      
              assertTrue("Output file " + output + " does not exist.", output.exists());
              assertTrue("Output file " + output + " is empty.", output.length() > 0);
          }
      
          @Test
          public void testBothEmptyVectors() throws Exception {
              System.out.println("testBothEmptyVectors");
              int size = 100;
              SparseDoubleVector A = new SparseDoubleVector(size, 0);
              SparseDoubleVector B = new SparseDoubleVector(size, 0);
              double expect = 0;
              double actual = test(A, B);
      
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testOneEmptyVector() throws Exception {
              System.out.println("testOneEmptyVector");
              int size = 100;
              SparseDoubleVector A = new SparseDoubleVector(size, 0);
              SparseDoubleVector B = new SparseDoubleVector(size, size);
              for (int i = 0; i < size; i++)
                  B.set(i, RANDOM.nextDouble());
      
              double expect = 0;
              double actual = test(A, B);
      
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testSizeOneVectors() throws Exception {
              System.out.println("testSizeOneVectors");
              int size = 100;
              SparseDoubleVector A = new SparseDoubleVector(size, 1);
              SparseDoubleVector B = new SparseDoubleVector(size, 1);
              A.set(0, 1);
              B.set(0, 1);
              double expect = INSTANCE.getHomogeneityBound();
              double actual = test(A, B);
      
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testCardinalityOneVectors() throws Exception {
              System.out.println("testCardinalityOneVectors");
              SparseDoubleVector A = new SparseDoubleVector(1, 1);
              SparseDoubleVector B = new SparseDoubleVector(1, 1);
              A.set(0, 1);
              B.set(0, 1);
              double expect = 1;
              double actual = test(A, B);
      
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testSizeTwoVectors() throws Exception {
              System.out.println("testSizeTwoVectors");
              int size = 100;
              SparseDoubleVector A = new SparseDoubleVector(size, 2);
              SparseDoubleVector B = new SparseDoubleVector(size, 2);
              A.set(0, 1);
              A.set(1, 1);
              B.set(0, 1);
              B.set(1, 1);
              double expect = INSTANCE.getHomogeneityBound();
              double actual = test(A, B);
      
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testCommutative() throws Exception {
              System.out.println("testCommutative");
              int size = 100;
              SparseDoubleVector A = new SparseDoubleVector(size, size);
              SparseDoubleVector B = new SparseDoubleVector(size, size);
              for (int i = 0; i < size; i++) {
                  A.set(i, RANDOM.nextDouble());
                  B.set(i, RANDOM.nextDouble());
              }
      
              double expect = test(A, B);
              double actual = test(B, A);
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testHomoginiety() throws Exception {
              System.out.println("testHomoginiety");
              int size = 100;
              SparseDoubleVector A = new SparseDoubleVector(size, size);
              SparseDoubleVector B = new SparseDoubleVector(size, size);
              for (int i = 0; i < size; i++) {
                  double value = RANDOM.nextDouble();
                  A.set(i, value);
                  B.set(i, value);
              }
      
              double expect = INSTANCE.getHomogeneityBound();
              double actual = test(A, B);
      
              assertEquals(expect, actual, EPSILON);
          }
      
          public void testHeteroginiety() throws Exception {
              System.out.println("testHeteroginiety");
              int size = 100;
              SparseDoubleVector A = new SparseDoubleVector(size, size);
              SparseDoubleVector B = new SparseDoubleVector(size, size);
              for (int i = 0; i < size / 2; i++) {
                  A.set(i * 2, i);
                  B.set(i * 2 + 1, i);
              }
      
              double expect = INSTANCE.getHeterogeneityBound();
              double actual = test(A, B);
      
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testFruitData() throws Exception {
              System.out.println("testFruitData");
              int limit = 5;
      
              List> vecs = TestConstants
                      .loadFruitVectors();
      
              limit = Math.min(limit, vecs.size());
      
              final double[][] results = new double[limit][limit];
              for (int i = 0; i < limit; i++) {
                  for (int j = 0; j < limit; j++) {
                      SparseDoubleVector A = vecs.get(i).value();
                      SparseDoubleVector B = vecs.get(j).value();
                      results[i][j] = test(A, B);
                  }
              }
      
              // diagonals should all be +1
              for (int i = 0; i < limit; i++) {
                  assertEquals(INSTANCE.getHomogeneityBound(), results[i][i], EPSILON);
              }
              // triangular mirrors should be equal
              for (int i = 0; i < limit; i++) {
                  for (int j = 0; j < limit; j++) {
                      assertEquals(results[i][j], results[j][i], EPSILON);
                  }
              }
          }
      =======
      
      /**
       * 
       * @author Hamish I A Morgan <hamish.morgan@sussex.ac.uk>
       */
      public class DiceTest extends AbstractMeasureTest {
      >>>>>>> 5f0ba9177b34449ea27dabdc17fd0793620c7d56
      
      	@Override
      	Class getMeasureClass() {
      Solution content
       */
      package uk.ac.susx.mlcl.byblo.measures.impl;
      
      
      /**
       * 
       * @author Hamish I A Morgan <hamish.morgan@sussex.ac.uk>
       */
      public class DiceTest extends AbstractMeasureTest {
      
      	@Override
      	Class getMeasureClass() {
      File
      DiceTest.java
      Developer's decision
      Version 2
      Kind of conflict
      Annotation
      Attribute
      Class signature
      Comment
      Import
      Method declaration
      Chunk
      Conflicting content
      		return "dice";
      	}
      
      <<<<<<< HEAD
          public double test(SparseDoubleVector A, SparseDoubleVector B) {
              final double val = INSTANCE.similarity(A, B);
              assertFalse("Similarity is NaN", Double.isNaN(val));
              assertFalse("Similarity is " + val, Double.isInfinite(val));
              assertTrue("Similarity < -1", val >= INSTANCE.getHeterogeneityBound());
              assertTrue("Similarity > +1", val <= INSTANCE.getHomogeneityBound());
              return val;
          }
      
      =======
      >>>>>>> 5f0ba9177b34449ea27dabdc17fd0793620c7d56
      }
      Solution content
      		return "dice";
      	}
      
      }
      File
      DiceTest.java
      Developer's decision
      Version 2
      Kind of conflict
      Method declaration
      Chunk
      Conflicting content
          }
              A.set(1, 1);
                  Tools.main(new String[]{
       */
      package uk.ac.susx.mlcl.byblo.measures.impl;
      
      <<<<<<< HEAD
      import org.junit.BeforeClass;
      import org.junit.Test;
      import uk.ac.susx.mlcl.TestConstants;
      import uk.ac.susx.mlcl.byblo.Tools;
      import uk.ac.susx.mlcl.byblo.enumerators.DoubleEnumerating;
      import uk.ac.susx.mlcl.byblo.enumerators.DoubleEnumeratingDelegate;
      import uk.ac.susx.mlcl.byblo.io.BybloIO;
      import uk.ac.susx.mlcl.byblo.io.FastWeightedTokenPairVectorSource;
      import uk.ac.susx.mlcl.lib.collect.Indexed;
      import uk.ac.susx.mlcl.lib.collect.SparseDoubleVector;
      
      import java.io.Closeable;
      import java.io.File;
      import java.util.ArrayList;
      import java.util.List;
      import java.util.Random;
      
      import static org.junit.Assert.*;
      import static uk.ac.susx.mlcl.TestConstants.*;
      import static uk.ac.susx.mlcl.lib.test.ExitTrapper.disableExitTrapping;
      import static uk.ac.susx.mlcl.lib.test.ExitTrapper.enableExistTrapping;
      
      /**
              B.set(0, 1);
       * @author Hamish I A Morgan <hamish.morgan@sussex.ac.uk>
       */
      public class DotProductTest {
      
          static DotProduct INSTANCE;
      
          static final double EPSILON = 0;
      
          static Random RANDOM;
      
          @BeforeClass
          public static void setUpClass() throws Exception {
              INSTANCE = new DotProduct();
              RANDOM = new Random(1234);
          }
      
          @Test
          public void testCLI() throws Exception {
              System.out.println("testCLI");
      
              File output = new File(TEST_OUTPUT_DIR, FRUIT_NAME + ".DotProduct");
              deleteIfExist(output);
      
              try {
                  enableExistTrapping();
                          "allpairs",
                          "--charset", "UTF-8",
                          "--measure", "dp",
                          "--input", TEST_FRUIT_EVENTS.toString(),
                          "--input-features", TEST_FRUIT_FEATURES.toString(),
                          "--input-entries", TEST_FRUIT_ENTRIES.toString(),
                          "--output", output.toString()
                  });
              } finally {
                  disableExitTrapping();
              }
      
      
              assertTrue("Output file " + output + " does not exist.", output.exists());
              assertTrue("Output file " + output + " is empty.", output.length() > 0);
          }
      
          @Test
          public void testBothEmptyVectors() throws Exception {
              System.out.println("testBothEmptyVectors");
              int size = 100;
              SparseDoubleVector A = new SparseDoubleVector(size, 0);
              SparseDoubleVector B = new SparseDoubleVector(size, 0);
              double expect = 0;
              double actual = test(A, B);
      
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testOneEmptyVector() throws Exception {
              System.out.println("testOneEmptyVector");
              int size = 100;
              SparseDoubleVector A = new SparseDoubleVector(size, 0);
              SparseDoubleVector B = new SparseDoubleVector(size, size);
              for (int i = 0; i < size; i++)
                  B.set(i, RANDOM.nextDouble());
      
              double expect = 0;
              double actual = test(A, B);
      
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testSizeOneVectors() throws Exception {
              System.out.println("testSizeOneVectors");
              int size = 100;
              SparseDoubleVector A = new SparseDoubleVector(size, 1);
              SparseDoubleVector B = new SparseDoubleVector(size, 1);
              A.set(0, 1);
              B.set(0, 1);
              double expect = 1;
              double actual = test(A, B);
      
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testCardinalityOneVectors() throws Exception {
              System.out.println("testCardinalityOneVectors");
              SparseDoubleVector A = new SparseDoubleVector(1, 1);
              SparseDoubleVector B = new SparseDoubleVector(1, 1);
              A.set(0, 1);
              B.set(0, 1);
              double expect = 1;
              double actual = test(A, B);
      
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testSizeTwoVectors() throws Exception {
              System.out.println("testSizeTwoVectors");
              int size = 100;
              SparseDoubleVector A = new SparseDoubleVector(size, 2);
              SparseDoubleVector B = new SparseDoubleVector(size, 2);
              A.set(0, 1);
              B.set(1, 1);
              double expect = 2;
              double actual = test(A, B);
      
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testCommutative() throws Exception {
              System.out.println("testCommutative");
              int size = 100;
              SparseDoubleVector A = new SparseDoubleVector(size, size);
              SparseDoubleVector B = new SparseDoubleVector(size, size);
              for (int i = 0; i < size; i++) {
                  A.set(i, RANDOM.nextDouble());
                  B.set(i, RANDOM.nextDouble());
              }
      
              double expect = test(A, B);
              double actual = test(B, A);
              assertEquals(expect, actual, EPSILON);
      
          @Test
          public void testHeteroginiety() throws Exception {
              System.out.println("testHeteroginiety");
              int size = 100;
              SparseDoubleVector A = new SparseDoubleVector(size, size);
              SparseDoubleVector B = new SparseDoubleVector(size, size);
              for (int i = 0; i < size / 2; i++) {
                  A.set(i * 2, i);
                  B.set(i * 2 + 1, i);
              }
      
              double expect = 0;
              double actual = test(A, B);
      
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testFruitData() throws Exception {
              System.out.println("testFruitData");
              int limit = 5;
      
              List> vecs = TestConstants.loadFruitVectors();
      
              limit = Math.min(limit, vecs.size());
      
              final double[][] results = new double[limit][limit];
              for (int i = 0; i < limit; i++) {
                  for (int j = 0; j < limit; j++) {
                      SparseDoubleVector A = vecs.get(i).value();
                      SparseDoubleVector B = vecs.get(j).value();
                      results[i][j] = test(A, B);
                  }
              }
      
              // triangular mirrors should be equal
              for (int i = 0; i < limit; i++) {
                  for (int j = 0; j < limit; j++) {
                      assertEquals(results[i][j], results[j][i], EPSILON);
                  }
              }
          }
      
          @Test
          public void testLargeCardinality() throws Exception {
              System.out.println("testLargeCardinality");
              final int size = 100;
              final SparseDoubleVector A = new SparseDoubleVector(
                      Integer.MAX_VALUE, size);
              final SparseDoubleVector B = new SparseDoubleVector(
                      Integer.MAX_VALUE, size);
              for (int i = 0; i < size; i++) {
                  A.set(RANDOM.nextInt(size * 2), RANDOM.nextDouble());
                  B.set(RANDOM.nextInt(size * 2), RANDOM.nextDouble());
              }
      
              test(A, B);
          }
      
          public double test(SparseDoubleVector A, SparseDoubleVector B) {
              final double val = INSTANCE.similarity(A, B);
              assertFalse("Similarity is NaN" + " with measure " + INSTANCE,
                      Double.isNaN(val));
              assertFalse("Similarity is " + val + " with measure " + INSTANCE,
                      Double.isInfinite(val));
      
              final double min, max;
              if (INSTANCE.getHeterogeneityBound() < INSTANCE.getHomogeneityBound()) {
                  min = INSTANCE.getHeterogeneityBound();
                  max = INSTANCE.getHomogeneityBound();
              } else {
                  min = INSTANCE.getHomogeneityBound();
                  max = INSTANCE.getHeterogeneityBound();
              }
              assertTrue("expected similarity >= " + min + " but found " + val,
                      val >= min);
              assertTrue("expected similarity <= " + max + " but found " + val,
                      val <= max);
      
      
              if (INSTANCE.isCommutative()) {
                  final double rev = INSTANCE.similarity(B, A);
                  assertEquals("Measure is declared computative, but reversing "
                          + "operands results in a different score.", rev, val,
                          EPSILON);
              }
      
              return val;
          }
      =======
      import static org.junit.Assert.assertEquals;
      import junit.framework.Assert;
      
      import org.junit.Ignore;
      import org.junit.Test;
      
      import uk.ac.susx.mlcl.byblo.measures.Measure;
      import uk.ac.susx.mlcl.lib.collect.SparseDoubleVector;
      
      /**
       * 
       * @author Hamish I A Morgan <hamish.morgan@sussex.ac.uk>
       */
      public class DotProductTest extends AbstractMeasureTest {
      
      	@Override
      	Class getMeasureClass() {
      		return DotProduct.class;
      	}
      
      	@Override
      	String getMeasureName() {
      		return "dp";
      	}
      
      	/**
      	 * Identity score varies bases on vector magnitude so homogeneity bound
      	 * can't be reached.
      	 */
      	@Test
      	@Override
      	public void testSizeOneVectors() {
      		System.out.println("testSizeOneVectors");
      
      		final int size = 100;
      		final SparseDoubleVector A = new SparseDoubleVector(size, 1);
      		final SparseDoubleVector B = new SparseDoubleVector(size, 1);
      		A.set(0, 1);
      		B.set(0, 1);
      		final double expect = 1; // newInstance().getHomogeneityBound();
      		final double actual = similarity(newInstance(), A, B);
      		Assert.assertEquals(expect, actual, EPSILON);
      	}
      
      	/**
      	 * Identity score varies bases on vector magnitude so homogeneity bound
      	 * can't be reached.
      	 */
      	@Test
      	@Override
      	public void testSizeTwoVectors() {
      		System.out.println("testSizeTwoVectors");
      		int size = 100;
      		SparseDoubleVector A = new SparseDoubleVector(size, 2);
      		SparseDoubleVector B = new SparseDoubleVector(size, 2);
      		A.set(0, 1);
      		A.set(1, 1);
      		B.set(0, 1);
      		B.set(1, 1);
      		double expect = 2; // newInstance().getHomogeneityBound();
      		double actual = similarity(newInstance(), A, B);
      
      		Assert.assertEquals(expect, actual, EPSILON);
      	}
      
      	@Test
      	@Override
      	public void testCardinalityOneVectors() {
      		System.out.println("testCardinalityOneVectors");
      		SparseDoubleVector A = new SparseDoubleVector(1, 1);
      		SparseDoubleVector B = new SparseDoubleVector(1, 1);
      		A.set(0, 1);
      		B.set(0, 1);
      		Measure instance = newInstance();
      		double expect = 1; //instance.getHomogeneityBound();
      		double actual = similarity(instance, A, B);
      
      		Assert.assertEquals(expect, actual, EPSILON);
      	}
      
      	
      	/**
      	 * Identity score varies bases on vector magnitude so homogeneity bound
      	 * can't be reached.
      	 */
      	@Test
      	@Ignore
      	@Override
      	public void testHomoginiety() {
      		throw new UnsupportedOperationException();
      	}
      	/**
      	 * Identity score varies bases on vector magnitude so homogeneity bound
      	 * can't be reached.
      	 */
      	@Test
      	@Ignore
      	@Override
      	public void testHomoginiety2() {
      		throw new UnsupportedOperationException();
      	}
      
      	/**
      	 * Identity score varies bases on vector magnitude so homogeneity bound
      	 * can't be reached.
      	 */
      	@Test
      	@Ignore
      	@Override
      	public void testHeteroginiety() {
      		throw new UnsupportedOperationException();
      	}
      
      
      	/**
      	 * Identity score varies bases on vector magnitude so homogeneity bound
      	 * can't be reached.
      	 */
      	@Test
      	@Ignore
      	@Override
      	public void testFruitIdentity() {
      		throw new UnsupportedOperationException();
      	}
      
      	@Test
      	public void testAgainReferenceImplementation() throws Exception {
      		System.out.println("testAgainReferenceImplementation()");
      		
      		final double[] arr1 = new double[] { 0, 1, 0, 3, 0, 8, 0, 3, 0, 6, 0, 2 };
      		final double[] arr2 = new double[] { 6, 2, 0, 4, 5, 1, 9, 0, 5, 2, 0, 0 };
      
      		double expected = 0;
      		for(int i = 0 ; i < arr1.length; i++) 
      			expected += arr1[i] * arr2[i];
      
      		
      		SparseDoubleVector vec1 = new SparseDoubleVector(arr1.length);
      		SparseDoubleVector vec2 = new SparseDoubleVector(arr2.length);
      		
      		for(int i = 0 ; i < arr1.length; i++) {
      			vec1.set(i, arr1[i]);
      			vec2.set(i, arr2[i]);
      		}
      
      		final double actual = similarity(new DotProduct(), vec1, vec2);
      		
      		assertEquals(expected, actual, EPSILON);
      	}
      >>>>>>> 5f0ba9177b34449ea27dabdc17fd0793620c7d56
      
      }
      Solution content
       */
      package uk.ac.susx.mlcl.byblo.measures.impl;
      
      import static org.junit.Assert.assertEquals;
      import junit.framework.Assert;
      
      import org.junit.Ignore;
      import org.junit.Test;
      
      import uk.ac.susx.mlcl.byblo.measures.Measure;
      import uk.ac.susx.mlcl.lib.collect.SparseDoubleVector;
      
      /**
       * 
       * @author Hamish I A Morgan <hamish.morgan@sussex.ac.uk>
       */
      public class DotProductTest extends AbstractMeasureTest {
      
      	@Override
      	Class getMeasureClass() {
      		return DotProduct.class;
      	}
      
      	@Override
      	String getMeasureName() {
      		return "dp";
      	}
      
      	/**
      	 * Identity score varies bases on vector magnitude so homogeneity bound
      	 * can't be reached.
      	 */
      	@Test
      	@Override
      	public void testSizeOneVectors() {
      		System.out.println("testSizeOneVectors");
      
      		final int size = 100;
      		final SparseDoubleVector A = new SparseDoubleVector(size, 1);
      		final SparseDoubleVector B = new SparseDoubleVector(size, 1);
      		A.set(0, 1);
      		B.set(0, 1);
      		final double expect = 1; // newInstance().getHomogeneityBound();
      		final double actual = similarity(newInstance(), A, B);
      		Assert.assertEquals(expect, actual, EPSILON);
      	}
      
      	/**
      	 * Identity score varies bases on vector magnitude so homogeneity bound
      	 * can't be reached.
      	 */
      	@Test
      	@Override
      	public void testSizeTwoVectors() {
      		System.out.println("testSizeTwoVectors");
      		int size = 100;
      		SparseDoubleVector A = new SparseDoubleVector(size, 2);
      		SparseDoubleVector B = new SparseDoubleVector(size, 2);
      		A.set(0, 1);
      		A.set(1, 1);
      		B.set(0, 1);
      		B.set(1, 1);
      		double expect = 2; // newInstance().getHomogeneityBound();
      		double actual = similarity(newInstance(), A, B);
      
      		Assert.assertEquals(expect, actual, EPSILON);
      	}
      
      	@Test
      	@Override
      	public void testCardinalityOneVectors() {
      		System.out.println("testCardinalityOneVectors");
      		SparseDoubleVector A = new SparseDoubleVector(1, 1);
      		SparseDoubleVector B = new SparseDoubleVector(1, 1);
      		A.set(0, 1);
      		B.set(0, 1);
      		Measure instance = newInstance();
      		double expect = 1; //instance.getHomogeneityBound();
      		double actual = similarity(instance, A, B);
      
      		Assert.assertEquals(expect, actual, EPSILON);
      	}
      
      	
      	/**
      	 * Identity score varies bases on vector magnitude so homogeneity bound
      	 * can't be reached.
      	 */
      	@Test
      	@Ignore
      	@Override
      	public void testHomoginiety() {
      		throw new UnsupportedOperationException();
      	}
      	/**
      	 * Identity score varies bases on vector magnitude so homogeneity bound
      	 * can't be reached.
      	 */
      	@Test
      	@Ignore
      	@Override
      	public void testHomoginiety2() {
      		throw new UnsupportedOperationException();
      	}
      
      	/**
      	 * Identity score varies bases on vector magnitude so homogeneity bound
      	 * can't be reached.
      	 */
      	@Test
      	@Ignore
      	@Override
      	public void testHeteroginiety() {
      		throw new UnsupportedOperationException();
      	}
      
      
      	/**
      	 * Identity score varies bases on vector magnitude so homogeneity bound
      	 * can't be reached.
      	 */
      	@Test
      	@Ignore
      	@Override
      	public void testFruitIdentity() {
      		throw new UnsupportedOperationException();
      	}
      
      	@Test
      	public void testAgainReferenceImplementation() throws Exception {
      		System.out.println("testAgainReferenceImplementation()");
      		
      		final double[] arr1 = new double[] { 0, 1, 0, 3, 0, 8, 0, 3, 0, 6, 0, 2 };
      		final double[] arr2 = new double[] { 6, 2, 0, 4, 5, 1, 9, 0, 5, 2, 0, 0 };
      
      		double expected = 0;
      		for(int i = 0 ; i < arr1.length; i++) 
      			expected += arr1[i] * arr2[i];
      
      		
      		SparseDoubleVector vec1 = new SparseDoubleVector(arr1.length);
      		SparseDoubleVector vec2 = new SparseDoubleVector(arr2.length);
      		
      		for(int i = 0 ; i < arr1.length; i++) {
      			vec1.set(i, arr1[i]);
      			vec2.set(i, arr2[i]);
      		}
      
      		final double actual = similarity(new DotProduct(), vec1, vec2);
      		
      		assertEquals(expected, actual, EPSILON);
      	}
      
      }
      File
      DotProductTest.java
      Developer's decision
      Version 2
      Kind of conflict
      Annotation
      Attribute
      Class signature
      Comment
      Import
      Method declaration
      Chunk
      Conflicting content
       */
      package uk.ac.susx.mlcl.byblo.measures.impl;
      
      <<<<<<< HEAD
      import org.junit.BeforeClass;
      import org.junit.Test;
      import uk.ac.susx.mlcl.TestConstants;
      import uk.ac.susx.mlcl.byblo.Tools;
      import uk.ac.susx.mlcl.byblo.enumerators.DoubleEnumerating;
      import uk.ac.susx.mlcl.byblo.enumerators.DoubleEnumeratingDelegate;
      import uk.ac.susx.mlcl.byblo.io.BybloIO;
      import uk.ac.susx.mlcl.byblo.io.FastWeightedTokenPairVectorSource;
      import uk.ac.susx.mlcl.lib.collect.Indexed;
      import uk.ac.susx.mlcl.lib.collect.SparseDoubleVector;
      
      import java.io.Closeable;
      import java.io.File;
      import java.io.IOException;
      import java.util.ArrayList;
      import java.util.List;
      import java.util.Random;
      
      import static org.junit.Assert.*;
      import static uk.ac.susx.mlcl.TestConstants.*;
      import static uk.ac.susx.mlcl.lib.test.ExitTrapper.disableExitTrapping;
      import static uk.ac.susx.mlcl.lib.test.ExitTrapper.enableExistTrapping;
      
      /**
       * @author Hamish I A Morgan <hamish.morgan@sussex.ac.uk>
       */
      public class HindleTest {
      
          static Hindle INSTANCE;
      
          static final double EPSILON = 0;
      
          static Random RANDOM;
      
          @BeforeClass
          public static void setUpClass() throws Exception {
              INSTANCE = new Hindle();
              RANDOM = new Random(1234);
          }
      
          @Test
          public void testCLI() throws Exception {
              System.out.println("testCLI");
      
              File output = new File(TEST_OUTPUT_DIR, FRUIT_NAME + ".Hindle");
              deleteIfExist(output);
      
              try {
                  enableExistTrapping();
                  Tools.main(new String[]{
                          "allpairs",
                          "--charset", "UTF-8",
                          "--measure", "hindle",
                          "--input", TEST_FRUIT_EVENTS.toString(),
                          "--input-features", TEST_FRUIT_FEATURES.toString(),
                          "--input-entries", TEST_FRUIT_ENTRIES.toString(),
                          "--output", output.toString()
                  });
              } finally {
                  disableExitTrapping();
              }
      
      
              assertTrue("Output file " + output + " does not exist.", output.exists());
              assertTrue("Output file " + output + " is empty.", output.length() > 0);
          }
      
          @Test
          public void testBothEmptyVectors() throws Exception {
              System.out.println("testBothEmptyVectors");
              int limit = 5;
              int size = 100;
              SparseDoubleVector A = new SparseDoubleVector(size, 0);
              SparseDoubleVector B = new SparseDoubleVector(size, 0);
              double expect = 0;
              double actual = test(A, B);
      
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testOneEmptyVector() throws Exception {
              System.out.println("testOneEmptyVector");
              int size = 100;
              SparseDoubleVector A = new SparseDoubleVector(size, 0);
              SparseDoubleVector B = new SparseDoubleVector(size, size);
              for (int i = 0; i < size; i++)
                  B.set(i, RANDOM.nextDouble());
      
              double expect = 0;
              double actual = test(A, B);
      
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testSizeOneVectors() throws Exception {
              System.out.println("testSizeOneVectors");
              int size = 100;
              SparseDoubleVector A = new SparseDoubleVector(size, 1);
              SparseDoubleVector B = new SparseDoubleVector(size, 1);
              A.set(0, 1);
              B.set(0, 1);
              double expect = 1;
              double actual = test(A, B);
      
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testCardinalityOneVectors() throws Exception {
              System.out.println("testCardinalityOneVectors");
              SparseDoubleVector A = new SparseDoubleVector(1, 1);
              SparseDoubleVector B = new SparseDoubleVector(1, 1);
              A.set(0, 1);
              B.set(0, 1);
              double expect = 1;
              double actual = test(A, B);
      
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testSizeTwoVectors() throws Exception {
              System.out.println("testSizeTwoVectors");
              int size = 100;
              SparseDoubleVector A = new SparseDoubleVector(size, 2);
              SparseDoubleVector B = new SparseDoubleVector(size, 2);
              A.set(0, 1);
              A.set(1, 1);
              B.set(0, 1);
              B.set(1, 1);
              double expect = 2;
              double actual = test(A, B);
      
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testCommutative() throws Exception {
              System.out.println("testCommutative");
              int size = 100;
              SparseDoubleVector A = new SparseDoubleVector(size, size);
              SparseDoubleVector B = new SparseDoubleVector(size, size);
              for (int i = 0; i < size; i++) {
                  A.set(i, RANDOM.nextDouble());
                  B.set(i, RANDOM.nextDouble());
              }
      
              double expect = test(A, B);
              double actual = test(B, A);
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testHeteroginiety() throws Exception {
              System.out.println("testHeteroginiety");
              int size = 100;
              SparseDoubleVector A = new SparseDoubleVector(size, size);
              SparseDoubleVector B = new SparseDoubleVector(size, size);
              for (int i = 0; i < size / 2; i++) {
                  A.set(i * 2, i);
                  B.set(i * 2 + 1, i);
              }
      
              double expect = INSTANCE.getHeterogeneityBound();
              double actual = test(A, B);
      
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testFruitData() throws Exception {
              System.out.println("testFruitData");
      
              List> vecs = TestConstants.loadFruitVectors();
      
              limit = Math.min(limit, vecs.size());
      
              final double[][] results = new double[limit][limit];
              for (int i = 0; i < limit; i++) {
                  for (int j = 0; j < limit; j++) {
                      SparseDoubleVector A = vecs.get(i).value();
                      SparseDoubleVector B = vecs.get(j).value();
                      results[i][j] = test(A, B);
                  }
              }
      
              // triangular mirrors should be equal
              for (int i = 0; i < limit; i++) {
                  for (int j = 0; j < limit; j++) {
                      assertEquals(results[i][j], results[j][i], EPSILON);
                  }
              }
          }
      
          @Test
          public void testLargeCardinality() throws Exception {
              System.out.println("testLargeCardinality");
              final int size = 100;
              final SparseDoubleVector A = new SparseDoubleVector(
                      Integer.MAX_VALUE, size);
              final SparseDoubleVector B = new SparseDoubleVector(
                      Integer.MAX_VALUE, size);
              for (int i = 0; i < size; i++) {
                  A.set(RANDOM.nextInt(size * 2), RANDOM.nextDouble());
                  B.set(RANDOM.nextInt(size * 2), RANDOM.nextDouble());
              }
      
              test(A, B);
          }
      
          public double test(SparseDoubleVector A, SparseDoubleVector B) {
              final double val = INSTANCE.similarity(A, B);
              assertFalse("Similarity is NaN", Double.isNaN(val));
              assertFalse("Similarity is " + val, Double.isInfinite(val));
              assertTrue("Similarity < -1", val >= INSTANCE.getHeterogeneityBound());
              assertTrue("Similarity > +1", val <= INSTANCE.getHomogeneityBound());
              return val;
          }
      
          static List> loadFruitVectors() throws IOException {
      
              final DoubleEnumerating indexDelegate = new DoubleEnumeratingDelegate();
              final FastWeightedTokenPairVectorSource eventSrc =
                      BybloIO.openEventsVectorSource(
                              TEST_FRUIT_EVENTS, DEFAULT_CHARSET, indexDelegate);
              final List> vecs =
                      new ArrayList>();
              while (eventSrc.hasNext())
                  vecs.add(eventSrc.read());
      
              if (eventSrc instanceof Closeable) {
                  ((Closeable) eventSrc).close();
              }
      
              return vecs;
          }
      =======
      import junit.framework.Assert;
      
      import org.junit.Ignore;
      import org.junit.Test;
      
      import uk.ac.susx.mlcl.byblo.measures.Measure;
      import uk.ac.susx.mlcl.lib.collect.SparseDoubleVector;
      
      /**
       * 
       * @author Hamish I A Morgan <hamish.morgan@sussex.ac.uk>
       */
      public class HindleTest extends AbstractMeasureTest {
      
      	@Override
      	Class getMeasureClass() {
      		return Hindle.class;
      	}
      
      	@Override
      	String getMeasureName() {
      		return "hindle";
      	}
      
      	/**
      	 * Identity score varies bases on vector magnitude so homogeneity bound
      	 * can't be reached.
      	 */
      	@Test
      	@Override
      	public void testSizeOneVectors() {
      		System.out.println("testSizeOneVectors");
      
      		final int size = 100;
      		final SparseDoubleVector A = new SparseDoubleVector(size, 1);
      		final SparseDoubleVector B = new SparseDoubleVector(size, 1);
      		A.set(0, 1);
      		B.set(0, 1);
      		final double expect = 1; // newInstance().getHomogeneityBound();
      		final double actual = similarity(newInstance(), A, B);
      		Assert.assertEquals(expect, actual, EPSILON);
      	}
      
      	/**
      	 * Identity score varies bases on vector magnitude so homogeneity bound
      	 * can't be reached.
      	 */
      	@Test
      	@Override
      	public void testSizeTwoVectors() {
      		System.out.println("testSizeTwoVectors");
      		int size = 100;
      		SparseDoubleVector A = new SparseDoubleVector(size, 2);
      		SparseDoubleVector B = new SparseDoubleVector(size, 2);
      		A.set(0, 1);
      		A.set(1, 1);
      		B.set(0, 1);
      		B.set(1, 1);
      		double expect = 2; // newInstance().getHomogeneityBound();
      		double actual = similarity(newInstance(), A, B);
      
      		Assert.assertEquals(expect, actual, EPSILON);
      	}
      
      	@Test
      	@Override
      	public void testCardinalityOneVectors() {
      		System.out.println("testCardinalityOneVectors");
      		SparseDoubleVector A = new SparseDoubleVector(1, 1);
      		SparseDoubleVector B = new SparseDoubleVector(1, 1);
      		A.set(0, 1);
      		B.set(0, 1);
      		Measure instance = newInstance();
      		double expect = 1;
      		double actual = similarity(instance, A, B);
      
      		Assert.assertEquals(expect, actual, EPSILON);
      	}
      
      	/**
      	 * Identity score varies bases on vector magnitude so homogeneity bound
      	 * can't be reached.
      	 */
      	@Test
      	@Ignore
      	@Override
      	public void testHomoginiety() {
      		throw new UnsupportedOperationException();
      	}
      	/**
      	 * Identity score varies bases on vector magnitude so homogeneity bound
      	 * can't be reached.
      	 */
      	@Test
      	@Ignore
      	@Override
      	public void testHomoginiety2() {
      		throw new UnsupportedOperationException();
      	}
      
      	/**
      	 * Identity score varies bases on vector magnitude so homogeneity bound
      	 * can't be reached.
      	 */
      	@Test
      	@Ignore
      	@Override
      	public void testFruitIdentity() {
      		throw new UnsupportedOperationException();
      	}
      
      >>>>>>> 5f0ba9177b34449ea27dabdc17fd0793620c7d56
      }
      Solution content
       */
      package uk.ac.susx.mlcl.byblo.measures.impl;
      
      import junit.framework.Assert;
      
      import org.junit.Ignore;
      import org.junit.Test;
      
      import uk.ac.susx.mlcl.byblo.measures.Measure;
      import uk.ac.susx.mlcl.lib.collect.SparseDoubleVector;
      
      /**
       * 
       * @author Hamish I A Morgan <hamish.morgan@sussex.ac.uk>
       */
      public class HindleTest extends AbstractMeasureTest {
      
      	@Override
      	Class getMeasureClass() {
      		return Hindle.class;
      	}
      
      	@Override
      	String getMeasureName() {
      		return "hindle";
      	}
      
      	/**
      	 * Identity score varies bases on vector magnitude so homogeneity bound
      	 * can't be reached.
      	 */
      	@Test
      	@Override
      	public void testSizeOneVectors() {
      		System.out.println("testSizeOneVectors");
      
      		final int size = 100;
      		final SparseDoubleVector A = new SparseDoubleVector(size, 1);
      		final SparseDoubleVector B = new SparseDoubleVector(size, 1);
      		A.set(0, 1);
      		B.set(0, 1);
      		final double expect = 1; // newInstance().getHomogeneityBound();
      		final double actual = similarity(newInstance(), A, B);
      		Assert.assertEquals(expect, actual, EPSILON);
      	}
      
      	/**
      	 * Identity score varies bases on vector magnitude so homogeneity bound
      	 * can't be reached.
      	 */
      	@Test
      	@Override
      	public void testSizeTwoVectors() {
      		System.out.println("testSizeTwoVectors");
      		int size = 100;
      		SparseDoubleVector A = new SparseDoubleVector(size, 2);
      		SparseDoubleVector B = new SparseDoubleVector(size, 2);
      		A.set(0, 1);
      		A.set(1, 1);
      		B.set(0, 1);
      		B.set(1, 1);
      		double expect = 2; // newInstance().getHomogeneityBound();
      		double actual = similarity(newInstance(), A, B);
      
      		Assert.assertEquals(expect, actual, EPSILON);
      	}
      
      	@Test
      	@Override
      	public void testCardinalityOneVectors() {
      		System.out.println("testCardinalityOneVectors");
      		SparseDoubleVector A = new SparseDoubleVector(1, 1);
      		SparseDoubleVector B = new SparseDoubleVector(1, 1);
      		A.set(0, 1);
      		B.set(0, 1);
      		Measure instance = newInstance();
      		double expect = 1;
      		double actual = similarity(instance, A, B);
      
      		Assert.assertEquals(expect, actual, EPSILON);
      	}
      
      	/**
      	 * Identity score varies bases on vector magnitude so homogeneity bound
      	 * can't be reached.
      	 */
      	@Test
      	@Ignore
      	@Override
      	public void testHomoginiety() {
      		throw new UnsupportedOperationException();
      	}
      	/**
      	 * Identity score varies bases on vector magnitude so homogeneity bound
      	 * can't be reached.
      	 */
      	@Test
      	@Ignore
      	@Override
      	public void testHomoginiety2() {
      		throw new UnsupportedOperationException();
      	}
      
      	/**
      	 * Identity score varies bases on vector magnitude so homogeneity bound
      	 * can't be reached.
      	 */
      	@Test
      	@Ignore
      	@Override
      	public void testFruitIdentity() {
      		throw new UnsupportedOperationException();
      	}
      
      }
      File
      HindleTest.java
      Developer's decision
      Version 2
      Kind of conflict
      Annotation
      Attribute
      Class signature
      Comment
      Import
      Method declaration
      Chunk
      Conflicting content
       */
      package uk.ac.susx.mlcl.byblo.measures.impl;
      
      <<<<<<< HEAD
      import org.junit.BeforeClass;
      import org.junit.Test;
      import uk.ac.susx.mlcl.TestConstants;
      import uk.ac.susx.mlcl.byblo.Tools;
      import uk.ac.susx.mlcl.byblo.enumerators.DoubleEnumerating;
      import uk.ac.susx.mlcl.byblo.enumerators.DoubleEnumeratingDelegate;
      import uk.ac.susx.mlcl.byblo.io.BybloIO;
      import uk.ac.susx.mlcl.byblo.io.FastWeightedTokenPairVectorSource;
      import uk.ac.susx.mlcl.lib.collect.Indexed;
      import uk.ac.susx.mlcl.lib.collect.SparseDoubleVector;
      
      import java.io.Closeable;
      import java.io.File;
      import java.io.IOException;
      import java.util.*;
      
      import static org.junit.Assert.*;
      import static uk.ac.susx.mlcl.TestConstants.*;
      import static uk.ac.susx.mlcl.lib.test.ExitTrapper.disableExitTrapping;
      import static uk.ac.susx.mlcl.lib.test.ExitTrapper.enableExistTrapping;
      
      /**
       * @author Hamish I A Morgan <hamish.morgan@sussex.ac.uk>
       */
      public class JaccardTest {
      
          static Jaccard INSTANCE;
      
          static final double EPSILON = 0;
      
      
          static Random RANDOM;
      
          @BeforeClass
          public static void setUpClass() throws Exception {
              INSTANCE = new Jaccard();
              RANDOM = new Random(1234);
          }
      
          @Test
          public void testJaccardCLI() throws Exception {
              System.out.println("testJaccardCLI");
      
              File output = new File(TEST_OUTPUT_DIR, FRUIT_NAME + ".Jaccard");
              deleteIfExist(output);
      
              try {
                  enableExistTrapping();
                  Tools.main(new String[]{
                          "allpairs",
                          "--charset", "UTF-8",
                          "--measure", "Jaccard",
                          "--input", TEST_FRUIT_EVENTS.toString(),
                          "--input-features", TEST_FRUIT_FEATURES.toString(),
                          "--input-entries", TEST_FRUIT_ENTRIES.toString(),
                          "--output", output.toString()
                  });
              } finally {
                  disableExitTrapping();
              }
      
      
              assertTrue("Output file " + output + " does not exist.", output.exists());
              assertTrue("Output file " + output + " is empty.", output.length() > 0);
          }
      
          /**
           * http://people.revoledu.com/kardi/tutorial/Similarity/Jaccard.html
           */
          @Test
          public void testJaccardExample1() {
              System.out.println("testJaccardExample1");
              double[] objectA = new double[]{1, 1, 1, 1};
              double[] objectB = new double[]{0, 1, 0, 0};
              int p = 1; // number of variables that positive for both objects
              int q = 3; // number of variables that positive for the th objects and negative for the th object
              int r = 0; // number of variables that negative for the th objects and positive for the th object
              int s = 0; // number of variables that negative for both objects
      //        int t = p + q + r + s; // total number of variables
      //        double jaccardDistance = (double) (q + r) / (double) (p + q + r);
              double jaccardCoef = (double) p / (double) (p + q + r);
      
              SparseDoubleVector vecA = SparseDoubleVector.from(objectA);
              SparseDoubleVector vecB = SparseDoubleVector.from(objectB);
      
              double result = INSTANCE.combine(INSTANCE.shared(vecA, vecB),
                      INSTANCE.left(vecA),
                      INSTANCE.left(vecB));
      
              assertEquals(jaccardCoef, result, 0.0001);
          }
      
          /**
           * http://people.revoledu.com/kardi/tutorial/Similarity/Jaccard.html
           */
          @Test
          public void testJaccardExample2() {
              System.out.println("testJaccardExample2");
              Set A = new HashSet();
              A.addAll(Arrays.asList(7, 3, 2, 4, 1));
      
              Set B = new HashSet();
              B.addAll(Arrays.asList(4, 1, 9, 7, 5));
      
              Set union = new HashSet();
              union.addAll(A);
              union.addAll(B);
      
              Set intersection = new HashSet();
              intersection.addAll(A);
              intersection.retainAll(B);
      
              double jaccardCoef = (double) intersection.size() / (double) union.
                      size();
      
      
              SparseDoubleVector vecA = new SparseDoubleVector(10);
              for (int a : A) {
                  vecA.set(a, 1);
              }
              SparseDoubleVector vecB = new SparseDoubleVector(10);
              for (int b : B) {
                  vecB.set(b, 1);
              }
      
              double result = INSTANCE.combine(INSTANCE.shared(vecA, vecB),
                      INSTANCE.left(vecA),
                      INSTANCE.left(vecB));
      
              assertEquals(jaccardCoef, result, 0.0001);
          }
      
          /**
           * Test of shared method, of class Jaccard.
           */
          @Test
          public void testShared() {
              System.out.println("testShared");
              SparseDoubleVector Q = SparseDoubleVector.from(
                      new double[]{0, 1, 0, 1, 0, 1, 0, 1, 1, 1});
              SparseDoubleVector R = SparseDoubleVector.from(
                      new double[]{1, 0, 1, 0, 1, 0, 1, 1, 1, 0});
              double expResult = 2.0;
              double result = INSTANCE.shared(Q, R);
              assertEquals(expResult, result, 0.0);
          }
      
          /**
           * Test of left method, of class Jaccard.
           */
          @Test
          public void testLeft() {
              System.out.println("testLeft");
              SparseDoubleVector Q = SparseDoubleVector.from(
                      new double[]{0, 1, 0, 1, 0, 1, 0, 1, 1, 1});
              double expResult = 6.0;
              double result = INSTANCE.left(Q);
              assertEquals(expResult, result, 0.0);
          }
      
          /**
           * Test of right method, of class Jaccard.
           */
          @Test
          public void testRight() {
              System.out.println("testRight");
              SparseDoubleVector R = SparseDoubleVector.from(
                      new double[]{0, 1, 0, 1, 0, 1, 0, 1, 1, 1});
              double expResult = 6.0;
              double result = INSTANCE.right(R);
              assertEquals(expResult, result, 0.0);
          }
      
          /**
           * Test of combine method, of class Jaccard.
           */
          @Test
          public void testCombine() {
              System.out.println("testCombine");
              double shared = 7.0;
              double left = 5.0;
              double right = 3.0;
              double expResult = shared / (left + right - shared);
              double result = INSTANCE.combine(shared, left, right);
              assertEquals(expResult, result, 0.0);
          }
      
          /**
           * Test of isSymmetric method, of class Jaccard.
           */
          @Test
          public void testIsSymmetric() {
              System.out.println("testIsSymmetric");
              boolean expResult = true;
              boolean result = INSTANCE.isCommutative();
              assertEquals(expResult, result);
          }
      
          @Test
          public void testBothEmptyVectors() throws Exception {
              System.out.println("testBothEmptyVectors");
              int size = 100;
              SparseDoubleVector A = new SparseDoubleVector(size, 0);
              SparseDoubleVector B = new SparseDoubleVector(size, 0);
              double expect = 0;
              double actual = test(A, B);
      
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testOneEmptyVector() throws Exception {
              System.out.println("testOneEmptyVector");
              int size = 100;
              SparseDoubleVector A = new SparseDoubleVector(size, 0);
              SparseDoubleVector B = new SparseDoubleVector(size, size);
              for (int i = 0; i < size; i++)
                  B.set(i, RANDOM.nextDouble());
      
              double expect = 0;
              double actual = test(A, B);
      
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testSizeOneVectors() throws Exception {
              System.out.println("testSizeOneVectors");
              int size = 100;
              SparseDoubleVector A = new SparseDoubleVector(size, 1);
              SparseDoubleVector B = new SparseDoubleVector(size, 1);
              A.set(0, 1);
              B.set(0, 1);
              double expect = INSTANCE.getHomogeneityBound();
              double actual = test(A, B);
      
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testCardinalityOneVectors() throws Exception {
              System.out.println("testCardinalityOneVectors");
              SparseDoubleVector A = new SparseDoubleVector(1, 1);
              SparseDoubleVector B = new SparseDoubleVector(1, 1);
              A.set(0, 1);
              B.set(0, 1);
              double expect = 1;
              double actual = test(A, B);
      
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testSizeTwoVectors() throws Exception {
              System.out.println("testSizeTwoVectors");
              int size = 100;
              SparseDoubleVector A = new SparseDoubleVector(size, 2);
              SparseDoubleVector B = new SparseDoubleVector(size, 2);
              A.set(0, 1);
              A.set(1, 1);
              B.set(0, 1);
              B.set(1, 1);
              double expect = INSTANCE.getHomogeneityBound();
              double actual = test(A, B);
      
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testCommutative() throws Exception {
              System.out.println("testCommutative");
              int size = 100;
              SparseDoubleVector A = new SparseDoubleVector(size, size);
              SparseDoubleVector B = new SparseDoubleVector(size, size);
              for (int i = 0; i < size; i++) {
                  A.set(i, RANDOM.nextDouble());
                  B.set(i, RANDOM.nextDouble());
              }
      
              double expect = test(A, B);
              double actual = test(B, A);
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testHomoginiety() throws Exception {
              System.out.println("testHomoginiety");
              int size = 100;
              SparseDoubleVector A = new SparseDoubleVector(size, size);
              SparseDoubleVector B = new SparseDoubleVector(size, size);
              for (int i = 0; i < size; i++) {
                  double value = RANDOM.nextDouble();
                  A.set(i, value);
                  B.set(i, value);
              }
      
              double expect = INSTANCE.getHomogeneityBound();
              double actual = test(A, B);
      
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testHeteroginiety() throws Exception {
              System.out.println("testHeteroginiety");
              int size = 100;
              SparseDoubleVector A = new SparseDoubleVector(size, size);
              SparseDoubleVector B = new SparseDoubleVector(size, size);
              for (int i = 0; i < size / 2; i++) {
                  A.set(i * 2, i);
                  B.set(i * 2 + 1, i);
              }
              double expect = INSTANCE.getHeterogeneityBound();
              double actual = test(A, B);
      
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testFruitData() throws Exception {
              System.out.println("testFruitData");
              int limit = 5;
      
              List> vecs = TestConstants.loadFruitVectors();
      
              limit = Math.min(limit, vecs.size());
      
              final double[][] results = new double[limit][limit];
              for (int i = 0; i < limit; i++) {
                  for (int j = 0; j < limit; j++) {
                      SparseDoubleVector A = vecs.get(i).value();
                      SparseDoubleVector B = vecs.get(j).value();
                      results[i][j] = test(A, B);
                  }
              }
      
              // diagonals should all be +1
              for (int i = 0; i < limit; i++) {
                  assertEquals(INSTANCE.getHomogeneityBound(), results[i][i], EPSILON);
              }
              // triangular mirrors should be equal
              for (int i = 0; i < limit; i++) {
                  for (int j = 0; j < limit; j++) {
                      assertEquals(results[i][j], results[j][i], EPSILON);
                  }
              }
          }
      
          @Test
          public void testLargeCardinality() throws Exception {
              System.out.println("testLargeCardinality");
              final int size = 100;
              final SparseDoubleVector A = new SparseDoubleVector(
                      Integer.MAX_VALUE, size);
              final SparseDoubleVector B = new SparseDoubleVector(
                      Integer.MAX_VALUE, size);
              for (int i = 0; i < size; i++) {
                  A.set(RANDOM.nextInt(size * 2), RANDOM.nextDouble());
                  B.set(RANDOM.nextInt(size * 2), RANDOM.nextDouble());
              }
      
              test(A, B);
          }
      
          public double test(SparseDoubleVector A, SparseDoubleVector B) {
              final double val = INSTANCE.similarity(A, B);
              assertFalse("Similarity is NaN", Double.isNaN(val));
              assertFalse("Similarity is " + val, Double.isInfinite(val));
              assertTrue("Similarity < -1", val >= INSTANCE.getHeterogeneityBound());
              assertTrue("Similarity > +1", val <= INSTANCE.getHomogeneityBound());
              return val;
          }
      
          static List> loadFruitVectors() throws IOException {
      
              final DoubleEnumerating indexDelegate = new DoubleEnumeratingDelegate();
              final FastWeightedTokenPairVectorSource eventSrc =
                      BybloIO.openEventsVectorSource(
                              TEST_FRUIT_EVENTS, DEFAULT_CHARSET, indexDelegate);
              final List> vecs =
                      new ArrayList>();
              while (eventSrc.hasNext())
                  vecs.add(eventSrc.read());
      
              if (eventSrc instanceof Closeable) {
                  ((Closeable) eventSrc).close();
              }
      
              return vecs;
          }
      =======
      import static org.junit.Assert.assertEquals;
      
      import java.util.Arrays;
      import java.util.HashSet;
      import java.util.Set;
      
      import org.junit.Test;
      
      import uk.ac.susx.mlcl.lib.collect.SparseDoubleVector;
      
      /**
       * 
       * @author Hamish I A Morgan <hamish.morgan@sussex.ac.uk>
       */
      public class JaccardTest extends AbstractMeasureTest {
      
      	@Override
      	Class getMeasureClass() {
      		return Jaccard.class;
      	}
      
      	@Override
      	String getMeasureName() {
      		return "jaccard";
      	}
      
      	/**
      	 * http://people.revoledu.com/kardi/tutorial/Similarity/Jaccard.html
      	 */
      	@Test
      	public void testJaccardExample1() {
      		System.out.println("testJaccardExample1");
      
      		double[] objectA = new double[] { 1, 1, 1, 1 };
      		double[] objectB = new double[] { 0, 1, 0, 0 };
      		int p = 1; // number of variables that positive for both objects
      		int q = 3; // number of variables that positive for the th objects and
      					// negative for the th object
      		int r = 0; // number of variables that negative for the th objects and
      					// positive for the th object
      					// int s = 0; // number of variables that negative for both
      					// objects
      		// int t = p + q + r + s; // total number of variables
      		// double jaccardDistance = (double) (q + r) / (double) (p + q + r);
      		double jaccardCoef = (double) p / (double) (p + q + r);
      
      		SparseDoubleVector vecA = SparseDoubleVector.from(objectA);
      		SparseDoubleVector vecB = SparseDoubleVector.from(objectB);
      
      		Jaccard INSTANCE = newInstance();
      
      		double result = INSTANCE.combine(INSTANCE.shared(vecA, vecB),
      				INSTANCE.left(vecA), INSTANCE.left(vecB));
      
      		assertEquals(jaccardCoef, result, 0.0001);
      	}
      
      	/**
      	 * http://people.revoledu.com/kardi/tutorial/Similarity/Jaccard.html
      	 */
      	@Test
      	public void testJaccardExample2() {
      		System.out.println("testJaccardExample2");
      
      		Set A = new HashSet();
      		A.addAll(Arrays.asList(7, 3, 2, 4, 1));
      
      		Set B = new HashSet();
      		B.addAll(Arrays.asList(4, 1, 9, 7, 5));
      
      		Set union = new HashSet();
      		union.addAll(A);
      		union.addAll(B);
      
      		Set intersection = new HashSet();
      		intersection.addAll(A);
      		intersection.retainAll(B);
      
      		double jaccardCoef = (double) intersection.size()
      				/ (double) union.size();
      
      		SparseDoubleVector vecA = new SparseDoubleVector(10);
      		for (int a : A) {
      			vecA.set(a, 1);
      		}
      		SparseDoubleVector vecB = new SparseDoubleVector(10);
      		for (int b : B) {
      			vecB.set(b, 1);
      		}
      		Jaccard INSTANCE = newInstance();
      
      		double result = INSTANCE.combine(INSTANCE.shared(vecA, vecB),
      				INSTANCE.left(vecA), INSTANCE.left(vecB));
      
      		assertEquals(jaccardCoef, result, 0.0001);
      	}
      
      	//
      	/**
      	 * Test of shared method, of class Jaccard.
      	 */
      	@Test
      	public void testShared() {
      		System.out.println("testShared");
      
      		SparseDoubleVector Q = SparseDoubleVector.from(new double[] { 0, 1, 0,
      				1, 0, 1, 0, 1, 1, 1 });
      		SparseDoubleVector R = SparseDoubleVector.from(new double[] { 1, 0, 1,
      				0, 1, 0, 1, 1, 1, 0 });
      		double expResult = 2.0;
      		Jaccard INSTANCE = newInstance();
      		double result = INSTANCE.shared(Q, R);
      		assertEquals(expResult, result, 0.0);
      	}
      
      	/**
      	 * Test of left method, of class Jaccard.
      	 */
      	@Test
      	public void testLeft() {
      		System.out.println("testLeft");
      
      		SparseDoubleVector Q = SparseDoubleVector.from(new double[] { 0, 1, 0,
      				1, 0, 1, 0, 1, 1, 1 });
      		double expResult = 6.0;
      		Jaccard INSTANCE = newInstance();
      		double result = INSTANCE.left(Q);
      		assertEquals(expResult, result, 0.0);
      	}
      
      	/**
      	 * Test of right method, of class Jaccard.
      	 */
      	@Test
      	public void testRight() {
      		System.out.println("testRight");
      
      		SparseDoubleVector R = SparseDoubleVector.from(new double[] { 0, 1, 0,
      				1, 0, 1, 0, 1, 1, 1 });
      		double expResult = 6.0;
      		Jaccard INSTANCE = newInstance();
      		double result = INSTANCE.right(R);
      		assertEquals(expResult, result, 0.0);
      	}
      
      	/**
      	 * Test of combine method, of class Jaccard.
      	 */
      	@Test
      	public void testCombine() {
      		System.out.println("testCombine");
      
      		double shared = 7.0;
      		double left = 5.0;
      		double right = 3.0;
      		double expResult = shared / (left + right - shared);
      		Jaccard INSTANCE = newInstance();
      		double result = INSTANCE.combine(shared, left, right);
      		assertEquals(expResult, result, 0.0);
      	}
      
      	/**
      	 * Test of isSymmetric method, of class Jaccard.
      	 */
      	@Test
      	public void testIsSymmetric() {
      		System.out.println("testIsSymmetric");
      
      		boolean expResult = true;
      		Jaccard INSTANCE = newInstance();
      		boolean result = INSTANCE.isCommutative();
      		assertEquals(expResult, result);
      	}
      
      >>>>>>> 5f0ba9177b34449ea27dabdc17fd0793620c7d56
      }
      Solution content
       */
      package uk.ac.susx.mlcl.byblo.measures.impl;
      
      import static org.junit.Assert.assertEquals;
      
      import java.util.Arrays;
      import java.util.HashSet;
      import java.util.Set;
      
      import org.junit.Test;
      
      import uk.ac.susx.mlcl.lib.collect.SparseDoubleVector;
      
      /**
       * 
       * @author Hamish I A Morgan <hamish.morgan@sussex.ac.uk>
       */
      public class JaccardTest extends AbstractMeasureTest {
      
      	@Override
      	Class getMeasureClass() {
      		return Jaccard.class;
      	}
      
      	@Override
      	String getMeasureName() {
      		return "jaccard";
      	}
      
      	/**
      	 * http://people.revoledu.com/kardi/tutorial/Similarity/Jaccard.html
      	 */
      	@Test
      	public void testJaccardExample1() {
      		System.out.println("testJaccardExample1");
      
      		double[] objectA = new double[] { 1, 1, 1, 1 };
      		double[] objectB = new double[] { 0, 1, 0, 0 };
      		int p = 1; // number of variables that positive for both objects
      		int q = 3; // number of variables that positive for the th objects and
      					// negative for the th object
      		int r = 0; // number of variables that negative for the th objects and
      					// positive for the th object
      					// int s = 0; // number of variables that negative for both
      					// objects
      		// int t = p + q + r + s; // total number of variables
      		// double jaccardDistance = (double) (q + r) / (double) (p + q + r);
      		double jaccardCoef = (double) p / (double) (p + q + r);
      
      		SparseDoubleVector vecA = SparseDoubleVector.from(objectA);
      		SparseDoubleVector vecB = SparseDoubleVector.from(objectB);
      
      		Jaccard INSTANCE = newInstance();
      
      		double result = INSTANCE.combine(INSTANCE.shared(vecA, vecB),
      				INSTANCE.left(vecA), INSTANCE.left(vecB));
      
      		assertEquals(jaccardCoef, result, 0.0001);
      	}
      
      	/**
      	 * http://people.revoledu.com/kardi/tutorial/Similarity/Jaccard.html
      	 */
      	@Test
      	public void testJaccardExample2() {
      		System.out.println("testJaccardExample2");
      
      		Set A = new HashSet();
      		A.addAll(Arrays.asList(7, 3, 2, 4, 1));
      
      		Set B = new HashSet();
      		B.addAll(Arrays.asList(4, 1, 9, 7, 5));
      
      		Set union = new HashSet();
      		union.addAll(A);
      		union.addAll(B);
      
      		Set intersection = new HashSet();
      		intersection.addAll(A);
      		intersection.retainAll(B);
      
      		double jaccardCoef = (double) intersection.size()
      				/ (double) union.size();
      
      		SparseDoubleVector vecA = new SparseDoubleVector(10);
      		for (int a : A) {
      			vecA.set(a, 1);
      		}
      		SparseDoubleVector vecB = new SparseDoubleVector(10);
      		for (int b : B) {
      			vecB.set(b, 1);
      		}
      		Jaccard INSTANCE = newInstance();
      
      		double result = INSTANCE.combine(INSTANCE.shared(vecA, vecB),
      				INSTANCE.left(vecA), INSTANCE.left(vecB));
      
      		assertEquals(jaccardCoef, result, 0.0001);
      	}
      
      	//
      	/**
      	 * Test of shared method, of class Jaccard.
      	 */
      	@Test
      	public void testShared() {
      		System.out.println("testShared");
      
      		SparseDoubleVector Q = SparseDoubleVector.from(new double[] { 0, 1, 0,
      				1, 0, 1, 0, 1, 1, 1 });
      		SparseDoubleVector R = SparseDoubleVector.from(new double[] { 1, 0, 1,
      				0, 1, 0, 1, 1, 1, 0 });
      		double expResult = 2.0;
      		Jaccard INSTANCE = newInstance();
      		double result = INSTANCE.shared(Q, R);
      		assertEquals(expResult, result, 0.0);
      	}
      
      	/**
      	 * Test of left method, of class Jaccard.
      	 */
      	@Test
      	public void testLeft() {
      		System.out.println("testLeft");
      
      		SparseDoubleVector Q = SparseDoubleVector.from(new double[] { 0, 1, 0,
      				1, 0, 1, 0, 1, 1, 1 });
      		double expResult = 6.0;
      		Jaccard INSTANCE = newInstance();
      		double result = INSTANCE.left(Q);
      		assertEquals(expResult, result, 0.0);
      	}
      
      	/**
      	 * Test of right method, of class Jaccard.
      	 */
      	@Test
      	public void testRight() {
      		System.out.println("testRight");
      
      		SparseDoubleVector R = SparseDoubleVector.from(new double[] { 0, 1, 0,
      				1, 0, 1, 0, 1, 1, 1 });
      		double expResult = 6.0;
      		Jaccard INSTANCE = newInstance();
      		double result = INSTANCE.right(R);
      		assertEquals(expResult, result, 0.0);
      	}
      
      	/**
      	 * Test of combine method, of class Jaccard.
      	 */
      	@Test
      	public void testCombine() {
      		System.out.println("testCombine");
      
      		double shared = 7.0;
      		double left = 5.0;
      		double right = 3.0;
      		double expResult = shared / (left + right - shared);
      		Jaccard INSTANCE = newInstance();
      		double result = INSTANCE.combine(shared, left, right);
      		assertEquals(expResult, result, 0.0);
      	}
      
      	/**
      	 * Test of isSymmetric method, of class Jaccard.
      	 */
      	@Test
      	public void testIsSymmetric() {
      		System.out.println("testIsSymmetric");
      
      		boolean expResult = true;
      		Jaccard INSTANCE = newInstance();
      		boolean result = INSTANCE.isCommutative();
      		assertEquals(expResult, result);
      	}
      
      }
      File
      JaccardTest.java
      Developer's decision
      Version 2
      Kind of conflict
      Annotation
      Attribute
      Class signature
      Comment
      Import
      Method declaration
      Chunk
      Conflicting content
      //    @Test
              assertEquals(expect, actual, EPSILON);
          }
      //
       */
      package uk.ac.susx.mlcl.byblo.measures.impl;
      
      <<<<<<< HEAD
      import org.junit.BeforeClass;
      import org.junit.Test;
      import uk.ac.susx.mlcl.TestConstants;
      import uk.ac.susx.mlcl.byblo.Tools;
      import uk.ac.susx.mlcl.byblo.enumerators.DoubleEnumerating;
      import uk.ac.susx.mlcl.byblo.enumerators.DoubleEnumeratingDelegate;
      import uk.ac.susx.mlcl.byblo.io.BybloIO;
      import uk.ac.susx.mlcl.byblo.io.FastWeightedTokenPairVectorSource;
      import uk.ac.susx.mlcl.lib.collect.Indexed;
      import uk.ac.susx.mlcl.lib.collect.SparseDoubleVector;
      
      import java.io.Closeable;
      import java.io.File;
      import java.io.IOException;
      import java.util.ArrayList;
      import java.util.List;
      import java.util.Random;
      
      import static org.junit.Assert.*;
      import static uk.ac.susx.mlcl.TestConstants.*;
      import static uk.ac.susx.mlcl.lib.test.ExitTrapper.disableExitTrapping;
      import static uk.ac.susx.mlcl.lib.test.ExitTrapper.enableExistTrapping;
      
      /**
       * @author Hamish I A Morgan <hamish.morgan@sussex.ac.uk>
       */
      public class JensenShannonDivergenceTest {
      
          static JensenShannonDivergence INSTANCE;
      
          static final double EPSILON = 1E-15;
      
          static Random RANDOM;
      
          @BeforeClass
          public static void setUpClass() throws Exception {
              INSTANCE = new JensenShannonDivergence();
              RANDOM = new Random(1234);
          }
      
          @Test
          public void testCLI() throws Exception {
              System.out.println("testCLI");
      
              File output = new File(TEST_OUTPUT_DIR, FRUIT_NAME
                      + ".JensenShannonDivergence");
              deleteIfExist(output);
      
              try {
                  enableExistTrapping();
                  Tools.main(new String[]{
                          "allpairs",
                          "--charset", "UTF-8",
                          "--measure", "js",
                          "--input", TEST_FRUIT_EVENTS.toString(),
                          "--input-features", TEST_FRUIT_FEATURES.toString(),
                          "--input-entries", TEST_FRUIT_ENTRIES.toString(),
                          "--output", output.toString()
                  });
              } finally {
                  disableExitTrapping();
              }
      
      
              assertTrue("Output file " + output + " does not exist.", output.exists());
              assertTrue("Output file " + output + " is empty.", output.length() > 0);
          }
      
          @Test
          public void testBothEmptyVectors() throws Exception {
              System.out.println("testBothEmptyVectors");
              int size = 100;
              SparseDoubleVector A = new SparseDoubleVector(size, 0);
              SparseDoubleVector B = new SparseDoubleVector(size, 0);
              double expect = 0;
              double actual = test(A, B);
      
      //    public void testOneEmptyVector() throws Exception {
      //        System.out.println("testOneEmptyVector");
      //        int size = 100;
      //        SparseDoubleVector A = new SparseDoubleVector(size, 0);
      //        SparseDoubleVector B = new SparseDoubleVector(size, size);
      //        for (int i = 0; i < size; i++)
      //            B.set(i, RANDOM.nextDouble());
      //
      //        double expect = 0;
      //        double actual = test(A, B);
      //
      //        assertEquals(expect, actual, EPSILON);
      //    }
      
          @Test
          public void testSizeOneVectors() throws Exception {
              System.out.println("testSizeOneVectors");
              int size = 100;
              SparseDoubleVector A = new SparseDoubleVector(size, 1);
              SparseDoubleVector B = new SparseDoubleVector(size, 1);
              A.set(0, 1);
              B.set(0, 1);
              double expect = INSTANCE.getHomogeneityBound();
              double actual = test(A, B);
      
              assertEquals(expect, actual, EPSILON);
          }
      //
      //    @Test
      //    public void testCardinalityOneVectors() throws Exception {
      //        System.out.println("testCardinalityOneVectors");
      //        SparseDoubleVector A = new SparseDoubleVector(1, 1);
      //        SparseDoubleVector B = new SparseDoubleVector(1, 1);
      //        A.set(0, 1);
      //        B.set(0, 1);
      //        double expect = 1;
      //        double actual = test(A, B);
      //
      //        assertEquals(expect, actual, EPSILON);
      //    }
      
          @Test
          public void testSizeTwoVectors() throws Exception {
              System.out.println("testSizeTwoVectors");
              int size = 100;
              SparseDoubleVector A = new SparseDoubleVector(size, 2);
              SparseDoubleVector B = new SparseDoubleVector(size, 2);
              A.set(0, 1);
              A.set(1, 1);
              B.set(0, 1);
              B.set(1, 1);
              double expect = INSTANCE.getHomogeneityBound();
              double actual = test(A, B);
      
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testCommutative() throws Exception {
              System.out.println("testCommutative");
              int size = 100;
              SparseDoubleVector A = new SparseDoubleVector(size, size);
              SparseDoubleVector B = new SparseDoubleVector(size, size);
              for (int i = 0; i < size; i++) {
                  A.set(i, RANDOM.nextDouble());
                  B.set(i, RANDOM.nextDouble());
              }
      
              double expect = test(A, B);
              double actual = test(B, A);
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testHomoginiety() throws Exception {
              System.out.println("testHomoginiety");
              int size = 100;
              SparseDoubleVector A = new SparseDoubleVector(size, size);
              if (INSTANCE.isCommutative()) {
              SparseDoubleVector B = new SparseDoubleVector(size, size);
              for (int i = 0; i < size; i++) {
                  double value = RANDOM.nextDouble();
                  A.set(i, value);
                  B.set(i, value);
              }
      
              double expect = INSTANCE.getHomogeneityBound();
              double actual = test(A, B);
      
              assertEquals(expect, actual, EPSILON);
          }
      //
      //    @Test
      //    public void testHeteroginiety() throws Exception {
      //        System.out.println("testHeteroginiety");
      //        int size = 100;
      //        SparseDoubleVector A = new SparseDoubleVector(size, size);
      //        SparseDoubleVector B = new SparseDoubleVector(size, size);
      //        for (int i = 0; i < size / 2; i++) {
      //            A.set(i * 2, i);
      //            B.set(i * 2 + 1, i);
      //        }
      //
      //        double expect = INSTANCE.getHeterogeneityBound();
      //        double actual = test(A, B);
      //
      //        assertEquals(expect, actual, EPSILON);
      //    }
      
          @Test
          public void testFruitData() throws Exception {
              System.out.println("testFruitData");
              int limit = 5;
      
              List> vecs = TestConstants.loadFruitVectors();
      
              limit = Math.min(limit, vecs.size());
      
              final double[][] results = new double[limit][limit];
              for (int i = 0; i < limit; i++) {
                  for (int j = 0; j < limit; j++) {
                      SparseDoubleVector A = vecs.get(i).value();
                      SparseDoubleVector B = vecs.get(j).value();
                      results[i][j] = test(A, B);
                  }
              }
      
              // diagonals should all be +1
              for (int i = 0; i < limit; i++) {
                  assertEquals(INSTANCE.getHomogeneityBound(), results[i][i], EPSILON);
              }
              // triangular mirrors should be equal
              for (int i = 0; i < limit; i++) {
                  for (int j = 0; j < limit; j++) {
                      assertEquals(results[i][j], results[j][i], EPSILON);
                  }
              }
          }
      
          @Test
          public void testLargeCardinality() throws Exception {
              System.out.println("testLargeCardinality");
              final int size = 100;
              final SparseDoubleVector A = new SparseDoubleVector(
                      Integer.MAX_VALUE, size);
              final SparseDoubleVector B = new SparseDoubleVector(
                      Integer.MAX_VALUE, size);
              for (int i = 0; i < size; i++) {
                  A.set(RANDOM.nextInt(size * 2), RANDOM.nextDouble());
                  B.set(RANDOM.nextInt(size * 2), RANDOM.nextDouble());
              }
      
              test(A, B);
          }
      
          public double test(SparseDoubleVector A, SparseDoubleVector B) {
              final double val = INSTANCE.similarity(A, B);
              assertFalse("Similarity is NaN" + " with measure " + INSTANCE,
                      Double.isNaN(val));
              assertFalse("Similarity is " + val + " with measure " + INSTANCE,
                      Double.isInfinite(val));
      
              final double min, max;
              if (INSTANCE.getHeterogeneityBound() < INSTANCE.getHomogeneityBound()) {
                  min = INSTANCE.getHeterogeneityBound();
                  max = INSTANCE.getHomogeneityBound();
              } else {
                  min = INSTANCE.getHomogeneityBound();
                  max = INSTANCE.getHeterogeneityBound();
              }
              assertTrue("expected similarity >= " + min + " but found " + val,
                      val - min >= -EPSILON);
              assertTrue("expected similarity <= " + max + " but found " + val,
                      val - max <= +EPSILON);
      
      
                  final double rev = INSTANCE.similarity(B, A);
                  assertEquals("Measure is declared computative, but reversing "
                          + "operands results in a different score.", rev, val,
                          EPSILON);
              }
      
              return val;
          }
      
          static List> loadFruitVectors() throws IOException {
      
              final DoubleEnumerating indexDelegate = new DoubleEnumeratingDelegate();
              final FastWeightedTokenPairVectorSource eventSrc =
                      BybloIO.openEventsVectorSource(
                              TEST_FRUIT_EVENTS, DEFAULT_CHARSET, indexDelegate);
              final List> vecs =
                      new ArrayList>();
              while (eventSrc.hasNext())
                  vecs.add(eventSrc.read());
      
              if (eventSrc instanceof Closeable) {
                  ((Closeable) eventSrc).close();
              }
      
              return vecs;
          }
      =======
      import java.util.Random;
      
      import junit.framework.Assert;
      
      import org.junit.Test;
      
      import uk.ac.susx.mlcl.lib.collect.SparseDoubleVector;
      
      /**
       * 
       * @author Hamish I A Morgan <hamish.morgan@sussex.ac.uk>
       */
      public class JensenShannonDivergenceTest extends
      		AbstractMeasureTest {
      
      	@Override
      	Class getMeasureClass() {
      		return JensenShannonDivergence.class;
      	}
      
      	@Override
      	String getMeasureName() {
      		return "js";
      	}
      
      	@Test
      	@Override
      	public void testOneEmptyVector() {
      		System.out.println("testOneEmptyVector");
      		int size = 100;
      		Random RANDOM = newRandom();
      		SparseDoubleVector A = new SparseDoubleVector(size, 0);
      		SparseDoubleVector B = new SparseDoubleVector(size, size);
      		for (int i = 0; i < size; i++)
      			B.set(i, RANDOM.nextDouble());
      
      		double expect = 0.5;
      		double actual = similarity(newInstance(), A, B);
      
      		Assert.assertEquals(expect, actual, EPSILON);
      	}
      
      >>>>>>> 5f0ba9177b34449ea27dabdc17fd0793620c7d56
      }
      Solution content
       */
      package uk.ac.susx.mlcl.byblo.measures.impl;
      
      import java.util.Random;
      
      import junit.framework.Assert;
      
      import org.junit.Test;
      
      import uk.ac.susx.mlcl.lib.collect.SparseDoubleVector;
      
      /**
       * 
       * @author Hamish I A Morgan <hamish.morgan@sussex.ac.uk>
       */
      public class JensenShannonDivergenceTest extends
      		AbstractMeasureTest {
      
      	@Override
      	Class getMeasureClass() {
      		return JensenShannonDivergence.class;
      	}
      
      	@Override
      	String getMeasureName() {
      		return "js";
      	}
      
      	@Test
      	@Override
      	public void testOneEmptyVector() {
      		System.out.println("testOneEmptyVector");
      		int size = 100;
      		Random RANDOM = newRandom();
      		SparseDoubleVector A = new SparseDoubleVector(size, 0);
      		SparseDoubleVector B = new SparseDoubleVector(size, size);
      		for (int i = 0; i < size; i++)
      			B.set(i, RANDOM.nextDouble());
      
      		double expect = 0.5;
      		double actual = similarity(newInstance(), A, B);
      
      		Assert.assertEquals(expect, actual, EPSILON);
      	}
      
      }
      File
      JensenShannonDivergenceTest.java
      Developer's decision
      Version 2
      Kind of conflict
      Annotation
      Attribute
      Class signature
      Comment
      Import
      Method declaration
      Chunk
      Conflicting content
       */
      package uk.ac.susx.mlcl.byblo.measures.impl;
      
      <<<<<<< HEAD
      import org.junit.*;
      import uk.ac.susx.mlcl.TestConstants;
      import uk.ac.susx.mlcl.byblo.Tools;
      import uk.ac.susx.mlcl.byblo.enumerators.DoubleEnumerating;
      import uk.ac.susx.mlcl.byblo.enumerators.DoubleEnumeratingDelegate;
      import uk.ac.susx.mlcl.byblo.io.BybloIO;
      import uk.ac.susx.mlcl.byblo.io.FastWeightedTokenPairVectorSource;
      import uk.ac.susx.mlcl.lib.collect.Indexed;
      import uk.ac.susx.mlcl.lib.collect.SparseDoubleVector;
      
      import java.io.Closeable;
      import java.io.File;
      import java.io.IOException;
      import java.util.ArrayList;
      import java.util.List;
      import java.util.Random;
      
      import static org.junit.Assert.*;
      import static uk.ac.susx.mlcl.TestConstants.*;
      import static uk.ac.susx.mlcl.lib.test.ExitTrapper.disableExitTrapping;
      import static uk.ac.susx.mlcl.lib.test.ExitTrapper.enableExistTrapping;
      =======
      import java.util.Random;
      
      import javax.annotation.CheckReturnValue;
      
      import junit.framework.Assert;
      
      import org.junit.Ignore;
      import org.junit.Test;
      
      import uk.ac.susx.mlcl.byblo.measures.Measure;
      import uk.ac.susx.mlcl.byblo.weighings.Weighting;
      import uk.ac.susx.mlcl.lib.collect.SparseDoubleVector;
      >>>>>>> 5f0ba9177b34449ea27dabdc17fd0793620c7d56
      
      /**
       * Unit tests for {@link KendallsTau } proximity measure.
      Solution content
       */
      package uk.ac.susx.mlcl.byblo.measures.impl;
      
      import java.util.Random;
      
      import javax.annotation.CheckReturnValue;
      
      import junit.framework.Assert;
      
      import org.junit.Ignore;
      import org.junit.Test;
      
      import uk.ac.susx.mlcl.byblo.measures.Measure;
      import uk.ac.susx.mlcl.byblo.weighings.Weighting;
      import uk.ac.susx.mlcl.lib.collect.SparseDoubleVector;
      
      /**
       * Unit tests for {@link KendallsTau } proximity measure.
      File
      KendallsTauTest.java
      Developer's decision
      Version 2
      Kind of conflict
      Import
      Chunk
      Conflicting content
      /**
       * Unit tests for {@link KendallsTau } proximity measure.
       * 

      <<<<<<< HEAD * * @author Hamish I A Morgan <hamish.morgan@sussex.ac.uk> */ public class KendallsTauTest { public KendallsTauTest() { } static KendallsTau INSTANCE; static final double EPSILON = 0; static Random RANDOM; @BeforeClass public static void setUpClass() throws Exception { INSTANCE = new KendallsTau(); RANDOM = new Random(1234); } @AfterClass public static void tearDownClass() throws Exception { } @Before public void setUp() { } @After public void tearDown() { } @Test public void testCLI() throws Exception { System.out.println("testCLI"); File output = new File(TEST_OUTPUT_DIR, FRUIT_NAME + ".KendallsTau"); deleteIfExist(output); try { enableExistTrapping(); Tools.main(new String[]{ "allpairs", "--charset", "UTF-8", "--measure", "tau", "--input", TEST_FRUIT_EVENTS.toString(), "--input-features", TEST_FRUIT_FEATURES.toString(), "--input-entries", TEST_FRUIT_ENTRIES.toString(), "--output", output.toString() }); } finally { disableExitTrapping(); } assertTrue("Output file " + output + " does not exist.", output.exists()); assertTrue("Output file " + output + " is empty.", output.length() > 0); } @Test public void testBothEmptyVectors() throws Exception { System.out.println("testBothEmptyVectors"); int size = 100; SparseDoubleVector A = new SparseDoubleVector(size, 0); SparseDoubleVector B = new SparseDoubleVector(size, 0); double expect = INSTANCE.getIndependenceBound(); double actual = test(A, B); assertEquals(expect, actual, EPSILON); } @Test public void testOneEmptyVector() throws Exception { System.out.println("testOneEmptyVector"); int size = 100; SparseDoubleVector A = new SparseDoubleVector(size, 0); SparseDoubleVector B = new SparseDoubleVector(size, size); for (int i = 0; i < size; i++) B.set(i, RANDOM.nextDouble()); double expect = INSTANCE.getIndependenceBound(); double actual = test(A, B); assertEquals(expect, actual, EPSILON); } @Test public void testSizeOneVectors() throws Exception { System.out.println("testSizeOneVectors"); int size = 100; SparseDoubleVector A = new SparseDoubleVector(size, 1); SparseDoubleVector B = new SparseDoubleVector(size, 1); A.set(0, RANDOM.nextDouble()); B.set(0, RANDOM.nextDouble()); double expect = INSTANCE.getHomogeneityBound(); double actual = test(A, B); assertEquals(expect, actual, EPSILON); } @Test public void testCardinalityOneVectors() throws Exception { System.out.println("testCardinalityOneVectors"); int size = 100; SparseDoubleVector A = new SparseDoubleVector(1, 1); SparseDoubleVector B = new SparseDoubleVector(1, 1); A.set(0, RANDOM.nextDouble()); B.set(0, RANDOM.nextDouble()); double expect = INSTANCE.getIndependenceBound(); double actual = test(A, B); assertEquals(expect, actual, EPSILON); } @Test public void testSizeTwoVectors() throws Exception { System.out.println("testSizeTwoVectors"); int size = 100; SparseDoubleVector A = new SparseDoubleVector(size, 2); SparseDoubleVector B = new SparseDoubleVector(size, 2); A.set(0, RANDOM.nextDouble()); A.set(1, 1 + RANDOM.nextDouble()); B.set(0, RANDOM.nextDouble()); B.set(1, 1 + RANDOM.nextDouble()); double expect = INSTANCE.getHomogeneityBound(); double actual = test(A, B); assertEquals(expect, actual, EPSILON); } @Test public void testCommutative() throws Exception { System.out.println("testCommutative"); int size = 100; SparseDoubleVector A = new SparseDoubleVector(size, size); SparseDoubleVector B = new SparseDoubleVector(size, size); for (int i = 0; i < size; i++) { A.set(i, RANDOM.nextDouble()); B.set(i, RANDOM.nextDouble()); } double expect = test(A, B); double actual = test(B, A); assertEquals(expect, actual, EPSILON); } @Test public void testHomoginiety() throws Exception { System.out.println("testHomoginiety"); int size = 100; SparseDoubleVector A = new SparseDoubleVector(size, size); SparseDoubleVector B = new SparseDoubleVector(size, size); for (int i = 0; i < size; i++) { double value = RANDOM.nextDouble(); A.set(i, value); B.set(i, value); } double expect = INSTANCE.getHomogeneityBound(); double actual = test(A, B); assertEquals(expect, actual, EPSILON); } @Test public void testHeteroginiety() throws Exception { System.out.println("testHeteroginiety"); int size = 100; SparseDoubleVector A = new SparseDoubleVector(size, size); SparseDoubleVector B = new SparseDoubleVector(size, size); for (int i = 0; i < size; i++) { A.set(i, i); B.set(i, size - i); } ======= * * @author Hamish I A Morgan <hamish.morgan@sussex.ac.uk> */ public class KendallsTauTest extends AbstractMeasureTest { >>>>>>> 5f0ba9177b34449ea27dabdc17fd0793620c7d56 @Override Class getMeasureClass() {

      Solution content
      /**
       * Unit tests for {@link KendallsTau } proximity measure.
       * 

      * * @author Hamish I A Morgan <hamish.morgan@sussex.ac.uk> */ public class KendallsTauTest extends AbstractMeasureTest { @Override Class getMeasureClass() {

      File
      KendallsTauTest.java
      Developer's decision
      Version 2
      Kind of conflict
      Annotation
      Attribute
      Class signature
      Comment
      For statement
      Method declaration
      Method invocation
      Method signature
      Variable
      Chunk
      Conflicting content
      			return cordance / denom;
      		}
      
      <<<<<<< HEAD
          static double tauB_naive1(SparseDoubleVector A, SparseDoubleVector B) {
              assert A.cardinality == B.cardinality :
                      "Cardinalities not equal " + A.cardinality + " != "
                              + B.cardinality;
      =======
      		@Override
      		@CheckReturnValue
      		public double getHomogeneityBound() {
      			throw new UnsupportedOperationException();
      		}
      //
      //		@Override
      //		public double getIndependenceBound() {
      //			throw new UnsupportedOperationException();
      //		}
      >>>>>>> 5f0ba9177b34449ea27dabdc17fd0793620c7d56
      
      		@Override
      		@CheckReturnValue
      Solution content
      			return cordance / denom;
      		}
      
      		@Override
      		@CheckReturnValue
      		public double getHomogeneityBound() {
      			throw new UnsupportedOperationException();
      		}
      //
      //		@Override
      //		public double getIndependenceBound() {
      //			throw new UnsupportedOperationException();
      //		}
      
      		@Override
      		@CheckReturnValue
      File
      KendallsTauTest.java
      Developer's decision
      Version 2
      Kind of conflict
      Annotation
      Assert statement
      Comment
      Method declaration
      Method signature
      Chunk
      Conflicting content
      			throw new UnsupportedOperationException();
      		}
      
      <<<<<<< HEAD
          static List> loadFruitVectors() throws IOException {
      
              final DoubleEnumerating indexDelegate = new DoubleEnumeratingDelegate();
              final FastWeightedTokenPairVectorSource eventSrc =
                      BybloIO.openEventsVectorSource(
                              TEST_FRUIT_EVENTS, DEFAULT_CHARSET, indexDelegate);
              final List> vecs =
      //////
                      new ArrayList>();
              while (eventSrc.hasNext())
                  vecs.add(eventSrc.read());
      
              if (eventSrc instanceof Closeable) {
                  ((Closeable) eventSrc).close();
              }
      
              return vecs;
          }
      //    
      //    static double tauA_naive1(SparseDoubleVector A, SparseDoubleVector B) {
      //        assert A.cardinality == B.cardinality :
      //                "Cardinalities not equal " + A.cardinality + " != " + B.cardinality;
      //
      //        final int n = A.cardinality;
      //        double result = 0;
      //        for (int i = 1; i < n; i++) {
      //            for (int j = 0; j < i; j++) {
      //                result += Math.signum(A.get(i) - A.get(j))
      //                        * Math.signum(B.get(i) - B.get(j));
      //            }
      //        }
      //        double denom = 0.5 * n * (n - 1);
      //
      //        return result / denom;
      //    }
      //
      //    @Test
      //    @Ignore
      //    public void testThing() throws Exception {
      //        System.out.println("test");
      //
      //        DoubleEnumerating indexDelegate = new DoubleEnumeratingDelegate();
      //        FastWeightedTokenPairVectorSource eventSrc =
      //                BybloIO.openEventsVectorSource(
      //                TEST_FRUIT_EVENTS, DEFAULT_CHARSET, indexDelegate);
      //
      //        List> vecs =
      //                new ArrayList>();
      //        while (eventSrc.hasNext()) {
      //            vecs.add(eventSrc.read());
      //        }
      //
      //        // Calcualte the maximum cardinality of the vectors
      //        int cardinality = 0;
      //        for (Indexed A : vecs) {
      //            if (A.value().cardinality > cardinality)
      //                cardinality = A.value().cardinality;
      //        }
      //
      //        //Update all the vectors to have the same cardinality
      //        for (Indexed A : vecs) {
      //            A.value().cardinality = cardinality;
      //        }
      ////
      ////        double tau = naive_tauA(vecs.get(0).value(), vecs.get(0).value());
      ////
      ////        System.out.printf("%d %d %f%n", vecs.get(0).key(), vecs.get(0).key(),
      ////                          tau);
      //
      ////             
      ////
      ////        tauB_naive1(vecs.get(0).value(), vecs.get(1).value());
      ////        tauB_naive3(vecs.get(0).value(), vecs.get(1).value());
      //////
      ////        tauB_naive1(vecs.get(0).value(), vecs.get(0).value());
      //        tauB_merge1(vecs.get(1).value(), vecs.get(0).value());
      //
      //        for (Indexed A : vecs) {
      //            for (Indexed B : vecs) {
      //
      ////
      ////                {
      ////                    System.out.println("imp1");
      ////
      ////                    final long t0 = System.currentTimeMillis();
      //        private long bties = 0;
      ////                    final double tau = tauB_naive1(A.value(), B.value());
      ////
      ////                    assertTrue("Tau expected in range [-1,+1] but found " + tau,
      ////                               tau >= -1 && tau <= +1);
      ////
      ////
      ////
      ////                    System.out.printf("%d %d %f   (%f seconds)%n",
      ////                                      A.key(), B.key(), tau,
      ////                                      (System.currentTimeMillis() - t0) / 1000.0);
      ////                }
      //
      ////                {
      ////                    System.out.println("imp2");
      ////
      ////                    final long t0 = System.currentTimeMillis();
      ////                    final double tau = tauB_naive2(A.value(), B.value());
      ////
      ////                    assertTrue("Tau expected in range [-1,+1] but found " + tau,
      ////                               tau >= -1 && tau <= +1);
      ////
      ////
      ////
      ////                    System.out.printf("%d %d %f   (%f seconds)%n",
      ////                                      A.key(), B.key(), tau,
      ////                                      (System.currentTimeMillis() - t0) / 1000.0);
      ////                }
      //
      ////                {
      //
      ////                    final long t0 = System.currentTimeMillis();
      //
      ////                    final double tau = new KendallsTauRC().proximity(A.value(), B.value());
      ////
      ////                    assertTrue("Tau expected in range [-1,+1] but found " + tau,
      ////                               tau >= -1 && tau <= +1);
      ////
      ////
      ////
      ////                    System.out.printf("imp3: %d %d %f   (%f seconds)%n",
      ////                                      A.key(), B.key(), tau,
      ////                                      (System.currentTimeMillis() - t0) / 1000.0);
      //
      ////                }
      ////                
      ////                  {
      ////                 
      ////
      //                final long t0 = System.currentTimeMillis();
      ////                    
      ////                    
      ////                    
      ////                final double tau = new TingDem(A.value(), B.value()).calc();
      //                final double tau = new KendallsTau().proximity(A.value(), B.
      //                        value());
      ////                    assertTrue("Tau expected in range [-1,+1] but found " + tau,
      ////                               tau >= -1 && tau <= +1);
      ////
      ////
      //
      //                System.out.printf("imp4: %d %d %f   (%f seconds)%n",
      //                                  A.key(), B.key(), tau,
      //                                  (System.currentTimeMillis() - t0) / 1000.0);
      //
      ////                }
      ////
      ////                {
      ////
      ////                    final long t0 = System.currentTimeMillis();
      ////                    final double tau = tauB_merge1(A.value(), B.value());
      ////
      ////                    assertTrue("Tau expected in range [-1,+1] but found " + tau,
      ////                               tau >= -1 && tau <= +1);
      ////
      ////
      ////
      ////                    System.out.printf("%d %d %f   (%f seconds)%n",
      ////                                      A.key(), B.key(), tau,
      ////                                      (System.currentTimeMillis() - t0) / 1000.0);
      ////                }
      //
      //            }
      //        }
      //
      ////        System.out.println(vecs);
      //
      //
      //    }
      //
      //    static final class TingDem {
      //
      //        private final SparseDoubleVector A;
      //
      //        private final SparseDoubleVector B;
      //
      //        private long cordance = 0;
      //
      //        private long aties = 0;
      //
      //
      //        private int intersectionSize = 0;
      //
      //        public TingDem(SparseDoubleVector A, SparseDoubleVector B) {
      //            Checks.checkNotNull(A);
      //            Checks.checkNotNull(B);
      //            this.A = A;
      //            this.B = B;
      //        }
      //
      //        public double calc() {
      //            assert A.cardinality == B.cardinality :
      //                    "Cardinalities not equal " + A.cardinality + " != " + B.cardinality;
      //
      //            final int N = A.cardinality;
      //
      //            final int L = A.size;
      //            final int M = B.size;
      //
      //            calc1();
      //
      //            final int unionSize = (L + M) - intersectionSize;
      //
      //            // Features that don't occur in either vector are a similarity
      //            // between the two sets. For each feature that they both have there
      //            // should be an addition +2 to the sum.
      //            // The relationship between these and disjoint features
      //            cordance += ((N - unionSize) * intersectionSize);
      //
      //            // Outside of those in the union all elements are zero add all pairwise
      //            // combinations to the ties counters.
      //            aties += ((N - unionSize) * (N - unionSize - 1)) >> 1;
      //            bties += ((N - unionSize) * (N - unionSize - 1)) >> 1;
      //
      //            // We also need to the add the cross-tries between zeros in union, and
      //            // everything else
      //            aties += ((unionSize - L) * (N - unionSize));
      //            bties += ((unionSize - M) * (N - unionSize));
      //
      //            // Within the union minus the size of vector, all elements are zero so
      //            // add all pairwise combinations
      //            aties += ((unionSize - L) * (unionSize - L - 1)) >> 1;
      //            bties += ((unionSize - M) * (unionSize - M - 1)) >> 1;
      ////            
      //            final long n0 = (N * (N - 1)) >> 1;
      //            final double denom = Math.sqrt((n0 - aties) * (n0 - bties));
      //            final double sim = cordance / denom;
      //
      //
      ////            
      ////            System.out.printf("n0=%d, ti=%d, tj=%d, conc=%d, denom=%f, sim=%f%n",
      ////                              n0, aties, bties, cordance, denom,
      ////                              cordance / denom);
      ////            
      //            return sim;
      //        }
      //
      //        void calc1() {
      //            int i = 0, j = 0;
      //            while (i + j < A.size + B.size) {
      //                if (i < A.size && (j == B.size || A.keys[i] < B.keys[j])) {
      //                    inner(i, j, A.values[i], 0);
      //                    ++i;
      //                } else if (j < B.size && (i == A.size || B.keys[j] < A.keys[i])) {
      //                    inner(i, j, 0, B.values[j]);
      //                    ++j;
      //                } else if (i < A.size && j < B.size) {
      //                    inner(i, j, A.values[i], B.values[j]);
      //                    ++intersectionSize;
      //                    ++i;
      //                    ++j;
      //                }
      //            }
      //
      //        }
      //
      //        private void inner(final int M, final int N,
      //                           final double aiv, final double biv) {
      //            int i = 0, j = 0;
      //            while (i + j < M + N) {
      //                if (i < M && (j == N || A.keys[i] < B.keys[j])) {
      //                    if (A.values[i] != 0)
      //                        concordance(aiv, biv, A.values[i], 0);
      //                    ++i;
      //                } else if (j < N && (i == M || B.keys[j] < A.keys[i])) {
      //                    if (B.values[j] != 0)
      //                        concordance(aiv, biv, 0, B.values[j]);
      //                    ++j;
      //                } else if (i < M && j < N) {
      //                    concordance(aiv, biv, A.values[i], B.values[j]);
      //                    ++i;
      //                    ++j;
      //                }
      //            }
      //        }
      //
      //        private void concordance(final double aiv, final double biv,
      //                                 final double ajv, final double bjv) {
      //            if (aiv == ajv)
      //                ++this.aties;
      //            if (biv == bjv)
      //                ++this.bties;
      //            this.cordance += signum(aiv - ajv)
      //                    * signum(biv - bjv);
      //        }
      //    }
      //
      //
      //
      //    static double tauB_naive2(SparseDoubleVector A, SparseDoubleVector B) {
      //        System.out.println("tauB_naive2");
      //        assert A.cardinality == B.cardinality :
      //                "Cardinalities not equal " + A.cardinality + " != " + B.cardinality;
      //                ++bi;
      //        int n = A.cardinality;
      //
      //        int cordance = 0;
      //        int intersectionSize = 0;
      //        int unionSize = 0;
      //        int ai = 0;
      //        int bi = 0;
      //
      //        // Count ties
      //        long ta = 0;
      //        long tb = 0;
      //
      //        while (ai < A.size && bi < B.size) {
      //            ++unionSize;
      //            if (A.keys[ai] < B.keys[bi]) {
      //                int aj = ai + 1;
      //                int bj = bi;
      //                while (aj < A.size && bj < B.size) {
      //                    if (A.keys[aj] < B.keys[bj]) {
      //                        if (A.values[ai] == A.values[aj])
      //                            ++ta;
      //                        ++aj;
      //                    } else if (A.keys[aj] > B.keys[bj]) {
      //                        --cordance;
      //                        ++bj;
      //                    } else {
      //                        if (A.values[ai] < A.values[aj])
      //                            ++cordance;
      //                        else if (A.values[ai] > A.values[aj])
      //                            --cordance;
      //                        else
      //                            ++ta;
      //                        ++aj;
      //                        ++bj;
      //                    }
      //                }
      //                cordance -= B.size - bj;
      //                while (aj < A.size) {
      //                    if (A.values[ai] == A.values[aj])
      //                        ++ta;
      //                    ++aj;
      //                }
      //                while (bj < B.size) {
      //                    if (B.values[bi] == B.values[bj])
      //                        ++tb;
      //                    ++bj;
      //                }
      //                ++ai;
      //            } else if (A.keys[ai] > B.keys[bi]) {
      //                int aj = ai;
      //                int bj = bi + 1;
      //                while (aj < A.size && bj < B.size) {
      //                    if (A.keys[aj] < B.keys[bj]) {
      //                        --cordance;
      //                        ++aj;
      //                    } else if (A.keys[aj] > B.keys[bj]) {
      //                        ++bj;
      //                    } else {
      //                        if (B.values[bi] < B.values[bj])
      //                            ++cordance;
      //                        else if (B.values[bi] > B.values[bj])
      //                            --cordance;
      //                        else
      //                            ++tb;
      //                        ++aj;
      //                        ++bj;
      //                    }
      //                }
      //                cordance -= A.size - aj;
      //                while (aj < A.size) {
      //                    if (A.values[ai] == A.values[aj])
      //                        ++ta;
      //                    ++aj;
      //                }
      //                while (bj < B.size) {
      //                    if (B.values[bi] == B.values[bj])
      //                        ++tb;
      //                    ++bj;
      //                }
      //                ++bi;
      //            } else {
      //                ++intersectionSize;
      //                int aj = ai + 1;
      //                int bj = bi + 1;
      //                while (aj < A.size && bj < B.size) {
      //                    if (A.keys[aj] < B.keys[bj]) {
      //                        if (A.values[ai] < A.values[aj])
      //                            --cordance;
      //                        else if (A.values[ai] > A.values[aj])
      //                            ++cordance;
      //                        else
      //                            ++ta;
      //                        ++aj;
      //                    } else if (A.keys[aj] > B.keys[bj]) {
      //                        if (B.values[bi] < B.values[bj])
      //                            --cordance;
      //                        else if (B.values[bi] > B.values[bj])
      //                            ++cordance;
      //                        else
      //                            ++tb;
      //                        ++bj;
      //                    } else {
      //                        final double diff = (A.values[ai] - A.values[aj])
      //                                * (B.values[bi] - B.values[bj]);
      //                        if (diff < 0)
      //                            --cordance;
      //                        else if (diff > 0)
      //                            ++cordance;
      //                        ++aj;
      //                        ++bj;
      //                    }
      //                }
      //                while (aj < A.size) {
      //                    if (A.values[ai] < A.values[aj])
      //                        --cordance;
      //                    else if (A.values[ai] > A.values[aj])
      //                        ++cordance;
      //                    else
      //                        ++ta;
      //                    ++aj;
      //                }
      //                while (bj < B.size) {
      //                    if (B.values[bi] < B.values[bj])
      //                        --cordance;
      //                    else if (B.values[bi] > B.values[bj])
      //                        ++cordance;
      //                    else
      //                        ++tb;
      //                    ++bj;
      //                }
      //                ++ai;
      //                ++bi;
      //            }
      //        }
      //        while (ai < A.size) {
      //            ++unionSize;
      //            int aj = ai + 1;
      //            int bj = bi;
      //            while (aj < A.size && bj < B.size) {
      //                if (A.keys[aj] < B.keys[bj]) {
      //                    ++aj;
      //                } else if (A.keys[aj] > B.keys[bj]) {
      //                    --cordance;
      //                    ++bj;
      //                } else {
      //                    if (A.values[ai] < A.values[aj])
      //                        ++cordance;
      //                    else if (A.values[ai] > A.values[aj])
      //                        --cordance;
      //                    else
      //                        ++ta;
      //                    ++aj;
      //                    ++bj;
      //                }
      //            }
      //            cordance -= B.size - bj;
      //            while (aj < A.size) {
      //                if (A.values[ai] == A.values[aj])
      //                    ++ta;
      //                ++aj;
      //            }
      //            while (bj < B.size) {
      //                if (B.values[bi] == B.values[bj])
      //                    ++tb;
      //                ++bj;
      //            }
      //            ++ai;
      //        }
      //        while (bi < B.size) {
      //            ++unionSize;
      //            int aj = ai;
      //            int bj = bi + 1;
      //            while (aj < A.size && bj < B.size) {
      //                if (A.keys[aj] < B.keys[bj]) {
      //                    --cordance;
      //                    ++aj;
      //                } else if (A.keys[aj] > B.keys[bj]) {
      //                    ++bj;
      //                } else {
      //                    if (B.values[bi] < B.values[bj])
      //                        ++cordance;
      //                    else if (B.values[bi] > B.values[bj])
      //                        --cordance;
      //                    else
      //                        ++tb;
      //                    ++aj;
      //                    ++bj;
      //                }
      //            }
      //            cordance -= A.size - aj;
      //            while (aj < A.size) {
      //                if (A.values[ai] == A.values[aj])
      //                    ++ta;
      //                ++aj;
      //            }
      //            while (bj < B.size) {
      //                if (B.values[bi] == B.values[bj])
      //                    ++tb;
      //                ++bj;
      //            }
      //            ++bi;
      //        }
      //
      //        System.out.println("n=" + n + ", |A|=" + A.size);
      //        System.out.println("n=" + n + ", |B|=" + B.size);
      //        System.out.println(ta + " " + tb);
      //        ta += ((n - A.size) * (n - A.size)) >> 1;
      //        tb += ((n - B.size) * (n - B.size)) >> 1;
      //        System.out.println(ta + " " + tb);
      //
      //        // Comparisons are only done in one direction so double the result
      //        cordance <<= 1;
      //
      //
      //        // Features that don't occur in either vector are a similarity
      //        // between the two sets. For each feature that they both have there
      //        // should be an addition +2 to the sum.
      //        // The relationship between these and disjoint features
      //        cordance += ((n - unionSize) * intersectionSize);
      //        //
      //
      //        long n0 = (n * (n - 1)) >> 1;
      //
      //
      //        double denom = Math.sqrt((n0 - ta) * (n0 - tb));
      //        double sim = (double) (cordance) / denom;
      //
      //        System.out.printf("n0=%d, ti=%d, tj=%d, conc=%d, denom=%f%n",
      //                          n0, ta, tb, cordance, denom);
      //
      //
      //        return sim;
      //    }
      //
      //    static double tauB_naive3(SparseDoubleVector A, SparseDoubleVector B) {
      //        assert A.cardinality == B.cardinality :
      //                "Cardinalities not equal " + A.cardinality + " != " + B.cardinality;
      //        final int totalSize = A.cardinality;
      //        final int aSize = A.size;
      //        final int bSize = B.size;
      //
      //        long cordance = 0;
      //        long aties = 0;
      //        long bties = 0;
      //
      //        int intersectionSize = 0;
      //
      //        int ai = 0, bi = 0;
      //        while (ai + bi < aSize + bSize) {
      //            if (ai < aSize && (bi == bSize || A.keys[ai] < B.keys[bi])) {
      //                int aj = 0, bj = 0;
      //                while (aj + bj < ai + bi) {
      //                    if (aj < ai && (bj == bi || A.keys[aj] < B.keys[bj])) {
      //                        if (A.values[ai] == A.values[aj])
      //                            ++aties;
      //                        ++aj;
      //                    } else if (bj < bi && (aj == ai || B.keys[bj] < A.keys[aj])) {
      //                        cordance += signum(A.values[ai])
      //                                * signum(-B.values[bj]);
      //                        ++bj;
      //                    } else if (aj < ai && bj < bi) {
      //                        if (A.values[ai] == A.values[aj])
      //                            ++aties;
      //                        cordance += signum(A.values[ai] - A.values[aj])
      //                                * signum(-B.values[bj]);
      //                        ++aj;
      //                        ++bj;
      //                    }
      //                }
      //                ++ai;
      //            } else if (bi < bSize && (ai == aSize || B.keys[bi] < A.keys[ai])) {
      //                int aj = 0, bj = 0;
      //                while (aj + bj < ai + bi) {
      //                    if (aj < ai && (bj == bi || A.keys[aj] < B.keys[bj])) {
      //                        cordance += signum(-A.values[aj])
      //                                * signum(B.values[bi]);
      //                        ++aj;
      //                    } else if (bj < bi && (aj == ai || B.keys[bj] < A.keys[aj])) {
      //                        if (B.values[bi] == B.values[bj])
      //                            ++bties;
      //                        ++bj;
      //                    } else if (aj < ai && bj < bi) {
      //                        if (B.values[bi] == B.values[bj])
      //                            ++bties;
      //                        cordance += signum(-A.values[aj])
      //                                * signum(B.values[bi] - B.values[bj]);
      //                        ++aj;
      //                        ++bj;
      //                    }
      //                }
      //            } else if (ai < aSize && bi < bSize) {
      //                int aj = 0, bj = 0;
      //                while (aj + bj < ai + bi) {
      //                    if (aj < ai && (bj == bi || A.keys[aj] < B.keys[bj])) {
      //                        if (A.values[ai] == A.values[aj])
      //                            ++aties;
      //                        cordance += signum(A.values[ai] - A.values[aj])
      //                                * signum(B.values[bi]);
      //                        ++aj;
      //                    } else if (bj < bi && (aj == ai || B.keys[bj] < A.keys[aj])) {
      //                        if (B.values[bi] == B.values[bj])
      //                            ++bties;
      //                        cordance += signum(A.values[ai])
      //                                * signum(B.values[bi] - B.values[bj]);
      //                        ++bj;
      //                    } else if (aj < ai && bj < bi) {
      //                        if (A.values[ai] == A.values[aj])
      //                            ++aties;
      //                        if (B.values[bi] == B.values[bj])
      //                            ++bties;
      //                        cordance += signum(A.values[ai] - A.values[aj])
      //                                * signum(B.values[bi] - B.values[bj]);
      //                        ++aj;
      //                        ++bj;
      //                    }
      //                }
      //                ++intersectionSize;
      //                ++ai;
      //                ++bi;
      //            }
      //        }
      //
      //        final int unionSize = (aSize + bSize) - intersectionSize;
      //
      //        // Features that don't occur in either vector are a similarity
      //        // between the two sets. For each feature that they both have there
      //        // should be an addition +2 to the sum.
      //        // The relationship between these and disjoint features
      //        cordance += ((totalSize - unionSize) * intersectionSize);
      //
      //        // Outside of those in the union all elements are zero add all pairwise
      //        // combinations to the ties counters.
      //        aties += ((totalSize - unionSize) * (totalSize - unionSize - 1)) >> 1;
      //        bties += ((totalSize - unionSize) * (totalSize - unionSize - 1)) >> 1;
      //
      //        // We also need to the add the cross-tries between zeros in union, and
      //        // everything else
      //        aties += ((unionSize - aSize) * (totalSize - unionSize));
      //        bties += ((unionSize - bSize) * (totalSize - unionSize));
      //
      //        // Within the union minus the size of vector, all elements are zero so
      //        // add all pairwise combinations
      //        aties += ((unionSize - aSize) * (unionSize - aSize - 1)) >> 1;
      //        bties += ((unionSize - bSize) * (unionSize - bSize - 1)) >> 1;
      //
      //        final long n0 = (totalSize * (totalSize - 1)) >> 1;
      //        final double denom = Math.sqrt((n0 - aties) * (n0 - bties));
      //        final double sim = cordance / denom;
      ////
      ////        System.out.printf(
      ////                "n0=%d, ti=%d, tj=%d, conc=%d, denom=%f, sim=%f%n",
      ////                n0, aties, bties, cordance, denom, sim);
      //
      //        return sim;
      //    }
      //
      //    static double tauB_merge1(SparseDoubleVector A, SparseDoubleVector B) {
      //        assert A.cardinality == B.cardinality :
      //                "Cardinalities not equal " + A.cardinality + " != " + B.cardinality;
      //        final int totalSize = A.cardinality;
      //        final int aSize = A.size;
      //        final int bSize = B.size;
      //
      //
      //        final double[][] data = unionArray(A, B);
      //
      ////        System.out.println(Arrays.deepToString(data));
      //
      //        sort(data);
      //
      //
      //        final double[] x = new double[data.length];
      //        final double[] y = new double[data.length];
      //
      //        for (int i = 0; i < data.length; i++) {
      //            x[i] = data[i][0];
      //            y[i] = data[i][1];
      //        }
      ////
      ////        System.out.println(Arrays.toString(x));
      ////        System.out.println(Arrays.toString(y));
      ////
      //
      //
      //        System.out.println(swaps(y));
      //
      //
      //        return 0;
      //    }
      //
      //    public static void sort(double[][] a) {
      //        sort1(a, 0, a.length);
      //    }
      //
      //    private static void sort1(double x[][], int off, int len) {
      //        // Insertion sort on smallest arrays
      //        if (len < 7) {
      //            for (int i = off; i < len + off; i++)
      //                for (int j = i; j > off && (x[j - 1][0] > x[j][0] || (x[j - 1][0] == x[j][0] && x[j - 1][1] > x[j][1])); j--)
      //                    swap(x, j, j - 1);
      //            return;
      //        }
      //
      //        // Choose a partition element, v
      //        int m = off + (len >> 1);       // Small arrays, middle element
      //        if (len > 7) {
      //            int l = off;
      //            int n = off + len - 1;
      //            if (len > 40) {        // Big arrays, pseudomedian of 9
      //                int s = len / 8;
      //                l = med3(x, l, l + s, l + 2 * s);
      //                m = med3(x, m - s, m, m + s);
      //                n = med3(x, n - 2 * s, n - s, n);
      //            }
      //            m = med3(x, l, m, n); // Mid-size, med of 3
      //        }
      //        double[] v = x[m];
      //
      //        // Establish Invariant: v* (v)* v*
      //        int a = off, b = a, c = off + len - 1, d = c;
      //        while (true) {
      //            while (b <= c && (x[b][0] < v[0] || (x[b][0] == v[0] && x[b][1] <= v[1]))) {
      //                if (x[b][0] == v[0])
      //                    swap(x, a++, b);
      //                b++;
      //            }
      //            while (c >= b && (x[c][0] > v[0] || (x[b][0] == v[0] && x[b][1] >= v[1]))) {
      //                if (x[c][0] == v[0])
      //                    swap(x, c, d--);
      //                c--;
      //            }
      //            if (b > c)
      //                break;
      //            swap(x, b++, c--);
      //        }
      //
      //        // Swap partition elements back to middle
      //        int s, n = off + len;
      //        s = Math.min(a - off, b - a);
      //        vecswap(x, off, b - s, s);
      //        s = Math.min(d - c, n - d - 1);
      //        vecswap(x, b, n - s, s);
      //
      //        // Recursively sort non-partition-elements
      //        if ((s = b - a) > 1)
      //            sort1(x, off, s);
      //        if ((s = d - c) > 1)
      //            sort1(x, n - s, s);
      //    }
      //
      //    /**
      //     * Swaps x[a] with x[b].
      //     */
      //    private static void swap(double x[][], int a, int b) {
      //        double[] t = x[a];
      //        x[a] = x[b];
      //        x[b] = t;
      //    }
      //
      //    /**
      //     * Swaps x[a .. (a+n-1)] with x[b .. (b+n-1)].
      //     */
      //    private static void vecswap(double x[][], int a, int b, int n) {
      //        for (int i = 0; i < n; i++, a++, b++)
      //            swap(x, a, b);
      //    }
      //
      //    /**
      //     * Returns the index of the median of the three indexed doubles.
      //     */
      //    private static int med3(double x[][], int a, int b, int c) {
      //        return (x[a][0] < x[b][0]
      //                ? (x[b][0] < x[c][0] ? b : x[a][0] < x[c][0] ? c : a)
      //                : (x[b][0] > x[c][0] ? b : x[a][0] > x[c][0] ? c : a));
      //    }
      //
      ////    static double[][] coSort(double[][] data, int left, int right) {
      ////
      ////        int mid = left + (right - left) / 2;
      ////
      ////        return coMerge(coSort(data, left, mid), coSort(data, mid + 1, right));
      ////    }
      	// // }
      	// //
      ////    static double[][] coMerge(double[][] a, double[][] b) {
      ////        double[][] out = new double[2][a[0].length];
      ////
      ////        int i = 0, j = 0, k = 0;
      ////        while (i < A.size && j < B.size) {
      ////            if (A.keys[i] < B.keys[j]) {
      ////                out[0][k] = A.values[i++];
      ////                out[1][k] = 0;
      ////                ++k;
      ////            } else if (B.keys[j] < A.keys[i]) {
      ////                out[0][k] = 0;
      ////                out[1][k] = B.values[j++];
      ////                ++k;
      ////            } else {
      ////                out[0][k] = A.values[i++];
      ////                out[1][k] = B.values[j++];
      ////                ++k;
      ////            }
      ////        }
      ////        while (i < A.size) {
      ////            out[0][k] = A.values[i++];
      ////            bOut[k] = 0;
      ////            ++k;
      ////        }
      ////        while (j < B.size) {
      ////            out[0][k] = 0;
      ////            out[1][k] = B.values[j++];
      ////            ++k;
      ////        }
      ////        return null;
      ////    }
      ////    private static final List entryList(
      ////            SparseDoubleVector vector) {
      ////        final List list =
      ////                new ArrayList(vector.size);
      ////        for (int i = 0; i < vector.size; i++)
      ////            list.add(new AbstractInt2DoubleMap.BasicEntry(vector.keys[i],
      ////                                                          vector.values[i]));
      ////        return list;
      ////    }
      ////
      ////    private static final Comparator VALUE_ORDER_ASC =
      ////            new Comparator() {
      ////
      ////                @Override
      ////                public int compare(Int2DoubleMap.Entry a, Int2DoubleMap.Entry b) {
      ////                    return Double.compare(a.getDoubleValue(), b.getDoubleValue());
      ////                }
      ////            };
      //    static long swaps(double[] y) {
      //        if (y.length < 2)
      //            return 0;
      //        int mid = y.length / 2;
      //
      //        double[] left = Arrays.copyOfRange(y, 0, mid);
      //        double[] right = Arrays.copyOfRange(y, mid, y.length);
      //
      //        return swaps(left) + swaps(right)
      //                + mergeCountSwaps(sorted(left), sorted(right));
      //    }
      //
      //    static double[] sorted(double[] arr) {
      //        double[] copy = Arrays.copyOf(arr, arr.length);
      //        Arrays.sort(copy);
      //        return copy;
      //    }
      //
      //    static long mergeCountSwaps(double[] L, double[] R) {
      //
      //        final int m = R.length;
      //        final int n = L.length;// + m;
      //
      //        long nSwaps = 0;
      //        int i = 0, j = 0;
      //        while (i + j < n) {
      //            if (i >= m || R[j] < L[i]) {
      //                nSwaps += m - i;
      //                ++j;
      //            } else {
      //                ++i;
      //            }
      //        }
      //        return nSwaps;
      //    }
      //
      //    static double[][] unionArray(SparseDoubleVector A, SparseDoubleVector B) {
      //        final double[][] out = new double[A.size + B.size][2];
      //
      //        int i = 0, j = 0, k = 0;
      //        while (i < A.size && j < B.size) {
      //            if (A.keys[i] < B.keys[j]) {
      //                out[k++][0] = A.values[i++];
      //            } else if (B.keys[j] < A.keys[i]) {
      //                out[k++][1] = B.values[j++];
      //            } else {
      //                out[k][0] = A.values[i++];
      //                out[k][1] = B.values[j++];
      //                ++k;
      //            }
      //        }
      //        while (i < A.size)
      //            out[k++][0] = A.values[i++];
      //        while (j < B.size)
      //            out[k++][1] = B.values[j++];
      //
      //        return out.length == k ? out : Arrays.copyOf(out, k);
      //    }
      =======
      	}
      	//
      	// //
      	// // static double tauA_naive1(SparseDoubleVector A, SparseDoubleVector B)
      	// {
      	// // assert A.cardinality == B.cardinality :
      	// // "Cardinalities not equal " + A.cardinality + " != " + B.cardinality;
      	// //
      	// // final int n = A.cardinality;
      	// // double result = 0;
      	// // for (int i = 1; i < n; i++) {
      	// // for (int j = 0; j < i; j++) {
      	// // result += Math.signum(A.get(i) - A.get(j))
      	// // * Math.signum(B.get(i) - B.get(j));
      	// // }
      	// // }
      	// // double denom = 0.5 * n * (n - 1);
      	// //
      	// // return result / denom;
      	// // }
      	// //
      	// // @Test
      	// // @Ignore
      	// // public void testThing() throws Exception {
      	// // System.out.println("test");
      	// //
      	// // DoubleEnumerating indexDeligate = new DoubleEnumeratingDeligate();
      	// // FastWeightedTokenPairVectorSource eventSrc =
      	// // BybloIO.openEventsVectorSource(
      	// // TEST_FRUIT_EVENTS, DEFAULT_CHARSET, indexDeligate);
      	// //
      	// // List> vecs =
      	// // new ArrayList>();
      	// // while (eventSrc.hasNext()) {
      	// // vecs.add(eventSrc.read());
      	// // }
      	// //
      	// // // Calcualte the maximum cardinality of the vectors
      	// // int cardinality = 0;
      	// // for (Indexed A : vecs) {
      	// // if (A.value().cardinality > cardinality)
      	// // cardinality = A.value().cardinality;
      	// // }
      	// //
      	// // //Update all the vectors to have the same cardinality
      	// // for (Indexed A : vecs) {
      	// // A.value().cardinality = cardinality;
      	// // }
      	// ////
      	// //// double tau = naive_tauA(vecs.get(0).value(), vecs.get(0).value());
      	// ////
      	// //// System.out.printf("%d %d %f%n", vecs.get(0).key(),
      	// vecs.get(0).key(),
      	// //// tau);
      	// //
      	// ////
      	// ////
      	// //// tauB_naive1(vecs.get(0).value(), vecs.get(1).value());
      	// //// tauB_naive3(vecs.get(0).value(), vecs.get(1).value());
      	// //////
      	// //// tauB_naive1(vecs.get(0).value(), vecs.get(0).value());
      	// // tauB_merge1(vecs.get(1).value(), vecs.get(0).value());
      	// //
      	// // for (Indexed A : vecs) {
      	// // for (Indexed B : vecs) {
      	// //
      	// ////
      	// //// {
      	// //// System.out.println("imp1");
      	// ////
      	// //// final long t0 = System.currentTimeMillis();
      	// //// final double tau = tauB_naive1(A.value(), B.value());
      	// ////
      	// //// assertTrue("Tau expected in range [-1,+1] but found " + tau,
      	// //// tau >= -1 && tau <= +1);
      	// ////
      	// ////
      	// ////
      	// //// System.out.printf("%d %d %f   (%f seconds)%n",
      	// //// A.key(), B.key(), tau,
      	// //// (System.currentTimeMillis() - t0) / 1000.0);
      	// //// }
      	// //
      	// //// {
      	// //// System.out.println("imp2");
      	// ////
      	// //// final long t0 = System.currentTimeMillis();
      	// //// final double tau = tauB_naive2(A.value(), B.value());
      	// ////
      	// //// assertTrue("Tau expected in range [-1,+1] but found " + tau,
      	// //// tau >= -1 && tau <= +1);
      	// ////
      	// ////
      	// ////
      	// //// System.out.printf("%d %d %f   (%f seconds)%n",
      	// //// A.key(), B.key(), tau,
      	// //// (System.currentTimeMillis() - t0) / 1000.0);
      	// //// }
      	// //
      	// //// {
      	// //
      	// //// final long t0 = System.currentTimeMillis();
      	// //
      	// //// final double tau = new KendallsTauRC().proximity(A.value(),
      	// B.value());
      	// ////
      	// //// assertTrue("Tau expected in range [-1,+1] but found " + tau,
      	// //// tau >= -1 && tau <= +1);
      	// ////
      	// ////
      	// ////
      	// //// System.out.printf("imp3: %d %d %f   (%f seconds)%n",
      	// //// A.key(), B.key(), tau,
      	// //// (System.currentTimeMillis() - t0) / 1000.0);
      	// //
      	// //// }
      	// ////
      	// //// {
      	// ////
      	// ////
      	// // final long t0 = System.currentTimeMillis();
      	// ////
      	// ////
      	// ////
      	// //// final double tau = new TingDem(A.value(), B.value()).calc();
      	// // final double tau = new KendallsTau().proximity(A.value(), B.
      	// // value());
      	// //// assertTrue("Tau expected in range [-1,+1] but found " + tau,
      	// //// tau >= -1 && tau <= +1);
      	// ////
      	// ////
      	// //
      	// // System.out.printf("imp4: %d %d %f   (%f seconds)%n",
      	// // A.key(), B.key(), tau,
      	// // (System.currentTimeMillis() - t0) / 1000.0);
      	// //
      	// //// }
      	// ////
      	// //// {
      	// ////
      	// //// final long t0 = System.currentTimeMillis();
      	// //// final double tau = tauB_merge1(A.value(), B.value());
      	// ////
      	// //// assertTrue("Tau expected in range [-1,+1] but found " + tau,
      	// //// tau >= -1 && tau <= +1);
      	// ////
      	// ////
      	// ////
      	// //// System.out.printf("%d %d %f   (%f seconds)%n",
      	// //// A.key(), B.key(), tau,
      	// //// (System.currentTimeMillis() - t0) / 1000.0);
      	// //// }
      	// //
      	// // }
      	// // }
      	// //
      	// //// System.out.println(vecs);
      	// //
      	// //
      	// // }
      	// //
      	// // static final class TingDem {
      	// //
      	// // private final SparseDoubleVector A;
      	// //
      	// // private final SparseDoubleVector B;
      	// //
      	// // private long cordance = 0;
      	// //
      	// // private long aties = 0;
      	// //
      	// // private long bties = 0;
      	// //
      	// // private int intersectionSize = 0;
      	// //
      	// // public TingDem(SparseDoubleVector A, SparseDoubleVector B) {
      	// // Checks.checkNotNull(A);
      	// // Checks.checkNotNull(B);
      	// // this.A = A;
      	// // this.B = B;
      	// // }
      	// //
      	// // public double calc() {
      	// // assert A.cardinality == B.cardinality :
      	// // "Cardinalities not equal " + A.cardinality + " != " + B.cardinality;
      	// //
      	// // final int N = A.cardinality;
      	// //
      	// // final int L = A.size;
      	// // final int M = B.size;
      	// //
      	// // calc1();
      	// //
      	// // final int unionSize = (L + M) - intersectionSize;
      	// //
      	// // // Features that don't occur in either vector are a similarity
      	// // // between the two sets. For each feature that they both have there
      	// // // should be an addition +2 to the sum.
      	// // // The relationship between these and disjoint features
      	// // cordance += ((N - unionSize) * intersectionSize);
      	// //
      	// // // Outside of those in the union all elements are zero add all
      	// pairwise
      	// // // combinations to the ties counters.
      	// // aties += ((N - unionSize) * (N - unionSize - 1)) >> 1;
      	// // bties += ((N - unionSize) * (N - unionSize - 1)) >> 1;
      	// //
      	// // // We also need to the add the cross-tries between zeros in union, and
      	// // // everything else
      	// // aties += ((unionSize - L) * (N - unionSize));
      	// // bties += ((unionSize - M) * (N - unionSize));
      	// //
      	// // // Within the union minus the size of vector, all elements are zero so
      	// // // add all pairwise combinations
      	// // aties += ((unionSize - L) * (unionSize - L - 1)) >> 1;
      	// // bties += ((unionSize - M) * (unionSize - M - 1)) >> 1;
      	// ////
      	// // final long n0 = (N * (N - 1)) >> 1;
      	// // final double denom = Math.sqrt((n0 - aties) * (n0 - bties));
      	// // final double sim = cordance / denom;
      	// //
      	// //
      	// ////
      	// ////
      	// System.out.printf("n0=%d, ti=%d, tj=%d, conc=%d, denom=%f, sim=%f%n",
      	// //// n0, aties, bties, cordance, denom,
      	// //// cordance / denom);
      	// ////
      	// // return sim;
      	// // }
      	// //
      	// // void calc1() {
      	// // int i = 0, j = 0;
      	// // while (i + j < A.size + B.size) {
      	// // if (i < A.size && (j == B.size || A.keys[i] < B.keys[j])) {
      	// // inner(i, j, A.values[i], 0);
      	// // ++i;
      	// // } else if (j < B.size && (i == A.size || B.keys[j] < A.keys[i])) {
      	// // inner(i, j, 0, B.values[j]);
      	// // ++j;
      	// // } else if (i < A.size && j < B.size) {
      	// // inner(i, j, A.values[i], B.values[j]);
      	// // ++intersectionSize;
      	// // ++i;
      	// // ++j;
      	// // }
      	// // }
      	// //
      	// // }
      	// //
      	// // private void inner(final int M, final int N,
      	// // final double aiv, final double biv) {
      	// // int i = 0, j = 0;
      	// // while (i + j < M + N) {
      	// // if (i < M && (j == N || A.keys[i] < B.keys[j])) {
      	// // if (A.values[i] != 0)
      	// // concordance(aiv, biv, A.values[i], 0);
      	// // ++i;
      	// // } else if (j < N && (i == M || B.keys[j] < A.keys[i])) {
      	// // if (B.values[j] != 0)
      	// // concordance(aiv, biv, 0, B.values[j]);
      	// // ++j;
      	// // } else if (i < M && j < N) {
      	// // concordance(aiv, biv, A.values[i], B.values[j]);
      	// // ++i;
      	// // ++j;
      	// // }
      	// // }
      	// // }
      	// //
      	// // private void concordance(final double aiv, final double biv,
      	// // final double ajv, final double bjv) {
      	// // if (aiv == ajv)
      	// // ++this.aties;
      	// // if (biv == bjv)
      	// // ++this.bties;
      	// // this.cordance += signum(aiv - ajv)
      	// // * signum(biv - bjv);
      	// // }
      	// // }
      	// //
      	// //
      	// //
      	// // static double tauB_naive2(SparseDoubleVector A, SparseDoubleVector B)
      	// {
      	// // System.out.println("tauB_naive2");
      	// // assert A.cardinality == B.cardinality :
      	// // "Cardinalities not equal " + A.cardinality + " != " + B.cardinality;
      	// // int n = A.cardinality;
      	// //
      	// // int cordance = 0;
      	// // int intersectionSize = 0;
      	// // int unionSize = 0;
      	// // int ai = 0;
      	// // int bi = 0;
      	// //
      	// // // Count ties
      	// // long ta = 0;
      	// // long tb = 0;
      	// //
      	// // while (ai < A.size && bi < B.size) {
      	// // ++unionSize;
      	// // if (A.keys[ai] < B.keys[bi]) {
      	// // int aj = ai + 1;
      	// // int bj = bi;
      	// // while (aj < A.size && bj < B.size) {
      	// // if (A.keys[aj] < B.keys[bj]) {
      	// // if (A.values[ai] == A.values[aj])
      	// // ++ta;
      	// // ++aj;
      	// // } else if (A.keys[aj] > B.keys[bj]) {
      	// // --cordance;
      	// // ++bj;
      	// // } else {
      	// // if (A.values[ai] < A.values[aj])
      	// // ++cordance;
      	// // else if (A.values[ai] > A.values[aj])
      	// // --cordance;
      	// // else
      	// // ++ta;
      	// // ++aj;
      	// // ++bj;
      	// // }
      	// // }
      	// // cordance -= B.size - bj;
      	// // while (aj < A.size) {
      	// // if (A.values[ai] == A.values[aj])
      	// // ++ta;
      	// // ++aj;
      	// // }
      	// // while (bj < B.size) {
      	// // if (B.values[bi] == B.values[bj])
      	// // ++tb;
      	// // ++bj;
      	// // }
      	// // ++ai;
      	// // } else if (A.keys[ai] > B.keys[bi]) {
      	// // int aj = ai;
      	// // int bj = bi + 1;
      	// // while (aj < A.size && bj < B.size) {
      	// // if (A.keys[aj] < B.keys[bj]) {
      	// // --cordance;
      	// // ++aj;
      	// // } else if (A.keys[aj] > B.keys[bj]) {
      	// // ++bj;
      	// // } else {
      	// // if (B.values[bi] < B.values[bj])
      	// // ++cordance;
      	// // else if (B.values[bi] > B.values[bj])
      	// // --cordance;
      	// // else
      	// // ++tb;
      	// // ++aj;
      	// // ++bj;
      	// // }
      	// // }
      	// // cordance -= A.size - aj;
      	// // while (aj < A.size) {
      	// // if (A.values[ai] == A.values[aj])
      	// // ++ta;
      	// // ++aj;
      	// // }
      	// // while (bj < B.size) {
      	// // if (B.values[bi] == B.values[bj])
      	// // ++tb;
      	// // ++bj;
      	// // }
      	// // ++bi;
      	// // } else {
      	// // ++intersectionSize;
      	// // int aj = ai + 1;
      	// // int bj = bi + 1;
      	// // while (aj < A.size && bj < B.size) {
      	// // if (A.keys[aj] < B.keys[bj]) {
      	// // if (A.values[ai] < A.values[aj])
      	// // --cordance;
      	// // else if (A.values[ai] > A.values[aj])
      	// // ++cordance;
      	// // else
      	// // ++ta;
      	// // ++aj;
      	// // } else if (A.keys[aj] > B.keys[bj]) {
      	// // if (B.values[bi] < B.values[bj])
      	// // --cordance;
      	// // else if (B.values[bi] > B.values[bj])
      	// // ++cordance;
      	// // else
      	// // ++tb;
      	// // ++bj;
      	// // } else {
      	// // final double diff = (A.values[ai] - A.values[aj])
      	// // * (B.values[bi] - B.values[bj]);
      	// // if (diff < 0)
      	// // --cordance;
      	// // else if (diff > 0)
      	// // ++cordance;
      	// // ++aj;
      	// // ++bj;
      	// // }
      	// // }
      	// // while (aj < A.size) {
      	// // if (A.values[ai] < A.values[aj])
      	// // --cordance;
      	// // else if (A.values[ai] > A.values[aj])
      	// // ++cordance;
      	// // else
      	// // ++ta;
      	// // ++aj;
      	// // }
      	// // while (bj < B.size) {
      	// // if (B.values[bi] < B.values[bj])
      	// // --cordance;
      	// // else if (B.values[bi] > B.values[bj])
      	// // ++cordance;
      	// // else
      	// // ++tb;
      	// // ++bj;
      	// // }
      	// // ++ai;
      	// // ++bi;
      	// // }
      	// // }
      	// // while (ai < A.size) {
      	// // ++unionSize;
      	// // int aj = ai + 1;
      	// // int bj = bi;
      	// // while (aj < A.size && bj < B.size) {
      	// // if (A.keys[aj] < B.keys[bj]) {
      	// // ++aj;
      	// // } else if (A.keys[aj] > B.keys[bj]) {
      	// // --cordance;
      	// // ++bj;
      	// // } else {
      	// // if (A.values[ai] < A.values[aj])
      	// // ++cordance;
      	// // else if (A.values[ai] > A.values[aj])
      	// // --cordance;
      	// // else
      	// // ++ta;
      	// // ++aj;
      	// // ++bj;
      	// // }
      	// // }
      	// // cordance -= B.size - bj;
      	// // while (aj < A.size) {
      	// // if (A.values[ai] == A.values[aj])
      	// // ++ta;
      	// // ++aj;
      	// // }
      	// // while (bj < B.size) {
      	// // if (B.values[bi] == B.values[bj])
      	// // ++tb;
      	// // ++bj;
      	// // }
      	// // ++ai;
      	// // }
      	// // while (bi < B.size) {
      	// // ++unionSize;
      	// // int aj = ai;
      	// // int bj = bi + 1;
      	// // while (aj < A.size && bj < B.size) {
      	// // if (A.keys[aj] < B.keys[bj]) {
      	// // --cordance;
      	// // ++aj;
      	// // } else if (A.keys[aj] > B.keys[bj]) {
      	// // ++bj;
      	// // } else {
      	// // if (B.values[bi] < B.values[bj])
      	// // ++cordance;
      	// // else if (B.values[bi] > B.values[bj])
      	// // --cordance;
      	// // else
      	// // ++tb;
      	// // ++aj;
      	// // ++bj;
      	// // }
      	// // }
      	// // cordance -= A.size - aj;
      	// // while (aj < A.size) {
      	// // if (A.values[ai] == A.values[aj])
      	// // ++ta;
      	// // ++aj;
      	// // }
      	// // while (bj < B.size) {
      	// // if (B.values[bi] == B.values[bj])
      	// // ++tb;
      	// // ++bj;
      	// // }
      	// // ++bi;
      	// // }
      	// //
      	// // System.out.println("n=" + n + ", |A|=" + A.size);
      	// // System.out.println("n=" + n + ", |B|=" + B.size);
      	// // System.out.println(ta + " " + tb);
      	// // ta += ((n - A.size) * (n - A.size)) >> 1;
      	// // tb += ((n - B.size) * (n - B.size)) >> 1;
      	// // System.out.println(ta + " " + tb);
      	// //
      	// // // Comparisons are only done in one direction so double the result
      	// // cordance <<= 1;
      	// //
      	// //
      	// // // Features that don't occur in either vector are a similarity
      	// // // between the two sets. For each feature that they both have there
      	// // // should be an addition +2 to the sum.
      	// // // The relationship between these and disjoint features
      	// // cordance += ((n - unionSize) * intersectionSize);
      	// // //
      	// //
      	// // long n0 = (n * (n - 1)) >> 1;
      	// //
      	// //
      	// // double denom = Math.sqrt((n0 - ta) * (n0 - tb));
      	// // double sim = (double) (cordance) / denom;
      	// //
      	// // System.out.printf("n0=%d, ti=%d, tj=%d, conc=%d, denom=%f%n",
      	// // n0, ta, tb, cordance, denom);
      	// //
      	// //
      	// // return sim;
      	// // }
      	// //
      	// // static double tauB_naive3(SparseDoubleVector A, SparseDoubleVector B)
      	// {
      	// // assert A.cardinality == B.cardinality :
      	// // "Cardinalities not equal " + A.cardinality + " != " + B.cardinality;
      	// // final int totalSize = A.cardinality;
      	// // final int aSize = A.size;
      	// // final int bSize = B.size;
      	// //
      	// // long cordance = 0;
      	// // long aties = 0;
      	// // long bties = 0;
      	// //
      	// // int intersectionSize = 0;
      	// //
      	// // int ai = 0, bi = 0;
      	// // while (ai + bi < aSize + bSize) {
      	// // if (ai < aSize && (bi == bSize || A.keys[ai] < B.keys[bi])) {
      	// // int aj = 0, bj = 0;
      	// // while (aj + bj < ai + bi) {
      	// // if (aj < ai && (bj == bi || A.keys[aj] < B.keys[bj])) {
      	// // if (A.values[ai] == A.values[aj])
      	// // ++aties;
      	// // ++aj;
      	// // } else if (bj < bi && (aj == ai || B.keys[bj] < A.keys[aj])) {
      	// // cordance += signum(A.values[ai])
      	// // * signum(-B.values[bj]);
      	// // ++bj;
      	// // } else if (aj < ai && bj < bi) {
      	// // if (A.values[ai] == A.values[aj])
      	// // ++aties;
      	// // cordance += signum(A.values[ai] - A.values[aj])
      	// // * signum(-B.values[bj]);
      	// // ++aj;
      	// // ++bj;
      	// // }
      	// // }
      	// // ++ai;
      	// // } else if (bi < bSize && (ai == aSize || B.keys[bi] < A.keys[ai])) {
      	// // int aj = 0, bj = 0;
      	// // while (aj + bj < ai + bi) {
      	// // if (aj < ai && (bj == bi || A.keys[aj] < B.keys[bj])) {
      	// // cordance += signum(-A.values[aj])
      	// // * signum(B.values[bi]);
      	// // ++aj;
      	// // } else if (bj < bi && (aj == ai || B.keys[bj] < A.keys[aj])) {
      	// // if (B.values[bi] == B.values[bj])
      	// // ++bties;
      	// // ++bj;
      	// // } else if (aj < ai && bj < bi) {
      	// // if (B.values[bi] == B.values[bj])
      	// // ++bties;
      	// // cordance += signum(-A.values[aj])
      	// // * signum(B.values[bi] - B.values[bj]);
      	// // ++aj;
      	// // ++bj;
      	// // }
      	// // }
      	// // ++bi;
      	// // } else if (ai < aSize && bi < bSize) {
      	// // int aj = 0, bj = 0;
      	// // while (aj + bj < ai + bi) {
      	// // if (aj < ai && (bj == bi || A.keys[aj] < B.keys[bj])) {
      	// // if (A.values[ai] == A.values[aj])
      	// // ++aties;
      	// // cordance += signum(A.values[ai] - A.values[aj])
      	// // * signum(B.values[bi]);
      	// // ++aj;
      	// // } else if (bj < bi && (aj == ai || B.keys[bj] < A.keys[aj])) {
      	// // if (B.values[bi] == B.values[bj])
      	// // ++bties;
      	// // cordance += signum(A.values[ai])
      	// // * signum(B.values[bi] - B.values[bj]);
      	// // ++bj;
      	// // } else if (aj < ai && bj < bi) {
      	// // if (A.values[ai] == A.values[aj])
      	// // ++aties;
      	// // if (B.values[bi] == B.values[bj])
      	// // ++bties;
      	// // cordance += signum(A.values[ai] - A.values[aj])
      	// // * signum(B.values[bi] - B.values[bj]);
      	// // ++aj;
      	// // ++bj;
      	// // }
      	// // }
      	// // ++intersectionSize;
      	// // ++ai;
      	// // ++bi;
      	// // }
      	// // }
      	// //
      	// // final int unionSize = (aSize + bSize) - intersectionSize;
      	// //
      	// // // Features that don't occur in either vector are a similarity
      	// // // between the two sets. For each feature that they both have there
      	// // // should be an addition +2 to the sum.
      	// // // The relationship between these and disjoint features
      	// // cordance += ((totalSize - unionSize) * intersectionSize);
      	// //
      	// // // Outside of those in the union all elements are zero add all
      	// pairwise
      	// // // combinations to the ties counters.
      	// // aties += ((totalSize - unionSize) * (totalSize - unionSize - 1)) >> 1;
      	// // bties += ((totalSize - unionSize) * (totalSize - unionSize - 1)) >> 1;
      	// //
      	// // // We also need to the add the cross-tries between zeros in union, and
      	// // // everything else
      	// // aties += ((unionSize - aSize) * (totalSize - unionSize));
      	// // bties += ((unionSize - bSize) * (totalSize - unionSize));
      	// //
      	// // // Within the union minus the size of vector, all elements are zero so
      	// // // add all pairwise combinations
      	// // aties += ((unionSize - aSize) * (unionSize - aSize - 1)) >> 1;
      	// // bties += ((unionSize - bSize) * (unionSize - bSize - 1)) >> 1;
      	// //
      	// // final long n0 = (totalSize * (totalSize - 1)) >> 1;
      	// // final double denom = Math.sqrt((n0 - aties) * (n0 - bties));
      	// // final double sim = cordance / denom;
      	// ////
      	// //// System.out.printf(
      	// //// "n0=%d, ti=%d, tj=%d, conc=%d, denom=%f, sim=%f%n",
      	// //// n0, aties, bties, cordance, denom, sim);
      	// //
      	// // return sim;
      	// // }
      	// //
      	// // static double tauB_merge1(SparseDoubleVector A, SparseDoubleVector B)
      	// {
      	// // assert A.cardinality == B.cardinality :
      	// // "Cardinalities not equal " + A.cardinality + " != " + B.cardinality;
      	// // final int totalSize = A.cardinality;
      	// // final int aSize = A.size;
      	// // final int bSize = B.size;
      	// //
      	// //
      	// // final double[][] data = unionArray(A, B);
      	// //
      	// //// System.out.println(Arrays.deepToString(data));
      	// //
      	// // sort(data);
      	// //
      	// //
      	// // final double[] x = new double[data.length];
      	// // final double[] y = new double[data.length];
      	// //
      	// // for (int i = 0; i < data.length; i++) {
      	// // x[i] = data[i][0];
      	// // y[i] = data[i][1];
      	// // }
      	// ////
      	// //// System.out.println(Arrays.toString(x));
      	// //// System.out.println(Arrays.toString(y));
      	// ////
      	// //
      	// //
      	// // System.out.println(swaps(y));
      	// //
      	// //
      	// // return 0;
      	// // }
      	// //
      	// // public static void sort(double[][] a) {
      	// // sort1(a, 0, a.length);
      	// // }
      	// //
      	// // private static void sort1(double x[][], int off, int len) {
      	// // // Insertion sort on smallest arrays
      	// // if (len < 7) {
      	// // for (int i = off; i < len + off; i++)
      	// // for (int j = i; j > off && (x[j - 1][0] > x[j][0] || (x[j - 1][0] ==
      	// x[j][0] && x[j - 1][1] > x[j][1])); j--)
      	// // swap(x, j, j - 1);
      	// // return;
      	// // }
      	// //
      	// // // Choose a partition element, v
      	// // int m = off + (len >> 1); // Small arrays, middle element
      	// // if (len > 7) {
      	// // int l = off;
      	// // int n = off + len - 1;
      	// // if (len > 40) { // Big arrays, pseudomedian of 9
      	// // int s = len / 8;
      	// // l = med3(x, l, l + s, l + 2 * s);
      	// // m = med3(x, m - s, m, m + s);
      	// // n = med3(x, n - 2 * s, n - s, n);
      	// // }
      	// // m = med3(x, l, m, n); // Mid-size, med of 3
      	// // }
      	// // double[] v = x[m];
      	// //
      	// // // Establish Invariant: v* (v)* v*
      	// // int a = off, b = a, c = off + len - 1, d = c;
      	// // while (true) {
      	// // while (b <= c && (x[b][0] < v[0] || (x[b][0] == v[0] && x[b][1] <=
      	// v[1]))) {
      	// // if (x[b][0] == v[0])
      	// // swap(x, a++, b);
      	// // b++;
      	// // }
      	// // while (c >= b && (x[c][0] > v[0] || (x[b][0] == v[0] && x[b][1] >=
      	// v[1]))) {
      	// // if (x[c][0] == v[0])
      	// // swap(x, c, d--);
      	// // c--;
      	// // }
      	// // if (b > c)
      	// // break;
      	// // swap(x, b++, c--);
      	// // }
      	// //
      	// // // Swap partition elements back to middle
      	// // int s, n = off + len;
      	// // s = Math.min(a - off, b - a);
      	// // vecswap(x, off, b - s, s);
      	// // s = Math.min(d - c, n - d - 1);
      	// // vecswap(x, b, n - s, s);
      	// //
      	// // // Recursively sort non-partition-elements
      	// // if ((s = b - a) > 1)
      	// // sort1(x, off, s);
      	// // if ((s = d - c) > 1)
      	// // sort1(x, n - s, s);
      	// // }
      	// //
      	// // /**
      	// // * Swaps x[a] with x[b].
      	// // */
      	// // private static void swap(double x[][], int a, int b) {
      	// // double[] t = x[a];
      	// // x[a] = x[b];
      	// // x[b] = t;
      	// // }
      	// //
      	// // /**
      	// // * Swaps x[a .. (a+n-1)] with x[b .. (b+n-1)].
      	// // */
      	// // private static void vecswap(double x[][], int a, int b, int n) {
      	// // for (int i = 0; i < n; i++, a++, b++)
      	// // swap(x, a, b);
      	// // }
      	// //
      	// // /**
      	// // * Returns the index of the median of the three indexed doubles.
      	// // */
      	// // private static int med3(double x[][], int a, int b, int c) {
      	// // return (x[a][0] < x[b][0]
      	// // ? (x[b][0] < x[c][0] ? b : x[a][0] < x[c][0] ? c : a)
      	// // : (x[b][0] > x[c][0] ? b : x[a][0] > x[c][0] ? c : a));
      	// // }
      	// //
      	// //// static double[][] coSort(double[][] data, int left, int right) {
      	// ////
      	// //// int mid = left + (right - left) / 2;
      	// ////
      	// //// return coMerge(coSort(data, left, mid), coSort(data, mid + 1,
      	// right));
      	// //// }
      	// //////
      	// //// static double[][] coMerge(double[][] a, double[][] b) {
      	// //// double[][] out = new double[2][a[0].length];
      	// ////
      	// //// int i = 0, j = 0, k = 0;
      	// //// while (i < A.size && j < B.size) {
      	// //// if (A.keys[i] < B.keys[j]) {
      	// //// out[0][k] = A.values[i++];
      	// //// out[1][k] = 0;
      	// //// ++k;
      	// //// } else if (B.keys[j] < A.keys[i]) {
      	// //// out[0][k] = 0;
      	// //// out[1][k] = B.values[j++];
      	// //// ++k;
      	// //// } else {
      	// //// out[0][k] = A.values[i++];
      	// //// out[1][k] = B.values[j++];
      	// //// ++k;
      	// //// }
      	// //// }
      	// //// while (i < A.size) {
      	// //// out[0][k] = A.values[i++];
      	// //// bOut[k] = 0;
      	// //// ++k;
      	// //// }
      	// //// while (j < B.size) {
      	// //// out[0][k] = 0;
      	// //// out[1][k] = B.values[j++];
      	// //// ++k;
      	// //// }
      	// //// return null;
      	// //// }
      	// //// private static final List entryList(
      	// //// SparseDoubleVector vector) {
      	// //// final List list =
      	// //// new ArrayList(vector.size);
      	// //// for (int i = 0; i < vector.size; i++)
      	// //// list.add(new AbstractInt2DoubleMap.BasicEntry(vector.keys[i],
      	// //// vector.values[i]));
      	// //// return list;
      	// //// }
      	// ////
      	// //// private static final Comparator VALUE_ORDER_ASC
      	// =
      	// //// new Comparator() {
      	// ////
      	// //// @Override
      	// //// public int compare(Int2DoubleMap.Entry a, Int2DoubleMap.Entry b) {
      	// //// return Double.compare(a.getDoubleValue(), b.getDoubleValue());
      	// //// }
      	// //// };
      	// // static long swaps(double[] y) {
      	// // if (y.length < 2)
      	// // return 0;
      	// // int mid = y.length / 2;
      	// //
      	// // double[] left = Arrays.copyOfRange(y, 0, mid);
      	// // double[] right = Arrays.copyOfRange(y, mid, y.length);
      	// //
      	// // return swaps(left) + swaps(right)
      	// // + mergeCountSwaps(sorted(left), sorted(right));
      	// // }
      	// //
      	// // static double[] sorted(double[] arr) {
      	// // double[] copy = Arrays.copyOf(arr, arr.length);
      	// // Arrays.sort(copy);
      	// // return copy;
      	// // static long mergeCountSwaps(double[] L, double[] R) {
      	// //
      	// // final int m = R.length;
      	// // final int n = L.length;// + m;
      	// //
      	// // long nSwaps = 0;
      	// // int i = 0, j = 0;
      	// // while (i + j < n) {
      	// // if (i >= m || R[j] < L[i]) {
      	// // nSwaps += m - i;
      	// // ++j;
      	// // } else {
      	// // ++i;
      	// // }
      	// // }
      	// // return nSwaps;
      	// // }
      	// //
      	// // static double[][] unionArray(SparseDoubleVector A, SparseDoubleVector
      	// B) {
      	// // final double[][] out = new double[A.size + B.size][2];
      	// //
      	// // int i = 0, j = 0, k = 0;
      	// // while (i < A.size && j < B.size) {
      	// // if (A.keys[i] < B.keys[j]) {
      	// // out[k++][0] = A.values[i++];
      	// // } else if (B.keys[j] < A.keys[i]) {
      	// // out[k++][1] = B.values[j++];
      	// // } else {
      	// // out[k][0] = A.values[i++];
      	// // out[k][1] = B.values[j++];
      	// // ++k;
      	// // }
      	// // }
      	// // while (i < A.size)
      	// // out[k++][0] = A.values[i++];
      	// // while (j < B.size)
      	// // out[k++][1] = B.values[j++];
      	// //
      	// // return out.length == k ? out : Arrays.copyOf(out, k);
      	// // }
      >>>>>>> 5f0ba9177b34449ea27dabdc17fd0793620c7d56
      }
      Solution content
      			throw new UnsupportedOperationException();
      		}
      
      	}
      	//
      	// //
      	// // static double tauA_naive1(SparseDoubleVector A, SparseDoubleVector B)
      	// {
      	// // assert A.cardinality == B.cardinality :
      	// // "Cardinalities not equal " + A.cardinality + " != " + B.cardinality;
      	// //
      	// // final int n = A.cardinality;
      	// // double result = 0;
      	// // for (int i = 1; i < n; i++) {
      	// // for (int j = 0; j < i; j++) {
      	// // result += Math.signum(A.get(i) - A.get(j))
      	// // * Math.signum(B.get(i) - B.get(j));
      	// // }
      	// // }
      	// // double denom = 0.5 * n * (n - 1);
      	// //
      	// // return result / denom;
      	// // }
      	// //
      	// // @Test
      	// // @Ignore
      	// // public void testThing() throws Exception {
      	// // System.out.println("test");
      	// //
      	// // DoubleEnumerating indexDelegate = new DoubleEnumeratingDelegate();
      	// // FastWeightedTokenPairVectorSource eventSrc =
      	// // BybloIO.openEventsVectorSource(
      	// // TEST_FRUIT_EVENTS, DEFAULT_CHARSET, indexDelegate);
      	// //
      	// // List> vecs =
      	// // new ArrayList>();
      	// // while (eventSrc.hasNext()) {
      	// // vecs.add(eventSrc.read());
      	// // }
      	// //
      	// // // Calcualte the maximum cardinality of the vectors
      	// // int cardinality = 0;
      	// // for (Indexed A : vecs) {
      	// // if (A.value().cardinality > cardinality)
      	// // cardinality = A.value().cardinality;
      	// // }
      	// //
      	// // //Update all the vectors to have the same cardinality
      	// // for (Indexed A : vecs) {
      	// // A.value().cardinality = cardinality;
      	// // }
      	// ////
      	// //// double tau = naive_tauA(vecs.get(0).value(), vecs.get(0).value());
      	// ////
      	// //// System.out.printf("%d %d %f%n", vecs.get(0).key(),
      	// //// }
      	// //
      	// vecs.get(0).key(),
      	// //// tau);
      	// //
      	// ////
      	// ////
      	// //// tauB_naive1(vecs.get(0).value(), vecs.get(1).value());
      	// //// tauB_naive3(vecs.get(0).value(), vecs.get(1).value());
      	// //////
      	// //// tauB_naive1(vecs.get(0).value(), vecs.get(0).value());
      	// // tauB_merge1(vecs.get(1).value(), vecs.get(0).value());
      	// //
      	// // for (Indexed A : vecs) {
      	// // for (Indexed B : vecs) {
      	// //
      	// ////
      	// //// {
      	// //// System.out.println("imp1");
      	// ////
      	// //// final long t0 = System.currentTimeMillis();
      	// //// final double tau = tauB_naive1(A.value(), B.value());
      	// ////
      	// //// assertTrue("Tau expected in range [-1,+1] but found " + tau,
      	// //// tau >= -1 && tau <= +1);
      	// ////
      	// ////
      	// ////
      	// //// System.out.printf("%d %d %f   (%f seconds)%n",
      	// //// A.key(), B.key(), tau,
      	// //// (System.currentTimeMillis() - t0) / 1000.0);
      	// //// }
      	// //
      	// //// {
      	// //// System.out.println("imp2");
      	// ////
      	// //// final long t0 = System.currentTimeMillis();
      	// //// final double tau = tauB_naive2(A.value(), B.value());
      	// ////
      	// //// assertTrue("Tau expected in range [-1,+1] but found " + tau,
      	// //// tau >= -1 && tau <= +1);
      	// ////
      	// ////
      	// ////
      	// //// System.out.printf("%d %d %f   (%f seconds)%n",
      	// //// A.key(), B.key(), tau,
      	// //// (System.currentTimeMillis() - t0) / 1000.0);
      	// //// {
      	// //
      	// //// final long t0 = System.currentTimeMillis();
      	// //
      	// //// final double tau = new KendallsTauRC().proximity(A.value(),
      	// B.value());
      	// ////
      	// //// assertTrue("Tau expected in range [-1,+1] but found " + tau,
      	// //// tau >= -1 && tau <= +1);
      	// ////
      	// ////
      	// ////
      	// //// System.out.printf("imp3: %d %d %f   (%f seconds)%n",
      	// //// A.key(), B.key(), tau,
      	// //// (System.currentTimeMillis() - t0) / 1000.0);
      	// //
      	// //// }
      	// ////
      	// //// {
      	// ////
      	// ////
      	// // final long t0 = System.currentTimeMillis();
      	// ////
      	// ////
      	// ////
      	// //// final double tau = new TingDem(A.value(), B.value()).calc();
      	// // final double tau = new KendallsTau().proximity(A.value(), B.
      	// // value());
      	// //// assertTrue("Tau expected in range [-1,+1] but found " + tau,
      	// //// tau >= -1 && tau <= +1);
      	// ////
      	// ////
      	// //
      	// // System.out.printf("imp4: %d %d %f   (%f seconds)%n",
      	// // A.key(), B.key(), tau,
      	// // (System.currentTimeMillis() - t0) / 1000.0);
      	// //
      	// //// }
      	// ////
      	// //// {
      	// ////
      	// //// final long t0 = System.currentTimeMillis();
      	// //// final double tau = tauB_merge1(A.value(), B.value());
      	// ////
      	// //// assertTrue("Tau expected in range [-1,+1] but found " + tau,
      	// //// tau >= -1 && tau <= +1);
      	// ////
      	// ////
      	// ////
      	// //// System.out.printf("%d %d %f   (%f seconds)%n",
      	// //// A.key(), B.key(), tau,
      	// //// (System.currentTimeMillis() - t0) / 1000.0);
      	// //// }
      	// //
      	// // }
      	// // }
      	// //
      	// //// System.out.println(vecs);
      	// //
      	// //
      	// // }
      	// //
      	// //
      	// // static final class TingDem {
      	// //
      	// // private final SparseDoubleVector A;
      	// //
      	// // private final SparseDoubleVector B;
      	// //
      	// // private long cordance = 0;
      	// //
      	// // private long aties = 0;
      	// //
      	// // private long bties = 0;
      	// //
      	// // private int intersectionSize = 0;
      	// //
      	// // public TingDem(SparseDoubleVector A, SparseDoubleVector B) {
      	// // Checks.checkNotNull(A);
      	// // Checks.checkNotNull(B);
      	// // this.A = A;
      	// // this.B = B;
      	// // }
      	// //
      	// // public double calc() {
      	// // assert A.cardinality == B.cardinality :
      	// // "Cardinalities not equal " + A.cardinality + " != " + B.cardinality;
      	// //
      	// // final int N = A.cardinality;
      	// //
      	// // final int L = A.size;
      	// // final int M = B.size;
      	// //
      	// // calc1();
      	// //
      	// // final int unionSize = (L + M) - intersectionSize;
      	// //
      	// // // Features that don't occur in either vector are a similarity
      	// // // between the two sets. For each feature that they both have there
      	// // // should be an addition +2 to the sum.
      	// // // The relationship between these and disjoint features
      	// // cordance += ((N - unionSize) * intersectionSize);
      	// //
      	// // // Outside of those in the union all elements are zero add all
      	// pairwise
      	// // // combinations to the ties counters.
      	// // aties += ((N - unionSize) * (N - unionSize - 1)) >> 1;
      	// // bties += ((N - unionSize) * (N - unionSize - 1)) >> 1;
      	// // // We also need to the add the cross-tries between zeros in union, and
      	// // // everything else
      	// // aties += ((unionSize - L) * (N - unionSize));
      	// // bties += ((unionSize - M) * (N - unionSize));
      	// //
      	// // // Within the union minus the size of vector, all elements are zero so
      	// // // add all pairwise combinations
      	// // aties += ((unionSize - L) * (unionSize - L - 1)) >> 1;
      	// // bties += ((unionSize - M) * (unionSize - M - 1)) >> 1;
      	// ////
      	// // final long n0 = (N * (N - 1)) >> 1;
      	// // final double denom = Math.sqrt((n0 - aties) * (n0 - bties));
      	// // final double sim = cordance / denom;
      	// //
      	// //
      	// ////
      	// ////
      	// System.out.printf("n0=%d, ti=%d, tj=%d, conc=%d, denom=%f, sim=%f%n",
      	// //// n0, aties, bties, cordance, denom,
      	// //// cordance / denom);
      	// ////
      	// // return sim;
      	// // }
      	// //
      	// // void calc1() {
      	// // int i = 0, j = 0;
      	// // while (i + j < A.size + B.size) {
      	// // if (i < A.size && (j == B.size || A.keys[i] < B.keys[j])) {
      	// // inner(i, j, A.values[i], 0);
      	// // ++i;
      	// // } else if (j < B.size && (i == A.size || B.keys[j] < A.keys[i])) {
      	// // inner(i, j, 0, B.values[j]);
      	// // ++j;
      	// // } else if (i < A.size && j < B.size) {
      	// // inner(i, j, A.values[i], B.values[j]);
      	// // ++intersectionSize;
      	// // ++i;
      	// // ++j;
      	// // }
      	// // }
      	// //
      	// // }
      	// //
      	// // private void inner(final int M, final int N,
      	// // final double aiv, final double biv) {
      	// // int i = 0, j = 0;
      	// // while (i + j < M + N) {
      	// // if (i < M && (j == N || A.keys[i] < B.keys[j])) {
      	// // if (A.values[i] != 0)
      	// // concordance(aiv, biv, A.values[i], 0);
      	// // ++i;
      	// // } else if (j < N && (i == M || B.keys[j] < A.keys[i])) {
      	// // if (B.values[j] != 0)
      	// // concordance(aiv, biv, 0, B.values[j]);
      	// // ++j;
      	// // } else if (i < M && j < N) {
      	// // concordance(aiv, biv, A.values[i], B.values[j]);
      	// // ++i;
      	// // ++j;
      	// // }
      	// // }
      	// // }
      	// //
      	// // private void concordance(final double aiv, final double biv,
      	// // final double ajv, final double bjv) {
      	// // if (aiv == ajv)
      	// // ++this.aties;
      	// // if (biv == bjv)
      	// // ++this.bties;
      	// // this.cordance += signum(aiv - ajv)
      	// // * signum(biv - bjv);
      	// // }
      	// // }
      	// //
      	// //
      	// //
      	// // static double tauB_naive2(SparseDoubleVector A, SparseDoubleVector B)
      	// {
      	// // System.out.println("tauB_naive2");
      	// // assert A.cardinality == B.cardinality :
      	// // "Cardinalities not equal " + A.cardinality + " != " + B.cardinality;
      	// // int n = A.cardinality;
      	// //
      	// // int cordance = 0;
      	// // int intersectionSize = 0;
      	// // int unionSize = 0;
      	// // int ai = 0;
      	// // int bi = 0;
      	// //
      	// // // Count ties
      	// // long ta = 0;
      	// // long tb = 0;
      	// //
      	// // while (ai < A.size && bi < B.size) {
      	// // ++unionSize;
      	// // if (A.keys[ai] < B.keys[bi]) {
      	// // int aj = ai + 1;
      	// // int bj = bi;
      	// // while (aj < A.size && bj < B.size) {
      	// // if (A.keys[aj] < B.keys[bj]) {
      	// // if (A.values[ai] == A.values[aj])
      	// // ++ta;
      	// // ++aj;
      	// // } else if (A.keys[aj] > B.keys[bj]) {
      	// // --cordance;
      	// // ++bj;
      	// // } else {
      	// // if (A.values[ai] < A.values[aj])
      	// // ++cordance;
      	// // else if (A.values[ai] > A.values[aj])
      	// // --cordance;
      	// // else
      	// // ++ta;
      	// // ++aj;
      	// // ++bj;
      	// // }
      	// // }
      	// // cordance -= B.size - bj;
      	// // while (aj < A.size) {
      	// // if (A.values[ai] == A.values[aj])
      	// // ++ta;
      	// // ++aj;
      	// // }
      	// // while (bj < B.size) {
      	// // if (B.values[bi] == B.values[bj])
      	// // ++tb;
      	// // ++bj;
      	// // }
      	// // ++ai;
      	// // } else if (A.keys[ai] > B.keys[bi]) {
      	// // int aj = ai;
      	// // int bj = bi + 1;
      	// // while (aj < A.size && bj < B.size) {
      	// // if (A.keys[aj] < B.keys[bj]) {
      	// // --cordance;
      	// // ++aj;
      	// // } else if (A.keys[aj] > B.keys[bj]) {
      	// // ++bj;
      	// // } else {
      	// // if (B.values[bi] < B.values[bj])
      	// // ++cordance;
      	// // else if (B.values[bi] > B.values[bj])
      	// // --cordance;
      	// // else
      	// // ++tb;
      	// // ++aj;
      	// // ++bj;
      	// // }
      	// // }
      	// // cordance -= A.size - aj;
      	// // while (aj < A.size) {
      	// // if (A.values[ai] == A.values[aj])
      	// // ++ta;
      	// // ++aj;
      	// // }
      	// // while (bj < B.size) {
      	// // if (B.values[bi] == B.values[bj])
      	// // ++tb;
      	// // ++bj;
      	// // }
      	// // ++bi;
      	// // } else {
      	// // ++intersectionSize;
      	// // int aj = ai + 1;
      	// // int bj = bi + 1;
      	// // while (aj < A.size && bj < B.size) {
      	// // if (A.keys[aj] < B.keys[bj]) {
      	// // if (A.values[ai] < A.values[aj])
      	// // --cordance;
      	// // else if (A.values[ai] > A.values[aj])
      	// // ++cordance;
      	// // else
      	// // ++ta;
      	// // ++aj;
      	// // } else if (A.keys[aj] > B.keys[bj]) {
      	// // if (B.values[bi] < B.values[bj])
      	// // --cordance;
      	// // else if (B.values[bi] > B.values[bj])
      	// // ++cordance;
      	// // else
      	// // ++tb;
      	// // ++bj;
      	// // } else {
      	// // final double diff = (A.values[ai] - A.values[aj])
      	// // * (B.values[bi] - B.values[bj]);
      	// // if (diff < 0)
      	// // --cordance;
      	// // else if (diff > 0)
      	// // ++cordance;
      	// // ++aj;
      	// // ++bj;
      	// // }
      	// // }
      	// // while (aj < A.size) {
      	// // if (A.values[ai] < A.values[aj])
      	// // --cordance;
      	// // else if (A.values[ai] > A.values[aj])
      	// // ++cordance;
      	// // else
      	// // ++ta;
      	// // ++aj;
      	// // }
      	// // while (bj < B.size) {
      	// // if (B.values[bi] < B.values[bj])
      	// // --cordance;
      	// // else if (B.values[bi] > B.values[bj])
      	// // ++cordance;
      	// // else
      	// // ++tb;
      	// // ++bj;
      	// // }
      	// // ++ai;
      	// // ++bi;
      	// // }
      	// // }
      	// // while (ai < A.size) {
      	// // ++unionSize;
      	// // int aj = ai + 1;
      	// // int bj = bi;
      	// // while (aj < A.size && bj < B.size) {
      	// // if (A.keys[aj] < B.keys[bj]) {
      	// // ++aj;
      	// // } else if (A.keys[aj] > B.keys[bj]) {
      	// // --cordance;
      	// // ++bj;
      	// // } else {
      	// // if (A.values[ai] < A.values[aj])
      	// // ++cordance;
      	// // else if (A.values[ai] > A.values[aj])
      	// // --cordance;
      	// // else
      	// // ++ta;
      	// // ++aj;
      	// // ++bj;
      	// // }
      	// // }
      	// // cordance -= B.size - bj;
      	// // while (aj < A.size) {
      	// // if (A.values[ai] == A.values[aj])
      	// // ++ta;
      	// // ++aj;
      	// // }
      	// // while (bj < B.size) {
      	// // if (B.values[bi] == B.values[bj])
      	// // ++tb;
      	// // ++bj;
      	// // }
      	// // ++ai;
      	// // }
      	// // while (bi < B.size) {
      	// // ++unionSize;
      	// // int aj = ai;
      	// // int bj = bi + 1;
      	// // while (aj < A.size && bj < B.size) {
      	// // if (A.keys[aj] < B.keys[bj]) {
      	// // --cordance;
      	// // ++aj;
      	// // } else if (A.keys[aj] > B.keys[bj]) {
      	// // ++bj;
      	// // } else {
      	// // if (B.values[bi] < B.values[bj])
      	// // ++cordance;
      	// // else if (B.values[bi] > B.values[bj])
      	// // --cordance;
      	// // else
      	// // ++tb;
      	// // ++aj;
      	// // ++bj;
      	// // }
      	// // }
      	// // cordance -= A.size - aj;
      	// // while (aj < A.size) {
      	// // if (A.values[ai] == A.values[aj])
      	// // ++ta;
      	// // ++aj;
      	// // }
      	// // while (bj < B.size) {
      	// // if (B.values[bi] == B.values[bj])
      	// // ++tb;
      	// // ++bj;
      	// // }
      	// // ++bi;
      	// // }
      	// //
      	// // System.out.println("n=" + n + ", |A|=" + A.size);
      	// // System.out.println("n=" + n + ", |B|=" + B.size);
      	// // System.out.println(ta + " " + tb);
      	// // ta += ((n - A.size) * (n - A.size)) >> 1;
      	// // tb += ((n - B.size) * (n - B.size)) >> 1;
      	// // System.out.println(ta + " " + tb);
      	// //
      	// // // Comparisons are only done in one direction so double the result
      	// // cordance <<= 1;
      	// //
      	// //
      	// // // Features that don't occur in either vector are a similarity
      	// // // between the two sets. For each feature that they both have there
      	// // // should be an addition +2 to the sum.
      	// // // The relationship between these and disjoint features
      	// // cordance += ((n - unionSize) * intersectionSize);
      	// // //
      	// //
      	// // long n0 = (n * (n - 1)) >> 1;
      	// //
      	// //
      	// // double denom = Math.sqrt((n0 - ta) * (n0 - tb));
      	// // double sim = (double) (cordance) / denom;
      	// //
      	// // System.out.printf("n0=%d, ti=%d, tj=%d, conc=%d, denom=%f%n",
      	// // n0, ta, tb, cordance, denom);
      	// //
      	// //
      	// // return sim;
      	// // }
      	// //
      	// // static double tauB_naive3(SparseDoubleVector A, SparseDoubleVector B)
      	// {
      	// // assert A.cardinality == B.cardinality :
      	// // "Cardinalities not equal " + A.cardinality + " != " + B.cardinality;
      	// // final int totalSize = A.cardinality;
      	// // final int aSize = A.size;
      	// // final int bSize = B.size;
      	// //
      	// // long cordance = 0;
      	// // long aties = 0;
      	// // long bties = 0;
      	// //
      	// // int intersectionSize = 0;
      	// //
      	// // int ai = 0, bi = 0;
      	// // while (ai + bi < aSize + bSize) {
      	// // if (ai < aSize && (bi == bSize || A.keys[ai] < B.keys[bi])) {
      	// // int aj = 0, bj = 0;
      	// // while (aj + bj < ai + bi) {
      	// // if (aj < ai && (bj == bi || A.keys[aj] < B.keys[bj])) {
      	// // if (A.values[ai] == A.values[aj])
      	// // ++aties;
      	// // ++aj;
      	// // } else if (bj < bi && (aj == ai || B.keys[bj] < A.keys[aj])) {
      	// // cordance += signum(A.values[ai])
      	// // * signum(-B.values[bj]);
      	// // ++bj;
      	// // } else if (aj < ai && bj < bi) {
      	// // if (A.values[ai] == A.values[aj])
      	// // ++aties;
      	// // cordance += signum(A.values[ai] - A.values[aj])
      	// // * signum(-B.values[bj]);
      	// // ++aj;
      	// // ++bj;
      	// // }
      	// // }
      	// // ++ai;
      	// // } else if (bi < bSize && (ai == aSize || B.keys[bi] < A.keys[ai])) {
      	// // int aj = 0, bj = 0;
      	// // while (aj + bj < ai + bi) {
      	// // if (aj < ai && (bj == bi || A.keys[aj] < B.keys[bj])) {
      	// // cordance += signum(-A.values[aj])
      	// // * signum(B.values[bi]);
      	// // ++aj;
      	// // } else if (bj < bi && (aj == ai || B.keys[bj] < A.keys[aj])) {
      	// // if (B.values[bi] == B.values[bj])
      	// // ++bties;
      	// // ++bj;
      	// // } else if (aj < ai && bj < bi) {
      	// // if (B.values[bi] == B.values[bj])
      	// // ++bties;
      	// // cordance += signum(-A.values[aj])
      	// // * signum(B.values[bi] - B.values[bj]);
      	// // ++aj;
      	// // ++bj;
      	// // }
      	// // }
      	// // ++bi;
      	// // } else if (ai < aSize && bi < bSize) {
      	// // int aj = 0, bj = 0;
      	// // while (aj + bj < ai + bi) {
      	// // if (aj < ai && (bj == bi || A.keys[aj] < B.keys[bj])) {
      	// // if (A.values[ai] == A.values[aj])
      	// // ++aties;
      	// // cordance += signum(A.values[ai] - A.values[aj])
      	// // * signum(B.values[bi]);
      	// // ++aj;
      	// // } else if (bj < bi && (aj == ai || B.keys[bj] < A.keys[aj])) {
      	// // if (B.values[bi] == B.values[bj])
      	// // ++bties;
      	// // cordance += signum(A.values[ai])
      	// // * signum(B.values[bi] - B.values[bj]);
      	// // ++bj;
      	// // } else if (aj < ai && bj < bi) {
      	// // if (A.values[ai] == A.values[aj])
      	// // ++aties;
      	// // if (B.values[bi] == B.values[bj])
      	// // ++bties;
      	// // cordance += signum(A.values[ai] - A.values[aj])
      	// // * signum(B.values[bi] - B.values[bj]);
      	// // ++aj;
      	// // ++bj;
      	// // }
      	// // }
      	// // ++intersectionSize;
      	// // ++ai;
      	// // ++bi;
      	// // }
      	// // }
      	// //
      	// // final int unionSize = (aSize + bSize) - intersectionSize;
      	// //
      	// // // Features that don't occur in either vector are a similarity
      	// // // between the two sets. For each feature that they both have there
      	// // // should be an addition +2 to the sum.
      	// // // The relationship between these and disjoint features
      	// // cordance += ((totalSize - unionSize) * intersectionSize);
      	// //
      	// // // Outside of those in the union all elements are zero add all
      	// pairwise
      	// // // combinations to the ties counters.
      	// // aties += ((totalSize - unionSize) * (totalSize - unionSize - 1)) >> 1;
      	// // bties += ((totalSize - unionSize) * (totalSize - unionSize - 1)) >> 1;
      	// //
      	// // // We also need to the add the cross-tries between zeros in union, and
      	// // // everything else
      	// // aties += ((unionSize - aSize) * (totalSize - unionSize));
      	// // bties += ((unionSize - bSize) * (totalSize - unionSize));
      	// //
      	// // // Within the union minus the size of vector, all elements are zero so
      	// // // add all pairwise combinations
      	// // aties += ((unionSize - aSize) * (unionSize - aSize - 1)) >> 1;
      	// // bties += ((unionSize - bSize) * (unionSize - bSize - 1)) >> 1;
      	// //
      	// // final long n0 = (totalSize * (totalSize - 1)) >> 1;
      	// // final double denom = Math.sqrt((n0 - aties) * (n0 - bties));
      	// // final double sim = cordance / denom;
      	// ////
      	// //// System.out.printf(
      	// //// "n0=%d, ti=%d, tj=%d, conc=%d, denom=%f, sim=%f%n",
      	// //// n0, aties, bties, cordance, denom, sim);
      	// //
      	// // return sim;
      	// // }
      	// //
      	// // static double tauB_merge1(SparseDoubleVector A, SparseDoubleVector B)
      	// {
      	// // assert A.cardinality == B.cardinality :
      	// // "Cardinalities not equal " + A.cardinality + " != " + B.cardinality;
      	// // final int totalSize = A.cardinality;
      	// // final int aSize = A.size;
      	// // final int bSize = B.size;
      	// //
      	// //
      	// // final double[][] data = unionArray(A, B);
      	// //
      	// //// System.out.println(Arrays.deepToString(data));
      	// //
      	// // sort(data);
      	// //
      	// //
      	// // final double[] x = new double[data.length];
      	// // final double[] y = new double[data.length];
      	// //
      	// // for (int i = 0; i < data.length; i++) {
      	// // x[i] = data[i][0];
      	// // y[i] = data[i][1];
      	// // }
      	// ////
      	// //// System.out.println(Arrays.toString(x));
      	// //// System.out.println(Arrays.toString(y));
      	// ////
      	// //
      	// //
      	// // System.out.println(swaps(y));
      	// //
      	// //
      	// // return 0;
      	// // }
      	// //
      	// // public static void sort(double[][] a) {
      	// // sort1(a, 0, a.length);
      	// // }
      	// //
      	// // private static void sort1(double x[][], int off, int len) {
      	// // // Insertion sort on smallest arrays
      	// // if (len < 7) {
      	// // for (int i = off; i < len + off; i++)
      	// // for (int j = i; j > off && (x[j - 1][0] > x[j][0] || (x[j - 1][0] ==
      	// x[j][0] && x[j - 1][1] > x[j][1])); j--)
      	// // swap(x, j, j - 1);
      	// // return;
      	// // }
      	// //
      	// //// }
      	// // // Choose a partition element, v
      	// // int m = off + (len >> 1); // Small arrays, middle element
      	// // if (len > 7) {
      	// // int l = off;
      	// // int n = off + len - 1;
      	// // if (len > 40) { // Big arrays, pseudomedian of 9
      	// // int s = len / 8;
      	// // l = med3(x, l, l + s, l + 2 * s);
      	// // m = med3(x, m - s, m, m + s);
      	// // n = med3(x, n - 2 * s, n - s, n);
      	// // }
      	// // m = med3(x, l, m, n); // Mid-size, med of 3
      	// // }
      	// // double[] v = x[m];
      	// //
      	// // // Establish Invariant: v* (v)* v*
      	// // int a = off, b = a, c = off + len - 1, d = c;
      	// // while (true) {
      	// // while (b <= c && (x[b][0] < v[0] || (x[b][0] == v[0] && x[b][1] <=
      	// v[1]))) {
      	// // if (x[b][0] == v[0])
      	// // swap(x, a++, b);
      	// // b++;
      	// // }
      	// // while (c >= b && (x[c][0] > v[0] || (x[b][0] == v[0] && x[b][1] >=
      	// v[1]))) {
      	// // if (x[c][0] == v[0])
      	// // swap(x, c, d--);
      	// // c--;
      	// // }
      	// // if (b > c)
      	// // break;
      	// // swap(x, b++, c--);
      	// // }
      	// //
      	// // // Swap partition elements back to middle
      	// // int s, n = off + len;
      	// // s = Math.min(a - off, b - a);
      	// // vecswap(x, off, b - s, s);
      	// // s = Math.min(d - c, n - d - 1);
      	// // vecswap(x, b, n - s, s);
      	// //
      	// // // Recursively sort non-partition-elements
      	// // if ((s = b - a) > 1)
      	// // sort1(x, off, s);
      	// // if ((s = d - c) > 1)
      	// // sort1(x, n - s, s);
      	// // }
      	// //
      	// // /**
      	// // * Swaps x[a] with x[b].
      	// // */
      	// // private static void swap(double x[][], int a, int b) {
      	// // double[] t = x[a];
      	// // x[a] = x[b];
      	// // x[b] = t;
      	// // }
      	// //
      	// // /**
      	// // * Swaps x[a .. (a+n-1)] with x[b .. (b+n-1)].
      	// // */
      	// // private static void vecswap(double x[][], int a, int b, int n) {
      	// // for (int i = 0; i < n; i++, a++, b++)
      	// // swap(x, a, b);
      	// // }
      	// //
      	// // /**
      	// // * Returns the index of the median of the three indexed doubles.
      	// // */
      	// // private static int med3(double x[][], int a, int b, int c) {
      	// // return (x[a][0] < x[b][0]
      	// // ? (x[b][0] < x[c][0] ? b : x[a][0] < x[c][0] ? c : a)
      	// // : (x[b][0] > x[c][0] ? b : x[a][0] > x[c][0] ? c : a));
      	// // }
      	// //
      	// //// static double[][] coSort(double[][] data, int left, int right) {
      	// ////
      	// //// int mid = left + (right - left) / 2;
      	// ////
      	// //// return coMerge(coSort(data, left, mid), coSort(data, mid + 1,
      	// right));
      	// //// }
      	// //////
      	// //// static double[][] coMerge(double[][] a, double[][] b) {
      	// //// double[][] out = new double[2][a[0].length];
      	// ////
      	// //// int i = 0, j = 0, k = 0;
      	// //// while (i < A.size && j < B.size) {
      	// //// if (A.keys[i] < B.keys[j]) {
      	// //// out[0][k] = A.values[i++];
      	// //// out[1][k] = 0;
      	// //// ++k;
      	// //// } else if (B.keys[j] < A.keys[i]) {
      	// //// out[0][k] = 0;
      	// //// out[1][k] = B.values[j++];
      	// //// ++k;
      	// //// } else {
      	// //// out[0][k] = A.values[i++];
      	// //// out[1][k] = B.values[j++];
      	// //// ++k;
      	// //// }
      	// //// }
      	// //// while (i < A.size) {
      	// //// out[0][k] = A.values[i++];
      	// //// bOut[k] = 0;
      	// //// ++k;
      	// //// while (j < B.size) {
      	// //// out[0][k] = 0;
      	// //// out[1][k] = B.values[j++];
      	// //// ++k;
      	// //// }
      	// //// return null;
      	// //// }
      	// //// private static final List entryList(
      	// //// SparseDoubleVector vector) {
      	// //// final List list =
      	// //// new ArrayList(vector.size);
      	// //// for (int i = 0; i < vector.size; i++)
      	// //// list.add(new AbstractInt2DoubleMap.BasicEntry(vector.keys[i],
      	// //// vector.values[i]));
      	// //// return list;
      	// //// }
      	// ////
      	// //// private static final Comparator VALUE_ORDER_ASC
      	// =
      	// //// new Comparator() {
      	// ////
      	// //// @Override
      	// //// public int compare(Int2DoubleMap.Entry a, Int2DoubleMap.Entry b) {
      	// //// return Double.compare(a.getDoubleValue(), b.getDoubleValue());
      	// //// }
      	// //// };
      	// // static long swaps(double[] y) {
      	// // if (y.length < 2)
      	// // return 0;
      	// // int mid = y.length / 2;
      	// //
      	// // double[] left = Arrays.copyOfRange(y, 0, mid);
      	// // double[] right = Arrays.copyOfRange(y, mid, y.length);
      	// //
      	// // return swaps(left) + swaps(right)
      	// // + mergeCountSwaps(sorted(left), sorted(right));
      	// // }
      	// //
      	// // static double[] sorted(double[] arr) {
      	// // double[] copy = Arrays.copyOf(arr, arr.length);
      	// // Arrays.sort(copy);
      	// // return copy;
      	// // }
      	// //
      	// // static long mergeCountSwaps(double[] L, double[] R) {
      	// //
      	// // final int m = R.length;
      	// // final int n = L.length;// + m;
      	// //
      	// // long nSwaps = 0;
      	// // int i = 0, j = 0;
      	// // while (i + j < n) {
      	// // if (i >= m || R[j] < L[i]) {
      	// // nSwaps += m - i;
      	// // ++j;
      	// // } else {
      	// // ++i;
      	// // }
      	// // }
      	// // return nSwaps;
      	// // }
      	// //
      	// // static double[][] unionArray(SparseDoubleVector A, SparseDoubleVector
      	// B) {
      	// // final double[][] out = new double[A.size + B.size][2];
      	// //
      	// // int i = 0, j = 0, k = 0;
      	// // while (i < A.size && j < B.size) {
      	// // if (A.keys[i] < B.keys[j]) {
      	// // out[k++][0] = A.values[i++];
      	// // } else if (B.keys[j] < A.keys[i]) {
      	// // out[k++][1] = B.values[j++];
      	// // } else {
      	// // out[k][0] = A.values[i++];
      	// // out[k][1] = B.values[j++];
      	// // ++k;
      	// // }
      	// // }
      	// // while (i < A.size)
      	// // out[k++][0] = A.values[i++];
      	// // while (j < B.size)
      	// // out[k++][1] = B.values[j++];
      	// //
      	// // return out.length == k ? out : Arrays.copyOf(out, k);
      	// // }
      }
      File
      KendallsTauTest.java
      Developer's decision
      Manual
      Kind of conflict
      Comment
      Method declaration
      Chunk
      Conflicting content
                  });
       */
      package uk.ac.susx.mlcl.byblo.measures.impl;
      
      <<<<<<< HEAD
      import org.junit.BeforeClass;
      import org.junit.Test;
      import uk.ac.susx.mlcl.TestConstants;
      import uk.ac.susx.mlcl.byblo.Tools;
      import uk.ac.susx.mlcl.byblo.enumerators.DoubleEnumerating;
      import uk.ac.susx.mlcl.byblo.enumerators.DoubleEnumeratingDelegate;
      import uk.ac.susx.mlcl.byblo.io.BybloIO;
      import uk.ac.susx.mlcl.byblo.io.FastWeightedTokenPairVectorSource;
      import uk.ac.susx.mlcl.lib.collect.Indexed;
      import uk.ac.susx.mlcl.lib.collect.SparseDoubleVector;
      
      import java.io.Closeable;
      import java.io.File;
      import java.io.IOException;
      import java.util.ArrayList;
      import java.util.List;
      import java.util.Random;
      
      import static org.junit.Assert.*;
      import static uk.ac.susx.mlcl.TestConstants.*;
      import static uk.ac.susx.mlcl.lib.test.ExitTrapper.disableExitTrapping;
      import static uk.ac.susx.mlcl.lib.test.ExitTrapper.enableExistTrapping;
      
      /**
       * @author Hamish I A Morgan <hamish.morgan@sussex.ac.uk>
       */
      public class KullbackLeiblerDivergenceTest {
      
          static KullbackLeiblerDivergence INSTANCE;
      
          static final double EPSILON = 0;
      
          static Random RANDOM;
      
          @BeforeClass
          public static void setUpClass() throws Exception {
              INSTANCE = new KullbackLeiblerDivergence();
              RANDOM = new Random(1234);
          }
      
          @Test
          public void testCLI() throws Exception {
              System.out.println("testCLI");
      
              File output = new File(TEST_OUTPUT_DIR,
                      FRUIT_NAME + ".KullbackLeiblerDivergence");
              deleteIfExist(output);
      
              try {
                  enableExistTrapping();
                  Tools.main(new String[]{
                          "allpairs",
                          "--charset", "UTF-8",
                          "--measure", "kl",
                          "--input", TEST_FRUIT_EVENTS.toString(),
                          "--input-features", TEST_FRUIT_FEATURES.toString(),
                          "--input-entries", TEST_FRUIT_ENTRIES.toString(),
                          "--output", output.toString()
              } finally {
                  disableExitTrapping();
              }
      
      
              assertTrue("Output file " + output + " does not exist.", output.exists());
              assertTrue("Output file " + output + " is empty.", output.length() > 0);
          }
      
          @Test
          public void testBothEmptyVectors() throws Exception {
              System.out.println("testBothEmptyVectors");
              int size = 100;
              SparseDoubleVector A = new SparseDoubleVector(size, 0);
              SparseDoubleVector B = new SparseDoubleVector(size, 0);
              double expect = 0;
              double actual = test(A, B);
      
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testSizeOneVectors() throws Exception {
              System.out.println("testSizeOneVectors");
              int size = 100;
              SparseDoubleVector A = new SparseDoubleVector(size, 1);
              SparseDoubleVector B = new SparseDoubleVector(size, 1);
              A.set(0, 1);
              B.set(0, 1);
              double expect = INSTANCE.getHomogeneityBound();
              double actual = test(A, B);
      
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testCardinalityOneVectors() throws Exception {
              System.out.println("testCardinalityOneVectors");
              SparseDoubleVector A = new SparseDoubleVector(1, 1);
              SparseDoubleVector B = new SparseDoubleVector(1, 1);
              A.set(0, 1);
              B.set(0, 1);
              double expect = INSTANCE.getHomogeneityBound();
              double actual = test(A, B);
      
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testSizeTwoVectors() throws Exception {
              System.out.println("testSizeTwoVectors");
              int size = 100;
              SparseDoubleVector A = new SparseDoubleVector(size, 2);
              SparseDoubleVector B = new SparseDoubleVector(size, 2);
              A.set(0, 1);
              A.set(1, 1);
              B.set(0, 1);
              B.set(1, 1);
              double expect = INSTANCE.getHomogeneityBound();
              double actual = test(A, B);
      
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testHomoginiety() throws Exception {
              System.out.println("testHomoginiety");
              int size = 100;
              SparseDoubleVector A = new SparseDoubleVector(size, size);
              SparseDoubleVector B = new SparseDoubleVector(size, size);
              for (int i = 0; i < size; i++) {
                  double value = RANDOM.nextDouble();
                  A.set(i, value);
                  B.set(i, value);
              }
      
              double expect = INSTANCE.getHomogeneityBound();
              double actual = test(A, B);
      
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testFruitData() throws Exception {
              System.out.println("testFruitData");
              int limit = 5;
      
              List> vecs = TestConstants.loadFruitVectors();
      
              limit = Math.min(limit, vecs.size());
      
              final double[][] results = new double[limit][limit];
              for (int i = 0; i < limit; i++) {
                  for (int j = 0; j < limit; j++) {
                      SparseDoubleVector A = vecs.get(i).value();
                      SparseDoubleVector B = vecs.get(j).value();
                      results[i][j] = test(A, B);
                  }
              }
          }
      
          @Test
          public void testLargeCardinality() throws Exception {
              System.out.println("testLargeCardinality");
              final int size = 100;
              final SparseDoubleVector A = new SparseDoubleVector(
                      Integer.MAX_VALUE, size);
              final SparseDoubleVector B = new SparseDoubleVector(
                      Integer.MAX_VALUE, size);
              for (int i = 0; i < size; i++) {
                  A.set(RANDOM.nextInt(size * 2), RANDOM.nextDouble());
                  B.set(RANDOM.nextInt(size * 2), RANDOM.nextDouble());
              }
      
              test(A, B);
          }
      
          public double test(SparseDoubleVector A, SparseDoubleVector B) {
              final double val = INSTANCE.similarity(A, B);
              assertFalse("Similarity is NaN" + " with measure " + INSTANCE,
                      Double.isNaN(val));
              assertFalse("Similarity is " + val + " with measure " + INSTANCE,
                      Double.isInfinite(val));
      
              final double min, max;
              if (INSTANCE.getHeterogeneityBound() < INSTANCE.getHomogeneityBound()) {
                  min = INSTANCE.getHeterogeneityBound();
                  max = INSTANCE.getHomogeneityBound();
              } else {
                  min = INSTANCE.getHomogeneityBound();
                  max = INSTANCE.getHeterogeneityBound();
              }
              assertTrue("expected similarity >= " + min + " but found " + val,
                      val >= min);
              assertTrue("expected similarity <= " + max + " but found " + val,
                      val <= max);
      
      
              if (INSTANCE.isCommutative()) {
                  final double rev = INSTANCE.similarity(B, A);
                  assertEquals("Measure is declared computative, but reversing "
                          + "operands results in a different score.", rev, val,
                          EPSILON);
              }
      
              return val;
          }
      =======
      import junit.framework.Assert;
      
      import org.junit.Ignore;
      import org.junit.Test;
      
      import uk.ac.susx.mlcl.lib.collect.SparseDoubleVector;
      
      /**
       * 
       * @author Hamish I A Morgan <hamish.morgan@sussex.ac.uk>
       */
      public class KullbackLeiblerDivergenceTest extends
      		AbstractMeasureTest {
      
      	@Override
      	Class getMeasureClass() {
      		return KullbackLeiblerDivergence.class;
      	}
      
      	@Override
      	String getMeasureName() {
      		return "kl";
      	}
      
      	@Test
      	@Override
      	@Ignore
      	public void testOneEmptyVector() {
      		throw new UnsupportedOperationException();
      	}
      
      	@Test
      	@Override
      	@Ignore
      	public void testHeteroginiety() {
      		throw new UnsupportedOperationException();
      	}
      >>>>>>> 5f0ba9177b34449ea27dabdc17fd0793620c7d56
      
          static List> loadFruitVectors() throws IOException {
      
      Solution content
       */
      package uk.ac.susx.mlcl.byblo.measures.impl;
      
      import junit.framework.Assert;
      
      import org.junit.Ignore;
      import org.junit.Test;
      
      import uk.ac.susx.mlcl.lib.collect.SparseDoubleVector;
      
      /**
       * 
       * @author Hamish I A Morgan <hamish.morgan@sussex.ac.uk>
       */
      public class KullbackLeiblerDivergenceTest extends
      		AbstractMeasureTest {
      
      	@Override
      	Class getMeasureClass() {
      		return KullbackLeiblerDivergence.class;
      	}
      
      	@Override
      	String getMeasureName() {
      		return "kl";
      	}
      
      	@Test
      	@Override
      	@Ignore
      	public void testOneEmptyVector() {
      		throw new UnsupportedOperationException();
      	}
      
      	@Test
      	@Override
      	@Ignore
      	public void testHeteroginiety() {
      		throw new UnsupportedOperationException();
      	}
      
      }
      File
      KullbackLeiblerDivergenceTest.java
      Developer's decision
      Version 2
      Kind of conflict
      Annotation
      Attribute
      Class signature
      Comment
      Import
      Method declaration
      Chunk
      Conflicting content
       */
      package uk.ac.susx.mlcl.byblo.measures.impl;
      
      <<<<<<< HEAD
      import org.junit.BeforeClass;
      import org.junit.Test;
      import uk.ac.susx.mlcl.TestConstants;
      import uk.ac.susx.mlcl.byblo.Tools;
      import uk.ac.susx.mlcl.byblo.enumerators.DoubleEnumerating;
      import uk.ac.susx.mlcl.byblo.enumerators.DoubleEnumeratingDelegate;
      import uk.ac.susx.mlcl.byblo.io.BybloIO;
      import uk.ac.susx.mlcl.byblo.io.FastWeightedTokenPairVectorSource;
      import uk.ac.susx.mlcl.lib.collect.Indexed;
      import uk.ac.susx.mlcl.lib.collect.SparseDoubleVector;
      
          }
      import java.io.Closeable;
      import java.io.File;
      import java.io.IOException;
      import java.util.ArrayList;
      import java.util.List;
      import java.util.Random;
      
      import static org.junit.Assert.*;
      import static uk.ac.susx.mlcl.TestConstants.*;
      import static uk.ac.susx.mlcl.lib.test.ExitTrapper.disableExitTrapping;
      import static uk.ac.susx.mlcl.lib.test.ExitTrapper.enableExistTrapping;
      
      /**
       * @author Hamish I A Morgan <hamish.morgan@sussex.ac.uk>
       */
      public class LambdaDivergenceTest {
      
          static LambdaDivergence INSTANCE;
      
          static final double EPSILON = 0.000000000001;
      
          static Random RANDOM;
      
          @BeforeClass
          public static void setUpClass() throws Exception {
              INSTANCE = new LambdaDivergence();
              RANDOM = new Random(1234);
          }
      
          @Test
          public void testCLI_001() throws Exception {
              testCLI(0.01);
          }
      
          @Test
          public void testCLI_010() throws Exception {
              testCLI(0.10);
          }
      
          @Test
          public void testCLI_050() throws Exception {
              testCLI(0.50);
          }
      
          @Test
          public void testCLI_090() throws Exception {
              testCLI(0.90);
          }
      
          @Test
          public void testCLI_099() throws Exception {
              testCLI(0.99);
          }
      
          public void testCLI(final double lambda) throws Exception {
              System.out.printf("testCLI(lambda=%.2f)%n", lambda);
      
              File output = new File(TEST_OUTPUT_DIR,
                      FRUIT_NAME
                              + String.format(".LambdaDivergence-lambda%03d",
                              (int) (lambda * 100)));
              deleteIfExist(output);
      
              try {
                  enableExistTrapping();
                  Tools.main(new String[]{
                          "allpairs",
                          "--charset", "UTF-8",
                          "--measure", "lambda",
                          "--lambda-lambda", Double.toString(lambda),
                          "--input", TEST_FRUIT_EVENTS.toString(),
                          "--input-features", TEST_FRUIT_FEATURES.toString(),
                          "--input-entries", TEST_FRUIT_ENTRIES.toString(),
                          "--output", output.toString()
                  });
              } finally {
                  disableExitTrapping();
              }
      
      
              assertTrue("Output file " + output + " does not exist.", output.exists());
              assertTrue("Output file " + output + " is empty.", output.length() > 0);
      
          @Test
          public void testBothEmptyVectors() throws Exception {
              System.out.println("testBothEmptyVectors");
              int size = 100;
              SparseDoubleVector A = new SparseDoubleVector(size, 0);
              SparseDoubleVector B = new SparseDoubleVector(size, 0);
              double expect = 0;
              double actual = test(A, B);
      
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testOneEmptyVector() throws Exception {
              System.out.println("testOneEmptyVector");
              int size = 100;
              SparseDoubleVector A = new SparseDoubleVector(size, 0);
              SparseDoubleVector B = new SparseDoubleVector(size, size);
              for (int i = 0; i < size; i++)
                  B.set(i, 1);
      
              }
              double expect = 0.5;
              double actual = test(A, B);
      
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testCardinalityOneVectors() throws Exception {
              System.out.println("testCardinalityOneVectors");
              SparseDoubleVector A = new SparseDoubleVector(1, 1);
              SparseDoubleVector B = new SparseDoubleVector(1, 1);
              A.set(0, 1);
              B.set(0, 1);
              double expect = 0;
              double actual = test(A, B);
      
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testSizeTwoVectors() throws Exception {
              System.out.println("testSizeTwoVectors");
              int size = 100;
              SparseDoubleVector A = new SparseDoubleVector(size, 2);
              SparseDoubleVector B = new SparseDoubleVector(size, 2);
              A.set(0, 1);
              A.set(1, 1);
              B.set(0, 1);
              B.set(1, 1);
              double expect = INSTANCE.getHomogeneityBound();
              double actual = test(A, B);
      
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testCommutative() throws Exception {
              System.out.println("testCommutative");
              int size = 100;
              SparseDoubleVector A = new SparseDoubleVector(size, size);
              SparseDoubleVector B = new SparseDoubleVector(size, size);
              for (int i = 0; i < size; i++) {
                  A.set(i, RANDOM.nextDouble());
                  B.set(i, RANDOM.nextDouble());
              }
      
              double expect = test(A, B);
              double actual = test(B, A);
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testHomoginiety() throws Exception {
              System.out.println("testHomoginiety");
              int size = 100;
              SparseDoubleVector A = new SparseDoubleVector(size, size);
              SparseDoubleVector B = new SparseDoubleVector(size, size);
              for (int i = 0; i < size; i++) {
                  double value = RANDOM.nextDouble();
                  A.set(i, value);
                  B.set(i, value);
              }
      
              double expect = INSTANCE.getHomogeneityBound();
              double actual = test(A, B);
      
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testHeteroginiety() throws Exception {
              System.out.println("testHeteroginiety");
              int size = 100;
              SparseDoubleVector A = new SparseDoubleVector(size, size);
              SparseDoubleVector B = new SparseDoubleVector(size, size);
              for (int i = 0; i < size / 2; i++) {
                  A.set(i * 2, i);
                  B.set(i * 2 + 1, i);
              }
      
              double expect = INSTANCE.getHeterogeneityBound();
              double actual = test(A, B);
      
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testFruitData() throws Exception {
              System.out.println("testFruitData");
              int limit = 5;
      
              List> vecs = TestConstants.loadFruitVectors();
      
              limit = Math.min(limit, vecs.size());
      
              final double[][] results = new double[limit][limit];
              for (int i = 0; i < limit; i++) {
                  for (int j = 0; j < limit; j++) {
                      SparseDoubleVector A = vecs.get(i).value();
                      SparseDoubleVector B = vecs.get(j).value();
                      results[i][j] = test(A, B);
                  }
      
              // diagonals should all be +1
              for (int i = 0; i < limit; i++) {
                  assertEquals(INSTANCE.getHomogeneityBound(), results[i][i], EPSILON);
              }
              // triangular mirrors should be equal
              for (int i = 0; i < limit; i++) {
                  for (int j = 0; j < limit; j++) {
                      assertEquals(results[i][j], results[j][i], EPSILON);
                  }
              }
          }
      
          @Test
          public void testLargeCardinality() throws Exception {
              System.out.println("testLargeCardinality");
              final int size = 100;
              final SparseDoubleVector A = new SparseDoubleVector(
                      Integer.MAX_VALUE, size);
              final SparseDoubleVector B = new SparseDoubleVector(
                      Integer.MAX_VALUE, size);
              for (int i = 0; i < size; i++) {
                  A.set(RANDOM.nextInt(size * 2), RANDOM.nextDouble());
                  B.set(RANDOM.nextInt(size * 2), RANDOM.nextDouble());
              }
      
              test(A, B);
          }
      
          public double test(SparseDoubleVector A, SparseDoubleVector B) {
              final double val = INSTANCE.similarity(A, B);
              assertFalse("Similarity is NaN" + " with measure " + INSTANCE,
                      Double.isNaN(val));
              assertFalse("Similarity is " + val + " with measure " + INSTANCE,
                      Double.isInfinite(val));
      
              final double min, max;
              if (INSTANCE.getHeterogeneityBound() < INSTANCE.getHomogeneityBound()) {
                  min = INSTANCE.getHeterogeneityBound();
                  max = INSTANCE.getHomogeneityBound();
              } else {
                  min = INSTANCE.getHomogeneityBound();
                  max = INSTANCE.getHeterogeneityBound();
              }
              assertTrue("expected similarity >= " + min + " but found " + val,
                      val >= min);
              assertTrue("expected similarity <= " + max + " but found " + val,
                      val <= max);
      
      
              if (INSTANCE.isCommutative()) {
                  final double rev = INSTANCE.similarity(B, A);
                  assertEquals("Measure is declared computative, but reversing "
                          + "operands results in a different score.", rev, val,
                          EPSILON);
              }
      
              return val;
          }
      =======
      import java.util.Random;
      
      import junit.framework.Assert;
      
      import org.junit.Test;
      
      import uk.ac.susx.mlcl.lib.collect.SparseDoubleVector;
      
      /**
       * 
       * @author Hamish I A Morgan <hamish.morgan@sussex.ac.uk>
       */
      public class LambdaDivergenceTest extends AbstractMeasureTest {
      
      	@Override
      	Class getMeasureClass() {
      		return LambdaDivergence.class;
      	}
      
      	@Override
      	String getMeasureName() {
      		return "lambda";
      	}
      
      	@Test
      	@Override
      	public void testOneEmptyVector() {
      		System.out.println("testOneEmptyVector");
      		int size = 100;
      		Random RANDOM = newRandom();
      		SparseDoubleVector A = new SparseDoubleVector(size, 0);
      		SparseDoubleVector B = new SparseDoubleVector(size, size);
      		for (int i = 0; i < size; i++)
      			B.set(i, RANDOM.nextDouble());
      
      		double expect = 0.5; // 0;
      		double actual = similarity(newInstance(), A, B);
      
      		Assert.assertEquals(expect, actual, EPSILON);
      	}
      
      	@Test
      	@Override
      	public void testCardinalityOneVectors() {
      		System.out.println("testCardinalityOneVectors");
      		SparseDoubleVector A = new SparseDoubleVector(1, 1);
      		SparseDoubleVector B = new SparseDoubleVector(1, 1);
      		A.set(0, 1);
      		B.set(0, 1);
      		double expect = 0; // 1
      		double actual = similarity(newInstance(), A, B);
      
      		Assert.assertEquals(expect, actual, EPSILON);
      	}
      
      	@Test
      	public void testCLI_Lambda001() throws Exception {
      		runFromCommandLine(0.01);
      	}
      
      	@Test
      	public void testCLI_Lambda010() throws Exception {
      		runFromCommandLine(0.10);
      	}
      
      	@Test
      	public void testCLI_Lambda050() throws Exception {
      		runFromCommandLine(0.50);
      	}
      
      	@Test
      	public void testCLI_Lambda090() throws Exception {
      		runFromCommandLine(0.90);
      	}
      
      	@Test
      	public void testCLI_Lambda099() throws Exception {
      		runFromCommandLine(0.99);
      	}
      
      	public void runFromCommandLine(final double lambda) throws Exception {
      		System.out.printf("testRunFromCommandLine(lambda=%.2f)%n", lambda);
      
      		String[] extraArgs = new String[] { "--lambda-lambda",
      				Double.toString(lambda) };
      		runFromCommandLine(extraArgs);
      	}
      >>>>>>> 5f0ba9177b34449ea27dabdc17fd0793620c7d56
      
          static List> loadFruitVectors() throws IOException {
      
      Solution content
       */
      package uk.ac.susx.mlcl.byblo.measures.impl;
      
      import java.util.Random;
      
      import junit.framework.Assert;
      
      import org.junit.Test;
      
      import uk.ac.susx.mlcl.lib.collect.SparseDoubleVector;
      
      /**
       * 
       * @author Hamish I A Morgan <hamish.morgan@sussex.ac.uk>
       */
      public class LambdaDivergenceTest extends AbstractMeasureTest {
      
      	@Override
      	Class getMeasureClass() {
      		return LambdaDivergence.class;
      	}
      
      	@Override
      	String getMeasureName() {
      		return "lambda";
      	}
      
      	@Test
      	@Override
      	public void testOneEmptyVector() {
      		System.out.println("testOneEmptyVector");
      		int size = 100;
      		Random RANDOM = newRandom();
      		SparseDoubleVector A = new SparseDoubleVector(size, 0);
      		SparseDoubleVector B = new SparseDoubleVector(size, size);
      		for (int i = 0; i < size; i++)
      			B.set(i, RANDOM.nextDouble());
      
      		double expect = 0.5; // 0;
      		double actual = similarity(newInstance(), A, B);
      
      		Assert.assertEquals(expect, actual, EPSILON);
      	}
      
      	@Test
      	@Override
      	public void testCardinalityOneVectors() {
      		System.out.println("testCardinalityOneVectors");
      		SparseDoubleVector A = new SparseDoubleVector(1, 1);
      		SparseDoubleVector B = new SparseDoubleVector(1, 1);
      		A.set(0, 1);
      		B.set(0, 1);
      		double expect = 0; // 1
      		double actual = similarity(newInstance(), A, B);
      
      		Assert.assertEquals(expect, actual, EPSILON);
      	}
      
      	@Test
      	public void testCLI_Lambda001() throws Exception {
      		runFromCommandLine(0.01);
      	}
      
      	@Test
      	public void testCLI_Lambda010() throws Exception {
      		runFromCommandLine(0.10);
      	}
      
      	@Test
      	public void testCLI_Lambda050() throws Exception {
      		runFromCommandLine(0.50);
      	}
      
      	@Test
      	public void testCLI_Lambda090() throws Exception {
      		runFromCommandLine(0.90);
      	}
      
      	@Test
      	public void testCLI_Lambda099() throws Exception {
      		runFromCommandLine(0.99);
      	}
      
      	public void runFromCommandLine(final double lambda) throws Exception {
      		System.out.printf("testRunFromCommandLine(lambda=%.2f)%n", lambda);
      
      		String[] extraArgs = new String[] { "--lambda-lambda",
      				Double.toString(lambda) };
      		runFromCommandLine(extraArgs);
      	}
      
      }
      File
      LambdaDivergenceTest.java
      Developer's decision
      Version 2
      Kind of conflict
      Annotation
      Attribute
      Class signature
      Comment
      Import
      Method declaration
      Chunk
      Conflicting content
       */
      package uk.ac.susx.mlcl.byblo.measures.impl;
      
      <<<<<<< HEAD
      import org.junit.BeforeClass;
      import org.junit.Test;
      import uk.ac.susx.mlcl.TestConstants;
      import uk.ac.susx.mlcl.byblo.Tools;
      import uk.ac.susx.mlcl.byblo.enumerators.DoubleEnumerating;
      import uk.ac.susx.mlcl.byblo.enumerators.DoubleEnumeratingDelegate;
      import uk.ac.susx.mlcl.byblo.io.BybloIO;
      import uk.ac.susx.mlcl.byblo.io.FastWeightedTokenPairVectorSource;
      import uk.ac.susx.mlcl.lib.collect.Indexed;
      import uk.ac.susx.mlcl.lib.collect.SparseDoubleVector;
      
      import java.io.Closeable;
      import java.io.File;
      import java.io.IOException;
      import java.util.ArrayList;
      import java.util.List;
      import java.util.Random;
      
      import static org.junit.Assert.*;
      import static uk.ac.susx.mlcl.TestConstants.*;
      import static uk.ac.susx.mlcl.lib.test.ExitTrapper.disableExitTrapping;
      import static uk.ac.susx.mlcl.lib.test.ExitTrapper.enableExistTrapping;
      
      /**
       * @author Hamish I A Morgan <hamish.morgan@sussex.ac.uk>
       */
      public class LeeSkewDivergenceTest {
      
          static LeeSkewDivergence INSTANCE;
      
          static final double EPSILON = 0;
      
          static Random RANDOM;
      
          @BeforeClass
          public static void setUpClass() throws Exception {
              INSTANCE = new LeeSkewDivergence();
              RANDOM = new Random(1234);
          }
      
          @Test
          public void testCLI_001() throws Exception {
              testCLI(0.01);
          }
      
          @Test
          public void testCLI_010() throws Exception {
              testCLI(0.10);
          }
      
          @Test
          public void testCLI_050() throws Exception {
              testCLI(0.50);
          }
      
          @Test
          public void testCLI_090() throws Exception {
              testCLI(0.90);
          }
      
          @Test
          public void testCLI_099() throws Exception {
              testCLI(0.99);
          }
      
          public void testCLI(double alpha) throws Exception {
              System.out.printf("testCLI(alpha=%.2f)%n", alpha);
      
              File output = new File(TEST_OUTPUT_DIR, FRUIT_NAME
                      + String.format(".Lee-%03d", (int) (alpha * 100)));
              deleteIfExist(output);
      
              try {
                  enableExistTrapping();
                  Tools.main(new String[]{
                          "allpairs",
                          "--charset", "UTF-8",
                          "--measure", "lee",
                          "--lee-alpha", Double.toString(alpha),
                          "--input", TEST_FRUIT_EVENTS.toString(),
                          "--input-features", TEST_FRUIT_FEATURES.toString(),
                          "--input-entries", TEST_FRUIT_ENTRIES.toString(),
                          "--output", output.toString()
                  });
              } finally {
                  disableExitTrapping();
              }
      
      
              assertTrue("Output file " + output + " does not exist.", output.exists());
              assertTrue("Output file " + output + " is empty.", output.length() > 0);
          }
      
          @Test
          public void testBothEmptyVectors() throws Exception {
              System.out.println("testBothEmptyVectors");
              int size = 100;
              SparseDoubleVector A = new SparseDoubleVector(size, 0);
              SparseDoubleVector B = new SparseDoubleVector(size, 0);
              double expect = 0;
              double actual = test(A, B);
      
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testSizeOneVectors() throws Exception {
              System.out.println("testSizeOneVectors");
              int size = 100;
              SparseDoubleVector A = new SparseDoubleVector(size, 1);
              SparseDoubleVector B = new SparseDoubleVector(size, 1);
              A.set(0, 1);
              B.set(0, 1);
              double expect = INSTANCE.getHomogeneityBound();
              double actual = test(A, B);
      
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testCardinalityOneVectors() throws Exception {
              System.out.println("testCardinalityOneVectors");
              SparseDoubleVector A = new SparseDoubleVector(1, 1);
              SparseDoubleVector B = new SparseDoubleVector(1, 1);
              A.set(0, 1);
              B.set(0, 1);
              double expect = 0;
              double actual = test(A, B);
      
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testSizeTwoVectors() throws Exception {
              System.out.println("testSizeTwoVectors");
              int size = 100;
              SparseDoubleVector A = new SparseDoubleVector(size, 2);
              SparseDoubleVector B = new SparseDoubleVector(size, 2);
              A.set(0, 1);
              A.set(1, 1);
              B.set(0, 1);
              B.set(1, 1);
              double expect = INSTANCE.getHomogeneityBound();
              double actual = test(A, B);
      
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testHomoginiety() throws Exception {
              System.out.println("testHomoginiety");
              int size = 100;
              SparseDoubleVector A = new SparseDoubleVector(size, size);
              SparseDoubleVector B = new SparseDoubleVector(size, size);
              for (int i = 0; i < size; i++) {
                  double value = RANDOM.nextDouble();
                  A.set(i, value);
                  B.set(i, value);
              }
      
              double expect = INSTANCE.getHomogeneityBound();
              double actual = test(A, B);
      
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testFruitData() throws Exception {
              System.out.println("testFruitData");
              int limit = 5;
      
              List> vecs = TestConstants.loadFruitVectors();
      
              limit = Math.min(limit, vecs.size());
      
              final double[][] results = new double[limit][limit];
              for (int i = 0; i < limit; i++) {
                  for (int j = 0; j < limit; j++) {
                      SparseDoubleVector A = vecs.get(i).value();
                      SparseDoubleVector B = vecs.get(j).value();
                      results[i][j] = test(A, B);
                  }
              }
      
          }
      
          @Test
          public void testLargeCardinality() throws Exception {
              System.out.println("testLargeCardinality");
              final int size = 100;
              final SparseDoubleVector A = new SparseDoubleVector(
                      Integer.MAX_VALUE, size);
              final SparseDoubleVector B = new SparseDoubleVector(
                      Integer.MAX_VALUE, size);
              for (int i = 0; i < size; i++) {
                  A.set(RANDOM.nextInt(size * 2), RANDOM.nextDouble());
                  B.set(RANDOM.nextInt(size * 2), RANDOM.nextDouble());
              }
      
              test(A, B);
          }
      
          static List> loadFruitVectors() throws IOException {
      
              final DoubleEnumerating indexDelegate = new DoubleEnumeratingDelegate();
              final FastWeightedTokenPairVectorSource eventSrc =
                      BybloIO.openEventsVectorSource(
                              TEST_FRUIT_EVENTS, DEFAULT_CHARSET, indexDelegate);
              final List> vecs =
                      new ArrayList>();
              while (eventSrc.hasNext())
                  vecs.add(eventSrc.read());
      
              if (eventSrc instanceof Closeable) {
                  ((Closeable) eventSrc).close();
              }
      
              return vecs;
          }
      
          public double test(SparseDoubleVector A, SparseDoubleVector B) {
              final double val = INSTANCE.similarity(A, B);
              assertFalse("Similarity is NaN" + " with measure " + INSTANCE,
                      Double.isNaN(val));
              assertFalse("Similarity is " + val + " with measure " + INSTANCE,
                      Double.isInfinite(val));
      
              final double min, max;
              if (INSTANCE.getHeterogeneityBound() < INSTANCE.getHomogeneityBound()) {
                  min = INSTANCE.getHeterogeneityBound();
                  max = INSTANCE.getHomogeneityBound();
              } else {
                  min = INSTANCE.getHomogeneityBound();
                  max = INSTANCE.getHeterogeneityBound();
              }
              assertTrue("expected similarity >= " + min + " but found " + val,
                      val >= min);
              assertTrue("expected similarity <= " + max + " but found " + val,
                      val <= max);
      
      
              if (INSTANCE.isCommutative()) {
                  final double rev = INSTANCE.similarity(B, A);
                  assertEquals("Measure is declared computative, but reversing "
                          + "operands results in a different score.", rev, val,
                          EPSILON);
              }
      =======
      import junit.framework.Assert;
      
      import org.junit.Ignore;
      import org.junit.Test;
      
      import uk.ac.susx.mlcl.lib.collect.SparseDoubleVector;
      
      /**
       * 
       * @author Hamish I A Morgan <hamish.morgan@sussex.ac.uk>
       */
      public class LeeSkewDivergenceTest extends
      		AbstractMeasureTest {
      
      	@Override
      	Class getMeasureClass() {
      		return LeeSkewDivergence.class;
      	}
      
      	@Override
      	String getMeasureName() {
      		return "lee";
      	}
      
      	@Test
      	@Ignore
      	@Override
      	public void testOneEmptyVector() {
      		throw new UnsupportedOperationException();
      	}
      
      	@Test
      	@Override
      	public void testCardinalityOneVectors() {
      		System.out.println("testCardinalityOneVectors");
      		SparseDoubleVector A = new SparseDoubleVector(1, 1);
      		SparseDoubleVector B = new SparseDoubleVector(1, 1);
      		A.set(0, 1);
      		B.set(0, 1);
      		double expect = 0;
      		double actual = similarity(newInstance(), A, B);
      
      		Assert.assertEquals(expect, actual, EPSILON);
      	}
      
      	@Test
      	@Ignore
      	@Override
      	public void testHeteroginiety() {
      		throw new UnsupportedOperationException();
      	}
      
      	//
      	@Test
      	public void testCLI_001() throws Exception {
      		testCLI(0.01);
      	}
      
      	@Test
      	public void testCLI_010() throws Exception {
      		testCLI(0.10);
      	}
      
      	@Test
      	public void testCLI_050() throws Exception {
      		testCLI(0.50);
      	}
      
      	@Test
      	public void testCLI_090() throws Exception {
      		testCLI(0.90);
      	}
      
      	@Test
      	public void testCLI_099() throws Exception {
      		testCLI(0.99);
      	}
      
      	public void testCLI(double alpha) throws Exception {
      		System.out.printf("testCLI(alpha=%.2f)%n", alpha);
      		runFromCommandLine("--lee-alpha", Double.toString(alpha));
      	}
      >>>>>>> 5f0ba9177b34449ea27dabdc17fd0793620c7d56
      
      }
      Solution content
       */
      package uk.ac.susx.mlcl.byblo.measures.impl;
      
      import junit.framework.Assert;
      
      import org.junit.Ignore;
      import org.junit.Test;
      
      import uk.ac.susx.mlcl.lib.collect.SparseDoubleVector;
      
      /**
       * 
       * @author Hamish I A Morgan <hamish.morgan@sussex.ac.uk>
       */
      public class LeeSkewDivergenceTest extends
      		AbstractMeasureTest {
      
      	@Override
      	Class getMeasureClass() {
      		return LeeSkewDivergence.class;
      	}
      
      	@Override
      	String getMeasureName() {
      		return "lee";
      	}
      
      	@Test
      	@Ignore
      	@Override
      	public void testOneEmptyVector() {
      		throw new UnsupportedOperationException();
      	}
      
      	@Test
      	@Override
      	public void testCardinalityOneVectors() {
      		System.out.println("testCardinalityOneVectors");
      		SparseDoubleVector A = new SparseDoubleVector(1, 1);
      		SparseDoubleVector B = new SparseDoubleVector(1, 1);
      		A.set(0, 1);
      		B.set(0, 1);
      		double expect = 0;
      		double actual = similarity(newInstance(), A, B);
      
      		Assert.assertEquals(expect, actual, EPSILON);
      	}
      
      	@Test
      	@Ignore
      	@Override
      	public void testHeteroginiety() {
      		throw new UnsupportedOperationException();
      	}
      
      	//
      	@Test
      	public void testCLI_001() throws Exception {
      		testCLI(0.01);
      	}
      
      	@Test
      	public void testCLI_010() throws Exception {
      		testCLI(0.10);
      	}
      
      	@Test
      	public void testCLI_050() throws Exception {
      		testCLI(0.50);
      	}
      
      	@Test
      	public void testCLI_090() throws Exception {
      		testCLI(0.90);
      	}
      
      	@Test
      	public void testCLI_099() throws Exception {
      		testCLI(0.99);
      	}
      
      	public void testCLI(double alpha) throws Exception {
      		System.out.printf("testCLI(alpha=%.2f)%n", alpha);
      		runFromCommandLine("--lee-alpha", Double.toString(alpha));
      	}
      
      }
      File
      LeeSkewDivergenceTest.java
      Developer's decision
      Version 2
      Kind of conflict
      Annotation
      Attribute
      Class signature
      Comment
      If statement
      Import
      Method declaration
      Method invocation
      Method signature
      Variable
      Chunk
      Conflicting content
          @BeforeClass
       */
      package uk.ac.susx.mlcl.byblo.measures.impl;
      
      <<<<<<< HEAD
      import org.junit.BeforeClass;
      import org.junit.Test;
      import uk.ac.susx.mlcl.TestConstants;
      import uk.ac.susx.mlcl.byblo.Tools;
      import uk.ac.susx.mlcl.byblo.enumerators.DoubleEnumerating;
      import uk.ac.susx.mlcl.byblo.enumerators.DoubleEnumeratingDelegate;
      import uk.ac.susx.mlcl.byblo.io.BybloIO;
      import uk.ac.susx.mlcl.byblo.io.FastWeightedTokenPairVectorSource;
      import uk.ac.susx.mlcl.lib.collect.Indexed;
      import uk.ac.susx.mlcl.lib.collect.SparseDoubleVector;
      
      import java.io.Closeable;
      import java.io.File;
      import java.io.IOException;
      import java.util.ArrayList;
      import java.util.List;
      import java.util.Random;
      
      import static org.junit.Assert.*;
      import static uk.ac.susx.mlcl.TestConstants.*;
      import static uk.ac.susx.mlcl.lib.test.ExitTrapper.disableExitTrapping;
      import static uk.ac.susx.mlcl.lib.test.ExitTrapper.enableExistTrapping;
      
      /**
       * @author Hamish I A Morgan <hamish.morgan@sussex.ac.uk>
       */
      public class LinTest {
      
          static Lin INSTANCE;
      
          static final double EPSILON = 0.0000000001;
      
          static Random RANDOM;
      
          public static void setUpClass() throws Exception {
              INSTANCE = new Lin();
              RANDOM = new Random(1234);
          }
      
          @Test
          public void testCLI() throws Exception {
              System.out.println("testCLI");
      
              File output = new File(TEST_OUTPUT_DIR, FRUIT_NAME + ".Lin");
              deleteIfExist(output);
      
              try {
                  enableExistTrapping();
                  Tools.main(new String[]{
                          "allpairs",
                          "--charset", "UTF-8",
                          "--measure", "lin",
                          "--input", TEST_FRUIT_EVENTS.toString(),
                          "--input-features", TEST_FRUIT_FEATURES.toString(),
                          "--input-entries", TEST_FRUIT_ENTRIES.toString(),
                          "--output", output.toString()
                  });
              } finally {
                  disableExitTrapping();
              }
      
      
              assertTrue("Output file " + output + " does not exist.", output.exists());
              assertTrue("Output file " + output + " is empty.", output.length() > 0);
          }
      
          @Test
          public void testBothEmptyVectors() throws Exception {
              System.out.println("testBothEmptyVectors");
              int size = 100;
              SparseDoubleVector A = new SparseDoubleVector(size, 0);
              SparseDoubleVector B = new SparseDoubleVector(size, 0);
              double expect = 0;
              double actual = test(A, B);
      
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testOneEmptyVector() throws Exception {
              System.out.println("testOneEmptyVector");
              int size = 100;
              SparseDoubleVector A = new SparseDoubleVector(size, 0);
              SparseDoubleVector B = new SparseDoubleVector(size, size);
              for (int i = 0; i < size; i++)
                  B.set(i, RANDOM.nextDouble());
      
              double expect = 0;
              double actual = test(A, B);
      
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testSizeOneVectors() throws Exception {
              System.out.println("testSizeOneVectors");
              int size = 100;
              SparseDoubleVector A = new SparseDoubleVector(size, 1);
              SparseDoubleVector B = new SparseDoubleVector(size, 1);
              A.set(0, 1);
              B.set(0, 1);
              double expect = INSTANCE.getHomogeneityBound();
              double actual = test(A, B);
      
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testCardinalityOneVectors() throws Exception {
              System.out.println("testCardinalityOneVectors");
              SparseDoubleVector A = new SparseDoubleVector(1, 1);
              SparseDoubleVector B = new SparseDoubleVector(1, 1);
              A.set(0, 1);
              B.set(0, 1);
              double expect = 1;
              double actual = test(A, B);
      
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testSizeTwoVectors() throws Exception {
              System.out.println("testSizeTwoVectors");
              int size = 100;
              SparseDoubleVector A = new SparseDoubleVector(size, 2);
              SparseDoubleVector B = new SparseDoubleVector(size, 2);
              A.set(0, 1);
              A.set(1, 1);
              B.set(0, 1);
              B.set(1, 1);
              double expect = INSTANCE.getHomogeneityBound();
              double actual = test(A, B);
      
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testCommutative() throws Exception {
              System.out.println("testCommutative");
              int size = 100;
              SparseDoubleVector A = new SparseDoubleVector(size, size);
              SparseDoubleVector B = new SparseDoubleVector(size, size);
              for (int i = 0; i < size; i++) {
                  A.set(i, RANDOM.nextDouble());
                  B.set(i, RANDOM.nextDouble());
              }
      
              double expect = test(A, B);
              double actual = test(B, A);
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testHomoginiety() throws Exception {
              System.out.println("testHomoginiety");
              int size = 100;
              SparseDoubleVector A = new SparseDoubleVector(size, size);
              SparseDoubleVector B = new SparseDoubleVector(size, size);
              for (int i = 0; i < size; i++) {
                  double value = RANDOM.nextDouble();
                  A.set(i, value);
                  B.set(i, value);
              }
      
              double expect = INSTANCE.getHomogeneityBound();
              double actual = test(A, B);
      
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testHeteroginiety() throws Exception {
              System.out.println("testHeteroginiety");
              int size = 100;
              SparseDoubleVector A = new SparseDoubleVector(size, size);
              SparseDoubleVector B = new SparseDoubleVector(size, size);
              for (int i = 0; i < size / 2; i++) {
                  A.set(i * 2, i);
                  B.set(i * 2 + 1, i);
              }
      
              double expect = INSTANCE.getHeterogeneityBound();
              double actual = test(A, B);
      
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testFruitData() throws Exception {
              System.out.println("testFruitData");
              int limit = 5;
      
              List> vecs = TestConstants.loadFruitVectors();
      
              limit = Math.min(limit, vecs.size());
      
              final double[][] results = new double[limit][limit];
              for (int i = 0; i < limit; i++) {
                  for (int j = 0; j < limit; j++) {
                      SparseDoubleVector A = vecs.get(i).value();
                      SparseDoubleVector B = vecs.get(j).value();
                      results[i][j] = test(A, B);
                  }
              }
      
              // diagonals should all be +1
              for (int i = 0; i < limit; i++) {
                  assertEquals(INSTANCE.getHomogeneityBound(), results[i][i], EPSILON);
              }
              // triangular mirrors should be equal
              for (int i = 0; i < limit; i++) {
                  for (int j = 0; j < limit; j++) {
                      assertEquals(results[i][j], results[j][i], EPSILON);
                  }
              }
          }
      
          @Test
          public void testLargeCardinality() throws Exception {
              System.out.println("testLargeCardinality");
              final int size = 100;
              final SparseDoubleVector A = new SparseDoubleVector(
                      Integer.MAX_VALUE, size);
              final SparseDoubleVector B = new SparseDoubleVector(
                      Integer.MAX_VALUE, size);
              for (int i = 0; i < size; i++) {
                  A.set(RANDOM.nextInt(size * 2), RANDOM.nextDouble());
                  B.set(RANDOM.nextInt(size * 2), RANDOM.nextDouble());
              }
      
              test(A, B);
          }
      
          public double test(SparseDoubleVector A, SparseDoubleVector B) {
              final double val = INSTANCE.similarity(A, B);
              assertFalse("Similarity is NaN" + " with measure " + INSTANCE,
                      Double.isNaN(val));
              assertFalse("Similarity is " + val + " with measure " + INSTANCE,
                      Double.isInfinite(val));
      
              final double min, max;
              if (INSTANCE.getHeterogeneityBound() < INSTANCE.getHomogeneityBound()) {
                  min = INSTANCE.getHeterogeneityBound();
                  max = INSTANCE.getHomogeneityBound();
              } else {
                  min = INSTANCE.getHomogeneityBound();
                  max = INSTANCE.getHeterogeneityBound();
              }
              assertTrue("expected similarity >= " + min + " but found " + val,
                      val >= min - EPSILON);
              assertTrue("expected similarity <= " + max + " but found " + val,
                      val <= max + EPSILON);
      
      
              if (INSTANCE.isCommutative()) {
                  final double rev = INSTANCE.similarity(B, A);
                  assertEquals("Measure is declared computative, but reversing "
                          + "operands results in a different score.", rev, val,
                          EPSILON);
              }
      =======
      
      /**
       * 
       * @author Hamish I A Morgan <hamish.morgan@sussex.ac.uk>
       */
      public class LinTest extends AbstractMeasureTest {
      
      	@Override
      	Class getMeasureClass() {
      		return Lin.class;
      	}
      >>>>>>> 5f0ba9177b34449ea27dabdc17fd0793620c7d56
      
      	@Override
      	String getMeasureName() {
      Solution content
       */
      package uk.ac.susx.mlcl.byblo.measures.impl;
      
      
      /**
       * 
       * @author Hamish I A Morgan <hamish.morgan@sussex.ac.uk>
       */
      public class LinTest extends AbstractMeasureTest {
      
      	@Override
      	Class getMeasureClass() {
      		return Lin.class;
      	}
      
      	@Override
      	String getMeasureName() {
      File
      LinTest.java
      Developer's decision
      Version 2
      Kind of conflict
      Annotation
      Attribute
      Class signature
      Comment
      If statement
      Import
      Method declaration
      Method invocation
      Method signature
      Variable
      Chunk
      Conflicting content
              }
          @Test
       */
      package uk.ac.susx.mlcl.byblo.measures.impl;
      
      <<<<<<< HEAD
      import org.junit.BeforeClass;
      import org.junit.Test;
      import uk.ac.susx.mlcl.TestConstants;
      import uk.ac.susx.mlcl.byblo.Tools;
      import uk.ac.susx.mlcl.byblo.enumerators.DoubleEnumerating;
      import uk.ac.susx.mlcl.byblo.enumerators.DoubleEnumeratingDelegate;
      import uk.ac.susx.mlcl.byblo.io.BybloIO;
      import uk.ac.susx.mlcl.byblo.io.FastWeightedTokenPairVectorSource;
      import uk.ac.susx.mlcl.lib.collect.Indexed;
      import uk.ac.susx.mlcl.lib.collect.SparseDoubleVector;
      
      import java.io.Closeable;
      import java.io.File;
      import java.io.IOException;
      import java.util.ArrayList;
      import java.util.List;
      import java.util.Random;
      
      import static org.junit.Assert.*;
      import static uk.ac.susx.mlcl.TestConstants.*;
      import static uk.ac.susx.mlcl.lib.test.ExitTrapper.disableExitTrapping;
      import static uk.ac.susx.mlcl.lib.test.ExitTrapper.enableExistTrapping;
      
      /**
       * @author Hamish I A Morgan <hamish.morgan@sussex.ac.uk>
       */
      public class LpSpaceDistanceTest {
      
          static LpSpaceDistance INSTANCE;
      
          static final double EPSILON = 0;
      
          static Random RANDOM;
      
          @BeforeClass
          public static void setUpClass() throws Exception {
              INSTANCE = new LpSpaceDistance();
              RANDOM = new Random(1234);
          }
      
          @Test
          public void testCLI_neginf() throws Exception {
              testCLI(Double.NEGATIVE_INFINITY);
          }
      
          @Test
          public void testCLI_posinf() throws Exception {
              testCLI(Double.POSITIVE_INFINITY);
          }
      
          @Test
          public void testCLI_neg1() throws Exception {
              testCLI(-1);
          }
      
          @Test
          public void testCLI_0() throws Exception {
              testCLI(0);
          }
      
          public void testCLI_1() throws Exception {
              testCLI(1);
          }
      
          @Test
          public void testCLI_2() throws Exception {
              testCLI(2);
          }
      
          @Test
          public void testCLI_3() throws Exception {
              testCLI(3);
          }
      
          @Test
          public void testCLI_e() throws Exception {
              testCLI(Math.E);
          }
      
          public void testCLI(double power) throws Exception {
              System.out.printf("testCLI(power=%f)%n", power);
      
              File output = new File(TEST_OUTPUT_DIR, FRUIT_NAME
                      + String.format(".L-%4.2f-Space", power));
              deleteIfExist(output);
      
              try {
                  enableExistTrapping();
                  Tools.main(new String[]{
                          "allpairs",
                          "--charset", "UTF-8",
                          "--measure", "lp",
                          "--mink-p", Double.toString(power),
                          "--input", TEST_FRUIT_EVENTS.toString(),
                          "--input-features", TEST_FRUIT_FEATURES.toString(),
                          "--input-entries", TEST_FRUIT_ENTRIES.toString(),
                          "--output", output.toString()
                  });
              } finally {
                  disableExitTrapping();
              }
      
              assertTrue("Output file " + output + " does not exist.", output.exists());
              assertTrue("Output file " + output + " is empty.", output.length() > 0);
          }
      
          @Test
          public void testBothEmptyVectors() throws Exception {
              System.out.println("testBothEmptyVectors");
              int size = 100;
              SparseDoubleVector A = new SparseDoubleVector(size, 0);
              SparseDoubleVector B = new SparseDoubleVector(size, 0);
              double expect = 0;
              double actual = test(A, B);
      
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testOneEmptyVector() throws Exception {
              System.out.println("testOneEmptyVector");
              int size = 100;
              SparseDoubleVector A = new SparseDoubleVector(size, 0);
              SparseDoubleVector B = new SparseDoubleVector(size, size);
              for (int i = 0; i < size; i++)
                  B.set(i, 1);
      
              double expect = Math.sqrt(size);
              double actual = test(A, B);
      
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testSizeOneVectors() throws Exception {
              System.out.println("testSizeOneVectors");
              int size = 100;
              SparseDoubleVector A = new SparseDoubleVector(size, 1);
              SparseDoubleVector B = new SparseDoubleVector(size, 1);
              A.set(0, 1);
              B.set(0, 1);
              double expect = INSTANCE.getHomogeneityBound();
              double actual = test(A, B);
      
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testCardinalityOneVectors() throws Exception {
              System.out.println("testCardinalityOneVectors");
              SparseDoubleVector A = new SparseDoubleVector(1, 1);
              SparseDoubleVector B = new SparseDoubleVector(1, 1);
              A.set(0, 1);
              B.set(0, 1);
              double expect = INSTANCE.getHomogeneityBound();
              double actual = test(A, B);
      
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testSizeTwoVectors() throws Exception {
              System.out.println("testSizeTwoVectors");
              int size = 100;
              SparseDoubleVector A = new SparseDoubleVector(size, 2);
              SparseDoubleVector B = new SparseDoubleVector(size, 2);
              A.set(0, 1);
              A.set(1, 1);
              B.set(0, 1);
              B.set(1, 1);
              double expect = INSTANCE.getHomogeneityBound();
              double actual = test(A, B);
      
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testCommutative() throws Exception {
              System.out.println("testCommutative");
              int size = 100;
              SparseDoubleVector A = new SparseDoubleVector(size, size);
              SparseDoubleVector B = new SparseDoubleVector(size, size);
              for (int i = 0; i < size; i++) {
                  A.set(i, RANDOM.nextDouble());
                  B.set(i, RANDOM.nextDouble());
              }
      
              double expect = test(A, B);
              double actual = test(B, A);
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testHomoginiety() throws Exception {
              System.out.println("testHomoginiety");
              int size = 100;
              SparseDoubleVector A = new SparseDoubleVector(size, size);
              SparseDoubleVector B = new SparseDoubleVector(size, size);
              for (int i = 0; i < size; i++) {
                  double value = RANDOM.nextDouble();
                  A.set(i, value);
                  B.set(i, value);
              }
      
              double expect = INSTANCE.getHomogeneityBound();
              double actual = test(A, B);
      
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testFruitData() throws Exception {
              System.out.println("testFruitData");
              int limit = 5;
      
              List> vecs = TestConstants.loadFruitVectors();
      
              limit = Math.min(limit, vecs.size());
      
              final double[][] results = new double[limit][limit];
              for (int i = 0; i < limit; i++) {
                  for (int j = 0; j < limit; j++) {
                      SparseDoubleVector A = vecs.get(i).value();
                      SparseDoubleVector B = vecs.get(j).value();
                      results[i][j] = test(A, B);
                  }
              }
      
              // diagonals should all be +1
              for (int i = 0; i < limit; i++) {
                  assertEquals(INSTANCE.getHomogeneityBound(), results[i][i], EPSILON);
              }
              // triangular mirrors should be equal
              for (int i = 0; i < limit; i++) {
                  for (int j = 0; j < limit; j++) {
                      assertEquals(results[i][j], results[j][i], EPSILON);
                  }
          }
      
          @Test
          public void testLargeCardinality() throws Exception {
              System.out.println("testLargeCardinality");
              final int size = 100;
              final SparseDoubleVector A = new SparseDoubleVector(
                      Integer.MAX_VALUE, size);
              final SparseDoubleVector B = new SparseDoubleVector(
                      Integer.MAX_VALUE, size);
              for (int i = 0; i < size; i++) {
                  A.set(RANDOM.nextInt(size * 2), RANDOM.nextDouble());
                  B.set(RANDOM.nextInt(size * 2), RANDOM.nextDouble());
              }
      
              test(A, B);
          }
      
          public double test(SparseDoubleVector A, SparseDoubleVector B) {
              final double val = INSTANCE.similarity(A, B);
              assertFalse("Similarity is NaN" + " with measure " + INSTANCE,
                      Double.isNaN(val));
              assertFalse("Similarity is " + val + " with measure " + INSTANCE,
                      Double.isInfinite(val));
      
              final double min, max;
              if (INSTANCE.getHeterogeneityBound() < INSTANCE.getHomogeneityBound()) {
                  min = INSTANCE.getHeterogeneityBound();
                  max = INSTANCE.getHomogeneityBound();
              } else {
                  min = INSTANCE.getHomogeneityBound();
                  max = INSTANCE.getHeterogeneityBound();
              }
              assertTrue("expected similarity >= " + min + " but found " + val,
                      val >= min);
              assertTrue("expected similarity <= " + max + " but found " + val,
                      val <= max);
      
      
              if (INSTANCE.isCommutative()) {
                  final double rev = INSTANCE.similarity(B, A);
                  assertEquals("Measure is declared computative, but reversing "
                          + "operands results in a different score.", rev, val,
                          EPSILON);
              }
      
              return val;
          }
      
          static List> loadFruitVectors() throws IOException {
      
              final DoubleEnumerating indexDelegate = new DoubleEnumeratingDelegate();
              final FastWeightedTokenPairVectorSource eventSrc =
                      BybloIO.openEventsVectorSource(
                              TEST_FRUIT_EVENTS, DEFAULT_CHARSET, indexDelegate);
              final List> vecs =
                      new ArrayList>();
              while (eventSrc.hasNext())
                  vecs.add(eventSrc.read());
      
              if (eventSrc instanceof Closeable) {
                  ((Closeable) eventSrc).close();
              }
      
              return vecs;
          }
      =======
      import org.junit.Ignore;
      import org.junit.Test;
      
      /**
       * 
       * @author Hamish I A Morgan <hamish.morgan@sussex.ac.uk>
       */
      public class LpSpaceDistanceTest extends AbstractMeasureTest {
      
      	@Override
      	Class getMeasureClass() {
      		return LpSpaceDistance.class;
      	}
      
      	@Override
      	String getMeasureName() {
      		return "lp";
      	}
      
      	@Test
      	@Override
      	@Ignore
      	public void testOneEmptyVector() {
      		throw new UnsupportedOperationException();
      	}
      
      	@Test
      	@Override
      	@Ignore
      	public void testHeteroginiety() {
      		throw new UnsupportedOperationException();
      	}
      
      	@Test
      	public void testCLI_neginf() throws Exception {
      		testCLI(Double.NEGATIVE_INFINITY);
      	}
      
      	@Test
      	public void testCLI_posinf() throws Exception {
      		testCLI(Double.POSITIVE_INFINITY);
      	}
      
      	@Test
      	public void testCLI_neg1() throws Exception {
      		testCLI(-1);
      	}
      
      	@Test
      	public void testCLI_0() throws Exception {
      		testCLI(0);
      	}
      
      	@Test
      	public void testCLI_1() throws Exception {
      		testCLI(1);
      	}
      
      	@Test
      	public void testCLI_2() throws Exception {
      		testCLI(2);
      	}
      
      	@Test
      	public void testCLI_3() throws Exception {
      		testCLI(3);
      	}
      
      	@Test
      	public void testCLI_e() throws Exception {
      		testCLI(Math.E);
      	}
      
      	public void testCLI(double power) throws Exception {
      		System.out.printf("testCLI(power=%f)%n", power);
      		runFromCommandLine("--mink-p", Double.toString(power));
      	}
      
      >>>>>>> 5f0ba9177b34449ea27dabdc17fd0793620c7d56
      }
      Solution content
       */
      package uk.ac.susx.mlcl.byblo.measures.impl;
      
      import org.junit.Ignore;
      import org.junit.Test;
      
      /**
       * 
       * @author Hamish I A Morgan <hamish.morgan@sussex.ac.uk>
       */
      public class LpSpaceDistanceTest extends AbstractMeasureTest {
      
      	@Override
      	Class getMeasureClass() {
      		return LpSpaceDistance.class;
      	}
      
      	@Override
      	String getMeasureName() {
      		return "lp";
      	}
      
      	@Test
      	@Override
      	@Ignore
      	public void testOneEmptyVector() {
      		throw new UnsupportedOperationException();
      	}
      
      	@Test
      	@Override
      	@Ignore
      	public void testHeteroginiety() {
      		throw new UnsupportedOperationException();
      	}
      
      	@Test
      	public void testCLI_neginf() throws Exception {
      		testCLI(Double.NEGATIVE_INFINITY);
      	}
      
      	@Test
      	public void testCLI_posinf() throws Exception {
      		testCLI(Double.POSITIVE_INFINITY);
      	}
      
      	@Test
      	public void testCLI_neg1() throws Exception {
      		testCLI(-1);
      	}
      
      	@Test
      	public void testCLI_0() throws Exception {
      		testCLI(0);
      	}
      
      	@Test
      	public void testCLI_1() throws Exception {
      		testCLI(1);
      	}
      
      	@Test
      	public void testCLI_2() throws Exception {
      		testCLI(2);
      	}
      
      	@Test
      	public void testCLI_3() throws Exception {
      		testCLI(3);
      	}
      
      	@Test
      	public void testCLI_e() throws Exception {
      		testCLI(Math.E);
      	}
      
      	public void testCLI(double power) throws Exception {
      		System.out.printf("testCLI(power=%f)%n", power);
      		runFromCommandLine("--mink-p", Double.toString(power));
      	}
      
      }
      File
      LpSpaceDistanceTest.java
      Developer's decision
      Version 2
      Kind of conflict
      Annotation
      Attribute
      Class signature
      Comment
      Import
      Method declaration
      Chunk
      Conflicting content
              int limit = 5;
       */
      package uk.ac.susx.mlcl.byblo.measures.impl;
      
      <<<<<<< HEAD
      import org.junit.BeforeClass;
      import org.junit.Test;
      import uk.ac.susx.mlcl.TestConstants;
      import uk.ac.susx.mlcl.byblo.Tools;
      import uk.ac.susx.mlcl.byblo.enumerators.DoubleEnumerating;
      import uk.ac.susx.mlcl.byblo.enumerators.DoubleEnumeratingDelegate;
      import uk.ac.susx.mlcl.byblo.io.BybloIO;
      import uk.ac.susx.mlcl.byblo.io.FastWeightedTokenPairVectorSource;
      import uk.ac.susx.mlcl.lib.collect.Indexed;
      import uk.ac.susx.mlcl.lib.collect.SparseDoubleVector;
      
      import java.io.Closeable;
      import java.io.File;
      import java.io.IOException;
      import java.util.ArrayList;
      import java.util.List;
      import java.util.Random;
      
      import static org.junit.Assert.*;
      import static uk.ac.susx.mlcl.TestConstants.*;
      import static uk.ac.susx.mlcl.lib.test.ExitTrapper.disableExitTrapping;
      import static uk.ac.susx.mlcl.lib.test.ExitTrapper.enableExistTrapping;
      
      /**
       * @author Hamish I A Morgan <hamish.morgan@sussex.ac.uk>
       */
      public class OverlapTest {
      
          static Overlap INSTANCE;
      
          static final double EPSILON = 0;
      
          static Random RANDOM;
      
          @BeforeClass
          public static void setUpClass() throws Exception {
              INSTANCE = new Overlap();
              RANDOM = new Random(1234);
          }
      
          @Test
          public void testCLI() throws Exception {
              System.out.println("testCLI");
      
              File output = new File(TEST_OUTPUT_DIR, FRUIT_NAME + ".Overlap");
              deleteIfExist(output);
      
              try {
                  enableExistTrapping();
                  Tools.main(new String[]{
                          "allpairs",
                          "--charset", "UTF-8",
                          "--measure", "Overlap",
                          "--input", TEST_FRUIT_EVENTS.toString(),
                          "--input-features", TEST_FRUIT_FEATURES.toString(),
                          "--input-entries", TEST_FRUIT_ENTRIES.toString(),
                          "--output", output.toString()
                  });
              } finally {
                  disableExitTrapping();
              }
      
      
              assertTrue("Output file " + output + " does not exist.", output.exists());
              assertTrue("Output file " + output + " is empty.", output.length() > 0);
          }
      
          @Test
          public void testBothEmptyVectors() throws Exception {
              System.out.println("testBothEmptyVectors");
              int size = 100;
              SparseDoubleVector A = new SparseDoubleVector(size, 0);
              SparseDoubleVector B = new SparseDoubleVector(size, 0);
              double expect = 0;
              double actual = test(A, B);
      
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testOneEmptyVector() throws Exception {
              System.out.println("testOneEmptyVector");
              int size = 100;
              SparseDoubleVector A = new SparseDoubleVector(size, 0);
              SparseDoubleVector B = new SparseDoubleVector(size, size);
              for (int i = 0; i < size; i++)
                  B.set(i, RANDOM.nextDouble());
      
              double expect = 0;
              double actual = test(A, B);
      
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testSizeOneVectors() throws Exception {
              System.out.println("testSizeOneVectors");
              int size = 100;
              SparseDoubleVector A = new SparseDoubleVector(size, 1);
              SparseDoubleVector B = new SparseDoubleVector(size, 1);
              A.set(0, 1);
              B.set(0, 1);
              double expect = INSTANCE.getHomogeneityBound();
              double actual = test(A, B);
      
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testCardinalityOneVectors() throws Exception {
              System.out.println("testCardinalityOneVectors");
              SparseDoubleVector A = new SparseDoubleVector(1, 1);
              SparseDoubleVector B = new SparseDoubleVector(1, 1);
              A.set(0, 1);
              B.set(0, 1);
              double expect = 1;
              double actual = test(A, B);
      
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testSizeTwoVectors() throws Exception {
              System.out.println("testSizeTwoVectors");
              int size = 100;
              SparseDoubleVector A = new SparseDoubleVector(size, 2);
              SparseDoubleVector B = new SparseDoubleVector(size, 2);
              A.set(0, 1);
              A.set(1, 1);
              B.set(0, 1);
              B.set(1, 1);
              double expect = INSTANCE.getHomogeneityBound();
              double actual = test(A, B);
      
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testCommutative() throws Exception {
              System.out.println("testCommutative");
              int size = 100;
              SparseDoubleVector A = new SparseDoubleVector(size, size);
              SparseDoubleVector B = new SparseDoubleVector(size, size);
              for (int i = 0; i < size; i++) {
                  A.set(i, RANDOM.nextDouble());
                  B.set(i, RANDOM.nextDouble());
              }
      
              double expect = test(A, B);
              double actual = test(B, A);
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testHomoginiety() throws Exception {
              System.out.println("testHomoginiety");
              int size = 100;
              SparseDoubleVector A = new SparseDoubleVector(size, size);
              SparseDoubleVector B = new SparseDoubleVector(size, size);
              for (int i = 0; i < size; i++) {
                  double value = RANDOM.nextDouble();
                  A.set(i, value);
                  B.set(i, value);
              }
      
              double expect = INSTANCE.getHomogeneityBound();
              double actual = test(A, B);
      
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testHeteroginiety() throws Exception {
              System.out.println("testHeteroginiety");
              int size = 100;
              SparseDoubleVector A = new SparseDoubleVector(size, size);
              SparseDoubleVector B = new SparseDoubleVector(size, size);
              for (int i = 0; i < size / 2; i++) {
                  A.set(i * 2, i);
                  B.set(i * 2 + 1, i);
              }
      
              double expect = INSTANCE.getHeterogeneityBound();
              double actual = test(A, B);
      
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testFruitData() throws Exception {
              System.out.println("testFruitData");
      
              List> vecs = TestConstants.loadFruitVectors();
      
              limit = Math.min(limit, vecs.size());
      
              final double[][] results = new double[limit][limit];
              for (int i = 0; i < limit; i++) {
                  for (int j = 0; j < limit; j++) {
                      SparseDoubleVector A = vecs.get(i).value();
                      SparseDoubleVector B = vecs.get(j).value();
                      results[i][j] = test(A, B);
                  }
              }
      
              // diagonals should all be +1
              for (int i = 0; i < limit; i++) {
                  assertEquals(INSTANCE.getHomogeneityBound(), results[i][i], EPSILON);
              }
              // triangular mirrors should be equal
              for (int i = 0; i < limit; i++) {
                  for (int j = 0; j < limit; j++) {
                      assertEquals(results[i][j], results[j][i], EPSILON);
                  }
              }
          }
      =======
      /**
       * 
       * @author Hamish I A Morgan <hamish.morgan@sussex.ac.uk>
       */
      public class OverlapTest extends AbstractMeasureTest {
      >>>>>>> 5f0ba9177b34449ea27dabdc17fd0793620c7d56
      
      	@Override
      	Class getMeasureClass() {
      Solution content
       */
      package uk.ac.susx.mlcl.byblo.measures.impl;
      
      /**
       * 
       * @author Hamish I A Morgan <hamish.morgan@sussex.ac.uk>
       */
      public class OverlapTest extends AbstractMeasureTest {
      
      	@Override
      	Class getMeasureClass() {
      File
      OverlapTest.java
      Developer's decision
      Version 2
      Kind of conflict
      Annotation
      Attribute
      Class signature
      Comment
      Import
      Method declaration
      Chunk
      Conflicting content
      		return "overlap";
      	}
      
      <<<<<<< HEAD
          public double test(SparseDoubleVector A, SparseDoubleVector B) {
              final double val = INSTANCE.similarity(A, B);
              assertFalse("Similarity is NaN", Double.isNaN(val));
              assertFalse("Similarity is " + val, Double.isInfinite(val));
              assertTrue("Similarity < -1", val >= INSTANCE.getHeterogeneityBound());
              assertTrue("Similarity > +1", val <= INSTANCE.getHomogeneityBound());
              return val;
          }
      
          static List> loadFruitVectors() throws IOException {
      
              final DoubleEnumerating indexDelegate = new DoubleEnumeratingDelegate();
              final FastWeightedTokenPairVectorSource eventSrc =
                      BybloIO.openEventsVectorSource(
                              TEST_FRUIT_EVENTS, DEFAULT_CHARSET, indexDelegate);
              final List> vecs =
                      new ArrayList>();
              while (eventSrc.hasNext())
                  vecs.add(eventSrc.read());
      
              if (eventSrc instanceof Closeable) {
                  ((Closeable) eventSrc).close();
              }
      
              return vecs;
          }
      =======
      >>>>>>> 5f0ba9177b34449ea27dabdc17fd0793620c7d56
      }
      Solution content
      		return "overlap";
      	}
      
      }
      File
      OverlapTest.java
      Developer's decision
      Version 2
      Kind of conflict
      Method declaration
      Chunk
      Conflicting content
       */
      package uk.ac.susx.mlcl.byblo.measures.impl;
      
      <<<<<<< HEAD
      import org.junit.BeforeClass;
      import org.junit.Test;
      
      import uk.ac.susx.mlcl.TestConstants;
      import uk.ac.susx.mlcl.byblo.Tools;
      import uk.ac.susx.mlcl.byblo.enumerators.DoubleEnumerating;
      import uk.ac.susx.mlcl.byblo.enumerators.DoubleEnumeratingDelegate;
      import uk.ac.susx.mlcl.byblo.io.BybloIO;
      import uk.ac.susx.mlcl.byblo.io.FastWeightedTokenPairVectorSource;
      import uk.ac.susx.mlcl.lib.collect.Indexed;
      import uk.ac.susx.mlcl.lib.collect.SparseDoubleVector;
      
      import java.io.Closeable;
      import java.io.File;
      import java.io.IOException;
      import java.util.ArrayList;
      import java.util.List;
      import java.util.Random;
      
      import static org.junit.Assert.*;
      import static uk.ac.susx.mlcl.TestConstants.*;
      import static uk.ac.susx.mlcl.lib.test.ExitTrapper.disableExitTrapping;
      import static uk.ac.susx.mlcl.lib.test.ExitTrapper.enableExistTrapping;
      
      /**
       * @author Hamish I A Morgan <hamish.morgan@sussex.ac.uk>
       */
      public class PrecisionTest {
      
          static Precision INSTANCE;
      
          static final double EPSILON = 0;
      
          static Random RANDOM;
      
          @BeforeClass
          public static void setUpClass() throws Exception {
              INSTANCE = new Precision();
              RANDOM = new Random(1234);
          }
      
          @Test
          public void testCLI() throws Exception {
              System.out.println("testCLI");
      
              File output = new File(TEST_OUTPUT_DIR, FRUIT_NAME + ".Precision");
              deleteIfExist(output);
      
              try {
                  enableExistTrapping();
                  Tools.main(new String[]{
                          "allpairs",
                          "--charset", "UTF-8",
                          "--measure", "precision",
                          "--input", TEST_FRUIT_EVENTS.toString(),
                          "--input-features", TEST_FRUIT_FEATURES.toString(),
                          "--input-entries", TEST_FRUIT_ENTRIES.toString(),
                          "--output", output.toString()
                  });
              } finally {
                  disableExitTrapping();
              }
      
      
              assertTrue("Output file " + output + " does not exist.", output.exists());
              assertTrue("Output file " + output + " is empty.", output.length() > 0);
          }
      
          @Test
          public void testBothEmptyVectors() throws Exception {
              System.out.println("testBothEmptyVectors");
              int size = 100;
              SparseDoubleVector A = new SparseDoubleVector(size, 0);
              SparseDoubleVector B = new SparseDoubleVector(size, 0);
              double expect = 0;
              double actual = test(A, B);
      
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testOneEmptyVector() throws Exception {
              System.out.println("testOneEmptyVector");
              int size = 100;
              SparseDoubleVector A = new SparseDoubleVector(size, 0);
              SparseDoubleVector B = new SparseDoubleVector(size, size);
              for (int i = 0; i < size; i++)
                  B.set(i, RANDOM.nextDouble());
      
              double expect = 0;
              double actual = test(A, B);
      
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testSizeOneVectors() throws Exception {
              System.out.println("testSizeOneVectors");
              int size = 100;
              SparseDoubleVector A = new SparseDoubleVector(size, 1);
              SparseDoubleVector B = new SparseDoubleVector(size, 1);
              A.set(0, 1);
              B.set(0, 1);
              double expect = INSTANCE.getHomogeneityBound();
              double actual = test(A, B);
      
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testCardinalityOneVectors() throws Exception {
              System.out.println("testCardinalityOneVectors");
              SparseDoubleVector A = new SparseDoubleVector(1, 1);
              SparseDoubleVector B = new SparseDoubleVector(1, 1);
              A.set(0, 1);
              B.set(0, 1);
              double expect = 1;
              double actual = test(A, B);
      
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testSizeTwoVectors() throws Exception {
              System.out.println("testSizeTwoVectors");
              int size = 100;
              SparseDoubleVector A = new SparseDoubleVector(size, 2);
              SparseDoubleVector B = new SparseDoubleVector(size, 2);
              A.set(0, 1);
              A.set(1, 1);
              B.set(0, 1);
              B.set(1, 1);
              double expect = INSTANCE.getHomogeneityBound();
              double actual = test(A, B);
      
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testCommutative() throws Exception {
              System.out.println("testCommutative");
              int size = 100;
              SparseDoubleVector A = new SparseDoubleVector(size, size);
              SparseDoubleVector B = new SparseDoubleVector(size, size);
              for (int i = 0; i < size; i++) {
                  A.set(i, RANDOM.nextDouble());
                  B.set(i, RANDOM.nextDouble());
              }
      
              double expect = test(A, B);
              double actual = test(B, A);
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testHomoginiety() throws Exception {
              System.out.println("testHomoginiety");
              int size = 100;
              SparseDoubleVector A = new SparseDoubleVector(size, size);
              SparseDoubleVector B = new SparseDoubleVector(size, size);
              for (int i = 0; i < size; i++) {
                  double value = RANDOM.nextDouble();
                  A.set(i, value);
                  B.set(i, value);
              }
      
              double expect = INSTANCE.getHomogeneityBound();
              double actual = test(A, B);
      
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testHeteroginiety() throws Exception {
              System.out.println("testHeteroginiety");
              int size = 100;
              SparseDoubleVector A = new SparseDoubleVector(size, size);
              SparseDoubleVector B = new SparseDoubleVector(size, size);
              for (int i = 0; i < size / 2; i++) {
                  A.set(i * 2, i);
                  B.set(i * 2 + 1, i);
              }
      
              double expect = INSTANCE.getHeterogeneityBound();
              double actual = test(A, B);
      
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testFruitData() throws Exception {
              System.out.println("testFruitData");
              int limit = 5;
      
              List> vecs = TestConstants.loadFruitVectors();
      
              limit = Math.min(limit, vecs.size());
      
              final double[][] results = new double[limit][limit];
              for (int i = 0; i < limit; i++) {
                  for (int j = 0; j < limit; j++) {
                      SparseDoubleVector A = vecs.get(i).value();
                      SparseDoubleVector B = vecs.get(j).value();
                      results[i][j] = test(A, B);
                  }
              }
          }
      
          @Test
          public void testLargeCardinality() throws Exception {
              System.out.println("testLargeCardinality");
              final int size = 100;
              final SparseDoubleVector A = new SparseDoubleVector(
                      Integer.MAX_VALUE, size);
              final SparseDoubleVector B = new SparseDoubleVector(
                      Integer.MAX_VALUE, size);
              for (int i = 0; i < size; i++) {
                  A.set(RANDOM.nextInt(size * 2), RANDOM.nextDouble());
                  B.set(RANDOM.nextInt(size * 2), RANDOM.nextDouble());
              }
      =======
      
      /**
       * 
       * @author Hamish I A Morgan <hamish.morgan@sussex.ac.uk>
       */
      public class PrecisionTest extends AbstractMeasureTest {
      >>>>>>> 5f0ba9177b34449ea27dabdc17fd0793620c7d56
      
      	@Override
      	Class getMeasureClass() {
      Solution content
       */
      package uk.ac.susx.mlcl.byblo.measures.impl;
      
      
      /**
       * 
       * @author Hamish I A Morgan <hamish.morgan@sussex.ac.uk>
       */
      public class PrecisionTest extends AbstractMeasureTest {
      
      	@Override
      	Class getMeasureClass() {
      File
      PrecisionTest.java
      Developer's decision
      Version 2
      Kind of conflict
      Annotation
      Attribute
      Class signature
      Comment
      For statement
      Import
      Method declaration
      Method invocation
      Method signature
      Variable
      Chunk
      Conflicting content
       */
      package uk.ac.susx.mlcl.byblo.measures.impl;
      
      <<<<<<< HEAD
      import org.junit.BeforeClass;
      import org.junit.Test;
      import uk.ac.susx.mlcl.TestConstants;
      import uk.ac.susx.mlcl.byblo.Tools;
      import uk.ac.susx.mlcl.byblo.enumerators.DoubleEnumerating;
      import uk.ac.susx.mlcl.byblo.enumerators.DoubleEnumeratingDelegate;
      import uk.ac.susx.mlcl.byblo.io.BybloIO;
      import uk.ac.susx.mlcl.byblo.io.FastWeightedTokenPairVectorSource;
      import uk.ac.susx.mlcl.lib.collect.Indexed;
      import uk.ac.susx.mlcl.lib.collect.SparseDoubleVector;
      
      import java.io.Closeable;
      import java.io.File;
      import java.io.IOException;
      import java.util.ArrayList;
      import java.util.List;
      import java.util.Random;
      
      import static org.junit.Assert.*;
      import static uk.ac.susx.mlcl.TestConstants.*;
      import static uk.ac.susx.mlcl.lib.test.ExitTrapper.disableExitTrapping;
      import static uk.ac.susx.mlcl.lib.test.ExitTrapper.enableExistTrapping;
      
      /**
       * @author Hamish I A Morgan <hamish.morgan@sussex.ac.uk>
       */
      public class RecallTest {
      
          static Recall INSTANCE;
      
          static final double EPSILON = 0;
      
          static Random RANDOM;
      
          @BeforeClass
          public static void setUpClass() throws Exception {
              INSTANCE = new Recall();
              RANDOM = new Random(1234);
          }
      
          @Test
          public void testCLI() throws Exception {
              System.out.println("testCLI");
      
              File output = new File(TEST_OUTPUT_DIR, FRUIT_NAME + ".Recall");
              deleteIfExist(output);
      
              try {
                  enableExistTrapping();
                  Tools.main(new String[]{
                          "allpairs",
                          "--charset", "UTF-8",
                          "--measure", "recall",
                          "--input", TEST_FRUIT_EVENTS.toString(),
                          "--input-features", TEST_FRUIT_FEATURES.toString(),
                          "--input-entries", TEST_FRUIT_ENTRIES.toString(),
                          "--output", output.toString()
                  });
              } finally {
                  disableExitTrapping();
              }
      
      
              assertTrue("Output file " + output + " does not exist.", output.exists());
              assertTrue("Output file " + output + " is empty.", output.length() > 0);
          }
      
          @Test
          public void testBothEmptyVectors() throws Exception {
              System.out.println("testBothEmptyVectors");
              int size = 100;
              SparseDoubleVector A = new SparseDoubleVector(size, 0);
              SparseDoubleVector B = new SparseDoubleVector(size, 0);
              double expect = 0;
              double actual = test(A, B);
      
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testOneEmptyVector() throws Exception {
              System.out.println("testOneEmptyVector");
              int size = 100;
              SparseDoubleVector A = new SparseDoubleVector(size, 0);
              SparseDoubleVector B = new SparseDoubleVector(size, size);
              for (int i = 0; i < size; i++)
                  B.set(i, RANDOM.nextDouble());
      
              double expect = 0;
              double actual = test(A, B);
      
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testSizeOneVectors() throws Exception {
              System.out.println("testSizeOneVectors");
              int size = 100;
              SparseDoubleVector A = new SparseDoubleVector(size, 1);
              SparseDoubleVector B = new SparseDoubleVector(size, 1);
              A.set(0, 1);
              B.set(0, 1);
              double expect = INSTANCE.getHomogeneityBound();
              double actual = test(A, B);
      
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testCardinalityOneVectors() throws Exception {
              System.out.println("testCardinalityOneVectors");
              SparseDoubleVector A = new SparseDoubleVector(1, 1);
              SparseDoubleVector B = new SparseDoubleVector(1, 1);
              A.set(0, 1);
              B.set(0, 1);
              double expect = 1;
              double actual = test(A, B);
      
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testSizeTwoVectors() throws Exception {
              System.out.println("testSizeTwoVectors");
              int size = 100;
              SparseDoubleVector A = new SparseDoubleVector(size, 2);
              SparseDoubleVector B = new SparseDoubleVector(size, 2);
              A.set(0, 1);
              A.set(1, 1);
              B.set(0, 1);
              B.set(1, 1);
              double expect = INSTANCE.getHomogeneityBound();
              double actual = test(A, B);
      
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testCommutative() throws Exception {
              System.out.println("testCommutative");
              int size = 100;
              SparseDoubleVector A = new SparseDoubleVector(size, size);
              SparseDoubleVector B = new SparseDoubleVector(size, size);
              for (int i = 0; i < size; i++) {
                  A.set(i, RANDOM.nextDouble());
                  B.set(i, RANDOM.nextDouble());
              }
      
              double expect = test(A, B);
              double actual = test(B, A);
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testHomoginiety() throws Exception {
              System.out.println("testHomoginiety");
              int size = 100;
              SparseDoubleVector A = new SparseDoubleVector(size, size);
              SparseDoubleVector B = new SparseDoubleVector(size, size);
              for (int i = 0; i < size; i++) {
                  double value = RANDOM.nextDouble();
                  A.set(i, value);
                  B.set(i, value);
              }
      
              double expect = INSTANCE.getHomogeneityBound();
              double actual = test(A, B);
      
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testHeteroginiety() throws Exception {
              System.out.println("testHeteroginiety");
              int size = 100;
              SparseDoubleVector A = new SparseDoubleVector(size, size);
              SparseDoubleVector B = new SparseDoubleVector(size, size);
              for (int i = 0; i < size / 2; i++) {
                  A.set(i * 2, i);
                  B.set(i * 2 + 1, i);
              }
      
              double expect = INSTANCE.getHeterogeneityBound();
              double actual = test(A, B);
      
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testFruitData() throws Exception {
              System.out.println("testFruitData");
              int limit = 5;
      
              List> vecs = TestConstants.loadFruitVectors();
      
              limit = Math.min(limit, vecs.size());
      
              final double[][] results = new double[limit][limit];
              for (int i = 0; i < limit; i++) {
                  for (int j = 0; j < limit; j++) {
                      SparseDoubleVector A = vecs.get(i).value();
                      SparseDoubleVector B = vecs.get(j).value();
                      results[i][j] = test(A, B);
                  }
              }
          }
      =======
      
      /**
       * 
       * @author Hamish I A Morgan <hamish.morgan@sussex.ac.uk>
       */
      public class RecallTest extends AbstractMeasureTest {
      >>>>>>> 5f0ba9177b34449ea27dabdc17fd0793620c7d56
      
      	@Override
      	Class getMeasureClass() {
      Solution content
       */
      package uk.ac.susx.mlcl.byblo.measures.impl;
      
      
      /**
       * 
       * @author Hamish I A Morgan <hamish.morgan@sussex.ac.uk>
       */
      public class RecallTest extends AbstractMeasureTest {
      
      	@Override
      	Class getMeasureClass() {
      File
      RecallTest.java
      Developer's decision
      Version 2
      Kind of conflict
      Annotation
      Attribute
      Class signature
      Comment
      Import
      Method declaration
      Chunk
      Conflicting content
      		return "recall";
      	}
      
      <<<<<<< HEAD
          public double test(SparseDoubleVector A, SparseDoubleVector B) {
              final double val = INSTANCE.similarity(A, B);
              assertFalse("Similarity is NaN", Double.isNaN(val));
              assertFalse("Similarity is " + val, Double.isInfinite(val));
              assertTrue("Similarity < -1", val >= INSTANCE.getHeterogeneityBound());
              assertTrue("Similarity > +1", val <= INSTANCE.getHomogeneityBound());
              return val;
          }
      
          static List> loadFruitVectors() throws IOException {
      
              final DoubleEnumerating indexDelegate = new DoubleEnumeratingDelegate();
              final FastWeightedTokenPairVectorSource eventSrc =
                      BybloIO.openEventsVectorSource(
                              TEST_FRUIT_EVENTS, DEFAULT_CHARSET, indexDelegate);
              final List> vecs =
                      new ArrayList>();
              while (eventSrc.hasNext())
                  vecs.add(eventSrc.read());
      
              if (eventSrc instanceof Closeable) {
                  ((Closeable) eventSrc).close();
              }
      
              return vecs;
          }
      =======
      >>>>>>> 5f0ba9177b34449ea27dabdc17fd0793620c7d56
      }
      Solution content
      		return "recall";
      	}
      
      }
      File
      RecallTest.java
      Developer's decision
      Version 2
      Kind of conflict
      Method declaration
      Chunk
      Conflicting content
              double expect = 0;
       */
      package uk.ac.susx.mlcl.byblo.measures.impl;
      
      <<<<<<< HEAD
      import org.junit.BeforeClass;
      import org.junit.Test;
      import uk.ac.susx.mlcl.TestConstants;
      import uk.ac.susx.mlcl.byblo.Tools;
      import uk.ac.susx.mlcl.byblo.enumerators.DoubleEnumerating;
      import uk.ac.susx.mlcl.byblo.enumerators.DoubleEnumeratingDelegate;
      import uk.ac.susx.mlcl.byblo.io.BybloIO;
      import uk.ac.susx.mlcl.byblo.io.FastWeightedTokenPairVectorSource;
      import uk.ac.susx.mlcl.lib.collect.Indexed;
      import uk.ac.susx.mlcl.lib.collect.SparseDoubleVector;
      
      import java.io.Closeable;
      import java.io.File;
      import java.io.IOException;
      import java.util.ArrayList;
      import java.util.List;
      import java.util.Random;
      
      import static org.junit.Assert.*;
      import static uk.ac.susx.mlcl.TestConstants.*;
      import static uk.ac.susx.mlcl.lib.test.ExitTrapper.disableExitTrapping;
              int limit = 5;
      import static uk.ac.susx.mlcl.lib.test.ExitTrapper.enableExistTrapping;
      
      /**
       * @author Hamish I A Morgan <hamish.morgan@sussex.ac.uk>
       */
      public class WeedsTest {
      
          static Weeds INSTANCE;
      
          static final double EPSILON = 0;
      
          static Random RANDOM;
      
          @BeforeClass
          public static void setUpClass() throws Exception {
              INSTANCE = new Weeds();
              RANDOM = new Random(1234);
          }
      
          @Test
          public void testCLI_000_100() throws Exception {
              testCLI(0, 1);
          }
      
          @Test
          public void testCLI_050_050() throws Exception {
              testCLI(0.5, 0.5);
          }
      
          @Test
          public void testCLI_100_000() throws Exception {
              testCLI(1, 0);
          }
      
          @Test
          public void testCLI_075_000() throws Exception {
              testCLI(0.75, 0);
          }
      
          @Test
          public void testCLI_050_000() throws Exception {
              testCLI(0.5, 0);
          }
      
          @Test
          public void testCLI_025_000() throws Exception {
              testCLI(0.25, 0);
          }
      
          @Test
          public void testCLI_000_000() throws Exception {
              testCLI(0, 0);
          }
      
          public void testCLI(double beta, double gamma) throws Exception {
              System.out.println(String.format("testCLI(beta=%.2f, gamma=%.2f)",
                      beta, gamma));
      
              File output = new File(TEST_OUTPUT_DIR, FRUIT_NAME
                      + String.format(".Weeds-beta%03d-gamma%03d",
                      (int) (100 * beta), (int) (100 * gamma)));
              deleteIfExist(output);
      
              try {
                  enableExistTrapping();
                  Tools.main(new String[]{
                          "allpairs",
                          "--charset", "UTF-8",
                          "--measure", "Weeds",
                          "--crmi-beta", Double.toHexString(beta),
                          "--crmi-gamma", Double.toHexString(gamma),
                          "--input", TEST_FRUIT_EVENTS.toString(),
                          "--input-features", TEST_FRUIT_FEATURES.toString(),
                          "--input-entries", TEST_FRUIT_ENTRIES.toString(),
                          "--output", output.toString()
                  });
              } finally {
                  disableExitTrapping();
              }
      
      
              assertTrue("Output file " + output + " does not exist.", output.exists());
              assertTrue("Output file " + output + " is empty.", output.length() > 0);
          }
      
          @Test
          public void testBothEmptyVectors() throws Exception {
              System.out.println("testBothEmptyVectors");
              int size = 100;
              SparseDoubleVector A = new SparseDoubleVector(size, 0);
              SparseDoubleVector B = new SparseDoubleVector(size, 0);
              double expect = 0;
              double actual = test(A, B);
      
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testOneEmptyVector() throws Exception {
              System.out.println("testOneEmptyVector");
              int size = 100;
              SparseDoubleVector A = new SparseDoubleVector(size, 0);
              SparseDoubleVector B = new SparseDoubleVector(size, size);
              for (int i = 0; i < size; i++)
                  B.set(i, RANDOM.nextDouble());
      
              double actual = test(A, B);
      
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testSizeOneVectors() throws Exception {
              System.out.println("testSizeOneVectors");
              int size = 100;
              SparseDoubleVector A = new SparseDoubleVector(size, 1);
              SparseDoubleVector B = new SparseDoubleVector(size, 1);
              A.set(0, 1);
              B.set(0, 1);
              double expect = INSTANCE.getHomogeneityBound();
              double actual = test(A, B);
      
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testCardinalityOneVectors() throws Exception {
              System.out.println("testCardinalityOneVectors");
              SparseDoubleVector A = new SparseDoubleVector(1, 1);
              SparseDoubleVector B = new SparseDoubleVector(1, 1);
              A.set(0, 1);
              B.set(0, 1);
              double expect = 1;
              double actual = test(A, B);
      
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testSizeTwoVectors() throws Exception {
              System.out.println("testSizeTwoVectors");
              int size = 100;
              SparseDoubleVector A = new SparseDoubleVector(size, 2);
              SparseDoubleVector B = new SparseDoubleVector(size, 2);
              A.set(0, 1);
              A.set(1, 1);
              B.set(0, 1);
              B.set(1, 1);
              double expect = INSTANCE.getHomogeneityBound();
              double actual = test(A, B);
      
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testCommutative() throws Exception {
              System.out.println("testCommutative");
              int size = 100;
              SparseDoubleVector A = new SparseDoubleVector(size, size);
              SparseDoubleVector B = new SparseDoubleVector(size, size);
      
              for (int i = 0; i < size; i++) {
                  A.set(i, RANDOM.nextDouble());
                  B.set(i, RANDOM.nextDouble());
              }
      
              double expect = test(A, B);
              double actual = test(B, A);
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testHomoginiety() throws Exception {
              System.out.println("testHomoginiety");
              int size = 100;
              SparseDoubleVector A = new SparseDoubleVector(size, size);
              SparseDoubleVector B = new SparseDoubleVector(size, size);
              for (int i = 0; i < size; i++) {
                  double value = RANDOM.nextDouble();
                  A.set(i, value);
                  B.set(i, value);
              }
      
              double expect = INSTANCE.getHomogeneityBound();
              double actual = test(A, B);
      
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testHeteroginiety() throws Exception {
              System.out.println("testHeteroginiety");
              int size = 100;
              SparseDoubleVector A = new SparseDoubleVector(size, size);
              SparseDoubleVector B = new SparseDoubleVector(size, size);
              for (int i = 0; i < size / 2; i++) {
                  A.set(i * 2, i);
                  B.set(i * 2 + 1, i);
              }
      
              double expect = INSTANCE.getHeterogeneityBound();
              double actual = test(A, B);
      
              assertEquals(expect, actual, EPSILON);
          }
      
          @Test
          public void testFruitData() throws Exception {
              System.out.println("testFruitData");
      
              List> vecs = TestConstants.loadFruitVectors();
      
              limit = Math.min(limit, vecs.size());
      
              final double[][] results = new double[limit][limit];
              for (int i = 0; i < limit; i++) {
                  for (int j = 0; j < limit; j++) {
                      SparseDoubleVector A = vecs.get(i).value();
                      SparseDoubleVector B = vecs.get(j).value();
                      results[i][j] = test(A, B);
                  }
              }
      
              // diagonals should all be +1
              for (int i = 0; i < limit; i++) {
                  assertEquals(INSTANCE.getHomogeneityBound(), results[i][i], EPSILON);
              }
              // triangular mirrors should be equal
              for (int i = 0; i < limit; i++) {
                  for (int j = 0; j < limit; j++) {
                      assertEquals(results[i][j], results[j][i], EPSILON);
                  }
              }
          }
      
          @Test
          public void testLargeCardinality() throws Exception {
              System.out.println("testLargeCardinality");
              final int size = 100;
              final SparseDoubleVector A = new SparseDoubleVector(
                      Integer.MAX_VALUE, size);
              final SparseDoubleVector B = new SparseDoubleVector(
                      Integer.MAX_VALUE, size);
              for (int i = 0; i < size; i++) {
                  A.set(RANDOM.nextInt(size * 2), RANDOM.nextDouble());
                  B.set(RANDOM.nextInt(size * 2), RANDOM.nextDouble());
              }
      
              test(A, B);
          }
      
          public double test(SparseDoubleVector A, SparseDoubleVector B) {
              final double val = INSTANCE.similarity(A, B);
              assertFalse("Similarity is NaN", Double.isNaN(val));
              assertFalse("Similarity is " + val, Double.isInfinite(val));
              assertTrue("Similarity < -1", val >= INSTANCE.getHeterogeneityBound());
              assertTrue("Similarity > +1", val <= INSTANCE.getHomogeneityBound());
              return val;
          }
      
          static List> loadFruitVectors() throws IOException {
      
              final DoubleEnumerating indexDelegate = new DoubleEnumeratingDelegate();
              final FastWeightedTokenPairVectorSource eventSrc =
                      BybloIO.openEventsVectorSource(
                              TEST_FRUIT_EVENTS, DEFAULT_CHARSET, indexDelegate);
              final List> vecs =
                      new ArrayList>();
              while (eventSrc.hasNext())
                  vecs.add(eventSrc.read());
      
              if (eventSrc instanceof Closeable) {
                  ((Closeable) eventSrc).close();
              }
      
              return vecs;
          }
      =======
      import org.junit.Test;
      
      /**
       * 
       * @author Hamish I A Morgan <hamish.morgan@sussex.ac.uk>
       */
      public class WeedsTest extends AbstractMeasureTest {
      
      	@Override
      	Class getMeasureClass() {
      		return Weeds.class;
      	}
      
      	@Override
      	String getMeasureName() {
      		return "weeds";
      	}
      
      	@Test
      	public void testCLI_000_100() throws Exception {
      		testCLI(0, 1);
      	}
      
      	@Test
      	public void testCLI_050_050() throws Exception {
      		testCLI(0.5, 0.5);
      	}
      
      	@Test
      	public void testCLI_100_000() throws Exception {
      		testCLI(1, 0);
      	}
      
      	@Test
      	public void testCLI_075_000() throws Exception {
      		testCLI(0.75, 0);
      	}
      
      	@Test
      	public void testCLI_050_000() throws Exception {
      		testCLI(0.5, 0);
      	}
      
      	@Test
      	public void testCLI_025_000() throws Exception {
      		testCLI(0.25, 0);
      	}
      
      	@Test
      	public void testCLI_000_000() throws Exception {
      		testCLI(0, 0);
      	}
      
      	public void testCLI(double beta, double gamma) throws Exception {
      		System.out.println(String.format("testCLI(beta=%.2f, gamma=%.2f)",
      				beta, gamma));
      
      		runFromCommandLine("--crmi-beta", Double.toHexString(beta),
      				"--crmi-gamma", Double.toHexString(gamma));
      	}
      
      >>>>>>> 5f0ba9177b34449ea27dabdc17fd0793620c7d56
      }
      Solution content
       */
      package uk.ac.susx.mlcl.byblo.measures.impl;
      
      import org.junit.Test;
      
      /**
       * 
       * @author Hamish I A Morgan <hamish.morgan@sussex.ac.uk>
       */
      public class WeedsTest extends AbstractMeasureTest {
      
      	@Override
      	Class getMeasureClass() {
      		return Weeds.class;
      	}
      
      	@Override
      	String getMeasureName() {
      		return "weeds";
      	}
      
      	@Test
      	public void testCLI_000_100() throws Exception {
      		testCLI(0, 1);
      	}
      
      	@Test
      	public void testCLI_050_050() throws Exception {
      		testCLI(0.5, 0.5);
      	}
      
      	@Test
      	public void testCLI_100_000() throws Exception {
      		testCLI(1, 0);
      	}
      
      	@Test
      	public void testCLI_075_000() throws Exception {
      		testCLI(0.75, 0);
      	}
      
      	@Test
      	public void testCLI_050_000() throws Exception {
      		testCLI(0.5, 0);
      	}
      
      	@Test
      	public void testCLI_025_000() throws Exception {
      		testCLI(0.25, 0);
      	}
      
      	@Test
      	public void testCLI_000_000() throws Exception {
      		testCLI(0, 0);
      	}
      
      	public void testCLI(double beta, double gamma) throws Exception {
      		System.out.println(String.format("testCLI(beta=%.2f, gamma=%.2f)",
      				beta, gamma));
      
      		runFromCommandLine("--crmi-beta", Double.toHexString(beta),
      				"--crmi-gamma", Double.toHexString(gamma));
      	}
      
      }
      File
      WeedsTest.java
      Developer's decision
      Version 2
      Kind of conflict
      Annotation
      Attribute
      Class signature
      Comment
      Import
      Method declaration