use of org.apache.solr.common.util.NamedList in project lucene-solr by apache.
the class CarrotClusteringEngineTest method testOtherTopics.
@Test
public void testOtherTopics() throws Exception {
ModifiableSolrParams params = new ModifiableSolrParams();
params.set(AttributeUtils.getKey(MockClusteringAlgorithm.class, "depth"), 1);
params.set(AttributeUtils.getKey(MockClusteringAlgorithm.class, "otherTopicsModulo"), 2);
List<NamedList<Object>> clusters = checkEngine(getClusteringEngine("mock"), AbstractClusteringTestCase.numberOfDocs, params);
int i = 1;
for (NamedList<Object> cluster : clusters) {
assertEquals(i++ % 2 == 0 ? true : null, isOtherTopics(cluster));
}
}
use of org.apache.solr.common.util.NamedList in project lucene-solr by apache.
the class CarrotClusteringEngineTest method testClusterScores.
@Test
public void testClusterScores() throws Exception {
ModifiableSolrParams params = new ModifiableSolrParams();
params.set(AttributeUtils.getKey(MockClusteringAlgorithm.class, "depth"), 1);
List<NamedList<Object>> clusters = checkEngine(getClusteringEngine("mock"), AbstractClusteringTestCase.numberOfDocs, params);
int i = 1;
for (NamedList<Object> cluster : clusters) {
final Double score = getScore(cluster);
assertNotNull(score);
assertEquals(0.25 * i++, score, 0);
}
}
use of org.apache.solr.common.util.NamedList in project lucene-solr by apache.
the class CarrotClusteringEngineTest method checkLexicalResourcesFromSolrConfig.
private void checkLexicalResourcesFromSolrConfig(String engineName, String wordsToCheck) throws IOException {
ModifiableSolrParams params = new ModifiableSolrParams();
params.set("merge-resources", false);
params.set(AttributeUtils.getKey(LexicalResourcesCheckClusteringAlgorithm.class, "wordsToCheck"), wordsToCheck);
// "customsolrstopword" is in stopwords.en, "customsolrstoplabel" is in
// stoplabels.mt, so we're expecting only one cluster with label "online".
final List<NamedList<Object>> clusters = checkEngine(getClusteringEngine(engineName), 1, params);
assertEquals(getLabels(clusters.get(0)), Collections.singletonList("online"));
}
use of org.apache.solr.common.util.NamedList in project lucene-solr by apache.
the class CarrotClusteringEngineTest method testSolrStopWordsUsedInCarrot2Clustering.
@Test
public void testSolrStopWordsUsedInCarrot2Clustering() throws Exception {
ModifiableSolrParams params = new ModifiableSolrParams();
params.set("merge-resources", false);
params.set(AttributeUtils.getKey(LexicalResourcesCheckClusteringAlgorithm.class, "wordsToCheck"), "online,solrownstopword");
// "solrownstopword" is in stopwords.txt, so we're expecting
// only one cluster with label "online".
final List<NamedList<Object>> clusters = checkEngine(getClusteringEngine("lexical-resource-check"), 1, params);
assertEquals(getLabels(clusters.get(0)), Collections.singletonList("online"));
}
use of org.apache.solr.common.util.NamedList in project lucene-solr by apache.
the class LTRThreadModule method extractThreadModuleParams.
private static NamedList extractThreadModuleParams(NamedList args) {
// gather the thread module args from amongst the general args
final NamedList extractedArgs = new NamedList();
for (Iterator<Map.Entry<String, Object>> it = args.iterator(); it.hasNext(); ) {
final Map.Entry<String, Object> entry = it.next();
final String key = entry.getKey();
if (key.startsWith(CONFIG_PREFIX)) {
extractedArgs.add(key.substring(CONFIG_PREFIX.length()), entry.getValue());
}
}
// since NamedList iterator does not support 'remove'
for (Object key : extractedArgs.asShallowMap().keySet()) {
args.remove(CONFIG_PREFIX + key);
}
return extractedArgs;
}
Aggregations