1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-07-02 02:03:14 +00:00
TiddlyWiki5/editions/tw5.com/tiddlers/filters/examples/How to remove stop words.tid
saqimtiaz 1a8c6fdc4b
Docs: Added example of how to remove stop words (#5066)
* Added example of how to remove stop words

* Moved filter operator example tiddlers to correct folder
2020-11-18 15:56:38 +00:00

28 lines
1.1 KiB
Plaintext

created: 20201118094513209
modified: 20201118103414384
tags: [[Operator Examples]] [[search-replace Operator]] [[sortsub Operator]]
title: How to remove stop words
type: text/vnd.tiddlywiki
\define book-list()
[[A Tale of Two Cities]]
[[The Dice Man]]
[[A New Kind of Science]]
[[The Recursive Universe]]
[[Great Expectations]]
[[Animal Farm]]
\end
\define compare-without-stopwords()
[<currentTiddler>search-replace:i:regexp[^The |A ],[]]
\end
You can use the [[search-replace Operator]] in combination with the [[sortsub Operator]] to ignore stop words like "A" and "The" at the beginning of titles when sorting. (Note for example that "A Tale of Two Cities" sorts under "T" rather than "A")
<<.operator-example 6 "[enlist<book-list>sortsub<compare-without-stopwords>]">>
You can also customise the listing so that "A Tale of Two Cities" is listed as "Tale of Two Cities, A" but still links to the correct tiddler.
<<wikitext-example-without-html """<ul>
<$list filter="[enlist<book-list>sortsub<compare-without-stopwords>]">
<li><$link><$text text={{{[<currentTiddler>search-replace:i:regexp[(^The |A )(.*)],[$2, $1]]}}}/></$link></li>
</$list>
</ul>""">>