Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,42 +29,48 @@ Metrics/BlockLength:
Exclude:
- 'test/**/*'
- 'lib/classifier/extensions/vector.rb'
- 'lib/classifier/cli.rb'

# Allow longer methods in complex algorithms (SVD, etc.)
# Allow longer methods in complex algorithms (SVD, etc.) and CLI
Metrics/MethodLength:
Max: 25
Exclude:
- 'test/**/*'
- 'lib/classifier/extensions/vector.rb'
- 'lib/classifier/lsi/content_node.rb'
- 'lib/classifier/cli.rb'

# Allow higher complexity for mathematical algorithms
# Allow higher complexity for mathematical algorithms and CLI
Metrics/AbcSize:
Max: 30
Exclude:
- 'test/**/*'
- 'lib/classifier/extensions/vector.rb'
- 'lib/classifier/lsi.rb'
- 'lib/classifier/lsi/content_node.rb'
- 'lib/classifier/cli.rb'

Metrics/CyclomaticComplexity:
Max: 10
Exclude:
- 'lib/classifier/extensions/vector.rb'
- 'lib/classifier/lsi/content_node.rb'
- 'lib/classifier/cli.rb'

Metrics/PerceivedComplexity:
Max: 10
Exclude:
- 'lib/classifier/extensions/vector.rb'
- 'lib/classifier/lsi/content_node.rb'
- 'lib/classifier/cli.rb'

# Class length limits - algorithms and tests can be longer
# Class length limits - algorithms, tests and CLI can be longer
Metrics/ClassLength:
Max: 250
Exclude:
- 'test/**/*'
- 'lib/classifier/lsi.rb'
- 'lib/classifier/cli.rb'

# SV_decomp is a standard algorithm name
Naming/MethodName:
Expand Down
15 changes: 14 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
classifier (2.2.0)
classifier (2.3.0)
fast-stemmer (~> 1.0)
matrix
mutex_m (~> 0.2)
Expand All @@ -23,12 +23,17 @@ GEM
securerandom (>= 0.3)
tzinfo (~> 2.0, >= 2.0.5)
uri (>= 0.13.1)
addressable (2.8.8)
public_suffix (>= 2.0.2, < 8.0)
ast (2.4.3)
base64 (0.3.0)
bigdecimal (4.0.1)
cgi (0.5.1)
concurrent-ruby (1.3.6)
connection_pool (3.0.2)
crack (1.0.1)
bigdecimal
rexml
csv (3.3.5)
date (3.5.1)
docile (1.4.1)
Expand All @@ -39,6 +44,7 @@ GEM
ffi (1.17.2-arm64-darwin)
ffi (1.17.2-x86_64-linux-gnu)
fileutils (1.8.0)
hashdiff (1.2.1)
i18n (1.14.8)
concurrent-ruby (~> 1.0)
json (2.18.0)
Expand All @@ -61,6 +67,7 @@ GEM
psych (5.3.1)
date
stringio
public_suffix (7.0.0)
racc (1.8.1)
rainbow (3.1.1)
rake (13.3.1)
Expand All @@ -80,6 +87,7 @@ GEM
psych (>= 4.0.0)
tsort
regexp_parser (2.11.3)
rexml (3.4.4)
rubocop (1.82.1)
json (~> 2.3)
language_server-protocol (~> 3.17.0.2)
Expand Down Expand Up @@ -134,6 +142,10 @@ GEM
unicode-emoji (~> 4.1)
unicode-emoji (4.2.0)
uri (1.1.1)
webmock (3.26.1)
addressable (>= 2.8.0)
crack (>= 0.3.2)
hashdiff (>= 0.4.0, < 2.0.0)

PLATFORMS
arm64-darwin-22
Expand All @@ -156,6 +168,7 @@ DEPENDENCIES
rubocop-minitest
simplecov
steep
webmock

BUNDLED WITH
4.0.3
6 changes: 6 additions & 0 deletions Steepfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ target :lib do

check 'lib'

# Stdlib dependencies for CLI
library 'fileutils'
library 'uri'
library 'net-http'
library 'json'

# Strict mode: report methods without type annotations
configure_code_diagnostics(D::Ruby.strict)

Expand Down
9 changes: 7 additions & 2 deletions classifier.gemspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
require_relative 'lib/classifier/version'

Gem::Specification.new do |s|
s.name = 'classifier'
s.version = '2.2.0'
s.version = Classifier::VERSION
s.summary = 'Text classification with Bayesian, LSI, Logistic Regression, kNN, and TF-IDF vectorization.'
s.description = 'A Ruby library for text classification featuring Naive Bayes, LSI (Latent Semantic Indexing), ' \
'Logistic Regression, and k-Nearest Neighbors classifiers. Includes TF-IDF vectorization, ' \
Expand All @@ -16,7 +18,9 @@ Gem::Specification.new do |s|
'changelog_uri' => 'https://github.com/cardmagic/classifier/releases'
}
s.required_ruby_version = '>= 3.1'
s.files = Dir['{lib,sig}/**/*.{rb,rbs}', 'ext/**/*.{c,h,rb}', 'bin/*', 'LICENSE', '*.md', 'test/*']
s.files = Dir['{lib,sig,exe}/**/*.{rb,rbs}', 'ext/**/*.{c,h,rb}', 'exe/*', 'bin/*', 'LICENSE', '*.md', 'test/*']
s.bindir = 'exe'
s.executables = ['classifier']
s.extensions = ['ext/classifier/extconf.rb']
s.license = 'LGPL'

Expand All @@ -28,4 +32,5 @@ Gem::Specification.new do |s|
s.add_development_dependency 'rbs-inline'
s.add_development_dependency 'rdoc'
s.add_development_dependency 'rake-compiler'
s.add_development_dependency 'webmock'
end
9 changes: 9 additions & 0 deletions exe/classifier
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env ruby
require 'classifier/cli'

result = Classifier::CLI.new(ARGV).run

warn result[:error] unless result[:error].empty?
puts result[:output] unless result[:output].empty?

exit result[:exit_code]
1 change: 1 addition & 0 deletions lib/classifier.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
# License:: LGPL

require 'rubygems'
require 'classifier/version'
require 'classifier/errors'
require 'classifier/storage'
require 'classifier/streaming'
Expand Down
Loading