Permalink
Browse files

allow admin to reclassify from the web

  • Loading branch information...
1 parent 4ffe9ca commit 58ae7dd9b7cae819a4a2f89decd789aadd056660 @feedbackmine committed Apr 21, 2009
Showing with 20 additions and 7 deletions.
  1. +0 −1 TODO
  2. +8 −0 app/controllers/feedbacks_controller.rb
  3. +9 −0 app/models/feedback.rb
  4. +2 −1 app/views/projects/show.html.erb
  5. +1 −5 jobs/classifier.rb
View
1 TODO
@@ -1,6 +1,5 @@
analyze
related jobs
-delete/reclassify from the web
language_detector demo
get description automatically
search sentiment
@@ -7,4 +7,12 @@ def destroy
redirect_to :back
end
+
+ #reclassify
+ def edit
+ @feedback = Feedback.find(params[:id])
+ @feedback.reclassify
+
+ redirect_to :back
+ end
end
View
@@ -42,6 +42,15 @@ def reply_url
def author_id
end
+ def reclassify
+ require RAILS_ROOT + '/jobs/classifier.rb'
+ sentiment_classifier = SentimentClassifier.new
+ polarity, content = sentiment_classifier.process(self.text_description)
+ self.polarity = polarity
+ self.description = content
+ self.save!
+ end
+
private
def polarity_int2name i
case i
@@ -69,7 +69,8 @@ What the Community is Saying about '<%= @project.name %>' :
<% end %>
<% if current_user %>
- <%= link_to 'Delete', {:id => feedback, :controller => 'feedbacks', :action => 'destroy'}, :method => :delete %>
+ <%= link_to 'Delete', {:controller => 'feedbacks', :action => 'destroy', :id => feedback}, :method => :delete %>
+ <%= link_to 'Reclassify', {:controller => 'feedbacks', :action => 'edit', :id => feedback} %>
<% end %>
</small>
View
@@ -168,12 +168,8 @@ def test
end
feedbacks.each { |feedback|
- sentiment_classifier = SentimentClassifier.new
puts "Before: #{feedback.description}"
- polarity, content = sentiment_classifier.process(feedback.text_description)
- feedback.polarity = polarity
- feedback.description = content
- feedback.save!
+ feedback.reclassify
puts "After: #{feedback.description}"
}
end

0 comments on commit 58ae7dd

Please sign in to comment.