Re: [tw5] Counting specific words

2021-09-24 Thread TW Tones
I would just add all the solutions here it are counting words in a title or 
string or the text field. None are attempting to render the tiddler first 
so that lists transclusions and macros etc.. are first expanded.

You can use the wikify widget to wikify the result into a variable and pass 
that to the word count.

Tones

On Saturday, 25 September 2021 at 10:07:16 UTC+10 mohamed...@hotmail.com 
wrote:

> Thank you very much,
>
> both work, also one more question , to get anywhere remotely close to 
> writing code like this  for tiddly wiki , what language should i try to 
> learn, i have no coding skills, and was just wondering if i would invest my 
> time in learning a bit, what language should i be looking at?
>
> thanks again
>
> On Thursday, September 23, 2021 at 11:32:19 PM UTC+2 jn.pierr...@gmail.com 
> wrote:
>
>> actually, https://tiddlywiki.com/#Macro%20Definitions%20in%20WikiText is 
>> very confusing! It took me a lot of time to make any sense out of it for 
>> the special case like using <<< and after my own tests, I have failed to 
>> see that as useful.
>>
>> Your code is actual code and it would be good to use it rather than the 
>> current example.
>>
>> I was sure you coded  instead of <__arg__> and I had copied it and 
>> executed. It was not functioning as it should. But I can no more remember 
>> why: was it the problem I told about why regexp was better or was it that 
>> it did nothing?
>>
>> Anyway, thank you for your correction about what I told. I have yet again 
>> something about tiddlywiki today! And I could use it, definitely.
>>
>>
>>
>>
>>
>> Le jeudi 23 septembre 2021 à 18:04:26 UTC+2, jeremy...@gmail.com a 
>> écrit :
>>
>>> Hi Jean-Pierre
>>>
>>> You made an error in your macro, Jeremy. You should have used $arg$ 
>>> instead of .
>>>
>>>
>>> It's actually not an error: it's an alternative way to access the 
>>> parameters of macros. It avoids the problem that otherwise the code would 
>>> fail with a tiddler title containing a closing square bracket.
>>>
>>> There are docs here under "Parameters as Variables <<__...__>>":
>>>
>>> https://tiddlywiki.com/#Macro%20Definitions%20in%20WikiText
>>>
>>> But it is false nonetheless because it would, for example, cut word 
>>> "totem" if asked for word "to". My regular expression does not do that 
>>> thanks to the \b at both ends of the arguments.
>>>
>>>
>>> Yes, I did that quickly, but indeed I think that splitregexp would be 
>>> needed to make it practical, both to resolve the word boundary issue and 
>>> the case sensitivity issue.
>>>
>>> Best wishes
>>>
>>> Jeremy.
>>>
>>>
>>> Le jeudi 23 septembre 2021 à 16:45:46 UTC+2, jeremy...@gmail.com a 
>>> écrit :
>>>
 Another technique is to use the “split” operator to split the string by 
 the word:

 \define count-words(title,word)
 <$text text={{{ [<__title__>get[text]split<__word__>count[]subtract[1]] 
 }}}/>
 \end

 <>

 Using the splitregexp operator instead allows would allow splitting 
 case insensitively, which might be more useful.

 Best wishes

 Jeremy.

 On 23 Sep 2021, at 15:37, Jean-Pierre Rivière  
 wrote:

 Here it is.

 ```
 \define count-word(word, tid)
 {{{ 
 [[$tid$]get[text]search-replace:gi:regexp[\b$word$\b],[þ]dump:v[first]search-replace:g:regexp,[]dump:v[final]length[]]
  
 }}}
 \end

 <>
 ```

 I use a char that should never be within the tiddler, þ in my example. 
 You can use another rare character is old English is concerned! I replace 
 every occurrence of the word with it, then remove any other character then 
 count the length of the result. If you want case sensitive search, just 
 omit the `i` flag in the first `search-replace`.

 Le mercredi 22 septembre 2021 à 15:14:55 UTC+2, mohamed.e...@
 vodafone.com a écrit :

> Hi ,
>
> is there a way to count the number of occurrences of a specific word 
> in a tiddler
>
> I have serached , but could only find a plugin that counts the total 
> number of words, or total number characters.
>
>  
>

 -- 
 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 view this discussion on the web visit 
 https://groups.google.com/d/msgid/tiddlywiki/a30f622a-627f-41a5-a532-4015e0f3faaen%40googlegroups.com
  
 
 .


 -- 
>>> 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 view 

Re: [tw5] Counting specific words

2021-09-24 Thread paulgilbert2000
Thank you very much,

both work, also one more question , to get anywhere remotely close to 
writing code like this  for tiddly wiki , what language should i try to 
learn, i have no coding skills, and was just wondering if i would invest my 
time in learning a bit, what language should i be looking at?

thanks again

On Thursday, September 23, 2021 at 11:32:19 PM UTC+2 jn.pierr...@gmail.com 
wrote:

> actually, https://tiddlywiki.com/#Macro%20Definitions%20in%20WikiText is 
> very confusing! It took me a lot of time to make any sense out of it for 
> the special case like using <<< and after my own tests, I have failed to 
> see that as useful.
>
> Your code is actual code and it would be good to use it rather than the 
> current example.
>
> I was sure you coded  instead of <__arg__> and I had copied it and 
> executed. It was not functioning as it should. But I can no more remember 
> why: was it the problem I told about why regexp was better or was it that 
> it did nothing?
>
> Anyway, thank you for your correction about what I told. I have yet again 
> something about tiddlywiki today! And I could use it, definitely.
>
>
>
>
>
> Le jeudi 23 septembre 2021 à 18:04:26 UTC+2, jeremy...@gmail.com a écrit :
>
>> Hi Jean-Pierre
>>
>> You made an error in your macro, Jeremy. You should have used $arg$ 
>> instead of .
>>
>>
>> It's actually not an error: it's an alternative way to access the 
>> parameters of macros. It avoids the problem that otherwise the code would 
>> fail with a tiddler title containing a closing square bracket.
>>
>> There are docs here under "Parameters as Variables <<__...__>>":
>>
>> https://tiddlywiki.com/#Macro%20Definitions%20in%20WikiText
>>
>> But it is false nonetheless because it would, for example, cut word 
>> "totem" if asked for word "to". My regular expression does not do that 
>> thanks to the \b at both ends of the arguments.
>>
>>
>> Yes, I did that quickly, but indeed I think that splitregexp would be 
>> needed to make it practical, both to resolve the word boundary issue and 
>> the case sensitivity issue.
>>
>> Best wishes
>>
>> Jeremy.
>>
>>
>> Le jeudi 23 septembre 2021 à 16:45:46 UTC+2, jeremy...@gmail.com a 
>> écrit :
>>
>>> Another technique is to use the “split” operator to split the string by 
>>> the word:
>>>
>>> \define count-words(title,word)
>>> <$text text={{{ [<__title__>get[text]split<__word__>count[]subtract[1]] 
>>> }}}/>
>>> \end
>>>
>>> <>
>>>
>>> Using the splitregexp operator instead allows would allow splitting case 
>>> insensitively, which might be more useful.
>>>
>>> Best wishes
>>>
>>> Jeremy.
>>>
>>> On 23 Sep 2021, at 15:37, Jean-Pierre Rivière  
>>> wrote:
>>>
>>> Here it is.
>>>
>>> ```
>>> \define count-word(word, tid)
>>> {{{ 
>>> [[$tid$]get[text]search-replace:gi:regexp[\b$word$\b],[þ]dump:v[first]search-replace:g:regexp,[]dump:v[final]length[]]
>>>  
>>> }}}
>>> \end
>>>
>>> <>
>>> ```
>>>
>>> I use a char that should never be within the tiddler, þ in my example. 
>>> You can use another rare character is old English is concerned! I replace 
>>> every occurrence of the word with it, then remove any other character then 
>>> count the length of the result. If you want case sensitive search, just 
>>> omit the `i` flag in the first `search-replace`.
>>>
>>> Le mercredi 22 septembre 2021 à 15:14:55 UTC+2, mohamed.e...@
>>> vodafone.com a écrit :
>>>
 Hi ,

 is there a way to count the number of occurrences of a specific word in 
 a tiddler

 I have serached , but could only find a plugin that counts the total 
 number of words, or total number characters.

  

>>>
>>> -- 
>>> 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 view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/tiddlywiki/a30f622a-627f-41a5-a532-4015e0f3faaen%40googlegroups.com
>>>  
>>> 
>>> .
>>>
>>>
>>> -- 
>> 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 view this discussion on the web visit 
>> https://groups.google.com/d/msgid/tiddlywiki/ab5296b2-f778-4334-9eef-1892487d6f19n%40googlegroups.com
>>  
>> 
>> .
>>
>>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web 

Re: [tw5] Counting specific words

2021-09-23 Thread Jean-Pierre Rivière
actually, https://tiddlywiki.com/#Macro%20Definitions%20in%20WikiText is 
very confusing! It took me a lot of time to make any sense out of it for 
the special case like using <<< and after my own tests, I have failed to 
see that as useful.

Your code is actual code and it would be good to use it rather than the 
current example.

I was sure you coded  instead of <__arg__> and I had copied it and 
executed. It was not functioning as it should. But I can no more remember 
why: was it the problem I told about why regexp was better or was it that 
it did nothing?

Anyway, thank you for your correction about what I told. I have yet again 
something about tiddlywiki today! And I could use it, definitely.





Le jeudi 23 septembre 2021 à 18:04:26 UTC+2, jeremy...@gmail.com a écrit :

> Hi Jean-Pierre
>
> You made an error in your macro, Jeremy. You should have used $arg$ 
> instead of .
>
>
> It's actually not an error: it's an alternative way to access the 
> parameters of macros. It avoids the problem that otherwise the code would 
> fail with a tiddler title containing a closing square bracket.
>
> There are docs here under "Parameters as Variables <<__...__>>":
>
> https://tiddlywiki.com/#Macro%20Definitions%20in%20WikiText
>
> But it is false nonetheless because it would, for example, cut word 
> "totem" if asked for word "to". My regular expression does not do that 
> thanks to the \b at both ends of the arguments.
>
>
> Yes, I did that quickly, but indeed I think that splitregexp would be 
> needed to make it practical, both to resolve the word boundary issue and 
> the case sensitivity issue.
>
> Best wishes
>
> Jeremy.
>
>
> Le jeudi 23 septembre 2021 à 16:45:46 UTC+2, jeremy...@gmail.com a écrit :
>
>> Another technique is to use the “split” operator to split the string by 
>> the word:
>>
>> \define count-words(title,word)
>> <$text text={{{ [<__title__>get[text]split<__word__>count[]subtract[1]] 
>> }}}/>
>> \end
>>
>> <>
>>
>> Using the splitregexp operator instead allows would allow splitting case 
>> insensitively, which might be more useful.
>>
>> Best wishes
>>
>> Jeremy.
>>
>> On 23 Sep 2021, at 15:37, Jean-Pierre Rivière  
>> wrote:
>>
>> Here it is.
>>
>> ```
>> \define count-word(word, tid)
>> {{{ 
>> [[$tid$]get[text]search-replace:gi:regexp[\b$word$\b],[þ]dump:v[first]search-replace:g:regexp,[]dump:v[final]length[]]
>>  
>> }}}
>> \end
>>
>> <>
>> ```
>>
>> I use a char that should never be within the tiddler, þ in my example. 
>> You can use another rare character is old English is concerned! I replace 
>> every occurrence of the word with it, then remove any other character then 
>> count the length of the result. If you want case sensitive search, just 
>> omit the `i` flag in the first `search-replace`.
>>
>> Le mercredi 22 septembre 2021 à 15:14:55 UTC+2, mohamed.e...@vodafone.com 
>> a écrit :
>>
>>> Hi ,
>>>
>>> is there a way to count the number of occurrences of a specific word in 
>>> a tiddler
>>>
>>> I have serached , but could only find a plugin that counts the total 
>>> number of words, or total number characters.
>>>
>>>  
>>>
>>
>> -- 
>> 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 view this discussion on the web visit 
>> https://groups.google.com/d/msgid/tiddlywiki/a30f622a-627f-41a5-a532-4015e0f3faaen%40googlegroups.com
>>  
>> 
>> .
>>
>>
>> -- 
> 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 view this discussion on the web visit 
> https://groups.google.com/d/msgid/tiddlywiki/ab5296b2-f778-4334-9eef-1892487d6f19n%40googlegroups.com
>  
> 
> .
>
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/a16a8a5b-4dfa-45b2-ae80-c5efe4187477n%40googlegroups.com.


Re: [tw5] Counting specific words

2021-09-23 Thread Jeremy Ruston
Hi Jean-Pierre
> You made an error in your macro, Jeremy. You should have used $arg$ instead 
> of .

It's actually not an error: it's an alternative way to access the parameters of 
macros. It avoids the problem that otherwise the code would fail with a tiddler 
title containing a closing square bracket.

There are docs here under "Parameters as Variables <<__...__>>":

https://tiddlywiki.com/#Macro%20Definitions%20in%20WikiText

> But it is false nonetheless because it would, for example, cut word "totem" 
> if asked for word "to". My regular expression does not do that thanks to the 
> \b at both ends of the arguments.

Yes, I did that quickly, but indeed I think that splitregexp would be needed to 
make it practical, both to resolve the word boundary issue and the case 
sensitivity issue.

Best wishes

Jeremy.

> 
>> Le jeudi 23 septembre 2021 à 16:45:46 UTC+2, jeremy...@gmail.com a écrit :
>> Another technique is to use the “split” operator to split the string by the 
>> word:
>> 
>> \define count-words(title,word)
>> <$text text={{{ [<__title__>get[text]split<__word__>count[]subtract[1]] }}}/>
>> \end
>> 
>> <>
>> 
>> Using the splitregexp operator instead allows would allow splitting case 
>> insensitively, which might be more useful.
>> 
>> Best wishes
>> 
>> Jeremy.
>> 
 On 23 Sep 2021, at 15:37, Jean-Pierre Rivière  
 wrote:
 
>>> Here it is.
>>> 
>>> ```
>>> \define count-word(word, tid)
>>> {{{ 
>>> [[$tid$]get[text]search-replace:gi:regexp[\b$word$\b],[þ]dump:v[first]search-replace:g:regexp,[]dump:v[final]length[]]
>>>  }}}
>>> \end
>>> 
>>> <>
>>> ```
>>> 
>>> I use a char that should never be within the tiddler, þ in my example. You 
>>> can use another rare character is old English is concerned! I replace every 
>>> occurrence of the word with it, then remove any other character then count 
>>> the length of the result. If you want case sensitive search, just omit the 
>>> `i` flag in the first `search-replace`.
>>> 
> Le mercredi 22 septembre 2021 à 15:14:55 UTC+2, mohamed.e...@vodafone.com 
> a écrit :
> Hi ,
> 
> is there a way to count the number of occurrences of a specific word in a 
> tiddler
> 
> I have serached , but could only find a plugin that counts the total 
> number of words, or total number characters.
> 
>  
 
 
>>> -- 
>>> 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 view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/tiddlywiki/a30f622a-627f-41a5-a532-4015e0f3faaen%40googlegroups.com.
>> 
> 
> -- 
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/tiddlywiki/ab5296b2-f778-4334-9eef-1892487d6f19n%40googlegroups.com.

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/221E8FD9-028C-4828-9326-012B89E321C2%40gmail.com.


Re: [tw5] Counting specific words

2021-09-23 Thread Jean-Pierre Rivière
You made an error in your macro, Jeremy. You should have used $arg$ instead 
of .

Thus your code would be


\define count-words(title,word)
<$text text={{{ [[$title$]get[text]split[$word$]count[]subtract[1]] }}}/>
\end

But it is false nonetheless because it would, for example, cut word "totem" 
if asked for word "to". My regular expression does not do that thanks to 
the \b at both ends of the arguments.

Le jeudi 23 septembre 2021 à 16:45:46 UTC+2, jeremy...@gmail.com a écrit :

> Another technique is to use the “split” operator to split the string by 
> the word:
>
> \define count-words(title,word)
> <$text text={{{ [<__title__>get[text]split<__word__>count[]subtract[1]] 
> }}}/>
> \end
>
> <>
>
> Using the splitregexp operator instead allows would allow splitting case 
> insensitively, which might be more useful.
>
> Best wishes
>
> Jeremy.
>
> On 23 Sep 2021, at 15:37, Jean-Pierre Rivière  
> wrote:
>
> Here it is.
>
> ```
> \define count-word(word, tid)
> {{{ 
> [[$tid$]get[text]search-replace:gi:regexp[\b$word$\b],[þ]dump:v[first]search-replace:g:regexp,[]dump:v[final]length[]]
>  
> }}}
> \end
>
> <>
> ```
>
> I use a char that should never be within the tiddler, þ in my example. You 
> can use another rare character is old English is concerned! I replace every 
> occurrence of the word with it, then remove any other character then count 
> the length of the result. If you want case sensitive search, just omit the 
> `i` flag in the first `search-replace`.
>
> Le mercredi 22 septembre 2021 à 15:14:55 UTC+2, mohamed.e...@vodafone.com 
> a écrit :
>
>> Hi ,
>>
>> is there a way to count the number of occurrences of a specific word in a 
>> tiddler
>>
>> I have serached , but could only find a plugin that counts the total 
>> number of words, or total number characters.
>>
>>  
>>
>
> -- 
> 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 view this discussion on the web visit 
> https://groups.google.com/d/msgid/tiddlywiki/a30f622a-627f-41a5-a532-4015e0f3faaen%40googlegroups.com
>  
> 
> .
>
>
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/ab5296b2-f778-4334-9eef-1892487d6f19n%40googlegroups.com.


Re: [tw5] Counting specific words

2021-09-23 Thread Jeremy Ruston
Another technique is to use the “split” operator to split the string by the 
word:

\define count-words(title,word)
<$text text={{{ [<__title__>get[text]split<__word__>count[]subtract[1]] }}}/>
\end

<>

Using the splitregexp operator instead allows would allow splitting case 
insensitively, which might be more useful.

Best wishes

Jeremy.

> On 23 Sep 2021, at 15:37, Jean-Pierre Rivière  
> wrote:
> 
> Here it is.
> 
> ```
> \define count-word(word, tid)
> {{{ 
> [[$tid$]get[text]search-replace:gi:regexp[\b$word$\b],[þ]dump:v[first]search-replace:g:regexp,[]dump:v[final]length[]]
>  }}}
> \end
> 
> <>
> ```
> 
> I use a char that should never be within the tiddler, þ in my example. You 
> can use another rare character is old English is concerned! I replace every 
> occurrence of the word with it, then remove any other character then count 
> the length of the result. If you want case sensitive search, just omit the 
> `i` flag in the first `search-replace`.
> 
> Le mercredi 22 septembre 2021 à 15:14:55 UTC+2, mohamed.e...@vodafone.com a 
> écrit :
> Hi ,
> 
> is there a way to count the number of occurrences of a specific word in a 
> tiddler
> 
> I have serached , but could only find a plugin that counts the total number 
> of words, or total number characters.
> 
>  
> 
> -- 
> 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+unsubscr...@googlegroups.com 
> .
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/tiddlywiki/a30f622a-627f-41a5-a532-4015e0f3faaen%40googlegroups.com
>  
> .

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/A3605A80-A13D-4390-A07D-E2A61891BA18%40gmail.com.