Skip to content

Commit

Permalink
Update the API to the Pattern Matcher
Browse files Browse the repository at this point in the history
See opencog/atomspace#2453 for the matching update
  • Loading branch information
linas committed Dec 26, 2019
1 parent b6d9bb1 commit eb3e756
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
15 changes: 9 additions & 6 deletions opencog/nlp/sureal/SuRealPMCB.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
*/

#include <opencog/atoms/core/FindUtils.h>
#include <opencog/query/PatternMatchEngine.h>
#include <opencog/neighbors/GetPredicates.h>
#include <opencog/neighbors/Neighbors.h>
#include <opencog/nlp/types/atom_types.h>
Expand Down Expand Up @@ -909,7 +910,7 @@ bool SuRealPMCB::disjunct_match(const Handle& hPatWordNode, const Handle& hSolnW
*
* @param pPME pointer to the PatternMatchEngine
*/
bool SuRealPMCB::initiate_search(PatternMatchEngine* pPME)
bool SuRealPMCB::initiate_search(PatternMatchCallback& pmc)
{
// set targets, m_targets should always be a subset of m_interp
if (m_interp.size() > 0)
Expand All @@ -918,11 +919,10 @@ bool SuRealPMCB::initiate_search(PatternMatchEngine* pPME)
m_interp.clear();
}

_search_fail = false;
if (not _variables->varset.empty())
{
bool found = neighbor_search(pPME);
if (not _search_fail) return found;
if (setup_neighbor_search())
return choice_loop(pmc, "sssssss neighbor_search uuuuuuuu");
}

// Not sure quite what triggers this, but there are patterns
Expand All @@ -936,7 +936,8 @@ bool SuRealPMCB::initiate_search(PatternMatchEngine* pPME)
logger().debug("[SuReal] Start pred is: %s",
bestClause->to_short_string().c_str());

// keep only links of the same type as bestClause and have linkage to InterpretationNode
// keep only links of the same type as bestClause and
// have linkage to InterpretationNode
HandleSeq qCandidate;
m_as->get_handles_by_type(std::back_inserter(qCandidate), bestClause->get_type());

Expand Down Expand Up @@ -985,11 +986,13 @@ bool SuRealPMCB::initiate_search(PatternMatchEngine* pPME)

std::sort(sCandidate.begin(), sCandidate.end(), sortBySize);

PatternMatchEngine pme(pmc);
pme.set_pattern(*_variables, *_pattern);
for (auto& c : sCandidate)
{
logger().debug("[SuReal] Loop candidate: %s", c.handle->to_short_string().c_str());

if (pPME->explore_neighborhood(bestClause, bestClause, c.handle))
if (pme.explore_neighborhood(bestClause, bestClause, c.handle))
return true;
}
return false;
Expand Down
2 changes: 1 addition & 1 deletion opencog/nlp/sureal/SuRealPMCB.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class SuRealPMCB :
virtual bool clause_match(const Handle& pattrn_link_h, const Handle& grnd_link_h);
virtual bool grounding(const HandleMap &var_soln,
const HandleMap &pred_soln);
virtual bool initiate_search(PatternMatchEngine*);
virtual bool initiate_search(PatternMatchCallback&);
virtual void set_pattern(const Variables& vars,
const Pattern& pat)
{
Expand Down

0 comments on commit eb3e756

Please sign in to comment.