#include <FuzzyPatternMatchCB.h>
|
| FuzzyPatternMatchCB (AtomSpace *, Type, const HandleSeq &) |
|
virtual bool | initiate_search (PatternMatchEngine *pme) |
|
virtual void | set_pattern (const Variables &vars, const Pattern &pat) |
|
virtual bool | fuzzy_match (const Handle &h1, const Handle &h2) |
|
virtual bool | link_match (const LinkPtr &pLink, const LinkPtr &gLink) |
|
virtual bool | node_match (const Handle &pNode, const Handle &gNode) |
|
virtual bool | grounding (const std::map< Handle, Handle > &var_soln, const std::map< Handle, Handle > &term_soln) |
|
| DefaultPatternMatchCB (AtomSpace *) |
|
virtual bool | variable_match (const Handle &, const Handle &) |
|
virtual bool | post_link_match (const LinkPtr &, const LinkPtr &) |
|
virtual bool | clause_match (const Handle &, const Handle &) |
|
virtual bool | optional_clause_match (const Handle &pattrn, const Handle &grnd) |
|
virtual bool | evaluate_sentence (const Handle &pat, const std::map< Handle, Handle > &gnds) |
|
virtual const std::set< Type > & | get_connectives (void) |
|
bool | optionals_present (void) |
|
virtual | ~PatternMatchCallback () |
|
virtual IncomingSet | get_incoming_set (const Handle &h) |
|
virtual void | push (void) |
|
virtual void | pop (void) |
|
Definition at line 31 of file FuzzyPatternMatchCB.h.
void FuzzyPatternMatchCB::check_if_accept |
( |
const Handle & |
gh | ) |
|
|
private |
Compare and estimate the similarity between the pattern and the potential solution, and decide whether or not to accept it. The potential solution will be accepted if it has a similarity greater than or equals to the maximum similarity that we know, rejected otherwise.
- Parameters
-
Definition at line 197 of file FuzzyPatternMatchCB.cc.
References clause, excl_list, opencog::get_all_nodes(), in_set_sizes, max_similarity, min_size_diff, pat_nodes, pat_size, solns, and opencog::Atom::toShortString().
void FuzzyPatternMatchCB::find_starters |
( |
const Handle & |
hp, |
|
|
const size_t & |
depth, |
|
|
const size_t & |
clause_idx, |
|
|
const Handle & |
term, |
|
|
std::vector< Starter > & |
rtn |
|
) |
| |
|
private |
Find the starters that can be used to initiate a fuzzy-search. Currently the starters has to be a node that is not an instance nor a variable.
- Parameters
-
hp | The pattern (the hypergraph in the query) |
depth | The depth of the starter in the pattern |
clause_idx | The index of the clause, i.e. which clause the starter is in among all input clauses |
term | The term that the starter is located in the pattern |
rtn | A list of potential starters found in the pattern |
Definition at line 49 of file FuzzyPatternMatchCB.cc.
References opencog::FuzzyPatternMatchCB::Starter::depth, excl_list, opencog::Atom::getIncomingSetSize(), opencog::FuzzyPatternMatchCB::Starter::handle, opencog::LinkCast(), opencog::NodeCast(), pat_size, opencog::FuzzyPatternMatchCB::Starter::term, opencog::Handle::UNDEFINED, opencog::FuzzyPatternMatchCB::Starter::uuid, opencog::Handle::value(), and opencog::FuzzyPatternMatchCB::Starter::width.
virtual bool opencog::FuzzyPatternMatchCB::fuzzy_match |
( |
const Handle & |
ph, |
|
|
const Handle & |
gh |
|
) |
| |
|
inlinevirtual |
Called when the template pattern and the candidate grounding are not having the same type, or one of them are undefined. It is obviously a mismatch so it returns false by default, but it would be useful if we are not looking for an exact match. It gives the Pattern Matcher more flexibility.
Reimplemented from opencog::PatternMatchCallback.
Definition at line 49 of file FuzzyPatternMatchCB.h.
virtual bool opencog::FuzzyPatternMatchCB::grounding |
( |
const std::map< Handle, Handle > & |
var_soln, |
|
|
const std::map< Handle, Handle > & |
term_soln |
|
) |
| |
|
inlinevirtual |
Called when a complete grounding for all clauses is found. Should return false to search for more solutions; or return true to terminate search. (Just as in all the other callbacks, a return value of true
means that the proposed grounding is acceptable. The engine is designed to halt once an acceptable solution has been found; thus, in order to force it to search for more, a return value of false is needed.)
Note that the callback may be called many times reporting the same result.
Implements opencog::PatternMatchCallback.
Definition at line 61 of file FuzzyPatternMatchCB.h.
Implement the initiate_search method in the Pattern Matcher. The main difference between this method and the default one is that this initiates multiple searches using differnt nodes as starters instead of one, explores the neighborhood of each of them, and captures the partial matches in the callbacks. It stops when there are no more available starters in the pattern.
- Parameters
-
- Returns
- True if one or more solutions are found, false otherwise
Implements opencog::PatternMatchCallback.
Definition at line 95 of file FuzzyPatternMatchCB.cc.
References _pattern, clause, opencog::FuzzyPatternMatchCB::Starter::depth, opencog::PatternMatchEngine::explore_neighborhood(), find_starters(), opencog::Atom::getIncomingSet(), opencog::Pattern::mandatory, solns, starters, opencog::Atom::toShortString(), opencog::FuzzyPatternMatchCB::Starter::uuid, and opencog::FuzzyPatternMatchCB::Starter::width.
bool FuzzyPatternMatchCB::link_match |
( |
const LinkPtr & |
pl, |
|
|
const LinkPtr & |
gl |
|
) |
| |
|
virtual |
virtual bool opencog::FuzzyPatternMatchCB::node_match |
( |
const Handle & |
npat_h, |
|
|
const Handle & |
nsoln_h |
|
) |
| |
|
inlinevirtual |
Called when a node in the template pattern needs to be compared to a possibly matching node in the atomspace. The first argument is a node from the pattern, and the second is a possible solution (grounding) node from the atomspace.
Return true if the nodes match, else return false. By default, the nodes must be identical.
Reimplemented from opencog::DefaultPatternMatchCB.
Definition at line 56 of file FuzzyPatternMatchCB.h.
virtual void opencog::FuzzyPatternMatchCB::set_pattern |
( |
const Variables & |
vars, |
|
|
const Pattern & |
pat |
|
) |
| |
|
inlinevirtual |
const Pattern* opencog::FuzzyPatternMatchCB::_pattern = NULL |
|
private |
Handle opencog::FuzzyPatternMatchCB::clause |
|
private |
HandleSeq opencog::FuzzyPatternMatchCB::excl_list |
|
private |
std::unordered_map<Handle, size_t> opencog::FuzzyPatternMatchCB::in_set_sizes |
|
private |
double opencog::FuzzyPatternMatchCB::max_similarity = -std::numeric_limits<double>::max() |
|
private |
size_t opencog::FuzzyPatternMatchCB::min_size_diff = SIZE_MAX |
|
private |
HandleSeq opencog::FuzzyPatternMatchCB::pat_nodes |
|
private |
size_t opencog::FuzzyPatternMatchCB::pat_size = 0 |
|
private |
std::vector<UUID> opencog::FuzzyPatternMatchCB::prev_compared |
|
private |
Type opencog::FuzzyPatternMatchCB::rtn_type |
|
private |
HandleSeq opencog::FuzzyPatternMatchCB::solns |
std::vector<Starter> opencog::FuzzyPatternMatchCB::starters |
|
private |
The documentation for this class was generated from the following files: