/** {@inheritDoc} */ public void addStartState(ResolutionState startState) { resolutionSearch.addStartState(startState); }
/** * {@inheritDoc} * * <p/>This also resets the entire knowledge base of this resolver, so that it is empty. */ public void reset() { // Empty the knowledge base and clear the current query. domain = new HashMap<Integer, List<PrologCompiledClause>>(); currentQuery = null; // Reset the underlying search. resolutionSearch.reset(); // If printing execution traces, ensure the execution indenter starts from zero. /*if (TRACE) { indenter.reset(); }*/ }
/** {@inheritDoc} */ public SearchNode<ResolutionState, ResolutionState> findGoalPath() throws SearchNotExhaustiveException { return resolutionSearch.findGoalPath(); }
/** * Calculates the set of free variables in a term. * * @param query The term to calculate the free non-anonymous variable set from. * * @return A set of variables that are free and non-anonymous in the term. */ public static Set<Variable> findFreeVariables(Term query) { QueueBasedSearchMethod<Term, Term> freeVarSearch = new DepthFirstSearch<Term, Term>(); freeVarSearch.reset(); freeVarSearch.addStartState(query); freeVarSearch.setGoalPredicate(new FreeVariablePredicate()); return (Set<Variable>) (Set) Searches.setOf(freeVarSearch); }
search.reset(); search.addStartState(new TreeSearchState<CategoryNode>(initialChild)); search.setGoalPredicate(predicate); goal = search.findGoalPath();
search.reset(); search.addStartState(new HierarchyLabelState(label, initialPath)); goal = search.findGoalPath();
/** {@inheritDoc} */ public void setMaxSteps(int max) { resolutionSearch.setMaxSteps(max); }
/** * Calculates the set of free and non-anonymous variables in a term. This is the set of variables that a user query * usually wants to be made aware of. * * @param query The term to calculate the free non-anonymous variable set from. * * @return A set of variables that are free and non-anonymous in the term. */ public static Set<Variable> findFreeNonAnonymousVariables(Term query) { QueueBasedSearchMethod<Term, Term> freeVarSearch = new DepthFirstSearch<Term, Term>(); freeVarSearch.reset(); freeVarSearch.addStartState(query); freeVarSearch.setGoalPredicate(new FreeNonAnonymousVariablePredicate()); return (Set<Variable>) (Set) Searches.setOf(freeVarSearch); }
search.reset(); search.addStartState(new TreeSearchState<CategoryNode>(initialChild)); search.setGoalPredicate(predicate); goal = search.findGoalPath();
/** * Calculates the set of free variables in a term. * * @param query The term to calculate the free non-anonymous variable set from. * * @return A set of variables that are free and non-anonymous in the term. */ public static Set<Variable> findFreeVariables(Term query) { QueueBasedSearchMethod<Term, Term> freeVarSearch = new DepthFirstSearch<Term, Term>(); freeVarSearch.reset(); freeVarSearch.addStartState(query); freeVarSearch.setGoalPredicate(new FreeVariablePredicate()); return (Set<Variable>) (Set) Searches.setOf(freeVarSearch); }
/** * Generates the next element in the search. * * @return The next solution from the search if one is available, or <tt>null</tt> if the search is * complete. */ public SearchNode<O, T> nextInSequence() { try { return search.findGoalPath(); } catch (SearchNotExhaustiveException e) { // SearchNotExhaustiveException means that the search has completed within its designed parameters // without exhausting the search space. Consequently there are no more solutions to find, // the exception can be ignored and the sequence correctly terminated. e = null; return null; } } };
/** {@inheritDoc} */ public void setQuery(PrologCompiledClause query) { // Reset the search in order to initialize it. resolutionSearch.reset(); // Keep a reference to the current query. currentQuery = query; // Create the starting point for the resolution, consisting of the queries to resolve as the intial goal stack, // and an empty list of bindings. goalStack = new StackQueue<BuiltInFunctor>(); // Create a fresh list to hold the results of the resolution in. bindings = new StackQueue<Variable>(); // Create the initial state of the proof search. ResolutionState initialState = new ResolutionStateImpl(query); addStartState(initialState); // If printing execution traces, ensure the execution indenter starts from zero. /*if (TRACE) { indenter.reset(); }*/ }
/** * Calculates the set of free and non-anonymous variables in a term. This is the set of variables that a user query * usually wants to be made aware of. * * @param query The term to calculate the free non-anonymous variable set from. * * @return A set of variables that are free and non-anonymous in the term. */ public static Set<Variable> findFreeNonAnonymousVariables(Term query) { QueueBasedSearchMethod<Term, Term> freeVarSearch = new DepthFirstSearch<Term, Term>(); freeVarSearch.reset(); freeVarSearch.addStartState(query); freeVarSearch.setGoalPredicate(new FreeNonAnonymousVariablePredicate()); return (Set<Variable>) (Set) Searches.setOf(freeVarSearch); }
/** * Generates the next element in the search. * * @return The next solution from the search if one is available, or <tt>null</tt> if the search is * complete. */ public SearchNode<O, T> nextInSequence() { try { return search.findGoalPath(); } catch (SearchNotExhaustiveException e) { // SearchNotExhaustiveException means that the search has completed within its designed parameters // without exhausting the search space. Consequently there are no more solutions to find, // the exception can be ignored and the sequence correctly terminated. e = null; return null; } } };
search.reset(); search.setGoalPredicate(goalPredicate); search.addStartState(term);
search.reset(); search.setGoalPredicate(goalPredicate); search.addStartState(term);
postfixSearch.reset(); postfixSearch.addStartState(nextFunctorArg); postfixSearch.setGoalPredicate(new FunctorTermPredicate());