Skip to content

Commit

Permalink
rename fields
Browse files Browse the repository at this point in the history
  • Loading branch information
tspenov committed Oct 27, 2023
1 parent 623e35d commit 32c24b6
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 26 deletions.
10 changes: 5 additions & 5 deletions lib/sanbase/social_data/trending_words.ex
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ defmodule Sanbase.SocialData.TrendingWords do
# postive, negative or netural sentiment. The values are in the range [0, 1]
# and add up to 1
[pos_sentiment, neg_sentiment, neu_sentiment] = sentiment_ratios
[bull_bb_sentiment, bear_bb_sentiment, neu_bb_sentiment] = bb_sentiment_ratios
[positive_bb_sentiment, negative_bb_sentiment, neutral_bb_sentiment] = bb_sentiment_ratios

summaries = [%{source: source, datetime: datetime, summary: summary}]
context = transform_context(context)
Expand All @@ -95,9 +95,9 @@ defmodule Sanbase.SocialData.TrendingWords do
positive_sentiment_ratio: pos_sentiment,
negative_sentiment_ratio: neg_sentiment,
neutral_sentiment_ratio: neu_sentiment,
bullish_bb_sentiment_ratio: bull_bb_sentiment,
bearish_bb_sentiment_ratio: bear_bb_sentiment,
neutral_bb_sentiment_ratio: neu_bb_sentiment
positive_bb_sentiment_ratio: positive_bb_sentiment,
negative_bb_sentiment_ratio: negative_bb_sentiment,
neutral_bb_sentiment_ratio: neutral_bb_sentiment
}

Map.update(acc, datetime, [elem], fn words -> [elem | words] end)
Expand Down Expand Up @@ -262,7 +262,7 @@ defmodule Sanbase.SocialData.TrendingWords do
words_context AS context,
summary,
tuple(pos_ratio, neg_ratio, neu_ratio) AS sentiment_ratios,
tuple(bull_bb_ratio, bear_bb_ratio, neu_bb_ratio) AS bb_sentiment_ratios
tuple(positive_bb_ratio, negative_bb_ratio, neutral_bb_ratio) AS bb_sentiment_ratios
FROM #{@table}
WHERE
dt >= toDateTime({{from}}) AND
Expand Down
4 changes: 2 additions & 2 deletions lib/sanbase_web/graphql/schema/types/social_data_types.ex
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ defmodule SanbaseWeb.Graphql.SocialDataTypes do
field(:negative_sentiment_ratio, :float)
field(:neutral_sentiment_ratio, :float)
# bearish/bullish sentiment ratios
field(:bullish_bb_sentiment_ratio, :float)
field(:bearish_bb_sentiment_ratio, :float)
field(:positive_bb_sentiment_ratio, :float)
field(:negative_bb_sentiment_ratio, :float)
field(:neutral_bb_sentiment_ratio, :float)

field :project, :project do
Expand Down
32 changes: 16 additions & 16 deletions test/sanbase/social_data/trending_words/trending_words_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ defmodule Sanbase.SocialData.TrendingWordsTest do
negative_sentiment_ratio: 0.3,
neutral_sentiment_ratio: 0.5,
positive_sentiment_ratio: 0.2,
bearish_bb_sentiment_ratio: 0.3,
negative_bb_sentiment_ratio: 0.3,
neutral_bb_sentiment_ratio: 0.5,
bullish_bb_sentiment_ratio: 0.2
positive_bb_sentiment_ratio: 0.2
},
%{
context: [%{score: 1.0, word: "usd"}, %{score: 0.5, word: "money"}],
Expand All @@ -65,9 +65,9 @@ defmodule Sanbase.SocialData.TrendingWordsTest do
negative_sentiment_ratio: 0.3,
neutral_sentiment_ratio: 0.5,
positive_sentiment_ratio: 0.2,
bearish_bb_sentiment_ratio: 0.3,
negative_bb_sentiment_ratio: 0.3,
neutral_bb_sentiment_ratio: 0.5,
bullish_bb_sentiment_ratio: 0.2
positive_bb_sentiment_ratio: 0.2
}
],
dt2 => [
Expand All @@ -87,9 +87,9 @@ defmodule Sanbase.SocialData.TrendingWordsTest do
negative_sentiment_ratio: 0.1,
neutral_sentiment_ratio: 0.7,
positive_sentiment_ratio: 0.2,
bearish_bb_sentiment_ratio: 0.1,
negative_bb_sentiment_ratio: 0.1,
neutral_bb_sentiment_ratio: 0.7,
bullish_bb_sentiment_ratio: 0.2
positive_bb_sentiment_ratio: 0.2
},
%{
context: [%{score: 1.0, word: "usd"}, %{score: 0.5, word: "money"}],
Expand All @@ -107,9 +107,9 @@ defmodule Sanbase.SocialData.TrendingWordsTest do
negative_sentiment_ratio: 0.1,
neutral_sentiment_ratio: 0.5,
positive_sentiment_ratio: 0.4,
bearish_bb_sentiment_ratio: 0.1,
negative_bb_sentiment_ratio: 0.1,
neutral_bb_sentiment_ratio: 0.5,
bullish_bb_sentiment_ratio: 0.4
positive_bb_sentiment_ratio: 0.4
}
],
dt3 => [
Expand All @@ -129,9 +129,9 @@ defmodule Sanbase.SocialData.TrendingWordsTest do
negative_sentiment_ratio: 0.3,
neutral_sentiment_ratio: 0.5,
positive_sentiment_ratio: 0.2,
bearish_bb_sentiment_ratio: 0.3,
negative_bb_sentiment_ratio: 0.3,
neutral_bb_sentiment_ratio: 0.5,
bullish_bb_sentiment_ratio: 0.2
positive_bb_sentiment_ratio: 0.2
},
%{
context: [%{score: 1.0, word: "usd"}, %{score: 0.5, word: "money"}],
Expand All @@ -149,9 +149,9 @@ defmodule Sanbase.SocialData.TrendingWordsTest do
negative_sentiment_ratio: 0.3,
neutral_sentiment_ratio: 0.5,
positive_sentiment_ratio: 0.2,
bearish_bb_sentiment_ratio: 0.3,
negative_bb_sentiment_ratio: 0.3,
neutral_bb_sentiment_ratio: 0.5,
bullish_bb_sentiment_ratio: 0.2
positive_bb_sentiment_ratio: 0.2
}
]
}
Expand Down Expand Up @@ -200,9 +200,9 @@ defmodule Sanbase.SocialData.TrendingWordsTest do
negative_sentiment_ratio: 0.3,
neutral_sentiment_ratio: 0.5,
positive_sentiment_ratio: 0.2,
bearish_bb_sentiment_ratio: 0.3,
negative_bb_sentiment_ratio: 0.3,
neutral_bb_sentiment_ratio: 0.5,
bullish_bb_sentiment_ratio: 0.2
positive_bb_sentiment_ratio: 0.2
},
%{
context: [%{score: 1.0, word: "usd"}, %{score: 0.5, word: "money"}],
Expand All @@ -220,9 +220,9 @@ defmodule Sanbase.SocialData.TrendingWordsTest do
negative_sentiment_ratio: 0.3,
neutral_sentiment_ratio: 0.5,
positive_sentiment_ratio: 0.2,
bearish_bb_sentiment_ratio: 0.3,
negative_bb_sentiment_ratio: 0.3,
neutral_bb_sentiment_ratio: 0.5,
bullish_bb_sentiment_ratio: 0.2
positive_bb_sentiment_ratio: 0.2
}
]
}
Expand Down
21 changes: 18 additions & 3 deletions test/sanbase_web/graphql/social_data/trending_words_api_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ defmodule SanbaseWeb.Graphql.TrendingWordsApiTest do
"{'word': 'halving', 'score': 1.0}"
],
"The summary",
[0.2, 0.3, 0.5],
[0.2, 0.3, 0.5]
],
[
Expand All @@ -49,6 +50,7 @@ defmodule SanbaseWeb.Graphql.TrendingWordsApiTest do
"{'word': 'bitcoin', 'score': 1.0}"
],
"Another summary",
[0.8, 0.1, 0.1],
[0.8, 0.1, 0.1]
],
[
Expand All @@ -61,6 +63,7 @@ defmodule SanbaseWeb.Graphql.TrendingWordsApiTest do
"{'word': 'tight', 'score': 1.0}"
],
"Third summary",
[0.5, 0.15, 0.35],
[0.5, 0.15, 0.35]
]
]
Expand Down Expand Up @@ -89,7 +92,10 @@ defmodule SanbaseWeb.Graphql.TrendingWordsApiTest do
"word" => "word",
"negativeSentimentRatio" => 0.15,
"neutralSentimentRatio" => 0.35,
"positiveSentimentRatio" => 0.5
"positiveSentimentRatio" => 0.5,
"negativeBbSentimentRatio" => 0.15,
"neutralBbSentimentRatio" => 0.35,
"positiveBbSentimentRatio" => 0.5
},
%{
"context" => [
Expand All @@ -102,7 +108,10 @@ defmodule SanbaseWeb.Graphql.TrendingWordsApiTest do
"word" => "btc",
"negativeSentimentRatio" => 0.1,
"neutralSentimentRatio" => 0.1,
"positiveSentimentRatio" => 0.8
"positiveSentimentRatio" => 0.8,
"negativeBbSentimentRatio" => 0.1,
"neutralBbSentimentRatio" => 0.1,
"positiveBbSentimentRatio" => 0.8
},
%{
"context" => [
Expand All @@ -115,7 +124,10 @@ defmodule SanbaseWeb.Graphql.TrendingWordsApiTest do
"word" => "eth",
"negativeSentimentRatio" => 0.3,
"neutralSentimentRatio" => 0.5,
"positiveSentimentRatio" => 0.2
"positiveSentimentRatio" => 0.2,
"negativeBbSentimentRatio" => 0.3,
"neutralBbSentimentRatio" => 0.5,
"positiveBbSentimentRatio" => 0.2
}
]
}
Expand Down Expand Up @@ -265,6 +277,9 @@ defmodule SanbaseWeb.Graphql.TrendingWordsApiTest do
positiveSentimentRatio
negativeSentimentRatio
neutralSentimentRatio
positiveBbSentimentRatio
negativeBbSentimentRatio
neutralBbSentimentRatio
context{
word
score
Expand Down

0 comments on commit 32c24b6

Please sign in to comment.