A small Groovy script for “cleaning” your Delicious bookmarks

This is a quick-and-dirty Groovy scriptlet I created yesterday to transform all my delicious tags to lowercase:

Now someone should “dash-separatize” all my compound keywords! Duh!

  • http://myopendraft.blogspot.com/ Alireza Haghighatkhah

    Nice post, Keep on Groovying ;-)

  • Anon

    You’re doing a linear scan to check for uppercase, then another linear scan to split the tags, then another linear scan to convert each tag to lower case one at a time, then another linear scan to join the tags back into a single string, plus you build several intermediate lists that I don’t see any benefit from.

    What’s wrong with just calling toLowerCase on the original tag string?

    posts.eachWithIndex { p, i ->
    println (i+1) + “/” + posts.size()
    d.addPost(p.href, p.description, p.extended, p.tag.toLowerCase(), null, false, p.shared)
    }

    More efficient, more concise, more clear about what you’re actually trying to do.

  • http://www.behrang.org/ Behrang

    You’re right. However the bottleneck in this case is communicating with delicious and changing the code like you suggest won’t have a tangible effect on the performance.

    Besides, I initially wanted to add logic for dash-separatzing compound keywords and this requires considering multiple cases. For example, ideally IBM, an abbreviation, should be transformed to ibm, but AnalyticalEngine should be transformed to analytical-engine. So I had code to check if a keyword needs dash-separatization or not.

    However in the end I didn’t add this logic to the code, because, again, for example, I didn’t want JavaServerPages to be transformed into j-s-p.

  • http://www.behrang.org/ Behrang

    Cheers bro!