5353 end
5454
5555 describe "custom reports" do
56- before { SiteSetting . ai_sentiment_inference_service_api_endpoint = "http://test.com" }
56+ before do
57+ SiteSetting . ai_sentiment_model_configs =
58+ "[{\" model_name\" :\" SamLowe/roberta-base-go_emotions\" ,\" endpoint\" :\" http://samlowe-emotion.com\" ,\" api_key\" :\" 123\" },{\" model_name\" :\" j-hartmann/emotion-english-distilroberta-base\" ,\" endpoint\" :\" http://jhartmann-emotion.com\" ,\" api_key\" :\" 123\" },{\" model_name\" :\" cardiffnlp/twitter-roberta-base-sentiment-latest\" ,\" endpoint\" :\" http://cardiffnlp-sentiment.com\" ,\" api_key\" :\" 123\" }]"
59+ end
5760
5861 fab! ( :pm ) { Fabricate ( :private_message_post ) }
5962
6063 fab! ( :post_1 ) { Fabricate ( :post ) }
6164 fab! ( :post_2 ) { Fabricate ( :post ) }
6265
6366 describe "overall_sentiment report" do
64- let ( :positive_classification ) { { negative : 2 , neutral : 30 , positive : 70 } }
65- let ( :negative_classification ) { { negative : 65 , neutral : 2 , positive : 10 } }
67+ let ( :positive_classification ) { { negative : 0. 2, neutral : 0.3 , positive : 0.7 } }
68+ let ( :negative_classification ) { { negative : 0. 65, neutral : 0. 2, positive : 0.1 } }
6669
6770 def sentiment_classification ( post , classification )
6871 Fabricate ( :sentiment_classification , target : post , classification : classification )
@@ -84,12 +87,28 @@ def sentiment_classification(post, classification)
8487
8588 describe "post_emotion report" do
8689 let ( :emotion_1 ) do
87- { sadness : 49 , surprise : 23 , neutral : 6 , fear : 34 , anger : 87 , joy : 22 , disgust : 70 }
90+ {
91+ sadness : 0.49 ,
92+ surprise : 0.23 ,
93+ neutral : 0.6 ,
94+ fear : 0.34 ,
95+ anger : 0.87 ,
96+ joy : 0.22 ,
97+ disgust : 0.70 ,
98+ }
8899 end
89100 let ( :emotion_2 ) do
90- { sadness : 19 , surprise : 63 , neutral : 45 , fear : 44 , anger : 27 , joy : 62 , disgust : 30 }
101+ {
102+ sadness : 0.19 ,
103+ surprise : 0.63 ,
104+ neutral : 0.45 ,
105+ fear : 0.44 ,
106+ anger : 0.27 ,
107+ joy : 0.62 ,
108+ disgust : 0.30 ,
109+ }
91110 end
92- let ( :model_used ) { "emotion" }
111+ let ( :model_used ) { "j-hartmann/ emotion-english-distilroberta-base " }
93112
94113 def emotion_classification ( post , classification )
95114 Fabricate (
@@ -106,7 +125,7 @@ def strip_emoji_and_downcase(str)
106125 end
107126
108127 it "calculate averages using only public posts" do
109- threshold = 30
128+ threshold = 0. 30
110129
111130 emotion_classification ( post_1 , emotion_1 )
112131 emotion_classification ( post_2 , emotion_2 )
0 commit comments