summaryrefslogtreecommitdiffstats
path: root/storage/mroonga/vendor/groonga/examples/dictionary/jmdict/jmdict.rb
diff options
context:
space:
mode:
Diffstat (limited to 'storage/mroonga/vendor/groonga/examples/dictionary/jmdict/jmdict.rb')
-rwxr-xr-xstorage/mroonga/vendor/groonga/examples/dictionary/jmdict/jmdict.rb42
1 files changed, 42 insertions, 0 deletions
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