From 676d3ce6b26fead3989d57ad59838d2e5e4f2eca Mon Sep 17 00:00:00 2001 From: Roman Rizzi Date: Tue, 28 Feb 2023 11:17:03 -0300 Subject: [PATCH] DEV: Rename XClassification --> XClassificator to make it more obvious (#3) --- lib/modules/nsfw/jobs/regular/evaluate_post_uploads.rb | 2 +- .../sentiment/jobs/regular/post_sentiment_analysis.rb | 2 +- .../toxicity/jobs/regular/toxicity_classify_chat_message.rb | 2 +- lib/modules/toxicity/jobs/regular/toxicity_classify_post.rb | 2 +- ...sage_classification.rb => chat_message_classificator.rb} | 2 +- lib/shared/{classification.rb => classificator.rb} | 2 +- .../{post_classification.rb => post_classificator.rb} | 2 +- plugin.rb | 6 +++--- ...ification_spec.rb => chat_message_classificator_spec.rb} | 2 +- .../{classification_spec.rb => classificator_spec.rb} | 4 ++-- ...st_classification_spec.rb => post_classificator_spec.rb} | 2 +- 11 files changed, 14 insertions(+), 14 deletions(-) rename lib/shared/{chat_message_classification.rb => chat_message_classificator.rb} (85%) rename lib/shared/{classification.rb => classificator.rb} (98%) rename lib/shared/{post_classification.rb => post_classificator.rb} (89%) rename spec/shared/{chat_message_classification_spec.rb => chat_message_classificator_spec.rb} (96%) rename spec/shared/{classification_spec.rb => classificator_spec.rb} (95%) rename spec/shared/{post_classification_spec.rb => post_classificator_spec.rb} (96%) diff --git a/lib/modules/nsfw/jobs/regular/evaluate_post_uploads.rb b/lib/modules/nsfw/jobs/regular/evaluate_post_uploads.rb index da34a630..8441b9ce 100644 --- a/lib/modules/nsfw/jobs/regular/evaluate_post_uploads.rb +++ b/lib/modules/nsfw/jobs/regular/evaluate_post_uploads.rb @@ -11,7 +11,7 @@ module Jobs return if post.uploads.none? { |u| FileHelper.is_supported_image?(u.url) } - DiscourseAI::PostClassification.new(DiscourseAI::NSFW::NSFWClassification.new).classify!(post) + DiscourseAI::PostClassificator.new(DiscourseAI::NSFW::NSFWClassification.new).classify!(post) end end end diff --git a/lib/modules/sentiment/jobs/regular/post_sentiment_analysis.rb b/lib/modules/sentiment/jobs/regular/post_sentiment_analysis.rb index a29a0162..ec642d3b 100644 --- a/lib/modules/sentiment/jobs/regular/post_sentiment_analysis.rb +++ b/lib/modules/sentiment/jobs/regular/post_sentiment_analysis.rb @@ -9,7 +9,7 @@ module ::Jobs post = Post.find_by(id: post_id, post_type: Post.types[:regular]) return if post&.raw.blank? - DiscourseAI::PostClassification.new( + DiscourseAI::PostClassificator.new( DiscourseAI::Sentiment::SentimentClassification.new, ).classify!(post) end diff --git a/lib/modules/toxicity/jobs/regular/toxicity_classify_chat_message.rb b/lib/modules/toxicity/jobs/regular/toxicity_classify_chat_message.rb index c0167a5f..a1bee072 100644 --- a/lib/modules/toxicity/jobs/regular/toxicity_classify_chat_message.rb +++ b/lib/modules/toxicity/jobs/regular/toxicity_classify_chat_message.rb @@ -10,7 +10,7 @@ module ::Jobs chat_message = ChatMessage.find_by(id: chat_message_id) return if chat_message&.message.blank? - DiscourseAI::ChatMessageClassification.new( + DiscourseAI::ChatMessageClassificator.new( DiscourseAI::Toxicity::ToxicityClassification.new, ).classify!(chat_message) end diff --git a/lib/modules/toxicity/jobs/regular/toxicity_classify_post.rb b/lib/modules/toxicity/jobs/regular/toxicity_classify_post.rb index f59b16d2..2b055ca0 100644 --- a/lib/modules/toxicity/jobs/regular/toxicity_classify_post.rb +++ b/lib/modules/toxicity/jobs/regular/toxicity_classify_post.rb @@ -11,7 +11,7 @@ module ::Jobs post = Post.find_by(id: post_id, post_type: Post.types[:regular]) return if post&.raw.blank? - DiscourseAI::PostClassification.new( + DiscourseAI::PostClassificator.new( DiscourseAI::Toxicity::ToxicityClassification.new, ).classify!(post) end diff --git a/lib/shared/chat_message_classification.rb b/lib/shared/chat_message_classificator.rb similarity index 85% rename from lib/shared/chat_message_classification.rb rename to lib/shared/chat_message_classificator.rb index 2b031faa..9255fbe8 100644 --- a/lib/shared/chat_message_classification.rb +++ b/lib/shared/chat_message_classificator.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module ::DiscourseAI - class ChatMessageClassification < Classification + class ChatMessageClassificator < Classificator private def flag!(chat_message, _toxic_labels) diff --git a/lib/shared/classification.rb b/lib/shared/classificator.rb similarity index 98% rename from lib/shared/classification.rb rename to lib/shared/classificator.rb index 35e0ee70..eecd6328 100644 --- a/lib/shared/classification.rb +++ b/lib/shared/classificator.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module ::DiscourseAI - class Classification + class Classificator def initialize(classification_model) @classification_model = classification_model end diff --git a/lib/shared/post_classification.rb b/lib/shared/post_classificator.rb similarity index 89% rename from lib/shared/post_classification.rb rename to lib/shared/post_classificator.rb index 62cfd83e..0e0f86f8 100644 --- a/lib/shared/post_classification.rb +++ b/lib/shared/post_classificator.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module ::DiscourseAI - class PostClassification < Classification + class PostClassificator < Classificator private def flag!(post, classification_type) diff --git a/plugin.rb b/plugin.rb index 12023bd6..d3d9e9fa 100644 --- a/plugin.rb +++ b/plugin.rb @@ -17,9 +17,9 @@ after_initialize do require_relative "app/models/classification_result" require_relative "lib/shared/inference_manager" - require_relative "lib/shared/classification" - require_relative "lib/shared/post_classification" - require_relative "lib/shared/chat_message_classification" + require_relative "lib/shared/classificator" + require_relative "lib/shared/post_classificator" + require_relative "lib/shared/chat_message_classificator" require_relative "lib/modules/nsfw/entry_point" require_relative "lib/modules/toxicity/entry_point" diff --git a/spec/shared/chat_message_classification_spec.rb b/spec/shared/chat_message_classificator_spec.rb similarity index 96% rename from spec/shared/chat_message_classification_spec.rb rename to spec/shared/chat_message_classificator_spec.rb index 735055c9..b452dd2e 100644 --- a/spec/shared/chat_message_classification_spec.rb +++ b/spec/shared/chat_message_classificator_spec.rb @@ -3,7 +3,7 @@ require "rails_helper" require_relative "../support/toxicity_inference_stubs" -describe DiscourseAI::ChatMessageClassification do +describe DiscourseAI::ChatMessageClassificator do fab!(:chat_message) { Fabricate(:chat_message) } let(:model) { DiscourseAI::Toxicity::ToxicityClassification.new } diff --git a/spec/shared/classification_spec.rb b/spec/shared/classificator_spec.rb similarity index 95% rename from spec/shared/classification_spec.rb rename to spec/shared/classificator_spec.rb index da26cd3b..58fde10d 100644 --- a/spec/shared/classification_spec.rb +++ b/spec/shared/classificator_spec.rb @@ -3,7 +3,7 @@ require "rails_helper" require_relative "../support/sentiment_inference_stubs" -describe DiscourseAI::Classification do +describe DiscourseAI::Classificator do describe "#classify!" do describe "saving the classification result" do let(:classification_raw_result) do @@ -16,7 +16,7 @@ describe DiscourseAI::Classification do end let(:model) { DiscourseAI::Sentiment::SentimentClassification.new } - let(:classification) { DiscourseAI::PostClassification.new(model) } + let(:classification) { DiscourseAI::PostClassificator.new(model) } fab!(:target) { Fabricate(:post) } before do diff --git a/spec/shared/post_classification_spec.rb b/spec/shared/post_classificator_spec.rb similarity index 96% rename from spec/shared/post_classification_spec.rb rename to spec/shared/post_classificator_spec.rb index 6c0da133..5ba69514 100644 --- a/spec/shared/post_classification_spec.rb +++ b/spec/shared/post_classificator_spec.rb @@ -3,7 +3,7 @@ require "rails_helper" require_relative "../support/toxicity_inference_stubs" -describe DiscourseAI::PostClassification do +describe DiscourseAI::PostClassificator do fab!(:post) { Fabricate(:post) } let(:model) { DiscourseAI::Toxicity::ToxicityClassification.new }