Hướng dẫn wordnet python install - cài đặt wordnet python

# WordNet

[! : //codecov.io/gh/anuragkumarak95/wordnet/branch/master/graph/badge.svg]] [//codecov.io/gh Yêu cầu.io/github/anuragkumarak95/wordnet/requirements.svg?branch=master]THER[//requires.io/github/anuragkumarak95/wordnet/requirements/?branch=master]
[![codecov][//codecov.io/gh/anuragkumarak95/wordnet/branch/master/graph/badge.svg]][//codecov.io/gh/anuragkumarak95/wordnet]
[![Requirements Status][//requires.io/github/anuragkumarak95/wordnet/requirements.svg?branch=master]][//requires.io/github/anuragkumarak95/wordnet/requirements/?branch=master]

Tạo một mạng ** các từ đơn giản ** liên quan đến nhau bằng cách sử dụng API phát trực tuyến ** twitter **.

! [Được làm bằng Python-3.5] [//forthebadge.com/images/badges/made-with-python.svg]

Các phần chính của dự án này.

* `Streamer`: ~/twitter_streaming.py*` tf-idf` gen: ~/wordnet/tf_idf_generator.py* `nn` words gene: ~/wordnet/nn_words.py .py
* `TF-IDF` Gene : ~/wordnet/tf_idf_generator.py
* `NN` words Gene :~/ wordnet/nn_words.py
* `NETWORK` Gene : ~/wordnet/word_net.py

## Sử dụng chức năng Streamer

1

1. Chuyển đến root-dir [~], tạo tệp config.py với các chi tiết được đề cập bên dưới: `` python # biến có chứa thông tin đăng nhập của người dùng để truy cập API phát trực tuyến Twitter # Liên kết này sẽ giúp bạn [ // SocialMedia -Class.org/twittertutorial.html] access_token = "xxx-xx-xxxx" access_token_secret = "xxxxx" tiêu dùng_key = "xxxxxx" Chạy `streamer` với một mảng các từ lọc mà bạn muốn tìm nạp các tweet trên. ví dụ. `$ python twitter_streaming.py Xin chào HLO HALLO Namaste> data_file.txt` Điều này sẽ lưu một dòng theo dòng từ các tweet được lọc theo các từ được sử dụng như args trong` data_file.txt`.
```python
# Variables that contains the user credentials to access Twitter Streaming API
# this link will help you[//socialmedia-class.org/twittertutorial.html]
access_token = "xxx-xx-xxxx"
access_token_secret = "xxxxx"
consumer_key = "xxxxxx"
consumer_secret = "xxxxxxxx"
```
1. run `Streamer` with an array of filter words that you want to fetch tweets on. eg. `$python twitter_streaming.py hello hi hallo namaste > data_file.txt` this will save a line by line words from tweets filtered according to words used as args in `data_file.txt`.

## Sử dụng mô -đun WordNet

1. `Bản sao repo` và cài đặt mô -đun WordNet bằng tập lệnh này,

$ python setup.py Cài đặt

1. Để tạo tệp cấu trúc `tf-idf` cho mọi tài liệu, hãy sử dụng:

`` `Python từ WordNet Nhập Find_TF_IDF
from wordnet import find_tf_idf

df, tf_idf = find_tf_idf [file_names = ['file/path2', 'file/path2', ..], # đường dẫn của các tệp sẽ được xử lý. /path.tfidfpkl ', # prev tf_idf để sửa đổi, định dạng tiêu chuẩn là. .tfidfpkl. Mặc định = Không]
file_names=['file/path2','file/path2',..], # paths of files to be processed.[create using twitter_streamer.py]
prev_file_path='prev/tf/idf/file/path.tfidfpkl', # prev TF_IDF file to modify over, format standard is .tfidfpkl. default = None
dump_path='path/to/dump/file.tfidfpkl' # dump_path if tf-idf needs to be dumped, format standard is .tfidfpkl. default = None
]

'' 'Nếu không có tệp nào được cung cấp tham số prev_file_path, tệp TF-idf mới sẽ được tạo và các giá trị TF-IDF khác sẽ được kết hợp với tệp trước đó và được bỏ tại Dump_path nếu được đề cập, nếu không sẽ chỉ trả về danh sách TF-IDF mới mới từ điển, và từ điển DF. '' '`` `1. Để sử dụng gen từ `nn` của mô -đun này, chỉ cần sử dụng wordnet.find_knn:
if no file is provided prev_file_path parameter, new TF-IDF file will be generated ,and else
TF-IDF values will be combined with previous file, and dumped at dump_path if mentioned,
else will only return the new tf-idf list of dictionaries, and df dictionary.
'''
```
1. To use `NN` Word Gene of this module, simply use wordnet.find_knn:

`` `Python từ WordNet nhập find_knn
from wordnet import find_knn

Words = find_knn [tf_idf = tf_idf, # tf_idf này được trả về bởi find_tf_idf [] ở trên. 10 rand_on = true # rand_on = hoặc để bỏ qua ngẫu nhiên một vài từ hoặc hiển thị từ k ban đầu mặc định = true]
tf_idf=tf_idf, # this tf_idf is returned by find_tf_idf[] above.
input_word='german', # a word for which k nearest neighbours are required.
k=10, # k = number of neighbours required, default=10
rand_on=True # rand_on = either to randomly skip few words or show initial k words default=True
]

'' 'Hàm này sẽ trả về một danh sách các từ liên quan chặt chẽ với Input_word được cung cấp tham khảo TF_IDF VAR được cung cấp cho nó. Sử dụng find_tf_idf [] để thu thập var hoặc pickle.load [] Một tệp kết xuất được bỏ bởi cùng một hàm tại thư mục bạn chọn. Tệp chứa 2 danh sách ở định dạng [IDF, TF_IDF]. '' '`` `
This function will return a list of words closely related to provided input_word refering to
tf_idf var provided to it. either use find_tf_idf[] to gather this var or pickle.load[] a dump
file dumped by the same function at your choosen directory. the file contains 2 lists in format
[idf, tf_idf].
'''
```

1. Để tạo một từ `mạng`, sử dụng:

`` `Python từ WordNet Nhập Generate_Net
from wordnet import generate_net

Word_Net = Generate_Net [df = df, # df này được trả về bởi find_tf_idf [] ở trên. kết xuất các tệp được tạo, tiêu chuẩn định dạng là .wrnt. default = none]
df=df, # this df is returned by find_tf_idf[] above.
tf_idf=tf_idf, # this tf_idf is returned by find_tf_idf[] above.
dump_path='path/to/dump.wrnt' # dump_path = path to dump the generated files, format standard is .wrnt. default=None
]

'' 'Hàm này trả về một lệnh của các thực thể từ, với từ là khóa. '' '`` `
this function returns a dict of Word entities, with word as key.
'''
```

1. Để truy xuất một từ `mạng`, sử dụng:

ings
from wordnet import retrieve_net

Word_Net = retrieve_Net ['path/to/network.wrnt' # path vào tệp mạng, tiêu chuẩn định dạng là. '' '`` `
'path/to/network.wrnt' # path to network file, format standard is .wrnt.
]
'''
this function returns a dictionary of Word entities, with word as key.
'''
```

1. Để truy xuất danh sách các từ ở độ sâu nào đó tạo thành một từ gốc trong mạng, hãy sử dụng:

`` `Python từ WordNet Nhập trở lại_net
from wordnet import return_net

words = return_net [word, # từ root trong quá trình này. Word_Net, # mạng từ được tạo từ Generate_Net [] độ sâu = 1 # Độ sâu mà bạn muốn trình thu thập từ này đi qua.] '' '"Hàm này trả về danh sách các từ mà đang được cung cấp độ sâu từ từ gốc trong mạng được cung cấp. '' '`` `
word, # root word in this process.
word_net, # word network generated from generate_net[]
depth=1 # depth to which you wish this word collector to traverse.
]
'''
This function returns a list of words that are at provided depth from root word in the
network provided.
'''
```

### Chạy thử nghiệm

Để chạy một bài kiểm tra chính thức, chỉ cần chạy tập lệnh này. `Python test.py`, mô -đun này sẽ trả về ** 0 ** nếu mọi thứ hoạt động như mong đợi.

test.py sử dụng dữ liệu mẫu được cung cấp [tại đây] [//github.com/anuragkumarak95/wordnet/tree/master/test] và thực hiện Unittest trên `find_tf_idf []`, `find_knn [] .

> `Chức năng streamer` sẽ không được cung cấp theo phân phối mã này.Đó chỉ là một kịch bản độc lập với mô -đun.

#### Đóng góp được hoan nghênh ở đây

! [Được xây dựng với tình yêu] [//forthebadge.com/images/badges/built-with-love.svg]

bởi [@anurag] [//github.com/anuragkumarak95]

Bài Viết Liên Quan

Chủ Đề