File tree Expand file tree Collapse file tree 4 files changed +61
-0
lines changed Expand file tree Collapse file tree 4 files changed +61
-0
lines changed Original file line number Diff line number Diff line change
1
+ class TokenizationSamplesController < ApplicationController
2
+ def new
3
+ @trained_messages = TrainedMessage . order ( "RANDOM()" ) . limit ( 5 )
4
+ if @trained_messages . any?
5
+ service = SpamClassifierService . new ( 0 , "dummy" )
6
+ @samples = @trained_messages . map do |msg |
7
+ {
8
+ original : msg . message ,
9
+ cleaned : service . clean_text ( msg . message ) ,
10
+ tokens : service . tokenize ( msg . message )
11
+ }
12
+ end
13
+ else
14
+ @samples = [ ]
15
+ end
16
+ end
17
+ end
Original file line number Diff line number Diff line change 47
47
48
48
<%= link_to "Banned Users" , banned_users_path ,
49
49
class : "#{ current_page? ( banned_users_path ) ? 'border-indigo-500 text-gray-900' : 'border-transparent text-gray-500 hover:border-gray-300 hover:text-gray-700' } inline-flex items-center px-1 pt-1 border-b-2 text-sm font-medium" %>
50
+ <%= link_to "Tokenization Samples" , new_tokenization_sample_path ,
51
+ class : "#{ current_page? ( new_tokenization_sample_path ) ? 'border-indigo-500 text-gray-900' : 'border-transparent text-gray-500 hover:border-gray-300 hover:text-gray-700' } inline-flex items-center px-1 pt-1 border-b-2 text-sm font-medium" %>
50
52
<%= link_to "Solid Queue Dashboard" , solid_queue_dashboard . root_path ,
51
53
class : "#{ current_page? ( solid_queue_dashboard . root_path ) ? 'border-indigo-500 text-gray-900' : 'border-transparent text-gray-500 hover:border-gray-300 hover:text-gray-700' } inline-flex items-center px-1 pt-1 border-b-2 text-sm font-medium" %>
52
54
</ div >
Original file line number Diff line number Diff line change
1
+ < div class ="container mx-auto px-4 ">
2
+ < h1 class ="text-2xl font-bold mb-4 "> Tokenization Samples</ h1 >
3
+
4
+ <%= link_to "Get Another Random Samples" ,
5
+ new_tokenization_sample_path ,
6
+ data : { turbo_frame : "sample" } ,
7
+ class : "bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded" %>
8
+
9
+ < turbo-frame id ="sample ">
10
+ <% if @samples . any? %>
11
+ <% @samples . each_with_index do |sample , index | %>
12
+ < div class ="mt-6 p-4 border rounded shadow bg-white ">
13
+ < h2 class ="text-xl font-semibold "> Sample <%= index + 1 %> </ h2 >
14
+
15
+ < div class ="mt-2 ">
16
+ < h3 class ="text-lg font-medium "> Original Message</ h3 >
17
+ < p class ="bg-gray-100 p-2 rounded "> <%= sample [ :original ] %> </ p >
18
+ </ div >
19
+
20
+ < div class ="mt-2 ">
21
+ < h3 class ="text-lg font-medium "> Cleaned Message</ h3 >
22
+ < p class ="bg-gray-100 p-2 rounded "> <%= sample [ :cleaned ] %> </ p >
23
+ </ div >
24
+
25
+ < div class ="mt-2 ">
26
+ < h3 class ="text-lg font-medium "> Tokens</ h3 >
27
+ < div class ="bg-gray-100 p-2 rounded flex flex-wrap ">
28
+ <% sample [ :tokens ] . each do |token | %>
29
+ < span class ="inline-block bg-gray-200 rounded-full px-3 py-1 text-sm font-semibold text-gray-700 mr-2 mb-2 ">
30
+ <%= token %>
31
+ </ span >
32
+ <% end %>
33
+ </ div >
34
+ </ div >
35
+ </ div >
36
+ <% end %>
37
+ <% else %>
38
+ < p class ="mt-4 "> No trained messages found in the database.</ p >
39
+ <% end %>
40
+ </ turbo-frame >
41
+ </ div >
Original file line number Diff line number Diff line change 5
5
resources :trained_messages do
6
6
post :bulk_update , on : :collection
7
7
end
8
+ resources :tokenization_samples , only : [ :new ]
8
9
# Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html
9
10
10
11
# Reveal health status on /up that returns 200 if the app boots with no exceptions, otherwise 500.
You can’t perform that action at this time.
0 commit comments