def parsing_plan(plan, plan_order):
    """
    parse the plan from string to list of triples, where each triple is a list of [s,p,o]
    :param plan: string, the same as those in .triple file
    :param plan_order: list, plan order
    :return:
    """
    tripleset = plan.split(' < tsp > ')
    tripleset = [[t.strip() for t in triple.split(' | ')] for triple in tripleset]
    assert len(tripleset) >= len(plan_order)
    assert all([len(triple) == 3 for triple in tripleset])
    tripleset = [tripleset[i] for i in plan_order]
    return tripleset