Question
Stop words are words that do not carry significant meaning. Some of the stop words are 'a', 'about', 'above', 'after', 'again', 'all', 'am', 'because', 'been',
Stop words are words that do not carry significant meaning. Some of the stop words are 'a', 'about', 'above', 'after', 'again', 'all', 'am', 'because', 'been', 'before', 'being', 'below', 'between', 'both', 'but', 'can't', 'cannot', 'could', 'couldn't', 'did', 'didn't'. Given a list of stop words and their weights in a file 'stopwords.txt' and a matrix of words in a file, design an algorithm and C++ code to determine the weight matrix of stop words in the matrix. If a word in input file is not a word in the given list of stopwords then give the weight as 0. The input is such that at least one entry in the outer rows and columns is 0. Rotate the outer elements (elements that lie in the outer row and the column) of the matrix right till the element in the index (0,0) is 0. If the content of stopwords.txt is as follows:
a 1
about 2
above 3
after 4
again 5
because 6
being 7
below 8
between 9
both 10
but 11
can 12
cannot 13
could 14
did 15
If the input matrix is given in a file matrix.txt:
a goat above sky
after can could above
being below between both
can after a but
did could can being
then the weight matrix is
1 0 3 0
4 12 14 3
7 8 9 10
12 4 1 11
15 14 12 7
and the desired output matrix is
0 3 10 11
3 12 14 7
0 8 9 12
1 4 1 14
4 7 12 15
Input Format
Name of the file with input word matrix
Order of elements in input file
number of rows, number of columns and
Elements in matrix in row major ordering
Output Format
Elements in the right shifted matrix with element in (0,0) as 0
element in the first row separated by tab
element in the second row separated by tab
...
...
element in the last row separated by tab
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started