required=True) parser.add_argument("--editmodel", "-e", type=argparse.FileType('rb'), required=True) args = parser.parse_args() s = SpellChecker(max_distance=2) s.load_language_model(args.languagemodel) s.load_channel_model(args.editmodel) print(s.channel_model.prob("hello", "hello")) print(s.channel_model.prob("hellp", "hello")) print(s.channel_model.prob("hllp", "hello")) print(s.check_line("they did not yb any menas")) """ >>> [['they'], ['did'], ['not'], ['by', 'b', 'ye', 'y', 'yo', 'ob', 'ya', 'ab'], ['any'], >>> ['means', 'mens', 'mena', 'zenas', 'menan', 'mends']] """ print(s.autocorrect_line("they did not yb any menas")) """ >>> ['they', 'did', 'not', 'by', 'any', 'means'] """ print(s.suggest_line("they did not yb any menas", max_suggestions=2)) """ >>> ['they', 'did', 'not', ['by', 'b'], 'any', ['means', 'mens']] """
"-e", type=argparse.FileType('rb'), required=True) args = parser.parse_args() s = SpellChecker(max_distance=2) s.load_language_model(args.languagemodel) s.load_channel_model(args.editmodel) print(s.channel_model.prob("hello", "hello")) print(s.channel_model.prob("hellp", "hello")) print(s.channel_model.prob("hllp", "hello")) print(s.channel_model.align("helol", "hello")) print(s.channel_model.prob("helol", "hello")) print(s.check_line("jesus chirst look at that!")) print(s.check_line("they did not yb any menas")) """ >>> [['they'], ['did'], ['not'], ['by', 'b', 'ye', 'y', 'yo', 'ob', 'ya', 'ab'], ['any'], >>> ['means', 'mens', 'mena', 'zenas', 'menan', 'mends']] """ print(s.autocorrect_line("they did not yb any menas.")) """ >>> ['they', 'did', 'not', 'by', 'any', 'means'] """ print(s.suggest_line("they did not yb any menas.", max_suggestions=2)) """ >>> ['they', 'did', 'not', ['by', 'b'], 'any', ['means', 'mens']]