[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[computer-go] SGF parsers



Before starting my experiment with automatic pattern generation for tactics
I have to think about making a good test-bed. For this I probably need
something to make test-positions, write them out to file (or database) and
be able to read them back in again. In the past I used the Ishi Press format
for these things, but I think SGF has become adapted as a kind of standard
over the past years.

Since I didn't feel like writing an SGF parser myself, I had a quick look at
what Java implementations are available at SourceForge. There are a few...
but looking at one (forgot which one) I soon realised that these probably
all create their own internal data-structures. Since I already have a good
tree data structure (based on the the Swing TreeModel with minimal extra
work) I don't feel like switching to someone elses just for the sake of SGF
parsing.

Then I realised that what would be a good solution is an SGF parser that
creates a DOM document (as defined by W3C). Parsing a DOM-tree and convert
it to my TreeModel is helluva lot easier than parsing SGF. All it would take
is consensus to what the Element tag-names and their attributes are going to
be. This is already part of some ongoing effort to create an XML standard
for SGF, but it's not clear to me what the status of that currently is. Does
anybody know?

There are several advantages to such an approach. First, the SGF parser
really needs to be made only once and will then be universally useful.
Second, once the XML definitions are agreed upon, the laziest solution to
parse them is to use an existing XML library like Xerces to create the
DOM-tree from XML. That way SGF can be used when space is an issue, as it's
more compact, and XML can be used for other purposes.

I made a quick-and-dirty implementation to try this idea out, but it only
parses the moves. It ignores everything else. It seems to work fine and
converting this DOM document into my TreeModel is just half a page of code.
So I'm hoping someone else had the same idea and that there already exists a
more extensive SGF parser that creates a DOM-tree, as making a full SGF
reader seems like a considerable amount of work.

P.S. In my search for definitions of SGF, I came upon an example with merged
games. That seems to unnecessarily complicate things, is it widely used?

_______________________________________________
computer-go mailing list
computer-go@xxxxxxxxxxxxxxxxx
http://www.computer-go.org/mailman/listinfo/computer-go/