natto2classifier 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 51ad6e9876016e7a4202e0c5e97e2c1e67d208c4
4
- data.tar.gz: 9684166a82e326f30b5b21a63658cd708540baad
3
+ metadata.gz: f8ef6d3851edf130a6a2b7ca3a6ba7c305cf39be
4
+ data.tar.gz: a73d1ab45544793c3a27a704233b29a8a1898b04
5
5
  SHA512:
6
- metadata.gz: b2811c6898c36d2e5d37267023a2f6121e38fa953e3c3d7191225b8d704c0c1d83c651f20353a09530739c46a8d0239f1d638153ffc221cd21509f6785323e44
7
- data.tar.gz: a9e57167f00b04feac3653cbe2a8362ac0cfc0946dad2e34912764173a03ca35c8db77404feb285cde009e8380a26033b8e501ab53b9a6e873d7cfc63be52e77
6
+ metadata.gz: b1b3dc2ca4d798aaffbcd1be95bd03d62a822550520b029b734a13265161582ca82c25d1720e6d05ebcab6c1c126e62e98b64ac345403e52c4b544914a0edc4a
7
+ data.tar.gz: 89fcf93bc0d47633659bfffa12b375d34f25cad5a8a774a7746b3c9e7dcbc99cba8eb6a72009b29d6660c41deb029eea2609c5c79fe8aae224c19b5ab1c0a2f4
data/.circleci/config.yml CHANGED
@@ -12,13 +12,3 @@ workflows:
12
12
  test:
13
13
  jobs:
14
14
  - test
15
- scheduled-workflow:
16
- triggers:
17
- - schedule:
18
- cron: "0 * * * *"
19
- filters:
20
- branches:
21
- only:
22
- - master
23
- jobs:
24
- - test
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- natto2classifier (0.2.0)
4
+ natto2classifier (0.3.0)
5
5
  classifier-reborn
6
6
  natto
7
7
  rb-gsl
data/README.md CHANGED
@@ -39,6 +39,17 @@ lsi.classify '納豆はいつも朝食べている' #=> '朝食'
39
39
  lsi.find_related '納豆はいつも朝食べている' #=> ['今日 キョウ の ノ 朝食 チョウショク は ハ 納豆 ナットウ だ ダ', '今日 キョウ の ノ 夕食 ユウショク は ハ 湯豆腐 ユドウフ だ ダ']
40
40
  ```
41
41
 
42
+ ### validate methods
43
+
44
+ ```
45
+ sample_data = CSV.read('./data/train.csv')
46
+ bayes = Natto2classifier::Bayes.new '朝食', '夕食'
47
+ cross_validate(bayes, sample_data) #=> report...
48
+
49
+ test_data, training_data = sample_data.partition.with_index { |_, i| (i % 2).zero? }
50
+ validate(bayes, training_data, test_data) #=> {"夕食"=>{"夕食"=>3, "朝食"=>0}, "朝食"=>{"夕食"=>...}}
51
+ ```
52
+
42
53
  ## Development
43
54
 
44
55
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -3,3 +3,4 @@ require 'natto2classifier/natto'
3
3
  require 'classifier-reborn'
4
4
  require 'natto2classifier/bayes'
5
5
  require 'natto2classifier/lsi'
6
+ require 'natto2classifier/validator'
@@ -0,0 +1,17 @@
1
+
2
+ module Natto2classifier
3
+ # It is a library that classifies Japanese language.
4
+ class Bayes < ClassifierReborn::Bayes
5
+ alias_method :__train__, :train
6
+ alias_method :__classify__, :classify
7
+ private :__train__, :__classify__
8
+
9
+ def train(category, word)
10
+ __train__ category, Natto2classifier::Natto.parse(word).join(' ')
11
+ end
12
+
13
+ def classify(word)
14
+ __classify__ Natto2classifier::Natto.parse(word).join(' ')
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,22 @@
1
+
2
+ module Natto2classifier
3
+ # It is a library that classifies Japanese language.
4
+ class LSI < ClassifierReborn::LSI
5
+ alias_method :__add_item__, :add_item
6
+ alias_method :__classify__, :classify
7
+ alias_method :__find_related__, :find_related
8
+ private :__add_item__, :__classify__, :__find_related__
9
+
10
+ def add_item(word, category)
11
+ __add_item__ Natto2classifier::Natto.parse(word).join(' '), category
12
+ end
13
+
14
+ def classify(word)
15
+ __classify__ Natto2classifier::Natto.parse(word).join(' ')
16
+ end
17
+
18
+ def find_related(word)
19
+ __find_related__ Natto2classifier::Natto.parse(word).join(' ')
20
+ end
21
+ end
22
+ end
@@ -1,3 +1,3 @@
1
1
  module Natto2classifier
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  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.2.0
4
+ version: 0.3.0
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-27 00:00:00.000000000 Z
11
+ date: 2018-05-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -129,6 +129,8 @@ files:
129
129
  - bin/setup
130
130
  - data/train.csv
131
131
  - lib/natto2classifier.rb
132
+ - lib/natto2classifier/bayes.rb
133
+ - lib/natto2classifier/lsi.rb
132
134
  - lib/natto2classifier/natto.rb
133
135
  - lib/natto2classifier/version.rb
134
136
  - natto2classifier.gemspec