web analytics

Stalled and Distracted

Not much visible progress in the last several weeks. I’ve been off wandering in the world of Python software development with forays into the Twitter API,  using sockets for inter-process communication, and a dozen other fascinating areas. Lots of new code written. Almost all the old code seems broken in some way or other.

So, it’s time to take stock of where we are on this journey. To that end, I’m going to  try and document the bits that I have, and the challenges as I see them now. The bits will be in the order I think of them, so probably won’t make sense.

1. SemNet

This bit started life as code I found here that “defined several simple classes for building and using semantic networks.” It defined three classes: Entity, Relation, and Fact. It allows statements like these:

>>> animal = Entity("animal")
>>> fish = Entity("fish")
>>> trout = Entity("trout")

>>> isa = Relation("is-a",True)

>>> Fact(fish, isa, animal)
>>> Fact(trout, isa, fish)

Having defined these variables, statements like this were easy:

>>> print "trout is a fish?", isa(trout,fish)
trout is a fish? True
>>> print "trout is an animal?", isa(trout,animal)
trout is an animal? True

The trouble came when I tried to persist the relations to a file. It turns out that the “Entity” object is storing the “isa” object in its list of known facts (actor-relation-object). Of course when the entity object is reloaded from disk, the relation object is a different object than the signature that was stored, so things come unraveled.

That has lead me into trying to figure out how to persist and recreate objects without losing the network relationships. I suspect there is an easy pattern for this sort of thing, but I’m not a skilled enough programmer to see it immediately.

More adventures will follow…