emoji: make the list an independent doc

during this draft phase, the authoritative document for the ordering of
the emoji needs to be consumable by other languages and as a library.

Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
This commit is contained in:
Vincent Batts 2016-12-13 12:56:45 -05:00
parent a2456feb8f
commit 2332d1260c
Signed by: vbatts
GPG Key ID: 10937E57733F1362
6 changed files with 583 additions and 266 deletions

5
emoji/README.md Normal file
View File

@ -0,0 +1,5 @@
# emojisum mapping
The JSON is the authority of ordering. While this package is importable by
golang projects, other languages can fetch the ordered list of the JSON
document and do their own emojisum comparison or rendering.

258
emoji/map-draft.json Normal file
View File

@ -0,0 +1,258 @@
[
":+1:",
":8ball:",
":airplane:",
":alien:",
":anchor:",
":angel:",
":angry:",
":ant:",
":apple:",
":art:",
":baby:",
":baby_bottle:",
":back:",
":bamboo:",
":banana:",
":barber:",
":bathtub:",
":beer:",
":bell:",
":bicyclist:",
":bird:",
":birthday:",
":blossom:",
":blue_car:",
":boar:",
":bomb:",
":boom:",
":bow:",
":boy:",
":broken_heart:",
":bulb:",
":bus:",
":cactus:",
":calendar:",
":camera:",
":candy:",
":cat:",
":cherries:",
":children_crossing:",
":chocolate_bar:",
":clap:",
":cloud:",
":clubs:",
":cn:",
":coffee:",
":construction:",
":cookie:",
":copyright:",
":corn:",
":cow:",
":crescent_moon:",
":crown:",
":cry:",
":crystal_ball:",
":curly_loop:",
":dancers:",
":dash:",
":de:",
":diamonds:",
":dog:",
":doughnut:",
":dragon:",
":dvd:",
":ear:",
":eggplant:",
":elephant:",
":end:",
":envelope:",
":es:",
":eyes:",
":facepunch:",
":family:",
":ferris_wheel:",
":finnadie:",
":fire:",
":fireworks:",
":floppy_disk:",
":football:",
":fork_and_knife:",
":four_leaf_clover:",
":fr:",
":fries:",
":frog:",
":fu:",
":full_moon:",
":game_die:",
":eu:",
":gem:",
":girl:",
":goat:",
":grimacing:",
":grin:",
":guardsman:",
":guitar:",
":gun:",
":hamburger:",
":hammer:",
":hamster:",
":hear_no_evil:",
":heart:",
":heart_eyes_cat:",
":hearts:",
":heavy_check_mark:",
":moyai:",
":izakaya_lantern:",
":helicopter:",
":hocho:",
":honeybee:",
":horse:",
":horse_racing:",
":hourglass:",
":house:",
":hurtrealbad:",
":icecream:",
":imp:",
":it:",
":jack_o_lantern:",
":japanese_goblin:",
":jp:",
":key:",
":kiss:",
":kissing_cat:",
":koala:",
":kr:",
":lemon:",
":lipstick:",
":lock:",
":lollipop:",
":man:",
":maple_leaf:",
":mask:",
":metal:",
":microscope:",
":moneybag:",
":monkey:",
":mount_fuji:",
":muscle:",
":mushroom:",
":musical_keyboard:",
":musical_score:",
":nail_care:",
":new_moon:",
":no_entry:",
":nose:",
":notes:",
":nut_and_bolt:",
":o:",
":ocean:",
":ok_hand:",
":on:",
":package:",
":palm_tree:",
":panda_face:",
":paperclip:",
":partly_sunny:",
":passport_control:",
":paw_prints:",
":peach:",
":penguin:",
":phone:",
":pig:",
":pill:",
":pineapple:",
":pizza:",
":point_left:",
":point_right:",
":poop:",
":poultry_leg:",
":pray:",
":princess:",
":purse:",
":pushpin:",
":rabbit:",
":rainbow:",
":raised_hand:",
":recycle:",
":red_car:",
":registered:",
":ribbon:",
":rice:",
":rocket:",
":roller_coaster:",
":rooster:",
":ru:",
":sailboat:",
":santa:",
":satellite:",
":satisfied:",
":saxophone:",
":scissors:",
":see_no_evil:",
":sheep:",
":shell:",
":shoe:",
":ski:",
":skull:",
":sleepy:",
":smile:",
":smiley_cat:",
":smirk:",
":smoking:",
":snail:",
":snake:",
":snowflake:",
":soccer:",
":soon:",
":space_invader:",
":spades:",
":speak_no_evil:",
":star:",
":stars:",
":statue_of_liberty:",
":steam_locomotive:",
":sunflower:",
":sunglasses:",
":sunny:",
":sunrise:",
":surfer:",
":swimmer:",
":syringe:",
":tada:",
":tangerine:",
":taxi:",
":tennis:",
":tent:",
":thought_balloon:",
":tm:",
":toilet:",
":tongue:",
":tophat:",
":tractor:",
":trolleybus:",
":trollface:",
":trophy:",
":trumpet:",
":turtle:",
":two_men_holding_hands:",
":two_women_holding_hands:",
":uk:",
":umbrella:",
":unlock:",
":us:",
":v:",
":vhs:",
":violin:",
":warning:",
":watermelon:",
":wave:",
":wavy_dash:",
":wc:",
":wheelchair:",
":woman:",
":x:",
":yum:",
":zap:",
":zzz:"
]

9
emoji/map.go Normal file
View File

@ -0,0 +1,9 @@
//go:generate go run map_json.go
package emoji
// Map returns the emoji at the provided position.
// This list is from 0-255
func Map(b byte) string {
return sumList[int(b)]
}

262
emoji/map_gen.go Normal file
View File

@ -0,0 +1,262 @@
// THIS FILE IS GENERATED. DO NOT EDIT.
package emoji
var sumList = []string{
":+1:",
":8ball:",
":airplane:",
":alien:",
":anchor:",
":angel:",
":angry:",
":ant:",
":apple:",
":art:",
":baby:",
":baby_bottle:",
":back:",
":bamboo:",
":banana:",
":barber:",
":bathtub:",
":beer:",
":bell:",
":bicyclist:",
":bird:",
":birthday:",
":blossom:",
":blue_car:",
":boar:",
":bomb:",
":boom:",
":bow:",
":boy:",
":broken_heart:",
":bulb:",
":bus:",
":cactus:",
":calendar:",
":camera:",
":candy:",
":cat:",
":cherries:",
":children_crossing:",
":chocolate_bar:",
":clap:",
":cloud:",
":clubs:",
":cn:",
":coffee:",
":construction:",
":cookie:",
":copyright:",
":corn:",
":cow:",
":crescent_moon:",
":crown:",
":cry:",
":crystal_ball:",
":curly_loop:",
":dancers:",
":dash:",
":de:",
":diamonds:",
":dog:",
":doughnut:",
":dragon:",
":dvd:",
":ear:",
":eggplant:",
":elephant:",
":end:",
":envelope:",
":es:",
":eyes:",
":facepunch:",
":family:",
":ferris_wheel:",
":finnadie:",
":fire:",
":fireworks:",
":floppy_disk:",
":football:",
":fork_and_knife:",
":four_leaf_clover:",
":fr:",
":fries:",
":frog:",
":fu:",
":full_moon:",
":game_die:",
":eu:",
":gem:",
":girl:",
":goat:",
":grimacing:",
":grin:",
":guardsman:",
":guitar:",
":gun:",
":hamburger:",
":hammer:",
":hamster:",
":hear_no_evil:",
":heart:",
":heart_eyes_cat:",
":hearts:",
":heavy_check_mark:",
":moyai:",
":izakaya_lantern:",
":helicopter:",
":hocho:",
":honeybee:",
":horse:",
":horse_racing:",
":hourglass:",
":house:",
":hurtrealbad:",
":icecream:",
":imp:",
":it:",
":jack_o_lantern:",
":japanese_goblin:",
":jp:",
":key:",
":kiss:",
":kissing_cat:",
":koala:",
":kr:",
":lemon:",
":lipstick:",
":lock:",
":lollipop:",
":man:",
":maple_leaf:",
":mask:",
":metal:",
":microscope:",
":moneybag:",
":monkey:",
":mount_fuji:",
":muscle:",
":mushroom:",
":musical_keyboard:",
":musical_score:",
":nail_care:",
":new_moon:",
":no_entry:",
":nose:",
":notes:",
":nut_and_bolt:",
":o:",
":ocean:",
":ok_hand:",
":on:",
":package:",
":palm_tree:",
":panda_face:",
":paperclip:",
":partly_sunny:",
":passport_control:",
":paw_prints:",
":peach:",
":penguin:",
":phone:",
":pig:",
":pill:",
":pineapple:",
":pizza:",
":point_left:",
":point_right:",
":poop:",
":poultry_leg:",
":pray:",
":princess:",
":purse:",
":pushpin:",
":rabbit:",
":rainbow:",
":raised_hand:",
":recycle:",
":red_car:",
":registered:",
":ribbon:",
":rice:",
":rocket:",
":roller_coaster:",
":rooster:",
":ru:",
":sailboat:",
":santa:",
":satellite:",
":satisfied:",
":saxophone:",
":scissors:",
":see_no_evil:",
":sheep:",
":shell:",
":shoe:",
":ski:",
":skull:",
":sleepy:",
":smile:",
":smiley_cat:",
":smirk:",
":smoking:",
":snail:",
":snake:",
":snowflake:",
":soccer:",
":soon:",
":space_invader:",
":spades:",
":speak_no_evil:",
":star:",
":stars:",
":statue_of_liberty:",
":steam_locomotive:",
":sunflower:",
":sunglasses:",
":sunny:",
":sunrise:",
":surfer:",
":swimmer:",
":syringe:",
":tada:",
":tangerine:",
":taxi:",
":tennis:",
":tent:",
":thought_balloon:",
":tm:",
":toilet:",
":tongue:",
":tophat:",
":tractor:",
":trolleybus:",
":trollface:",
":trophy:",
":trumpet:",
":turtle:",
":two_men_holding_hands:",
":two_women_holding_hands:",
":uk:",
":umbrella:",
":unlock:",
":us:",
":v:",
":vhs:",
":violin:",
":warning:",
":watermelon:",
":wave:",
":wavy_dash:",
":wc:",
":wheelchair:",
":woman:",
":x:",
":yum:",
":zap:",
":zzz:",
}

47
emoji/map_json.go Normal file
View File

@ -0,0 +1,47 @@
// +build ignore
package main
import (
"encoding/json"
"log"
"os"
"text/template"
)
func main() {
input, err := os.Open("map-draft.json")
if err != nil {
log.Fatal(err)
}
defer input.Close()
// these are an ordered list, referened by a byte (each byte of a checksum digest)
Map := []string{}
dec := json.NewDecoder(input)
if err := dec.Decode(&Map); err != nil {
log.Fatal(err)
}
output, err := os.Create("map_gen.go")
if err != nil {
log.Fatal(err)
}
defer output.Close()
if err := mapGoTemp.Execute(output, Map); err != nil {
log.Fatal(err)
}
}
var (
mapGoText = `// THIS FILE IS GENERATED. DO NOT EDIT.
package emoji
var sumList = []string{ {{- range . }}
"{{.}}",{{- end }}
}
`
mapGoTemp = template.Must(template.New("map.go").Parse(mapGoText))
)

268
main.go
View File

@ -12,6 +12,7 @@ import (
"strings"
"github.com/kyokomi/emoji"
esum "github.com/vbatts/emojisum/emoji"
)
func main() {
@ -173,272 +174,7 @@ func Sum(r io.Reader) ([]byte, error) {
func emojiFromBytes(buf []byte) string {
var ret string
for _, b := range buf {
ret = ret + emojiFromRune(b)
ret = ret + esum.Map(b)
}
return ret
}
func emojiFromRune(b byte) string {
//fmt.Printf("%#v\n", b)
return emojiMap[int(b)]
}
// these are an ordered list, referened by a byte (each byte of a checksum digest)
var emojiMap = []string{
":+1:",
":8ball:",
":airplane:",
":alien:",
":anchor:",
":angel:",
":angry:",
":ant:",
":apple:",
":art:",
":baby:",
":baby_bottle:",
":back:",
":bamboo:",
":banana:",
":barber:",
":bathtub:",
":beer:",
":bell:",
":bicyclist:",
":bird:",
":birthday:",
":blossom:",
":blue_car:",
":boar:",
":bomb:",
":boom:",
":bow:",
":boy:",
":broken_heart:",
":bulb:",
":bus:",
":cactus:",
":calendar:",
":camera:",
":candy:",
":cat:",
":cherries:",
":children_crossing:",
":chocolate_bar:",
":clap:",
":cloud:",
":clubs:",
":cn:",
":coffee:",
":construction:",
":cookie:",
":copyright:",
":corn:",
":cow:",
":crescent_moon:",
":crown:",
":cry:",
":crystal_ball:",
":curly_loop:",
":dancers:",
":dash:",
":de:",
":diamonds:",
":dog:",
":doughnut:",
":dragon:",
":dvd:",
":ear:",
":eggplant:",
":elephant:",
":end:",
":envelope:",
":es:",
":eyes:",
":facepunch:",
":family:",
":ferris_wheel:",
":finnadie:",
":fire:",
":fireworks:",
":floppy_disk:",
":football:",
":fork_and_knife:",
":four_leaf_clover:",
":fr:",
":fries:",
":frog:",
":fu:",
":full_moon:",
":game_die:",
":eu:",
":gem:",
":girl:",
":goat:",
":grimacing:",
":grin:",
":guardsman:",
":guitar:",
":gun:",
":hamburger:",
":hammer:",
":hamster:",
":hear_no_evil:",
":heart:",
":heart_eyes_cat:",
":hearts:",
":heavy_check_mark:",
":moyai:",
":izakaya_lantern:",
":helicopter:",
":hocho:",
":honeybee:",
":horse:",
":horse_racing:",
":hourglass:",
":house:",
":hurtrealbad:",
":icecream:",
":imp:",
":it:",
":jack_o_lantern:",
":japanese_goblin:",
":jp:",
":key:",
":kiss:",
":kissing_cat:",
":koala:",
":kr:",
":lemon:",
":lipstick:",
":lock:",
":lollipop:",
":man:",
":maple_leaf:",
":mask:",
":metal:",
":microscope:",
":moneybag:",
":monkey:",
":mount_fuji:",
":muscle:",
":mushroom:",
":musical_keyboard:",
":musical_score:",
":nail_care:",
":new_moon:",
":no_entry:",
":nose:",
":notes:",
":nut_and_bolt:",
":o:",
":ocean:",
":ok_hand:",
":on:",
":package:",
":palm_tree:",
":panda_face:",
":paperclip:",
":partly_sunny:",
":passport_control:",
":paw_prints:",
":peach:",
":penguin:",
":phone:",
":pig:",
":pill:",
":pineapple:",
":pizza:",
":point_left:",
":point_right:",
":poop:",
":poultry_leg:",
":pray:",
":princess:",
":purse:",
":pushpin:",
":rabbit:",
":rainbow:",
":raised_hand:",
":recycle:",
":red_car:",
":registered:",
":ribbon:",
":rice:",
":rocket:",
":roller_coaster:",
":rooster:",
":ru:",
":sailboat:",
":santa:",
":satellite:",
":satisfied:",
":saxophone:",
":scissors:",
":see_no_evil:",
":sheep:",
":shell:",
":shoe:",
":ski:",
":skull:",
":sleepy:",
":smile:",
":smiley_cat:",
":smirk:",
":smoking:",
":snail:",
":snake:",
":snowflake:",
":soccer:",
":soon:",
":space_invader:",
":spades:",
":speak_no_evil:",
":star:",
":stars:",
":statue_of_liberty:",
":steam_locomotive:",
":sunflower:",
":sunglasses:",
":sunny:",
":sunrise:",
":surfer:",
":swimmer:",
":syringe:",
":tada:",
":tangerine:",
":taxi:",
":tennis:",
":tent:",
":thought_balloon:",
":tm:",
":toilet:",
":tongue:",
":tophat:",
":tractor:",
":trolleybus:",
":trollface:",
":trophy:",
":trumpet:",
":turtle:",
":two_men_holding_hands:",
":two_women_holding_hands:",
":uk:",
":umbrella:",
":unlock:",
":us:",
":v:",
":vhs:",
":violin:",
":warning:",
":watermelon:",
":wave:",
":wavy_dash:",
":wc:",
":wheelchair:",
":woman:",
":x:",
":yum:",
":zap:",
":zzz:",
}