pyBlazon: Blazonry to SVG Converter

Links here are temporarily broken: Google code shut down, and the project has been moved to github; I'll update the links soon.

pyBlazon is a Python program that attempts to translate from Blazonry, the specialized terminology used for describing coats of arms (specifically shields) to Scalable Vector Graphics. In other words, this is an attempt at automatic emblazoning (drawing) of a blazon (description). pyBlazon was written by Mark Shoulson and Arnt Richard Johansen.

Blazonry has been called the first programming language, loosely speaking (maybe a markup language would be closer. Like HTML or something). But it never intended for the kind of precision required here, and was always meant to be read by readers with full Natural Language Processing abilities (i.e., people), not by a computer program trying to implement it as a proper subset of English. The line between blazonry and just plain English is not a sharp one, so be aware the program’s abilities are very limited compared to the liberties blazons commonly take.

pyBlazon is licensed under the GNU Lesser General Public License, and can be downloaded (via SVN) from the pyBlazon GoogleCode Site.

The program uses PLY, which is a Python port of the venerable LEX/YACC combo. The grammar is thus subject to some limitations, but we'll see what can be done about that. As the blazon is parsed, various blazonry objects are created and called upon each other, representing tinctures, charges, ordinaries, and so forth. The other library used is SVGdraw, which does not seem to be supported anymore, so we will include it with the pyBlazon distribution (the license appears to permit this). SVGdraw is a fairly simple library that just makes building SVG files a bit easier.

Use the online pyBlazon server to convert blazons into graphics

See the Googlecode pyBlazon Site

News

The SVN log of the project will show the checkin messages as changes are made to the code, but more usefully...

1 May 2008

Merged a “branch” version I had been working on back into the trunk: I think I don't yet properly appreciate when I should really be dealing with branches. The new one, now uploaded to the server, uses a different method of lexing, which gives more flexibility, and also added a question-mark charge to be used whenever someone gives a charge that the program does not know about. This should lead to fewer unenlightening “error” pages.

Also, finally announcing the pyBlazon GoogleCode repository for all your pyBlazon needs. You can check out the source code from there (yay!), add your comments to the wiki, track issues that I'll ignore, etc.

14 March 2008
Pursuant to bug report #422599 reported on Mozilla Firefox, which someone else filed after having trouble seeing the SVG code generated by pyBlazon, I’ve corrected all the SVG errors. I had run the output through a validator, but that was a while ago and also there are errors that validators don’t catch. I may backtrack on some that apparently did not need to be fixed, but things do seem to be working better on Opera, at any rate.

pyBlazon’s Grammar

The full grammar understood by pyBlazon is in its plyyacc.py file, contained in the __doc__ strings of the functions, as required by the PLY package. Here is a link to a printout of the current grammar, and here is one for the lexical elements. But it is probably more helpful to have a simplified description. I am replacing the almost-formal informal grammar that used to be here with something much shorter and more example-oriented; maybe that will be helpful. Note that punctuation, in general, is stripped out and ignored, so don’t go worrying about where to put commas: they do not need to be anywhere.

View SVN Changelog

Known Issues

Just from looking at the grammar you can see some potential problems with commonly-used constructions. This isn't an exhaustive list, though I'm working on it. I'm sure you'll find plenty of perfectly normal blazons that don't work: remember, blazons were intended for humans, whose English is much better than the program's.

This section prone to fast out-of-dateness.

See also Hacks.