forked from moneyDboat/data_grand
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
moneyDboat
committed
Sep 11, 2018
1 parent
5fc92e2
commit 04775e6
Showing
13 changed files
with
220 additions
and
126 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import word2vec | ||
import fire | ||
|
||
paths = ['raw_word.txt', 'raw_article.txt'] | ||
sizes = [300] | ||
|
||
|
||
def tran(path): | ||
model = word2vec.load(path) | ||
vocab, vectors = model.vocab, model.vectors | ||
print(path) | ||
print('shape of word embeddings : ') | ||
print(vectors.shape) | ||
|
||
new_path = path.split('.')[0] + '_.txt' | ||
print('Transform start....') | ||
f = open(new_path, 'w') | ||
for word, vector in zip(vocab, vectors): | ||
f.write(str(word) + ' ' + ' '.join(map(str, vector)) + '\n') | ||
print('Transform Complete!\n') | ||
|
||
|
||
for path in paths: | ||
for size in sizes: | ||
emb_path = path.split('.')[0].split('_')[1] + '_' + str(size) + '.bin' | ||
word2vec.word2vec(path, emb_path, min_count=5, size=size, verbose=True) | ||
tran(emb_path) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import pandas as pd | ||
import numpy as np | ||
import random | ||
|
||
train_data = pd.read_csv('/data/yujun/captain/datasets1/train_set.csv') | ||
val_data = pd.read_csv('/data/yujun/captain/datasets1/val_set.csv') | ||
test_data = pd.read_csv('/data/yujun/datasets/daguanbei_data/test_set.csv') | ||
print('raw data loaded!') | ||
|
||
train_data[['word_seg', 'class']].to_csv('word/train_set.csv') | ||
val_data[['word_seg', 'class']].to_csv('word/val_set.csv') | ||
test_data[['id', 'word_seg']].to_csv('word/test_set.csv') | ||
print('word data made!') | ||
|
||
train_data[['article', 'class']].to_csv('article/train_set.csv') | ||
val_data[['article', 'class']].to_csv('article/val_set.csv') | ||
test_data[['id', 'article']].to_csv('article/test_set.csv') | ||
print('article data made!') |