//TODO: For each model create separate implementation.
@Override
    public void process(JCas jCas) throws AnalysisEngineProcessException {
        long startTime = System.currentTimeMillis();
        FeatureExtractor fe = new NYTEntitySalienceFeatureExtractor();
        List<EntityInstance> entityInstances;
        try {
            entityInstances = fe.getEntityInstances(jCas, TrainingSettings.FeatureExtractor.ENTITY_SALIENCE);
            final int featureVectorSize = FeatureSetFactory.createFeatureSet(TrainingSettings.FeatureExtractor.ENTITY_SALIENCE).getFeatureVectorSize();
            //TODO: For each model create separate implementation.
            RandomForestClassificationModel rfm = (RandomForestClassificationModel)trainingModel.stages()[2];
            for(EntityInstance ei : entityInstances) {
                Vector vei = FeatureValueInstanceUtils.convertToSparkMLVector(ei, featureVectorSize);
                double label = rfm.predict(vei);
                Vector probabilities = rfm.predictProbability(vei);
                double salience = probabilities.toArray()[1];
                SalientEntity salientEntity = new SalientEntity(jCas, 0, 0);
                salientEntity.setLabel(label);
                salientEntity.setID(ei.getEntityId());
                salientEntity.setSalience(salience);
                salientEntity.addToIndexes();
            }
            long endTime = System.currentTimeMillis() - startTime;
            logger.debug("Annotating salient entities finished in {}ms.", endTime);
        } catch (Exception e) {
            throw new AnalysisEngineProcessException(e);
        }
    }
entityInstances = fe.getEntityInstances(jCas, TrainingSettings.FeatureExtractor.ENTITY_SALIENCE);
final int featureVectorSize = FeatureSetFactory.createFeatureSet(TrainingSettings.FeatureExtractor.ENTITY_SALIENCE).getFeatureVectorSize();
//TODO: For each model create separate implementation.
RandomForestClassificationModel rfm = (RandomForestClassificationModel)trainingModel.stages()[2];
for(EntityInstance ei : entityInstances) {
@Override
public void process(JCas jCas) throws AnalysisEngineProcessException {
long startTime = System.currentTimeMillis();
FeatureExtractor fe = new NYTEntitySalienceFeatureExtractor();
List<EntityInstance> entityInstances;
try {
entityInstances = fe.getEntityInstances(jCas, TrainingSettings.FeatureExtractor.ENTITY_SALIENCE);
final int featureVectorSize = FeatureSetFactory.createFeatureSet(TrainingSettings.FeatureExtractor.ENTITY_SALIENCE).getFeatureVectorSize();
//TODO: For each model create separate implementation.
RandomForestClassificationModel rfm = (RandomForestClassificationModel)trainingModel.stages()[2];
for(EntityInstance ei : entityInstances) {
Vector vei = FeatureValueInstanceUtils.convertToSparkMLVector(ei, featureVectorSize);
double label = rfm.predict(vei);
Vector probabilities = rfm.predictProbability(vei);
double salience = probabilities.toArray()[1];
SalientEntity salientEntity = new SalientEntity(jCas, 0, 0);
salientEntity.setLabel(label);
salientEntity.setID(ei.getEntityId());
salientEntity.setSalience(salience);
@Override
public void process(JCas jCas) throws AnalysisEngineProcessException {
long startTime = System.currentTimeMillis();
FeatureExtractor fe = new NYTEntitySalienceFeatureExtractor();
List<EntityInstance> entityInstances;
try {
entityInstances = fe.getEntityInstances(jCas, TrainingSettings.FeatureExtractor.ENTITY_SALIENCE);
final int featureVectorSize = FeatureSetFactory.createFeatureSet(TrainingSettings.FeatureExtractor.ENTITY_SALIENCE).getFeatureVectorSize();
//TODO: For each model create separate implementation.
RandomForestClassificationModel rfm = (RandomForestClassificationModel)trainingModel.stages()[2];
for(EntityInstance ei : entityInstances) {
Vector vei = FeatureValueInstanceUtils.convertToSparkMLVector(ei, featureVectorSize);
double label = rfm.predict(vei);
Vector probabilities = rfm.predictProbability(vei);
double salience = probabilities.toArray()[1];
SalientEntity salientEntity = new SalientEntity(jCas, 0, 0);
salientEntity.setLabel(label);
salientEntity.setID(ei.getEntityId());
salientEntity.setSalience(salience);
salientEntity.addToIndexes();
}
long endTime = System.currentTimeMillis() - startTime;
logger.debug("Annotating salient entities finished in {}ms.", endTime);
} catch (Exception e) {
throw new AnalysisEngineProcessException(e);
}
}