Search in sources :

Example 1 with DefaultNormaliser

use of org.apache.stanbol.entityhub.indexing.core.normaliser.DefaultNormaliser in project stanbol by apache.

the class IndexingConfig method initNormaliser.

private void initNormaliser() {
    Object value = configuration.get(IndexingConstants.KEY_SCORE_NORMALIZER);
    if (value == null) {
        this.scoreNormaliser = new DefaultNormaliser();
    } else {
        ScoreNormaliser normaliser = null;
        ScoreNormaliser last = null;
        List<ConfigEntry> configs = parseConfigEntries(value.toString());
        for (int i = configs.size() - 1; i >= 0; i--) {
            last = normaliser;
            normaliser = null;
            ConfigEntry config = configs.get(i);
            try {
                normaliser = (ScoreNormaliser) Class.forName(config.getClassName()).newInstance();
            } catch (Exception e) {
                throw new IllegalArgumentException("Invalid Normaliser configuration '" + config.getConfigString() + "'!", e);
            }
            Map<String, Object> normaliserConfig = getComponentConfig(config, normaliser.getClass().getSimpleName(), config.getParams().containsKey(CONFIG_PARAM));
            //add also the directly provided parameters
            normaliserConfig.putAll(config.getParams());
            if (last != null) {
                normaliserConfig.put(ScoreNormaliser.CHAINED_SCORE_NORMALISER, last);
            }
            normaliser.setConfiguration(normaliserConfig);
        }
        //set the normaliser!
        this.scoreNormaliser = normaliser;
    }
}
Also used : ScoreNormaliser(org.apache.stanbol.entityhub.indexing.core.normaliser.ScoreNormaliser) DefaultNormaliser(org.apache.stanbol.entityhub.indexing.core.normaliser.DefaultNormaliser) UnsupportedEncodingException(java.io.UnsupportedEncodingException) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 DefaultNormaliser (org.apache.stanbol.entityhub.indexing.core.normaliser.DefaultNormaliser)1 ScoreNormaliser (org.apache.stanbol.entityhub.indexing.core.normaliser.ScoreNormaliser)1