本文整理汇总了Java中org.galagosearch.core.retrieval.query.NodeType类的典型用法代码示例。如果您正苦于以下问题:Java NodeType类的具体用法?Java NodeType怎么用?Java NodeType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
NodeType类属于org.galagosearch.core.retrieval.query包,在下文中一共展示了NodeType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getIterator
import org.galagosearch.core.retrieval.query.NodeType; //导入依赖的package包/类
/**
* Given a query node, generates the corresponding iterator object that can be used
* for structured retrieval. This method just calls getClass() on the node,
* then instantiates the resulting class.
*
* If the class returned by getClass() is a ScoringFunction, it must contain
* a constructor that takes a single Parameters object. If the class returned by
* getFeatureClass() is some kind of StructuredIterator (either a ScoreIterator,
* ExtentIterator or CountIterator), it must take a Parameters object and an
* ArrayList of DocumentDataIterators as parameters.
*/
public StructuredIterator getIterator(Node node, ArrayList<StructuredIterator> childIterators) throws Exception {
NodeType type = getNodeType(node);
Constructor constructor = type.getConstructor();
Class[] types = type.getParameterTypes(1 + childIterators.size());
if (!isUsableConstructor(types, childIterators)) {
throw new Exception("Couldn't find a reasonable constructor.");
}
Parameters parametersCopy = new Parameters();
parametersCopy.copy(node.getParameters());
Object[] args = argsForConstructor(constructor.getParameterTypes(),
parametersCopy,
childIterators);
RequiredStatistics required =
type.getIteratorClass().getAnnotation(RequiredStatistics.class);
if (required != null) {
for (String statistic : required.statistics()) {
parametersCopy.add(statistic, parameters.get(statistic, null));
}
}
return (StructuredIterator) constructor.newInstance(args);
}
示例2: afterNode
import org.galagosearch.core.retrieval.query.NodeType; //导入依赖的package包/类
public Node afterNode(Node node) throws Exception {
ArrayList<Node> newChildren = new ArrayList<Node>();
NodeType nodeType = retrieval.getNodeType(node);
if (nodeType == null) return node;
ArrayList<Node> children = node.getInternalNodes();
// Given that we're going to pass children.size() + 1 parameters to
// this constructor, what types should those parameters have?
Class[] types = nodeType.getParameterTypes(children.size() + 1);
if (types == null) return node;
for (int i = 1; i < types.length; ++i) {
Node child = children.get(i-1);
// If the parent will expect a ScoreIterator at this position, but
// we've got a CountIterator here, we'll perform a conversion step.
if (ScoreIterator.class.isAssignableFrom(types[i]) &&
isCountNode(children.get(i-1))) {
Node feature = createSmoothingNode(child);
newChildren.add(feature);
} else {
newChildren.add(child);
}
}
return new Node(node.getOperator(), node.getParameters(),
newChildren, node.getPosition());
}
示例3: getNodeType
import org.galagosearch.core.retrieval.query.NodeType; //导入依赖的package包/类
public NodeType getNodeType(Node node) throws Exception {
NodeType nodeType = index.getNodeType(node);
if (nodeType == null) {
nodeType = featureFactory.getNodeType(node);
}
return nodeType;
}
示例4: getNodeType
import org.galagosearch.core.retrieval.query.NodeType; //导入依赖的package包/类
public NodeType getNodeType(Node node) throws IOException {
NodeType result = null;
StructuredIndexPartReader part = getIndexPart(node);
if (part != null) {
final String operator = node.getOperator();
final Map<String, NodeType> nodeTypes = part.getNodeTypes();
result = nodeTypes.get(operator);
}
return result;
}
示例5: testIsStructuredIteratorOrArray
import org.galagosearch.core.retrieval.query.NodeType; //导入依赖的package包/类
public void testIsStructuredIteratorOrArray() {
NodeType n = new NodeType(ExtentIterator.class);
assertTrue(n.isStructuredIteratorOrArray(ExtentIterator.class));
assertTrue(n.isStructuredIteratorOrArray(StructuredIterator.class));
assertFalse(n.isStructuredIteratorOrArray(Integer.class));
assertFalse(n.isStructuredIteratorOrArray(Date.class));
assertTrue(n.isStructuredIteratorOrArray(new ExtentIterator[0].getClass()));
}
示例6: testGetInputs
import org.galagosearch.core.retrieval.query.NodeType; //导入依赖的package包/类
public void testGetInputs() throws Exception {
NodeType n = new NodeType(FakeIterator.class);
Class[] input = n.getInputs();
assertEquals(3, input.length);
assertEquals(Parameters.class, input[0]);
assertEquals(ExtentIterator.class, input[1]);
assertEquals(new StructuredIterator[0].getClass(), input[2]);
}
示例7: testGetParameterTypes
import org.galagosearch.core.retrieval.query.NodeType; //导入依赖的package包/类
public void testGetParameterTypes() throws Exception {
NodeType n = new NodeType(FakeIterator.class);
Class[] input = n.getParameterTypes(5);
assertEquals(5, input.length);
assertEquals(Parameters.class, input[0]);
assertEquals(ExtentIterator.class, input[1]);
assertEquals(StructuredIterator.class, input[2]);
assertEquals(StructuredIterator.class, input[3]);
assertEquals(StructuredIterator.class, input[4]);
}
示例8: testGetConstructor
import org.galagosearch.core.retrieval.query.NodeType; //导入依赖的package包/类
public void testGetConstructor() throws Exception {
NodeType n = new NodeType(FakeIterator.class);
Constructor c = n.getConstructor();
Constructor actual =
FakeIterator.class.getConstructor(Parameters.class, ExtentIterator.class,
new StructuredIterator[0].getClass());
assertEquals(actual, c);
}
示例9: testGetNodeType
import org.galagosearch.core.retrieval.query.NodeType; //导入依赖的package包/类
/**
* Test of getNodeType method, of class FeatureFactory.
*/
public void testGetNodeType() throws Exception {
FeatureFactory f = new FeatureFactory(new Parameters());
NodeType type = f.getNodeType(new Node("combine", ""));
Class c = type.getIteratorClass();
assertEquals(UnfilteredCombinationIterator.class.getName(), c.getName());
}
示例10: getNodeType
import org.galagosearch.core.retrieval.query.NodeType; //导入依赖的package包/类
public NodeType getNodeType(Node node) throws Exception {
return new NodeType(getClass(node));
}
示例11: isCountNode
import org.galagosearch.core.retrieval.query.NodeType; //导入依赖的package包/类
public boolean isCountNode(Node node) throws Exception {
NodeType nodeType = retrieval.getNodeType(node);
if (nodeType == null) return false;
Class outputClass = nodeType.getIteratorClass();
return CountIterator.class.isAssignableFrom(outputClass);
}
示例12: getNodeTypes
import org.galagosearch.core.retrieval.query.NodeType; //导入依赖的package包/类
public Map<String, NodeType> getNodeTypes() {
HashMap<String, NodeType> nodeTypes = new HashMap<String, NodeType>();
nodeTypes.put("scores", new NodeType(Iterator.class));
return nodeTypes;
}
示例13: getNodeTypes
import org.galagosearch.core.retrieval.query.NodeType; //导入依赖的package包/类
public Map<String, NodeType> getNodeTypes() {
HashMap<String, NodeType> types = new HashMap<String, NodeType>();
types.put("counts", new NodeType(Iterator.class));
types.put("extents", new NodeType(Iterator.class));
return types;
}
示例14: getNodeTypes
import org.galagosearch.core.retrieval.query.NodeType; //导入依赖的package包/类
public HashMap<String, NodeType> getNodeTypes() {
HashMap<String, NodeType> nodeTypes = new HashMap<String, NodeType>();
nodeTypes.put("extents", new NodeType(Iterator.class));
return nodeTypes;
}
示例15: testGetIteratorClass
import org.galagosearch.core.retrieval.query.NodeType; //导入依赖的package包/类
public void testGetIteratorClass() {
NodeType n = new NodeType(ExtentIterator.class);
assertEquals(ExtentIterator.class, n.getIteratorClass());
}