tiny-classifier 2.0 → 2.1
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 +4 -4
- data/README.md +1 -1
- data/lib/tiny-classifier/base.rb +20 -2
- data/lib/tiny-classifier/classifier.rb +1 -1
- data/lib/tiny-classifier/retrainer.rb +1 -1
- data/lib/tiny-classifier/tokenizer.rb +1 -1
- data/lib/tiny-classifier/trainer.rb +4 -4
- data/lib/tiny-classifier/untrainer.rb +1 -1
- data/tiny-classifier.gemspec +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7eb179e8a3a17711921f6bd0af6132909ace2f90
|
4
|
+
data.tar.gz: 2f029f934ddb3f5277980228800fa24093491bab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9ecc0831b783aed6891e09fe73260f0eef63f021e450bf4db89cea267b4797cffade8f74b05530a058646d77ca1265a24ea7287e6754e132ec1e724d0ae21611
|
7
|
+
data.tar.gz: aa5e0822ebcbc19b5497f1596be44b3b01e0fe184903d8b111fa9eae635f5bfd8c94ed34bda5a98658514cf10d185806abbd0eb12a124beba92943750bf107a0
|
data/README.md
CHANGED
@@ -67,7 +67,7 @@ positive
|
|
67
67
|
|
68
68
|
### Common
|
69
69
|
|
70
|
-
`-
|
70
|
+
`-c`, `--categories=CATEGORIES` (required)
|
71
71
|
: A comman-separated list of categories. You should use only alphabetic characters. (Non-alphabetical characters will cause problems.)
|
72
72
|
|
73
73
|
`-d`, `--data-dir=PATH` (optional)
|
data/lib/tiny-classifier/base.rb
CHANGED
@@ -25,6 +25,7 @@ module TinyClassifier
|
|
25
25
|
def initialize
|
26
26
|
@tokenizer = Tokenizer.new
|
27
27
|
@data_dir = Dir.pwd
|
28
|
+
@verbose = false
|
28
29
|
end
|
29
30
|
|
30
31
|
def parse_command_line_options(command_line_options)
|
@@ -51,6 +52,7 @@ module TinyClassifier
|
|
51
52
|
parser.on("-c CATEGORIES", "--categories=CATEGORIES",
|
52
53
|
"List of categories (comma-separated)") do |categories|
|
53
54
|
@categories = normalize_categories(categories)
|
55
|
+
log("categories: #{@categories}")
|
54
56
|
end
|
55
57
|
|
56
58
|
parser.on("-t TOKENIZER", "--tokenizer=TOKENIZER",
|
@@ -58,6 +60,11 @@ module TinyClassifier
|
|
58
60
|
@tokenizer.type = tokenizer
|
59
61
|
end
|
60
62
|
|
63
|
+
parser.on("-v", "--verbose",
|
64
|
+
"Output internal information (for debugging)") do |verbose|
|
65
|
+
@verbose = verbose
|
66
|
+
end
|
67
|
+
|
61
68
|
parser
|
62
69
|
end
|
63
70
|
|
@@ -107,12 +114,23 @@ module TinyClassifier
|
|
107
114
|
|
108
115
|
def prepare_input
|
109
116
|
unless File.pipe?(STDIN)
|
110
|
-
|
117
|
+
error("Error: No effective input. You need to give any input via the STDIN.")
|
111
118
|
exit(false)
|
112
119
|
end
|
113
120
|
@input = $stdin.readlines.join(" ")
|
114
|
-
@tokenizer.tokenize(@input)
|
121
|
+
@input = @tokenizer.tokenize(@input)
|
122
|
+
log("tokenizer: #{@tokenizer.type}")
|
115
123
|
@input.strip!
|
124
|
+
log("input: #{@input}")
|
125
|
+
@input
|
126
|
+
end
|
127
|
+
|
128
|
+
def error(message)
|
129
|
+
STDERR.puts(message)
|
130
|
+
end
|
131
|
+
|
132
|
+
def log(message)
|
133
|
+
STDERR.puts(message) if @verbose
|
116
134
|
end
|
117
135
|
end
|
118
136
|
end
|
@@ -35,7 +35,7 @@ module TinyClassifier
|
|
35
35
|
@category = params[:category]
|
36
36
|
prepare_category
|
37
37
|
if input.empty?
|
38
|
-
|
38
|
+
error("Error: No effective input.")
|
39
39
|
false
|
40
40
|
else
|
41
41
|
classifier.send("train_#{@category}", input)
|
@@ -47,19 +47,19 @@ module TinyClassifier
|
|
47
47
|
private
|
48
48
|
def prepare_category
|
49
49
|
unless @category
|
50
|
-
|
50
|
+
error("Error: You need to specify the category for the input.")
|
51
51
|
exit(false)
|
52
52
|
end
|
53
53
|
|
54
54
|
@category = @category.downcase.strip
|
55
55
|
|
56
56
|
if @category.empty?
|
57
|
-
|
57
|
+
error("Error: You need to specify the category for the input.")
|
58
58
|
exit(false)
|
59
59
|
end
|
60
60
|
|
61
61
|
unless @categories.include?(@category.capitalize)
|
62
|
-
|
62
|
+
error("Error: You need to specify one of valid categories: #{@categories.join(', ')}")
|
63
63
|
exit(false)
|
64
64
|
end
|
65
65
|
end
|
data/tiny-classifier.gemspec
CHANGED
@@ -21,7 +21,7 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "lib"))
|
|
21
21
|
|
22
22
|
Gem::Specification.new do |spec|
|
23
23
|
spec.name = "tiny-classifier"
|
24
|
-
spec.version = "2.
|
24
|
+
spec.version = "2.1"
|
25
25
|
spec.homepage = "https://github.com/piroor/tiny-classifier"
|
26
26
|
spec.authors = ["YUKI \"Piro\" Hiroshi"]
|
27
27
|
spec.email = ["piro.outsider.reflex@gmail.com"]
|