9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'app/jobs/decidim/ai/spam_detection/generic_spam_analyzer_job.rb', line 9
def perform(reportable, author, locale, fields)
@author = author
@organization = reportable.organization
overall_score = I18n.with_locale(locale) do
fields.map do |field|
classifier.classify(translated_attribute(reportable.send(field)))
classifier.score
end
end
overall_score = overall_score.inject(0.0, :+) / overall_score.size
return unless overall_score >= Decidim::Ai::SpamDetection.resource_score_threshold
Decidim::CreateReport.call(form, reportable)
end
|