Cleaned up some code and comments I left behind

This commit is contained in:
XanaxOG committed 2021-09-01 21:03:29 +02:00
1 parent dcb7ae4609
commit 8687fd6923
1 file changed
+9 -25
+9 -25
View File
@@ -9,37 +9,21 @@ import (
"strings"
)
type EmojipastaConfig struct {
WordDelimiter string
WordDelimiter string
MaxEmojisPerWord int
FixedEmojiNumber bool
}
func SplitWordByDelimiter(word string, delimiter string) []string{
func SplitWordByDelimiter(word string, delimiter string) []string {
return strings.Split(word, delimiter)
}
func AddEmojisToSlice(phrase []string, maxEmojisPerWord int, fixedEmojiNumber bool) string{
////emj := retrieveEmojis()
//var p fastjson.Parser
//f, err := ioutil.ReadAll("assets/emojis.json")
//if err != nil {
// log.Fatal(err)
//}
//v, err2 := p.Parse(string(f))
//if err2 != nil {
// log.Fatal(err2)
//}
//fmt.Println(v.GetStringBytes("dlc"))
// Open our jsonFile
func AddEmojisToSlice(phrase []string, maxEmojisPerWord int, fixedEmojiNumber bool) string {
jsonFile, err := os.Open("assets/emojis.json")
// if we os.Open returns an error then handle it
if err != nil {
fmt.Println(err)
}
// defer the closing of our jsonFile so that we can parse it later on
defer jsonFile.Close()
byteValue, _ := ioutil.ReadAll(jsonFile)
@@ -59,13 +43,13 @@ func AddEmojisToSlice(phrase []string, maxEmojisPerWord int, fixedEmojiNumber bo
if j == 0 {
finalString += word
} else {
finalString += " " + word
finalString += " " + word
}
emojis = strings.Split(fmt.Sprintf("%v", result[strings.ToLower(word)]), " ")
for i := 1; i <= maxEmojisPerWord; i++{
for i := 1; i <= maxEmojisPerWord; i++ {
index := rand.Intn(len(emojis))
if emojis[index] != "<nil>"{
if emojis[index] != "<nil>" {
finalString += emojis[index]
}
}
@@ -76,13 +60,13 @@ func AddEmojisToSlice(phrase []string, maxEmojisPerWord int, fixedEmojiNumber bo
if j == 0 {
finalString += word
} else {
finalString += " " + word
finalString += " " + word
}
emojis = strings.Split(fmt.Sprintf("%v", result[strings.ToLower(word)]), " ")
for i := 0; i <= rnd; i++{
for i := 0; i <= rnd; i++ {
index := rand.Intn(len(emojis))
if emojis[index] != "<nil>"{
if emojis[index] != "<nil>" {
finalString += emojis[index]
}
}