Message Boards Message Boards

4 Replies
5 Total Likes
View groups...
Share this post:

Is it possible to use Wolfram|Alpha to compress a text string?

Is it possible to use Wolfram|Alpha to compress a text string so that you could use the string in a tweet and thereby circumvent the 140 charcter limit.  In order for this to be useful, it would have to be necessary for the recipient to be able to uncompress the string with with Wolfram|Alpha.  (please delete this question - I see why it's not possible.  Thanks, George Wolfe)
POSTED BY: George Wolfe
4 Replies
From running a few tests on W|A it appears not. 

But the additional question is whether it'd be worth it.  Use something like this to experiment with this problem. 

 Framed@DynamicModule[{text = "", compressed},
    TextCell["Type Text here \[DownArrow]", "Text"],
    InputField[Dynamic[text], String, ContinuousAction -> True,
     FieldSize -> {30, 5}],
     Row[{"Compressed Version:\n ",
       Dynamic[compressed = Compress@text]}], "Text"],
    Row[{"Original Text Length: ", Dynamic[StringLength[text]]}],
    Row[{"Compressed Text Length: ",
      Dynamic[StringLength[compressed]]}], "Text"],
    Row[{"Useful?: ",
      Dynamic[StringLength[compressed] < StringLength[text]]}], "Text"]
  Alignment -> Left]

But a quick exploration of one of the works of Jane Austin suggests that it is not worth one's while...
janeAustin =

tweets = StringJoin /@ Partition[Characters[janeAustin], 140];

Histogram[StringLength[Compress[#]] & /@ tweets, Frame -> True]

POSTED BY: David Reiss
P.S.  I didn't notice your comment about deleting the quesiton!  But perhaps it's worth keeping as an example of how in the Wolfram Language one can explore a question like this in 3 lines of code that would take dozens of lines in many other  languages...
POSTED BY: David Reiss
Thanks, David. Interesting and clever.  By testing the compression of various sentences and also non-sentence text strins with your app, it appears that normal sentences don't have enough repeated characters to take advantage of compression. Strings with repeted sequenced do.

This is a great demonstration.
POSTED BY: George Wolfe
I also think this is rather a good question and Reiss response is great - well worth keeping the thread.
POSTED BY: Sam Carrettie
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract