musings of a Lispnik

blog index | homepage | RSS

Sun, 29 Jun 2008

cl-morfeusz: A ninety minutes’ hack

Here’s what I came up with today, after no more than 90 minutes of coding (complete with comments and all):

MORFEUSZ> (morfeusz-analyse "zażółć gęślą jaźń")
((0 1 "zażółć" "zażółcić" "impt:sg:sec:perf")
 (1 2 "gęślą" "gęśl" "subst:sg:inst:f")
 (2 3 "jaźń" "jaźń" "subst:sg:nom.acc:f"))

This is cl-morfeusz in action, a Common Lisp interface to Morfeusz, the morphological analyser for Polish.

It’s a single Lisp file, so there’s no ASDF system definition or asdf-installability for now. I’m not putting it under version control, either. Or, should I say, not yet. When I get around to it, I plan to write a simple parser and write a Polish-language version of the text adventure that started it all.

Meanwhile, you may use cl-morfeusz for anything you wish (of course, as long as you comply with Morfeusz’s license). Have fun!

Update 2010-Jan-17: With the advent of UTF-8 support in CFFI, the ugly workarounds in the code are probably no longer necessary; I don’t have time to check it right now, though.

permanent link | comments

Mon, 23 Jun 2008

You win some, you lose some, you talk some

After my shameful performance in the previous tournament, this weekend saw my greatest achievement in tournament Scrabble to date: that of advancing to the quarterfinals of the Cup of Poland. For the record, here are the final standings. In the quarterfinal, I lost both games to Tomasz Zwoliński (the former Champion of Poland), who went on to win the Cup.

On Thursday, I will be delivering a presentation about the dark side of programming: error handling and how to cope up with Murphy’s law. The talk will last around 30 minutes and be held within TechAula, a place to hear about exciting and revolutionary technologies in software engineering. Feel invited to register and show up.

(Postscriptum 11 July: By public demand, the slides from my talk are now available for download.)

permanent link | comments

Thu, 19 Jun 2008

Another metapost

No, I am not going to write about the programming language for generating vector graphics. This is not a real post, but rather a note to self to write ones on certain topics once I get ready for that. And as for today’s title, I just couldn’t resist the pun. ;-)

I’ve been rewriting the Poliqarp Java (GUI) client for the last two weeks or so. The point is to convert it to use the new protocol, and to take the opportunity of turning a messy, kludgey and bit-rotting pile of code into a neatly decoupled, cleanly designed, robust and comprehensible utility. And the further I get, the more I see how much it’s worth it. I strongly believe that at the end of this path, upon remergence with the mainline, Poliqarp will become better than ever before.

Thus, when I have something to show (I hope to deliver a preliminary working version, though not yet feature-complete, within the upcoming week or so), I will probably brag about the design solutions I’ve taken. While I’m at it, I will possibly also write the long-delayed description of the new build system.

If there is anybody out there besides me who actually cares for that, stay tuned!

permanent link | comments

Wed, 11 Jun 2008

Today’s lesson: Mind the symlinks

Probably every day I keep learning new things, without even realizing it most of the time. The vast majority of them are minor or even tiny tidbits of knowledge; but even these might be worth noting down from time to time, especially when they are tiny pitfalls I’d fallen into and spent a couple of minutes getting out. By sharing them, I might hopefully prevent someone else for slipping and falling in.

So here’s a simple Unix question: If you enter a subdirectory of the current directory and back to .., where will you end up? The most obvious answer is, of course, “in the original directory”, and is mostly correct. But is it always? Let’s see.

nathell@breeze:~$ pwd
/home/nathell
nathell@breeze:~$ cd foobar
nathell@breeze:~/foobar$ cd ..
nathell@breeze:~$ pwd
/home/nathell

So the hypothesis seems to be right. But let’s try doing this in Python, just for the heck of it:

nathell@breeze:~$ python
Python 2.5.2 (r252:60911, Apr 21 2008, 11:12:42) 
[GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> print os.getcwd()
/home/nathell
>>> os.chdir("foobar")
>>> os.chdir("..")
>>> print os.getcwd()
/var

Whoa, hang on! What’s that /var doing there? Of course the one thing I didn’t tell you is that foobar is not really a directory, but rather a symlink pointing to one (/var/log in this case).

The corollary is that the shell builtin cd is not the same as Unix chdir() (it is easily checked that both Perl and C exhibit the same behaviour). In fact, the shell builtin has an oft-forgotten command-line switch, -P, which causes it to follow physical instead of logical path structure.

On a closing note: I have somewhat neglected the blog throughout the previous month, but I hope to revive it soon. It is not unlikely that such irregularities will recur.

permanent link | comments