{"published":"2011-12-01 20:24:11","version":"1.0","provider_url":"https://hatena.blog","author_name":"aerith","provider_name":"Hatena Blog","author_url":"https://blog.hatena.ne.jp/aerith/","blog_url":"https://aerith.hateblo.jp/","type":"rich","image_url":null,"height":"190","blog_title":"\u3042\u308c\u3053\u308c\u305d\u308c\u3069\u3053\uff1f","html":"<iframe src=\"https://hatenablog-parts.com/embed?url=https%3A%2F%2Faerith.hateblo.jp%2Fentry%2F2011%2F12%2F01%2F202411\" title=\"N-gram \u3063\u3066\u306a\u306b\u2026\u3002 - \u3042\u308c\u3053\u308c\u305d\u308c\u3069\u3053\uff1f\" class=\"embed-card embed-blogcard\" scrolling=\"no\" frameborder=\"0\" style=\"display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;\"></iframe>","url":"https://aerith.hateblo.jp/entry/2011/12/01/202411","title":"N-gram \u3063\u3066\u306a\u306b\u2026\u3002","categories":[],"width":"100%","description":"def ngram(target, n) analyzed = [] keywords = target.split(//u) keywords.size.times do |i| keyword = keywords[i, n].delete_if { |i| i.nil? || i.blank? || i.match(/^\\s+$/) } next if keyword.size < n analyzed << keyword.join end analyzed.join(\" \") end \u306a\u3093\u304b\u4f5c\u3063\u3066\u304f\u3060\u3055\u3044\u3063\u3066\u8a00\u308f\u308c\u305f\u306e\u3067\u4f5c\u3063\u305f\u3002\u6587\u5b57\u5217\u3092 n \u6587\u5b57\u3067\u5206\u5272\u3057\u305f\u3082\u306e\u3092\u4f5c\u308c\u3070\u3044\u3044\u306e\u304b\u306a\u304f\u3089\u3044\u2026"}