Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (options[0] == "list") {
- auto dictionary_datastructure = make_shared<List_Datastructure>(dictionary_string);
- auto textfile_datastructure = make_unique<List_Datastructure>(textfile_string);
- string toOutputCSV = "";
- string toOutputTXT = "";
- std::list<std::string>::const_iterator iterator;
- for (iterator = textfile_datastructure->contents.begin(); iterator != textfile_datastructure->contents.end(); ++iterator) {
- if ( word_count_map.find(*iterator) == word_count_map.end() ) {
- word_count_map[*iterator] = dictionary->wordIsInDictionary(*iterator, dictionary_datastructure);
- }
- else {
- word_count_map[*iterator]++;
- }
- }
- for (const auto &p : word_count_map) {
- if (p.second != 0) {
- toOutputCSV = toOutputCSV + p.first + "," + to_string(p.second) + "\n";
- }
- else
- {
- string closest_fussymatch;
- int lowest_editdistance = 0;
- for (iterator = dictionary_datastructure->contents.begin(); iterator != dictionary_datastructure->contents.end(); ++iterator) {
- if (lowest_editdistance == 0) {
- lowest_editdistance = editDistance(p.first, *iterator);
- closest_fussymatch = p.first + " " + *iterator;
- }
- else if(editDistance(p.first, *iterator) <= lowest_editdistance)
- {
- lowest_editdistance = editDistance(p.first, *iterator);
- closest_fussymatch = p.first + " " + *iterator;
- }
- }
- toOutputTXT = toOutputTXT + closest_fussymatch + "\n";
- }
- }
- file->outputContentsToFile(toOutputCSV, options[3] + ".csv");
- file->outputContentsToFile(toOutputTXT, options[3] + ".txt");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement