length function for corpus