python中nlp的词汇管理。

vocab的Python项目详细描述


Documentation Statushttps://travis-ci.org/vzhong/vocab.svg?branch=master

vocab是一个python包,它为自然语言处理提供词汇表对象。

安装

pip install vocab
pip install git+https://github.com/vzhong/vocab.git

用法

>>>fromvocabimportVocab,UnkVocab>>>v=Vocab()>>>v.word2index('hello',train=True)0>>>v.word2index(['hello','world'],train=True)[0,1]>>>v.index2word([1,0])['world','hello']>>>v.index2word(1)'world'>>>small=v.prune_by_count(2)>>>small.to_dict(){'counts':{'hello':2},'index2word':['hello']}>>>u=UnkVocab()>>>u.word2index(['hello','world'],train=True)[1,2]>>>u.word2index('hello friend !'.split())[1,0,0]>>>u.index2word(0)'<unk>'

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
在Grails中集成javaapplet   动态设置片段时发生java错误   JavaSpringVelocity模板电子邮件?   SpringHateOAS中java自定义json输出   java wait()和notify()相关问题   正则表达式中的单词边界是什么?   使用外部库将项目部署到glassfish后发生java NoClassDefFoundError   java为什么在这里初始化ListNode两次?   java libGDX移动三维模型   java使线程等待另一个线程的执行   正则表达式如何在java中使用正则表达式解析给定字符串   java SWT ScrolledComposite在32768像素后切断画布生成的图像