Apply a multi part filter to a list - how?

55 views
Skip to first unread message

Mat

unread,
Jul 8, 2019, 5:20:49 PM7/8/19
to tiddl...@googlegroups.com
[post edit: Please disregard this post as it turned out to oversimplify the actual problem so it doesn't make sense.]

-----------------------------------------

Beyond my control, the user defines a filter like 

[suffix[berry]] [tag[tasty]]  (could be many more, and more complex)

This is to be applied to my list of fruits'n berries, where some of them are tagged "tasty".

How? Here's the problem shown:

{{{ tastyapple blueberry rottenbanana lingonberry <inserted-userfilter>  }}}

The output should be: tastyapple blueberry lingonberry

It no worky because 
1) the user filter consists of multiple parts so even if I put a "+" before the user filter it wouldn't distribute to the [tag[tasty]] part
2) the original fruit list should be, again, filtered in full by that second filter. 

It seems the user filter must itself be treated like a list of elements... but is that even possible?

<$list filter="[suffix[berry]] [tag[tasty]]" variable=part>
<$list filter="tastyapple blueberry rottenbanana lingonberry +[
<part>]">

<$list>
<$list>

The problem here is of course that the "[suffix[berry]] etc" will be evaluated and not treated as merely a string.

Can I make it be treated like a string? ...but more importantly, should I? The actual problem is the former, not the latter.

Thank you!

<:-)

Mark S.

unread,
Jul 8, 2019, 5:58:10 PM7/8/19
to TiddlyWiki
Your nested filter loops should work. The outer part will pick out all the candidates. The inner will compare the full list against the candidate and print if there's a match. There might be a double output if something has both a suffix berry and is tagged tasty.

You could do it as one massive filter by listing the full list against suffix berry and then again, in a second run, against the tasty tag. In that case, the duplicates should collapse.

Or maybe I'm not understanding the problem?

Mat

unread,
Jul 8, 2019, 7:24:13 PM7/8/19
to TiddlyWiki
Hrmpf... I've apparently oversimplified my problem.  I'll likely get back with a better explanation of the problem.
Really thank you for replying Mark and sorry for causing confusion (of which I have plenty to share though)

<:-)

Xavier Cazin

unread,
Jul 9, 2019, 5:53:40 AM7/9/19
to tiddl...@googlegroups.com
Hi Mat,

From what I understand, the only piece that is missing in your compound filter is the subfilter operator. This should work as expected:

<$list filter="[suffix[berry]] [tag[tasty]]" variable=part>
<$list filter="tastyapple blueberry rottenbanana lingonberry +[subfilter<part>]">

<$list>
<$list>

Cheers
-- Xavier Cazin


On Mon, Jul 8, 2019 at 11:20 PM Mat <matia...@gmail.com> wrote:
Beyond my control, the user defines a filter like 

[suffix[berry]] [tag[tasty]]  (could be many more, and more complex)

This is to be applied to my list of fruits'n berries, where some of them are tagged "tasty".

How? Here's the problem shown:

{{{ tastyapple blueberry rottenbanana lingonberry <inserted-userfilter>  }}}

The output should be: tastyapple blueberry lingonberry

It no worky because 
1) the user filter consists of multiple parts so even if I put a "+" before the user filter it wouldn't distribute to the [tag[tasty]] part
2) the original fruit list should be, again, filtered in full by that second filter. 

It seems the user filter must itself be treated like a list of elements... but is that even possible?

<$list filter="[suffix[berry]] [tag[tasty]]" variable=part>
<$list filter="tastyapple blueberry rottenbanana lingonberry +[
<part>]">

<$list>
<$list>

The problem here is of course that the "[suffix[berry]] etc" will be evaluated and not treated as merely a string.

Can I make it be treated like a string? ...but more importantly, should I? The actual problem is the former, not the latter.

Thank you!

<:-)

--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/8b7c7a4d-9d1f-405b-b8ff-61ddf111c896%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages