def simple_menu(choices, index, scores=None, escape='x'):
    """
    Given two lists of choices and scores, present menu with the two
    of them.
    """

    assert scores is None or len(scores) == len(choices), \
      "Score must have same length as choices got %i vs %i" % (len(scores), len(choices))
    if scores is None:
        scores = [float("-inf")] * len(choices)

    chosen_page = None
    while chosen_page is None:
        print("---------------------------------------------------")
        for ii, (choice, score) in enumerate(zip(choices, scores)):
            if score > float("-inf"):
                print("%i)\t%s\t%0.2f" % (ii, choice, score))
            else:
                print("%i)\t%s" % (ii, choice))
        usr = raw_input("Enter wikipedia page:").decode(sys.stdin.encoding)
        usr = usr.replace("_", " ").strip()

        try:
            if int(usr) in xrange(len(choices)):
                chosen_page = choices[int(usr)]
                print("Good choice, %i: %s" % (int(usr), chosen_page))
        except __HOLE__:
            if usr.startswith("!"):
                chosen_page = usr[1:]
            elif usr != "" and not usr in index:
                print("Nope, not found; try again")
                chosen_page = None
            else:
                chosen_page = usr

        print(chosen_page)
        if usr.lower() == escape:
            break

    return chosen_page


# if __name__ == "__main__":
#     flags.define_glob("raw_csv", "data/*.csv", "Input file")
#     flags.define_int("max_size", -1, "Max size of our raw dataset")
#     flags.define_string("wiki_index", None, "Index of wikipages")
#     flags.define_list("train_columns", ["title_score", "title_edit_dist", "bias", "body_score"],
#                       "Columns used to build model")
#     flags.define_string("match_location", None,
#                         "Where we write the matches learned")

#     flags.InitFlags()

#     al = ActiveLearner(flags.raw_csv, flags.match_location, flags.train_columns, max_size=flags.max_size)
#     al.relearn()

#     if flags.wiki_index:
#         wiki_index = pickle.load(open(flags.wiki_index))
#     else:
#         wiki_index = []

#     interactions = 0
#     usr = ''
#     for qid, column in al.uncertain():
#         candidates = al._raw[al._raw['id'] == qid].sort(column, ascending=False)
#         choices = candidates['page']
#         scores = candidates['guess']

#         print(max(candidates['text']))
#         print(max(candidates['answer']))
#         chosen_page = simple_menu(choices, wiki_index, scores, 'x')

#         if chosen_page is not None:
#             al.remember(qid, chosen_page)
#             al.relearn()
#         else:
#             break

#     al.dump(flags.match_location)
dataset/ETHPy150Open Pinafore/qb/page_assignment/active_learning_for_matching.py/simple_menu