@Beta public final class InspectorTreeDSL extends Object
InspectionNodes pass their input to their output unchanged but may apply zero or more
inspectors as the data passed through.
TransformNodes do not inspect their input, but they do apply some transformation to it
before passing it on to their consumers.
To build an inspector tree, first determine what the original input type to the tree will be and
create a corresponding TypeToken(s). Then use the type tokens to create input nodes
using either input(TypeToken) or pairedInput(TypeToken), depending on whether
you are observing single objects or pairs of objects (e.g. in a scorer, where you have system
output and a gold standard). This will be the root of the inspection tree which you will feed
the data to inspect to. It will be an InspectionNode without any inspectors.
To add a transformation node, use transformed(InspectorTreeNode, Function) or transformBoth(InspectorTreeNode, Function). To add an observation node, use inspect(InspectorTreeNode) like this:
inspect(myInputNode).with(someInspector);
An example:
TypeToken<Integer> inputIsInteger = new TypeToken<Integer> () {}
InspectionNode<Integer> input = input(inputIsInteger);
inspect(input).with(printFunction)
InspectorTreeNode<Integer> plusTwo = transformed(input, plusTwoFunction);
inspect(plusTwo).with(printFunction);
inspect(plusTwo).with(emailToFredFunction);
for (int x : myInts) {
input.inspect(x);
}
input.finish();
Users beware - this is a very rough draft and is likely to change in the future without warning.| Modifier and Type | Class and Description |
|---|---|
static class |
InspectorTreeDSL.InspectionBuilder<InT> |
| Constructor and Description |
|---|
InspectorTreeDSL() |
| Modifier and Type | Method and Description |
|---|---|
static <KeyT extends F,ValT extends F,F> |
filterBothSets(InspectorTreeNode<EvalPair<Set<KeyT>,Set<ValT>>> inputNode,
com.google.common.base.Predicate<F> pred) |
static <T> InspectionNode<T> |
input(com.google.common.reflect.TypeToken<T> typeToken) |
static <InT> InspectorTreeDSL.InspectionBuilder<InT> |
inspect(InspectorTreeNode<InT> inputNode) |
static <T> InspectionNode<EvalPair<T,T>> |
pairedInput(com.google.common.reflect.TypeToken<T> typeToken) |
static <T,V> InspectionNode<EvalPair<T,V>> |
pairedInput(com.google.common.reflect.TypeToken<T> leftTypeToken,
com.google.common.reflect.TypeToken<V> rightTypeToken) |
static <KeyT extends F,ValT extends F,F,T> |
transformBoth(InspectorTreeNode<EvalPair<KeyT,ValT>> inputNode,
com.google.common.base.Function<F,T> func) |
static <KeyT extends F,ValT extends F,F,T> |
transformBothSets(InspectorTreeNode<EvalPair<Set<KeyT>,Set<ValT>>> inputNode,
com.google.common.base.Function<F,T> func) |
static <InT,OutT> InspectorTreeNode<OutT> |
transformed(InspectorTreeNode<InT> inputNode,
com.google.common.base.Function<? super InT,? extends OutT> func) |
static <KeyT extends F,ValT,F,T> |
transformLeft(InspectorTreeNode<EvalPair<KeyT,ValT>> inputNode,
com.google.common.base.Function<F,T> func) |
static <KeyT,ValT extends F,F,T> |
transformRight(InspectorTreeNode<EvalPair<KeyT,ValT>> inputNode,
com.google.common.base.Function<F,T> func) |
public static <T> InspectionNode<T> input(com.google.common.reflect.TypeToken<T> typeToken)
public static <T> InspectionNode<EvalPair<T,T>> pairedInput(com.google.common.reflect.TypeToken<T> typeToken)
public static <T,V> InspectionNode<EvalPair<T,V>> pairedInput(com.google.common.reflect.TypeToken<T> leftTypeToken, com.google.common.reflect.TypeToken<V> rightTypeToken)
public static <InT,OutT> InspectorTreeNode<OutT> transformed(InspectorTreeNode<InT> inputNode, com.google.common.base.Function<? super InT,? extends OutT> func)
public static <KeyT extends F,ValT extends F,F,T> InspectorTreeNode<EvalPair<T,T>> transformBoth(InspectorTreeNode<EvalPair<KeyT,ValT>> inputNode, com.google.common.base.Function<F,T> func)
public static <KeyT extends F,ValT extends F,F,T> InspectorTreeNode<EvalPair<Set<T>,Set<T>>> transformBothSets(InspectorTreeNode<EvalPair<Set<KeyT>,Set<ValT>>> inputNode, com.google.common.base.Function<F,T> func)
public static <KeyT extends F,ValT extends F,F> InspectorTreeNode<EvalPair<Set<F>,Set<F>>> filterBothSets(InspectorTreeNode<EvalPair<Set<KeyT>,Set<ValT>>> inputNode, com.google.common.base.Predicate<F> pred)
public static <KeyT extends F,ValT,F,T> InspectorTreeNode<EvalPair<T,ValT>> transformLeft(InspectorTreeNode<EvalPair<KeyT,ValT>> inputNode, com.google.common.base.Function<F,T> func)
public static <KeyT,ValT extends F,F,T> InspectorTreeNode<EvalPair<KeyT,T>> transformRight(InspectorTreeNode<EvalPair<KeyT,ValT>> inputNode, com.google.common.base.Function<F,T> func)
public static <InT> InspectorTreeDSL.InspectionBuilder<InT> inspect(InspectorTreeNode<InT> inputNode)
Copyright © 2016. All rights reserved.