Packages

Sentiment analysis based on afinn-165, emojis and some enhancements.

Current section

Files

Jump to
veritaserum lib evaluator.ex
Raw

lib/evaluator.ex

defmodule Veritaserum.Evaluator do
["word", "negator", "booster"]
|> Enum.each(fn domain ->
File.read!("#{__DIR__}/../config/#{domain}.json")
|> Poison.Parser.parse!
|> Enum.each(fn {word, value} ->
@doc """
Evaluates if a word/emoji is a **#{domain}** and returns value.
iex> Veritaserum.Evaluator.evaluate_#{domain}("#{word}")
#{value}
"""
def unquote(:"evaluate_#{domain}")(unquote(word)), do: unquote(value)
end)
def unquote(:"evaluate_#{domain}")(_), do: 0
end)
end