6
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

emacsでLatexの英文法チェック

Last updated at Posted at 2016-11-22

以下の英文法チェッカをemacsから使えるように設定する

  • textlint
  • redpen
  • langtool
  • textgears
  • AfterTheDeadline
  • link-grammar

#textlint

textlintと英文法チェックルールをインストール

textlint-install.sh
# npm update -g npm
# npm install -g textlint
# npm install -g textlint-rule-unexpanded-acronym textlint-rule-rousseau  textlint-rule-alex textlint-rule-common-misspellings textlint-rule-ginger textlint-rule-spellchecker textlint-rule-write-good textlint-rule-en-max-word-count

textlintでmarkdownのチェックができるようにする(textlintはLatexに対応していない)

textlint-conf.el
(require 'flycheck)

(flycheck-define-checker textlint
  "A linter for prose."
  :command ("textlint" "--format" "unix" "--rule" "unexpanded-acronym" "--rule" "rousseau" "--rule" "alex" "--rule" "common-misspellings" "--rule" "ginger"  "--rule"  "spellchecker" "--rule" "write-good" source-inplace)
 :error-patterns
  ((warning line-start (file-name) ":" line ":" column ": "
            (id (one-or-more (not (any " "))))
            (message (one-or-more not-newline)
                     (zero-or-more "\n" (any " ") (one-or-more not-newline)))
            line-end))
  :modes (text-mode markdown-mode))

(add-to-list 'flycheck-checkers 'textlint)
(add-hook 'markdown-mode-hook 'flycheck-mode)

redpen & langtool

redpenとlangtoolを以下のように設定する

redpenをインストールしてemacsをここに書いた設定をする

app-text/languagetoolをインストールして以下のemacs設定

langtool-conf.el
(require 'langtool)
(setq langtool-language-tool-jar "/usr/share/languagetool/lib/languagetool-commandline.jar")
(setq langtool-default-language "en-US")
;;(setq langtool-mother-tongue "en")
(defun langtool-autoshow-detail-popup (overlays)
  (when (require 'popup nil t)
    ;; Do not interrupt current popup
    (unless (or popup-instances
                ;; suppress popup after type `C-g' .
                (memq last-command '(keyboard-quit)))
      (let ((msg (langtool-details-error-message overlays)))
        (popup-tip msg)))))

(setq langtool-autoshow-message-function
      'langtool-autoshow-detail-popup)

edit-indirect-region-latex

Latex内の領域選択した部分だけを文法チェッカーが誤認識しない形式に変換してから英文法チェックできるように
edit-indirect-region-latex のスクリプトを

M-x package-install edit-indirect-region-latex

してから

(require 'edit-indirect-region-latex)
(setq edit-indirect-region-latex-after-creation-functions
(list
(lambda ( ) (write-file "/tmp/indirect.md" nil) )
;; #'langtool-check-buffer ;;gentooのlangtoolが動かなくなったので念のため除外
#'redpen-paragraph
) )

を .emacs.el に加える

textgears & AfterTheDeadLine & link-grammar

さらにtextlintと同じように

install-engchecker2flycheck.sh
# pip install engchecker2flycheck

でコマンドラインから英文チェッカーを使えるようになるので,これをflycheckから使う設定をする.

use-engchecker2flycheck.el
(require 'flycheck)

(setq textgears-key "your textgeras key")

(flycheck-define-checker textgears
    "textgears check"
    :command  ("textgearschkfile"  source  (eval textgears-key )   )
  :error-patterns
  ((warning line-start (file-name) ":" line ":" column ": " (message) line-end))
  :modes (text-mode markdown-mode))

(add-to-list 'flycheck-checkers 'textgears)

(flycheck-define-checker link-grammar
  "link-grammar check"
  :command ("linkgrammarengchkfile" source)
  :error-patterns
  ((warning line-start (file-name) ":" line ":" column ": " (message) line-end))
  :modes (text-mode markdown-mode))

(add-to-list 'flycheck-checkers 'link-grammar)


(flycheck-define-checker afterthedeadline
  "afterthedeadline check"
  :command ("afterthedeadlinechkfile" source)
  :error-patterns
  ((warning line-start (file-name) ":" line ":" column ": " (message) line-end))
  :modes (text-mode markdown-mode))

(add-to-list 'flycheck-checkers 'afterthedeadline)


(add-hook 'markdown-mode-hook 'flycheck-mode)

textgearsは
(setq textgears-key "your textgeras key")
しないと使えない.
AfterTheDeadLineはサーバーをローカルで動かさないと使えないので注意.

組合せ方

C-c ! s チェックツール名
で英文チェッカーツールを切り替えできる

  • 間違い検出能力が一番高いのはlink-grammar.ただし修正候補は示さない
  • textgearsは修正も示すが有料.しかもオンライン.
  • afterthedeadlineは無料で修正も示すが見逃しが多い
  • textlintのgengerはtextgearsには劣る
  • redpenは誤検出が沢山出る

なので無料で修正候補も示してくれる
afterthedeadline,textlint,redpen,langtool
を最初にかけて
次に
link-grammar
でエラーがないかチェックして,
最後にエラーがなくなってからtextgearsをかける
のが理想的な順番ではないかと思う

6
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?