c++ n grams - map_to_string: returns a single string of the map<string,long>, wh
ID: 3864095 • Letter: C
Question
c++ n grams
- map_to_string: returns a single string of the map<string,long>, where each element is printed as string:long, comma separated elements. No comma at the end
•vector_to_string: returns a single string of the argument vector<pair<string,long>>,where each element is printed as string:long, comma
separated elements. No comma at the end! This vector is convenient for sorting, (can't sort a map)
•clean_string: for the provided string argument returns a new string where the only contents are alphabetic characters in lower case of the argument string
•generate_ngrams: for the provided argument string, generates all the n grams of a given nfor that string. Returns a vector<string>
of all the ngrams found (no counting at this point, just avector of ngrams, could have repeats.
input 1: ( ouput 1: thisisatest)
1
This is a test!!!
input 2: (output2: hel, ell, llo, low, owo, wor, orl, rld, )
input 3: ( output3: a:3, b:2, c:1)
3
input 4: (output4:hin:2, his:1, ing:1, int:1, ist:1, nth:1, sth:1, thi:3)
Explanation / Answer
You say you want a character vector with that output, but others who find this question may be looking for one of these functions instead:
First, a way to get output ready for input to R; that would be dput:
Second, a way to output a csv file, which would be write.csv or write.table. These functions take a parameter file, not used here, to directly output to a file.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.