Created
August 6, 2023 16:23
-
-
Save rtrppl/54ecdb41fb8a47175c2b6bfe1ff4d2ed to your computer and use it in GitHub Desktop.
gpt-dictionary-sentence
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun lt/gpt-dictionary-sentence () | |
"Provide a separate translation and dictionary look-up for all Chinese words in the current sentence, including pinyin." | |
(interactive) | |
(set-mark (point)) | |
(forward-sentence) | |
(unless (region-active-p) | |
(user-error "No region active")) | |
(let ((buffer (get-buffer-create "*ChatGPT Chinese Dictionary*")) | |
(prompt "You emulate a traditional dictionary. Provide a separate translation for all (!) words in the Chinese sentence that follows the final colon. The format of the translation should be: Chinese characters   (pinyin) - English. Add a line break after each translation. Add a translation of the whole sentence at the end, but don't start this translation with Translation: : ") | |
(buffer-text (buffer-substring-no-properties (region-beginning) (region-end)))) | |
(with-current-buffer buffer | |
(erase-buffer) | |
(insert (chatgpt-shell-post-prompt (concat prompt buffer-text))) | |
(display-buffer buffer t)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment