python check.py ../Languages/birom.py or python check.py ../Language/*.py """ import numpy import sys from NumberSystem import * from Shared import * from math import log for f in sys.argv[1:]: print "# Loading file ",f NS = NumberSystem() for k in open(f, 'r'): print k if re.match("\\s*f\\[", k): NS.add_rule_from_string(k.strip()) for n in range(1,100): v = NS.number_to_string(n) # call first so we get f_calls #print NS.distinct_morphemes print q(f), n, NS.f_calls, len(NS.derivation_morphemes), q(v) NS.check(verbose=True, check_rule_use=True, check_unique=True) # Curious: what happens if we just load all the rules and scramble them? """
import numpy import sys from NumberSystem import * from Shared import * from math import log Ns = numpy.array(range(1, 101)) def p(n): return 1.0 / (n * n) ##TODO: NORMALIZE CORRECTLY for f in sys.argv[1:]: NS = NumberSystem() for k in open(f, 'r'): if re.match("\\s*f\\[", k): NS.add_rule_from_string(k.strip()) expected_length = 0.0 expected_recurse = 0.0 for n in Ns: v = NS.number_to_string(n) expected_length += float(NS.morpheme_count) * p(n) expected_recurse += float(NS.f_calls) * p(n) M = len(NS.all_morphemes()) print q(f), expected_length, expected_recurse, M
TODO: This will be updated with what measures we want """ import numpy import sys from NumberSystem import * from Shared import * from math import log Ns = numpy.array( range(1,101) ) def p(n): return 1.0/(n*n) ##TODO: NORMALIZE CORRECTLY for f in sys.argv[1:]: NS = NumberSystem() for k in open(f, 'r'): if re.match("\\s*f\\[", k): NS.add_rule_from_string(k.strip()) expected_length = 0.0 expected_recurse = 0.0 for n in Ns: v = NS.number_to_string(n) expected_length += float(NS.morpheme_count) * p(n) expected_recurse += float(NS.f_calls) * p(n) M = len(NS.all_morphemes()) print q(f), expected_length, expected_recurse, M
Use via: python check.py ../Languages/birom.py or python check.py ../Language/*.py """ import numpy import sys from NumberSystem import * from Shared import * from math import log for f in sys.argv[1:]: print "# Loading file ", f NS = NumberSystem() for k in open(f, 'r'): print k if re.match("\\s*f\\[", k): NS.add_rule_from_string(k.strip()) for n in range(1, 100): v = NS.number_to_string(n) # call first so we get f_calls #print NS.distinct_morphemes print q(f), n, NS.f_calls, len(NS.derivation_morphemes), q(v) NS.check(verbose=True, check_rule_use=True, check_unique=True) # Curious: what happens if we just load all the rules and scramble them? """ import random