Repository Public
1// =============================================================================2// SP BOUCHER | SOFTWARE & RESEARCH3// ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING4// =============================================================================5//6// PROJECT METADATA7// -----------------------------------------------------------------------------8// Project : SP Keyboard9// File : Shared/Sources/KeyboardCore/Emoji.swift10// Description : Local emoji catalogue by category with offline search11// (Unicode names in English plus French keywords). No usage12// history is kept: only favourites the user pins explicitly.13// Module : KeyboardCore14// Repository : https://git.spboucher.ai/sp-keyboard15// Created : 2026-12-0116// Last Modified : 2026-12-0117//18// =============================================================================19// AUTHOR & PROFESSIONAL AFFILIATION20// =============================================================================21//22// Author : Simon-Pierre Boucher23// Position : Professor of Finance24// Institution : Université du Québec en Outaouais (UQO)25// Department : Département des sciences administratives26// Organization : SP Boucher27//28// Website : https://spboucher.ai29// Git : https://git.spboucher.ai30//31// =============================================================================32// OFFICIAL CONTACT DIRECTORY33// =============================================================================34//35// General : info@spboucher.ai36// Professional : contact@spboucher.ai37// Direct : simon@spboucher.ai38// Research : research@spboucher.ai39// Development : dev@spboucher.ai40// Support : support@spboucher.ai41// Security/Admin : admin@spboucher.ai42// Notifications : notifications@spboucher.ai43//44// Preferred Contact: support@spboucher.ai45//46// =============================================================================47// COPYRIGHT & INTELLECTUAL PROPERTY48// =============================================================================49//50// Copyright (c) 202651// Simon-Pierre Boucher52//53// All rights reserved where applicable.54//55// This file is governed by the applicable project license,56// copyright notices, institutional agreements and relevant law.57//58// Unless expressly authorized by the applicable license or59// rights holder, copying, redistribution, sublicensing,60// publication and commercial exploitation are not permitted.61//62// Existing third-party rights and notices remain unaffected.63//64// =============================================================================65// CONFIDENTIALITY & SECURITY66// =============================================================================67//68// Classification : Public69// Distribution : Public repository; use is governed by the project license70// Security Contact : admin@spboucher.ai71//72// Access to this source does not independently grant permission73// to redistribute or disclose confidential materials.74//75// Do not embed credentials, private keys, access tokens,76// certificates or confidential personal information.77//78// =============================================================================79// LICENSE & MAINTENANCE80// =============================================================================81//82// License : None specified (no license file in this repository)83// Maintainer : Simon-Pierre Boucher84// Technical Contact: dev@spboucher.ai85//86// =============================================================================87// END OF SP BOUCHER SOURCE HEADER88// =============================================================================8990import Foundation9192public struct EmojiCategory: Sendable, Identifiable, Hashable {93 public var id: String94 public var title: String95 /// Glyph shown on the category tab.96 public var icon: String97 public var emoji: [String]98}99100public enum EmojiCatalog {101 private static func split(_ text: String) -> [String] {102 text.split(separator: " ").map(String.init)103 }104105 public static let categories: [EmojiCategory] = [106 EmojiCategory(id: "smileys", title: "Visages", icon: "😀", emoji: split(107 "😀 😃 😄 😁 😆 😅 🤣 😂 🙂 🙃 😉 😊 😇 🥰 😍 🤩 😘 😗 😚 😙 😋 😛 😜 🤪 😝 🤑 🤗 🤭 🤫 🤔 🤐 🤨 😐 😑 😶 😏 😒 🙄 😬 🤥 😌 😔 😪 🤤 😴 😷 🤒 🤕 🤢 🤮 🤧 🥵 🥶 🥴 😵 🤯 🤠 🥳 😎 🤓 🧐 😕 😟 🙁 😮 😯 😲 😳 🥺 😦 😧 😨 😰 😥 😢 😭 😱 😖 😣 😞 😓 😩 😫 🥱 😤 😡 😠 🤬 😈 👿 💀 💩 🤡 👻 👽 🤖 😺 😸 😹 😻 😼 😽 🙀 😿 😾")),108 EmojiCategory(id: "people", title: "Gestes", icon: "👋", emoji: split(109 "👋 🤚 🖐 ✋ 🖖 👌 🤏 ✌ 🤞 🤟 🤘 🤙 👈 👉 👆 👇 👍 👎 ✊ 👊 🤛 🤜 👏 🙌 👐 🤲 🤝 🙏 ✍ 💅 🤳 💪 🦵 🦶 👂 👃 🧠 👀 👁 👅 👄 👶 🧒 👦 👧 🧑 👨 👩 🧓 👴 👵 🙍 🙅 🙆 💁 🙋 🙇 🤦 🤷 👮 🕵 👷 🤴 👸 🤵 👰 🎅 🧙 🧟 💆 💇 🚶 🏃 💃 🕺 👯 🧘 👫 👪")),110 EmojiCategory(id: "hearts", title: "Cœurs", icon: "❤️", emoji: split(111 "❤️ 🧡 💛 💚 💙 💜 🖤 🤍 🤎 💔 ❣️ 💕 💞 💓 💗 💖 💘 💝 💟 💌 💋 💯 💢 💥 💫 💦 💨 💤 ✨ ⭐ 🌟 🔥 🎉 🎊 🎈 🎁 🏆 🥇 👑 💎")),112 EmojiCategory(id: "nature", title: "Nature", icon: "🌿", emoji: split(113 "🐶 🐱 🐭 🐹 🐰 🦊 🐻 🐼 🐨 🐯 🦁 🐮 🐷 🐸 🐵 🙈 🙉 🙊 🐔 🐧 🐦 🐤 🦆 🦅 🦉 🦇 🐺 🐗 🐴 🦄 🐝 🐛 🦋 🐌 🐞 🐜 🕷 🐢 🐍 🦎 🐙 🦑 🦐 🦞 🦀 🐡 🐠 🐟 🐬 🐳 🐋 🦈 🐊 🐅 🐆 🦓 🦍 🐘 🦛 🦏 🐪 🦒 🦘 🐃 🐄 🐎 🐖 🐏 🐑 🐐 🦌 🐕 🐩 🐈 🐓 🦃 🦚 🦜 🦢 🕊 🐇 🦝 🦫 🦦 🐿 🦔 🌵 🎄 🌲 🌳 🌴 🌱 🌿 ☘️ 🍀 🍃 🍂 🍁 🍄 🌾 💐 🌷 🌹 🥀 🌺 🌸 🌼 🌻 🌞 🌝 🌛 🌚 🌕 🌙 🌎 🪐 ⚡ ☄️ 🌈 ☀️ ⛅ ☁️ 🌧 ⛈ 🌩 ❄️ ☃️ ⛄ 🌬 💧 ☔ 🌊 🌫")),114 EmojiCategory(id: "food", title: "Nourriture", icon: "🍎", emoji: split(115 "🍏 🍎 🍐 🍊 🍋 🍌 🍉 🍇 🍓 🫐 🍈 🍒 🍑 🥭 🍍 🥥 🥝 🍅 🍆 🥑 🥦 🥬 🥒 🌶 🌽 🥕 🧄 🧅 🥔 🍠 🥐 🥯 🍞 🥖 🥨 🧀 🥚 🍳 🧈 🥞 🧇 🥓 🥩 🍗 🍖 🌭 🍔 🍟 🍕 🥪 🥙 🧆 🌮 🌯 🥗 🥘 🍝 🍜 🍲 🍛 🍣 🍱 🥟 🍤 🍙 🍚 🍘 🍥 🥠 🍢 🍡 🍧 🍨 🍦 🥧 🧁 🍰 🎂 🍮 🍭 🍬 🍫 🍿 🍩 🍪 🌰 🥜 🍯 🥛 🍼 ☕ 🍵 🧃 🥤 🍶 🍺 🍻 🥂 🍷 🥃 🍸 🍹 🧉 🍾 🧊 🥄 🍴 🍽")),116 EmojiCategory(id: "activity", title: "Activités", icon: "⚽", emoji: split(117 "⚽ 🏀 🏈 ⚾ 🥎 🎾 🏐 🏉 🥏 🎱 🏓 🏸 🏒 🏑 🥍 🏏 🥅 ⛳ 🏹 🎣 🥊 🥋 🎽 🛹 🛷 ⛸ 🥌 🎿 ⛷ 🏂 🏋 🤸 ⛹ 🤾 🏌 🏇 🏊 🤽 🚣 🧗 🚵 🚴 🎪 🎭 🎨 🎬 🎤 🎧 🎼 🎹 🥁 🎷 🎺 🎸 🎻 🎲 ♟ 🎯 🎳 🎮 🎰 🧩")),118 EmojiCategory(id: "travel", title: "Voyages", icon: "🚗", emoji: split(119 "🚗 🚕 🚙 🚌 🚎 🏎 🚓 🚑 🚒 🚐 🚚 🚛 🚜 🛵 🏍 🚲 🛴 🚨 🚔 🚍 🚘 🚖 🚡 🚠 🚟 🚃 🚋 🚞 🚝 🚄 🚅 🚈 🚂 🚆 🚇 🚊 🚉 ✈️ 🛫 🛬 🛩 💺 🛰 🚀 🛸 🚁 🛶 ⛵ 🚤 🛥 🛳 ⛴ 🚢 ⚓ ⛽ 🚧 🚦 🚥 🗺 🗿 🗽 🗼 🏰 🏯 🏟 🎡 🎢 🎠 ⛲ ⛱ 🏖 🏝 🏜 🌋 ⛰ 🏔 🗻 🏕 ⛺ 🏠 🏡 🏘 🏚 🏗 🏭 🏢 🏬 🏣 🏤 🏥 🏦 🏨 🏪 🏫 🏩 💒 🏛 ⛪ 🕌 🕍 🛕 🌁 🌃 🏙 🌄 🌅 🌆 🌇 🌉")),120 EmojiCategory(id: "objects", title: "Objets", icon: "💡", emoji: split(121 "⌚ 📱 📲 💻 ⌨️ 🖥 🖨 🖱 💽 💾 💿 📀 📷 📸 📹 🎥 📞 ☎️ 📟 📠 📺 📻 🎙 ⏱ ⏲ ⏰ 🕰 ⌛ ⏳ 📡 🔋 🔌 💡 🔦 🕯 🧯 💸 💵 💴 💶 💷 💰 💳 🧾 ✉️ 📧 📨 📩 📤 📥 📦 📫 📮 📝 💼 📁 📂 📅 📆 📇 📈 📉 📊 📋 📌 📍 📎 🖇 📏 📐 ✂️ 🗃 🗄 🗑 🔒 🔓 🔏 🔐 🔑 🗝 🔨 ⛏ ⚒ 🛠 🗡 ⚔️ 🔧 🔩 ⚙️ 🧰 🧲 ⚗️ 🧪 🧫 🧬 🔬 🔭 💉 💊 🩹 🩺 🚪 🛏 🛋 🚽 🚿 🛁 🧴 🧹 🧺 🧻 🧼 🧽 🛒 🎓 👓 🕶 👔 👕 👖 🧣 🧤 🧥 🧦 👗 👘 👙 👚 👛 👜 👝 🎒 👞 👟 👠 👡 👢 🎩 🧢 ⛑ 📿 💄 💍")),122 EmojiCategory(id: "symbols", title: "Symboles", icon: "✅", emoji: split(123 "✅ ☑️ ✔️ ❌ ❎ ➕ ➖ ➗ ✖️ ♾ ‼️ ⁉️ ❓ ❔ ❕ ❗ 〰️ ⚠️ 🚸 ⛔ 🚫 🚳 🚭 🚯 🚱 🚷 📵 🔞 ☢️ ☣️ ⬆️ ↗️ ➡️ ↘️ ⬇️ ↙️ ⬅️ ↖️ ↕️ ↔️ ↩️ ↪️ ⤴️ ⤵️ 🔃 🔄 🔙 🔚 🔛 🔜 🔝 🔀 🔁 🔂 ▶️ ⏩ ⏭ ⏯ ◀️ ⏪ ⏮ 🔼 ⏫ 🔽 ⏬ ⏸ ⏹ ⏺ ⏏️ 🎦 🔅 🔆 📶 📳 📴 ♀️ ♂️ ⚕️ ♻️ ⚜️ 🔱 📛 🔰 ⭕ 💠 Ⓜ️ 🌀 💲 💱 ™️ ©️ ®️ 🔟 🔠 🔡 🔢 🔣 🔤 🅰️ 🆎 🅱️ 🆑 🆒 🆓 ℹ️ 🆔 🆕 🆖 🅾️ 🆗 🅿️ 🆘 🆙 🆚 🔴 🟠 🟡 🟢 🔵 🟣 🟤 ⚫ ⚪ 🟥 🟧 🟨 🟩 🟦 🟪 🟫 ⬛ ⬜ 🔶 🔷 🔸 🔹 🔺 🔻 🔘 🔳 🔲 🏁 🚩 🎌 🏴 🏳️ 🇨🇦 🇫🇷 🇺🇸 🇪🇸 🇲🇽 🇬🇧 🇩🇪 🇮🇹 🇯🇵")),124 ]125126 public static let all: [String] = categories.flatMap(\.emoji)127128 /// French keywords for the emoji people actually look for; English comes from the Unicode names.129 static let french: [String: String] = [130 "😀": "sourire content heureux", "😂": "rire larmes mdr lol", "🤣": "rire mort de rire", "😊": "sourire content gentil",131 "😉": "clin d'oeil", "😍": "amour coeur yeux", "🥰": "amour tendre", "😘": "bisou bec", "😎": "cool lunettes soleil",132 "🤔": "penser réfléchir hmm", "😢": "triste larme pleurer", "😭": "pleurer triste", "😡": "fâché colère", "😴": "dormir dodo fatigué",133 "😱": "peur choc", "🤯": "explosion incroyable", "🥳": "fête célébrer", "🤗": "câlin", "🙄": "yeux au ciel", "😅": "ouf sueur",134 "👍": "pouce ok oui bravo", "👎": "pouce non", "👏": "bravo applaudir", "🙏": "merci prière svp", "💪": "fort muscle",135 "👋": "salut bonjour allo bye", "🤝": "poignée entente accord", "👀": "yeux regarder", "🤷": "je sais pas haussement",136 "🤦": "facepalm découragé", "❤️": "coeur amour rouge", "💔": "coeur brisé", "🔥": "feu chaud", "✨": "étincelles brillant magie",137 "🎉": "fête bravo célébration", "🎂": "gâteau fête anniversaire", "🎁": "cadeau", "⭐": "étoile", "💯": "cent parfait",138 "✅": "ok fait coché oui", "❌": "non croix erreur", "⚠️": "attention avertissement", "❓": "question", "❗": "exclamation important",139 "☕": "café", "🍺": "bière", "🍷": "vin", "🍕": "pizza", "🍔": "burger hamburger", "🍟": "frites poutine", "🍁": "érable feuille canada",140 "☀️": "soleil beau", "🌧": "pluie", "❄️": "neige froid hiver flocon", "⛄": "bonhomme neige hiver", "🌈": "arc-en-ciel",141 "🚗": "auto voiture char", "✈️": "avion voyage", "🏠": "maison", "🏒": "hockey", "⚽": "soccer football", "💻": "ordinateur portable",142 "📱": "téléphone cellulaire", "📧": "courriel", "📅": "calendrier date", "⏰": "réveil heure alarme", "💰": "argent sac",143 "💵": "argent dollar", "📈": "hausse graphique bourse", "📉": "baisse graphique bourse", "📊": "graphique statistiques",144 "🇨🇦": "canada drapeau", "🇫🇷": "france drapeau", "🐶": "chien", "🐱": "chat", "🦫": "castor", "🐻": "ours",145 "💡": "idée ampoule", "🔒": "cadenas sécurité", "🔑": "clé", "📝": "note écrire", "📌": "épingle", "🎓": "diplôme université",146 ]147148 /// Lower-cased searchable text of one emoji: its Unicode scalar names and its French keywords.149 public static func keywords(for emoji: String) -> String {150 let names = emoji.unicodeScalars.compactMap { scalar -> String? in151 guard scalar.value != 0xFE0F, scalar.value != 0x200D else { return nil }152 return scalar.properties.name?.lowercased()153 }154 return (names + [french[emoji] ?? ""]).joined(separator: " ")155 }156157 private static let index: [(emoji: String, text: String)] = all.map { ($0, TextFold.fold(keywords(for: $0))) }158159 /// Emoji whose names contain every word of `query` (accent and case insensitive), in catalogue order.160 public static func search(_ query: String, limit: Int = 48) -> [String] {161 let terms = TextFold.fold(query).split(separator: " ").map(String.init)162 guard !terms.isEmpty else { return [] }163 var results: [String] = []164 for entry in index where terms.allSatisfy({ entry.text.contains($0) }) {165 results.append(entry.emoji)166 if results.count >= limit { break }167 }168 return results169 }170}171172enum TextFold {173 static func fold(_ text: String) -> String {174 text.folding(options: [.diacriticInsensitive, .caseInsensitive], locale: Locale(identifier: "fr_CA")).lowercased()175 }176}177