te_rex 0.0.5 → 0.0.10

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: 17bee1b2969c5ea0885ee13cab910a660315c186
4
- data.tar.gz: d68c27c7666231c8e1d3431a495d3f6f93b9a32d
3
+ metadata.gz: 41cbaf3893f705db1f366bdf247e0882971d860b
4
+ data.tar.gz: 909c02dd6578c76bdc5ec7ae4cab8f3b7cedd8d1
5
5
  SHA512:
6
- metadata.gz: e7f412936cb643c27057eb2ba8f3f4c480e293ffa816f4f4d1724957d0a39710cc977e5e6076fdf0f3ea96cb29c19b99a88f873eafc5ebd5ecacdaa259c2eaf2
7
- data.tar.gz: 440189ed0d1f93b98f6cd0121642b71c5013f71ae9804e10d4d4fdb455732e48c2448c9931c76fd019ad6e544fc49babdf2f2e40950cc431bcf64b33f12c7e41
6
+ metadata.gz: b9878b1e86ec13e17dd892abc4c615e1e369f692ea020413f121687af8b70c50a597557f7f36674f2a87464657edd62edd9f4ca62ab901fe3e042d98443180b8
7
+ data.tar.gz: 08a16cf36d77697253a56147fc3903f505ef5c09ebbfa7eb6f03474e44f87418a29a8c4640c8a46fb242cc441a39e193fa57bb9a8218653095eec9b3c519451e
data/lib/te_rex/bayes.rb CHANGED
@@ -6,10 +6,15 @@ module TeRex
6
6
  class Bayes
7
7
 
8
8
  attr_accessor :category_counts, :total_words
9
+ attr_reader :messages
9
10
 
11
+ # categories = [{:tag => "Thing1", :msg => "Thing1 message"}, {:tag => "Thing2", :msg => "Thing2 message"}]
12
+ # initialize({:tag => "Refund", :msg => "You'll get a refund"}, {:tag => "Nonrefund", :msg => "You won't get a refund"})
10
13
  def initialize(*categories)
11
- @clasif = Hash.new
12
- categories.each {|cat| @clasif[TeRex::Format.category_term(cat)] = Hash.new}
14
+ @clasif = Hash.new
15
+ @messages = Hash.new
16
+ categories.each {|cat| @clasif[TeRex::Format.category_term(cat[:tag])] = Hash.new}
17
+ categories.each {|cat| @messages[cat[:tag]] = cat[:msg]}
13
18
  @total_words = 0
14
19
  @category_counts = Hash.new(0)
15
20
  end
@@ -18,7 +23,7 @@ module TeRex
18
23
  category = TeRex::Format.category_term(ctgry)
19
24
  @category_counts[category] += 1
20
25
 
21
- BayesData.index_frequency(text).each do |word, count|
26
+ BayesData.index_frequency(text).each do |word, count|
22
27
  @clasif[category][word] ||= 0
23
28
  @clasif[category][word] += count
24
29
 
@@ -46,7 +51,8 @@ module TeRex
46
51
  end
47
52
 
48
53
  def classify(text)
49
- (classifications(text).sort_by{|a| -a[1]})[0][0]
54
+ tag = (classifications(text).sort_by{|a| -a[1]})[0][0]
55
+ [tag, @messages[tag]]
50
56
  end
51
57
 
52
58
  def categories
@@ -59,7 +65,7 @@ module TeRex
59
65
  @clasif.each_pair do |term,val|
60
66
  cc = self.category_counts[term]
61
67
  train_ratio = (@total_words/cc).to_f
62
- tmp << [(train_ratio > max_threshold), term, "description" => {"training_ratio" => "#{train_ratio}", "threshold" => "#{max_threshold}", "category_counts" => "#{cc}", "total_words" => "#{@total_words}"}]
68
+ tmp << [(train_ratio >= max_threshold), term, "description" => {"training_ratio" => "#{train_ratio}", "threshold" => "#{max_threshold}", "category_counts" => "#{cc}", "total_words" => "#{@total_words}"}]
63
69
  end
64
70
  tmp
65
71
  end
@@ -1,3 +1,3 @@
1
1
  module TeRex
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.10"
3
3
  end
data/lib/te_rex.rb CHANGED
@@ -1,3 +1,10 @@
1
+ #require 'simplecov'
2
+ #SimpleCov.command_name 'mt'
3
+ #
4
+ #SimpleCov.start do
5
+ # add_filter 'test/test_modules'
6
+ #end
7
+
1
8
  require_relative "format/format"
2
9
  require_relative "format/corpus/brown_file"
3
10
  require_relative "format/corpus/basic_file"
@@ -0,0 +1,9 @@
1
+ require 'simplecov'
2
+ SimpleCov.command_name 'mt'
3
+
4
+ SimpleCov.start do
5
+ add_filter 'test/modules'
6
+
7
+ add_group 'Formatter', 'lib/format'
8
+ add_group 'Core', 'lib/te_lrex'
9
+ end
@@ -25,7 +25,6 @@ module TeRex
25
25
  "- 12 NOON HOTEL TIME DAY OF ARRIVAL TO AVOID BILLING OF 1NT ROOM AND TAX OR FORFEITURE OF DEPOSIT",
26
26
  "RESERVATIONS MUST BE CANCELLED BY 1600/4PM DAY OF ARRIVAL LOCAL HOTEL TIME TO AVOID A PENALTY OF ONE NIGHT ROOM AND TAX CHARGE. NOTE- INDIVIDUAL PLANS MAY VARY. PLEASE READ INDIVIDUAL DISPLAY FOR MORE INFORMATION. **50.00USD EARLY DEPARTURE FEE** .",
27
27
  "- RESERVATIONS BOOKED 8 DAYS OR MORE PRIOR TO ARRIVAL MUST BE CANCELLED 7 DAYS PRIOR TO ARRIVAL TO RECEIVE REFUND - RESERVATIONS BOOKED WITHIN 7 DAYS OF ARRIVAL FORFEIT DEPOSIT OF 3 NIGHTS ROOM AND TAX",
28
- "ALL RESERVATIONS MUST BE CANCELLED 24 HOURS PRIOR TO HOST TIME UNLESS DEPOSIT REQUIRED IF THIS RESERVATION HAS BEEN MADE ELECTRONICALLY PLEASE CANCEL IT ELECTRONICALLY TO AVOID CONFUSION AND A NO SHOW BILL POLICY SUBJECT TO CHANGE .",
29
28
  "PLEASE REFER TO RATE DETAILS AT THE TIME OF BOOKING FOR CANCELLATION POLICY. PLEASE NOTE THAT POLICY IS SUBJECT TO CHANGES WITHOUT NOTICE."
30
29
  ]
31
30
  end
@@ -3,6 +3,7 @@ module TeRex
3
3
  UNKNOWN = [
4
4
  "The cancellation policy will be determined when the rate is validated.",
5
5
  "-CANCEL POLICY MAY VARY BY DAY OF WEEK AND SEASON. THE MOST ACCURATE CANCEL POLICY IS ADVISED DURING BOOKING PROCESS. IN CASE OF A NO-SHOW THE CREDIT CARD WILL BE CHARGED ONE NIGHT STAY. OUR SYSTEM ACKNOWLEDGES ALL PROPERLY CANCELED RESERVATIONS BY RETURNING A CANCELLATION NUMBER. DO NOT ASSUME YOUR RESERVATION IS CANCELED IF YOU HAVE NOT RECEIVED A CANCELLATION NUMBER IN YOUR PNR OR BOOKING FILE. IF YOU DO NOT RECEIVE A CANCELLATION NUMBER, PLEASE CALL THE CHOICE GDS DEPARTMENT AT 1-866-953-4570",
6
+ "CANCELLATION DEADLINES MAY VARY BY DATES OF ARRIVAL/ SPECIAL EVENTS OR BY RATE PLAN. PLEASE READ THE RATE RULES FOR YOUR RESERVATION FOR THE EXACT DEADLINE. FAILURE TO CANCEL WITHIN THE DEADLINE WILL RESULT IN A CANCELLATION FEE THAT COULD RANGE FROM 1 NIGHT UP TO THE TOTAL AMOUNT OF STAY. NON REFUNDABLE RATES CANNOT BE CANCELLED AND ARE SUBJECT TO FULL AMOUNT OF STAY PENALTY. -EARLY CHECKOUT POLICY -NO CHARGE FOR EARLY DEPARTURE AS LONG AS THE GUEST CHECKS OUT BY 12PM EASTERN STANDARD TIME -EXCEPTIONS MAY APPLY DURING SPECIAL EVENTS OR CONVENTIONS - SEE RATE RULES.",
6
7
  "-14JAN02 - END - CANCEL POLICIES VARY BY HOTEL. SINCE A HOTEL CAN SET A CANCELLATION POLICY OF UP TO 30 DAYS IN ADVANCE, PLEASE REVIEW POLICY PRIOR TO BOOKING TO AVOID POSSIBLE CHARGE."
7
8
  ]
8
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: te_rex
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joshua Bowles
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-23 00:00:00.000000000 Z
11
+ date: 2014-11-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fast-stemmer
@@ -111,65 +111,59 @@ dependencies:
111
111
  - !ruby/object:Gem::Version
112
112
  version: 0.10.1
113
113
  - !ruby/object:Gem::Dependency
114
- name: pry-debugger
114
+ name: pry-rescue
115
115
  requirement: !ruby/object:Gem::Requirement
116
116
  requirements:
117
117
  - - "~>"
118
118
  - !ruby/object:Gem::Version
119
- version: '0.2'
119
+ version: '1.4'
120
120
  - - ">="
121
121
  - !ruby/object:Gem::Version
122
- version: 0.2.3
122
+ version: 1.4.1
123
123
  type: :development
124
124
  prerelease: false
125
125
  version_requirements: !ruby/object:Gem::Requirement
126
126
  requirements:
127
127
  - - "~>"
128
128
  - !ruby/object:Gem::Version
129
- version: '0.2'
129
+ version: '1.4'
130
130
  - - ">="
131
131
  - !ruby/object:Gem::Version
132
- version: 0.2.3
132
+ version: 1.4.1
133
133
  - !ruby/object:Gem::Dependency
134
- name: pry-rescue
134
+ name: pry-stack_explorer
135
135
  requirement: !ruby/object:Gem::Requirement
136
136
  requirements:
137
137
  - - "~>"
138
138
  - !ruby/object:Gem::Version
139
- version: '1.4'
139
+ version: '0.4'
140
140
  - - ">="
141
141
  - !ruby/object:Gem::Version
142
- version: 1.4.1
142
+ version: 0.4.9.1
143
143
  type: :development
144
144
  prerelease: false
145
145
  version_requirements: !ruby/object:Gem::Requirement
146
146
  requirements:
147
147
  - - "~>"
148
148
  - !ruby/object:Gem::Version
149
- version: '1.4'
149
+ version: '0.4'
150
150
  - - ">="
151
151
  - !ruby/object:Gem::Version
152
- version: 1.4.1
152
+ version: 0.4.9.1
153
153
  - !ruby/object:Gem::Dependency
154
- name: pry-stack_explorer
154
+ name: simplecov
155
155
  requirement: !ruby/object:Gem::Requirement
156
156
  requirements:
157
- - - "~>"
158
- - !ruby/object:Gem::Version
159
- version: '0.4'
160
157
  - - ">="
161
158
  - !ruby/object:Gem::Version
162
- version: 0.4.9.1
159
+ version: '0'
163
160
  type: :development
164
161
  prerelease: false
165
162
  version_requirements: !ruby/object:Gem::Requirement
166
163
  requirements:
167
- - - "~>"
168
- - !ruby/object:Gem::Version
169
- version: '0.4'
170
164
  - - ">="
171
165
  - !ruby/object:Gem::Version
172
- version: 0.4.9.1
166
+ version: '0'
173
167
  description: Simple text processing for small data sets.
174
168
  email:
175
169
  - jbowayles@gmail.com
@@ -190,12 +184,13 @@ files:
190
184
  - test/alpha_num_test.rb
191
185
  - test/bayes_data_test.rb
192
186
  - test/sparse_bayes_test.rb
187
+ - test/test_helper.rb
193
188
  - test/test_modules/nonrefund.rb
194
189
  - test/test_modules/partrefund.rb
195
190
  - test/test_modules/refund.rb
196
191
  - test/test_modules/unknown.rb
197
192
  - test/trained_bayes_test.rb
198
- homepage: ''
193
+ homepage: https://github.com/jbowles/te_rex
199
194
  licenses:
200
195
  - MIT
201
196
  metadata: {}
@@ -215,7 +210,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
215
210
  version: '0'
216
211
  requirements: []
217
212
  rubyforge_project:
218
- rubygems_version: 2.4.1
213
+ rubygems_version: 2.2.2
219
214
  signing_key:
220
215
  specification_version: 4
221
216
  summary: Basic NLP stuff for small data sets. Naive Bayes classification and corpora
@@ -224,6 +219,7 @@ test_files:
224
219
  - test/alpha_num_test.rb
225
220
  - test/bayes_data_test.rb
226
221
  - test/sparse_bayes_test.rb
222
+ - test/test_helper.rb
227
223
  - test/test_modules/nonrefund.rb
228
224
  - test/test_modules/partrefund.rb
229
225
  - test/test_modules/refund.rb