term_frequency function for js, ruby, & python