use of org.apache.solr.ltr.feature.Feature in project lucene-solr by apache.
the class TestRerankBase method getFeatures.
protected List<Feature> getFeatures(List<String> names) throws FeatureException {
final List<Feature> features = new ArrayList<>();
int pos = 0;
for (final String name : names) {
final Map<String, Object> params = new HashMap<String, Object>();
params.put("value", 10);
final Feature f = Feature.getInstance(solrResourceLoader, ValueFeature.class.getCanonicalName(), name, params);
f.setIndex(pos);
features.add(f);
++pos;
}
return features;
}
use of org.apache.solr.ltr.feature.Feature in project lucene-solr by apache.
the class TestManagedFeatureStore method getInstanceTest.
@Test
public void getInstanceTest() throws FeatureException {
fstore.addFeature(createMap("test", OriginalScoreFeature.class.getCanonicalName(), null), "testFstore");
final Feature feature = fstore.getFeatureStore("testFstore").get("test");
assertNotNull(feature);
assertEquals("test", feature.getName());
assertEquals(OriginalScoreFeature.class.getCanonicalName(), feature.getClass().getCanonicalName());
}
use of org.apache.solr.ltr.feature.Feature in project lucene-solr by apache.
the class TestManagedFeatureStore method testFeatureStoreAdd.
@Test
public void testFeatureStoreAdd() throws FeatureException {
final FeatureStore fs = fstore.getFeatureStore("fstore-testFeature");
for (int i = 0; i < 5; i++) {
final String name = "c" + i;
fstore.addFeature(createMap(name, OriginalScoreFeature.class.getCanonicalName(), null), "fstore-testFeature");
final Feature f = fs.get(name);
assertNotNull(f);
}
assertEquals(5, fs.getFeatures().size());
}
use of org.apache.solr.ltr.feature.Feature in project lucene-solr by apache.
the class TestSelectiveWeightCreation method makeFeatureWeights.
private static Map<String, Object> makeFeatureWeights(List<Feature> features) {
final Map<String, Object> nameParams = new HashMap<String, Object>();
final HashMap<String, Double> modelWeights = new HashMap<String, Double>();
for (final Feature feat : features) {
modelWeights.put(feat.getName(), 0.1);
}
nameParams.put("weights", modelWeights);
return nameParams;
}
use of org.apache.solr.ltr.feature.Feature in project lucene-solr by apache.
the class TestSelectiveWeightCreation method makeFeatures.
private static List<Feature> makeFeatures(int[] featureIds) {
final List<Feature> features = new ArrayList<>();
for (final int i : featureIds) {
Map<String, Object> params = new HashMap<String, Object>();
params.put("value", i);
final Feature f = Feature.getInstance(solrResourceLoader, ValueFeature.class.getCanonicalName(), "f" + i, params);
f.setIndex(i);
features.add(f);
}
return features;
}
Aggregations