Search in sources :

Example 6 with EntityScore

use of org.apache.stanbol.entityhub.indexing.core.EntityIterator.EntityScore in project stanbol by apache.

the class EntityIneratorToScoreProviderAdapter method initialise.

@Override
public void initialise() {
    //initialise the source entity iterator
    if (entityIterator.needsInitialisation()) {
        entityIterator.initialise();
    }
    //initialise this instace
    Map<String, Float> entityScoreMap = new HashMap<String, Float>();
    while (entityIterator.hasNext()) {
        EntityScore entityScore = entityIterator.next();
        entityScoreMap.put(entityScore.id, entityScore.score);
    }
    //close the source because it is no longer needed!
    entityIterator.close();
    provider = new MapEntityScoreProvider(entityScoreMap);
    //initialise the wrapped score provider
    if (provider.needsInitialisation()) {
        provider.initialise();
    }
}
Also used : EntityScore(org.apache.stanbol.entityhub.indexing.core.EntityIterator.EntityScore) HashMap(java.util.HashMap)

Aggregations

EntityScore (org.apache.stanbol.entityhub.indexing.core.EntityIterator.EntityScore)6 EntityIterator (org.apache.stanbol.entityhub.indexing.core.EntityIterator)4 IndexingConfig (org.apache.stanbol.entityhub.indexing.core.config.IndexingConfig)4 Test (org.junit.Test)4 EntityDataProvider (org.apache.stanbol.entityhub.indexing.core.EntityDataProvider)3 HashMap (java.util.HashMap)1 ScoreNormaliser (org.apache.stanbol.entityhub.indexing.core.normaliser.ScoreNormaliser)1 Representation (org.apache.stanbol.entityhub.servicesapi.model.Representation)1