twss 0.0.4 → 0.0.5
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.
- data/README.markdown +2 -2
- data/lib/twss/engine.rb +1 -1
- data/lib/twss/trainer.rb +4 -6
- data/twss.gemspec +2 -3
- metadata +2 -15
data/README.markdown
CHANGED
@@ -3,7 +3,7 @@ TWSS
|
|
3
3
|
|
4
4
|
Because automation knows no bounds... including lowbrow comedy.
|
5
5
|
|
6
|
-
TWSS is a simple Bayes classifer trained off of a
|
6
|
+
TWSS is a simple Bayes classifer trained off of a twssstories.com.
|
7
7
|
|
8
8
|
Installation
|
9
9
|
------------
|
@@ -22,7 +22,7 @@ Usage
|
|
22
22
|
You can also adjust the scoring threshold for your comedic customization. The
|
23
23
|
lower the value, the more "obscure" the jokes can be.
|
24
24
|
|
25
|
-
TWSS.threshold =
|
25
|
+
TWSS.threshold = 5.0
|
26
26
|
|
27
27
|
It's far from perfect, but it's accurate enough to be funny. I'll probably
|
28
28
|
continue tweaking it some (increase the training set size and whatnot). I'm not
|
data/lib/twss/engine.rb
CHANGED
@@ -17,7 +17,7 @@ module TWSS
|
|
17
17
|
|
18
18
|
def initialize(options = {})
|
19
19
|
@data_file = options[:data_file] || DATA_FILE
|
20
|
-
@threshold ||= options[:threshold] || 7.
|
20
|
+
@threshold ||= options[:threshold] || 7.0
|
21
21
|
@classifier = load_classifier_from_file!(@data_file) || new_classifier
|
22
22
|
end
|
23
23
|
|
data/lib/twss/trainer.rb
CHANGED
@@ -4,12 +4,11 @@ module TWSS
|
|
4
4
|
|
5
5
|
class Trainer
|
6
6
|
|
7
|
-
attr_reader :engine
|
7
|
+
attr_reader :engine
|
8
8
|
|
9
9
|
def initialize(engine, options = {})
|
10
10
|
@engine = engine
|
11
11
|
engine.clear_state!
|
12
|
-
@training_percentage = options[:training_percentage] || 0.9
|
13
12
|
end
|
14
13
|
|
15
14
|
def train
|
@@ -66,7 +65,7 @@ module TWSS
|
|
66
65
|
false_positives = 0
|
67
66
|
total = 0
|
68
67
|
correct = 0
|
69
|
-
test_each(positive_test_file
|
68
|
+
test_each(positive_test_file) do |line, result|
|
70
69
|
if result
|
71
70
|
correct += 1
|
72
71
|
else
|
@@ -75,7 +74,7 @@ module TWSS
|
|
75
74
|
total += 1
|
76
75
|
end
|
77
76
|
|
78
|
-
test_each(negative_test_file
|
77
|
+
test_each(negative_test_file) do |line, result|
|
79
78
|
if !result
|
80
79
|
correct += 1
|
81
80
|
else
|
@@ -92,10 +91,9 @@ module TWSS
|
|
92
91
|
puts
|
93
92
|
end
|
94
93
|
|
95
|
-
def test_each(file,
|
94
|
+
def test_each(file, &blk)
|
96
95
|
i = 0
|
97
96
|
File.read(file).each_line do |line|
|
98
|
-
return if i > sample_size
|
99
97
|
l = line.strip
|
100
98
|
unless l.empty?
|
101
99
|
r = TWSS(l)
|
data/twss.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "twss"
|
3
|
-
s.version = "0.0.
|
3
|
+
s.version = "0.0.5"
|
4
4
|
s.platform = Gem::Platform::RUBY
|
5
5
|
s.authors = ["Ben VandenBos"]
|
6
6
|
s.email = "bvandenbos@gmail.com"
|
@@ -17,7 +17,6 @@ Gem::Specification.new do |s|
|
|
17
17
|
s.executables = `git ls-files`.split("\n").map{|f| f =~ /^bin\/(.*)/ ? $1 : nil}.compact
|
18
18
|
s.require_path = 'lib'
|
19
19
|
|
20
|
-
s.add_runtime_dependency("classifier", ["1.3.1"])
|
21
|
-
s.add_development_dependency("twitter", [">= 0"])
|
20
|
+
s.add_runtime_dependency("classifier", ["= 1.3.1"])
|
22
21
|
|
23
22
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 5
|
9
|
+
version: 0.0.5
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Ben VandenBos
|
@@ -47,19 +47,6 @@ dependencies:
|
|
47
47
|
version: 1.3.1
|
48
48
|
type: :runtime
|
49
49
|
version_requirements: *id002
|
50
|
-
- !ruby/object:Gem::Dependency
|
51
|
-
name: twitter
|
52
|
-
prerelease: false
|
53
|
-
requirement: &id003 !ruby/object:Gem::Requirement
|
54
|
-
none: false
|
55
|
-
requirements:
|
56
|
-
- - ">="
|
57
|
-
- !ruby/object:Gem::Version
|
58
|
-
segments:
|
59
|
-
- 0
|
60
|
-
version: "0"
|
61
|
-
type: :development
|
62
|
-
version_requirements: *id003
|
63
50
|
description: |-
|
64
51
|
Pre-trained "That's What She Said" Bayes classifier.
|
65
52
|
Given a string, returns true if it's a TWSS joke. Pre-trained from
|