Documentation
¶
Overview ¶
Package hashtag implements extraction of Twitter type hashtags, mentions and replies form text in Go. This package partially ports extraction routines from Twitter's official Java package at https://github.com/twitter/twitter-text to Go and runs most of the standard twitter-text conformance tests. It does not yet implement URL extraction (and hence URL/Hashtag overlaps), cashtags and lists
Since the package attempts to closely follow the Twitter-Text Java API, function names may be longer than typical Go package function names
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtractHashtags ¶
ExtractHashtags extracts hashtags without the hash markers from input text and returns them as a slice of strings.
func ExtractMentions ¶
ExtractMentions extracts mentions without the @ markers from input text and returns them as a slice of strings.
Example ¶
fmt.Println(ExtractMentions("mention @username1 @username2 but not user@example.com"))
Output: [username1 username2]
func ExtractReply ¶
ExtractReply extracts reply username without the @ marker from input text and returns it as a string. Empty string signals no reply username
Example ¶
fmt.Println(ExtractReply("@username1 reply something but not to @username2"))
Output: username1
Types ¶
type Entity ¶
Entity is used by ExtractXXXXWithIndices functions to return the position and text extracted. This may be expanded in the future to support List slugs
func ExtractHashtagsWithIndices ¶
ExtractHashtagsWithIndices extracts hashtags without the hash markers from input text and returns them as a slice of Entities containing start/end positions.
func ExtractMentionsWithIndices ¶
ExtractMentionsWithIndices extracts mentions without the @ markers from input text and returns them as a slice of Entities containing start/end positions.
Example ¶
fmt.Println(ExtractMentionsWithIndices("mention @username1 @username2 but not user@example.com"))
Output: [{9 18 username1} {20 29 username2}]