2
$\begingroup$

I want to get all counts of trigrams that with "th" (or any other given digram).

humanRights = 
  ToLowerCase@ExampleData[{"Text", "UNHumanRightsEnglish"}]; 

trigramCounts = LetterCounts[humanRights, 3];

How can I do this? Neither trigramCounts["th"<> _], trigramCounts[["th" ~~ _]] nor trigramCounts[RegularExpression["th*"]] produce the desired effect

$\endgroup$
1
  • $\begingroup$ All the values are trigrams. Therefore I think the pattern "th"~~_ is sufficient and the anonymous function becomes StringMatchQ[#, "th" ~~ _]& $\endgroup$ Aug 3, 2015 at 8:44

1 Answer 1

4
$\begingroup$

This is one way:

KeySelect[trigramCounts, StringMatchQ[#, "th" ~~ ___] &]
$\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.