File tree 3 files changed +40
-2
lines changed
3 files changed +40
-2
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,8 @@ target :lib do
10
10
check "lib/compsci/elo.rb"
11
11
check "lib/compsci/fibonacci.rb"
12
12
check "lib/compsci/fit.rb"
13
+ # ...
14
+ check "lib/compsci/oracle.rb"
13
15
14
16
# library "pathname" # Standard libraries
15
17
# library "strong_json" # Gems
Original file line number Diff line number Diff line change @@ -64,14 +64,14 @@ def percentage
64
64
65
65
def prediction
66
66
highest = -1
67
- best = nil
67
+ best = ''
68
68
@freq [ @ring . to_s ] &.each { |val , count |
69
69
if count > highest
70
70
best = val
71
71
highest = count
72
72
end
73
73
}
74
- best
74
+ best . empty? ? nil : best
75
75
end
76
76
77
77
def update ( char )
Original file line number Diff line number Diff line change
1
+ module CompSci
2
+ module Oracle
3
+ class Ring
4
+ @limit: Integer
5
+ @cursor: Integer
6
+ @storage: Array[untyped ]
7
+
8
+ attr_reader limit: Integer
9
+ attr_reader cursor: Integer
10
+ attr_reader storage: Array[untyped ]
11
+
12
+ def initialize : (?Integer limit) -> void
13
+ def update : (untyped val) -> self
14
+ def to_s : () -> String
15
+ def full? : () -> bool
16
+ end
17
+
18
+ class Model
19
+ @ring: Ring
20
+ @freq: Hash[String, Hash[String, Integer]]
21
+ @pred: Hash[Symbol, Integer]
22
+
23
+ attr_reader ring: Ring
24
+ attr_reader freq: Hash[String, Hash[String, Integer]]
25
+ attr_reader pred: Hash[Symbol, Integer]
26
+
27
+ def initialize : (?Integer limit) -> void
28
+ def to_s : () -> String
29
+ def ratio : () -> Rational
30
+ def percentage : () -> Float
31
+ def prediction : () -> String?
32
+ def update : (String char) -> self
33
+ def accept : (String str) -> self
34
+ end
35
+ end
36
+ end
You can’t perform that action at this time.
0 commit comments