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/上找到许可证的副本