{"id":619,"date":"2014-05-29T17:01:07","date_gmt":"2014-05-29T08:01:07","guid":{"rendered":"http:\/\/frsw.net\/blog\/?p=619"},"modified":"2014-05-29T17:30:00","modified_gmt":"2014-05-29T08:30:00","slug":"windows%e3%81%a7juman%e3%82%92%e7%94%a8%e3%81%84%e3%82%8b%e3%81%a8%e3%81%8d%e3%81%ae%e6%96%87%e5%ad%97%e3%82%b3%e3%83%bc%e3%83%89%e3%81%ab%e3%81%a4%e3%81%84%e3%81%a6%e3%81%ae%e6%b3%a8%e6%84%8f","status":"publish","type":"post","link":"http:\/\/frsw.net\/blog\/windows%e3%81%a7juman%e3%82%92%e7%94%a8%e3%81%84%e3%82%8b%e3%81%a8%e3%81%8d%e3%81%ae%e6%96%87%e5%ad%97%e3%82%b3%e3%83%bc%e3%83%89%e3%81%ab%e3%81%a4%e3%81%84%e3%81%a6%e3%81%ae%e6%b3%a8%e6%84%8f\/","title":{"rendered":"Windows\u3067JUMAN\u3092\u7528\u3044\u308b\u3068\u304d\u306e\u6587\u5b57\u30b3\u30fc\u30c9\u306b\u3064\u3044\u3066\u306e\u6ce8\u610f"},"content":{"rendered":"<p>\u3053\u3093\u306b\u3061\u306f\u3002<\/p>\n<p>Ruby\u3067JUMAN\u3092\u4f7f\u7528\u3057\u3066\u3044\u305f\u3089\u3001UTF8\u306e\u30d5\u30a1\u30a4\u30eb\u3067\u30a8\u30e9\u30fc\u304c\u51fa\u307e\u304f\u3063\u3066\u3044\u305f\u306e\u3067\u8abf\u3079\u3066\u307f\u305f\u3089\u300c\u305f\u3060\u3057\uff0cWindows \u7248\u306f\u5f93\u6765\u3068\u540c\u3058\u304f\uff0c\u5165\u51fa\u529b\u304a\u3088\u3073\u8f9e\u66f8\u306e\u6587\u5b57\u30b3\u30fc\u30c9\u306fSJIS \u3067\u3042\u308b\uff0e\u300d\u3068\u306e\u3053\u3068\u3067\u3057\u305f\u3002(JUMAN version 7.0 \u30de\u30cb\u30e5\u30a2\u30eb\u3088\u308a)<br \/>\u306a\u306e\u3067\u3001UTF8\u3092\u7528\u3044\u3066JUMAN\u3067\u306a\u3093\u304b\u3057\u3089\u306e\u64cd\u4f5c\u3092\u3057\u305f\u3044\u5834\u5408\u306f\u30a8\u30f3\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\u3092\u884c\u3063\u3066Shift-JIS\u306b\u5909\u66f4\u3059\u308b\u5fc5\u8981\u304c\u3042\u308b\u307f\u305f\u3044\u3067\u3059\u3002<\/p>\n<p>\u3068\u3044\u3046\u8a33\u3067\u3001\u305d\u3053\u3089\u8fba\u3092\u610f\u8b58\u3057\u305fRuby\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u8f09\u305b\u3066\u304a\u304d\u307e\u3059\u3002<\/p>\n<p><!--more--><\/p>\n<p>[ruby]<br \/>\n# coding: utf-8<\/p>\n<p># \u2605\u6587\u5b57\u51e6\u7406\u306b\u3064\u3044\u3066<br \/>\n# open3\u306e\u53d7\u3051\u6e21\u3057\u6642\u306e\u307fShidt-JIS\u306b\u3057\u3066\uff0c\u305d\u308c\u4ee5\u5916\u306e\u51e6\u7406\u306f\u3059\u3079\u3066UTF8\u3067\u884c\u3046<br \/>\n# \uff08\u524d\u51e6\u7406\uff09\u2192\u3010utf8 to Shift-JIS\u3011\u2192\uff08JUMAN\u51e6\u7406\uff09\u2192\u3010Shift-JIS to utf8\u3011\u2192\uff08\u5f8c\u51e6\u7406\uff09<\/p>\n<p>require &#8216;open3&#8217; # open3\u306e\u547c\u3073\u51fa\u3057<\/p>\n<p># string\u306fUTF8<br \/>\nstring =&quot;\u72ac\u3082\u6b69\u3051\u3070\u68d2\u306b\u5f53\u305f\u308b\u3057\u3001\u733f\u306f\u6728\u304b\u3089\u843d\u3061\u308b\u3057\u6563\u3005\u3060\u3002&quot;<\/p>\n<p># \u5f62\u614b\u7d20\u60c5\u5831\u3092\u683c\u7d0d\u3059\u308b\u914d\u5217\u3092\u521d\u671f\u5316<br \/>\n#<br \/>\n# \u5927\u96d1\u628a\u306a\u69cb\u9020\u2190\u4e2d\u8eab\u306f\u7d50\u69cb\u3080\u305a\u304b\u3057\u3044<br \/>\n# [ [1\u756a\u3081\u6587\u5b57\u306e\u5f62\u614b\u7d20\u60c5\u5831], [2\u756a\u3081\u6587\u5b57\u306e\u5f62\u614b\u7d20\u60c5\u5831],<br \/>\n#                            \u2026, [n\u756a\u3081\u6587\u5b57\u306e\u5f62\u614b\u7d20\u60c5\u5831] ]<br \/>\nkeitaisojouhou = Array.new<\/p>\n<p># open3\u3067\u6a19\u6e96\u5165\u51fa\u529b\u3092\u64cd\u4f5c\u3057\u3066Juman\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c<br \/>\nOpen3.popen3(&quot;juman -b&quot;) do |stdin, stdout, stderr|<\/p>\n<p>  # JUMAN\u306b\u6587\u5b57\u5217\u3092\u53d7\u3051\u6e21\u3059\u524d\u306bShift-JIS\u306b\u5909\u63db<br \/>\n  string.encode!(&quot;Windows-31J&quot;)<\/p>\n<p>  # \u5165\u529b<br \/>\n  stdin.puts(string)<br \/>\n  stdin.close<\/p>\n<p>  # \u6a19\u6e96\u51fa\u529b\u3092\u53d6\u5f97\u3057\u305f\u77ac\u9593UTF\u306b\u5909\u63db\uff01<br \/>\n  str = stdout.read.encode!(&quot;UTF-8&quot;)<\/p>\n<p>  # keitaisojouhou\u306b\u8ffd\u52a0<br \/>\n  str.each_line do |line_str|<\/p>\n<p>    unless line_str == nil<br \/>\n      keitaisojouhou.push(line_str.split(\/\\s\/))<br \/>\n    end<\/p>\n<p>  end<\/p>\n<p>end<\/p>\n<p># \u8a9e\u5f59\u306e\u30ea\u30b9\u30c8\u3092\u8868\u793a<br \/>\nkeitaisojouhou.each do |elm|<br \/>\n  unless elm[2] == nil<br \/>\n    print(&quot;\u30fb#{elm[2]}\\n&quot;)<br \/>\n  end<br \/>\nend<br \/>\n[\/ruby]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3053\u3093\u306b\u3061\u306f\u3002 Ruby\u3067JUMAN\u3092\u4f7f\u7528\u3057\u3066\u3044\u305f\u3089\u3001UTF8\u306e\u30d5\u30a1\u30a4\u30eb\u3067\u30a8\u30e9\u30fc\u304c\u51fa\u307e\u304f\u3063\u3066\u3044\u305f\u306e\u3067\u8abf\u3079\u3066\u307f\u305f\u3089\u300c\u305f\u3060\u3057\uff0cWindows \u7248\u306f\u5f93\u6765\u3068\u540c\u3058\u304f\uff0c\u5165\u51fa\u529b\u304a\u3088\u3073\u8f9e\u66f8\u306e\u6587\u5b57\u30b3\u30fc\u30c9\u306fSJIS \u3067\u3042\u308b\uff0e\u300d\u3068\u306e\u3053\u3068\u3067\u3057\u305f\u3002 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10,4,16,7],"tags":[],"_links":{"self":[{"href":"http:\/\/frsw.net\/blog\/wp-json\/wp\/v2\/posts\/619"}],"collection":[{"href":"http:\/\/frsw.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/frsw.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/frsw.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/frsw.net\/blog\/wp-json\/wp\/v2\/comments?post=619"}],"version-history":[{"count":5,"href":"http:\/\/frsw.net\/blog\/wp-json\/wp\/v2\/posts\/619\/revisions"}],"predecessor-version":[{"id":624,"href":"http:\/\/frsw.net\/blog\/wp-json\/wp\/v2\/posts\/619\/revisions\/624"}],"wp:attachment":[{"href":"http:\/\/frsw.net\/blog\/wp-json\/wp\/v2\/media?parent=619"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/frsw.net\/blog\/wp-json\/wp\/v2\/categories?post=619"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/frsw.net\/blog\/wp-json\/wp\/v2\/tags?post=619"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}