Hi Linas, Thanks, I'll get to it once I'm done with the current phase of homeworks, reports and a big report coming up for school.
You're right about what I thought, I thought I could have an orderedList (a, b, c, d.. etc), match (a, d) and throw everything else into another variable. For now I'll try the StarNode if it works with what I'm trying to do. Thanks On Tuesday, 8 November 2016 07:36:33 UTC+9, linas wrote: > > Hi Tareq, > > You can probably implement StarNode as a minor variation on the current > GlobNode code. By the way, that code is here: > https://github.com/opencog/atomspace/blob/master/opencog/query/PatternMatchEngine.cc#L227-L288 > > and specifically, here: > > https://github.com/opencog/atomspace/blob/master/opencog/query/PatternMatchEngine.cc#L255-L261 > So, to implement star-node, all you need to do is to change line 257 to > say "if (is_glob and tc)" and set is_glob to false when matching star nodes. > > > The inverted match is here: > > https://github.com/opencog/atomspace/blob/master/opencog/query/Recognizer.cc#L218-L254 > > > I don't think you need the inverted match in what you are doing. > > Re: ordered vs unordered: this is already handled automatically. If your > data is in an ordered link, then the comparison to the pattern will always > be ordered. If the data and pattern are unordered links, then all possible > permutations will be explored. One of those permutations will put > everything "unknown" next to each-other, where the star node can pick them > up. > > There's even a unit test, somewhere, checking that globnode works with > unorderded links. so it should work automatically ... > > So you do not need to write any extra code to handle the "match everything > left over". Unless you mean... Hmm. Unless you mean this: > > (ListLink ; notice this is an ordered link! > (ConceptNode "a") > (ConceptNode "b") > (StarNode "var") > (ConceptNode "p") > (ConceptNode "q") > (StarNode "var") > (ConceptNode "y") > (ConceptNode "z")) > > and you want everything dumped into one big bag. Because right now, the > way pattern matching is defined, the above will match only if the stuff in > the first location is exactly identical to the stuff in the second location. > > If you want everything i a big bag, it would be better to use two vars, > and consolidate them into one, after the matching is done. > > --linas > > On Mon, Nov 7, 2016 at 2:38 AM, Tareq Alkhaldi <tareq.a...@gmail.com > <javascript:>> wrote: > >> Hi Linas, >> >> Okay, I started adding the StarNode variable, but I have a question. So >> StarNode should work exactly like GlobNode except that it can accept a >> zero, right? What about something that will match zero or more but not >> necessarily in order? For example to match all the nodes in the pattern, >> and throw all the unmatched nodes (in any location) on that level in the >> target side to this variable. It's kind of "AllUnmatchedStuffNode" (for >> lacking a better name). >> >> On Saturday, 29 October 2016 02:11:28 UTC+9, linas wrote: >>> >>> Hi Tareq, >>> >>> Currently, the only way to do this is is to write two different >>> patterns, one that searches for three words, and one that searches for two. >>> >>> Another possibility is to use a GlobNode instead of a VariableNode, this >>> will accept sequences of neighboring words, as one. However, this might >>> not be what you want: the output of a glob is a list. >>> >>> You do ask an interesting question: it would be nice to have this kind >>> of matching. Currently, VariableNode must match exactly one item, and >>> GlobNode must match one or more. A "MaybeNode" that matches zero or one, >>> and a "StarNode" that matches zero or more could be useful. .. But these >>> don't exist, yet. Might not be hard to add ... >>> >>> --linas >>> >>> >>> >>> On Fri, Oct 28, 2016 at 2:47 AM, Tareq Alkhaldi <tareq.a...@gmail.com> >>> wrote: >>> >>>> Hi all, >>>> >>>> Is there a way to use the PM to match a partial list as the following? >>>> >>>> Atomspace has this: >>>> >>>> (EvaluationLink >>>> (PredicateNode "pulled@463a5d30-1733-48bc-b188-cb1fcd1d3ee0") >>>> (ListLink >>>> (ConceptNode "James@c597a7ec-60ab-429d-b003-4782200c7a91") >>>> (ConceptNode "pudding@f797c773-b58a-4136-8bad-74b4ad399c63") >>>> (ConceptNode "all@3f71ac77-ef99-4499-883d-2ae3332fdb6a") ;;;;; >>>> This may or may not exist >>>> ) >>>> ) >>>> >>>> Pattern I want to match is: >>>> >>>> (BindLink >>>> (VariableList >>>> (VariableNode "$X") >>>> (VariableNode "$Y") >>>> ) >>>> >>>> (EvaluationLink >>>> (VariableNode "$X") >>>> (ListLink >>>> (ConceptNode "James@6c0671a2-1b11-4dd9-a787-d27d7779a0c8") >>>> (VariableNode "$Y") >>>> ) >>>> ) >>>> (VariableNode "$Y") >>>> ) >>>> >>>> How can I match that without having to add another variable after "$Y" >>>> in the list, knowing that the (ConceptNode "all@...") may not always be >>>> there. >>>> >>>> Can this be done? >>>> >>>> Thanks >>>> >>>> -- >>>> You received this message because you are subscribed to the Google >>>> Groups "opencog" group. >>>> To unsubscribe from this group and stop receiving emails from it, send >>>> an email to opencog+u...@googlegroups.com. >>>> To post to this group, send email to ope...@googlegroups.com. >>>> Visit this group at https://groups.google.com/group/opencog. >>>> To view this discussion on the web visit >>>> https://groups.google.com/d/msgid/opencog/764c3a00-c443-46ed-9d05-7aa11ddb4cb8%40googlegroups.com >>>> >>>> <https://groups.google.com/d/msgid/opencog/764c3a00-c443-46ed-9d05-7aa11ddb4cb8%40googlegroups.com?utm_medium=email&utm_source=footer> >>>> . >>>> For more options, visit https://groups.google.com/d/optout. >>>> >>> >>> > -- You received this message because you are subscribed to the Google Groups "opencog" group. To unsubscribe from this group and stop receiving emails from it, send an email to opencog+unsubscr...@googlegroups.com. To post to this group, send email to opencog@googlegroups.com. Visit this group at https://groups.google.com/group/opencog. To view this discussion on the web visit https://groups.google.com/d/msgid/opencog/8bc67320-2d3a-4a91-ba10-3acc66ee5988%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.