def build_dict(segfun, n=50, stopword_list=None, filename = None): we = WeightEngine(segfun, stopwordList=stopword_list) we.weight_learning(read_arbitrary_mock(2000000)) if filename: we.save_record(filename) return sort_dict(we._dict)[:n]