def calcdf(matrix):
    """
    Calculates the document frequency for every term in the matrix supplied. Returns
    a tuple containing a dictionary with the terms and `df` value, as well as the amount of documents.
    """
    docamount = len(matrix[0])  # get the amount of documents
    df = dict()  # create a new dictionary
    wordcount = len(matrix)
    for line in range(1, wordcount):  # get every line from the matrix
        current_line = matrix[line]  # get the current line from the matrix
        term = current_line[0]
        worddf = 0
        for word in range(1, docamount):
            current_word = current_line[word]
            if (current_word > 0):  
            # if the value of the term is above zero, add this for the df
                worddf += 1
        df[term] = worddf  # save the df for the current term in a dictionary
    return df, docamount