Skip to content

Instantly share code, notes, and snippets.

@sguzman
Created March 8, 2021 02:25
Show Gist options
  • Save sguzman/455ac001f9e5b3f3aed0953d7c625d1b to your computer and use it in GitHub Desktop.
Save sguzman/455ac001f9e5b3f3aed0953d7c625d1b to your computer and use it in GitHub Desktop.
rank n grams in mathematica
With[{nlimit = 4, text = chs},
Grid@
TakeLargestBy[
Table[
{First@j, Last@j, Length@First@j * Last@j,
N@((Length@First@j * Last@j)/Length@text)}, {j,
Join @@
Table[
Tally@
Partition[text, i, 1], {i, 1, nlimit, 1}
]}
]
, Last, 20]
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment