Sha256: c40db127f80e846803833d5d0ff2e4be293e45f48c90aef2149139a3868f21e3

Contents?: true

Size: 817 Bytes

Versions: 2

Compression:

Stored size: 817 Bytes

Contents

#!/usr/bin/ruby
# -*- coding: utf-8 -*-

$KCODE = 'u'

require 'kconv'

class String
  def to_json
    a = split(//).map {|char|
      case char
      when '"' then '\\"'
      when '\\' then '\\\\'
      when "\b" then '\b'
      when "\f" then '\f'
      when "\n" then '\n'
      when "\r" then ''
      when "\t" then '\t'
      else char
      end
    }
    "\"#{a.join('')}\""
  end
end

class Array
  def to_json
    '[' + map {|element|
      element.to_json
    }.join(',') + ']'
  end
end

puts <<END
column_create item edict_desc COLUMN_SCALAR ShortText
column_create bigram item_edict_desc COLUMN_INDEX|WITH_POSITION item edict_desc
load --table item
[["_key","edict_desc"],
END

while !STDIN.eof?
  line = Kconv.toutf8(gets.strip)
  key, body = line.split('/', 2)
  puts [key, body].to_json
end
puts ']'

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rroonga-1.1.0-x86-mingw32 vendor/local/share/groonga/examples/dictionary/edict/edict2grn.rb
rroonga-1.0.1-x86-mingw32 vendor/local/share/groonga/examples/dictionary/edict/edict2grn.rb