Join 3,363 readers in helping fund MetaFilter (Hide)

Help Me Automatically Shorten Status Updates for Facebook/Twitter Updates ...
July 26, 2010 8:37 AM   Subscribe

I'm seeking to write a shell script (probably using sed) that will be given some text and will abbreviate it for me. I've no need to reinvent the wheel, if such a shell script already exists. More inside.

I'm a wordy sort (although I've improved), and so it's easy for me when writing a Facebook status update to go far over the 420-character limit -- God help me if I have to write a tweet. As with anything I find myself routinely repeating time after time, it occurred to me the other day that a shell script should be able to make the kind of shortenings I put my words through automatically. I can pipe in the clipboard's contents into the shell script using pbpaste, and once changed put it back in there using pbcopy.

What I'm seeking from you are (a) ideas for shortenings I can apply within the script -- but, ideally, things that don't wind up with it looking too incomprehensibly l33t-awful; (b) any little "caches of abbreviations" one might find within the source code of websites, programs, etc. with a similar purpose; and/or (c) if such a shell script already exists, I'd appreciate linkage -- as I say above, no need to reinvent the wheel.
posted by WCityMike to Computers & Internet (6 answers total)
You could create a new dictionary in MS Word, and then use Word's autocorrect features to shorten on the fly when you type in your status.
posted by inigo2 at 9:00 AM on July 26, 2010

This is going to be way too l33t-awful for you but anyway ...

I came up with an algorithm many years ago to "compress" messages so that could fit into the 160 character limit of an SMS. The rules were simple, for each word remove every single vowel unless:

1. The word started or ended in a vowel, in which case keep it.
2. There were two or more vowels in succession, in which case keep all of them.

Therefore the sentence "the quick brown fox jumps over a lazy dog" would be compressed to "the quick brwn fx jmps ovr a lzy dg".

I cmpltly agree tht it's nt the bst algrthm in the wrld, bt you my be able to use it to cme up wth smthng bttr.

(Looking back at it now, I think I'd add a third rule about not compressing any word under 4 characters long)
posted by mr_silver at 9:25 AM on July 26, 2010

Tweetdeck has built-in functionality to shrink text and will post to FB and Twitter for you.
posted by msbutah at 11:04 AM on July 26, 2010

You could also use some strange unicode characters (though you lose some legibility): vacuum becomes vacɯm for one less letter; operate becomes ȹerate; abseils becomes abseiʪ; alloy becomes allѹ. If you don't mind an odd-looking capital then abductors becomes abducto₨ and accepts becomes acce₧.

Apologies to anyone with a browser that doesn't properly render this comment.
posted by alby at 12:03 PM on July 26, 2010

Text::Squeeze for Perl.
You can use this module e.g. to preprocess text before it is sent to electronic media that has some maximum text size limit. For example pagers have an arbitrary text size limit, typically around 200 characters, which you want to fill as much as possible. Alternatively you may have GSM cellular phone which is capable of receiving Short Messages (SMS), whose message size limit is 160 characters. For demonstration of this module's SqueezeText() function, this paragraph's conversion result is presented below. See yourself if it's readable (Yes, it takes some time to get used to). The compression ratio is typically 30-40%

u _n use thi mod e.g. to prprce txt bfre i_s snt to
elrnic mda has som max txt siz lim. f_xmple pag
hv abitry txt siz lim, tpcly 200 chr, W/ u wnt
to fll as mch as psbleAlternatvly u may hv GSM cllar P8
w_s cpble of rcivng Short msg (SMS), WS/ msg siz
lim is 160 chr. 4 demonstrton of thi mods SquezText
fnc , dsc txt of thi prgra has ben cnvd_ blow
See uself if i_s redble (Yes, it tak som T to get usdto
compr rat is tpcly 30-40

And if $SQZ_OPTIMIZE_LEVEL is set to non-zero

posted by zengargoyle at 12:06 PM on July 26, 2010 [1 favorite]

If you're just looking for sed syntax then it's pretty straightforward:

sed -e 's,because,b/c,g' -e 's,regarding,Re:,g' -e 's,information,info,g' ...
posted by Rhomboid at 1:34 PM on July 26, 2010

« Older How to find a good nutritionis...   |  What can we do in Atlanta, GA ... Newer »
This thread is closed to new comments.