Skip to content

Commit

Permalink
Revert "Merge pull request #2500 from linas/anchor-link"
Browse files Browse the repository at this point in the history
Linking results to the AnchorNode idea now seems like a bad idea,
in retrospect.  The ideas in #2911 seem superior. So trash the
AnchorNode support in the query subsystem.

FWIW, if this kind of thing was wanted, a better solution would
be a new kind of Value, that dequeued from a QueueValue, and
plopped the results onto an AnchorNode. ***This*** is the real
reason for stripping away this code: its not generic enough.

Merge branch 'revert-anchor'
  • Loading branch information
linas committed Dec 16, 2022
2 parents 01e53cf + 389fa3f commit eee7a61
Show file tree
Hide file tree
Showing 12 changed files with 2 additions and 302 deletions.
1 change: 0 additions & 1 deletion examples/pattern-matcher/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ Basic Examples
The first five examples provide a basic introduction to basic
pattern matching.

* `anchor.scm` -- Obtaining results incrementally.
* `satisfaction.scm` -- Determining satisfiability of a query.
* `unify.scm` -- Basic term unification.
* `glob.scm` -- Matching multiple atoms at once.
Expand Down
66 changes: 0 additions & 66 deletions examples/pattern-matcher/anchor.scm

This file was deleted.

4 changes: 0 additions & 4 deletions opencog/atoms/core/ScopeLink.cc
Original file line number Diff line number Diff line change
Expand Up @@ -360,10 +360,6 @@ ContentHash ScopeLink::scope_hash(const FreeVariables::IndexMap& index) const
// As to not mix together VariableList and VariableSet
fnv1a_hash(hsh, _variables._ordered);

// If there's an AnchorNode, hash that too.
if (_variables._anchor)
fnv1a_hash(hsh, _variables._anchor->get_hash());

Arity vardecl_offset = _vardecl != Handle::UNDEFINED;
Arity n_scoped_terms = get_arity() - vardecl_offset;
fnv1a_hash(hsh, n_scoped_terms);
Expand Down
9 changes: 0 additions & 9 deletions opencog/atoms/core/Variables.cc
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,6 @@ void Variables::validate_vardecl(const Handle& hdecls)
// variables inference is aborted for now.
return;
}
else if (ANCHOR_NODE == tdecls)
{
_anchor = hdecls;
}
else
{
throw InvalidParamException(TRACE_INFO,
Expand All @@ -164,10 +160,6 @@ void Variables::validate_vardecl(const HandleSeq& oset)
{
unpack_vartype(h);
}
else if (ANCHOR_NODE == t)
{
_anchor = h;
}
else
{
throw InvalidParamException(TRACE_INFO,
Expand Down Expand Up @@ -686,7 +678,6 @@ Handle Variables::get_vardecl() const

if (_ordered)
return HandleCast(createVariableList(std::move(vardecls)));

return HandleCast(createVariableSet(std::move(vardecls)));
}

Expand Down
4 changes: 2 additions & 2 deletions opencog/atoms/core/Variables.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ struct Variables : public FreeVariables
/// _typemap holds back-ponters to TypedVariableLinkPtrs
VariableTypeMap _typemap;

/// Anchor, if present, else undefined.
Handle _anchor;
// See VariableList.cc for comments
void get_vartype(const Handle&);

// Validate the variable decls
void validate_vardecl(const Handle&);
Expand Down
10 changes: 0 additions & 10 deletions opencog/atoms/pattern/BindLink.cc
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,6 @@ ValuePtr BindLink::execute(AtomSpace* as, bool silent)
OC_ASSERT(qv->is_closed(), "Unexpected queue state!");
HandleSeq rslt(qv->to_handle_seq());

// If there is an anchor, then attach results to the anchor.
// Otherwise, create a SetLink and return that.
if (_variables._anchor and as)
{
for (const Handle& h: rslt)
as->add_link(MEMBER_LINK, h, _variables._anchor);

return _variables._anchor;
}

// The result_set contains a list of the grounded expressions.
// (The order of the list has no significance, so it's really a set.)
// Put the set into a SetLink, cache it, and return that.
Expand Down
15 changes: 0 additions & 15 deletions opencog/atoms/pattern/DualLink.cc
Original file line number Diff line number Diff line change
Expand Up @@ -79,21 +79,6 @@ ValuePtr DualLink::execute(AtomSpace* as, bool silent)
if (nullptr == as) as = _atom_space;
Recognizer reco(as);
reco.satisfy(PatternLinkCast(get_handle()));

// If there is an anchor, then attach results to the anchor.
// Otherwise, create a SetLink and return that.
// XXX FIXME ... at this time, there is no documented way of
// squeezing an AnchorLink into a DualLink. So the below
// if-statement is never taken. Some additional design work
// is needed.
if (_variables._anchor and as)
{
for (const Handle& h : reco._rules)
as->add_link(MEMBER_LINK, h, _variables._anchor);

return _variables._anchor;
}

return as->add_atom(createUnorderedLink(reco._rules, SET_LINK));
}

Expand Down
10 changes: 0 additions & 10 deletions opencog/atoms/pattern/GetLink.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,6 @@ ValuePtr GetLink::execute(AtomSpace* as, bool silent)
OC_ASSERT(qv->is_closed(), "Unexpected queue state!");
HandleSet hs(qv->to_handle_set());

// If there is an anchor, then attach results to the anchor.
// Otherwise, create a SetLink and return that.
if (_variables._anchor and as)
{
for (const Handle& h : hs)
as->add_link(MEMBER_LINK, h, _variables._anchor);

return _variables._anchor;
}

// Create the satisfying set, and cache it.
Handle satset(createUnorderedLink(std::move(hs), SET_LINK));

Expand Down
6 changes: 0 additions & 6 deletions opencog/atoms/pattern/SatisfactionLink.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,6 @@ TruthValuePtr SatisfactionLink::evaluate(AtomSpace* as, bool silent)
Satisfier sater(as);
sater.satisfy(PatternLinkCast(get_handle()));

// If there is an anchor, then attach results to the anchor.
if (_variables._anchor and as)
{
as->add_link(MEMBER_LINK, sater._ground, _variables._anchor);
}

return sater._result;
}

Expand Down
138 changes: 0 additions & 138 deletions tests/query/AnchorUTest.cxxtest

This file was deleted.

2 changes: 0 additions & 2 deletions tests/query/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ ADD_CXXTEST(RecognizerUTest)
ADD_CXXTEST(ArcanaUTest)
ADD_CXXTEST(SubstitutionUTest)
ADD_CXXTEST(GetLinkUTest)
ADD_CXXTEST(AnchorUTest)
ADD_CXXTEST(NotLinkUTest)
ADD_CXXTEST(GetStateUTest)
ADD_CXXTEST(ClassicalBooleanUTest)
Expand Down Expand Up @@ -150,7 +149,6 @@ TARGET_LINK_LIBRARIES(SparseUTest
)

# -------------------------------------------------------------

# Run only the tests in this subdirectory
ADD_CUSTOM_TARGET (qtest
DEPENDS tests
Expand Down
39 changes: 0 additions & 39 deletions tests/query/anchor.scm

This file was deleted.

0 comments on commit eee7a61

Please sign in to comment.