Category Archives: Coding
Python unicode doctest howto in a doctest
Another thing which has been on my stack for quite a while has been a unicode doctest howto, as I remember I was quite lost when I first tried to test encoding stuff in a doctest. So I thought the … Continue reading
How to restrict the length of a unicode string
Ha, not with me! It’s a pretty common tripwire: Imagine you have a unicode string and for whatever reason (which should be a good reason, so make sure you really need this) you need to make sure that its UTF-8 … Continue reading
Setting up a local DBpedia mirror with Virtuoso
So you’re the guy who is allowed to setup a local DBpedia mirror for your work group? OK, today is your lucky day and you’re in the right place. I hope you’ll be able to benefit from my hours of trials and errors
Continue reading
How to convert hex strings to binary ascii strings in python (incl. 8bit space)
As this comes across may way again and again: How do you turn a hex string like "c3a4c3b6c3bc" into a nice binary string like this: "11000011 10100100 11000011 10110110 11000011 10111100"? The solution is based on the Python 2.6 new … Continue reading
Bash prompt indicating return value
Lately I’ve fiddled a lot with installing virtuoso on some virtual machines and found myself repeatedly asking bash for the return value of the last command echo $?. I remembered this blog post by Gecko quite a while ago and … Continue reading
WTFPL
Thanks to Ralf I came across this really nice license today. If you’ve ever been lost in the licensing jungle of any software, you’ll understand: The WTFPL (Homepage includes a nice FAQ section as well ): … Continue reading
(URL)Encoding in python
Well, encodings are a never ending story and whenever you don’t want to waste time on them, it’s for sure that you’ll stumble over yet another tripwire. This time it is the encoding of URLs (note: even though related I’m … Continue reading
Itertools
Just recently came across the python itertools “tools for efficient looping” again. Generators have the advantage of not creating the whole list on definition, but on demand (in contrast to e.g., list comprehensions). Really worth a look: import itertools as … Continue reading
Precision-Recall diagrams including the F-Measure
Today I was asked how to generate Recall-Precision diagrams including the f-measure values as height-lines from within python. Actually Gunnar was the one who had this idea quite a while ago, but constantly writing things into files, then loading them … Continue reading
Sort python dictionaries by values
Perhaps you already encountered a problem like the following one yourself: You have a large list of items (let’s say URIs for this example) and want to sum up how often they were viewed (or edited or… whatever). A small … Continue reading