From c1f012e5370c4b46ec6ed55b6f1e23472cf9ade8 Mon Sep 17 00:00:00 2001 From: Helge Vatheuer <43379346+hlgvth@users.noreply.github.com> Date: Fri, 25 Nov 2022 13:01:18 +0100 Subject: [PATCH] Edit check for valid input path --- Source_Code/text_preprocessing/preprocess.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Source_Code/text_preprocessing/preprocess.py b/Source_Code/text_preprocessing/preprocess.py index 062ca28..5ddb901 100644 --- a/Source_Code/text_preprocessing/preprocess.py +++ b/Source_Code/text_preprocessing/preprocess.py @@ -90,12 +90,15 @@ def pos_tagging(self): print(input_file_path + " Done!") self.output_preprocessed_data(parsed_json, file_name) - +def input_path(val): + if os.path.exists(val): + return val + raise ValueError("Invalid path: %s" % val) def main(): # Define command line parameters parser = argparse.ArgumentParser(description='Get terminal command line input') - parser.add_argument('--input', '-i', type=str, dest='input_path', action='store', + parser.add_argument('--input', '-i', type=input_path, dest='input_path', action='store', default='../input/Raw_Text/BOOKS/', help="type you input file/folder path through command line")