in comprehend_groundtruth_integration/src/comprehend_customer_scripts/GroundTruth/EntityRecognizer/groundtruth_format_conversion_handler.py [0:0]
def validate_s3_input(self, args):
dataset_output_S3Uri = args.dataset_output_S3Uri
annotations_output_S3Uri = args.annotations_output_S3Uri
dataset_url = urlparse(dataset_output_S3Uri)
dataset_scheme = dataset_url.scheme
self.dataset_filename = dataset_url.path.split("/")[-1]
annotations_url = urlparse(annotations_output_S3Uri)
annotation_scheme = annotations_url.scheme
self.annotation_filename = annotations_url.path.split("/")[-1]
print(self.dataset_filename)
print(self.annotation_filename)
if dataset_scheme != "s3" or annotation_scheme != "s3" or self.dataset_filename.split(".")[-1] != "csv" or self.annotation_filename.split(".")[-1] != "csv":
raise Exception("Either of the output S3 location provided is incorrect!")
# write header
with open(self.annotation_filename, 'w', encoding='utf8') as annotation_file:
datawriter = csv.writer(annotation_file, delimiter=',', lineterminator='\n')
datawriter.writerow(ANNOTATION_CSV_HEADER)