Keywords.parse
You're seeing just the function
parse
, go back to Keywords module for more information.
Parses tickers from string
opts -> counts: true/false (include total occurrences of each keyword) -> aggregate: true/false (group results by pattern name) defaults -> counts: false, aggregate: true
Examples
iex> Keywords.parse(" XOM AAPL $TSLA buy now, ++ PLTR and $AMZN", :stocks)
[XOM, AAPL, TSLA, PLTR, AMZN]
iex> Keywords.parse(" XOM AAPL $TSLA buy now, ++ PLTR and $AMZN", :stocks_2)
["AAPL", "PLTR"]
iex> Keywords.parse(" XOM AAPL $TSLA buy now, ++ PLTR and $AMZN", [:stocks, :stocks_2])
["AAPL", "PLTR", XOM, TSLA, PLTR, AMZN]
iex> Keywords.parse(" XOM AAPL AMZN $TSLA buy now, ++ PLTR and $AMZN", :all)
["XOM", "AMZN", "TSLA", "AAPL", "PLTR"]
iex> Keywords.parse(" XOM AAPL AMZN $TSLA buy now, ++ PLTR and $AMZN", :stocks, [counts: true])
[{"AMZN", 2}, {"TSLA", 1}, {"XOM", 1}]
iex> Keywords.parse(" XOM AAPL AMZN $TSLA buy now, ++ PLTR and $AMZN", [:stocks, :stocks_2], [counts: true])
[{"AAPL", 1}, {"AMZN", 2}, {"PLTR", 1}, {"TSLA", 1}, {"XOM", 1}]
iex> Keywords.parse(" XOM AAPL AMZN $TSLA buy now, ++ PLTR and $AMZN", [:stocks, :stocks_2], [counts: true, aggregate: false])
[stocks: [{"AMZN", 2}, {"TSLA", 1}, {"XOM", 1}], stocks_2: [{"AAPL", 1}, {"PLTR", 1}]]
iex> Keywords.parse(" XOM AAPL AMZN $TSLA buy now, ++ PLTR and $AMZN", [:stocks, :stocks_2], [aggregate: false])
[stocks: ["XOM", "AMZN", "TSLA"], stocks_2: ["AAPL", "PLTR"]]
iex> Keywords.parse("a|n[xwn;qw%dl$qm*w", :stocks)
[]
iex> Keywords.parse(nil, :stocks)
[]