diff options
Diffstat (limited to '')
-rw-r--r-- | storage/mroonga/vendor/groonga/examples/dictionary/jmdict/Makefile.am | 3 | ||||
-rwxr-xr-x | storage/mroonga/vendor/groonga/examples/dictionary/jmdict/jmdict.rb | 42 |
2 files changed, 45 insertions, 0 deletions
diff --git a/storage/mroonga/vendor/groonga/examples/dictionary/jmdict/Makefile.am b/storage/mroonga/vendor/groonga/examples/dictionary/jmdict/Makefile.am new file mode 100644 index 00000000..70b4a5bc --- /dev/null +++ b/storage/mroonga/vendor/groonga/examples/dictionary/jmdict/Makefile.am @@ -0,0 +1,3 @@ +jmdictdir = $(examples_dictionarydir)/jmdict +dist_jmdict_SCRIPTS = \ + jmdict.rb diff --git a/storage/mroonga/vendor/groonga/examples/dictionary/jmdict/jmdict.rb b/storage/mroonga/vendor/groonga/examples/dictionary/jmdict/jmdict.rb new file mode 100755 index 00000000..bf892678 --- /dev/null +++ b/storage/mroonga/vendor/groonga/examples/dictionary/jmdict/jmdict.rb @@ -0,0 +1,42 @@ +#!/usr/bin/env ruby +# -*- coding: utf-8 -*- + +require 'rexml/document' +require 'rexml/parsers/streamparser' +require 'rexml/parsers/baseparser' +require 'rexml/streamlistener' + +#REXML::Document.new(STDIN) + +class MyListener + include REXML::StreamListener + def tag_start(name, attrs) + # p name, attrs + case name + when 'entry' + @n = 0 + end + end + def tag_end name + # p "tag_end: #{x}" + case name + when 'sense' + @n += 1 + when 'entry' + @n_ents += 1 + puts "#{@ent}:#{@n}" if (@n > 8) + when 'ent_seq' + @ent = @text + end + end + + def text(text) + @text = text + end + + def xmldecl(version, encoding, standalone) + @n_ents = 0 + end +end + +REXML::Parsers::StreamParser.new(STDIN, MyListener.new).parse |