Search in sources :

Example 21 with IndexingConfig

use of org.apache.stanbol.entityhub.indexing.core.config.IndexingConfig in project stanbol by apache.

the class SolrYardIndexingDestinationTest method testWithSolrConf.

@Test
public void testWithSolrConf() throws YardException, IOException {
    String testName = "withSolrConf";
    IndexingConfig config = new IndexingConfig(CONFIG_ROOT + File.separatorChar + testName, CONFIG_ROOT + '/' + testName) {
    };
    validateSolrDestination(config);
}
Also used : IndexingConfig(org.apache.stanbol.entityhub.indexing.core.config.IndexingConfig) Test(org.junit.Test)

Example 22 with IndexingConfig

use of org.apache.stanbol.entityhub.indexing.core.config.IndexingConfig in project stanbol by apache.

the class RdfIndexingSourceTest method testEntityDataIterable.

@Test
public void testEntityDataIterable() {
    log.info(" --- testEntityDataIterable ---");
    String testName = "iterable";
    IndexingConfig config = new IndexingConfig(CONFIG_ROOT + File.separatorChar + testName, CONFIG_ROOT + '/' + testName) {
    };
    EntityDataIterable iterable = config.getDataIterable();
    try {
        assertNotNull(iterable);
        assertEquals(iterable.getClass(), RdfIndexingSource.class);
        if (iterable.needsInitialisation()) {
            iterable.initialise();
        }
        EntityDataIterator it = iterable.entityDataIterator();
        long count = 0;
        while (it.hasNext()) {
            String entity = it.next();
            log.info("validate Entity " + entity);
            assertNotNull(entity);
            validateRepresentation(it.getRepresentation(), entity);
            count++;
        }
        //check if all entities where indexed
        //this checks if more entities are indexed as listed by the
        //textEntityIDs.txt file
        assertTrue(String.format("> %s Entities expected but only %s processed!", NUMBER_OF_ENTITIES_EXPECTED, count), NUMBER_OF_ENTITIES_EXPECTED <= count);
    } finally {
        //we need to ensure close is called as otherwise other tests might fail 
        iterable.close();
    }
}
Also used : IndexingConfig(org.apache.stanbol.entityhub.indexing.core.config.IndexingConfig) EntityDataIterable(org.apache.stanbol.entityhub.indexing.core.EntityDataIterable) EntityDataIterator(org.apache.stanbol.entityhub.indexing.core.EntityDataIterator) Test(org.junit.Test)

Example 23 with IndexingConfig

use of org.apache.stanbol.entityhub.indexing.core.config.IndexingConfig in project stanbol by apache.

the class ConfigTest method testEntityIdIteratorConfig.

@Test
public void testEntityIdIteratorConfig() {
    IndexingConfig config = new IndexingConfig();
    EntityIterator iterator = config.getEntityIdIterator();
    ScoreNormaliser normaliser = config.getNormaliser();
    if (iterator.needsInitialisation()) {
        iterator.initialise();
    }
    float lastScore = Float.MAX_VALUE;
    float lastNormalisedScore = 1f;
    while (iterator.hasNext()) {
        EntityScore entity = iterator.next();
        assertNotNull(entity);
        assertNotNull(entity.id);
        assertNotNull(entity.score);
        //log.info("Entity: {}",entity);
        assertTrue(entity.id.startsWith("http://dbpedia.org/resource/"));
        float score = entity.score.floatValue();
        assertTrue(score > 0);
        assertTrue(score <= lastScore);
        lastScore = score;
        Float normalisedScore = normaliser.normalise(entity.score);
        assertNotNull(normalisedScore);
        float nScore = normalisedScore.floatValue();
        assertTrue(nScore <= lastNormalisedScore);
        if (score < 2) {
            //the value of "min-score" in minincoming
            log.info("score=" + score + " nScore=" + nScore);
            assertTrue(nScore < 0);
            return;
        } else {
            assertTrue(nScore > 0);
        }
    }
}
Also used : ScoreNormaliser(org.apache.stanbol.entityhub.indexing.core.normaliser.ScoreNormaliser) EntityScore(org.apache.stanbol.entityhub.indexing.core.EntityIterator.EntityScore) IndexingConfig(org.apache.stanbol.entityhub.indexing.core.config.IndexingConfig) EntityIterator(org.apache.stanbol.entityhub.indexing.core.EntityIterator) Test(org.junit.Test)

Example 24 with IndexingConfig

use of org.apache.stanbol.entityhub.indexing.core.config.IndexingConfig in project stanbol by apache.

the class FieldValueFilter method setConfiguration.

@Override
public void setConfiguration(Map<String, Object> config) {
    log.info("> configure {}", getClass().getSimpleName());
    IndexingConfig indexingConfig = (IndexingConfig) config.get(IndexingConfig.KEY_INDEXING_CONFIG);
    nsPrefixProvider = indexingConfig.getNamespacePrefixService();
    Object value = config.get(PARAM_FIELD);
    if (value == null || value.toString().isEmpty()) {
        this.field = getUri(DEFAULT_FIELD);
    } else {
        this.field = getUri(value.toString());
    }
    log.info(" - field: {}", field);
    value = config.get(PARAM_VALUES);
    log.info(" - filters:");
    parseFilterConfig(value);
}
Also used : IndexingConfig(org.apache.stanbol.entityhub.indexing.core.config.IndexingConfig)

Example 25 with IndexingConfig

use of org.apache.stanbol.entityhub.indexing.core.config.IndexingConfig in project stanbol by apache.

the class EntityIneratorToScoreProviderAdapter method setConfiguration.

@Override
public void setConfiguration(Map<String, Object> config) {
    //the IndexingConfig is available via the IndexingConfig.KEY_INDEXING_CONFIG key!
    IndexingConfig indexingConfig = (IndexingConfig) config.get(IndexingConfig.KEY_INDEXING_CONFIG);
    //configure first the EntityIterator to adapt
    entityIterator = indexingConfig.getEntityIdIterator();
    if (entityIterator == null) {
        throw new IllegalArgumentException("No EntityIterator available via the indexing configuration " + indexingConfig.getName());
    }
}
Also used : IndexingConfig(org.apache.stanbol.entityhub.indexing.core.config.IndexingConfig)

Aggregations

IndexingConfig (org.apache.stanbol.entityhub.indexing.core.config.IndexingConfig)26 Test (org.junit.Test)15 File (java.io.File)8 EntityIterator (org.apache.stanbol.entityhub.indexing.core.EntityIterator)4 EntityScore (org.apache.stanbol.entityhub.indexing.core.EntityIterator.EntityScore)4 IOException (java.io.IOException)3 EntityDataIterable (org.apache.stanbol.entityhub.indexing.core.EntityDataIterable)3 EntityDataIterator (org.apache.stanbol.entityhub.indexing.core.EntityDataIterator)3 EntityDataProvider (org.apache.stanbol.entityhub.indexing.core.EntityDataProvider)3 ResourceLoader (org.apache.stanbol.entityhub.indexing.core.source.ResourceLoader)3 FileInputStream (java.io.FileInputStream)2 InputStream (java.io.InputStream)2 NamespacePrefixService (org.apache.stanbol.commons.namespaceprefix.NamespacePrefixService)2 ScoreNormaliser (org.apache.stanbol.entityhub.indexing.core.normaliser.ScoreNormaliser)2 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 IndexerImpl (org.apache.stanbol.entityhub.indexing.core.impl.IndexerImpl)1 EntityIneratorToScoreProviderAdapter (org.apache.stanbol.entityhub.indexing.core.source.EntityIneratorToScoreProviderAdapter)1