natto2classifier 0.1.0 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/natto2classifier/natto.rb +4 -4
- data/lib/natto2classifier/version.rb +1 -1
- data/lib/natto2classifier.rb +3 -9
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 02b109066fdf91265548ae0c5d134540b133abf6
|
4
|
+
data.tar.gz: 897e64f5e80a5a9bf6148cfd63aec5d4088f31f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d04874ddf991c810524e1dd8d496037416ad14b85032e9ad4fbc0ec82fd6331e4d223e92c2b2f32d7942e3ec9f2b5c05bbdae2cb33d2e442993a379621e7560
|
7
|
+
data.tar.gz: 35dfad66177cbce511c1b301a43e6f8683cda0a366ad1ce9ab609e080f4d4becac8772a9192dd9b07a6b75bb5edd20432a9e27ef83b650d5e054f5dc38bc94ca
|
data/Gemfile.lock
CHANGED
@@ -4,11 +4,11 @@ require 'natto'
|
|
4
4
|
module Natto2classifier
|
5
5
|
class Natto
|
6
6
|
def self.parse(word)
|
7
|
-
|
8
|
-
|
9
|
-
nm = ::Natto::MeCab.new('-F%m')
|
7
|
+
nm = ::Natto::MeCab.new('-F%m\s%f[7]')
|
10
8
|
results = []
|
11
|
-
nm.enum_parse(word).each
|
9
|
+
nm.enum_parse(word.to_s).each do |n|
|
10
|
+
results << n.feature if !n.is_eos?
|
11
|
+
end
|
12
12
|
results
|
13
13
|
end
|
14
14
|
end
|
data/lib/natto2classifier.rb
CHANGED
@@ -4,19 +4,13 @@ require 'classifier-reborn'
|
|
4
4
|
|
5
5
|
module Natto2classifier
|
6
6
|
# It is a library that classifies Japanese language.
|
7
|
-
class Bayes
|
8
|
-
def initialize(*category)
|
9
|
-
raise 'category is not exists' if category.nil?
|
10
|
-
raise 'category is not array' unless category.is_a?(Array)
|
11
|
-
@bayes = ClassifierReborn::Bayes.new(*category)
|
12
|
-
end
|
13
|
-
|
7
|
+
class Bayes < ClassifierReborn::Bayes
|
14
8
|
def train(category, word)
|
15
|
-
|
9
|
+
super category, Natto2classifier::Natto.parse(word).join(' ')
|
16
10
|
end
|
17
11
|
|
18
12
|
def classify(word)
|
19
|
-
|
13
|
+
super Natto2classifier::Natto.parse(word).join(' ')
|
20
14
|
end
|
21
15
|
end
|
22
16
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: natto2classifier
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kanayannet
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-04-
|
11
|
+
date: 2018-04-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|