if args.trace:
print("analyzing chunker coverage of %s with %s\n" % (args.corpus, chunker.__class__.__name__))
iobs_found = FreqDist()
sents = corpus.sents()
if args.fraction != 1.0:
cutoff = int(math.ceil(len(sents) * args.fraction))
sents = sents[:cutoff]
for sent in sents:
tree = chunker.parse(tagger.tag(sent))
for child in tree.subtrees(lambda t: t.node != "S"):
iobs_found.inc(child.node)
iobs = iobs_found.samples()
justify = max(7, *[len(iob) for iob in iobs])
After Change
if args.trace:
print("analyzing chunker coverage of %s with %s\n" % (args.corpus, chunker.__class__.__name__))
iobs_found = collections.defaultdict(int)
sents = corpus.sents()
if args.fraction != 1.0:
cutoff = int(math.ceil(len(sents) * args.fraction))
sents = sents[:cutoff]
for sent in sents:
tree = chunker.parse(tagger.tag(sent))
for child in tree.subtrees(lambda t: node_label(t) != "S"):
iobs_found[node_label(child)] += 1
iobs = iobs_found.keys()
justify = max(7, *[len(iob) for iob in iobs])