mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-04-11 21:33:13 +00:00
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
This commit is contained in:
parent
6f8dca956b
commit
1a8c6fdc4b
editions/tw5.com/tiddlers/filters/examples
@ -0,0 +1,28 @@
|
||||
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>""">>
|
@ -1,5 +1,5 @@
|
||||
created: 20201107112846692
|
||||
modified: 20201107113536230
|
||||
modified: 20201118103305351
|
||||
tags: [[Operator Examples]] [[search-replace Operator]]
|
||||
title: search-replace Operator (Examples)
|
||||
type: text/vnd.tiddlywiki
|
||||
@ -20,6 +20,7 @@ Replace all matches of a string irrespective of case:
|
||||
<<.operator-example 3 """[[Hello There]search-replace:gi[H],[]]""">>
|
||||
|
||||
You can also use regular expression capture groups in the replacement string:
|
||||
|
||||
`\define names() (\w+)\s(\w+)`
|
||||
<<.operator-example 4 """[[John Smith]search-replace::regexp<names>,[$2,$1]]""" >>
|
||||
<<.operator-example 4 """[[John Smith]search-replace::regexp<names>,[$2,$1]]""" >>
|
||||
|
||||
{{How to remove stop words}}
|
@ -1,5 +1,5 @@
|
||||
created: 20200425110427700
|
||||
modified: 20200425110427700
|
||||
modified: 20201118103327392
|
||||
tags: [[sortsub Operator]] [[Operator Examples]]
|
||||
title: sortsub Operator (Examples)
|
||||
type: text/vnd.tiddlywiki
|
||||
@ -29,4 +29,6 @@ These examples make use of the following variables:
|
||||
<<.operator-example 4 "[!sortsub:number<compare-by-text-length>limit[10]]">>
|
||||
<<.operator-example 5 "[tag[Field Operators]sortsub:date<compare-by-newest-of-modified-and-created-dates>]">>
|
||||
|
||||
{{How to remove stop words}}
|
||||
|
||||
</$vars>
|
Loading…
x
Reference in New Issue
Block a user