def output(self): for node_type, count in sorted_by_value_desc(self.counts): if node_type == 'total': continue print "% 15s | %d" % (node_type, count) print "% 15s | %d" % ('total', self.counts['total']) print for dict_name in ('predication', 'apposition', 'modification', 'adjunction', 'coordination'): print dict_name for tag_string, count in sorted_by_value_desc(getattr(self, dict_name + '_kinds')): print "% 6d | (% 2d) %s" % (count, len(tag_string.split(' ')), tag_string) print
def output(self): for node_type, count in sorted_by_value_desc(self.counts): if node_type == 'total': continue print "% 15s | %d" % (node_type, count) print "% 15s | %d" % ('total', self.counts['total']) print for dict_name in ('predication', 'apposition', 'modification', 'adjunction', 'coordination'): print dict_name for tag_string, count in sorted_by_value_desc( getattr(self, dict_name + '_kinds')): print "% 6d | (% 2d) %s" % (count, len( tag_string.split(' ')), tag_string) print
def output(self): print 'trace types:' for k, v in sorted_by_value_desc(self.parents): print '% 5d | %s' % (v, k) print 'derivs with rcs: %d/%d=%.2f%%' % (self.rcderivs, self.total, self.rcderivs / float(self.total) * 100.)
def output(self): headings = ("(%s ,) %s -> %s", "(, %s) %s -> %s", "%s (%s ,) -> %s", "%s (, %s) -> %s") for index, heading in enumerate(headings): env_hash = getattr(self, "e%d" % index) print heading % ("X", "Y", "Z") print "-" * len(heading) examples_hash = getattr(self, "e%d_examples" % index) for (l, r, p), f in sorted_by_value_desc(env_hash): triple = heading % (l, r, p) print "% 10d [%28s] %-60s %s" % ( f, analyse(C(l), C(r), C(p)), triple, " ".join(examples_hash[(l, r, p)]), ) if index == 0 and (l, r, p) in self.e3 and self.e3[(l, r, p)] <= f: alt_triple = headings[3] % (l, r, p) alt_freq = self.e3[(l, r, p)] print "* % 8d%32s%-60s %s" % (alt_freq, " " * 32, alt_triple, " ".join(self.e3_examples[(l, r, p)])) elif index == 3 and (l, r, p) in self.e0 and self.e0[(l, r, p)] <= f: alt_triple = headings[0] % (l, r, p) alt_freq = self.e0[(l, r, p)] print "* % 8d%32s%-60s %s" % (alt_freq, " " * 32, alt_triple, " ".join(self.e0_examples[(l, r, p)]))
def output(self): headings = ("(%s ,) %s -> %s", "(, %s) %s -> %s", "%s (%s ,) -> %s", "%s (, %s) -> %s") for index, heading in enumerate(headings): env_hash = getattr(self, 'e%d' % index) print heading % ('X', 'Y', 'Z') print "-" * len(heading) examples_hash = getattr(self, 'e%d_examples' % index) for (l, r, p), f in sorted_by_value_desc(env_hash): triple = heading % (l, r, p) print "% 10d [%28s] %-60s %s" % (f, analyse(C(l), C(r), C(p)), triple, ' '.join(examples_hash[(l, r, p)])) if (index == 0 and (l, r, p) in self.e3 and self.e3[(l, r, p)] <= f): alt_triple = headings[3] % (l, r, p) alt_freq = self.e3[(l, r, p)] print "* % 8d%32s%-60s %s" % (alt_freq, " "*32, alt_triple, ' '.join(self.e3_examples[(l, r, p)])) elif (index == 3 and (l, r, p) in self.e0 and self.e0[(l, r, p)] <= f): alt_triple = headings[0] % (l, r, p) alt_freq = self.e0[(l, r, p)] print "* % 8d%32s%-60s %s" % (alt_freq, " "*32, alt_triple, ' '.join(self.e0_examples[(l, r, p)]))
def output(self): with file(self.growth_fn, 'w') as f: print >>f, '\n'.join( ' '.join(map(str, xy)) for xy in self.data_points ) with file(self.rank_fn, 'w') as f: for k, freq in sorted_by_value_desc(self.freqs): print >>f, freq
def output(self): as_left = {} as_right = {} for (l, r, p), f in self.envs.iteritems(): if l == ",": as_left[(l, r, p)] = f else: as_right[(l, r, p)] = f print ", _ -> _" print "--------" for (l, r, p), f in sorted_by_value_desc(as_left): print "% 10d [%28s] %s %20s -> %s" % (f, analyse(C(l), C(r), C(p)), l, r, p) print "_ , -> _" print "--------" for (l, r, p), f in sorted_by_value_desc(as_right): print "% 10d [%28s] %20s %s -> %s" % (f, analyse(C(l), C(r), C(p)), l, r, p)
def output(self): as_left = {} as_right = {} for (l, r, p), f in self.envs.iteritems(): if l == ',': as_left[(l, r, p)] = f else: as_right[(l, r, p)] = f print ", _ -> _" print "--------" for (l, r, p), f in sorted_by_value_desc(as_left): print "% 10d [%28s] %s %20s -> %s" % (f, analyse(C(l), C(r), C(p)), l, r, p) print "_ , -> _" print "--------" for (l, r, p), f in sorted_by_value_desc(as_right): print "% 10d [%28s] %20s %s -> %s" % (f, analyse(C(l), C(r), C(p)), l, r, p)
def output(self): with file(self.growth_fn, 'w') as f: print >> f, '\n'.join(' '.join(map(str, xy)) for xy in self.data_points) with file(self.rank_fn, 'w') as f: for k, freq in sorted_by_value_desc(self.freqs): print >> f, freq
def output(self): as_left = {} as_right = {} for (side, l, r, p), f in self.envs.iteritems(): if side == AnalyseAbsorption.LEFT: as_left[ (l, r, p) ] = f elif side == AnalyseAbsorption.RIGHT: as_right[ (l, r, p) ] = f print "(X ,) Y -> Z" print "--------" for (l, r, p), f in sorted_by_value_desc(as_left): print "% 10d [%28s] (%s ,) %s -> %s" % (f, analyse(C(l), C(r), C(p)), l, r, p) print "X (, Y) -> Z" print "--------" for (l, r, p), f in sorted_by_value_desc(as_right): print "% 10d [%28s] %s (, %s) -> %s" % (f, analyse(C(l), C(r), C(p)), l, r, p)
def output(self): for sig, (count, examples) in sorted_by_value_desc(self.counts): print '% 10d | %s' % (count, sig) print '; '.join(examples[:10])
def output(self): for comb, freq in sorted_by_value_desc(self.counts): print "% 10s | %d" % (comb, freq)
else: # Split unrecognised rules by type if r: binary[rule_tuple] += 1 else: unary[rule_tuple] += 1 unrecognised_rules[rule_tuple] += 1 if not has_unrecognised_rules: with_unrecognised_rules += 1 has_unrecognised_rules = True total += 1 print "With unrecognised rules: %d/%d=%.2f" % (with_unrecognised_rules, total, with_unrecognised_rules/float(total)*100.0) for rule, freq in sorted_by_value_desc(unrecognised_rules): l, r, p = rule print "% 4d | %20s %20s -> %s" % (freq, l, r, p) print "UCP rules: %d/%d=%.2f" % (with_ucp, total, with_ucp/float(total)*100.0) for rule, freq in sorted_by_value_desc(ucp_rules): l, r, p = rule print "% 4d | %20s %20s -> %s" % (freq, l, r, p) print "Unrecognised binary rules:" for rule, freq in sorted_by_value_desc(binary): l, r, p = rule print "% 4d | %20s %20s -> %s" % (freq, l, r, p) print "Unrecognised unary rules:" for rule, freq in sorted_by_value_desc(unary):
def output(self): for (l, r, p), freq in sorted_by_value_desc(self.counts): print "%8d | %15s %-15s -> %-15s [%s]" % (freq, l, r, p, analyse(l, r, p))
def output(self): for (cat, lex_dict) in self.examples.iteritems(): print "Category %s:" % cat for (lex, frequency ) in sorted_by_value_desc(lex_dict)[0:self.example_count]: print "\t% 3d | %s" % (frequency, lex)
def output(self): for key, freq in sorted_by_value_desc(self.counts): print '% 10d | %s' % (freq, key)
def output(self): for (cat, lex_dict) in self.examples.iteritems(): print "Category %s:" % cat for (lex, frequency) in sorted_by_value_desc(lex_dict)[0:self.example_count]: print "\t% 3d | %s" % (frequency, lex)
def output(self): with file(os.path.join(self.outdir, 'failed_freqs'), 'w') as f: for badcat, freq in sorted_by_value_desc(self.bad_freqs): print >>f, '% 5d | %s' % (freq, badcat)
def output(self): for punct, f in sorted_by_value_desc(self.counts): print "%d | %s" % (f, punct) print "Total: %d" % self.total
def output(self): for (lch, rch, parent), freq in sorted_by_value_desc(self.envs): print "% 10d (%s %s -> %s)" % (freq, lch, rch, parent)
def output(self): for (comma_on_left, lch, rch, parent), freq in sorted_by_value_desc(self.envs): print "% 10d %s (%s %s -> %s)" % (freq, "L" if comma_on_left else "R", lch, rch, parent)
def output(self): for head, freq in sorted_by_value_desc(self.headfreqs): print '% 4d | %s' % (freq, head)
def output(self): for comb, count in sorted_by_value_desc(self.counter): print "% 20s | %d" % (comb, count)
if r: binary[rule_tuple] += 1 else: unary[rule_tuple] += 1 unrecognised_rules[rule_tuple] += 1 if not has_unrecognised_rules: with_unrecognised_rules += 1 has_unrecognised_rules = True total += 1 print "With unrecognised rules: %d/%d=%.2f" % (with_unrecognised_rules, total, with_unrecognised_rules / float(total) * 100.0) for rule, freq in sorted_by_value_desc(unrecognised_rules): l, r, p = rule print "% 4d | %20s %20s -> %s" % (freq, l, r, p) print "UCP rules: %d/%d=%.2f" % (with_ucp, total, with_ucp / float(total) * 100.0) for rule, freq in sorted_by_value_desc(ucp_rules): l, r, p = rule print "% 4d | %20s %20s -> %s" % (freq, l, r, p) print "Unrecognised binary rules:" for rule, freq in sorted_by_value_desc(binary): l, r, p = rule print "% 4d | %20s %20s -> %s" % (freq, l, r, p) print "Unrecognised unary rules:"
def output(self): for (p, l, r), f in sorted_by_value_desc(self.rules): print p, l, r, f
def output(self): for (cat, comb, slash_index), frequency in sorted_by_value_desc(self.freqs): print "% 60s | %2d | %25s | %d" % (cat, slash_index, comb, frequency)
def output(self): with file(os.path.join(self.outdir, 'failed_freqs'), 'w') as f: for badcat, freq in sorted_by_value_desc(self.bad_freqs): print >> f, '% 5d | %s' % (freq, badcat)
def output(self): print 'trace types:' for k, v in sorted_by_value_desc(self.parents): print '% 5d | %s' % (v, k) print 'derivs with rcs: %d/%d=%.2f%%' % (self.rcderivs, self.total, self.rcderivs/float(self.total)*100.)