Bugfix and ignore empty lines
This commit is contained in:
		
							parent
							
								
									7a62bebf76
								
							
						
					
					
						commit
						1c88d49452
					
				
					 3 changed files with 6 additions and 6 deletions
				
			
		| 
						 | 
				
			
			@ -25,8 +25,8 @@ bool Dictionary::contains(const string &word) const {
 | 
			
		|||
std::vector<string> Dictionary::get_suggestions(const string &word) const {
 | 
			
		||||
    vector<string> suggestions;
 | 
			
		||||
    add_trigram_suggestions(suggestions, word);
 | 
			
		||||
    rank_suggestions(suggestions, word);
 | 
			
		||||
    trim_suggestions(suggestions, word);
 | 
			
		||||
    rank_suggestions(suggestions, word);
 | 
			
		||||
    return suggestions;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -123,6 +123,8 @@ int Dictionary::slurp(path p) {
 | 
			
		|||
 | 
			
		||||
    std::string line;
 | 
			
		||||
    while (std::getline(file, line)) {
 | 
			
		||||
        if (line.empty())
 | 
			
		||||
            continue;
 | 
			
		||||
        // Words larger  than max gets placed in the topmost bucket
 | 
			
		||||
        words[std::min(line.size(), static_cast<size_t>(MAXLEN) - 1)].push_back(
 | 
			
		||||
            Word(line));
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -30,11 +30,9 @@ Word::Word(const std::string &w) : word(w) {
 | 
			
		|||
    std::sort(triagrams.begin(), triagrams.end());
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
string Word::get_word() const { return string(); }
 | 
			
		||||
string Word::get_word() const { return word; }
 | 
			
		||||
 | 
			
		||||
vector<std::string> Word::get_triagrams() const {
 | 
			
		||||
    return triagrams;
 | 
			
		||||
}
 | 
			
		||||
vector<std::string> Word::get_triagrams() const { return triagrams; }
 | 
			
		||||
 | 
			
		||||
unsigned int Word::get_matches(const vector<string> &t) const {
 | 
			
		||||
    unsigned int matches = 0;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -18,7 +18,7 @@ class Word {
 | 
			
		|||
    std::string get_word() const;
 | 
			
		||||
 | 
			
		||||
    /** Returns triagrams */
 | 
			
		||||
  std::vector<std::string> get_triagrams() const;
 | 
			
		||||
    std::vector<std::string> get_triagrams() const;
 | 
			
		||||
 | 
			
		||||
    /** Returns how many of the trigrams in t that are present
 | 
			
		||||
     in this word's trigram vector */
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue