D
- distance typeN
- number type@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 implements DistanceParser<D>
Modifier and Type | Class and Description |
---|---|
static class |
NumberDistanceParser.Parameterizer<D extends NumberDistance<D,N>,N extends Number>
Parameterization class.
|
Modifier and Type | Field and Description |
---|---|
static OptionID |
DISTANCE_FUNCTION_ID
Parameter for distance function.
|
private DistanceFunction<?,D> |
distanceFunction
The distance function.
|
private static Logging |
logger
The logger for this class.
|
ATTRIBUTE_CONCATENATION, COLUMN_SEPARATOR_ID, COMMENT, NUMBER_PATTERN, QUOTE_CHAR, QUOTE_ID, quoteChar, WHITESPACE_PATTERN
Constructor and Description |
---|
NumberDistanceParser(Pattern colSep,
char quoteChar,
DistanceFunction<?,D> distanceFunction)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
containsKey(DBID id1,
DBID id2,
Map<DBIDPair,D> cache)
Returns true if the specified distance cache contains a distance
value for the specified ids.
|
protected Logging |
getLogger()
Get the logger for this class.
|
DistanceParsingResult<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(DBID id1,
DBID id2,
D distance,
Map<DBIDPair,D> cache)
Puts the specified distance value for the given ids to the distance cache.
|
tokenize, toString
private static final Logging logger
public static final OptionID DISTANCE_FUNCTION_ID
private DistanceFunction<?,D extends NumberDistance<D,N>> distanceFunction
public NumberDistanceParser(Pattern colSep, char quoteChar, DistanceFunction<?,D> distanceFunction)
colSep
- quoteChar
- distanceFunction
- public DistanceParsingResult<D> parse(InputStream in)
DistanceParser
parse
in interface DistanceParser<D extends NumberDistance<D,N>>
in
- the stream to parse objects fromprivate void put(DBID id1, DBID id2, D distance, Map<DBIDPair,D> cache)
id1
- the first idid2
- the second iddistance
- the distance valuecache
- the distance cachepublic boolean containsKey(DBID id1, DBID id2, Map<DBIDPair,D> cache)
id1
- the first idid2
- the second idcache
- the distance cacheprotected Logging getLogger()
AbstractParser
getLogger
in class AbstractParser