-
August 13th, 2013, 12:47 PM
#1
inverse index
over the past week i have been trying to create a program that reads in two text files. Then the inverse index should produce the following set of key:value pairs
{‘my’:[1,2], ‘dog’:[1,2], ‘has’:[1], ‘no’:[1,2], ‘nose’:[1], ‘wants’:[2], ‘bone’:[2]}
i have been trying to do this with out using the container map and vector and only using the header files: iostream,fstream,cmath and string
i know how to read and search text files and i have been been researching so much but there is no piece of code that i have been able to find to help me create this program. So if you could please help me i would really appreciate it?
-
August 13th, 2013, 12:50 PM
#2
Re: inverse index
by the way one file reads “my dog has no nose” and the other reads no dog wants my bone”
-
August 13th, 2013, 12:54 PM
#3
Re: inverse index
Well, how would you do it with a pencil on a paper sheet?
Victor Nijegorodov
-
August 13th, 2013, 12:57 PM
#4
Re: inverse index
so are you saying that its not possible to create a map like function without using the container map
-
August 13th, 2013, 01:07 PM
#5
Re: inverse index
Originally Posted by casjb
so are you saying that its not possible to create a map like function without using the container map
Where was I saying it?
You can. but before you will implement it in C++ code you have to understand how you will do it!
Victor Nijegorodov
-
August 13th, 2013, 01:09 PM
#6
Re: inverse index
okay so will u be able to breakdown how to go about it please?
-
August 13th, 2013, 01:11 PM
#7
Re: inverse index
Originally Posted by casjb
okay so will u be able to breakdown how to go about it please?
Probably. But not now.
Victor Nijegorodov
-
August 13th, 2013, 01:15 PM
#8
Re: inverse index
is there anyone who will be able to breakdown how to create a map like function without using the container map please?
-
August 13th, 2013, 01:20 PM
#9
Re: inverse index
Originally Posted by casjb
{‘my’:[1,2], ‘dog’:[1,2], ‘has’:[1], ‘no’:[1,2], ‘nose’:[1], ‘wants’:[2], ‘bone’:[2]}
i have been trying to do this with out using the container map and vector and only using the header files: iostream,fstream,cmath and string
So in other words, you're learning 'C' instead of C++.
but there is no piece of code that i have been able to find to help me create this program.
That is not how programming works.
You have to first figure out logically how to solve the problem. Then you write the steps down -- then you translate those steps into a C++ program.
So if you could please help me i would really appreciate it?
Well, if you could use a map and vector, how would you solve it? After you answer that question, then you look at your solution and replace map and vector with your own classes that do the same thing.
Regards,
Paul McKenzie
-
August 13th, 2013, 01:23 PM
#10
Re: inverse index
Originally Posted by casjb
is there anyone who will be able to breakdown how to create a map like function without using the container map please?
Is this a homework assignment? Why can't you use map?
Regards,
Paul McKenzie
-
August 13th, 2013, 01:30 PM
#11
Re: inverse index
Originally Posted by casjb
is there anyone who will be able to breakdown how to create a map like function without using the container map please?
Anyway, have you used arrays and structs, because those are the aggregate types that wasn't on your list of banned items. If you can't use arrays and structs, then the course you're taking is a waste of your time as it is a cruel joke played on you.
You have a string and then you have an array of integers associated with the string. This is where struct usage is done (that's how you associate) where you group the string and array in one entity. Then you need an array of these structs so that you can facilitate searching the array for a string to see if it was found, etc.
In other words, it isn't just a map issue. You have to build the program from scratch -- create the proper data struture, then you need to parse the text and populate the structure accordingly. Just parsing the data doesn't require any map usage.
Regards,
Paul McKenzie
Last edited by Paul McKenzie; August 13th, 2013 at 01:34 PM.
-
August 13th, 2013, 01:38 PM
#12
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|