forked from AcademiaSinicaNLPLab/LJ40K
-
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
Showing
6 changed files
with
335 additions
and
108 deletions.
There are no files selected for viewing
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,63 @@ | ||
import sys | ||
import logging | ||
sys.path.append('..') | ||
from feelit.features import FileSplitter | ||
import numpy as np | ||
import argparse | ||
import pickle | ||
|
||
|
||
def get_arguments(argv): | ||
|
||
parser = argparse.ArgumentParser(description='split data in each emotion into the .npz file') | ||
parser.add_argument('-b', '--begin', metavar='RANGE_BEGIN', type=int, default=0, | ||
help='The begining index of the data in each emotion (DEFAULT: 0)') | ||
parser.add_argument('-e', '--end', metavar='RANGE_END', type=int, default=1000, | ||
help='The end index of the data in each emotion (DEFAULT: 1000)') | ||
parser.add_argument('-p', '--pickle_file', metavar='FILE_NAME', default='', | ||
help='pickle file generated by using feelit.utils.random_idx and pickle') | ||
parser.add_argument('-x', '--output_ext', metavar='EXT', default='.npz', | ||
help='output files\' extension; only useful when specified "-s" (DEFAULT: ".npz")') | ||
parser.add_argument('input', metavar='input', | ||
help='File name of the input data') | ||
parser.add_argument('output', metavar='output', | ||
help='File name or prefix for output data') | ||
parser.add_argument('-s', '--split', action='store_true', default=False, | ||
help='separate output file by emotions') | ||
parser.add_argument('-v', '--verbose', action='store_true', default=False, | ||
help='show messages') | ||
parser.add_argument('-d', '--debug', action='store_true', default=False, | ||
help='show debug messages') | ||
args = parser.parse_args(argv) | ||
return args | ||
|
||
|
||
if __name__ == '__main__': | ||
|
||
args = get_arguments(sys.argv[1:]) | ||
|
||
if args.debug: | ||
loglevel = logging.DEBUG | ||
elif args.verbose: | ||
loglevel = logging.INFO | ||
else: | ||
loglevel = logging.ERROR | ||
logging.basicConfig(format='[%(levelname)s] %(message)s', level=loglevel) | ||
|
||
splitter = FileSplitter(logger=logging) | ||
|
||
splitter.load(args.input) | ||
|
||
splitter.split(args.begin, args.end) | ||
|
||
if args.pickle_file != '': | ||
idxs = pickle.load(open(args.pickle_file)) | ||
splitter.merge_negatives(idxs) | ||
|
||
if args.split: | ||
splitter.dump_by_emotions(args.output, args.output_ext) | ||
else: | ||
splitter.dump(args.output) | ||
|
||
|
||
|
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,7 @@ | ||
[ | ||
{ | ||
"feature": "pattern40", | ||
"train_dir": "/home/doug919/projects/data/MKLv2/2000samples_4/train/pattern40/800p800n_Xy", | ||
"test_file": "/home/doug919/projects/data/MKLv2/2000samples_4/test_8000/pattern40/full.Xy/pattern40.full.Xy.test.npz" | ||
} | ||
] |
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
Oops, something went wrong.