OpenCog Framework
Branch: master, revision 6f0b7fc776b08468cf1b74aa9db028f387b4f0c0
|
#include <FindUtils.h>
Public Member Functions | |
FindAtoms (Type t, bool subclass=false) | |
if (subclass) | |
FindAtoms (Type ta, Type tb, bool subclass=false) | |
_target_types () | |
_target_atoms () | |
FindAtoms (const std::set< Handle > &selection) | |
void | search_set (const Handle &h) |
void | search_set (const std::vector< Handle > &hlist) |
Public Attributes | |
bool | stop_at_quote |
std::set< Handle > | varset |
std::set< Handle > | holders |
std::set< Handle > | least_holders |
Private Types | |
enum | Loco { NOPE, YEP, IMM } |
Private Member Functions | |
Loco | find_rec (const Handle &h) |
Private Attributes | |
std::set< Type > | _target_types |
std::set< Handle > | _target_atoms |
There are two different types of utilities in this file: those that tell you if some target atom or target atom type occurs in some tree, returning a simple yes/no answer, and another utility, telling you exactly where it occurs. We start with the more complicated one first. Otherwise, skip down to get at the simpler ones. The FindAtoms class is used to locate atoms of a given type or target that occur inside some clause. The target is specified in the constructor, the clause to be searched is given with the 'search_set()' method. Aftr the search has been done, the targets are available in the various public members.
Find a "target atom", or find all atoms of a given "target type", and all of the links that hold that target, that occur in a clause (an expression tree formed by the outgoing set.) This is typically used to find all variables in an expression, but it can be used for any purpose.
After search_set() is called, the set of target atoms that were found can be retreived from the public member varset
. The set of links that had one of these targets occuring somewhere, anywhere, within them is in the public member holders
. This includes the holders of holders, etc, all the way up to the very top. The least_holders
member will contain only those links that contain a target in their immediate outgoing set. That is, the least_holders
are the smallest links that contain the target.
A "target" is defined in one of two ways: It is either a specified target type, or it is any one of the given set of specific target atoms. When only the type is given, it will typically be VARIABLE_NODE, GROUNDED_PREDICATE_NODE or GROUNDED_SCHEMA_NODE, COMPOSE_LINK, or something like that, and so this just finds these atom types if they occur in the clause(s). Alternately, if a set of specific atoms is given, then this finds the subset of that set that actually occurs in the given clause(s). That is, it computes the intersection between the set of given atoms, and the set of all atoms that occur in the clauses.
Note that anything occuring below a QUOTE_LINK is not explored. Thus, a quote acts like a cut, halting recursion.
Definition at line 84 of file FindUtils.h.
|
private |
Enumerator | |
---|---|
NOPE | |
YEP | |
IMM |
Definition at line 138 of file FindUtils.h.
|
inline |
Definition at line 92 of file FindUtils.h.
Definition at line 101 of file FindUtils.h.
|
inline |
Definition at line 117 of file FindUtils.h.
|
inline |
opencog::FindAtoms::_target_types | ( | ) |
Don't explore link-typed vars!
Definition at line 145 of file FindUtils.h.
References _target_atoms(), _target_types(), opencog::Atom::getType(), holders, IMM, least_holders, opencog::LinkCast(), NOPE, stop_at_quote, python.undocumented.blocksworld::t, varset, and YEP.
|
inline |
Definition at line 95 of file FindUtils.h.
References _target_types(), opencog::classserver(), opencog::ClassServer::getChildrenRecursive(), and python.undocumented.blocksworld::t.
|
inline |
Given a handle to be searched, create a set of all of the target atoms/types that lie in the outgoing set of the handle (recursively).
Definition at line 128 of file FindUtils.h.
References find_rec().
|
inline |
Definition at line 133 of file FindUtils.h.
References find_rec().
|
private |
Definition at line 179 of file FindUtils.h.
|
private |
Definition at line 178 of file FindUtils.h.
std::set<Handle> opencog::FindAtoms::holders |
Definition at line 89 of file FindUtils.h.
std::set<Handle> opencog::FindAtoms::least_holders |
Definition at line 90 of file FindUtils.h.
bool opencog::FindAtoms::stop_at_quote |
Definition at line 87 of file FindUtils.h.
std::set<Handle> opencog::FindAtoms::varset |
Definition at line 88 of file FindUtils.h.