simple string compression?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Chris LaJoie

    #1

    simple string compression?

    I'm looking for some kind of simple string compression code I can use. I'm
    not looking for SharpZipLib. Their implimentation spans several classes and
    is very complex. I'm just looking for something simple. A single class,
    preferrably. Does such a thing exist? Thanks,

    Chris


  • Fergus Cooney

    #2
    Re: simple string compression?

    Hi Chris,

    What kind of strings are you talking about here? What's in them and how
    long are they? What strength of compression do you want? (yes, ideally down to
    1 byte, lol, but what would be reasonable)

    Regards,
    Fergus

    || I'm looking for some kind of simple string compression code I can
    || use. I'm not looking for SharpZipLib. Their implimentation spans
    || several classes and is very complex. I'm just looking for something
    || simple. A single class, preferrably. Does such a thing exist?
    || Thanks,
    || Chris



    Comment

    • Fergus Cooney

      #3
      Re: simple string compression?

      Hi Chris,

      What kind of strings are you talking about here? What's in them and how
      long are they? What strength of compression do you want? (yes, ideally down to
      1 byte, lol, but what would be reasonable)

      Regards,
      Fergus

      || I'm looking for some kind of simple string compression code I can
      || use. I'm not looking for SharpZipLib. Their implimentation spans
      || several classes and is very complex. I'm just looking for something
      || simple. A single class, preferrably. Does such a thing exist?
      || Thanks,
      || Chris



      Comment

      • Chris LaJoie

        #4
        Re: simple string compression?

        the files being compressed will be about 300 to 600k. The files are plain
        text, and consist mostly of spaces, so they compress extremely well. I just
        tried one, normal zip compression brought the file from 599,111 to 54,337
        bytes. That's 9% of the original file size. I'm looking for something
        (anything) that compresses the text by at least 50%.

        Chris

        "Fergus Cooney" <filter-1@tesco.net> wrote in message
        news:uo%23HeB5i DHA.1808@TK2MSF TNGP09.phx.gbl. ..[color=blue]
        > Hi Chris,
        >
        > What kind of strings are you talking about here? What's in them and[/color]
        how[color=blue]
        > long are they? What strength of compression do you want? (yes, ideally[/color]
        down to[color=blue]
        > 1 byte, lol, but what would be reasonable)
        >
        > Regards,
        > Fergus
        >
        > || I'm looking for some kind of simple string compression code I can
        > || use. I'm not looking for SharpZipLib. Their implimentation spans
        > || several classes and is very complex. I'm just looking for[/color]
        something[color=blue]
        > || simple. A single class, preferrably. Does such a thing exist?
        > || Thanks,
        > || Chris
        >
        >
        >[/color]


        Comment

        • Chris LaJoie

          #5
          Re: simple string compression?

          the files being compressed will be about 300 to 600k. The files are plain
          text, and consist mostly of spaces, so they compress extremely well. I just
          tried one, normal zip compression brought the file from 599,111 to 54,337
          bytes. That's 9% of the original file size. I'm looking for something
          (anything) that compresses the text by at least 50%.

          Chris

          "Fergus Cooney" <filter-1@tesco.net> wrote in message
          news:uo%23HeB5i DHA.1808@TK2MSF TNGP09.phx.gbl. ..[color=blue]
          > Hi Chris,
          >
          > What kind of strings are you talking about here? What's in them and[/color]
          how[color=blue]
          > long are they? What strength of compression do you want? (yes, ideally[/color]
          down to[color=blue]
          > 1 byte, lol, but what would be reasonable)
          >
          > Regards,
          > Fergus
          >
          > || I'm looking for some kind of simple string compression code I can
          > || use. I'm not looking for SharpZipLib. Their implimentation spans
          > || several classes and is very complex. I'm just looking for[/color]
          something[color=blue]
          > || simple. A single class, preferrably. Does such a thing exist?
          > || Thanks,
          > || Chris
          >
          >
          >[/color]


          Comment

          • Jon Skeet [C# MVP]

            #6
            Re: simple string compression?

            Chris LaJoie <chris@etriptra der.com> wrote:[color=blue]
            > the files being compressed will be about 300 to 600k. The files are plain
            > text, and consist mostly of spaces, so they compress extremely well. I just
            > tried one, normal zip compression brought the file from 599,111 to 54,337
            > bytes. That's 9% of the original file size. I'm looking for something
            > (anything) that compresses the text by at least 50%.[/color]

            Could you say exactly why it matters that SharpZipLib is several
            classes? The reason that's important might constrain other solutions.
            Do you have a sample file that you could put on a website somewhere for
            us to test potential solutions?

            --
            Jon Skeet - <skeet@pobox.co m>
            Pobox has been discontinued as a separate service, and all existing customers moved to the Fastmail platform.

            If replying to the group, please do not mail me too

            Comment

            • Jon Skeet [C# MVP]

              #7
              Re: simple string compression?

              Chris LaJoie <chris@etriptra der.com> wrote:[color=blue]
              > the files being compressed will be about 300 to 600k. The files are plain
              > text, and consist mostly of spaces, so they compress extremely well. I just
              > tried one, normal zip compression brought the file from 599,111 to 54,337
              > bytes. That's 9% of the original file size. I'm looking for something
              > (anything) that compresses the text by at least 50%.[/color]

              Could you say exactly why it matters that SharpZipLib is several
              classes? The reason that's important might constrain other solutions.
              Do you have a sample file that you could put on a website somewhere for
              us to test potential solutions?

              --
              Jon Skeet - <skeet@pobox.co m>
              Pobox has been discontinued as a separate service, and all existing customers moved to the Fastmail platform.

              If replying to the group, please do not mail me too

              Comment

              • Fergus Cooney

                #8
                Re: simple string compression?

                Hi Chris,

                If over 50% of the file is spaces, run-length-encoding is an extremely
                simple method (ie. you could do it in a single method, let alone a single
                class!).

                The files also sound as if they would be amenable to Huffman coding. This
                is more complicated but still pretty straightforward .

                Would you like further help with this?

                Regards,
                Fergus


                Comment

                • Fergus Cooney

                  #9
                  Re: simple string compression?

                  Hi Jon,

                  || Do you have a sample file that you could put on a
                  || website somewhere for us to test potential solutions?

                  Yes, a few of your files in a zip for us to play with! :-)

                  Regards,
                  Fergus


                  Comment

                  • Chris LaJoie

                    #10
                    Re: simple string compression?

                    Here is the file I'm using to test:


                    Also, I found exactly what I was looking for here:


                    the compressed text was 42% of the original size. Not good, but it will do.

                    Chris

                    "Fergus Cooney" <filter-1@tesco.net> wrote in message
                    news:uKiLTtAjDH A.1672@TK2MSFTN GP09.phx.gbl...[color=blue]
                    > Hi Jon,
                    >
                    > || Do you have a sample file that you could put on a
                    > || website somewhere for us to test potential solutions?
                    >
                    > Yes, a few of your files in a zip for us to play with! :-)
                    >
                    > Regards,
                    > Fergus
                    >
                    >[/color]


                    Comment

                    • Fergus Cooney

                      #11
                      Re: simple string compression?

                      Hi Chris,



                      The link seems to download a blank file. :-(

                      Regards,
                      Fergus


                      Comment

                      • Jon Skeet [C# MVP]

                        #12
                        Re: simple string compression?

                        Fergus Cooney <filter-1@tesco.net> wrote:[color=blue]
                        > If over 50% of the file is spaces, run-length-encoding is an extremely
                        > simple method (ie. you could do it in a single method, let alone a single
                        > class!).
                        >
                        > The files also sound as if they would be amenable to Huffman coding. This
                        > is more complicated but still pretty straightforward .
                        >
                        > Would you like further help with this?[/color]

                        I've been thinking about this a bit, and I reckon it would be quite
                        interesting as it's *text only* to work it out as a
                        System.Text.Enc oding class - that way it would be really simple to use,
                        for one thing.

                        Of course, if we knew the type of text which would need to be encoded,
                        that would help - if it were all ASCII, for instance, that increases
                        the options somewhat. (As a *very* simple example, you could store any
                        non-single spaces as a byte with the top bit set and the rest of the
                        byte being the number of spaces (2-129 encoded as 0-127) and that would
                        do quite nicely.)

                        --
                        Jon Skeet - <skeet@pobox.co m>
                        Pobox has been discontinued as a separate service, and all existing customers moved to the Fastmail platform.

                        If replying to the group, please do not mail me too

                        Comment

                        • Jon Skeet [C# MVP]

                          #13
                          Re: simple string compression?

                          Chris LaJoie <chris@etriptra der.com> wrote:[color=blue]
                          > Here is the file I'm using to test:
                          > http://www.etriptrader.com/ual/remot...sep/ORDATD.300[/color]

                          Like Fergus, I couldn't get any useful data out of that.
                          [color=blue]
                          > Also, I found exactly what I was looking for here:
                          > http://www.chipstips.info/showtopic.asp?topic=cshacc
                          >
                          > the compressed text was 42% of the original size. Not good, but it will do.[/color]

                          Interesting that it returns it as a string - I'd anticipated that you'd
                          want it converting to a byte array. (One thing that's nasty about the
                          above is that it seems to believe that ASCII is 8 bit rather than 7 bit
                          - I don't believe it *is* actually compatible in environments that only
                          deal with ASCII.)

                          If you're still interested in seeing whether there are ways of getting
                          it down lower than that, feel free to mail me a couple of sample files
                          directly - if you only need the compressor to be able to compress real
                          ASCII, I'll try the scheme I proposed in my last post, just to see how
                          it does.

                          --
                          Jon Skeet - <skeet@pobox.co m>
                          Pobox has been discontinued as a separate service, and all existing customers moved to the Fastmail platform.

                          If replying to the group, please do not mail me too

                          Comment

                          • Chris LaJoie

                            #14
                            Re: simple string compression?

                            > Like Fergus, I couldn't get any useful data out of that.

                            My appologies, the link now works.
                            [color=blue]
                            > If you're still interested in seeing whether there are ways of getting
                            > it down lower than that, feel free to mail me a couple of sample files
                            > directly - if you only need the compressor to be able to compress real
                            > ASCII, I'll try the scheme I proposed in my last post, just to see how
                            > it does.[/color]

                            Sure, if you think you can, I'd certainly be interrested in seeing what you
                            come up with. Even if it doesn't produce better compression ratios.
                            Thanks,

                            Chris


                            Comment

                            • Jon Skeet [C# MVP]

                              #15
                              Re: simple string compression?

                              Chris LaJoie <chris@etriptra der.com> wrote:[color=blue][color=green]
                              > > Like Fergus, I couldn't get any useful data out of that.[/color]
                              >
                              > My appologies, the link now works.
                              >[color=green]
                              > > If you're still interested in seeing whether there are ways of getting
                              > > it down lower than that, feel free to mail me a couple of sample files
                              > > directly - if you only need the compressor to be able to compress real
                              > > ASCII, I'll try the scheme I proposed in my last post, just to see how
                              > > it does.[/color]
                              >
                              > Sure, if you think you can, I'd certainly be interrested in seeing what you
                              > come up with. Even if it doesn't produce better compression ratios.[/color]

                              Well, using my "space saver" technique got the 519,942 byte input file
                              down to 217,875 bytes - again, 42%. I suspect that getting it down
                              significantly from there would take a fair amount more work -
                              basically, writing a Huffman encoder, which is reasonably
                              straightforward (I've done it before) but not trivial, and not
                              something I fancy doing at half four in the morning :)

                              --
                              Jon Skeet - <skeet@pobox.co m>
                              Pobox has been discontinued as a separate service, and all existing customers moved to the Fastmail platform.

                              If replying to the group, please do not mail me too

                              Comment

                              Working...