# Builds the test strings for the caption counting tests. Output: inputs.json (word counter) and tags.json (hashtag counter).
import json
fam = "\U0001F468‍\U0001F469‍\U0001F467"          # family emoji, 3 people + 2 joiners
flag = "\U0001F1E9\U0001F1EA"                                  # regional indicators D E
thumb = "\U0001F44D\U0001F3FD"                                 # thumbs up, skin tone
croissant = "\U0001F950"
bold_b = "\U0001D401"                                          # mathematical bold B (a "fancy font" letter)
sample = ("Weeknight pasta in 15 minutes " + croissant + "\nThree pantry ingredients, one pan, and a sauce that clings.\n"
          "Save this for Thursday. Full recipe below.\n\n#pasta #dinner #quick_meals #15min #weeknight")
items = [
 {"id": "empty", "text": "", "note": "control: empty box"},
 {"id": "a2200", "text": "a" * 2200, "note": "control: 2,200 letters"},
 {"id": "a2201", "text": "a" * 2201, "note": "control: 2,201 letters"},
 {"id": "sample", "text": sample, "note": "made-up recipe caption, 1 emoji, 4 line breaks"},
 {"id": "croissant-1100", "text": croissant * 1100, "note": "1,100 emoji"},
 {"id": "croissant-1101", "text": croissant * 1101, "note": "1,101 emoji"},
 {"id": "letters-100-croissant", "text": "a" * 2100 + croissant * 100, "note": "2,100 letters + 100 emoji"},
 {"id": "family", "text": fam, "note": "one family emoji"},
 {"id": "flag", "text": flag, "note": "one flag"},
 {"id": "thumb-tone", "text": thumb, "note": "thumbs up with skin tone"},
 {"id": "keycap-1", "text": "1️⃣", "note": "keycap 1"},
 {"id": "e-acute-nfc", "text": "café", "note": "precomposed e-acute"},
 {"id": "e-acute-nfd", "text": "café", "note": "e + combining acute"},
 {"id": "cjk", "text": "今日のランチ", "note": "6 CJK characters"},
 {"id": "bold-fancy", "text": bold_b * 10, "note": "10 mathematical bold letters (fancy font style)"},
 {"id": "line-breaks", "text": "a\n\nb\nc", "note": "3 line breaks"},
]
json.dump(items, open("inputs.json", "w"), ensure_ascii=False, indent=1)
tags = [
 {"id": "none", "text": "no tags here", "expect": 0},
 {"id": "three", "text": "#a #b #c", "expect": 3},
 {"id": "five", "text": "#one #two #three #four #five", "expect": 5},
 {"id": "six", "text": "#one #two #three #four #five #six", "expect": 6},
 {"id": "lone-hash", "text": "# alone and ## and #!", "expect": 0},
 {"id": "joined", "text": "#tag1#tag2", "expect": 2},
 {"id": "digits", "text": "#2026", "expect": 1},
 {"id": "accent", "text": "#café", "expect": 1},
 {"id": "apostrophe", "text": "#don't", "expect": 1},
 {"id": "hyphen", "text": "#dont-stop", "expect": 1},
 {"id": "url-fragment", "text": "see example.com/page#section for more", "expect": 0, "note": "a link anchor, not a hashtag"},
 {"id": "duplicates", "text": "#Pasta #pasta #PASTA", "expect": 3, "unique": 1},
 {"id": "emoji-tag", "text": "#" + croissant, "expect": 0},
 {"id": "fullwidth", "text": "＃tag", "expect": 0, "note": "fullwidth number sign"},
 {"id": "cjk-tag", "text": "#今日", "expect": 1},
]
json.dump(tags, open("tags.json", "w"), ensure_ascii=False, indent=1)
print("wrote", len(items), "strings and", len(tags), "tag cases")
