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

1 Answer 1

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 and acknowledge you have read our privacy policy.

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