@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);
        }
    }
@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();
           
            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);
        }
    }
@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(); 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); } }