canTone launched with a singular mission: to provide the most complete, lightning-fast offline search engine for Cantonese lyric writing. If you are learning how to write Cantopop lyrics or producing tracks in Hong Kong, you know that finding the exact word to fit a melody is a mathematical challenge. 

Our application ships the entire dictionary and query engine locally to your device. There are no servers required, no internet connection needed, and absolutely no dependency on older, web-based legacy tone-matching websites. Originally conceived as a macOS developer tool, v0.1 brings our highly optimized local backend to both **Windows and macOS**, creating a dedicated, distraction-free environment for professional music production.

## Core Search Engine & Syntax

To build a professional Cantonese lyric writing software, we developed a fundamental search model based on **left-to-right chaining**. Every operator you type modifies the token immediately following it, allowing you to combine multiple operators in a single query to build hyper-specific searches for your songwriting process.

- **Strict Syllable Length Matching:** This feature is turned on by default. The number of search tokens you type determines the exact syllable count of the results you get back. If you want to find a pattern anywhere within a longer phrase, simply append a `-` (for example, `-0243-`) to unbind that restriction.
- **Full-Width Symbol Support:** Variants of all standard symbols (such as `＠`, `％`, `！！`, `＄＄`) are fully supported by the engine, ensuring you never have to waste time switching your keyboard language mid-query.
- **Alternatives and OR Logic:** Use the `/` operator to create OR logic within any search string (for example, typing `>香/港` will instantly find Cantonese words rhyming with either character).

---

## Melody & Tone Search (Cantonese Tone Matching)

Matching words by their tonal contour is the defining "hip jam" (協音) requirement of Cantopop lyric writing. Our offline Cantonese tone matching dictionary supports multiple notation systems to fit your workflow.

- **4-Tone Mode (0243):** This is the original Cantonese lyricist number system. Typing `0243` finds 4-syllable phrases perfectly matching the flat-low, low-rising, flat-mid, and high-falling pitch contour. Typing `33` finds 2-syllable words where both characters are pronounced mid-flat.
- **5-Tone and 6-Tone Modes (02493 / 025493):** For advanced writers, the 5-tone mode uses `9` to safely distinguish a high-rising tone from a flat-high `3`. The 6-tone mode introduces `5` to separate a low-rising tone from a low-falling `4`.
- **9-Tone Mode (Entering Tones):** This mode is crucial for precise rhythmic writing, including high (`1`), mid (`8`), and low (`6`) checked tones covering the sharp `-p`, `-t`, and `-k` endings. 
- **Classical Ping/Zak (`P`/`Z`):** For traditional flat/oblique poetic notation, typing `PZ` finds a 2-syllable word where the first is an even tone (平) and the second is an oblique tone (仄).
- **Wildcards and Explicit Melodies:** The `?` operator acts as a wildcard, holding a position without specifying a tone (e.g., `0?3`). The explicit melody marker (`^`) lets you write phonetic operators in any order, so `>聲^0243` reliably matches rhymes of "聲" that specifically follow the 0243 sequence.
- **Monotones (`^^`):** Use this operator to find Cantonese words where every single syllable shares the exact same tone, such as `-3^^` for all-3 words of any length.

---

## Phonetics Search & Jyutping Rhyming

Modern hip-hop flows and pop structures require more than just tone matching. canTone doubles as a comprehensive Jyutping rhyme dictionary, allowing you to drill down into the exact phonetic structures of your lyrics.

- **Cantonese Rhymes (`>`):** Typing `>港` finds words perfectly rhyming with the final vowel and consonant of 港 (`-ong`).
- **Alliteration (`<`):** Typing `>`):** This instantly finds words where all syllables share the exact same rime, known in Chinese linguistics as 疊韻.
- **Alliterative Compounds (`<<`):** This finds words where all syllables share the exact same initial consonant (雙聲).
- **Homonyms and Homosyllabic Words:** The `$知` operator returns all words sharing the same initial and final as 知 (`zi`) regardless of tone. The `$$` operator finds words where every syllable sounds identical, like 爸爸 or 姐姐.

---

## Semantic Search & Meaning Filters

Finding a word that fits the melody is only half the battle; it also needs to make sense. Built on the *words.hk* relationship graph, you can filter results by their actual meaning while strictly maintaining your melodic constraints.

- **Synonyms and Antonyms:** Typing `~開心` retrieves semantically related words expressing happiness, while `!大` finds words meaning the exact opposite of large.
- **Compound Relationships:** The `~~` operator finds 2-character words built from two synonymous characters (like 朋友), while `!!` finds words built from two opposing characters (like 生死).
- **Paired Filters:** Using `~~~` or `!!!` filters the entire dictionary to display only words that have a mapped synonym or antonym, speeding up your brainstorming process.

---

## Character & Structure Search

- **Anchored Literals (`@`):** The `@香?港` query keeps "香" and "港" as fixed Chinese characters while the `?` wildcard roams, intentionally bypassing phonetic matching entirely.
- **Polyphones (`@@`):** Identify words with more than one valid pronunciation (多音字). Typing `33@@` filters results specifically to polyphones whose default reading fits the mid-flat contour.
- **Anagrams and Reversible Words:** `%香港` finds dictionary words using the exact same characters in any order (e.g., 港香). The `%%` operator identifies words that remain valid when read backwards (迴文).

---

## Solfa & ABC Musical Notation (Experimental)

If you are a composer wanting to write Cantopop melodies without learning the numerical tone system, you can search using western musical notation directly. The engine automatically maps relative pitch intervals onto your active Cantonese tone mode.

Simply type `doremi` for relative solfa notation, or `abc` for ABC notation. You can use a comma (`,`) to drop an octave, and an apostrophe (`'`) to raise one. Wildcards (`?`) work perfectly inside musical phrases too (e.g., `so,?do`), allowing Western producers to write Cantonese lyrics seamlessly. *(Note: This feature is experimental and relative interval mappings may provide approximate results).*

---

## Under the Hood & Legacy Migration

- **Legacy Parser Compatibility:** If you are migrating your workflow from older, web-based Cantonese tone dictionaries, you will feel right at home. The legacy `=` prefix for alliteration and postfix for rhyming are fully supported. For example, `=h` operates exactly like `香港`.
- **System Architecture:** canTone is built on the **Tauri** framework, combining a featherweight web frontend with a high-performance **Rust** backend for maximum efficiency.
- **Local Database:** The app relies on an embedded **SQLite** database, heavily optimized for sub-millisecond Full-Text Search across hundreds of thousands of English, Jyutping, and Traditional Chinese entries.