diff --git a/00-Meta/GEMINI.md b/00-Meta/GEMINI.md index b11d92a..d89d17f 100644 --- a/00-Meta/GEMINI.md +++ b/00-Meta/GEMINI.md @@ -99,6 +99,16 @@ Always respond in Markdown. Use headings, lists, and bold text for clarity. 3. **Broken Link Check:** Scan the entire vault for internal links pointing to non-existent notes and report them. 4. **Workflow Integrity Check:** A self-audit to ensure temporary files from other workflows have been properly deleted. +- **[Memory/Workflow Name]:** Chinese Note Completion Workflow +- **Value:** This workflow automatically completes Chinese vocabulary entries in notes by finding and filling in missing Hanzi, Pinyin, or English translations. It uses a dedicated Python script for Pinyin conversion. +- **Example Protocol:** + 1. **Trigger:** Manually run on a specific Chinese note file. + 2. **Action:** The assistant scans the note for incomplete entries (missing Hanzi, Pinyin, or translation). + 3. **Action (Pinyin):** If Pinyin is missing, it executes the `00-Meta/scripts/get_pinyin.py` script with the Hanzi as an argument to get the correct Pinyin. + 4. **Action (Translation):** If the English translation is missing, it uses a web search to find the translation for the Hanzi/Pinyin. + 5. **Action (Hanzi):** If Hanzi is missing, it uses a web search with the Pinyin and/or translation to find the characters. + 6. **Action:** The assistant updates the note file with the completed entries. + - **[Memory/Workflow Name]:** [Brief Description of the Task] - **Value:** [Why this task is useful/complex to record] - **Example Protocol:** [Step-by-step instructions or key constraint used to achieve the desired outcome] diff --git a/00-Meta/scripts/get_pinyin.py b/00-Meta/scripts/get_pinyin.py new file mode 100644 index 0000000..6027c17 --- /dev/null +++ b/00-Meta/scripts/get_pinyin.py @@ -0,0 +1,41 @@ +# -*- coding: utf-8 -*- +""" +This script converts a string of Chinese characters (Hanzi) into Pinyin with tone marks. + +Usage: + python get_pinyin.py "你的汉字" + +Example: + python get_pinyin.py "你好" + Expected output: nǐ hǎo +""" +import sys +from pypinyin import pinyin, Style + +def get_pinyin(text): + """ + Converts a string of Hanzi characters to a Pinyin string with tone marks. + + Args: + text (str): The Hanzi string to convert. + + Returns: + str: The resulting Pinyin string. + """ + # The pinyin() function returns a list of lists, e.g., [['nǐ'], ['hǎo']] + # We use a list comprehension to flatten it and then join the elements with a space. + pinyin_list = pinyin(text, style=Style.TONE) + return " ".join([item[0] for item in pinyin_list]) + +if __name__ == "__main__": + # Check if a command-line argument was provided + if len(sys.argv) > 1: + # The first argument (sys.argv[0]) is the script name, + # so the Hanzi text is the second argument (sys.argv[1]). + hanzi_text = sys.argv[1] + pinyin_output = get_pinyin(hanzi_text) + print(pinyin_output) + else: + # If no argument is provided, print the usage instructions. + print('Usage: python get_pinyin.py "你的汉字"') + print('Example: python get_pinyin.py "你好"')