On 4/29/06, Milan Berta <[EMAIL PROTECTED]> wrote:
Is there any way how to count bad words in a file which is spelled? Or any function which can show an 'error rate' of a file?
The script that does what you want is below, and also attached. Press F5 to activate. This is sample output: Total words: 93 Bad words: 21 Semi-bad words: 0 Bad words ratio: 18.42% Yakov ---------------- countspell.vim ---------------------- " count number of misspelled words, and ratio of bad/good words. map <F5> :call CountMisspell()<cr> func! CountMisspell() let save_cursor = getpos('.') norm gg set spell let total = 0 let bad = 0 let good = 0 let warn = 0 let flags='Wc' while search('\i\+', flags) let flags = 'W' let total += 1 let word = expand('<cword>') let list = spellbadword(word) if list[1] == '' let good += 1 elseif list[1] == 'bad' let bad += 1 else " rare, local, caps let warn += 1 endif endwh echo "Total words: " . good echo "Bad words: " . bad echo "Semi-bad words: " . warn if bad != 0 let ratio = (10000 * bad) / total let ratio = printf("%03d", ratio) let ratio = substitute(ratio, '\d\d$', '.&', '') else let ratio='0.00' endif echo "Bad words ratio: " . ratio . '%' call setpos('.', save_cursor ) endfu -------------------------------------------------------
countspell.vim
Description: Binary data