Skip to content

Latest commit

 

History

History
257 lines (216 loc) · 13 KB

README.org

File metadata and controls

257 lines (216 loc) · 13 KB

paw (point-and-write)

images/logo.jpg

Study for a life in Emacs.

paw.el was created in 2021 as an annotation tool, but I was not used it a lot at that time. Recently I picked it up and dramatically changed its usage. Now it is a complete solution of making annotations and language learning tools, right inside Emacs.

paw relies on sqlite. All annotations are saved inside a database, which means it can be easily backup and you can read and make annotation right inside Emacs (PC/mobile) using same database.

paw is not a just a dictionary tool. paw was created with in mind that:

  1. Query word as easy as possible, even no need to click.
  2. Save and trace all known/unknown words and wordlist support, online or offline.
  3. Integrate with other great open source tools, libraries, and dictionaries.
  4. Integrate with external dictionary tools.
  5. Support many languages.
  6. Multi-Platform Support, including Mobile/e-link devices.
  7. Use AI as assistant.

The standout feature of Paw is the ability to scan an entire buffer, tokenize all words, batch-query them, and filter them out according to user-provided tags, ultimately applying overlays alongside meanings to all discovered words. In essence, Paw proactively queries the dictionary on your behalf, making the highlighted word’s meaning immediately available.

  • This means that you can simply hover your mouse over a word to view its definition, without having to click on it.

This package is mainly used along with:

  1. nov-mode
  2. org-mode
  3. eaf-mode
  4. eww-mode
  5. pdf-view-mode

But it is able to work with all modes (defined in paw-annotation-mode-supported-modes) in Emacs.

I’ll update the doc in the future, there are too much to cover. But I’ll show you the most useful cases first:

Reading and annotation

  1. Open an epub file using nov.el or open an org file or browse web with eww
  2. Enable paw-annotation-mode (buffer will be turned into read-only if paw-annotation-read-only-enable is t to avoid accidental alternation)
  3. Use paw add word/highlight/bookmark/todo/, for example, paw-add-word, paw-add-highlight… Please check M-x paw-add-* related commands for all type of supported annotations.
  4. Annotations will be highlighted via overlay. Under the annotation, you can do various of operations. For example, to edit the annotation, under the annotation, press i, paw-find-note. It will create an temporary org file dedicated for this annotation, put your content under Saved Meanings or Notes (Don’t remove other things!), then save by C-c C-c, changes under Saved Meanings and Notes will be saved in the database respectively.
  5. Call paw, paw-list-all-annotations or paw-list-all-links to manage or jump to annotation location (One useful case is that make highlight or create bookmark on eww, and jump back to the exact same annotation location simply pressing Enter)
  6. Under the annotation, M-x paw-view-notes, all notes under the same path will be shown, giving you an overview on all notes you’ve made for the same file.
  7. paw-add-bookmark works great on eww-mode/eaf-mode (browser or pdf-viewer)

Language Learning

  1. Copy a text you want to learn to an org file or browse a page with eww.
  2. Enable paw-annotation-mode
  3. Click/Select word/sentence with paw-view-note, it will show you an informative buffer of the word/sentence. It has dictionary, translation, notes and also able to search by external browser.
  4. Use paw-add-offline-word or paw-add-online-word to add a new word. For online word, currently only support Eudic, apply Authorization key on https://my.eudic.net/OpenAPI/Authorization, and fill it into paw-authorization-keys before adding online words. All offline/online words appeared on any buffers that were enabled paw-annoation-mode will be highlighted, useful for language learners using the important method: Repetition.
  5. For offline words, please setup paw-offline-studylist before using it. By default we have two offline studylists: English Studylist and Japanese Studylist.
  6. You can also use paw-add-word. Unlike offline/online word, the word added by paw-add-word is linked with an unique id, it is only highlighted at the location where we added it.
  7. Under any annotation, click or press v to invoke paw-view-note, a buffer with saved meanings, dictionary, translation, notes is shown.
  8. Under any annotation, click or press c to invoke paw-change-word-learning-level, select from level 1~5. 1~4 are controlled by paw-level-1-word-face to paw-level-4-word-face for online words, paw-level-1-offline-word-face to paw-level-4-offline-word-face for offline words, while 5 is considered as Known word, skipping adding overlay face (just hiding). You can change the word to level 5 while keep it hiding, but if you don’t need it anymore, simply run paw-delete-word to delete it.
  9. Click/Select word/sentence with paw-view-note-current-thing, paw-view-note-next-thing, paw-view-note-prev-thing, it will do segmentation using kagome (Japanese), and ECDICT (English).
  10. Check https://www.lingq.com/en/, you know more ideas how to learn a foreign language with paw.el.
  11. Run paw-export-notes-to-csv, check the csv file under paw-csv-file, import it to Anki for further studying.
  12. Both paw-add-word and paw-add-online-word will capture the context sentence and save it into Notes field.

Tip: Find some interesting contents on LingQ, and browse using eww, enable paw-annotation-mode, enjoy language studying!

Search a word/sentence

  1. Select/Under a word/sentence
  2. Run paw-view-note (no segmentation, good for word) or paw-view-note-current-thing (segmentation, good for sentence)
  3. Optimized for eaf-mode, nov-mode, eww-mode, focus-mode

Installation

Please install sdcv, kagome (For Japanese segmentation), ecdict(for English learning), focus, edge-tts (pronunciation), gptel, go-translate, goldendict, If you want to make use all power of it.

You may also need to install shrface, wallabag, eaf, popweb, pdf-tools, and more (Please check the source code what are missing, I’ll organize them better in the future.)

Install paw

(package! paw :recipe (:host github :repo "chenyanming/paw" :files ("*")))

Language Detection

Set paw-detect-language-p to t, and run pip install gcld3, paw will use gcld3 (may use others tools in the future, check paw-detect-language-program) to detect the language for more accurate tts pronunciation and translation.

If you don’t want to use language detection program, paw use simple ascii rate: paw-ascii-rate to detect the language, if the rate is greater than paw-ascii-rate, then it is considered as English, otherwise use paw-detect-language-program to detect the language of the TEXT, if paw-detect-language-p is t, or return as paw-non-ascii-language if paw-detect-language-p is nil.

Setup paw-python-program if necessary, if the pip module is installed with different python version

Supported edge-tts voice:

  • paw-tts-english-voice
  • paw-tts-zh-cn-voice
  • paw-tts-zh-tw-voice
  • paw-tts-japanese-voice
  • paw-tts-korean-voice
  • Other languages: paw-tts-multilingual-voice

Welcome PRs to add more languages :)

My Setup

(use-package paw
  :init
  (setq paw-db-file (expand-file-name "paw.sqlite" org-directory))
  ;; ecdict dictionary
  (setq paw-ecdict-db (expand-file-name "stardict.db" org-directory))
  ;; setup ECDICT before using it, and create the files manually if not exist
  (setq paw-ecdict-known-words-files `(,(expand-file-name "eudic.csv" org-directory)
                                       ,(expand-file-name "english.txt" org-directory)))
  ;; setup ECDICT before using it, and create the file manually if not exists
  (setq paw-ecdict-default-known-words-file (expand-file-name "english.txt" org-directory))

  ;; jlpt dictionary
  (setq paw-jlpt-db (expand-file-name "japanese.db" org-directory))
  ;; setup jlpt before using it, and create the files manually if not exist
  (setq paw-jlpt-known-words-files `(,(expand-file-name "japanese.txt" org-directory)))
  ;; setup jlpt before using it, and create the file manually if not exists
  (setq paw-jlpt-default-known-words-file (expand-file-name "japanese.txt" org-directory))
  :custom
  ;; (paw-svg-enable t)
  (paw-pbm-enable t)
  (paw-detect-language-p t)
  (paw-python-program (if (string-equal system-type "android") "python3.10" "python3"))
  (paw-detect-language-program 'gcld3) ;; android can only install cld3
  (paw-click-overlay-enable t)
  (paw-annotation-read-only-enable t)
  (paw-annotation-show-unknown-words-p t) ;; setup ECDICT before using it
  (paw-ecdict-frq 3000) ;; setup ECDICT before using it
  (paw-ecdict-bnc 3000) ;; setup ECDICT before using it
  (paw-ecdict-tags "cet6 ielts toefl gre") ;; setup ECDICT before using it
  (paw-ecdict-oxford 0) ;; setup ECDICT before using it
  (paw-ecdict-collins-max-level 4) ;; to setup ECDICT before using it
  ;; (paw-posframe-p (if (string-equal system-type "android") t))
  ;; For online words, you have to apply api on
  ;; https://my.eudic.net/OpenAPI/Authorization
  (paw-authorization-keys (auth-source-pick-first-password :host "eudic-api-key"))
  ;; limit the other languages web buttons number
  (paw-english-web-button-number (if (eq system-type 'android) 4 4))
  ;; limit the japanese web buttons number
  (paw-japanese-web-button-number (if (eq system-type 'android) 3 4))
  ;; limit the general web buttons number
  (paw-general-web-button-number (if (eq system-type 'android) 2 3))
  ;; (paw-default-say-word-function (if (eq system-type 'android) 'paw-android-say-word 'paw-say-word))
  (paw-tts-zh-cn-voice "zh-CN-YunjianNeural") ; zh-CN-XiaoxiaoNeural, zh-CN-YunyangNeural
  ;; (paw-sdcv-dictionary-list '("简明英汉字典增强版"))
  ;; add online word by default for add button
  (paw-add-button-online-p t)
  ;; show the note both in minibuffer or/and *paw-view-note*
  ;; To use this, you need to setup ECDICT (English) or JLPT (Japanese) before
  ;; use this, otherwise, use the 'buffer instead
  (paw-view-note-show-type (if (eq system-type 'android) 'minibuffer 'all))
  :config
  (setq paw-note-dir (expand-file-name "Dict_Notes" org-directory))
  ;; if the file was moved to other places after adding annotations, we can add
  ;; the parent path of the file for paw to search. This is necessary for
  ;; multiple clients (PC/Mobile/Pad) to use the same database but file location
  ;; is different.
  (setq paw-annotation-search-paths '("~/Data/Books/"
                                       "/storage/emulated/0/Books/"
                                       "/storage/emulated/0/Download/"
                                       "/storage/emulated/0/Download/Telegram/"
                                       "/storage/emulated/0/org/web/"
                                       "~/org/web/"
                                       "~/org/web/"
                                       ))

  ;; show image annotation in *paw-view-note*
  (add-hook 'paw-view-note-after-render-hook #'org-display-inline-images)
  (add-hook 'context-menu-functions #'paw-annotation-context-menu)

  (unless (string-equal system-type "android")
      (setq paw-dictionary-browse-function 'popweb-url-input)
      (setq paw-mdict-dictionary-function 'popweb-url-input))

  )

Demos

https://emacs-china.org/uploads/default/original/3X/2/b/2bc2d9fd996827097b13f751c327ad7141376f88.gif

https://emacs-china.org/uploads/default/original/3X/3/5/3544a2bf376d1f3b8f1fc86063af2975e4da42b4.gif

https://emacs-china.org/uploads/default/optimized/3X/b/8/b8d7ae2d68baae4fe7dcb6477998cb761e28165f_2_1234x1000.png

https://emacs-china.org/uploads/default/optimized/3X/b/b/bb28af2a398f8d33861002facc62a6f7782be3b7_2_1232x1000.png

https://emacs-china.org/uploads/default/original/3X/5/5/55c6991c0521c6a70dbbce844ce1fb650119dc1e.png

https://emacs-china.org/uploads/default/original/3X/9/7/971b92c62a837e0a2e053e0e01f02916b8ae465d.png

User Discussions

https://emacs-china.org/t/paw-el-emacs-lingq/27331

https://t.me/emacs_paw

Thanks the following great tools

  1. LingQ: Learning a language by reading
  2. Kindle Vocabulary Builder
  3. org noter
  4. Chatgpt
  5. SDCV
  6. go-translate
  7. Eudic
  8. 蒙哥阅读器