手動增加本地詞典

來源:互聯網
上載者:User

手動增加本地詞典 01#!/bin/sh02  03 # spelldict.sh -- 使用'aspell'特性以及一些過濾以便04 # 允許命令列拼字檢查給定的輸入檔案05  06 # 不可避免的,你會發現,有些詞彙是錯誤的,但你認為07 # 它們是正確的。簡單的將它們儲存在一個檔案中,一次08 # 一行,並且確定變數'okaywords'指向這個檔案。09  10 okaywords="$HOME/okaywords"11 tempout="/tmp/spell.tmp.$$"12 spell="aspell"    # 根據需要修改13  14 trap "/bin/rm -f $tempout" EXIT15  16 if [ -z "$1" ]; then17     echo "Usage: spell file | URL" >&218     exit 119 elif [ ! -f $okaywords ]; then20     echo "No personal dictionary found. Create one and return this command." >&221     echo "Your dictionary file: $okaywords" >&222     exit 123 fi24  25 for filename26 do27     $spell -a < $filename | \28     grep -v '@(#)' | sed "s/\'//g" | \29         awk '{if(length($0) > 15 && length($2) > 2) print $2}' | \30     grep -vif $okaywords | \31     grep '[[:lower:]]' | grep -v '[[:digit:]]' | sort -u | \32     sed 's/^/ /' > $tempout33  34     if [ -s $tempout ]; then35         sed 's/^/${filename}: /' $tempout36     fi37 done38  39 exit 0運行指令碼:這個指令碼需要在命令列上提供一個或多個檔案名稱 運行結果: 01首先,一個空的個人字典,txt內容摘錄自愛麗絲漫遊記:02$ spelldict ragged.txt03ragged.txt:    herrself04ragged.txt:    teacups05ragged.txt:    Gryphon06ragged.txt:    clamour07 08有兩個詞拼錯了,所以準備用echo命令把它們加到okaywords檔案中:09 10$ echo "Gryphon" >> ~/.okaywords11$ echo "teacups" >> ~/.okaywords12 13擴充了詞典檔案後的檢查結果如下:14 15$ spelldict ragged.txt16ragged.txt:    herrself17ragged.txt:    clamour 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.