Environment for
DeveLoping
KDD-Applications
Supported by Index-Structures

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

java.lang.Object
  extended by de.lmu.ifi.dbs.elki.logging.AbstractLoggable
      extended by de.lmu.ifi.dbs.elki.utilities.optionhandling.AbstractParameterizable
          extended by de.lmu.ifi.dbs.elki.parser.AbstractParser<ExternalObject>
              extended by de.lmu.ifi.dbs.elki.parser.NumberDistanceParser<D>
All Implemented Interfaces:
Loggable, DistanceParser<ExternalObject,D>, Parser<ExternalObject>, Parameterizable

public class NumberDistanceParser<D extends NumberDistance<D>>
extends AbstractParser<ExternalObject>
implements DistanceParser<ExternalObject,D>

Provides a parser for parsing one distance value per line.

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

Author:
Elke Achtert

Field Summary
static String DISTANCE_FUNCTION_D
          Description for parameter distance function.
static String DISTANCE_FUNCTION_P
          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.utilities.optionhandling.AbstractParameterizable
optionHandler
 
Fields inherited from class de.lmu.ifi.dbs.elki.logging.AbstractLoggable
debug
 
Constructor Summary
NumberDistanceParser()
          Provides a parser for parsing one double distance per line.
 
Method Summary
 boolean containsKey(Integer id1, Integer id2, Map<Integer,Map<Integer,D>> cache)
          Returns true if the specified distance cache contains a distance value for the specified ids.
 String description()
          Returns a description of the class and the required parameters.
 List<AttributeSettings> getAttributeSettings()
          Returns the parameter setting of the attributes.
 DistanceFunction<ExternalObject,D> getDistanceFunction()
          Returns the distance function of this parser.
 ParsingResult<ExternalObject> 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<Integer,Map<Integer,D>> cache)
          Puts the specified distance value for the given ids to the distance cache.
 String[] setParameters(String[] args)
          Sets the attributes of the class accordingly to the given parameters.
 
Methods inherited from class de.lmu.ifi.dbs.elki.parser.AbstractParser
toString, usage
 
Methods inherited from class de.lmu.ifi.dbs.elki.utilities.optionhandling.AbstractParameterizable
addOption, checkGlobalParameterConstraints, deleteOption, description, description, getParameters, getParameterValue, getPossibleOptions, inlineDescription, isSet, setParameters
 
Methods inherited from class de.lmu.ifi.dbs.elki.logging.AbstractLoggable
debugFine, debugFiner, debugFinest, exception, message, progress, progress, progress, verbose, verbose, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface de.lmu.ifi.dbs.elki.utilities.optionhandling.Parameterizable
checkGlobalParameterConstraints, getParameters, getPossibleOptions, inlineDescription
 

Field Detail

DISTANCE_FUNCTION_P

public static final String DISTANCE_FUNCTION_P
Parameter for distance function.

See Also:
Constant Field Values

DISTANCE_FUNCTION_D

public static final String DISTANCE_FUNCTION_D
Description for parameter distance function.


distanceFunction

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

Constructor Detail

NumberDistanceParser

public NumberDistanceParser()
Provides a parser for parsing one double distance per line. A line must have the follwing format: id1 id2 distanceValue, where id1 and is2 are integers representing the two ids belonging to the distance value, the distance value is a double value. Lines starting with "#" will be ignored.

Method Detail

parse

public ParsingResult<ExternalObject> parse(InputStream in)
Description copied from interface: Parser
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 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.
See Also:
Parser.parse(java.io.InputStream)

getDistanceFunction

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

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

description

public String description()
Description copied from interface: Parameterizable
Returns a description of the class and the required parameters.

This description should be suitable for a usage description as for a standalone application.

Specified by:
description in interface Parameterizable
Overrides:
description in class AbstractParameterizable
Returns:
String a description of the class and the required parameters
See Also:
Parameterizable.description()

setParameters

public String[] setParameters(String[] args)
                       throws ParameterException
Description copied from interface: Parameterizable
Sets the attributes of the class accordingly to the given parameters. Returns a new String array containing those entries of the given array that are neither expected nor used by this Parameterizable.

Specified by:
setParameters in interface Parameterizable
Overrides:
setParameters in class AbstractParameterizable
Parameters:
args - parameters to set the attributes accordingly to
Returns:
String[] an array containing the unused parameters
Throws:
ParameterException - in case of wrong parameter-setting
See Also:
Parameterizable.setParameters(java.lang.String[])

getAttributeSettings

public List<AttributeSettings> getAttributeSettings()
Returns the parameter setting of the attributes.

Specified by:
getAttributeSettings in interface Parameterizable
Overrides:
getAttributeSettings in class AbstractParameterizable
Returns:
the parameter setting of the attributes
See Also:
Parameterizable.getAttributeSettings()

put

private void put(Integer id1,
                 Integer id2,
                 D distance,
                 Map<Integer,Map<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<Integer,Map<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.1 (2008-07-10_1838)