Advertisement
Guest User

Untitled

a guest
Aug 13th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.45 KB | None | 0 0
  1. if (options[0] == "list") {
  2. auto dictionary_datastructure = make_shared<List_Datastructure>(dictionary_string);
  3. auto textfile_datastructure = make_unique<List_Datastructure>(textfile_string);
  4. string toOutputCSV = "";
  5. string toOutputTXT = "";
  6.  
  7. std::list<std::string>::const_iterator iterator;
  8. for (iterator = textfile_datastructure->contents.begin(); iterator != textfile_datastructure->contents.end(); ++iterator) {
  9. if ( word_count_map.find(*iterator) == word_count_map.end() ) {
  10. word_count_map[*iterator] = dictionary->wordIsInDictionary(*iterator, dictionary_datastructure);
  11. }
  12. else {
  13. word_count_map[*iterator]++;
  14. }
  15. }
  16. for (const auto &p : word_count_map) {
  17. if (p.second != 0) {
  18. toOutputCSV = toOutputCSV + p.first + "," + to_string(p.second) + "\n";
  19. }
  20. else
  21. {
  22. string closest_fussymatch;
  23. int lowest_editdistance = 0;
  24. for (iterator = dictionary_datastructure->contents.begin(); iterator != dictionary_datastructure->contents.end(); ++iterator) {
  25. if (lowest_editdistance == 0) {
  26. lowest_editdistance = editDistance(p.first, *iterator);
  27. closest_fussymatch = p.first + " " + *iterator;
  28. }
  29. else if(editDistance(p.first, *iterator) <= lowest_editdistance)
  30. {
  31. lowest_editdistance = editDistance(p.first, *iterator);
  32. closest_fussymatch = p.first + " " + *iterator;
  33. }
  34. }
  35. toOutputTXT = toOutputTXT + closest_fussymatch + "\n";
  36. }
  37. }
  38.  
  39. file->outputContentsToFile(toOutputCSV, options[3] + ".csv");
  40. file->outputContentsToFile(toOutputTXT, options[3] + ".txt");
  41.  
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement