示例#1
0
FrequencyTable insert_word(FrequencyTable mytable, string holder)
{
  if (isalpha(holder[0])) {
    for (int i = 0; i < (int) holder.length(); i++) {
      holder[i] =  tolower(holder[i]);
    }
    mytable.insert(holder);
  }
  return mytable;
}
示例#2
0
/******************************************************************************
purpose: reads in data from a file
input: a class of type FrequencyTable, includes all the private and public
        variables and functions
returns: a class of type FrequencyTable
*****************************************************************************/
FrequencyTable maketable(FrequencyTable table)
{
  string word;
  int size;

  while(cin >> word){//reads in strings until there is no more data
    size = word.size();

      for(int i = 0; i < size; i++){
	word[i] = tolower(word[i]);//lowercases the word
      }

      if(isalpha(word[0])){
        table.insert(word);
      }
  }

  return table;
}