omnicat 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,6 @@
1
1
  Master Branch
2
+ 0.2.1
3
+ # to_hash method delegated to 'hashable' gem
2
4
 
3
5
  0.2.0
4
6
  # bayes classifier moved to another gem which is 'omnicat-bayes'
data/README.md CHANGED
@@ -35,7 +35,7 @@ OmniCat allows you to change strategy on runtime.
35
35
  classifier.classify('I am happy :)')
36
36
  ...
37
37
  # change strategy to Support Vector Machine (SVM) on runtime
38
- classifier = OmniCat::Classifier.new(OmniCat::Classifiers::SVM.new())
38
+ classifier.strategy = OmniCat::Classifiers::SVM.new
39
39
  # now you do not need to re-train, add category and so on..
40
40
  # just classify with new strategy
41
41
  classifier.classify('I am happy :)')
data/Rakefile CHANGED
@@ -9,7 +9,7 @@ task :default => [ :test ]
9
9
  desc "Run all unit tests"
10
10
  Rake::TestTask.new do |t|
11
11
  t.libs << 'lib'
12
- t.test_files = FileList['lib/test/unit/*_test.rb']
12
+ t.test_files = FileList['test/unit/*_test.rb']
13
13
  t.verbose = true
14
14
  end
15
15
 
@@ -1,7 +1,6 @@
1
1
  require File.dirname(__FILE__) + '/omnicat/version'
2
2
  require File.dirname(__FILE__) + '/omnicat/configuration'
3
3
  require File.dirname(__FILE__) + '/omnicat/array'
4
- require File.dirname(__FILE__) + '/omnicat/hash'
5
4
  require File.dirname(__FILE__) + '/omnicat/base'
6
5
  require File.dirname(__FILE__) + '/omnicat/doc'
7
6
  require File.dirname(__FILE__) + '/omnicat/result'
@@ -1,16 +1,8 @@
1
+ require 'hashable'
2
+
1
3
  module OmniCat
2
4
  class Base
3
- # Returns Base object as Hash
4
- #
5
- # @return Base object instance variables in a Hash
6
- def to_hash
7
- hash = {}
8
- self.instance_variables.each do |key|
9
- if val = instance_variable_get(key)
10
- hash[key[1..-1].to_sym] = val.class.to_s.include?('OmniCat') ? val.to_hash : val
11
- end
12
- end
13
- hash
14
- end
5
+ include Hashable
6
+ def to_hash; self.to_dh; end
15
7
  end
16
8
  end
@@ -17,7 +17,7 @@ module OmniCat
17
17
  attr_accessor :uniq_token_count # Integer - Total uniq token count
18
18
 
19
19
  def initialize(strategy_hash = {})
20
- @categories = ::OmniCat::Hash.new
20
+ @categories = {}
21
21
  @category_count = strategy_hash[:category_count].to_i
22
22
  @category_size_limit = strategy_hash[:category_size_limit].to_i
23
23
  @doc_count = strategy_hash[:doc_count].to_i
@@ -1,3 +1,3 @@
1
1
  module OmniCat
2
- VERSION = "0.2.0"
2
+ VERSION = '0.2.1'
3
3
  end
@@ -4,20 +4,21 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'omnicat/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
- spec.name = "omnicat"
7
+ spec.name = 'omnicat'
8
8
  spec.version = OmniCat::VERSION
9
- spec.authors = ["Mustafa Turan"]
10
- spec.email = ["mustafaturan.net@gmail.com"]
9
+ spec.authors = ['Mustafa Turan']
10
+ spec.email = ['mustafaturan.net@gmail.com']
11
11
  spec.description = %q{A generalized framework for text classifications.}
12
12
  spec.summary = spec.description
13
- spec.homepage = "https://github.com/mustafaturan/omnicat"
14
- spec.license = "MIT"
13
+ spec.homepage = 'https://github.com/mustafaturan/omnicat'
14
+ spec.license = 'MIT'
15
15
 
16
16
  spec.files = `git ls-files`.split($/)
17
17
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
- spec.require_paths = ["lib"]
19
+ spec.require_paths = ['lib']
20
20
 
21
- spec.add_development_dependency "bundler", "~> 1.3"
22
- spec.add_development_dependency "rake"
21
+ spec.add_dependency 'hashable', '~> 0.1.0'
22
+ spec.add_development_dependency 'bundler', '~> 1.3'
23
+ spec.add_development_dependency 'rake'
23
24
  end
@@ -1,2 +1,2 @@
1
1
  require 'test/unit'
2
- require File.expand_path(File.join(File.dirname(__FILE__), '..', 'omnicat'))
2
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'omnicat'))
File without changes
File without changes
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omnicat
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,8 +9,24 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-07-06 00:00:00.000000000 Z
12
+ date: 2013-07-11 00:00:00.000000000 Z
13
13
  dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: hashable
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 0.1.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 0.1.0
14
30
  - !ruby/object:Gem::Dependency
15
31
  name: bundler
16
32
  requirement: !ruby/object:Gem::Requirement
@@ -65,16 +81,14 @@ files:
65
81
  - lib/omnicat/classifiers/strategy_internals/category.rb
66
82
  - lib/omnicat/configuration.rb
67
83
  - lib/omnicat/doc.rb
68
- - lib/omnicat/hash.rb
69
84
  - lib/omnicat/result.rb
70
85
  - lib/omnicat/version.rb
71
- - lib/test/test_helper.rb
72
- - lib/test/unit/array_test.rb
73
- - lib/test/unit/classifier_test.rb
74
- - lib/test/unit/classifiers/strategy_test.rb
75
- - lib/test/unit/doc_test.rb
76
- - lib/test/unit/hash_test.rb
77
86
  - omnicat.gemspec
87
+ - test/test_helper.rb
88
+ - test/unit/array_test.rb
89
+ - test/unit/classifier_test.rb
90
+ - test/unit/classifiers/strategy_test.rb
91
+ - test/unit/doc_test.rb
78
92
  homepage: https://github.com/mustafaturan/omnicat
79
93
  licenses:
80
94
  - MIT
@@ -100,4 +114,9 @@ rubygems_version: 1.8.23
100
114
  signing_key:
101
115
  specification_version: 3
102
116
  summary: A generalized framework for text classifications.
103
- test_files: []
117
+ test_files:
118
+ - test/test_helper.rb
119
+ - test/unit/array_test.rb
120
+ - test/unit/classifier_test.rb
121
+ - test/unit/classifiers/strategy_test.rb
122
+ - test/unit/doc_test.rb
@@ -1,13 +0,0 @@
1
- module OmniCat
2
- class Hash < ::Hash
3
- def to_hash
4
- hash = {}
5
- self.keys.each do |key|
6
- if val = self[key]
7
- hash[key] = val.class.to_s.include?('OmniCat') ? val.to_hash : val
8
- end
9
- end
10
- hash
11
- end
12
- end
13
- end
@@ -1,12 +0,0 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), '..', 'test_helper'))
2
-
3
- class TestHash < Test::Unit::TestCase
4
- def test_to_hash
5
- categories_hash = {
6
- "pos" => { doc_count: 0, docs: {}, tokens: {}, token_count: 0 }
7
- }
8
- categories = OmniCat::Hash.new
9
- categories["pos"] = OmniCat::Classifiers::StrategyInternals::Category.new(categories_hash["pos"])
10
- assert_equal(categories_hash, categories.to_hash)
11
- end
12
- end