Python: captionbob.emoji
captionbob.emoji.unicode_emoji
Unicode emoji data: the name, group, skin tones and keywords of an emoji.
The Unicode file emoji-test.txt lists every emoji with its codepoints, its status, its name and its group and subgroup. The reader takes the emojis of the status fully-qualified, which are the forms that a keyboard sends. An emoji with a skin tone codepoint, 1f3fb to 1f3ff, is a skin tone version of an emoji with no skin tone, its base. The base has the same codepoints with no skin tone and no FE0F. When no emoji has them, as for handshake: light skin tone, dark skin tone, the base is the emoji whose name is the part of the name before the colon.
The CLDR annotation files give the keywords of an emoji and its names to read out, such as doctor, medicine and pill for the pill emoji. They are JSON files of the cldr-json project, one for the emojis and one for the emojis derived from others, such as flags and skin tones. Their keys are the emojis with no FE0F.
Source file: captionbob/emoji/unicode_emoji.py
UnicodeEmoji
class UnicodeEmoji(NamedTuple)
One fully-qualified emoji of emoji-test.txt.
Args:
codepoints: The codepoints of the emoji, with FE0F where the file has it.name: The name of the emoji, such as woman health worker.group: The group of the emoji, such as People & Body.subgroup: The subgroup of the emoji, such as person-role.
EmojiFamily
class EmojiFamily(NamedTuple)
An emoji with no skin tone and its skin tone versions.
Args:
base: The emoji with no skin tone.skin_tones: Its skin tone versions, in the order of the file.
CldrAnnotation
class CldrAnnotation(NamedTuple)
The CLDR words of an emoji.
Args:
names: The names of the emoji to read out.keywords: The keywords of the emoji.
plain_codepoints
def plain_codepoints(codepoints: Sequence[int]) -> tuple[int, ...]
Give the codepoints with no FE0F.
Args:
codepoints: The codepoints of an emoji.
Returns:
The codepoints in their order, with no FE0F.
has_skin_tone
def has_skin_tone(codepoints: Sequence[int]) -> bool
Say if an emoji has a skin tone codepoint.
Args:
codepoints: The codepoints of the emoji.
Returns:
True when one codepoint is 1f3fb to 1f3ff.
read_emoji_test
def read_emoji_test(text: str) -> tuple[UnicodeEmoji, ...]
Read the fully-qualified emojis of emoji-test.txt.
Args:
text: The text of the file.
Returns:
The emojis in the order of the file, each with the group and the subgroup of the lines above it.
Raises:
ValueError: When a line does not have the form of the file, when an emoji comes before the first group, when an emoji is in the file two times, or when the file has no emoji.
emoji_families
def emoji_families(emojis: Sequence[UnicodeEmoji]) -> tuple[EmojiFamily, ...]
Link each skin tone version to its base.
Args:
emojis: The emojis of emoji-test.txt.
Returns:
One family for each emoji with no skin tone, in the order of the emojis, with its skin tone versions.
Raises:
ValueError: When a skin tone version has no base.
read_cldr_annotations
def read_cldr_annotations(
file_data: object) -> dict[tuple[int, ...], CldrAnnotation]
Read the names and the keywords of a CLDR annotation file.
Args:
file_data: The file as JSON reads it: a mapping with one of the keys annotations or annotationsDerived, which holds a mapping whose annotations map each emoji to its lists default and tts.
Returns:
The names and the keywords of each emoji, by its codepoints with no FE0F. A missing list gives no text.
Raises:
ValueError: When the file does not have this form.