def dfs(M, fns, word):
    """Compute the Document Frequency Score of a word from a document-word count matrix.

    """
    word_index = fns.index(word)

    # Word count over all documents. It's a Matrix (2d ndarray).
    W = M[:, [word_index]]

    # The total number of Documents is just the number of rows of the matrix.
    n_total_documents = W.shape[0]

    # The number of documents where the word appears is the length of the array of nonzero elements in that row
    document_frequency = len(W.nonzero()[0])

    # Scaled document frequency in relation to the total number of documents
    rdfm =  document_frequency / n_total_documents

    return rdfm