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 { | std::vector<string> Dictionary::get_suggestions(const string &word) const { | ||||||
|     vector<string> suggestions; |     vector<string> suggestions; | ||||||
|     add_trigram_suggestions(suggestions, word); |     add_trigram_suggestions(suggestions, word); | ||||||
|     rank_suggestions(suggestions, word); |  | ||||||
|     trim_suggestions(suggestions, word); |     trim_suggestions(suggestions, word); | ||||||
|  |     rank_suggestions(suggestions, word); | ||||||
|     return suggestions; |     return suggestions; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -123,6 +123,8 @@ int Dictionary::slurp(path p) { | ||||||
| 
 | 
 | ||||||
|     std::string line; |     std::string line; | ||||||
|     while (std::getline(file, line)) { |     while (std::getline(file, line)) { | ||||||
|  |         if (line.empty()) | ||||||
|  |             continue; | ||||||
|         // Words larger  than max gets placed in the topmost bucket
 |         // Words larger  than max gets placed in the topmost bucket
 | ||||||
|         words[std::min(line.size(), static_cast<size_t>(MAXLEN) - 1)].push_back( |         words[std::min(line.size(), static_cast<size_t>(MAXLEN) - 1)].push_back( | ||||||
|             Word(line)); |             Word(line)); | ||||||
|  |  | ||||||
|  | @ -30,11 +30,9 @@ Word::Word(const std::string &w) : word(w) { | ||||||
|     std::sort(triagrams.begin(), triagrams.end()); |     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 { | vector<std::string> Word::get_triagrams() const { return triagrams; } | ||||||
|     return triagrams; |  | ||||||
| } |  | ||||||
| 
 | 
 | ||||||
| unsigned int Word::get_matches(const vector<string> &t) const { | unsigned int Word::get_matches(const vector<string> &t) const { | ||||||
|     unsigned int matches = 0; |     unsigned int matches = 0; | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Imbus
						Imbus