Can we count words with ZP?

mark leenheer

Client
Регистрация
29.01.2012
Сообщения
156
Благодарностей
6
Баллы
0
I'd like to get a words count in one of my templates, is this easy to do?

I CAN count characters and that might work for me, but would prefer to get a word count if possible.

Is this easily done?
 

muchink

Client
Регистрация
28.07.2012
Сообщения
193
Благодарностей
6
Баллы
18
You could count the spaces and add +1 in the end since there is always 1 more word than spaces.
Use "String.Space"
 

mark leenheer

Client
Регистрация
29.01.2012
Сообщения
156
Благодарностей
6
Баллы
0
Thanks, so my next move is to look for string.space and how to use it, so I type it into the search window and I see 15 pages of posts not related at all to string.space.... I mean the text is not even found anywhere on the page. WTF :mad:

Count words in a variable text:


return project.Variables["text"].Value.Split( new char[] { ' ', ',', ';', '.', '!', '"', '(', ')', '?' },
System.StringSplitOptions.RemoveEmptyEntries).Length;

Dozer posted this snippet in another thread I can try, I'll post it here in case anyone has trouble finding the answer as I did.
 

rostonix

Известная личность
Регистрация
23.12.2011
Сообщения
29 067
Благодарностей
5 706
Баллы
113
You can use {-String.Space-} to identify space
{-String.Tab} = Tab
{-Straing.Enter} = Enter/Linebreak
 
  • Спасибо
Реакции: mark leenheer

mark leenheer

Client
Регистрация
29.01.2012
Сообщения
156
Благодарностей
6
Баллы
0
I don't know HOW to use string.space, that is the problem ;-)

I don't like having to ask for help all the time, but it's very hard for me to find the help I need,
esp with the search function being as bad as it is.

I checked the wiki too, nothing there on split.string or how to use it.


I was able to make it work using the C# snippet...
 

rostonix

Известная личность
Регистрация
23.12.2011
Сообщения
29 067
Благодарностей
5 706
Баллы
113
I think for that kind of tasks that you mentioned in your 1st post you shoud use JS and google solutions for it. Cause ZennoPoster doesn't have user friendly interfaces for all tiny tasks that you might ever need.

If you wanna operate with ZP actions, you can use Text processing - Regex and use \s as expression.
Then put found data to list and count number of lines.
 

mark leenheer

Client
Регистрация
29.01.2012
Сообщения
156
Благодарностей
6
Баллы
0
Yes I can understand that, it would be very hard to cover everything for sure. Thanks for the help.
 

HuangXiangCai(黄祥财)

Administrator
Команда форума
Регистрация
03.10.2012
Сообщения
21
Благодарностей
14
Баллы
3
i have a simple way to resolve this problem

1:get the article and put the reuslt to the variable "articlecontent"

2:replace the space of {-variable.articlecontent-} to \r\n and put the result to variable "{-variable.articlecontentspace-}"

3:replace the "{-variable.articlecontentspace-}" with the following string processing :{-String.Replace-|-{-variable.articlecontentspace--|-\r\n-|-{-String.Enter-}-} and put the result to list named "articlewordcount"

4:It's very easy to use a "get row count" to the get the word count result and put the result to {-variable.wordcountresult-}

5:save the word count result to some file via File--> "write text"
 

mark leenheer

Client
Регистрация
29.01.2012
Сообщения
156
Благодарностей
6
Баллы
0
I get what you are doing, clever idea. Do you happen to have an example snippet you could post?

I know what you are doing, not 100%$ on how to do it exactly.
 

hotohori

Client
Регистрация
10.02.2012
Сообщения
154
Благодарностей
40
Баллы
28

Кто просматривает тему: (Всего: 1, Пользователи: 0, Гости: 1)