def read_triples(filename, min_attested=0):
    """
    Reads in triples from a TSV file, of the form distributed by OpenIE. A small dataset, constructed
    from one distributed by the University of Washington, is provided for you to use in your exercise.

    Note that everything is lowercased, so you should lowercase your queries as well.

    """
    with open(filename, "r") as f:
        data = f.read()
    fields = [line.split("\t") for line in data.split("\n") if line]
    # The LHS, predicate and RHS are in columns 1 to 3
    # Col 7 contains the number of attestations during extraction: filter out those with very few
    # Make them all lowercase, for ease of querying
    return [(row[1].lower(), row[2].lower(), row[3].lower()) for row in fields if int(row[7]) >= min_attested]