def handle(self, *args, **options):
if (options['reset_db']):
call_command('cleardatabase')
print("Grammar objects initially in database: {}".format(Grammar.objects.count()))
#Number of randomly generated grammars
num = options['num']
#Number variables this run will include.
#For example [2,3] will run the script to generate
#grammars with 2 variables and 3 variables
nVariables = [2, 3]
nonTerminals = ['A','B','C','D']
terminals = ['x','y','z','w']
if options['silent']:
sys.stdout = open(os.devnull, "w")
for n in nVariables:
start_time = time.time()
mg = MassGrammarGenerator.MassGrammarGenerator(n)
mg.run(num,nonTerminals[:n],terminals)
print("{}Variables: {} seconds---".format(n,(time.time() - start_time)))
if options['silent']:
sys.stdout = sys.__stdout__
print("Grammar objects finally in database: {}".format(Grammar.objects.count()))
评论列表
文章目录