0
$\begingroup$

How can I count letters and words in the following "text", by using LetterCounts and WordCount?

 text = {"რომელმან", "შექმნა", "სამყარო", "ძალითა", "მით", "ძლიერითა", 
"ზეგარდმო", "არსნი", "სულითა", "ყვნა", "ზეცით", "მონაბერითა", 
"ჩვენ", "კაცთა", "მოგვცა", "ქვეყანა", "გვაქვს", "უთვალავი", 
"ფერითა", "მისგან", "არს", "ყოვლი", "ხელმწიფე", "სახითა", "მის", 
"მიერითა"}

I tried:

LetterCounts[text]
WordCount[text]

but that doesn't work.

When I remove the quotes from text (by hand), then WordCount works, but LetterCounts still doesn't.

$\endgroup$
  • 1
    $\begingroup$ Try LetterCounts[StringRiffle[text]]; as noted in the docs, you need to give a string and not a list of strings. $\endgroup$ – J. M. will be back soon Jun 9 '16 at 11:52
  • $\begingroup$ Both LetterCounts and WordCount want a single string, not a list, as its argument. $\endgroup$ – m_goldberg Jun 9 '16 at 11:53
  • $\begingroup$ @J.M. Thanks, both works perfectly LetterCounts[StringRiffle[text]] WordCount[StringRiffle[text]] $\endgroup$ – vito Jun 9 '16 at 11:57
  • $\begingroup$ Can you answer your own question, then? $\endgroup$ – J. M. will be back soon Jun 9 '16 at 11:58
  • $\begingroup$ @J.M. yes, of course :) $\endgroup$ – vito Jun 9 '16 at 12:08
1
$\begingroup$

I use code from J.M comment, and it works perfectly

text = {"რომელმან", "შექმნა", "სამყარო", "ძალითა", "მით", "ძლიერითა", 
"ზეგარდმო", "არსნი", "სულითა", "ყვნა", "ზეცით", "მონაბერითა", 
"ჩვენ", "კაცთა", "მოგვცა", "ქვეყანა", "გვაქვს", "უთვალავი", 
"ფერითა", "მისგან", "არს", "ყოვლი", "ხელმწიფე", "სახითა", "მის", 
"მიერითა"}

LetterCounts[StringRiffle[text]]
WordCount[StringRiffle[text]]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.