-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvalidations.py
More file actions
33 lines (26 loc) · 1.37 KB
/
validations.py
File metadata and controls
33 lines (26 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import argparse
def isValidDataName(parser, arg):
if arg not in ["diabetes", "posts", "anonymized1", "anonymized2"]:
parser.error("Dataset %s does not exist." % arg)
else:
return arg
def isValidDirection(parser, arg):
if arg not in ["up", "down"]:
parser.error("Direction %s is not valid. Type 'up' or 'down'." % arg)
else:
return arg
def isValidBide(parser, arg):
if arg not in ["true", "false", "0", "1"]:
parser.error("BIDE usage decision %s is not valid. Type 'true' or 'false' or '1' or '0'." % arg)
else:
return arg
def parseArguments():
parser = argparse.ArgumentParser()
parser.add_argument("file", help="Data set name: diabetes, posts, anonymized1 or anonymized2.", type=lambda arg: isValidDataName(parser, arg))
parser.add_argument("direction", help="Direction of search: up or down.", type=lambda arg: isValidDirection(parser, arg))
parser.add_argument("-t", "--threshold", help="Support measure threshold.", type=int, default=10)
parser.add_argument("-m", "--minlen", help="Minumum length of pattern.", type=int, default=1)
parser.add_argument("-u", "--user", help="User number.", type=int, default=-1)
parser.add_argument("-b", "--bide", help="Whether to use BIDE algorithm.", type=lambda arg: isValidBide(parser, arg), default="false")
args = parser.parse_args()
return args