Skip to content

Commit

Permalink
Prevent errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Tame, Dan authored and Tame, Dan committed Nov 11, 2015
1 parent a2dde04 commit 4f862f7
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/sentient.ex
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require IEx

defmodule Sentient do
@afinn_source File.read!(__DIR__ <> "/../config/AFINN-111.json")
|> Poison.Parser.parse!
Expand All @@ -7,9 +9,11 @@ defmodule Sentient do
|> Map.merge(override_words)

phrase
|> String.replace(~r/\n/, "")
|> Tokenizer.tokenize
|> Enum.filter(&(afinn[&1]))
|> Enum.map(&(afinn[&1]))
|> Enum.reduce(&(&1 + &2))
|> Enum.reduce(0, &(&1 + &2))

end
end

0 comments on commit 4f862f7

Please sign in to comment.