Package network.aika.neuron.activation
Class SearchNode
- java.lang.Object
-
- network.aika.neuron.activation.SearchNode
-
- All Implemented Interfaces:
Comparable<SearchNode>
public class SearchNode extends Object implements Comparable<SearchNode>
TheSearchNodeclass represents a node in the binary search tree that is used to find the optimal interpretation for a given document. Each search node possess a refinement (simply a set of interpretation nodes). The two options that this search node examines are that the refinement will either part of the final interpretation or not. During each search step the activation values in all the neuron activations adjusted such that they reflect the interpretation of the current search path. When the search reaches the maximum depth of the search tree and no further refinements exists, a weight is computed evaluating the current search path. The search path with the highest weight is used to determine the final interpretation.Before the search is started a set of initial refinements is generated from the conflicts within the document. In other words, if there are no conflicts in a given document, then no search is needed. In this case the final interpretation will simply be the set of all interpretation nodes. The initial refinements are then expanded, meaning all interpretation nodes that are consistent with this refinement are added to the refinement. The initial refinements are then propagated along the search path as refinement candidates.
- Author:
- Lukas Molzberger
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSearchNode.DebugStatestatic classSearchNode.Decisionstatic interfaceSearchNode.SkipSelectStepstatic classSearchNode.TimeoutException
-
Field Summary
Fields Modifier and Type Field Description static booleanCOMPUTE_SOFT_MAXstatic booleanENABLE_CACHINGstatic booleanENABLE_CACHING_COMPARISONstatic intMAX_SEARCH_STEPSstatic booleanOPTIMIZE_SEARCH
-
Constructor Summary
Constructors Constructor Description SearchNode(Document doc, SearchNode selParent, SearchNode exclParent, int level)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidchangeState(Activation.Mode m)booleancompareNewState(SearchNode cachedNode)intcompareTo(SearchNode sn)static voidcomputeCachedFactor(SearchNode sn)voiddumpDebugState()doublegetAccumulatedWeight()ActivationgetActivation()SearchNodegetAlternative()Activation.OptiongetCurrentOption()SearchNode.DecisiongetDecision()intgetId()Map<Activation,Activation.StateChange>getModifiedActivations()Activation.OptiongetOption()SearchNodegetParent()doublegetWeightSum()static voidinvalidateCachedDecision(Activation act)StringpathToString()static voidsearch(Document doc, SearchNode root, long v, Long timeoutInMilliSeconds)Searches for the best interpretation for the given document.StringtoString()
-
-
-
Field Detail
-
MAX_SEARCH_STEPS
public static int MAX_SEARCH_STEPS
-
ENABLE_CACHING
public static boolean ENABLE_CACHING
-
ENABLE_CACHING_COMPARISON
public static boolean ENABLE_CACHING_COMPARISON
-
OPTIMIZE_SEARCH
public static boolean OPTIMIZE_SEARCH
-
COMPUTE_SOFT_MAX
public static boolean COMPUTE_SOFT_MAX
-
-
Constructor Detail
-
SearchNode
public SearchNode(Document doc, SearchNode selParent, SearchNode exclParent, int level) throws Activation.OscillatingActivationsException
-
-
Method Detail
-
getId
public int getId()
-
getOption
public Activation.Option getOption()
-
getModifiedActivations
public Map<Activation,Activation.StateChange> getModifiedActivations()
-
getAccumulatedWeight
public double getAccumulatedWeight()
-
getActivation
public Activation getActivation()
-
getCurrentOption
public Activation.Option getCurrentOption()
-
compareNewState
public boolean compareNewState(SearchNode cachedNode)
-
dumpDebugState
public void dumpDebugState()
-
search
public static void search(Document doc, SearchNode root, long v, Long timeoutInMilliSeconds) throws SearchNode.TimeoutException, Activation.RecursiveDepthExceededException, Activation.OscillatingActivationsException
Searches for the best interpretation for the given document. This implementation of the algorithm is iterative to prevent stack overflow errors from happening. Depending on the document the search tree might be getting very deep.- Parameters:
doc-root-- Throws:
SearchNode.TimeoutExceptionActivation.RecursiveDepthExceededExceptionActivation.OscillatingActivationsException
-
getWeightSum
public double getWeightSum()
-
getAlternative
public SearchNode getAlternative()
-
invalidateCachedDecision
public static void invalidateCachedDecision(Activation act) throws Activation.RecursiveDepthExceededException
-
computeCachedFactor
public static void computeCachedFactor(SearchNode sn)
-
pathToString
public String pathToString()
-
changeState
public void changeState(Activation.Mode m)
-
compareTo
public int compareTo(SearchNode sn)
- Specified by:
compareToin interfaceComparable<SearchNode>
-
getParent
public SearchNode getParent()
-
getDecision
public SearchNode.Decision getDecision()
-
-