FIX: Truncate content for sentiment/toxicity classification (#431)
This commit is contained in:
parent
5bdf3dc1f4
commit
c70f43f130
|
@ -48,11 +48,14 @@ module DiscourseAi
|
||||||
end
|
end
|
||||||
|
|
||||||
def content_of(target_to_classify)
|
def content_of(target_to_classify)
|
||||||
|
content =
|
||||||
if target_to_classify.post_number == 1
|
if target_to_classify.post_number == 1
|
||||||
"#{target_to_classify.topic.title}\n#{target_to_classify.raw}"
|
"#{target_to_classify.topic.title}\n#{target_to_classify.raw}"
|
||||||
else
|
else
|
||||||
target_to_classify.raw
|
target_to_classify.raw
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Tokenizer::BertTokenizer.truncate(content, 512)
|
||||||
end
|
end
|
||||||
|
|
||||||
def endpoint
|
def endpoint
|
||||||
|
|
|
@ -59,8 +59,10 @@ module DiscourseAi
|
||||||
end
|
end
|
||||||
|
|
||||||
def content_of(target_to_classify)
|
def content_of(target_to_classify)
|
||||||
return target_to_classify.message if target_to_classify.is_a?(Chat::Message)
|
content =
|
||||||
|
if target_to_classify.is_a?(Chat::Message)
|
||||||
|
target_to_classify.message
|
||||||
|
else
|
||||||
if target_to_classify.post_number == 1
|
if target_to_classify.post_number == 1
|
||||||
"#{target_to_classify.topic.title}\n#{target_to_classify.raw}"
|
"#{target_to_classify.topic.title}\n#{target_to_classify.raw}"
|
||||||
else
|
else
|
||||||
|
@ -68,6 +70,9 @@ module DiscourseAi
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Tokenizer::BertTokenizer.truncate(content, 512)
|
||||||
|
end
|
||||||
|
|
||||||
def endpoint
|
def endpoint
|
||||||
if SiteSetting.ai_toxicity_inference_service_api_endpoint_srv.present?
|
if SiteSetting.ai_toxicity_inference_service_api_endpoint_srv.present?
|
||||||
service =
|
service =
|
||||||
|
|
Loading…
Reference in New Issue