Environment for
DeveLoping
KDD-Applications
Supported by Index-Structures

de.lmu.ifi.dbs.elki.parser
Class NumberDistanceParser<D extends NumberDistance<D,N>,N extends Number>

java.lang.Object
  extended by de.lmu.ifi.dbs.elki.logging.AbstractLoggable
      extended by de.lmu.ifi.dbs.elki.parser.AbstractParser<ExternalObject>
          extended by de.lmu.ifi.dbs.elki.parser.NumberDistanceParser<D,N>
Type Parameters:
D - distance type
N - number type
All Implemented Interfaces:
DistanceParser<ExternalObject,D>, Parser<ExternalObject>, Parameterizable

@Title(value="Number Distance Parser")
@Description(value="Parser for the following line format:\nid1 id2 distanceValue, where id1 and is2 are integers representing the two ids belonging to the distance value.\n The ids and the distance value are separated by whitespace. Empty lines and lines beginning with \"#\" will be ignored.")
public class NumberDistanceParser<D extends NumberDistance<D,N>,N extends Number>
extends AbstractParser<ExternalObject>
implements DistanceParser<ExternalObject,D>, Parameterizable

Provides a parser for parsing one distance value per line.

A line must have the following format: id1 id2 distanceValue, where id1 and id2 are integers representing the two ids belonging to the distance value. Lines starting with "#" will be ignored.

Author:
Elke Achtert

Field Summary
static OptionID DISTANCE_FUNCTION_ID
          OptionID for DISTANCE_FUNCTION_PARAM
private  ObjectParameter<DistanceFunction<ExternalObject,D>> DISTANCE_FUNCTION_PARAM
          Parameter for distance function.
private  DistanceFunction<ExternalObject,D> distanceFunction
          The distance function.
 
Fields inherited from class de.lmu.ifi.dbs.elki.parser.AbstractParser
ATTRIBUTE_CONCATENATION, COMMENT, WHITESPACE_PATTERN
 
Fields inherited from class de.lmu.ifi.dbs.elki.logging.AbstractLoggable
debug, logger
 
Constructor Summary
NumberDistanceParser(Parameterization config)
          Constructor, adhering to Parameterizable
 
Method Summary
 boolean containsKey(Integer id1, Integer id2, Map<Pair<Integer,Integer>,D> cache)
          Returns true if the specified distance cache contains a distance value for the specified ids.
 DistanceFunction<ExternalObject,D> getDistanceFunction()
          Returns the distance function of this parser.
 DistanceParsingResult<ExternalObject,D> parse(InputStream in)
          Returns a list of the objects parsed from the specified input stream and a list of the labels associated with the objects.
private  void put(Integer id1, Integer id2, D distance, Map<Pair<Integer,Integer>,D> cache)
          Puts the specified distance value for the given ids to the distance cache.
 
Methods inherited from class de.lmu.ifi.dbs.elki.parser.AbstractParser
toString
 
Methods inherited from class de.lmu.ifi.dbs.elki.logging.AbstractLoggable
debugFine, debugFiner, debugFinest, exception, progress, verbose, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DISTANCE_FUNCTION_ID

public static final OptionID DISTANCE_FUNCTION_ID
OptionID for DISTANCE_FUNCTION_PARAM


DISTANCE_FUNCTION_PARAM

private ObjectParameter<DistanceFunction<ExternalObject,D extends NumberDistance<D,N>>> DISTANCE_FUNCTION_PARAM
Parameter for distance function.


distanceFunction

private DistanceFunction<ExternalObject,D extends NumberDistance<D,N>> distanceFunction
The distance function.

Constructor Detail

NumberDistanceParser

public NumberDistanceParser(Parameterization config)
Constructor, adhering to Parameterizable

Parameters:
config - Parameterization
Method Detail

parse

public DistanceParsingResult<ExternalObject,D> parse(InputStream in)
Description copied from interface: DistanceParser
Returns a list of the objects parsed from the specified input stream and a list of the labels associated with the objects.

Specified by:
parse in interface DistanceParser<ExternalObject,D extends NumberDistance<D,N>>
Specified by:
parse in interface Parser<ExternalObject>
Parameters:
in - the stream to parse objects from
Returns:
a list containing those objects parsed from the input stream and their associated labels.

getDistanceFunction

public DistanceFunction<ExternalObject,D> getDistanceFunction()
Returns the distance function of this parser.

Specified by:
getDistanceFunction in interface DistanceParser<ExternalObject,D extends NumberDistance<D,N>>
Returns:
the distance function of this parser

put

private void put(Integer id1,
                 Integer id2,
                 D distance,
                 Map<Pair<Integer,Integer>,D> cache)
Puts the specified distance value for the given ids to the distance cache.

Parameters:
id1 - the first id
id2 - the second id
distance - the distance value
cache - the distance cache

containsKey

public boolean containsKey(Integer id1,
                           Integer id2,
                           Map<Pair<Integer,Integer>,D> cache)
Returns true if the specified distance cache contains a distance value for the specified ids.

Parameters:
id1 - the first id
id2 - the second id
cache - the distance cache
Returns:
true if this cache contains a distance value for the specified ids, false otherwise

Release 0.3 (2010-03-31_1612)