Skip to content

Instantly share code, notes, and snippets.

@cv
Created January 26, 2009 22:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cv/53020 to your computer and use it in GitHub Desktop.
Save cv/53020 to your computer and use it in GitHub Desktop.
[master!ioke]$ cat frequencies.ik
scriptFrequency = method(text,
count = {} withDefault(0)
text chars each(char,
count[char script] += 1
)
count
)
scriptFrequency("Hi there, how are you?") println
scriptFrequency("ウィキペディアはオープンコンテントの百科事典です。基本方針に賛") println
scriptFrequency(" במאה ה-19, עם המצאת הטלפון, הפכה המילה למילת ברכה בינלאומית, בעיקר בשימוש כפותחת שיחות טלפון.") println
scriptFrequency("是英語中常用的問候語") println
[master!ioke]$ ioke frequencies.ik
{Common=6, Latin=16}
{Katakana=15, Common=2, Han=9, Hiragana=5}
{Hebrew=72, Common=22}
{Han=10}
[master!ioke]$
[olabini-master!ioke]$ time ioke frequencies.ik
{Common=6, Latin=16}
{Common=2, Hiragana=5, Katakana=15, Han=9}
{Common=22, Hebrew=72}
{Han=10}
real 2m31.464s
user 2m21.231s
sys 0m2.273s
[olabini-master!ioke]$
[master!ioke]$ time ioke frequencies.ik
{Latin=16, Common=6}
{Han=9, Hiragana=5, Katakana=15, Common=2}
{Hebrew=72, Common=22}
{Han=10}
real 0m4.905s
user 0m4.486s
sys 0m0.169s
[master!ioke]$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment