Semantic Structure, Recursive Filters, and Wikify

159 views
Skip to first unread message

LorenzGL

unread,
Oct 3, 2018, 12:48:18 AM10/3/18
to TiddlyWiki
I'm working on creating a semantic structure in TW. U fortunately, this requires recursive filters. I’m stuck trying to feed the output of a recursive macro into a filter using wikify. The problem seems to be that the macro is outputting a formatted list but the filter expects a title list. I haven't been able to figure out how to solve the problem. The goal is to display a list of all individuals of a superclass for individuals that are only linked to subclasses but not the superclass. Here is my code:

\define class_sub()
<$list filter="[is_subclass_of{!!title}]">
<$link><<currentTiddler>></$link>
<$macrocall $name="class_sub">>
</$list>
\end

<$wikify name="all_subclasses" text=<<class_sub>> output=html>
<<list-links filter:"[enlist<all_subclasses>listed[is_individual_of]]">>
</$wikify>

Any help on this would be greatly appreciated.

TonyM

unread,
Oct 3, 2018, 2:03:09 AM10/3/18
to TiddlyWiki
Not sure I get the use case, ie the structure subclasses and is-individual of


Why is the output=html ?

I am not sure how "[is_subclass_of{!!title}]" works

Rather than get class_sub to return links, why not simply return titles you can then use the title to display a link as you do by using list-links.

Try removing output=html 
and removing <$link><<currentTiddler>></$link> 
and just use <<currentTiddler>>
I think then <<class_sub>> will return what you expect.

Also you may replace list links with a list widget then you can have more control and debug better.

Tony

BurningTreeC

unread,
Oct 3, 2018, 4:34:14 AM10/3/18
to TiddlyWiki
Hi @LorenzGL

I tried your code on tiddlywiki.com and this code seems to work if I get what you're trying to accomplish:

\define create-tiddler-title()
[[[[$(currentTiddler)$]]]]
\end

\define class_sub() 
<$list filter="[is_subclass_of{!!title}]"> 
<<create-tiddler-title>>
<$macrocall $name="class_sub">/> 
</$list> 
\end

<$wikify name="all_subclasses" text=<<class_sub>> output="text">
<<list-links filter:"[enlist<all_subclasses>]">> 
</$wikify> 

This assumes that tiddler titles in the field "is_subclass_of" are always stored without [[ ]] ... so a tiddler couldn't be subclass of more tiddlers.

On tiddlywiki.com/prerelease there's the new "contains" operator and I tried:

\define create-tiddler-title()
[[[[$(currentTiddler)$]]]]
\end

\define class_sub() 
<$list filter="[all[tiddlers]contains:is_subclass_of{!!title}]"> 
<<create-tiddler-title>>
<$macrocall $name="class_sub">/> 
</$list> 
\end

<$wikify name="all_subclasses" text=<<class_sub>> output="text">
<<list-links filter:"[enlist<all_subclasses>]">> 
</$wikify> 

This works for a "is_subclass_of" field which contains a list of tiddler titles.


Let me know if I got it right,

BTC
Message has been deleted

LorenzGL

unread,
Oct 3, 2018, 8:14:44 PM10/3/18
to TiddlyWiki
Works beautifully! Also, thanks a lot for the pointer about the “contains” operator. While not an issue, yet, multiple parents might become relevant. Much appreciated!

LorenzGL

unread,
Oct 4, 2018, 12:22:24 AM10/4/18
to TiddlyWiki
Hello Tony, thanks for the suggestion using the list widget... I’m still very much figuring out the interplay between macros, widgets, and html.

The use case of the class hierarchy and recursive filters is for modeling complex semantic relationships, e.g. it allows you to list San Francisco as a city in North America/USA if you specify that it is located in California and that California is part of the USA and the USA is part of North America without having to specify that San Francisco is located in NA/USA.
Reply all
Reply to author
Forward
0 new messages