Skip to Main Content
Exercises in Programming Style
book

Exercises in Programming Style

by Cristina Videira Lopes
November 2015
Intermediate to advanced content levelIntermediate to advanced
304 pages
5h 23m
English
Chapman and Hall/CRC
Content preview from Exercises in Programming Style

Prologue

Term Frequency

LIKE QUENEAU'S STORY, the computational task in this book is trivial: given a text file, we want to display the N (e.g. 25) most frequent words and corresponding frequencies ordered by decreasing value of frequency. We should make sure to normalize for capitalization and to ignore stop words like "the", "for", etc. To keep things simple, we don't care about the ordering of words that have equal frequencies. This computational task is known as term frequency.

Here is an example of an input file and corresponding output after computing the term frequency:

Input:
 White tigers live mostly in India
 Wild lions live mostly in Africa
Output:
 live - 2
 mostly - 2
 africa - 1
 india - 1
 lions - 1
 tigers - 1
 white - 1
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Exercises for Programmers

Exercises for Programmers

Brian P. Hogan
Street Coder

Street Coder

Sedat Kapanoglu
Handbook of Constraint Programming

Handbook of Constraint Programming

Francesca Rossi, Peter van Beek, Toby Walsh

Publisher Resources

ISBN: 9781482227376