Advertisement
Guest User

Untitled

a guest
Mar 24th, 2013
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. kan={}
  2. for line in io.lines("kanjidic.utf8") do
  3. if string.sub(line,1,1)~="#" then
  4. a=string.find(line,' G')
  5. if a then
  6. b=string.find(line,' ',a+1)
  7. if b then
  8. no=tonumber(string.sub(line,a+2,b))
  9. if no then
  10. if not kan[no] then
  11. kan[no]={}
  12. end
  13. table.insert(kan[no],string.sub(line,1,3))
  14. end
  15. end
  16. end
  17. end
  18. end
  19.  
  20.  
  21. for i,v in pairs(kan) do
  22. print(i,#v)
  23. out=io.open("/tmp/grade"..i..".html","w")
  24. out:write("<html><head>"..'<meta http-equiv="Content-Type" content="text/html; charset=utf-8">'.."</head><body><h1>Grade "..i.."</h1><font size=5>\n")
  25. count=0
  26. for _,k in pairs(v) do
  27. count=count+1
  28. out:write("<a target=\"jisho\" href=\"http://www.jisho.org/kanji/details/"..k..'">'..k.."</a><font size=1><a target=\"jisho\" href=\"http://www.jisho.org/sentences?jap="..k..'">(ex)</a></font> ')
  29. if count>=13 then
  30. count=0
  31. out:write("\n")
  32. end
  33. end
  34. out:write("\n</font></body></html>")
  35. out:close()
  36. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement