スペルチェッカーは、テキストファイルやドキュメントの作成や編集を行う場合に重要なツールです。ほとんどのGUIベースのエディターにはスペルチェック機能が組み込まれていますが、コマンドラインエディターについても同じことは言えません。ただし、スペルチェックに役立つ個別のコマンドラインツールがあります。
ここで、このチュートリアルでは、 aspellと呼ばれるそのようなユーティリティの1つについて説明します。 。ただし、詳しく説明する前に、記事のすべての例がUbuntu18.04LTSマシンでテストされていることを言及する価値があります。
Linuxaspellコマンド
すでに冒頭で述べたように、aspellコマンドを使用すると、テキストファイルのスペルチェックを実行できます。個々の単語をチェックすることもできます。その構文は次のとおりです。
aspell [options] <command>
そして、このツールについてのマニュアルページの内容は次のとおりです。
aspell is a utility program that connects to the Aspell library so that
it can function as an ispell -a replacement, as an independent spell
checker, as a test utility to test out Aspell library features, and as
a utility for managing dictionaries used by the library.
The Aspell library contains an interface allowing other programs direct
access to its functions and therefore reducing the complex task of
spell checking to simple library calls. The default library does not
contain dictionary word lists. To add language dictionaries, please
check your distro first for modified dictionaries, otherwise look here
for base language dictionaries <http://aspell.net>.
以下は、ユーティリティがどのように機能するかについてのより良いアイデアを与えるはずのいくつかのQ&Aスタイルの例です。
Q1。 aspellコマンドの使い方は?
aspellの基本的な使用法は完全に単純ではないため、「usage」コマンドオプションを使用して取得できる使用法の概要を取得することをお勧めします。
aspell usage
そして、これがあなたが出力で得る可能性が高いものです:
Usage: aspell [options] <command>
<command> is one of:
-?|usage display a brief usage message
help display a detailed help message
-c|check <file> to check a file
-a|pipe "ispell -a" compatibility mode
[dump] config dumps the current configuration to stdout
config <key> prints the current value of an option
[dump] dicts | filters | modes
lists available dictionaries / filters / filter modes
[options] is any of the following:
--encoding=<str> encoding to expect data to be in
--mode=<str> filter mode
-l,--lang=<str> language code
-d,--master=<str> base name of the main dictionary to use
--sug-mode=<str> suggestion mode
Q2。 aspellでファイルのスペルミスをチェックする方法は?
これは、-cコマンドラインオプションを使用して実行できます。例:
aspell -c test.txt
上記のコマンドを実行したときにツールが表示した内容は次のとおりです。
そのため、ツールがテキストの最初のスペルミスを強調表示し、ウィンドウの下半分に、代わりに興味があると思われるオプションが表示されていることがわかります。また、よく見ると、現在強調表示されているスペルミスを無視し、現在強調表示されている単語の出現箇所をすべて置き換え、aspellの辞書に追加して、このビューを終了するオプションもあります。
Q3。 aspellを使用して個々の単語をチェックする方法は?
これは、-aコマンドラインオプションを使用して実行できます。
aspell -a
このコマンドを実行するとすぐに、ユーザー入力を待ちます。このモードで単語を入力し、Enterキーを押すと、stdoutでスペルの提案を提供するaspellが表示されます。
次のスクリーンショットは、このコマンドラインオプションの動作を示しています。
Q4。 aspellを使用して単語をまとめてチェックする方法は?
これは、「list」コマンドオプションを使用して実行できます。
aspell list
上記のコマンドを実行すると、ユーザー入力を待ちます。必要な数の単語を追加し、完了したらCtrl+Dを押します。次に、入力した入力の下にaspellのスペルが間違っている単語が表示されることがわかります。
次のスクリーンショットは、このオプションの動作を示しています。
Q5。 aspellで使用される辞書を制御する方法は?
aspellのマニュアルページには、このコマンドで使用される辞書を制御するために使用できるさまざまなオプションが用意されています。重要なもののいくつかを次に示します。
--master=<name>, -d <name>
Base name of the dictionary to use. If this option is specified
then Aspell will either use this dictionary or die.
--dict-dir=<directory>
Location of the main dictionary word list.
--lang=<string>, -l <string>
Language to use. It follows the same format of the LANG envi?
ronmental variable on most systems. It consists of the two let?
ter ISO 639 language code and an optional two letter ISO 3166
country code after a dash or underscore. The default value is
based on the value of the LC_MESSAGES locale.
--size=<string>
The preferred size of the dictionary word list. This consists
of a two char digit code describing the size of the list, with
typical values of: 10=tiny, 20=really small, 30=small, 40=med-
small, 50=med, 60=med-large, 70=large, 80=huge, 90=insane.
aspellは、Linuxコマンドラインユーザーが知っておくべき便利なツールであることに同意するでしょう。ここでは、このツールの基本について説明しました。これらのオプションを練習したら、コマンドのマニュアルページにアクセスして詳細を確認してください。