I See Dead Code

… as sounding brass, or a tinkling cymbal.

I See Dead Code header image 4

Entries Tagged as 'python'

Infrequently Asked Linguistics Questions (IALQ), No. 1

Dezember 11th, 2011 · 1 Comment

Q: “How many constituent trees fit on a single A0 poster in style?” A: “886”

[Read more →]

Tags: coli · lang:en · python · treealigner · uni

Breaking Event Cycles

Juli 12th, 2009 · No Comments

A recurring problem in (not only) GUI programming are event cycles, i.e. the receiving of events oneself has triggered. These can quickly lead to event cycles, where change triggers change triggers change, until something gives out—usually the stack. A particularly cheap way of breaking cycles are simple boolean flags: class Foo(object): listen = True def [...]

[Read more →]

Tags: python

Scrollable Widgets with PyGTK

Mai 17th, 2009 · No Comments

It is possible to write custom GTK widgets that have “native” scrolling support, as opposed to just shoving them into a GtkViewPort and forgetting about them. Apart from having mastered a small coding challenge, as it turned out to be, this also gives you greater control over the scrolling itself, like making sure that certain [...]

[Read more →]

Tags: lang:en · programming · python

I have no life and I must program

Mai 31st, 2008 · No Comments

Some participants of this semester’s „Computational Linguistics” course (which is a code word for „10 different lecturers guide you through the wonderful world of algorithms and theoretical foundations of CoLi”) obviously lack a life and willfully extended their own homework assignment, writing small toolkits for finite state automata. Surprisingly, all those toolkits were written in [...]

[Read more →]

Tags: coli · lang:en · programming · python

Look at me, I know Functional Programming!

Mai 5th, 2008 · 1 Comment

Sometimes I wonder what the hell I might have been thinking while writing code like this1 : 1 2 3 4 5 6 7 def uncurry(f): return lambda t: f(*t)   def longest_common_prefix(Sa, Sb): return len(list( takewhile(uncurry(eq), izip(Sa, Sb)))) I bet the tenses are all wrong again. [↩]

[Read more →]

Tags: lang:en · programming · python

Random Python unittesting snippet #1

Dezember 18th, 2007 · No Comments

A small context manager for stating assertions about exceptions in Python unit tests: @contextmanager def assert_raises(*exc_types): """A context to ensure that an exception of a given type is thrown.   Instead of   @nose.tools.raises(ValueError) def test_that_raises(): # … lengthy setup raise ValueError   you can write   def test_that_raises_at_the_end(): # … lengthy setup with assert_raises(ValueError): [...]

[Read more →]

Tags: lang:en · programming · python

Stockholm TreeAligner 0.8 „Gamla Stan” released

Dezember 13th, 2007 · No Comments

It’s only a couple of months late, but we’ve just released a new version of the Stockholm TreeAligner to an awed audience. This release features the prototype implementations of TIGERSearch and alignment queries, which will be perfected in the next release, due in March 2008. For those who are wondering what kind of code name [...]

[Read more →]

Tags: coli · lang:en · programming · python · treealigner

Truth itself

Dezember 8th, 2007 · No Comments

As is the way with Python, it turns out that you can create the start of something useful in less that fifty lines of code.↪ I simply cannot confirm often enough how true that is.

[Read more →]

Tags: lang:en · python

TLT 2007

Dezember 6th, 2007 · No Comments

Es ist soweit, und die ganze Welt der Baumdatenbanken bekommt einen Geschmack vom Stockholm TreeAligner. Joakim wird morgen ein Poster über das „Gamla Stan”-Release von STA präsentieren (Paper). Nachdem das Release nur ein paar Monate verspätet war, machen wir uns auch gerade daran, die technische Basis mit ein paar gezielten geradezurücken. Die Hauptattraktionen für das [...]

[Read more →]

Tags: coli · lang:de · projects · python

I have two cores, where’s my free lunch?

August 26th, 2007 · No Comments

I have tried to optimize the TigerXML parser in STA [↪] a bit, the results (graphs are stored in memory, with a 55 MiB corpus, on my Core 2 Duo 2.2GHz): unoptimized: 61.01s optimized: 39.68s That still seemed a bit too slow to me, and I decided to try out some parallelization: since the ID [...]

[Read more →]

Tags: lang:en · programming · python · tech