List of usage examples for java.util TreeSet equals
boolean equals(Object o);
From source file:de.tudarmstadt.ukp.dkpro.tc.core.task.uima.ExtractFeaturesConnector.java
@Override public void collectionProcessComplete() throws AnalysisEngineProcessException { super.collectionProcessComplete(); // apply filters that influence the whole feature store // filters are applied in the order that they appear as parameters for (String filterString : featureFilters) { FeatureStoreFilter filter;//from w w w . j a va 2s.c o m try { filter = (FeatureStoreFilter) Class.forName(filterString).newInstance(); } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) { throw new AnalysisEngineProcessException(e); } if (filter.isApplicableForTraining() && !isTesting || filter.isApplicableForTesting() && isTesting) { filter.applyFilter(featureStore); } } // write feature names file if in training mode if (!isTesting) { try { FileUtils.writeLines(new File(outputDirectory, Constants.FILENAME_FEATURES), featureStore.getFeatureNames()); } catch (IOException e) { throw new AnalysisEngineProcessException(e); } } // apply the feature names filter else { File featureNamesFile = new File(outputDirectory, Constants.FILENAME_FEATURES); TreeSet<String> trainFeatureNames; try { trainFeatureNames = new TreeSet<>(FileUtils.readLines(featureNamesFile)); } catch (IOException e) { throw new AnalysisEngineProcessException(e); } AdaptTestToTrainingFeaturesFilter filter = new AdaptTestToTrainingFeaturesFilter(); // if feature space from training set and test set differs, apply the filter // to keep only features seen during training if (!trainFeatureNames.equals(featureStore.getFeatureNames())) { filter.setFeatureNames(trainFeatureNames); filter.applyFilter(featureStore); } } // FIXME if the feature store now determines whether to use dense or sparse instances, // we might get rid of the corresponding parameter here // addInstanceId requires dense instances try { DataWriter writer = (DataWriter) Class.forName(dataWriterClass).newInstance(); writer.write(outputDirectory, featureStore, true, learningMode, applyWeighting); } catch (Exception e) { throw new AnalysisEngineProcessException(e); } }
From source file:org.dkpro.tc.core.task.uima.ExtractFeaturesConnector.java
private void applyFeatureNameFilter() throws AnalysisEngineProcessException { File featureNamesFile = new File(outputDirectory, Constants.FILENAME_FEATURES); TreeSet<String> trainFeatureNames; try {/* w w w . java2 s . co m*/ trainFeatureNames = new TreeSet<>(FileUtils.readLines(featureNamesFile)); } catch (IOException e) { throw new AnalysisEngineProcessException(e); } AdaptTestToTrainingFeaturesFilter filter = new AdaptTestToTrainingFeaturesFilter(); // if feature space from training set and test set differs, apply the filter // to keep only features seen during training if (!trainFeatureNames.equals(featureStore.getFeatureNames())) { filter.setFeatureNames(trainFeatureNames); filter.applyFilter(featureStore); } }