paloma blog

NWエンジニアやってます。主に自宅環境のお遊びを書きます。Pythonもちょっと。タイトルは好きなカクテルから。

python製英英辞書"pyvoc"がいい感じ

我々エンジニアは英語のマニュアルを読む場面が多々ありますが、私なんか翻訳ツールに頼ってしまいます。
とは言っても全く読めないわけではなく、わからない単語が数個出てきたのでついでに文ごと翻訳かけるって言うやり方です。

そんな折、ostechnixでpyvocなるツールを見つけました。
いわゆる英英辞典です。

www.ostechnix.com

helpを調べる"pydoc"じゃないですよ、"pyvoc"です。
cli辞書&ボキャブラリビルドツールとありますね。

非ネイティブ英語スピーカーの学習に使えるようなツールのようです。

オックスフォードの辞書APIを使用しているようです。

インストール

年末に買った持ち運びに便利なノートPC(Windows10 Pro)にインストールしてみます。
このPCにはWSLもインストール済みですが、気軽に使えるようwindows側にインストールします。

pythonは3.7.2をインストール済み。
powershellから実行します。

PS C:\Users\masashi> python --version
Python 3.7.2

インストールはpipで一発。
windowsだとpipモジュールを呼び出して実行します。

PS C:\Users\masashi> python -m pip install pyvoc
Collecting pyvoc
  Downloading https://files.pythonhosted.org/packages/7c/34/15b2e3bce4d04d8e41dffe563f441330bff9bb526e25e45e337482826639/pyvoc-1.1.0-py3-none-any.whl

()

Successfully installed colorama-0.4.1 pyvoc-1.1.0 termcolor-1.1.0

OK。

さっそく"python"でも引いてみます。
初回はAPI Keyのセッティングが走ります。

PS C:\Users\masashi> pyvoc python
 -Creating necessary config files
 -getting api keys. please handle with care!
 \

python
Noun:            large heavy-bodied non-venomous snake occurring throughout Old World tropics
example:         None

品詞と例を表示してくれるのがいいですね。
Nounは名詞です。
"python"だと例はないようです。

"古くから熱帯地方に生息する非毒性の大型の蛇"とでも訳せますかね…?
違ってたら恥ずかしいです。

プログラミング言語としての役は入って無い様ですね。

意味も英語で表示されるので、調べていくうちに言い回しの勉強も出来そうです。
再帰的に調べていったら収集つかなくなりそうですね。

いくつか単語を調べましょう。
好きなバイク関係でも。

PS C:\Users\masashi> pyvoc motircycle
 \
No definition found. Please check the spelling!!
PS C:\Users\masashi> pyvoc motorcycle
 |

motorcycle
Noun:            two-wheeled vehicle that is powered by motor and has no pedals
example:         None

PS C:\Users\masashi> pyvoc vehicle
 \

vehicle
Noun:            thing used for transporting people or goods
example:         the vehicle was sent skidding across the road

PS C:\Users\masashi>
PS C:\Users\masashi> pyvoc bike
 |

bike
Noun:            bicycle or motorcycle
example:         I'm going by bike

Verb:            ride bicycle or motorcycle
example:         Danny bikes to the park and back every day

いいですね。しかもコマンドなんで早いし、サクッと調べられます。
"Verb”は動詞です。

ボキャブラリーグループ

どういう括りかわかりませんが、ボキャブラリーグループというのがあって単語をグルーピングしてあるみたいです。

-aオプションで自分でも辞書を追加できるみたいですが、このグループの内容がよくわかっていません。

ホームディレクトリにはデフォルトでそれっぽいファイルが作成されています。

PS C:\Users\masashi> ls C:\Users\masashi\.pyvoc\


    ディレクトリ: C:\Users\masashi\.pyvoc


Mode                LastWriteTime         Length Name
----                -------------         ------ ----
-a----       2019/01/22     23:23              2 all_words.json
-a----       2019/01/22     23:23              9 defaultgroups.json
-a----       2019/01/22     23:23          68023 group101.json
-a----       2019/01/22     23:23          66113 group102.json
-a----       2019/01/22     23:23          60768 group103.json
-a----       2019/01/22     23:23              2 group51.json
-a----       2019/01/22     23:23          47059 options.json
-a----       2019/01/22     23:23             72 pyvoc.config
-a----       2019/01/22     23:23              2 usergroups.json

改定

グループを指定して-rオプションで内容を改定?できるんですかね。
この辺はいじってませんがEnterを押すと単語がどんどん出てきます

PS C:\Users\masashi> pyvoc 101 -r
 |

 Press <enter> for next. q<enter> to exit

balk           a roughly squared timber beam
1. >

connecting     joining or linking things together
2. >

ennui          feeling of listlessness and dissatisfaction arising from lack of occupation or excitement
3. >

avenge         inflict harm in return for
4. >

vex            angry; annoyed
5. >

motivation     a reason or reasons for acting or behaving in a particular way
6. >

クイズ

グループ指定でーqオプションで4択クイズもできます。

途中でやめちゃいましたが、10問クイズが出ます。

PS C:\Users\masashi> pyvoc 101 -q 10
 |
                Starting Quiz

1 point for every correct answer. q<enter> to exit


emend
[1] make corrections and revisions to (a text)
[2] a written character that represents a syllable
[3] a person who is proficient
[4] joint in legs of animals, equivalent to knee in humans
1.>
enter a valid integer[1, 2, 3, 4]. q<enter> to exit
1.> 1
correct answer

forlorn
[1] pitifully sad and abandoned or lonely
[2] recurring every seven years.
[3] archaic variant of wizened
[4] (of a person or action) showing dedication and diligence
2.> 2
wrong answer

impudent
[1] the action of suppressing something such as an activity or publication
[2] give or make a long, high-pitched complaining cry or sound
[3] not showing due respect for another person; impertinent
[4] archaic variant of wizened
3.>

早くて楽しいツールです

コマンドでサクサク検索できるので、ストレスもなく楽しいツールです。
これを使って英語勉強ライフを進めていきたいと思います。

pyvocは初期開発らしくてこれからの機能追加が楽しみですね。

ちなみにオックスフォード辞書APIのサイトを見たら、フリーアカウントだと月3000リクエストの制約があるようですが、このツール経由だとどうなるんですかね。

developer.oxforddictionaries.com

使っていけばわかるか。