public IBSimilarityProvider(String name, Settings settings, Settings indexSettings) { super(name); Distribution distribution = parseDistribution(settings); Lambda lambda = parseLambda(settings); Normalization normalization = parseNormalization(settings); this.similarity = new IBSimilarity(distribution, lambda, normalization); }
/** * Parses the given Settings and creates the appropriate {@link Lambda} * * @param settings Settings to parse * @return {@link Normalization} referred to in the Settings */ protected Lambda parseLambda(Settings settings) { String rawLambda = settings.get("lambda"); Lambda lambda = LAMBDAS.get(rawLambda); if (lambda == null) { throw new IllegalArgumentException("Unsupported Lambda [" + rawLambda + "]"); } return lambda; }
private Lambda parseLambda(String expr) { if ("DF".equals(expr)) { return new LambdaDF(); } else if ("TTF".equals(expr)) { return new LambdaTTF(); } else { throw new RuntimeException("Invalid lambda: " + expr); } }