File I/O and strings 1. Create a file containing text or use one that is publicly available (e.g., see https://www.gutenberg.org/). It should have at least 100 words. 2. Write a program to read in...

1 answer below »
write it in c++


File I/O and strings 1. Create a file containing text or use one that is publicly available (e.g., see https://www.gutenberg.org/). It should have at least 100 words. 2. Write a program to read in each word from the file. 3. As you process each word, convert it to lowercase (built-in function) and remove all punctuation (use std::remove_if with your own functor, remember to call string::erase afterwards). 4. If you have not yet seen this word in the file, compute three facts about the word (e.g. its length, the ascii value of its first character, how many vowels it contains...) and store them in a vector. Add the vector to a map of vectors, keyed by the word, which will hold those three facts about every word in file. 5. Write out the map of vectors to a new file called features.csv. Every entry in the map should be on a new row, and every item on the row should be separated by commas. Before you write out the map, write a header row with the column names. Sample input On either side the river lie long fields of barley and of rye... Sample output Word, NChars, NVowels, HasZ on, 2, 1, 0 either, 6, 3, 0 the, 3, 1, 0 river, 5, 2, 0 lie, 3, 2, 0 long, 4, 1, 0 etc.
Answered 1 days AfterMay 07, 2021

Answer To: File I/O and strings 1. Create a file containing text or use one that is publicly available (e.g.,...

Vaishnavi R answered on May 09 2021
158 Votes
complete/features.csv
word, length, ASCI value, vowels,
apple, 5, 97, 2,
apricot, 7, 97, 3,
avocado, 7, 97, 4,
banana, 6, 98, 3,
berry, 5, 98, 1,
bilberry, 8, 98, 2,
blackb
erry, 10, 98, 2,
blackcurrant, 12, 98, 3,
blood, 5, 98, 2,
blueberry, 9, 98, 3,
boysenberry, 11, 98, 3,
cantaloupe, 10, 99, 5,
cherimoya, 9, 99, 4,
cherry, 6, 99, 1,
chico, 5, 99, 2,
clementine, 10, 99, 4,
cloudberry, 10, 99, 3,
coconut, 7, 99, 3,
cranberry, 9, 99, 2,
cucumber, 8, 99, 3,
currant, 7, 99, 2,
custard, 7, 99, 2,
damson, 6, 100, 2,
date, 4, 100, 2,
dragonfruit, 11, 100, 4,
durian, 6, 100, 3,
elderberry, 10, 101, 3,
feijoa, 6, 102, 4,
fig, 3, 102, 1,
fruit, 5, 102, 2,
goji, 4, 103, 2,
gooseberry, 10, 103, 4,
grape, 5, 103, 2,
grapefruit, 10, 103, 4,
guava, 5, 103, 3,
honeyberry, 10, 104, 3,
honeydew, 8, 104, 3,
huckleberry, 11, 104, 3,
jabuticaba, 10, 106, 5,
jackfruit, 9, 106, 3,
jambul, 6, 106, 2,
jujube, 6, 106, 3,
juniper, 7, 106, 3,
kiwano, 6, 107, 3,
kiwifruit, 9, 107, 4,
kumquat, 7, 107, 3,
lemon, 5, 108, 2,
lime, 4, 108, 2,
longan, 6, 108, 2,
loquat, 6, 108, 3,
lychee, 6, 108, 2,
mandarine, 9, 109, 4,
mango, 5, 109, 2,
mangosteen, 10, 109, 4,
marionberry, 11, 109, 4,
melon, 5, 109, 2,
miracle, 7, 109, 3,
mulberry, 8, 109, 2,
nance, 5, 110, 2,
nectarine, 9, 110, 4,
olive, 5, 111, 3,
orange, 6, 111, 3,
papaya, 6, 112, 3,
passionfruit, 12, 112, 5,
peach, 5, 112, 2,
pear, 4, 112, 2,
persimmon, 9, 112, 3,
physalis, 8, 112, 2,
pineapple, 9, 112, 4,
plantain, 8, 112, 3,
plum, 4, 112, 1,
plumcot, 7, 112, 2,
pomegranate, 11, 112, 5,
pomelo, 6, 112, 3,
prune, 5, 112, 2,
purple, 6, 112, 2,
quince, 6, 113, 3,
quitoense, 9, 113, 5,
raisin, 6, 114, 3,
rambutan, 8, 114, 3,
raspberry, 9, 114, 2,
redcurrant,...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here