在一个文档语料库下,建立基于真实感的词网络的模块。
wordnet的Python项目详细描述
#wordnet
[![构建状态](https://travis-ci.org/anuragkumarak95/wordnet.svg?branch=master)(https://travis ci.org/anuragkumarak95/wordnet)
[![codecov](https://codecov.io/gh/anuragkumarak95/wordnet/branch/master/graph/badge.svg)(https://codecov.io/gh/anuragkumarak95/wordnet)
[![需求状态](https://requires.io/github/anuragkumarak95/wordnet/requirements.svg?branch=master)(https://requires.io/github/anuragkumarak95/wordnet/requirements/?branch=master)
[用python-3.5制作](http://forthebadge.com/images/badges/made with python.svg)
ORD_net.py使用拖缆功能
1。`克隆此repo并在bash`$pip install-r requirements.txt`@根目录下运行,您就可以开始了..
1。转到根目录(~),创建一个config.py文件,其中包含下面提到的详细信息:
`` python
access_token_secret="xxxxx"
consumer_key="xxxxxx"
consumer_secret="xxxxxxx"
````
1。运行'streamer',使用一组要获取tweets的筛选词。例如,`$python twitter_streaming.py hello hi hallo namaste>;data_file.txt`这将保存根据"data_file.txt"中用作参数的单词筛选的tweets中的逐行单词。
`克隆此repo并使用此脚本安装wordnet模块,
$python setup.py install
1。要为每个文档创建一个"tf-idf"结构文件,请使用:
``python
from wordnet import find_tf_idf
df,tf_idf=find_tfu idf(
file_names=['file/path1','file/path2',…],要处理的文件路径。(使用twitter_streamer.py创建)
prev_file_u path='prev/tf/idf/file/path.tfidfpkl',prev tf_u idf要修改的文件,格式标准为.tfidfpkl。默认值=无
转储路径='path/to/dump/file.tfidfpkl'\dump路径如果需要转储tf idf,格式标准为.tfidfpkl。默认值=无
)
'
'
如果没有提供prev_file_path参数,将生成新的tf-idf文件,否则
tf-idf值将与前一个文件合并,并转储到dump_path如果提到,
else将只返回dictio的新tf idf列表naries和df字典。若要使用此模块的"nn"字基因,只需使用wordnet。find"knn:
`` python
从wordnet import find"knn
words=find"knn"(
tf idf=tf idf,",此tf"idf"由上面的find"tf"idf()返回。
input"word="german","一个最接近neig的单词。需要h小时。
k=10,k=需要的邻居数,默认值=10
rand_on=true rand_on=随机跳过几个单词或显示初始k个单词默认值=trueted提供的输入字是指提供给它的tf idf var。使用find_tf_idf()来收集此变量,或者使用pickle.load()在choosen目录中转储同一函数转储的
文件。该文件包含2个格式为
(idf,tf-idf)的列表。
'
````
1。要创建单词"network",请使用:
``python
from word net import generate_net
df=df,此df由上面的find_tf_idf()返回。
tf idf=tf_idf,此tf_idf由上面的find_u tf_idf()返回。
dump_path=/path/to/dump.wrnt'dump_path=path转储生成的文件,格式标准为.wrnt。默认值=none
)
'
'
此函数返回单词实体的dict,其中word是键。
'
```
>1。要检索单词"network",请使用:
``python
from word net import retrieve_net
'path/to/network.wrnt'path to network file,format standard is.wrnt.
)
'
以单词为键的实体。
'
```
>1。要从网络中的根单词中检索深度一定的单词列表,请使用:
``python
from word net import return戋net
words=return戋net(
word,在此过程中为根单词。
word戋net,由generate戋n生成的word networket()
depth=1希望此字收集器遍历的深度。
)
'
'
此函数返回从
提供的网络中的根字到指定深度的单词列表。
'
'
````
我测试,只要运行这个脚本。` python test.py`,如果一切按预期工作,则此模块将返回**0**。
test.py使用[此处]提供的示例数据(https://github.com/anuragkumarak95/wordnet/tree/master/test),并在"find戋tf戋idf()`,`find戋knn()`&;`generate戋net()`.
>;`streamer`f在本规范的发布下,将不提供功能性。这只是一个独立于模块的脚本。
[用爱建造](http://forthebadge.com/images/badges/build with love.svg)
[![构建状态](https://travis-ci.org/anuragkumarak95/wordnet.svg?branch=master)(https://travis ci.org/anuragkumarak95/wordnet)
[![codecov](https://codecov.io/gh/anuragkumarak95/wordnet/branch/master/graph/badge.svg)(https://codecov.io/gh/anuragkumarak95/wordnet)
[![需求状态](https://requires.io/github/anuragkumarak95/wordnet/requirements.svg?branch=master)(https://requires.io/github/anuragkumarak95/wordnet/requirements/?branch=master)
[用python-3.5制作](http://forthebadge.com/images/badges/made with python.svg)
ORD_net.py使用拖缆功能
1。`克隆此repo并在bash`$pip install-r requirements.txt`@根目录下运行,您就可以开始了..
1。转到根目录(~),创建一个config.py文件,其中包含下面提到的详细信息:
`` python
access_token_secret="xxxxx"
consumer_key="xxxxxx"
consumer_secret="xxxxxxx"
````
1。运行'streamer',使用一组要获取tweets的筛选词。例如,`$python twitter_streaming.py hello hi hallo namaste>;data_file.txt`这将保存根据"data_file.txt"中用作参数的单词筛选的tweets中的逐行单词。
`克隆此repo并使用此脚本安装wordnet模块,
$python setup.py install
1。要为每个文档创建一个"tf-idf"结构文件,请使用:
``python
from wordnet import find_tf_idf
df,tf_idf=find_tfu idf(
file_names=['file/path1','file/path2',…],要处理的文件路径。(使用twitter_streamer.py创建)
prev_file_u path='prev/tf/idf/file/path.tfidfpkl',prev tf_u idf要修改的文件,格式标准为.tfidfpkl。默认值=无
转储路径='path/to/dump/file.tfidfpkl'\dump路径如果需要转储tf idf,格式标准为.tfidfpkl。默认值=无
)
'
'
如果没有提供prev_file_path参数,将生成新的tf-idf文件,否则
tf-idf值将与前一个文件合并,并转储到dump_path如果提到,
else将只返回dictio的新tf idf列表naries和df字典。若要使用此模块的"nn"字基因,只需使用wordnet。find"knn:
`` python
从wordnet import find"knn
words=find"knn"(
tf idf=tf idf,",此tf"idf"由上面的find"tf"idf()返回。
input"word="german","一个最接近neig的单词。需要h小时。
k=10,k=需要的邻居数,默认值=10
rand_on=true rand_on=随机跳过几个单词或显示初始k个单词默认值=trueted提供的输入字是指提供给它的tf idf var。使用find_tf_idf()来收集此变量,或者使用pickle.load()在choosen目录中转储同一函数转储的
文件。该文件包含2个格式为
(idf,tf-idf)的列表。
'
````
1。要创建单词"network",请使用:
``python
from word net import generate_net
tf idf=tf_idf,此tf_idf由上面的find_u tf_idf()返回。
dump_path=/path/to/dump.wrnt'dump_path=path转储生成的文件,格式标准为.wrnt。默认值=none
)
'
'
此函数返回单词实体的dict,其中word是键。
'
```
>1。要检索单词"network",请使用:
``python
from word net import retrieve_net
)
'
以单词为键的实体。
'
```
>1。要从网络中的根单词中检索深度一定的单词列表,请使用:
``python
from word net import return戋net
words=return戋net(
word,在此过程中为根单词。
word戋net,由generate戋n生成的word networket()
depth=1希望此字收集器遍历的深度。
)
'
'
此函数返回从
提供的网络中的根字到指定深度的单词列表。
'
'
````
我测试,只要运行这个脚本。` python test.py`,如果一切按预期工作,则此模块将返回**0**。
test.py使用[此处]提供的示例数据(https://github.com/anuragkumarak95/wordnet/tree/master/test),并在"find戋tf戋idf()`,`find戋knn()`&;`generate戋net()`.
>;`streamer`f在本规范的发布下,将不提供功能性。这只是一个独立于模块的脚本。
[用爱建造](http://forthebadge.com/images/badges/build with love.svg)