Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

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 »
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 After May 07, 2021

Solution

Vaishnavi R answered on May 09 2021
148 Votes
complete/features.csv
word, length, ASCI value, vowels,
apple, 5, 97, 2,
apricot, 7, 97, 3,
avocado, 7, 97, 4,
anana, 6, 98, 3,
e
y, 5, 98, 1,
ilbe
y, 8, 98, 2,
lackbe
y, 10, 98, 2,
lackcu
ant, 12, 98, 3,
lood, 5, 98, 2,
luebe
y, 9, 98, 3,
oysenbe
y, 11, 98, 3,
cantaloupe, 10, 99, 5,
cherimoya, 9, 99, 4,
che
y, 6, 99, 1,
chico, 5, 99, 2,
clementine, 10, 99, 4,
cloudbe
y, 10, 99, 3,
coconut, 7, 99, 3,
cranbe
y, 9, 99, 2,
cucumber, 8, 99, 3,
cu
ant, 7, 99, 2,
custard, 7, 99, 2,
damson, 6, 100, 2,
date, 4, 100, 2,
dragonfruit, 11, 100, 4,
durian, 6, 100, 3,
elde
e
y, 10, 101, 3,
feijoa, 6, 102, 4,
fig, 3, 102, 1,
fruit, 5, 102, 2,
goji, 4, 103, 2,
goosebe
y, 10, 103, 4,
grape, 5, 103, 2,
grapefruit, 10, 103, 4,
guava, 5, 103, 3,
honeybe
y, 10, 104, 3,
honeydew, 8, 104, 3,
hucklebe
y, 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,
marionbe
y, 11, 109, 4,
melon, 5, 109, 2,
miracle, 7, 109, 3,
mulbe
y, 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,
aisin, 6, 114, 3,
ambutan, 8, 114, 3,
aspbe
y, 9, 114, 2,
edcu
ant,...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here