RedditPostClassifierBot 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 24f519dba9e63cfe4f5c8bdccc5eb9bb4da91133
4
- data.tar.gz: 86691d72a1f186828759409dccab43da978df2a5
3
+ metadata.gz: dc702c8142af33798cd4105a225d66bb494de9d8
4
+ data.tar.gz: e4fbb1206147d9ba5f162e4d9f7c0e421a20d422
5
5
  SHA512:
6
- metadata.gz: 3f2ea6b4823fa43c6e255bba4ef51d93adc76189c9ebddae9738d8637f258c916bae51c5ed3d19c8692809567a9907fa77009ce262ad0f15e00705bdaff16635
7
- data.tar.gz: 5931d91769d21c412698d60d3e42fa16282a132cf586a0299f0c8fd023d6b80adec81c13efe7a3835b6ca54383c603bb2c9a8985af6fe49b2ee8ea0f174df01a
6
+ metadata.gz: c200ef8b3c100d43041c2cebe2f805ea2e75bcd666058acc06eaf4a23889c0ace7c5d3f116469b4c27e11242d06e8a1cec49d823a0d000bef53530ca2f838887
7
+ data.tar.gz: ea1839df63d9437e28174d258ede4783bd904f76a6cd128f2f49c9213bf3557ecb3a40a016e308e13168ffebfe79cbca09ecbed56986223e50f06a963c7abfee
@@ -16,4 +16,8 @@ module RedditPostClassifierBot
16
16
  def self.classify_posts(path)
17
17
  classifier.fetch_and_classify path
18
18
  end
19
+
20
+ def trained_classifier!
21
+ NBayesClassifier.trained? ? classifier : train_classifier
22
+ end
19
23
  end
@@ -2,6 +2,10 @@ module RedditPostClassifierBot
2
2
  class NBayesClassifier
3
3
  NBAYES_FILE = ENV.fetch "NBAYES_FILE_PATH", "./RPCB-nbayes.yml"
4
4
 
5
+ def self.trained?
6
+ File.exists?(NBAYES_FILE) && File.read(NBAYES_FILE).chomp.size > 100
7
+ end
8
+
5
9
  def initialize
6
10
  @nbayes = NBayes::Base.new
7
11
  end
@@ -1,3 +1,3 @@
1
1
  module RedditPostClassifierBot
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: RedditPostClassifierBot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Diego Salazar