Skip to content

Commit

Permalink
Convert mailer_emoji JSON file to map
Browse files Browse the repository at this point in the history
This fixes a pending TODO comment regarding inefficient tags to emojis
mapping, by requiring a full scan over emoji aliases to determine
matches.

Instead, now the JSON file is a map, with aliases as keys, and emojis as
values. The script to convert the file with Python was:

```python
import json

with open("./mailer_emoji.json", "r", encoding="utf-8") as f:
    content = json.load(f)

emoji_map = {}
for emoji in content:
    for alias in emoji["aliases"]:
        if alias in emoji_map:
            print("WARNING: Duplicate alias:", alias)
            continue
        emoji_map[alias] = str(emoji["emoji"])

sorted_emoji_map = {k: emoji_map[k] for k in sorted(emoji_map)}

with open("./mailer_emoji_map.json", "w", encoding="utf-8") as f:
    json.dump(sorted_emoji_map, f, indent=4, ensure_ascii=False)
```
  • Loading branch information
adamantike committed May 13, 2023
1 parent bd81aef commit 0acf910
Show file tree
Hide file tree
Showing 3 changed files with 1,868 additions and 14 deletions.
1 change: 0 additions & 1 deletion server/mailer_emoji.json

This file was deleted.

Loading

0 comments on commit 0acf910

Please sign in to comment.