}
}
// Make sure there's at least one expansion model specified.
if (scoreFunctionNodes.size() == 0) {
throw new ConfigurationException("No conceptscore specified!");
}
// Create the expander.
expander = new UnigramLatentConceptExpander(env, fbDocs, fbTerms, expanderWeight, parameters,
scoreFunctionNodes, importanceModels);
// Maximum number of candidate expansion terms to consider per query.
int maxCandidates = XMLTools.getAttributeValue(model, "maxCandidates", 0);
if (maxCandidates > 0) {
expander.setMaxCandidates(maxCandidates);
}
} else if ("latentconcept".equals(normExpanderType)) {
int defaultFbDocs = XMLTools.getAttributeValue(model, "fbDocs", 10);
int defaultFbTerms = XMLTools.getAttributeValue(model, "fbTerms", 10);
List<Integer> gramList = new ArrayList<Integer>();
List<MRFBuilder> builderList = new ArrayList<MRFBuilder>();
List<Integer> fbDocsList = new ArrayList<Integer>();
List<Integer> fbTermsList = new ArrayList<Integer>();
// Get the expandermodel, which describes how to actually build the expanded MRF.
NodeList children = model.getChildNodes();
for (int i = 0; i < children.getLength(); i++) {
Node child = children.item(i);
if ("expansionmodel".equals(child.getNodeName())) {
int gramSize = XMLTools.getAttributeValue(child, "gramSize", 1);
int fbDocs = XMLTools.getAttributeValue(child, "fbDocs", defaultFbDocs);
int fbTerms = XMLTools.getAttributeValue(child, "fbTerms", defaultFbTerms);
// Set MRF builder parameters.
gramList.add(gramSize);
builderList.add(MRFBuilder.get(env, child));
fbDocsList.add(fbDocs);
fbTermsList.add(fbTerms);
}
}
// Make sure there's at least one expansion model specified.
if (builderList.size() == 0) {
throw new ConfigurationException("No expansionmodel specified!");
}
// Create the expander.
expander = new NGramLatentConceptExpander(env, gramList, builderList, fbDocsList,
fbTermsList);
// Maximum number of candidate expansion terms to consider per query.
int maxCandidates = XMLTools.getAttributeValue(model, "maxCandidates", 0);
if (maxCandidates > 0) {
expander.setMaxCandidates(maxCandidates);
}
} else {
throw new ConfigurationException("Unrecognized expander type -- " + expanderType);
}
return expander;
}