natto 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -55,6 +55,10 @@ e.g., for Cygwin
55
55
 
56
56
  ## Changelog
57
57
 
58
+ - __2011/01/13: 0.0.9 release.
59
+ - Further development and testing for mecab dictionary access/destruction
60
+ - Continuing update of documentation
61
+
58
62
  - __2011/01/07__: 0.0.8 release.
59
63
  - Adding support for accessing dictionaries
60
64
  - Further tweaking of documentation with markdown
@@ -87,4 +91,4 @@ e.g., for Cygwin
87
91
 
88
92
  ## Copyright
89
93
 
90
- natto © 2010-2013 by Brooke M. Fujita, licensed under the new BSD license. Please see the [LICENSE](file.LICENSE.html) document for further details.
94
+ natto © 2010-2013 by Brooke M. Fujita, licensed under the new BSD license. Please see the [LICENSE](LICENSE) document for further details.
data/lib/natto.rb CHANGED
@@ -110,7 +110,7 @@ module Natto
110
110
  # Returns a <tt>Proc</tt> that is registered to be invoked
111
111
  # after the object owning <tt>ptr</tt> has been destroyed.
112
112
  #
113
- # @param [FFI::MemoryPointer] ptr
113
+ # @param [FFI::Pointer] ptr
114
114
  # @return [Proc] to release <tt>mecab</tt> resources properly
115
115
  def self.create_free_proc(ptr)
116
116
  Proc.new do
data/lib/natto/version.rb CHANGED
@@ -1,50 +1,20 @@
1
1
  # coding: utf-8
2
2
 
3
- # natto combines the Ruby programming language with MeCab,
4
- # the part-of-speech and morphological analyzer for the
5
- # Japanese language.
6
- #
7
- # ## Requirements
8
- # natto requires the following:
3
+ # <tt>Natto</tt> is the namespace for objects that provide
4
+ # a binding to the <tt>mecab</tt> parser and related resources.
9
5
  #
10
- # - [MeCab _0.98_](http://sourceforge.net/projects/mecab/files/mecab/0.98/)
11
- # - [ffi _0.6.3 or greater_](http://rubygems.org/gems/ffi)
12
- # - Ruby _1.8.7 or greater_
6
+ # <tt>Natto::MeCab</tt> is a wrapper class for the <tt>mecab</tt>
7
+ # parser.
13
8
  #
14
- # ## Installation
15
- # Install natto with the following gem command:
16
- # gem install natto
9
+ # <tt>Natto::DictionaryInfo</tt> is a wrapper for a <tt>Natto::MeCab</tt>
10
+ # instance's related dictionary information.
17
11
  #
18
- # ## Configuration
19
- # - natto will try to locate the <tt>mecab</tt> library based upon its runtime environment.
20
- # - In case of <tt>LoadError</tt>, please set the <tt>MECAB_PATH</tt> environment variable to the exact name/path to your <tt>mecab</tt> library.
12
+ # <tt>Natto::MeCabError</tt> is a general error class for the
13
+ # <tt>Natto</tt> module.
21
14
  #
22
- # e.g., for bash on UNIX/Linux
23
- # export MECAB_PATH=mecab.so
24
- # e.g., on Windows
25
- # set MECAB_PATH=C:\Program Files\MeCab\bin\libmecab.dll
26
- # e.g., for Cygwin
27
- # export MECAB_PATH=cygmecab-1
28
- #
29
- # ## Usage
30
- #
31
- # require 'natto'
32
- #
33
- # m = Natto::MeCab.new
34
- # => #<Natto::MeCab:0x28d93dd4 @options={}, \
35
- # @dicts=[#<Natto::DictionaryInfo:0x28d93d34>], \
36
- # @ptr=#<FFI::Pointer address=0x28af3e58>>
37
- # puts m.parse("すもももももももものうち")
38
- # すもも 名詞,一般,*,*,*,*,すもも,スモモ,スモモ
39
- # も 助詞,係助詞,*,*,*,*,も,モ,モ
40
- # もも 名詞,一般,*,*,*,*,もも,モモ,モモ
41
- # も 助詞,係助詞,*,*,*,*,も,モ,モ
42
- # もも 名詞,一般,*,*,*,*,もも,モモ,モモ
43
- # の 助詞,連体化,*,*,*,*,の,ノ,ノ
44
- # うち 名詞,非自立,副詞可能,*,*,*,うち,ウチ,ウチ
45
- # EOS
46
- # => nil
15
+ # Module <tt>Natto::Binding</tt> encapsulates methods and behavior
16
+ # which are made available via <tt>FFI</tt> bindings to <tt>mecab</tt>.
47
17
  module Natto
48
18
  # Version string for this Rubygem.
49
- VERSION = "0.0.8"
19
+ VERSION = "0.0.9"
50
20
  end
data/test/test_natto.rb CHANGED
@@ -1,9 +1,11 @@
1
- # -*- encoding: utf-8 -*-
1
+ # coding: utf-8
2
2
  $:.unshift('lib')
3
3
  require 'rubygems' if RUBY_VERSION.to_f < 1.9
4
4
  require 'test/unit'
5
5
  require 'natto'
6
6
 
7
+ # TestNatto encapsulates tests for the basic
8
+ # behavior of natto.
7
9
  class TestNatto < Test::Unit::TestCase
8
10
  def setup
9
11
  @klass = Class.new do
@@ -12,12 +14,15 @@ class TestNatto < Test::Unit::TestCase
12
14
  end
13
15
 
14
16
  def teardown
17
+ @klass = nil
15
18
  end
16
19
 
20
+ # Tests the class methods include callback.
17
21
  def test_classmethods_include
18
22
  assert_equal('0.98', @klass.mecab_version)
19
23
  end
20
24
 
25
+ # Tests the build_options_str function.
21
26
  def test_build_options_str
22
27
  res = Natto::MeCab.build_options_str
23
28
  assert_equal('', res)
@@ -82,6 +87,8 @@ class TestNatto < Test::Unit::TestCase
82
87
 
83
88
  end
84
89
 
90
+ # Tests the state of a Natto::MeCab instance
91
+ # after construction.
85
92
  def test_construction
86
93
  m = nil
87
94
  assert_nothing_raised do
@@ -102,6 +109,8 @@ class TestNatto < Test::Unit::TestCase
102
109
  assert_equal(opts, m.options)
103
110
  end
104
111
 
112
+ # Tests the initialize method for error cases for
113
+ # erroneous mecab options.
105
114
  def test_initialize_with_errors
106
115
  assert_raise Natto::MeCabError do
107
116
  Natto::MeCab.new(:output_format_type=>'not_defined_anywhere')
@@ -120,6 +129,10 @@ class TestNatto < Test::Unit::TestCase
120
129
  end
121
130
  end
122
131
 
132
+ # Tests the dictionary accessor method.
133
+ # Assumes that:
134
+ # a) system dictionary is /usr/local/lib/mecab/dic/ipadic/sys.dic
135
+ # b) system dictionary encoding is utf-8
123
136
  def test_dictionary_accessor
124
137
  m = Natto::MeCab.new
125
138
  dicts = m.dicts
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 8
9
- version: 0.0.8
8
+ - 9
9
+ version: 0.0.9
10
10
  platform: ruby
11
11
  authors:
12
12
  - Brooke M. Fujita
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-01-07 00:00:00 +09:00
17
+ date: 2011-01-13 00:00:00 +09:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -57,7 +57,7 @@ rdoc_options:
57
57
  - --title
58
58
  - "natto #{Natto::VERSION} -- Ruby-Mecab binding"
59
59
  - --main
60
- - README
60
+ - README.md
61
61
  - -c UTF-8
62
62
  require_paths:
63
63
  - lib