开发者

Emacs: How to generate a wordlist for a document?

I would like to generate an index for a LaTex document with RefTex, following this advice from the RefTex manual:

"...you might want to start from a word list of the document and remove all words which should not be indexed." (-> collecting phrases for the index phrases file).

Now I ask myself: how do I generate such a word list for my multi-file LaTex Document? I don't find the answer in the Emac开发者_如何学Gos manual or on the web. But Emacs must be able to do that, right?

Thanks for any hints.


a quick way to get started (at the command line, not emacs):

sed 's/ */\n/g' < myDocument.txt | sort -f | uniq > wordListToEdit.txt


I found a solution that is independent from Emacs, but it produces a file with all tokens found in the document(s). I just marked all the .tex files in my LaTeX project in Emacs Dired, and then used

! myshellscript

to run the following script on all of them. You find more Information about nltk and Python here: http://www.nltk.org/

#!/usr/bin/env bash
echo $0
echo $1

python -c "\
from __future__ import division;\
import nltk, re, pprint;\
f = open('$1');\
raw = f.read();\
print nltk.word_tokenize(raw)\
" >> tok 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜