def _count_libsvm_features(lines):
    """
    Determine how many featues are present in a libsvm file.

    :param lines: the lines of a libsvm file

    :return: the number of featues in the libsvm file
    """

    max_column_index = -1

    for line in lines:
        elements = line.split()

        for element in elements[1:]:
            column_index = int(element.split(":")[0])

            if column_index > max_column_index:
                max_column_index = column_index

    if max_column_index == -1:
        raise Exception("LibSVM file contains no data")

    return max_column_index + 1