natto 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +23 -0
- data/lib/natto.rb +39 -0
- data/test/test_natto.rb +20 -0
- metadata +83 -0
data/LICENSE
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
Copyright (c) 2010, Brooke M. Fujita
|
2
|
+
All rights reserved.
|
3
|
+
|
4
|
+
Redistribution and use in source and binary forms, with or without modification, are
|
5
|
+
permitted provided that the following conditions are met:
|
6
|
+
|
7
|
+
* Redistributions of source code must retain the above
|
8
|
+
copyright notice, this list of conditions and the
|
9
|
+
following disclaimer.
|
10
|
+
|
11
|
+
* Redistributions in binary form must reproduce the above
|
12
|
+
copyright notice, this list of conditions and the
|
13
|
+
following disclaimer in the documentation and/or other
|
14
|
+
materials provided with the distribution.
|
15
|
+
|
16
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
|
17
|
+
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
18
|
+
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
19
|
+
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
20
|
+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
21
|
+
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
22
|
+
TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
23
|
+
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/lib/natto.rb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'rubygems' if RUBY_VERSION.to_f < 1.9
|
2
|
+
require 'ffi'
|
3
|
+
require 'rbconfig'
|
4
|
+
|
5
|
+
module Natto
|
6
|
+
extend FFI::Library
|
7
|
+
|
8
|
+
def self.included(base)
|
9
|
+
base.extend(ClassMethods)
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.find_library
|
13
|
+
host_os = RbConfig::CONFIG['host_os']
|
14
|
+
|
15
|
+
if host_os =~ /mswin|mingw/
|
16
|
+
raise LoadError, "Please set MECAB_PATH to full path to libmecab.dll"
|
17
|
+
elsif host_os =~ /cygwin/
|
18
|
+
'cygmecab-1'
|
19
|
+
else
|
20
|
+
'mecab'
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
ffi_lib(ENV['MECAB_PATH'] || find_library)
|
25
|
+
|
26
|
+
attach_function :mecab_new2, [:string], :pointer
|
27
|
+
attach_function :mecab_version, [], :string
|
28
|
+
attach_function :mecab_sparse_tostr, [:pointer, :string], :string
|
29
|
+
attach_function :mecab_strerror, [:pointer],:string
|
30
|
+
attach_function :mecab_destroy, [:pointer], :void
|
31
|
+
|
32
|
+
module ClassMethods
|
33
|
+
def mecab_version
|
34
|
+
Natto.mecab_version
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
|
data/test/test_natto.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
$:.unshift('lib')
|
2
|
+
|
3
|
+
require 'rubygems' if RUBY_VERSION.to_f < 1.9
|
4
|
+
require 'test/unit'
|
5
|
+
require 'natto'
|
6
|
+
|
7
|
+
class TestNatto < Test::Unit::TestCase
|
8
|
+
def setup
|
9
|
+
end
|
10
|
+
|
11
|
+
def teardown
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_classmethods_include
|
15
|
+
klass = Class.new do
|
16
|
+
include Natto
|
17
|
+
end
|
18
|
+
assert_equal('0.98', klass.mecab_version)
|
19
|
+
end
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: natto
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
version: 0.0.1
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Brooke M. Fujita
|
13
|
+
autorequire: natto
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-12-14 00:00:00 +09:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: ffi
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
segments:
|
29
|
+
- 0
|
30
|
+
- 6
|
31
|
+
- 3
|
32
|
+
version: 0.6.3
|
33
|
+
type: :runtime
|
34
|
+
version_requirements: *id001
|
35
|
+
description: " natto combines the Ruby programming language\n with MeCab, the part-of-speech and morphological\n analyzer for the Japanese language.\n"
|
36
|
+
email: buruzaemon@gmail.com
|
37
|
+
executables: []
|
38
|
+
|
39
|
+
extensions: []
|
40
|
+
|
41
|
+
extra_rdoc_files: []
|
42
|
+
|
43
|
+
files:
|
44
|
+
- lib/natto.rb
|
45
|
+
- test/test_natto.rb
|
46
|
+
- LICENSE
|
47
|
+
has_rdoc: true
|
48
|
+
homepage: http://code.google.com/p/natto/
|
49
|
+
licenses:
|
50
|
+
- BSD
|
51
|
+
post_install_message:
|
52
|
+
rdoc_options: []
|
53
|
+
|
54
|
+
require_paths:
|
55
|
+
- lib
|
56
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
segments:
|
62
|
+
- 1
|
63
|
+
- 8
|
64
|
+
- 7
|
65
|
+
version: 1.8.7
|
66
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
67
|
+
none: false
|
68
|
+
requirements:
|
69
|
+
- - ">="
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
segments:
|
72
|
+
- 0
|
73
|
+
version: "0"
|
74
|
+
requirements:
|
75
|
+
- none
|
76
|
+
- MeCab, 0.98 or greater
|
77
|
+
rubyforge_project:
|
78
|
+
rubygems_version: 1.3.7
|
79
|
+
signing_key:
|
80
|
+
specification_version: 3
|
81
|
+
summary: natto combines the Ruby programming language with MeCab, the part-of-speech and morphological analyzer for the Japanese language.
|
82
|
+
test_files:
|
83
|
+
- test/test_natto.rb
|