public DFRSimilarityProvider(String name, Settings settings, Settings indexSettings) { super(name); BasicModel basicModel = parseBasicModel(settings); AfterEffect afterEffect = parseAfterEffect(settings); Normalization normalization = parseNormalization(settings); this.similarity = new DFRSimilarity(basicModel, afterEffect, normalization); }
/** * Parses the given Settings and creates the appropriate {@link AfterEffect} * * @param settings Settings to parse * @return {@link AfterEffect} referred to in the Settings */ protected AfterEffect parseAfterEffect(Settings settings) { String afterEffect = settings.get("after_effect"); AfterEffect effect = AFTER_EFFECTS.get(afterEffect); if (effect == null) { throw new IllegalArgumentException("Unsupported AfterEffect [" + afterEffect + "]"); } return effect; }
private AfterEffect parseAfterEffect(String expr) { if ("B".equals(expr)) { return new AfterEffectB(); } else if ("L".equals(expr)) { return new AfterEffectL(); } else if ("none".equals(expr)) { return new AfterEffect.NoAfterEffect(); } else { throw new RuntimeException("Invalid afterEffect: " + expr); } }