Don't count "a" and "it" toward the emojification score

Fixes #95.
This commit is contained in:
Steve McCoy 2017-11-27 22:07:59 -05:00
parent ce292934cc
commit 83289d65f0
1 changed files with 9 additions and 3 deletions

View File

@ -71,19 +71,25 @@ func (p *EmojifyMePlugin) Message(message msg.Message) bool {
tokens := strings.Fields(strings.ToLower(message.Body)) tokens := strings.Fields(strings.ToLower(message.Body))
for i, token := range tokens { for i, token := range tokens {
if _, ok := p.Emoji[token]; ok { if _, ok := p.Emoji[token]; ok {
if token != "a" && token != "it" {
emojied++ emojied++
}
tokens[i] = ":" + token + ":" tokens[i] = ":" + token + ":"
} else if strings.HasSuffix(token, "s") { } else if strings.HasSuffix(token, "s") {
//Check to see if we can strip the trailing "es" off and get an emoji //Check to see if we can strip the trailing "es" off and get an emoji
temp := strings.TrimSuffix(token, "s") temp := strings.TrimSuffix(token, "s")
if _, ok := p.Emoji[temp]; ok { if _, ok := p.Emoji[temp]; ok {
if token != "a" && token != "it" {
emojied++ emojied++
}
tokens[i] = ":" + temp + ":s" tokens[i] = ":" + temp + ":s"
} else if strings.HasSuffix(token, "es") { } else if strings.HasSuffix(token, "es") {
//Check to see if we can strip the trailing "es" off and get an emoji //Check to see if we can strip the trailing "es" off and get an emoji
temp := strings.TrimSuffix(token, "es") temp := strings.TrimSuffix(token, "es")
if _, ok := p.Emoji[temp]; ok { if _, ok := p.Emoji[temp]; ok {
if token != "a" && token != "it" {
emojied++ emojied++
}
tokens[i] = ":" + temp + ":es" tokens[i] = ":" + temp + ":es"
} }
} }