Created
December 22, 2023 18:48
-
-
Save rtrppl/c6b478f476c46da2f941bb0e456a0d5e to your computer and use it in GitHub Desktop.
using fastgpt as a dictionary
This file contains hidden or 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 fastgpt-dictionary-sentence () | |
"Provide a separate translation and dictionary look-up for all Chinese words in the next 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. First repeat the Chinese sentence, then provide a separate translation for all words in the Chinese sentence that follows. The format of the translation should be: X (Y) - Z, whereby X stands for the Chinese characters, Y stands for pinyin with markers for tones and Z stands for English. Add a line break after each translation. Add a translation of the whole sentence at the end. Also, do not translate the interpunction and do not provide additional links. ") | |
(buffer-text (buffer-substring-no-properties (region-beginning) (region-end)))) | |
(with-current-buffer buffer | |
(erase-buffer) | |
(insert (kagi--process-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