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 Distribution} * * @param settings Settings to parse * @return {@link Normalization} referred to in the Settings */ protected Distribution parseDistribution(Settings settings) { String rawDistribution = settings.get("distribution"); Distribution distribution = DISTRIBUTIONS.get(rawDistribution); if (distribution == null) { throw new IllegalArgumentException("Unsupported Distribution [" + rawDistribution + "]"); } return distribution; }
private Distribution parseDistribution(String expr) { if ("LL".equals(expr)) { return new DistributionLL(); } else if ("SPL".equals(expr)) { return new DistributionSPL(); } else { throw new RuntimeException("Invalid distribution: " + expr); } }