CS61B NGramMap

package ngordnet.ngrams;

import java.util.Collection;

* An object that provides utility methods for making queries on the
* Google NGrams dataset (or a subset thereof).
* An NGramMap stores pertinent data from a “words file” and a “counts
* file”. It is not a map in the strict sense, but it does provide additional
* functionality.
* @author Josh Hug
public class NGramMap {

private static final int MIN_YEAR = 1400;
private static final int MAX_YEAR = 2100;
// TODO: Add any necessary static/instance variables.

* Constructs an NGramMap from WORDSFILENAME and COUNTSFILENAME.
public NGramMap(String wordsFilename, String countsFilename) {
// TODO: Fill in this constructor. See the “NGramMap Tips” section of the spec for help.

* Provides the history of WORD between STARTYEAR and ENDYEAR, inclusive of both ends. The
* returned TimeSeries should be a copy, not a link to this NGramMap’s TimeSeries. In other
* words, changes made to the object returned by this function should not also affect the
* NGramMap. This is also known as a “defensive copy”.
public TimeSeries countHistory(String word, int startYear, int endYear) {
// TODO: Fill in this method.
return null;

* Provides the history of WORD. The returned TimeSeries should be a copy,
* not a link to this NGramMap’s TimeSeries. In other words, changes made
* to the object returned by this function should not also affect the
* NGramMap. This is also known as a “defensive copy”.
public TimeSeries countHistory(String word) {
// TODO: Fill in this method.
return null;

* Returns a defensive copy of the total number of words recorded per year in all volumes.
public TimeSeries totalCountHistory() {
// TODO: Fill in this method.
return null;

* Provides a TimeSeries containing the relative frequency per year of WORD between STARTYEAR
* and ENDYEAR, inclusive of both ends.
public TimeSeries weightHistory(String word, int startYear, int endYear) {
// TODO: Fill in this method.
return null;

* Provides a TimeSeries containing the relative frequency per year of WORD compared to
* all words recorded in that year. If the word is not in the data files, return an empty
* TimeSeries.
public TimeSeries weightHistory(String word) {
// TODO: Fill in this method.
return null;

* Provides the summed relative frequency per year of all words in WORDS
* between STARTYEAR and ENDYEAR, inclusive of both ends. If a word does not exist in
* this time frame, ignore it rather than throwing an exception.
public TimeSeries summedWeightHistory(Collection words,
int startYear, int endYear) {
// TODO: Fill in this method.
return null;

* Returns the summed relative frequency per year of all words in WORDS.
public TimeSeries summedWeightHistory(Collection words) {
// TODO: Fill in this method.
return null;

// TODO: Add any private helper methods.
// TODO: Remove all TODO comments before submitting.