social_parser v1.1.0 SocialParser
SocialParser is used to parse out common social message commponents such as hashtags, mentions and urls.
Summary
Functions
Returns a map of all components for a given message
Returns a map of all components for a given message
filtered by a list of
atoms specified in the components
Returns an array of tuples containing all components found for the given message
Functions
Returns a map of all components for a given message
Usage
iex> SocialParser.extract("hi @you checkout http://example.com/ that +someone hosted #example")
%{
hashtags: ["#example"],
mentions: ["@you", "+someone"],
links: ["http://example.com/"],
text: ["hi ", " checkout ", " that ", " hosted "]
}
Returns a map of all components for a given message
filtered by a list of
atoms specified in the components
The available atoms are, :hashtags
, :mentions
, :links
and :text
Usage
iex> SocialParser.extract("hi @you checkout http://example.com/", [:mentions, :links])
%{
mentions: ["@you"],
links: ["http://example.com/"],
}
Returns an array of tuples containing all components found for the given message
Prefixes used
#
for hashtags@
or+
for mentionshttp://
orhttps://
for links
Usage
iex> SocialParser.parse("hi @you checkout http://example.com/ that +someone hosted #example")
[
{:text, "hi "},
{:mention, "@you"},
{:text, " checkout "},
{:link, "http://example.com/"},
{:text, " that "},
{:mention, "+someone"},
{:text, " hosted "},
{:hashtag, "#example"}
]