<s> import gzip <EOL> import os <EOL> import sys , re <EOL> import glob <EOL> import numpy <EOL> import theano <EOL> import theano . tensor as T <EOL> from utils . utils import string2bool , parse_ignore_label , parse_map_label <EOL> from pfile_io import PfileDataRead , PfileDataReadStream <EOL> from pickle_io import PickleDataRead <EOL> from kaldi_io import KaldiDataRead <EOL> def read_data_args ( data_spec ) : <EOL> elements = data_spec . split ( "<STR_LIT:U+002C>" ) <EOL> pfile_path_list = glob . glob ( elements [ <NUM_LIT:0> ] ) <EOL> dataset_args = { } <EOL> dataset_args [ '<STR_LIT:type>' ] = '<STR_LIT>' <EOL> dataset_args [ '<STR_LIT>' ] = False <EOL> dataset_args [ '<STR_LIT>' ] = False <EOL> dataset_args [ '<STR_LIT>' ] = <NUM_LIT> * <NUM_LIT> * <NUM_LIT> <EOL> dataset_args [ '<STR_LIT>' ] = <NUM_LIT:0> <EOL> dataset_args [ '<STR_LIT>' ] = <NUM_LIT:0> <EOL> if '<STR_LIT>' in data_spec or '<STR_LIT>' in data_spec : <EOL> dataset_args [ '<STR_LIT:type>' ] = '<STR_LIT>' <EOL> elif '<STR_LIT>' in data_spec : <EOL> dataset_args [ '<STR_LIT:type>' ] = '<STR_LIT>' <EOL> elif '<STR_LIT>' in data_spec : <EOL> dataset_args [ '<STR_LIT:type>' ] = '<STR_LIT>' <EOL> else : <EOL> dataset_args [ '<STR_LIT:type>' ] = '<STR_LIT>' <EOL> for i in range ( <NUM_LIT:1> , len ( elements ) ) : <EOL> element = elements [ i ] <EOL> arg_value = element . split ( "<STR_LIT:=>" ) <EOL> value = arg_value [ <NUM_LIT:1> ] <EOL> key = arg_value [ <NUM_LIT:0> ] <EOL> if key == '<STR_LIT>' : <EOL> dataset_args [ '<STR_LIT>' ] = <NUM_LIT> * <NUM_LIT> * int ( value . replace ( '<STR_LIT:m>' , '<STR_LIT>' ) ) <EOL> elif key == '<STR_LIT>' : <EOL> dataset_args [ '<STR_LIT>' ] = string2bool ( value ) <EOL> elif key == '<STR_LIT>' : <EOL> dataset_args [ '<STR_LIT>' ] = string2bool ( value ) <EOL> elif key == '<STR_LIT:label>' : <EOL> dataset_args [ '<STR_LIT:label>' ] = value <EOL> elif key == '<STR_LIT>' : <EOL> dataset_args [ '<STR_LIT>' ] = int ( value ) <EOL> elif key == '<STR_LIT>' : <EOL> dataset_args [ '<STR_LIT>' ] = int ( value ) <EOL> elif key == '<STR_LIT>' : <EOL> value = tuple ( int ( x ) for x in value . split ( '<STR_LIT::>' ) ) <EOL> if len ( value ) == <NUM_LIT:1> : value += value <EOL> dataset_args [ '<STR_LIT>' ] , dataset_args [ '<STR_LIT>' ] = value <EOL> elif key == '<STR_LIT>' : <EOL> dataset_args [ '<STR_LIT>' ] = parse_ignore_label ( value ) <EOL> elif key == '<STR_LIT>' : <EOL> dataset_args [ '<STR_LIT>' ] = parse_map_label ( value ) <EOL> else : <EOL> dataset_args [ key ] = value <EOL> return pfile_path_list , dataset_args <EOL> def read_dataset ( file_path_list , read_opts ) : <EOL> if read_opts [ '<STR_LIT:type>' ] == '<STR_LIT>' : <EOL> data_reader = PickleDataRead ( file_path_list , read_opts ) <EOL> elif read_opts [ '<STR_LIT:type>' ] == '<STR_LIT>' : <EOL> if read_opts [ '<STR_LIT>' ] : <EOL> data_reader = PfileDataReadStream ( file_path_list , read_opts ) <EOL> else : <EOL> data_reader = PfileDataRead ( file_path_list , read_opts ) <EOL> elif read_opts [ '<STR_LIT:type>' ] == '<STR_LIT>' : <EOL> data_reader = KaldiDataRead ( file_path_list , read_opts ) <EOL> data_reader . initialize_read ( first_time_reading = True ) <EOL> shared_xy = data_reader . make_shared ( ) <EOL> shared_x , shared_y = shared_xy <EOL> shared_y = T . cast ( shared_y , '<STR_LIT>' ) <EOL> return data_reader , shared_xy , shared_x , shared_y </s>
