Skip to content

Commit c508865

Browse files
committed
fix: add RBS inline annotations for @min_word_length
Add missing instance variable declarations for Steep type checker: - @min_word_length in Bayes, TFIDF, LogisticRegression, LSI - @config and method signatures in Config module These annotations allow the type checker to properly verify the new min_word_length parameter added in this PR.
1 parent 2926338 commit c508865

5 files changed

Lines changed: 12 additions & 1 deletion

File tree

lib/classifier/bayes.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class Bayes # rubocop:disable Metrics/ClassLength
2020
# @rbs @cached_vocab_size: Integer?
2121
# @rbs @dirty: bool
2222
# @rbs @storage: Storage::Base?
23+
# @rbs @min_word_length: Integer
2324

2425
attr_accessor :storage
2526

lib/classifier/config.rb

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,29 @@
11
# rbs_inline: enabled
22

33
module Classifier
4+
# @rbs @config: Config?
5+
46
# This lazy initialization is not thread-safe.
57
# In multi-threaded environments, ensure this method is called
68
# or configuration is set explicitly during startup before using classifiers.
9+
# @rbs () -> Config
710
def config
811
@config ||= Config.new
912
end
1013

14+
# @rbs () { (Config) -> void } -> void
1115
def configure(&block)
12-
block.call(config)
16+
block&.call(config)
1317
end
1418

1519
module_function :config, :configure
1620

1721
class Config
22+
# @rbs @min_word_length: Integer
23+
1824
attr_accessor :min_word_length #: Integer
1925

26+
# @rbs () -> void
2027
def initialize
2128
@min_word_length = 3
2229
end

lib/classifier/logistic_regression.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class LogisticRegression # rubocop:disable Metrics/ClassLength
3434
# @rbs @fitted: bool
3535
# @rbs @dirty: bool
3636
# @rbs @storage: Storage::Base?
37+
# @rbs @min_word_length: Integer
3738

3839
attr_accessor :storage
3940

lib/classifier/lsi.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ class LSI
8080
# @rbs @u_matrix: Matrix?
8181
# @rbs @max_rank: Integer
8282
# @rbs @initial_vocab_size: Integer?
83+
# @rbs @min_word_length: Integer
8384

8485
attr_reader :word_list, :singular_values
8586
attr_accessor :auto_rebuild, :storage

lib/classifier/tfidf.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class TFIDF
2828
# @rbs @fitted: bool
2929
# @rbs @dirty: bool
3030
# @rbs @storage: Storage::Base?
31+
# @rbs @min_word_length: Integer
3132

3233
attr_reader :vocabulary, :idf, :num_documents
3334
attr_accessor :storage

0 commit comments

Comments
 (0)