Last active
January 29, 2016 15:28
-
-
Save dulimarta/30866e27fd783d3eb254 to your computer and use it in GitHub Desktop.
TextPredictor.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Created by Hans Dulimarta | |
// | |
#include <iostream> | |
#include "TextPredictor.h" | |
using namespace std; | |
TextPredictor::TextPredictor() { | |
} | |
void TextPredictor::scanWordsFrom(istream &input) { | |
string curr_word, next_word, w; | |
/* TODO add your own code here */ | |
input >> w; | |
curr_word = lowercaseof(w); | |
while (input >> w) { | |
next_word = lowercaseof(w); | |
// clog << next_word << " follows " << curr_word << endl; | |
/* TODO add your own code here */ | |
curr_word = next_word; | |
} | |
/* TODO add your own code here */ | |
} | |
vector<string> TextPredictor::wordsFromPrefix(const string &p) const { | |
vector<string> res; | |
/* TODO complete this function (less than 5 lines of code) */ | |
return res; | |
} | |
vector<string> TextPredictor::wordsAfter(const string &w) const { | |
vector<string> res; | |
/* TODO complete this function (less than 5 lines of code) */ | |
return res; | |
} | |
string TextPredictor::lowercaseof(const string& word) const { | |
string out = word; | |
for (int k = 0; k < word.length(); k++) | |
{ | |
out[k] = tolower(word[k]); | |
} | |
return out; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment