def get_data(self): module_type = self.module.type.lower() expect_data_format = self.module.processor.data_format( self.module.default_signature) input_data = {} if len(expect_data_format) == 1: key = list(expect_data_format.keys())[0] if self.args.input_file: input_data[key] = txt_parser.parse(self.args.input_file, self.args.use_strip) else: if module_type.startswith("cv"): if hasattr(self.args, "input_path"): self.check_file() input_data[key] = [self.args.input_path] elif module_type.startswith("nlp"): input_data[key] = [self.args.input_text] else: for key in expect_data_format.keys(): input_data[key] = [self.args.__dict__[key]] if self.args.input_file: input_data = pandas.read_csv(self.args.input_file, sep="\t") return input_data
def check_input_data(self, args): input_data = [] if args.input_file: if not os.path.exists(args.input_file): print("File %s is not exist." % args.input_file) raise RuntimeError else: input_data = txt_parser.parse(args.input_file, use_strip=True) elif args.input_text: if args.input_text.strip() != '': if six.PY2: input_data = [ args.input_text.decode( sys_stdin_encoding()).decode("utf8") ] else: input_data = [args.input_text] else: print( "ERROR: The input data is inconsistent with expectations.") if input_data == []: print("ERROR: The input data is inconsistent with expectations.") raise DataFormatError return input_data
def check_input_data(self, args): input_data = list() if args.input_path: input_data = [args.input_path] elif args.input_file: if not os.path.exists(args.input_file): raise RuntimeError("File %s is not exist." % args.input_file) else: input_data = txt_parser.parse(args.input_file, use_strip=True) return input_data
def check_input_data(self, args): input_data = [] if args.input_file: if not os.path.exists(args.input_file): raise FileNotFoundError( "File %s does not exist." % args.input_file) else: input_data = txt_parser.parse(args.input_file, use_strip=True) elif args.input_text: input_data = [args.input_text] return input_data