com.aliasi.util.Distance Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of aliasi-lingpipe Show documentation
Show all versions of aliasi-lingpipe Show documentation
This is the original Lingpipe:
http://alias-i.com/lingpipe/web/download.html
There were not made any changes to the source code.
/*
* LingPipe v. 4.1.0
* Copyright (C) 2003-2011 Alias-i
*
* This program is licensed under the Alias-i Royalty Free License
* Version 1 WITHOUT ANY WARRANTY, without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Alias-i
* Royalty Free License Version 1 for more details.
*
* You should have received a copy of the Alias-i Royalty Free License
* Version 1 along with this program; if not, visit
* http://alias-i.com/lingpipe/licenses/lingpipe-license-1.txt or contact
* Alias-i, Inc. at 181 North 11th Street, Suite 401, Brooklyn, NY 11211,
* +1 (718) 290-9170.
*/
package com.aliasi.util;
/**
* The Distance
interface provides a general method for
* defining distances between two objects. Distance is a kind of
* dissimilarity measure, because the larger the distance between two
* objects, the less similar they are. The distance interface
* provides a single method {@link #distance(Object,Object)} returning
* the distance between objects.
*
* A proper distance is said to form a metric if it satisfies the
* following four properties:
*
*
* - Positive:
distance(x,y) >= 0
* - Self Distance Zero:
distance(x,x) = 0
* - Symmetric:
distance(x,y) = distance(y,x)
* - Triangle Inequaltiy:
distance(x,y) + distance(y,z) >= distance(x,z)
*
*
* For example, the Euclidean distance between vectors is
* a proper metric.
*
*
* distance(x,y) = sqrt(Σi (x[i] * y[i])2)
*
* as is the Manhattan metric, or taxicab distance:
*
*
* distance(x,y) = Σi abs(x[i] - y[i])
*
* Cosine is also popular for vectors:
*
*
* distance(x,y) = dotProduct(x,y) / (length(x) * length(y))
*
* A good introduction to distance may be found at:
*
*
*
* @author Bob Carpenter
* @version 3.0
* @since LingPipe3.0
* @param the type of objects over which distances are defined
*/
public interface Distance {
/**
* Returns the distance between the specified pair of objects.
*
* @param e1 First object.
* @param e2 Second object.
* @return Distance between the two objects.
*/
public double distance(E e1, E e2);
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy