vocabulary
v1.0.4
以模塊形式的字典魔術師!
| 作者: | 塔斯迪克·拉赫曼(Tasdik Rahman) |
|---|
內容
[回到頂部]
對於給定的單詞,使用Vocabulary ,您可以得到它
noun , interjection還是adverb等[回到頂部]
Python寫JSON對象, PYTHON詞典和列表Wordnet (幾乎!)想看嗎?這是一個很小的比較python2.*和python3.*[回到頂部]
Wordnet是一個很好的資源。毫無疑問!那麼,當我們已經有Wordnet的時候,為什麼要使用Vocabulary呢?
[回到頂部]
假設您想找出car一詞的同義詞。
Wordnet > >> from nltk . corpus import wordnet
> >> syns = wordnet . synsets ( 'car' )
> >> syns [ 0 ]. lemmas [ 0 ]. name
'car'
> >> [ s . lemmas [ 0 ]. name for s in syns ]
[ 'car' , 'car' , 'car' , 'car' , 'cable_car' ]
> >> [ l . name for s in syns for l in s . lemmas ]
[ 'car' , 'auto' , 'automobile' , 'machine' , 'motorcar' , 'car' , 'railcar' , 'railway_car' , 'railroad_car' , 'car' , 'gondola' , 'car' , 'elevator_car' , 'cable_car' , 'car' ]Vocabulary做同樣的事情 > >> from vocabulary . vocabulary import Vocabulary as vb
> >> vb . synonym ( "car" )
'[{
"seq" : 0 ,
"text" : "automobile"
}, {
"seq" : 1 ,
"text" : "cart"
}, {
"seq" : 2 ,
"text" : "automotive"
}, {
"seq" : 3 ,
"text" : "wagon"
}, {
"seq" : 4 ,
"text" : "motor"
}]'
>> > ## load the json data
> >> car_synonyms = json . loads ( vb . synonym ( "car" ))
> >> type( car_synonyms )
< class 'list' >
> >>所以你去了。您以簡單的JSON格式獲取數據。
您也可以繼續比較其他方法。
[回到頂部]
PYPI軟件包鏈接
$ pip install vocabulary
如果您在代理後面
$ pip --proxy [username:password@]domain_name:port install vocabulary
注意:如果command not found則$ sudo apt-get install python-pip應該解決
$ git clone https://github.com/tasdikrahman/vocabulary.git
$ cd vocabulary/
$ pip install -r requirements.txt
$ python setup.py install[回到頂部]
[回到頂部]
有關詳細的用法示例,請參考閱讀文檔中的文檔
[回到頂部]
請參考貢獻頁面以獲取詳細信息
[回到頂部]
如果您想聊天,或者您有任何疑問,請加入我們的吉特頻道。
[回到頂部]
[回到頂部]
請參閱ChangElog頁面以獲取詳細信息
[回到頂部]
請在問題跟踪器中報告錯誤
[回到頂部]
其他受詞彙啟發的類似軟件
python的Go lang端口python的Guile Scheme港口[回到頂部]
> >> vb . synonym ( "car" )
[{
"seq" : 0 ,
"text" : "automotive"
}, {
"seq" : 1 ,
"text" : "motor"
}, {
"seq" : 2 ,
"text" : "wagon"
}, {
"seq" : 3 ,
"text" : "cart"
}, {
"seq" : 4 ,
"text" : "automobile"
}]
> >> type( vb . pronunciation ( "hippopotamus" ))
< class 'list' >
> >> json . dumps ( vb . pronunciation ( "hippopotamus" ))
'[{"raw": "(h \ u012dp \ u02cc \ u0259-p \ u014ft \ u02c8 \ u0259-m \ u0259s)", "rawType": "ahd-legacy", "seq": 0}, {"raw": "HH IH2 P AH0 P AA1 T AH0 M AH0 S", "rawType": "arpabet", "seq": 1}]'
>> >您將被返回一個list對象,而不是JSON對象。返回後者時,存在一些unicode問題。解決此問題的修復將很快發布。
我可能會建議使用Python-ftfy,這可以在此問題上為您提供幫助。
[回到頂部]
由Tasdik Rahman由MIT許可©
您可以在http://prodicus.mit-license.org/上找到許可證的副本