あとで清書する
動機
Create MLもでたので
機械学習で画像認識するものをつくりたい
→画像集めを簡単にしたい
→ImageNetから画像を取得するスクリプトを書いた
→Wordnet ID(wnid)でしか検索できないので、wnidを単語から入手するのを簡単にしたい
環境
macOS 10.14.1
xcode 10.1
やり方メモ
WordNetからダウンロード
https://wordnet.princeton.edu/download/current-version
初めてなのでフルセット。
データベースのみ差し替えることもできるらしい
XQuartzをいれておく
流れ:解凍->configure->make->sudo make install -> パス通す
$ tar -zxvf (ダウンロードしたファイル)
$ ./configure --with-tcl=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Tcl.framework/ --with-tk=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Tk.framework
$ make CC='gcc -I/opt/X11/include'
$ sudo make install
/usr/local/Word-Net(ほにゃらら)/binにパスを通せと言われるので言う通りにする。
使ってみる
$ wn
usage: wn word [-hgla] [-n#] -searchtype [-searchtype...]
wn [-l]
-h Display help text before search output
-g Display gloss
-l Display license and copyright notice
-a Display lexicographer file information
-o Display synset offset
-s Display sense numbers in synsets
-n# Search only sense number #
searchtype is at least one of the following:
-ants{n|v|a|r} Antonyms
-hype{n|v} Hypernyms
-hypo{n|v}, -tree{n|v} Hyponyms & Hyponym Tree
-entav Verb Entailment
-syns{n|v|a|r} Synonyms (ordered by estimated frequency)
-smemn Member of Holonyms
-ssubn Substance of Holonyms
-sprtn Part of Holonyms
-membn Has Member Meronyms
-subsn Has Substance Meronyms
-partn Has Part Meronyms
-meron All Meronyms
-holon All Holonyms
-causv Cause to
-pert{a|r} Pertainyms
-attr{n|a} Attributes
-deri{n|v} Derived Forms
-domn{n|v|a|r} Domain
-domt{n|v|a|r} Domain Terms
-faml{n|v|a|r} Familiarity & Polysemy Count
-framv Verb Frames
-coor{n|v} Coordinate Terms (sisters)
-simsv Synonyms (grouped by similarity of meaning)
-hmern Hierarchical Meronyms
-hholn Hierarchical Holonyms
-grep{n|v|a|r} List of Compound Words
-over Overview of Senses
犬について調べたい
$ wn dog
Information available for noun dog
-hypen Hypernyms
-hypon, -treen Hyponyms & Hyponym Tree
-synsn Synonyms (ordered by estimated frequency)
-smemn Member of Holonyms
-sprtn Part of Holonyms
-partn Has Part Meronyms
-meron All Meronyms
-holon All Holonyms
-famln Familiarity & Polysemy Count
-coorn Coordinate Terms (sisters)
-hmern Hierarchical Meronyms
-hholn Hierarchical Holonyms
-grepn List of Compound Words
-over Overview of Senses
Information available for verb dog
-hypev Hypernyms
-hypov, -treev Hyponyms & Hyponym Tree
-synsv Synonyms (ordered by estimated frequency)
-famlv Familiarity & Polysemy Count
-framv Verb Frames
-coorv Coordinate Terms (sisters)
-simsv Synonyms (grouped by similarity of meaning)
-grepv List of Compound Words
-over Overview of Senses
No information available for adj dog
No information available for adv dog
dogの同義語を調べる。。。
$ wn dog -synsn
Synonyms/Hypernyms (Ordered by Estimated Frequency) of noun dog
7 senses of dog
Sense 1
dog, domestic dog, Canis familiaris
=> canine, canid
=> domestic animal, domesticated animal
Sense 2
frump, dog
=> unpleasant woman, disagreeable woman
Sense 3
dog
=> chap, fellow, feller, fella, lad, gent, blighter, cuss, bloke
Sense 4
cad, bounder, blackguard, dog, hound, heel
=> villain, scoundrel
Sense 5
frank, frankfurter, hotdog, hot dog, dog, wiener, wienerwurst, weenie
=> sausage
Sense 6
pawl, detent, click, dog
=> catch, stop
Sense 7
andiron, firedog, dog, dog-iron
=> support
wnidの定義を見ると
http://www.image-net.org/download-API
ImageNet is based upon WordNet 3.0. To uniquely identify a synset, we use "WordNet ID" (wnid), which is a concatenation of POS ( i.e. part of speech ) and SYNSET OFFSET of WordNet. For more information, please refer to the WordNet documentation. ImageNet currently only considers nouns, so every wnid starts with "n". For example, the wnid of synset "dog, domestic dog, Canis familiaris" is "n02084071"
- SYNSET OFFSET をIDとしてあつかう
とある。
usage: wn word [-hgla] [-n#] -searchtype [-searchtype...]
wn [-l]
-h Display help text before search output
-g Display gloss
-l Display license and copyright notice
-a Display lexicographer file information
-o Display synset offset
-s Display sense numbers in synsets
-n# Search only sense number #
$ wn dog -o -synsn
Synonyms/Hypernyms (Ordered by Estimated Frequency) of noun dog
7 senses of dog
Sense 1
{02084071} dog, domestic dog, Canis familiaris
=> {02083346} canine, canid
=> {01317541} domestic animal, domesticated animal
Sense 2
{10114209} frump, dog
=> {10739636} unpleasant woman, disagreeable woman
Sense 3
{10023039} dog
=> {09908025} chap, fellow, feller, fella, lad, gent, blighter, cuss, bloke
Sense 4
{09886220} cad, bounder, blackguard, dog, hound, heel
=> {10753546} villain, scoundrel
Sense 5
{07676602} frank, frankfurter, hotdog, hot dog, dog, wiener, wienerwurst, weenie
=> {07675627} sausage
Sense 6
{03901548} pawl, detent, click, dog
=> {02982790} catch, stop
Sense 7
{02710044} andiron, firedog, dog, dog-iron
=> {04359589} support
$ wn dog -synsn -o
Synonyms/Hypernyms (Ordered by Estimated Frequency) of noun dog
7 senses of dog
Sense 1
{02084071} dog, domestic dog, Canis familiaris
=> {02083346} canine, canid
=> {01317541} domestic animal, domesticated animal
Sense 2
{10114209} frump, dog
=> {10739636} unpleasant woman, disagreeable woman
Sense 3
{10023039} dog
=> {09908025} chap, fellow, feller, fella, lad, gent, blighter, cuss, bloke
Sense 4
{09886220} cad, bounder, blackguard, dog, hound, heel
=> {10753546} villain, scoundrel
Sense 5
{07676602} frank, frankfurter, hotdog, hot dog, dog, wiener, wienerwurst, weenie
=> {07675627} sausage
Sense 6
{03901548} pawl, detent, click, dog
=> {02982790} catch, stop
Sense 7
{02710044} andiron, firedog, dog, dog-iron
=> {04359589} support
入手できた。
おしまい