{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Create a list of all ipa symbols\n",
    "\n",
    "Please refer [phonemes.md](text/phonemes.md)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Consonants\n",
    "\n",
    "consonants = \"\"\"\n",
    " m̥     | m     |       | ɱ     |       |       | n̥     | n     |       |       | ɳ̊     | ɳ     | ɲ̟̊     | ɲ̟     | ɲ̊     | ɲ     | ŋ̊     | ŋ     | ɴ̥     | ɴ     |       |       |       |       |\n",
    " p     | b     | p̪     | b̪     | t̪     | d̪     | t     | d     |       |       | ʈ     | ɖ     |       |       | c     | ɟ     | k     | ɡ     | q     | ɢ     | ʡ     |       | ʔ     |       |\n",
    "       |       |       |       |       |       | t͡s    | d͡z    | t͡ʃ    | d͡ʒ    | ʈ͡ʂ    | ɖ͡ʐ    | t͡ɕ    | d͡ʑ    |       |       |       |       |       |       |       |       |       |       |\n",
    " p͡ɸ    | b͡β    | p̪͡f    | b̪͡v    | t͡θ    | d͡ð    |       |       |       |       |       |       |       |       | c͡ç    | ɟ͡ʝ    | k͡x    | ɡ͡ɣ    | q͡χ    | ɢ͡ʁ    | ʡ͡ħ    | ʡ͡ʕ    | ʔ͡h    |       |\n",
    "       |       |       |       |       |       | t͡ɬ    | d͡ɮ    |       |       | ʈ͡ɭ̊˔   |       |       |       | c͡ʎ̥˔   |       | k͡ʟ̝̊    | ɡ͡ʟ̝    |       |       |       |       |       |       |\n",
    "       |       |       |       |       |       | s     | z     | ʃ     | ʒ     | ʂ     | ʐ     | ɕ     | ʑ     |       |       |       |       |       |       |       |       |       |       |\n",
    " ɸ     | β     | f     | v     | θ     | ð     |       |       |       |       |       |       |       |       | ç     | ʝ     | x     | ɣ     | χ     | ʁ     | ħ     | ʕ     | h     | ɦ     |\n",
    "       |       |       |       |       |       | ɬ     | ɮ     |       |       | ɭ̊˔    |       |       |       | ʎ̥˔    | ʎ̝     | ʟ̝̊     | ʟ̝     |       |       |       |       |       |       |\n",
    "       |       | ʋ̥     | ʋ     |       |       | ɹ̥     | ɹ     |       |       | ɻ̊     | ɻ     |       |       | j̊     | j     | ɰ̊     | ɰ     |       |       |       |       |       |       |\n",
    "       |       |       |       |       |       | l̥     | l     |       |       | ɭ̊     | ɭ     |       |       | ʎ̥     | ʎ     | ʟ̥     | ʟ     |       | ʟ̠     |       |       |       |       |\n",
    "       | ⱱ̟     |       | ⱱ     |       |       | ɾ̥     | ɾ     |       |       | ɽ̊     | ɽ     |       |       |       |       |       |       |       | ɢ̆     |       | ʡ̮     |       |       |\n",
    "       |       |       |       |       |       |       | ɺ     |       |       |       | ɭ̆     |       |       |       | ʎ̮     |       | ʟ̆     |       |       |       |       |       |       |\n",
    "       | ʙ     |       |       |       |       | r̥     | r     |       |       | ɽ͡r̥    | ɽ͡r    |       |       |       |       |       |       | ʀ̥     | ʀ     | ʜ     | ʢ     |       |       |\n",
    " ʘ     |       |       |       | ǀ     |       | ǃ     |       |       |       |       |       | ǂ     |       |       |       |       |       |       |       |       |       |       |       |\n",
    "       |       |       |       |       |       | ǁ     |       |       |       |       |       |       |       |       |       |       |       |       |       |       |       |       |       |\n",
    "       | ɓ     |       |       |       |       |       | ɗ     |       |       |       |       |       |       |       | ʄ     |       | ɠ     |       | ʛ     |       |       |       |       |\n",
    " pʼ    |       |       |       |       |       | tʼ    |       |       |       | ʈʼ    |       |       |       | cʼ    |       | kʼ    |       | qʼ    |       | ʡʼ    |       |       |       |\n",
    "       |       | fʼ    |       | θʼ    |       | sʼ    |       | ʃʼ    |       | ʂʼ    |       |       |       |       |       | xʼ    |       | χʼ    |       |       |       |       |       |\n",
    "       |       |       |       |       |       | ɬʼ    |       |       |       |       |       |       |       |       |       |       |       |       |       |       |       |       |       |\n",
    "\"\"\"\n",
    "\n",
    "consonants_other = \"\"\"\n",
    "       |       |       |       |       |       |       |       |       | ŋ͡m    |       |       |\n",
    "       |       |       |       |       |       |       |       | k͡p    | ɡ͡b    |       |       |\n",
    " p͡f    | b͡v    |       |       |       |       |       |       |       |       |       |       |\n",
    "       |       |       |       | ɧ     |       |       |       |       |       |       |       |\n",
    "       |       |       |       |       |       |       | ɥ     |       |       | ʍ     | w     |\n",
    "       |       |       | ɫ     |       |       |       |       |       |       |       |       |\n",
    "\"\"\"\n",
    "\n",
    "\n",
    "manner_of_articulation = \"\"\"\n",
    " ʼ     |\n",
    "\"\"\"\n",
    "\n",
    "# Vowels\n",
    "\n",
    "vowels = \"\"\"\n",
    " i     | y     | ɨ     | ʉ     | ɯ     | u     |\n",
    " ɪ     | ʏ     |       |       |       | ʊ     |\n",
    " e     | ø     | ɘ     | ɵ     | ɤ     | o     |\n",
    "       |       | ə     |       |       |       |\n",
    " ɛ     | œ     | ɜ     | ɞ     | ʌ     | ɔ     |\n",
    " æ     |       | ɐ     |       |       |       |\n",
    " a     | ɶ     |       |       | ɑ     | ɒ     |\n",
    "\"\"\"\n",
    "\n",
    "\n",
    "vowels_other = \"\"\"\n",
    "| ɚ      |\n",
    "| ɝ      |\n",
    "\"\"\"\n",
    "\n",
    "# Diacritics\n",
    "\n",
    "articulation = \"\"\"\n",
    " ◌̼      |\n",
    " ◌̪͆    |\n",
    " ◌̪      |\n",
    " ◌̺      |\n",
    " ◌̻      |\n",
    " ◌̟      |\n",
    " ◌̠      |\n",
    " ◌̈      |\n",
    " ◌̽      |\n",
    " ◌̝      |\n",
    " ◌̞      |\n",
    "\"\"\"\n",
    "\n",
    "air_flow = \"\"\"\n",
    " ↑      |\n",
    " ↓      |\n",
    "\"\"\"\n",
    "\n",
    "phonation = \"\"\"\n",
    " ◌̤      |\n",
    " ◌̥      |\n",
    " ◌̬      |\n",
    " ◌̰      |\n",
    " ʔ͡◌     |\n",
    "\"\"\"\n",
    "\n",
    "rounding_and_labialization = \"\"\"\n",
    " ◌ʷ◌ᶣ |\n",
    " ◌ᵝ     |\n",
    " ◌̹      |\n",
    " ◌̜      |\n",
    "\"\"\"\n",
    "\n",
    "\n",
    "syllabicity = \"\"\"\n",
    " ◌̩      |\n",
    " ◌̯      |\n",
    "\"\"\"\n",
    "\n",
    "consonant_release = \"\"\"\n",
    " ◌ʰ     |\n",
    " ◌ⁿ     |\n",
    " ◌ˡ     |\n",
    " ◌̚      |\n",
    "\"\"\"\n",
    "\n",
    "co_articulation = \"\"\"\n",
    " ◌ʲ     |\n",
    " ◌ˠ◌̴  |\n",
    " ◌ˤ◌̴  |\n",
    " ◌̃      |\n",
    " ◌˞     |\n",
    "\"\"\"\n",
    "\n",
    "tongue_root = \"\"\"\n",
    " ◌̘      |\n",
    " ◌̙      |\n",
    "\"\"\"\n",
    "\n",
    "fortis_and_lenis = \"\"\"\n",
    " ◌͈      |\n",
    " ◌͉      |\n",
    "\"\"\"\n",
    "\n",
    "# Suprasegmentals\n",
    "\n",
    "stress = \"\"\"\n",
    " ˈ◌   |\n",
    " ˌ◌   |\n",
    "\"\"\"\n",
    "\n",
    "length = \"\"\"\n",
    " ◌̆      |\n",
    " ◌ˑ     |\n",
    " ◌ː     |\n",
    " ◌ːː    |\n",
    "\"\"\"\n",
    "\n",
    "rhythm = \"\"\"\n",
    " .    |\n",
    " ◌‿◌  |\n",
    "\"\"\"\n",
    "\n",
    "tones = \"\"\"\n",
    " ◌˥   |\n",
    " ◌˦   |\n",
    " ◌˧   |\n",
    " ◌˨   |\n",
    " ◌˩   |\n",
    " ꜛ◌   |\n",
    " ꜜ◌   |\n",
    "\"\"\"\n",
    "\n",
    "intonation = \"\"\"\n",
    " |    |\n",
    " ‖    |\n",
    " ↗︎    |\n",
    " ↘︎    |\n",
    "\"\"\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "def get_non_empty_content(md_table):\n",
    "    non_empty_content = []\n",
    "\n",
    "    # Split table by lines\n",
    "    lines = md_table.split(\"\\n\")\n",
    "\n",
    "    for line in lines:\n",
    "        # Split each line by \"|\" to get the cells\n",
    "        cells = line.split(\"|\")\n",
    "\n",
    "        for cell in cells:\n",
    "            cell_content = cell.strip()\n",
    "\n",
    "            # If the cell content is not empty, add it to the list\n",
    "            if cell_content != \"\":\n",
    "                non_empty_content.append(cell_content)\n",
    "\n",
    "    non_empty_content = \"\".join(non_empty_content)\n",
    "\n",
    "    # unique non_empty_content\n",
    "    non_empty_content = set(non_empty_content)\n",
    "    non_empty_content = \"\".join(non_empty_content)\n",
    "\n",
    "    # sort non_empty_content\n",
    "    non_empty_content = sorted(non_empty_content)\n",
    "\n",
    "    return non_empty_content\n",
    "\n",
    "\n",
    "# Consonants\n",
    "consonants = get_non_empty_content(consonants)\n",
    "consonants_other = get_non_empty_content(consonants_other)\n",
    "manner_of_articulation = get_non_empty_content(manner_of_articulation)\n",
    "# Vowels\n",
    "vowels = get_non_empty_content(vowels)\n",
    "vowels_other = get_non_empty_content(vowels_other)\n",
    "# Diacritics\n",
    "articulation = get_non_empty_content(articulation)\n",
    "air_flow = get_non_empty_content(air_flow)\n",
    "phonation = get_non_empty_content(phonation)\n",
    "rounding_and_labialization = get_non_empty_content(rounding_and_labialization)\n",
    "syllabicity = get_non_empty_content(syllabicity)\n",
    "consonant_release = get_non_empty_content(consonant_release)\n",
    "co_articulation = get_non_empty_content(co_articulation)\n",
    "tongue_root = get_non_empty_content(tongue_root)\n",
    "fortis_and_lenis = get_non_empty_content(fortis_and_lenis)\n",
    "# Suprasegmentals\n",
    "stress = get_non_empty_content(stress)\n",
    "length = get_non_empty_content(length)\n",
    "rhythm = get_non_empty_content(rhythm)\n",
    "tones = get_non_empty_content(tones)\n",
    "intonation = get_non_empty_content(intonation)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# All symbols\n",
    "_ipa = (\n",
    "    consonants\n",
    "    + consonants_other\n",
    "    + manner_of_articulation\n",
    "    + vowels\n",
    "    + vowels_other\n",
    "    + articulation\n",
    "    + air_flow\n",
    "    + phonation\n",
    "    + rounding_and_labialization\n",
    "    + syllabicity\n",
    "    + consonant_release\n",
    "    + co_articulation\n",
    "    + tongue_root\n",
    "    + fortis_and_lenis\n",
    "    + stress\n",
    "    + length\n",
    "    + rhythm\n",
    "    + tones\n",
    "    + intonation\n",
    ")\n",
    "\n",
    "print(_ipa)\n",
    "print(len(_ipa))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "_ipa = \"\".join(_ipa)\n",
    "\n",
    "# unique _ipa\n",
    "_ipa = set(_ipa)\n",
    "_ipa = \"\".join(_ipa)\n",
    "\n",
    "# sort symbols\n",
    "_ipa = sorted(_ipa)\n",
    "\n",
    "print(f'_ipa = \"{\"\".join(_ipa)}\"')\n",
    "print(len(_ipa))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "_punctuation = ';:,.!?¡¿—…\"«»“” '\n",
    "\n",
    "symbols = list(_punctuation) + list(_ipa)\n",
    "\n",
    "# unique symbols\n",
    "symbols = set(symbols)\n",
    "symbols = \"\".join(symbols)\n",
    "\n",
    "# sort symbols\n",
    "symbols = sorted(symbols)\n",
    "\n",
    "symbols = \"\".join(symbols)\n",
    "\n",
    "print(f'symbols = \"{\"\".join(symbols)}\"')\n",
    "print(len(symbols))"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "py11",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.4"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
