Need sample code for Text File Compression!!!

Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Nov 2008
Posts: 4
Reputation: SlayerX is an unknown quantity at this point 
Solved Threads: 0
SlayerX SlayerX is offline Offline
Newbie Poster

Need sample code for Text File Compression!!!

 
-1
  #1
Nov 26th, 2008
Need some help on text file compression....
Text File Compression.

The text file compression must be able to perform the following functions:

• Able to compress a text file and generate an index file
• Able to decompress the file
• Able to show the time taken for compressing and decompressing
• Able to show the file size before and after compressed






Task:
1) Replace repeated sentence with index number
2) Decompress into original text file
3 )Use class
4) Replace repeated words with index number
5) Use any 2 concepts of OOD (i.e. inheritance, polymorphism)
6) Comment methods and variables appropriately
7) Generate Index file that store index number and correspondent word/sentence
Last edited by SlayerX; Nov 26th, 2008 at 4:24 am.
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 2,001
Reputation: ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of 
Solved Threads: 343
ArkM's Avatar
ArkM ArkM is offline Offline
Postaholic

Re: Need sample code for Text File Compression!!!

 
0
  #2
Nov 26th, 2008
911: http://www.daniweb.com/forums/announcement8-2.html
Sample code needed? Google is your friend!..
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 4
Reputation: SlayerX is an unknown quantity at this point 
Solved Threads: 0
SlayerX SlayerX is offline Offline
Newbie Poster

Re: Need sample code for Text File Compression!!!

 
0
  #3
Nov 26th, 2008
can giv me a sample?thx or help me with it .....i will learn it myself or u can write comment for me to let me learn it in the code....
Last edited by SlayerX; Nov 26th, 2008 at 12:34 pm.
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 973
Reputation: Alex Edwards is a jewel in the rough Alex Edwards is a jewel in the rough Alex Edwards is a jewel in the rough Alex Edwards is a jewel in the rough 
Solved Threads: 107
Alex Edwards's Avatar
Alex Edwards Alex Edwards is offline Offline
Posting Shark

Re: Need sample code for Text File Compression!!!

 
0
  #4
Nov 26th, 2008
You know, I've been wondering about this for awhile now myself.

Honestly you can probably get away with making some kind of regex or key to "compress" files with given values.

For example lets say you have a text document and it is set up something like this--

// myWord.txt

ssssss      
ss

-- what is listed is 6 s's, then 6 space characters, then a newline character and then 2 s's. After those s's, the end-of-file character is present (not in the above example, but pretend it is there for the sake of this example @_@ ).

How would you compress this? Right now the amount of space this file takes up on a disk is between (6 * 1 + 6 * 1 + 6 * 2 + (1 or 0)) or 24-25 bytes to 4096 bytes (4 kb) due to the way expansions work on some disk drives. If you want to compress this file to take up less space, you can form a special key that detects multiple values of a particular character and places them in an index.

For example, there are 6 s's. You can make a .compress file such that it has a pair of numbers (like 1 and 6) such that they are read from a parser that you will create that takes an index file of the same name for a particular .compress file and maps the numbers to their corresponding characters in the index file.

Your index file might look something like this--

s//[s char]
// [newline char] //[space char]s//[s char]

--and if you have a smart parser, you can do repetition-detection for a particular character such that you don't need to index the same character more than once. Your index file would then look like--

s//[s char]
// [newline char] //[space char]

--the job of your compress file is simply to have a number (or a key) match with a value and for a given position of the cursor the appropriate amount of values will be placed in appending order from the cursor's location.

The only down-side to this technique is that if you have too many individual data values in your file (that are non-recurring or not consecutive), you may face an expansion instead of a compression when you try to compress the file.

This is just a theory, but hopefully it helps.

-Alex
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 949
Reputation: MosaicFuneral is just really nice MosaicFuneral is just really nice MosaicFuneral is just really nice MosaicFuneral is just really nice MosaicFuneral is just really nice 
Solved Threads: 92
MosaicFuneral's Avatar
MosaicFuneral MosaicFuneral is offline Offline
Posting Shark

Re: Need sample code for Text File Compression!!!

 
0
  #5
Nov 26th, 2008
In the case the you only had to use ASCII values 32-126, you then could share a single byte for two values. You could even use a truth table that points out the positions of a nibble that is really its opposite extended version 128-255.
"Jedenfalls bin ich überzeugt, daß der Alte nicht würfelt."
"I became very sensitive to what will happen to all this and all of us." -Two geniuses named Albert
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 4
Reputation: SlayerX is an unknown quantity at this point 
Solved Threads: 0
SlayerX SlayerX is offline Offline
Newbie Poster

Re: Need sample code for Text File Compression!!!

 
-1
  #6
Nov 27th, 2008
oh..thx guys.....but i still cant do it....need some beginning codes...as u know im still beginner....well..hope u can help me thx!!
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 670
Reputation: Freaky_Chris is a jewel in the rough Freaky_Chris is a jewel in the rough Freaky_Chris is a jewel in the rough 
Solved Threads: 113
Freaky_Chris's Avatar
Freaky_Chris Freaky_Chris is offline Offline
Practically a Master Poster

Re: Need sample code for Text File Compression!!!

 
0
  #7
Nov 27th, 2008
Originally Posted by SlayerX View Post
oh..thx guys.....but i still cant do it....need some beginning codes...as u know im still beginner....well..hope u can help me thx!!
You are NOT going to get a code solution. Either give in trying or post what you think you should be doing in words, pseudo-code or some method of displaying what you think you have to do. Then we can help you from there.

@everyone else
Hmm this makes interesting reading thanks

Chris
Knowledge is power -- But experience is everything
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 5,850
Reputation: Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute 
Solved Threads: 749
Team Colleague
Salem's Avatar
Salem Salem is offline Offline
Void main'ers are DOOMed

Re: Need sample code for Text File Compression!!!

 
1
  #8
Nov 27th, 2008
Get nice and comfortable, this is a long read
http://www.faqs.org/faqs/compression-faq/
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 4
Reputation: SlayerX is an unknown quantity at this point 
Solved Threads: 0
SlayerX SlayerX is offline Offline
Newbie Poster

Re: Need sample code for Text File Compression!!!

 
0
  #9
Nov 28th, 2008
If i know how to do...do u think i will post here??...jus giv me a starting point......i really dont know how to do only post here...
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 5,850
Reputation: Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute 
Solved Threads: 749
Team Colleague
Salem's Avatar
Salem Salem is offline Offline
Void main'ers are DOOMed

Re: Need sample code for Text File Compression!!!

 
1
  #10
Nov 29th, 2008
Tell me, can you even write a program to copy a file one character at a time?

Or write a program which can say count the number of 'a' characters in a file?

Or even produce a histogram showing the distribution of letters in a file?
See, having done this, you're half-way there to fulfilling one of your program requirements.

Because the same old plz help, gimme the codez refrain isn't doing you any favours at all.

a) we're not going to give you the complete answer
b) we're not going to give you much help until YOU post some code. When you post code, we know where to start with the explanations.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC