<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Parerga und Paralipomena</title>
	<atom:link href="http://www.michelepasin.org/techblog/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.michelepasin.org/techblog</link>
	<description>At the core of all well-founded belief lies belief that is unfounded - Wittgenstein</description>
	<lastBuildDate>Thu, 16 Feb 2012 14:12:56 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>HTML5 Canvas Cookbook</title>
		<link>http://www.michelepasin.org/techblog/2012/02/08/html5-canvas-cookbook/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=html5-canvas-cookbook</link>
		<comments>http://www.michelepasin.org/techblog/2012/02/08/html5-canvas-cookbook/#comments</comments>
		<pubDate>Wed, 08 Feb 2012 17:34:12 +0000</pubDate>
		<dc:creator>mike</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[book]]></category>
		<category><![CDATA[canvas]]></category>
		<category><![CDATA[html5]]></category>

		<guid isPermaLink="false">http://www.michelepasin.org/techblog/?p=1815</guid>
		<description><![CDATA[HTML5 Canvas Cookbook is a new publication from Packt publishing that discusses in details the new drawing functionalities the html5 canvas element makes available; in the last weeks I've been looking at this book in more details and since it's been a quite useful learning experience I wanted to mention it here too. The book [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.packtpub.com/html5-canvas-cookbook-recipes-to-revolutionize-web-experience/book">HTML5 Canvas Cookbook</a> is a new publication from Packt publishing that discusses in details the new drawing functionalities the html5 canvas element makes available; in the last weeks I've been looking at this book in more details and since it's been a quite useful learning experience I wanted to mention it here too.</p> 

<p>The book (which is <a href="http://www.packtpub.com/html5-canvas-cookbook-recipes-to-revolutionize-web-experience/book">available online here</a> )is simple and well organized; it spends quite a bit of time on both introductory topics and more advanced ones, so it'll probably fit both the beginner and the more experienced programmer. </p>

<p>Here's a list of the chapters available: </p>

<div style="height: 400px; overflow: auto;"><pre>
CHAPTER 1: GETTING STARTED WITH PATHS AND TEXT
Introduction
Drawing a line
Drawing an arc
Drawing a Quadratic curve
Drawing a Bezier curve
Drawing a zigzag
Drawing a spiral
Working with text
Drawing 3D text with shadows
Unlocking the power of fractals: Drawing a haunted tree

CHAPTER 2: SHAPE DRAWING AND COMPOSITES
Introduction
Drawing a rectangle
Drawing a circle
Working with custom shapes and fill styles
Fun with Bezier curves: drawing a cloud
Drawing transparent shapes
Working with the context state stack to save and restore styles
Working with composite operations
Creating patterns with loops: drawing a gear
Randomizing shape properties: drawing a field of flowers
Creating custom shape functions: playing card suits
Putting it all together: drawing a jet

CHAPTER 3: WORKING WITH IMAGES AND VIDEOS
Introduction
Drawing an image
Cropping an image
Copying and pasting sections of the canvas
Working with video
Getting image data
Introduction to pixel manipulation: inverting image colors
Inverting video colors
Converting image colors to grayscale
Converting a canvas drawing into a data URL
Saving a canvas drawing as an image
Loading the canvas with a data URL
Creating a pixelated image focus

CHAPTER 4: MASTERING TRANSFORMATIONS
Introduction
Translating the canvas context
Rotating the canvas context
Scaling the canvas context
Creating a mirror transform
Creating a custom transform
Shearing the canvas context
Handling multiple transforms with the state stack
Transforming a circle into an oval
Rotating an image
Drawing a simple logo and randomizing its position, rotation, and scale

CHAPTER 5: BRINGING THE CANVAS TO LIFE WITH ANIMATION
Introduction
Creating an Animation class
Creating a linear motion
Creating acceleration
Creating oscillation
Oscillating a bubble
Swinging a pendulum
Animating mechanical gears
Animating a clock
Simulating particle physics
Creating microscopic life forms
Stressing the canvas and displaying the FPS

CHAPTER 6: INTERACTING WITH THE CANVAS: ATTACHING EVENT LISTENERS TO SHAPES AND REGIONS 
Introduction
Creating an Events Class
Working With Canvas Mouse Coordinates
Attaching Mouse Event Listeners to Regions
Attaching Touch Event Listeners to Regions on a Mobile Device
Attaching Event Listeners to Images
Dragging-And-Dropping Shapes
Dragging-And-Dropping Images
Creating an Image Magnifier
Creating a Drawing Application

CHAPTER 7: CREATING GRAPHS AND CHARTS
Introduction
Creating a pie chart
Creating a bar chart
Graphing equations
Plotting data points with a line chart

CHAPTER 8: SAVING THE WORLD WITH GAME DEVELOPMENT
Introduction
Creating sprite sheets for the heroes and enemies
Creating level images and boundary maps
Creating an Actor class for the hero and enemies
Creating a Level class
Creating a Health Bar class
Creating a Controller class
Creating a Model class
Creating a View class
Setting up the HTML document and starting the game

CHAPTER 9: INTRODUCING WEBGL
Introduction
Creating a WebGL wrapper to simplify the WebGL API
Creating a triangular plane
Rotating a triangular plane in 3D space
Creating a rotating cube
Adding textures and lighting
Creating a 3D world that you can explore

</pre></div>

<p>The last chapters about animations and game developments are probably the most interesting ones, especially they all include detailed walk-through of the techniques discussed. Here's for example an example from Chapter 5, 'Oscillating a bubble': </p>


<canvas id="myCanvas" width="400" height="250" style="border:1px solid black;">
</canvas>




<script type="text/javascript">


var Animation = function(canvasId){
    this.canvas = document.getElementById(canvasId);
    this.context = this.canvas.getContext("2d");
    this.t = 0;
    this.timeInterval = 0;
    this.startTime = 0;
    this.lastTime = 0;
    this.frame = 0;
    this.animating = false;
    
    // provided by Paul Irish
    window.requestAnimFrame = (function(callback){
        return window.requestAnimationFrame ||
        window.webkitRequestAnimationFrame ||
        window.mozRequestAnimationFrame ||
        window.oRequestAnimationFrame ||
        window.msRequestAnimationFrame ||
        function(callback){
            window.setTimeout(callback, 1000 / 60);
        };
    })();
};

Animation.prototype.getContext = function(){
    return this.context;
};

Animation.prototype.getCanvas = function(){
    return this.canvas;
};

Animation.prototype.clear = function(){
    this.context.clearRect(0, 0, this.canvas.width, this.canvas.height);
};

Animation.prototype.setDrawStage = function(func){
    this.drawStage = func;
};

Animation.prototype.isAnimating = function(){
    return this.animating;
};

Animation.prototype.getFrame = function(){
    return this.frame;
};

Animation.prototype.start = function(){
    this.animating = true;
    var date = new Date();
    this.startTime = date.getTime();
    this.lastTime = this.startTime;
    
    if (this.drawStage !== undefined) {
        this.drawStage();
    }
    
    this.animationLoop();
};

Animation.prototype.stop = function(){
    this.animating = false;
};
Animation.prototype.getTimeInterval = function(){
    return this.timeInterval;
};

Animation.prototype.getTime = function(){
    return this.t;
};

Animation.prototype.getFps = function(){
    return this.timeInterval > 0 ? 1000 / this.timeInterval : 0;
};

Animation.prototype.animationLoop = function(){
    var that = this;
    
    this.frame++;
    var date = new Date();
    var thisTime = date.getTime();
    this.timeInterval = thisTime - this.lastTime;
    this.t += this.timeInterval;
    this.lastTime = thisTime;
    
    if (this.drawStage !== undefined) {
        this.drawStage();
    }
    
    if (this.animating) {
        requestAnimFrame(function(){
            that.animationLoop();
        });
    }
};



window.onload = function(){
    // instantiate new animation object
    var anim = new Animation("myCanvas");
    var context = anim.getContext();
    var canvas = anim.getCanvas();
    
    anim.setDrawStage(function(){
        // update
        var widthScale = Math.sin(this.getTime() / 200) * 0.1 + 0.9;
        var heightScale = -1 * Math.sin(this.getTime() / 200) * 0.1 + 0.9;

        // clear
        this.clear();
        
        //draw
        context.beginPath();
        context.save();
        context.translate(canvas.width / 2, canvas.height / 2);
        context.scale(widthScale, heightScale);
        context.arc(0, 0, 65, 0, 2 * Math.PI, false);
        context.restore();
        context.fillStyle = "#8ED6FF";
        context.fill();
        context.lineWidth = 2;
        context.strokeStyle = "#555";
        context.stroke();
        
        context.beginPath();
        context.save();
        context.translate(canvas.width / 2, canvas.height / 2);
        context.scale(widthScale, heightScale);
        context.arc(-30, -30, 15, 0, 2 * Math.PI, false);
        context.restore();
        context.fillStyle = "white";
        context.fill();
    });
    
    anim.start();
};

</script>



<p>&nbsp;</p>

In a nutshell, this is what is going on (note that the 'animation' library is discussed in a previous chapter of the book): 

<p>&nbsp;</p>

<pre style='color:#000020;background:#f6f8ff; overflow: auto;'><span style='color:#308080; '>&lt;</span>script src<span style='color:#308080; '>=</span><span style='color:#800000; '>"</span><span style='color:#1060b6; '>animation.js</span><span style='color:#800000; '>"</span><span style='color:#308080; '>></span><span style='color:#308080; '>&lt;</span><span style='color:#308080; '>/</span>script<span style='color:#308080; '>></span>
<span style='color:#308080; '>&lt;</span>script<span style='color:#308080; '>></span>
    window<span style='color:#308080; '>.</span>onload <span style='color:#308080; '>=</span> <span style='color:#200080; font-weight:bold; '>function</span><span style='color:#308080; '>(</span><span style='color:#308080; '>)</span><span style='color:#406080; '>{</span>
        <span style='color:#595979; '>// instantiate new animation object</span>
        <span style='color:#200080; font-weight:bold; '>var</span> anim <span style='color:#308080; '>=</span> <span style='color:#200080; font-weight:bold; '>new</span> Animation<span style='color:#308080; '>(</span><span style='color:#800000; '>"</span><span style='color:#1060b6; '>myCanvas</span><span style='color:#800000; '>"</span><span style='color:#308080; '>)</span><span style='color:#406080; '>;</span>
        <span style='color:#200080; font-weight:bold; '>var</span> context <span style='color:#308080; '>=</span> anim<span style='color:#308080; '>.</span>getContext<span style='color:#308080; '>(</span><span style='color:#308080; '>)</span><span style='color:#406080; '>;</span>
        <span style='color:#200080; font-weight:bold; '>var</span> canvas <span style='color:#308080; '>=</span> anim<span style='color:#308080; '>.</span>getCanvas<span style='color:#308080; '>(</span><span style='color:#308080; '>)</span><span style='color:#406080; '>;</span>
        
        anim<span style='color:#308080; '>.</span>setDrawStage<span style='color:#308080; '>(</span><span style='color:#200080; font-weight:bold; '>function</span><span style='color:#308080; '>(</span><span style='color:#308080; '>)</span><span style='color:#406080; '>{</span>
            <span style='color:#595979; '>// update</span>
            <span style='color:#200080; font-weight:bold; '>var</span> widthScale <span style='color:#308080; '>=</span> <span style='color:#007d45; '>Math</span><span style='color:#308080; '>.</span><span style='color:#200080; font-weight:bold; '>sin</span><span style='color:#308080; '>(</span><span style='color:#200080; font-weight:bold; '>this</span><span style='color:#308080; '>.</span><span style='color:#200080; font-weight:bold; '>getTime</span><span style='color:#308080; '>(</span><span style='color:#308080; '>)</span> <span style='color:#308080; '>/</span> <span style='color:#008c00; '>200</span><span style='color:#308080; '>)</span> <span style='color:#308080; '>*</span> <span style='color:#008000; '>0.1</span> <span style='color:#308080; '>+</span> <span style='color:#008000; '>0.9</span><span style='color:#406080; '>;</span>
            <span style='color:#200080; font-weight:bold; '>var</span> heightScale <span style='color:#308080; '>=</span> <span style='color:#308080; '>-</span><span style='color:#008c00; '>1</span> <span style='color:#308080; '>*</span> <span style='color:#007d45; '>Math</span><span style='color:#308080; '>.</span><span style='color:#200080; font-weight:bold; '>sin</span><span style='color:#308080; '>(</span><span style='color:#200080; font-weight:bold; '>this</span><span style='color:#308080; '>.</span><span style='color:#200080; font-weight:bold; '>getTime</span><span style='color:#308080; '>(</span><span style='color:#308080; '>)</span> <span style='color:#308080; '>/</span> <span style='color:#008c00; '>200</span><span style='color:#308080; '>)</span> <span style='color:#308080; '>*</span> <span style='color:#008000; '>0.1</span> <span style='color:#308080; '>+</span> <span style='color:#008000; '>0.9</span><span style='color:#406080; '>;</span>

            <span style='color:#595979; '>// clear</span>
            <span style='color:#200080; font-weight:bold; '>this</span><span style='color:#308080; '>.</span>clear<span style='color:#308080; '>(</span><span style='color:#308080; '>)</span><span style='color:#406080; '>;</span>
            
            <span style='color:#595979; '>//draw</span>
            context<span style='color:#308080; '>.</span>beginPath<span style='color:#308080; '>(</span><span style='color:#308080; '>)</span><span style='color:#406080; '>;</span>
            context<span style='color:#308080; '>.</span>save<span style='color:#308080; '>(</span><span style='color:#308080; '>)</span><span style='color:#406080; '>;</span>
            context<span style='color:#308080; '>.</span>translate<span style='color:#308080; '>(</span>canvas<span style='color:#308080; '>.</span>width <span style='color:#308080; '>/</span> <span style='color:#008c00; '>2</span><span style='color:#308080; '>,</span> canvas<span style='color:#308080; '>.</span>height <span style='color:#308080; '>/</span> <span style='color:#008c00; '>2</span><span style='color:#308080; '>)</span><span style='color:#406080; '>;</span>
            context<span style='color:#308080; '>.</span>scale<span style='color:#308080; '>(</span>widthScale<span style='color:#308080; '>,</span> heightScale<span style='color:#308080; '>)</span><span style='color:#406080; '>;</span>
            context<span style='color:#308080; '>.</span>arc<span style='color:#308080; '>(</span><span style='color:#008c00; '>0</span><span style='color:#308080; '>,</span> <span style='color:#008c00; '>0</span><span style='color:#308080; '>,</span> <span style='color:#008c00; '>65</span><span style='color:#308080; '>,</span> <span style='color:#008c00; '>0</span><span style='color:#308080; '>,</span> <span style='color:#008c00; '>2</span> <span style='color:#308080; '>*</span> <span style='color:#007d45; '>Math</span><span style='color:#308080; '>.</span>PI<span style='color:#308080; '>,</span> <span style='color:#0f4d75; '>false</span><span style='color:#308080; '>)</span><span style='color:#406080; '>;</span>
            context<span style='color:#308080; '>.</span>restore<span style='color:#308080; '>(</span><span style='color:#308080; '>)</span><span style='color:#406080; '>;</span>
            context<span style='color:#308080; '>.</span>fillStyle <span style='color:#308080; '>=</span> <span style='color:#800000; '>"</span><span style='color:#1060b6; '>#8ED6FF</span><span style='color:#800000; '>"</span><span style='color:#406080; '>;</span>
            context<span style='color:#308080; '>.</span>fill<span style='color:#308080; '>(</span><span style='color:#308080; '>)</span><span style='color:#406080; '>;</span>
            context<span style='color:#308080; '>.</span>lineWidth <span style='color:#308080; '>=</span> <span style='color:#008c00; '>2</span><span style='color:#406080; '>;</span>
            context<span style='color:#308080; '>.</span>strokeStyle <span style='color:#308080; '>=</span> <span style='color:#800000; '>"</span><span style='color:#1060b6; '>#555</span><span style='color:#800000; '>"</span><span style='color:#406080; '>;</span>
            context<span style='color:#308080; '>.</span>stroke<span style='color:#308080; '>(</span><span style='color:#308080; '>)</span><span style='color:#406080; '>;</span>
            
            context<span style='color:#308080; '>.</span>beginPath<span style='color:#308080; '>(</span><span style='color:#308080; '>)</span><span style='color:#406080; '>;</span>
            context<span style='color:#308080; '>.</span>save<span style='color:#308080; '>(</span><span style='color:#308080; '>)</span><span style='color:#406080; '>;</span>
            context<span style='color:#308080; '>.</span>translate<span style='color:#308080; '>(</span>canvas<span style='color:#308080; '>.</span>width <span style='color:#308080; '>/</span> <span style='color:#008c00; '>2</span><span style='color:#308080; '>,</span> canvas<span style='color:#308080; '>.</span>height <span style='color:#308080; '>/</span> <span style='color:#008c00; '>2</span><span style='color:#308080; '>)</span><span style='color:#406080; '>;</span>
            context<span style='color:#308080; '>.</span>scale<span style='color:#308080; '>(</span>widthScale<span style='color:#308080; '>,</span> heightScale<span style='color:#308080; '>)</span><span style='color:#406080; '>;</span>
            context<span style='color:#308080; '>.</span>arc<span style='color:#308080; '>(</span><span style='color:#308080; '>-</span><span style='color:#008c00; '>30</span><span style='color:#308080; '>,</span> <span style='color:#308080; '>-</span><span style='color:#008c00; '>30</span><span style='color:#308080; '>,</span> <span style='color:#008c00; '>15</span><span style='color:#308080; '>,</span> <span style='color:#008c00; '>0</span><span style='color:#308080; '>,</span> <span style='color:#008c00; '>2</span> <span style='color:#308080; '>*</span> <span style='color:#007d45; '>Math</span><span style='color:#308080; '>.</span>PI<span style='color:#308080; '>,</span> <span style='color:#0f4d75; '>false</span><span style='color:#308080; '>)</span><span style='color:#406080; '>;</span>
            context<span style='color:#308080; '>.</span>restore<span style='color:#308080; '>(</span><span style='color:#308080; '>)</span><span style='color:#406080; '>;</span>
            context<span style='color:#308080; '>.</span>fillStyle <span style='color:#308080; '>=</span> <span style='color:#800000; '>"</span><span style='color:#1060b6; '>white</span><span style='color:#800000; '>"</span><span style='color:#406080; '>;</span>
            context<span style='color:#308080; '>.</span>fill<span style='color:#308080; '>(</span><span style='color:#308080; '>)</span><span style='color:#406080; '>;</span>
        <span style='color:#406080; '>}</span><span style='color:#308080; '>)</span><span style='color:#406080; '>;</span>
        
        anim<span style='color:#308080; '>.</span>start<span style='color:#308080; '>(</span><span style='color:#308080; '>)</span><span style='color:#406080; '>;</span>
    <span style='color:#406080; '>}</span><span style='color:#406080; '>;</span>
<span style='color:#308080; '>&lt;</span><span style='color:#308080; '>/</span>script<span style='color:#308080; '>></span>
</pre>

<p>&nbsp;</p>

<p>All in all, a book definitely worth reading!</p>

<p>&nbsp;</p>]]></content:encoded>
			<wfw:commentRss>http://www.michelepasin.org/techblog/2012/02/08/html5-canvas-cookbook/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Setting up the new &#8216;staticfiles&#8217; app on Django 1.3</title>
		<link>http://www.michelepasin.org/techblog/2012/01/24/setting-up-the-new-staticfiles-app-on-django-1-3/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=setting-up-the-new-staticfiles-app-on-django-1-3</link>
		<comments>http://www.michelepasin.org/techblog/2012/01/24/setting-up-the-new-staticfiles-app-on-django-1-3/#comments</comments>
		<pubDate>Tue, 24 Jan 2012 10:26:09 +0000</pubDate>
		<dc:creator>mike</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[static]]></category>

		<guid isPermaLink="false">http://www.michelepasin.org/techblog/?p=1734</guid>
		<description><![CDATA[Even if I've been using Django 1.3 for a while now, I've been holding off on some of it new features, such as the new way to handle static files via a new app called (guess what) staticfiles . Essentially, what the new static app does is allowing you to leave all static files within [...]]]></description>
			<content:encoded><![CDATA[Even if I've been using Django 1.3 for a while now, I've been holding off on some of it new features, such as the new way to handle static files via a <a href="https://docs.djangoproject.com/en/dev/howto/static-files/">new app</a> called (guess what) <span style="font-family:monospace;color:#000000; ">staticfiles</span> . Essentially, what the new static app does is allowing you to leave all static files within the <span style="font-family:monospace;color:#000000; ">/static</span> directory of each of the django apps you're using. This is for development; when you're deploying and (most likely) want these files to be served via a (faster) separate server process, the <span style="font-family:monospace;color:#000000; ">staticfiles</span> app helps you gather all of them into a predefined directory by using a handy shell command.

That's the gist of it. I finally took a look at <span style="font-family:monospace;color:#000000; ">django.contrib.staticfiles</span> last week, so here's a brief report on how to get it to work (p.s. a couple of related threads on stack overflow can be found <a href="http://stackoverflow.com/questions/7620307/how-do-i-serve-css-to-django-in-development">here</a> and <a href="http://stackoverflow.com/questions/4565935/django-staticfiles-app-help">here</a>).



<h3>1. Set up the static and media paths settings</h3>

My previous settings looked like this:

<pre style='overflow:auto;color:#000000;background:#ffffff;'><span style='color:#3f7f59; '># the site root is one level up from where settings.py is</span>
SITE_ROOT = os.path.dirname(os.path.realpath(__file__)).rsplit(<span style='color:#2a00ff; '>'/'</span>, 1)[0]
MEDIA_ROOT = os.path.join(SITE_ROOT, <span style='color:#2a00ff; '>'static'</span>)
MEDIA_URL = <span style='color:#2a00ff; '>'/static/'</span>
ADMIN_MEDIA_PREFIX = <span style='color:#2a00ff; '>'/static/adminmedia1.3/'</span>
</pre>

The media root contained all of my static files, some of which I had to copy in there manually, each time I added a new django app to my project. On the production server, the <span style="font-family:monospace;color:#000000; ">MEDIA_URL</span> is mapped to a local path (in the apache conf settings) that is essentially a duplicate of the <span style="font-family:monospace;color:#000000; ">/static</span> directory we have in the development server. The only difference, the static stuff is delivered directly by Apache, bypassing django (=so to make it faster). 

The <strong>new way</strong> of declaring these variables is this instead:

<pre style='overflow:auto;color:#000000;background:#ffffff;'>MEDIA_URL = <span style='color:#2a00ff; '>'/media/uploads/'</span>
STATIC_URL = <span style='color:#2a00ff; '>'/media/static/'</span>
ADMIN_MEDIA_PREFIX = <span style='color:#2a00ff; '>'/media/static/admin/'</span>

<span style='color:#3f7f59; '># Absolute path to the directory that holds media uploaded</span>
MEDIA_ROOT = os.path.join(SITE_ROOT, <span style='color:#2a00ff; '>'media/uploads'</span>)

<span style='color:#3f7f59; '># physical location of extra static files in development server</span>
STATICFILES_DIRS = (
    os.path.join(SITE_ROOT, <span style='color:#2a00ff; '>'media/static'</span>),
)
<span style='color:#3f7f59; '># path used with "python manage.py collectstatic"</span>
STATIC_ROOT = os.path.join(SITE_ROOT, <span style='color:#2a00ff; '>'media/static_apache'</span>)
</pre>

Obviously on a production server, you will have to set up the required aliases in the <a href="https://docs.djangoproject.com/en/dev/howto/deployment/wsgi/modwsgi/#serving-files">apache conf</a> file, so that <span style="font-family:monospace;color:#000000; ">MEDIA_URL</span> and <span style="font-family:monospace;color:#000000; ">STATIC_URL</span> are pointing at the right physical locations: 

<pre style='overflow:auto;color:#000000;background:#ffffff;'>Alias /media/uploads/ /path/to/mysite.com/media/uploads/
Alias /media/static/ /path/to/mysite.com/media/static_apache/
</pre>

The <a href="https://docs.djangoproject.com/en/dev/howto/static-files/">django docs</a> explain the new approach with these words: 

<blockquote>In previous versions of Django, it was common to place static assets in MEDIA_ROOT along with user-uploaded files, and serve them both at MEDIA_URL. Part of the purpose of introducing the staticfiles app is to make it easier to keep static files separate from user-uploaded files.

For this reason, you need to make your MEDIA_ROOT and MEDIA_URL different from your STATIC_ROOT and STATIC_URL.

The STATIC_ROOT directory is not necessary in the development server: in fact  is only used if you call the collectstatic manangement command. It's not needed to add the directory to the STATICFILES_DIRS setting to serve your static files!

Furthemore, the STATICFILES_DIRS variable tells Django of the location of static files which are not within specific applications. Mind that during the 'collection' operations also these files will be copied into the STATIC_ROOT directory.</blockquote>


<p>&nbsp;</p>
<h3>2. Add context processors and the app</h3>

Add the required context processor in <span style="font-family:monospace;color:#000000; ">setting.py</span>: 

<pre style='overflow:auto;color:#000000;background:#ffffff;'>TEMPLATE_CONTEXT_PROCESSORS += <span style='color:#2a00ff; '>'django.core.context_processors.static'</span></pre>
	
Add also the new static app to your installed apps:

<pre style='overflow:auto;color:#000000;background:#ffffff;'>INSTALLED_APPS = (
....    
    <span style='color:#2a00ff; '>'django.contrib.staticfiles'</span>,    
.....
)
</pre>

<blockquote>Keep in mind that it's very likely that in your templates you will have to manually change all references to <span style="font-family:monospace;color:#000000; ">MEDIA_URL</span> into <span style="font-family:monospace;color:#000000; ">STATIC_URL</span>!</blockquote>

<p>&nbsp;</p>
<h3>3. Url configuration</h3>

On your <strong>development</strong> server, this is what you would do:

<pre style='overflow:auto;color:#000000;background:#ffffff;'><span style='color:#7f0055; font-weight:bold; '>from</span> django.contrib.staticfiles.urls <span style='color:#7f0055; font-weight:bold; '>import</span> staticfiles_urlpatterns
<span style='color:#3f7f59; '># ... the rest of your URLconf goes here ...</span>
urlpatterns += staticfiles_urlpatterns()
</pre>

This will inspect your <span style="font-family:monospace;color:#000000; ">STATIC_URL</span> setting and wire up the view to serve static files accordingly. Don't forget to set the <span style="font-family:monospace;color:#000000; ">STATICFILES_DIRS</span> setting appropriately to let <span style="font-family:monospace;color:#000000; ">django.contrib.staticfiles</span> know where to look for files additionally to files in app directories.

<blockquote><strong>WARNING</strong>: the <span style="font-family:monospace;color:#000000; ">staticfiles_urlpatterns</span> helper function will only work if <span style="font-family:monospace;color:#000000; ">DEBUG</span> is True and your <span style="font-family:monospace;color:#000000; ">STATIC_URL</span> setting is neither empty nor a full URL such as http://static.example.com/ (more info <a href="https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/#staticfiles-development-view">here</a>).</blockquote>

Finally, mind that in this new approach you will need to arrange for serving of files in <span style="font-family:monospace;color:#000000; ">MEDIA_ROOT</span> yourself; <strong>staticfiles does not deal with user-uploaded files at all</strong>. You can, however, use <span style="font-family:monospace;color:#000000; ">django.views.static.serve()</span> view for serving <span style="font-family:monospace;color:#000000; ">MEDIA_ROOT</span> in development (for more info see <a href="https://docs.djangoproject.com/en/dev/howto/static-files/#serving-other-directories">Serving other directories</a>).

<pre style='overflow:auto;color:#000000;background:#ffffff;'><span style='color:#7f0055; font-weight:bold; '>if</span> settings.LOCAL_SERVER:     <span style='color:#3f7f59; '># ===> static files on local machine    </span>
    urlpatterns += patterns(<span style='color:#2a00ff; '>''</span>, 
        (<span style='color:#2a00ff; '>r'^media/uploads/(?P&lt;path>.*)$'</span>, <span style='color:#2a00ff; '>'django.views.static.serve'</span>, 
            {<span style='color:#2a00ff; '>'document_root'</span>: settings.MEDIA_ROOT, <span style='color:#2a00ff; '>'show_indexes'</span>: True}),
        )
</pre>

In the end, I conflated the two things into this code (ps I've added a variable called <span style="font-family:monospace;color:#000000; ">LOCAL_SERVER</span> to quickly see which platform I'm on):

<pre style='overflow:auto;color:#000000;background:#ffffff;'><span style='color:#7f0055; font-weight:bold; '>if</span> settings.LOCAL_SERVER:     <span style='color:#3f7f59; '># ===> static files on local machine</span>
    <span style='color:#7f0055; font-weight:bold; '>from</span> django.contrib.staticfiles.urls <span style='color:#7f0055; font-weight:bold; '>import</span> staticfiles_urlpatterns
    urlpatterns += staticfiles_urlpatterns()    
    urlpatterns += patterns(<span style='color:#2a00ff; '>''</span>, 
        (<span style='color:#2a00ff; '>r'^media/uploads/(?P&lt;path>.*)$'</span>, <span style='color:#2a00ff; '>'django.views.static.serve'</span>, 
            {<span style='color:#2a00ff; '>'document_root'</span>: settings.MEDIA_ROOT, <span style='color:#2a00ff; '>'show_indexes'</span>: True}),
        )
</pre>

<p>&nbsp;</p>
<h3>4. On your production server</h3>

Easy: in your urlconf there's no need to do anything, as static urls are usually handled by Apache directly. However for that to happen what you have to do is collect all static files into the directory that apache is looking into, that is, the one specified with the <span style="font-family:monospace;color:#000000; ">STATIC_ROOT</span> setting. This is how you do it: 

<blockquote><code><font size="2" face="Courier New" color="black">python manage.py collectstatic</font></code></blockquote>

This shell command will
a) look in the <span style="font-family:monospace;color:#000000; ">/static/</span> directory of each of the apps of yours <span style="font-family:monospace;color:#000000; ">INSTALLED_APPS</span> setting.
b) look in directories you specify in the <span style="font-family:monospace;color:#000000; ">STATICFILES_DIRS</span> setting.

…and copy whatever it finds into the <span style="font-family:monospace;color:#000000; ">STATIC_ROOT</span> directory, as defined in your settings (ps: it'll preserve the original directory structure). 


That's all folks!


<p>&nbsp;</p>]]></content:encoded>
			<wfw:commentRss>http://www.michelepasin.org/techblog/2012/01/24/setting-up-the-new-staticfiles-app-on-django-1-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Towards a conceptual model for the domain of Sculpture</title>
		<link>http://www.michelepasin.org/techblog/2011/11/19/towards-a-conceptual-model-for-the-domain-of-sculpture/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=towards-a-conceptual-model-for-the-domain-of-sculpture</link>
		<comments>http://www.michelepasin.org/techblog/2011/11/19/towards-a-conceptual-model-for-the-domain-of-sculpture/#comments</comments>
		<pubDate>Sat, 19 Nov 2011 14:44:09 +0000</pubDate>
		<dc:creator>mike</dc:creator>
				<category><![CDATA[digitalHumanities]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[mindmapping]]></category>
		<category><![CDATA[modeling]]></category>
		<category><![CDATA[representations]]></category>
		<category><![CDATA[sculpture]]></category>

		<guid isPermaLink="false">http://www.michelepasin.org/techblog/?p=1704</guid>
		<description><![CDATA[For the next two years I'll be collaborating with the Art of Making project. The project investigates the processes involved in the carving of stone during the Roman period, in particular it aims at analysing them using the insights and understanding Peter Rockwell (son of Norman Rockwell) developed during his lifelong experience as a sculptor. [...]]]></description>
			<content:encoded><![CDATA[For the next two years I'll be collaborating with the <a href="http://www.artofmaking.ac.uk/">Art of Making</a> project. The project investigates the processes involved in the carving of stone during the Roman period, in particular it aims at analysing them using the insights and understanding <a href="http://www.geoffreyrockwell.com/PRportfolio/">Peter Rockwell</a> (son of <a href="http://en.wikipedia.org/wiki/Norman_Rockwell">Norman Rockwell</a>) developed during his lifelong experience as a sculptor. Eventually we will present these results by means of a freely accessible online digital resource that guides users through examples of stone carving. In this post I just wanted to report on the very first discussions I had with the sculpture and art scholars I'm working with, to the purpose of creating a shared model for this  domain.   

The project started this July, it is based at <a href="http://www.kcl.ac.uk/">King’s College London</a> and is funded by the Leverhulme Trust. I'm more involved with the digital aspects of the project, and as usual one of the first steps involved in the building of a digital resource (in particular, a database-backed digital resource) is the construction of a <b>conceptual model</b> that can represent the main <b>types of things</b> being dealt with. 

In other words, it is fundamental to identify which are the things our database and web-application should 'talk about'; later on, this model can be refined and extended so to become an abstract template of the data-manipulation tasks the software application must be capable of supporting (e.g. entering data into the system, searching and visualising them). 

Here's a nice example of the sculptures (a <a href="http://www.artofmaking.ac.uk/2012/01/03/image-of-the-month-january-2012/">sarcophagus from Aphrodisias</a>) that constitute our 'source' materials:

<p><img src="http://www.artofmaking.ac.uk/wp-content/uploads/2012/01/7-4.jpg" /></p>



<h3>What are the key entities in the sculpture domain?</h3>

To this purpose, a few weeks ago we had a very productive brainstorming session aimed at fleshing out the main items of interest in the world of sculpture. This is a very first step towards the construction of a formal model for this domain; nonetheless, I think that we have already managed to pin down the key elements we're going to be dealing with in the next two years. 

Here's a list of the main objects we identified:

<ul>
<li>- <strong>People</strong>, such as craftsman's etc..</li>
<li>- <strong>Sculptures</strong> (of various kinds)</li>
<li>- <strong>Materials</strong></li>
<li>- <strong>Tools</strong></li>
<li>- Generic <strong>processes</strong> that are part of a sculpting project, such as quarrying and transport.
</li>
<li>- More specific <strong>methods</strong> being used within a particular process, e.g. carving styles, or approaches to quarrying.</li>
<li>- <strong>Traditions</strong>, conceptualisations of the 'way of doing things' that, in turn, can inspire the way methods and processes are carried out nowadays.</li>
</ul>

We encoded the results of our discussions in a <a href="http://en.wikipedia.org/wiki/Mind_map">mind map</a> for better readability, and also in order to use a technology that would make it easier to share our findings later on. I added it below.. (in case the interactive image doesn't work, you can find it <a href="">here</a> too).

<iframe id='xmindshare_embedviewer' src='http://www.xmind.net/share/_embed/magicrebirth/xmind-972121/' width='600px' height='600px' frameborder='0' scrolling='no'></iframe>

<h3>Fleshing out the model a bit more</h3>

After a few weeks of work we did a reiteration of the conceptual map above. The good news was that it soon became evident to us that we got it quite right on the first round; that is, we didn't really feel like adding or removing anything from the map. 

On the other hand, we thought we should try to add some <b>relations</b> (= links, arcs) among the concepts (=bubbles) previously identified, so to characterize their semantics a bit more. I had a go at adding some relations first, and here's the result:

<iframe id='xmindshare_embedviewer' src='http://www.xmind.net/share/_embed/magicrebirth/main-entities-relations/' width='600px' height='400px' frameborder='0' scrolling='no'></iframe>

I should specify that I have no knowledge whatsoever of the domain of sculpture, so the stuff I added to the map came out entirely from the (little) research I've been doing on the subject (on and off) during the last weeks. 

At the same time, also Will and Ben (the art historians I'm collaborating with) worked independently at the task of fleshing out the mind map with more relations. Needeless to say, what they came up with is way more dense and intricate than what I could have ever imagined! This is probably not surprising, as one would expect to see a significant difference between a non-expert's representation of a subject domain and another one which is instead created by experts. Still, it was interesting to see it happening with my own eyes!
Here it is: 

<iframe id='xmindshare_embedviewer' src='http://www.xmind.net/share/_embed/magicrebirth/the-art-of-making-structure/' width='600px' height='400px' frameborder='0' scrolling='no'></iframe>


The next step will be trying to reduce the (natural) complexity of the portion of the world we are representing to a more manageable size… then, formalize it, and start building our database based on that..  stay tuned for more! 

<p>&nbsp;</p>]]></content:encoded>
			<wfw:commentRss>http://www.michelepasin.org/techblog/2011/11/19/towards-a-conceptual-model-for-the-domain-of-sculpture/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Upgrading to Lion: tips and tricks</title>
		<link>http://www.michelepasin.org/techblog/2011/10/19/upgrading-to-lion-tips-and-tricks/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=upgrading-to-lion-tips-and-tricks</link>
		<comments>http://www.michelepasin.org/techblog/2011/10/19/upgrading-to-lion-tips-and-tricks/#comments</comments>
		<pubDate>Wed, 19 Oct 2011 14:01:18 +0000</pubDate>
		<dc:creator>mike</dc:creator>
				<category><![CDATA[justBlogging]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[lion]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[osx]]></category>

		<guid isPermaLink="false">http://www.michelepasin.org/techblog/?p=1643</guid>
		<description><![CDATA[I've finally decided to upgrade my mac operating system from Snow Leopard (10.6.8) to Lion (10.7.2). Not really for the new features such as Mission Control and LaunchPad (which although being pretty cool are not going to change my life) but mostly for the fact that the new OS is well integrated with iCloud. Sharing [...]]]></description>
			<content:encoded><![CDATA[I've finally decided to upgrade my mac operating system from Snow Leopard (10.6.8) to Lion (10.7.2). Not really for the <a href="http://www.apple.com/uk/macosx/whats-new/features.html">new features</a> such as Mission Control and LaunchPad (which although being pretty cool are not going to change my life) but mostly for the fact that the new OS is well integrated with <a href="http://www.apple.com/uk/icloud/">iCloud</a>. Sharing my iCal calendars, Address book contacts and other useful stuff across my apple computers and mobile devices is going to be a digital-life-changer, hopefully for the better.

Unfortunately as usual an OS upgrade is never as smooth as I would like it to be; so here's a list of the problems I ran into (and still am), with pointers to solutions whenever I found one.
<blockquote>Tip: A useful place where to get info about Lion is here: <a href="http://osxdaily.com/tag/mac-os-x-10-7/">http://osxdaily.com/tag/mac-os-x-10-7/</a></blockquote>

<h3>1. Wi-Fi disconnection issues</h3>

This is quite a bad one: my wifi connection wouldn't stay on for more than 2-3 minutes at times, making it impossible to do any continuative work online. After a lot of swearing and searching online, I found a good solution on <a href="http://www.ilounge.com/index.php/backstage/comments/os-x-lion-serious-wi-fi-disconnect-problems-for-macs-and-solutions/">this article on iLounge.com</a>. The article offers many solutions, but the one that worked for me is to manually downgrading the Atheros WiFi driver which seems to be ill on Lion to the version provided with Snow Leopard (comment 53). Here's the recipy:

<blockquote>
1. run <span style="font-family:monospace;color:#000000; ">kextstat | grep -i atheros</span>
  if a line was returned, you are most likely using Atheros WiFi card and the related kext
2. In your home folder create two directories: <span style="font-family:monospace;color:#000000; ">cd && mkdir New Old</span>
3. If you have a copy (time machine backup) or other system installed with Snow Leopard (as latest as possible), take a copy of <span style="font-family:monospace;color:#000000; ">/System/Library/Extensions/IO80211Family.kext </span>and put it into <span style="font-family:monospace;color:#000000; ">~/Old/</span> directory 
[<em>P.S. if you don't know where to get that file, I've uploaded a copy here: <a href="http://www.box.net/shared/8igl4hybcml0e4zc5dzx">IO80211Family.kext.zip</a></em>]
4. (Back on to your main system) gain root access: <span style="font-family:monospace;color:#000000; ">sudo -s</span>
5. Move: <span style="font-family:monospace;color:#000000; ">mv /System/Library/Extensions/IO80211Family.kext ~/New/</span>
6. Move cache file: <span style="font-family:monospace;color:#000000; ">mv /System/Library/Caches/com.apple.kext.caches/Startup/kernelcache ~/New/</span>
7. copy old kext: <span style="font-family:monospace;color:#000000; ">cp -r ~/Old/IO80211Family.kext /System/Library/Extensions/</span>
8. go to: <span style="font-family:monospace;color:#000000; ">cd /System/Library/Caches/com.apple.kext.caches/Startup/</span>
9. rebuild cache: <span style="font-family:monospace;color:#000000; ">kextcache -v 1 -a i386 -a x86_64 -mkext kernelcache /System/Library/Extensions</span>
10. Using GUI Utilities->Disk Utility->Macintosh HD->Repair permissions
11. pray and reboot</blockquote>

<h3>2. Install the latest Xcode and Developer Tools</h3>

This is number 2 in the list, but really it should be number 1 if you are a software developer. The latest Xcode (4.2, get it on the <a href="http://itunes.apple.com/us/app/xcode/id448457090?mt=12">apple store</a> for free) includes all sorts of low and high level programming frameworks, from C compilers to Python interpreters. In other words, without reinstalling Xcode tons of software development environments won't run as usual!

Installing Xcode is very easy, here's a nice tip to keep in mind though (as found <a href="http://jessenoller.com/2011/07/30/quick-pythondeveloper-tips-for-osx-lion/">here</a>):   
<blockquote>When installing XCode, for some unknown unholy rea­son, if you have not quit itunes, and itunes helper (see activ­ity mon­i­tor) prior to start­ing the XCode installer, the install will hang. Do your­self a favor and kill it with fire.</blockquote>

Also, two more crucial things to keep in mind: 

<blockquote>- Remem­ber; the binary direc­tory for the dev tools is in <span style="font-family:monospace;color:#000000; ">/Developer/usr/bin/</span> — this includes gcc-4.2
- Do your­self a favor, drop “<span style="font-family:monospace;color:#000000; ">export ARCHFLAGS="-arch x86_64"</span>” into your <span style="font-family:monospace;color:#000000; ">.bash_profile</span>.</blockquote>

The last point is extremely important; make sure you do that otherwise you'll easily run into all sorts of 32 vs 64 bits architectures conflicts that (if you're like me) you have no time to get into (<a href="http://stackoverflow.com/questions/5256397/python-easy-install-fails-with-assembler-for-architecture-ppc-not-installed-on">more info here</a>).


<h3>3. Fix your Python installation</h3>

On my iMac I couldn't run <a href="http://ipython.org/">iPython</a> anymore; this was surprisingly easy to fix, I just run again <span style="font-family:monospace;color:#000000; ">easy_install ipython</span> from the command line and there you go iPython went back up (version 2.7, the default one with Lion).

This didn't work on my other mac though (a slightly older MacBook); the <span style="font-family:monospace;color:#000000; ">easy_install ipython</span> trick failed with a <span style="font-family:monospace;color:#000000; ">DistributionNotFound </span> error; if this is the case, you probably have to re-install Apple's Developer Tools (see point 2 above). 
However before doing that you might want to consider this <strong>good tip</strong> which I found <a href="">here</a>:

<blockquote>1. Make a list of all the third-party libraries you currently have installed under Python 2.6, because you’ll have to reinstall all of them for 2.7 and you won’t have the 2.6 <span style="font-family:monospace;color:#000000; ">site-packages</span> directory to refer to.
2. Update to Lion.
3. Update to Xcode 4.1. It’s free in the App Store. </blockquote>

Good, so I installed XCode 4 (= Apple's Developer Tools) but I still had a problem: for some reason the default python binary (<span style="font-family:monospace;color:#000000; ">/usr/bin/python</span>) was still pointing at the 2.5 release, instead of the 2.7 that comes with Lion. This was easily fixed by issuing this command: 
<blockquote><span style="font-family:monospace;color:#000000; ">defaults write com.apple.versioner.python Version 2.7</span></blockquote>

Two final steps are then required: 

<blockquote>a) <a href="http://pypi.python.org/pypi/setuptools#downloads">Download</a> the 2.7 version of setuptools and install it (e.g. <span style="font-family:monospace;color:#000000; ">sudo sh setuptools-0.6c11-py2.7.egg</span>); 
b) re-install iPython via setuptools: <span style="font-family:monospace;color:#000000; ">sudo easy_install ipython</span></blockquote>

Obviously I'll have to manually install under 2.7 all the libraries I used to have on 2.6, but that can be done incrementally and thanks to <span style="font-family:monospace;color:#000000; ">easy_install</span> it's also quite quick. 

For more discussions on python and Lion, check out these posts: <a href="http://jessenoller.com/2011/07/30/quick-pythondeveloper-tips-for-osx-lion/">Quick Python/Developer tips for OSX Lion</a> and <a href="http://www.leancrew.com/all-this/2011/07/python-problems-on-lion-mostly-self-inflicted/">Python problems on Lion</a>.


<h3>4. The Mercurial binaries disappeared</h3>

What the heck. You need to reinstall Mercurial using the package available here: <a href="http://mercurial.berkwood.com/">http://mercurial.berkwood.com/</a> and Python problems on Lion


<h3>5. Omnigraffle can't save files anymore</h3>

My 5.0 copy of Omnigraffle loaded and let me create stuff just fine, but it won't save files anymore. I got an error message that looked like an internal error ("class bla bla can't be subclassed by bla bla bla") each time I tried to save my work. Bugger. 

Couldn't find a solution to this; I guess that getting the latest version (5.3 I think) will solve the issue (it' 70 dollars though).


<h3>6. Java runtime missing</h3>

Lion does not provide a Java runtime by default, so you need to install it separately. No worries: that's going to happen automatically as soon as you try to run a Java application; alternatively, you can do that manually <a href="http://support.apple.com/kb/dl1421">here</a>.

<h3>7. The Finder Sidebar Icons colours (well lack of..) are depressing</h3>

Why on earth haven't they made that a preference we can change? There's a way around it though, and it is <a href="http://osxdaily.com/2011/08/25/get-color-sidebar-icons-back-in-mac-os-x-10-7-lion-finder-windows/">described here</a>. This is the gist of it:

<blockquote>
- Download and install SIMBL, which you can <a href="http://www.culater.net/software/SIMBL/SIMBL.php">get here</a>
- Download the <a href="http://cooviewerzoom.web.fc2.com/ColorfulSidebar1.0.dmg.zip">ColorfulSidebar SIMBL plugin</a> (direct link) or <a href="http://cooviewerzoom.web.fc2.com/colorfulsidebar.html">visit the developers home</a> and mount the DMG file
- Move the <span style="font-family:monospace;color:#000000; ">ColorfulSidebar.bundle</span> into the following SIMBL plugin folder: <span style="font-family:monospace;color:#000000; ">~/Library/Application Support/SIMBL/Plugins/</span>
- Either login and logout of Mac OS X, or just kill the Finder through the Terminal to relaunch it: <span style="font-family:monospace;color:#000000; ">killall Finder</span></blockquote>

Unfortunately this solution won't stick after an OS reload; but it's enough to relaunch the Finder (<span style="font-family:monospace;color:#000000; ">killall Finder</span>) to reload the plugin. 

P.S. If you can't access the <span style="font-family:monospace;color:#000000; ">~/Library</span> folder using Finder, check out point 12 below!

<h3>8. Safari Won't Reopen To HomePage</h3>
Apple <a href="https://discussions.apple.com/message/15662314#15662314">changed</a> the way new windows open. In Safari, if you set the "New windows open with" preference to "Homepage", then ALL new windows will now open with your homepage setting, including the initial startup window. In past versions, you could set that preference to "Same Page" while startup would auto open the homepage. 

Solution: go to <em>System Preferences/General/</em> and uncheck the "Restore windows when quitting and re-opening apps" option.

<h3>9. The CD-TO utility disappeared</h3>
A small utility I've been using all the time is <a href="http://code.google.com/p/cdto/">cdto</a>, a mini application that opens a Terminal.app window cd'd to the front most finder window. 

That doesn't work anymore, but the good news is that as of Mac OS X Lion 10.7, Terminal includes exactly this functionality as a Service, which you can set by going to System <span style="font-family:monospace;color:#000000; ">Preferences > Keyboard > Keyboard Shortcuts > Services</span> (check this useful <a href="http://www.tech-recipes.com/rx/16708/os-x-lion-how-to-easily-open-a-new-terminal-or-terminal-tab-at-a-folder/">blog post for more details</a>). Also, a more in-depth discussion of the various options available can be found on <a href="http://stackoverflow.com/questions/420456/open-terminal-here-in-mac-os-finder">stackOverflow</a>. 

In addition, Lion Terminal will open a new terminal window if you drag a folder (or pathname) onto the Terminal application icon, and you can also drag to the tab bar of an existing window to create a new tab.

<strong>Update</strong>: CDTO has a <a href="http://code.google.com/p/cdto/downloads/list">Lion version</a> available too. Also, another free software that offers the same functionalities is <a href="http://itunes.apple.com/us/app/go2shell/id445770608?mt=12">Go2Shell</a>.

<h3>10. Visor doesn't work anymore</h3>

Yes because Visor (a pumped-up version of the terminal application) relied on SIMBL, which is handled different on Lion. Not a problem, just download <a href="http://totalterminal.binaryage.com/">TotalTerminal</a>, which is an updated and more stable version of Visor. 

For original Visor 2.2 users: TotalTerminal plugin is not injected into Terminal.app automatically like with SIMBL. You have to launch TotalTerminal.app to inject the plugin into Terminal.app. You might want to put TotalTerminal.app into Startup Items.

<h3>11. VmwareFusion won't work</h3>

VmwareFusion is a Virtual-PC software that people use to run windows on a mac; I was using an older version of it and it looks as if this is incompatible with the 64-bit architecture of the Lion operating system. 

Solution: nothing else than getting the <a href="http://www.vmware.com/products/fusion/overview.html">latest version of VmwareFusion</a>, which currently sells for 50 dollars. Bugger.

<h3>12. Customize the Finder</h3>
Get the Library folder to show again: by default, the <span style="font-family:monospace;color:#000000; ">Library</span> folder in your home directory doesn't show in Finder. Just type this into your terminal app to fix it:
<blockquote><span style="font-family:monospace;color:#000000; ">chflags nohidden ~/Library/</span></blockquote>
Show hidden files in finder: beware though, this might result in a lot of information being displayed which is not needed.
<blockquote><span style="font-family:monospace;color:#000000; ">defaults write com.apple.finder AppleShowAllFiles -bool YES</span>
</blockquote>
Show full paths in finder: it's quite useful to know always where you are.
<blockquote><span style="font-family:monospace;color:#000000; ">defaults write com.apple.finder _FXShowPosixPathInTitle -bool YES</span></blockquote>

.. and many more customisations are listed on <a href="http://secrets.blacktree.com/">http://secrets.blacktree.com/</a>. 

Alternatively, you can customise your mac to the bone without touching the console by downloading a free utility software called <a href="http://www.bresink.com/osx/0TinkerTool/download.php5">TinkerTool</a>.


<h3>13. Get the Old Apple Mail Back</h3>

The new Apple Mail interface is quite slick, but I still have some problems adapting to it. 

You can easily revert back to the old interface just by going to the <span style="font-family:monospace;color:#000000; ">Mail</span> menu and choose <span style="font-family:monospace;color:#000000; ">Preferences</span>. From there, click <span style="font-family:monospace;color:#000000; ">Viewing</span> and you'll find the options you want right at the top.



<h3>14. .. ? (still looking for it!)


<p>&nbsp;</p>]]></content:encoded>
			<wfw:commentRss>http://www.michelepasin.org/techblog/2011/10/19/upgrading-to-lion-tips-and-tricks/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Seminar: Tagore digital editions and Bengali textual computing</title>
		<link>http://www.michelepasin.org/techblog/2011/10/13/seminar-tagore-digital-editions-and-bengali-textual-computing/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=seminar-tagore-digital-editions-and-bengali-textual-computing</link>
		<comments>http://www.michelepasin.org/techblog/2011/10/13/seminar-tagore-digital-editions-and-bengali-textual-computing/#comments</comments>
		<pubDate>Thu, 13 Oct 2011 17:01:52 +0000</pubDate>
		<dc:creator>mike</dc:creator>
				<category><![CDATA[digitalHumanities]]></category>
		<category><![CDATA[bengali]]></category>
		<category><![CDATA[collation]]></category>
		<category><![CDATA[india]]></category>
		<category><![CDATA[tagore]]></category>
		<category><![CDATA[text-analysis]]></category>

		<guid isPermaLink="false">http://www.michelepasin.org/techblog/?p=1603</guid>
		<description><![CDATA[Professor Sukanta Chaudhuri yesterday gave a very interesting talk on the scope, methods and aims of 'Bichitra' (literally, 'the various'), the ongoing project for an online variorum edition of the complete works of Rabindranath Tagore in English and Bengali. The talk (part of this year's DDH research seminar) highlighted a number of issues I personally [...]]]></description>
			<content:encoded><![CDATA[Professor Sukanta Chaudhuri yesterday gave a very interesting talk on the scope, methods and aims of 'Bichitra' (literally, 'the various'), the ongoing project for an online variorum edition of the complete works of Rabindranath Tagore in English and Bengali. The talk (part of this year's <a href="http://www.kcl.ac.uk/artshums/depts/ddh/events/newdh/index.aspx">DDH research seminar</a>) highlighted a number of issues I personally wasn't much familiar with, so in this post I'm summarising them a bit and then highlighting a couple of possible suggestions.

<a href="http://en.wikipedia.org/wiki/Sukanta_Chaudhuri">Sukanta Chaudhuri</a> is Professor Emeritus at <a href="http://www.jadavpur.edu/">Jadavpur University</a>, Kolkata (Calcutta), where he was formerly Professor of English and Director of the <a href="http://www.jaduniv.edu.in/view_department.php?deptid=135">School of Cultural Texts and Records</a>. His core specializations are in Renaissance literature and in textual studies: he published <a href="http://www.amazon.co.uk/Metaphysics-Text-Sukanta-Chaudhuri/dp/0521197961">The Metaphysics of Text</a> from Cambridge University Press in 2010. He has also translated widely from Bengali into English, and is General Editor of the <a href="http://www.oup.co.in/category.php?cat_id=143772">Oxford Tagore Translations</a>. 

<a href="http://en.wikipedia.org/wiki/Rabindranath_Tagore">Rabindranath Tagore </a>(1861 – 1941), the first nobel laureate of Asia, was arguably the most important icon of modern Indian Renaissance. This recent project on the electronic collation of Tagore texts, called 'the Bichitra project', is being developed as part of the national commemoration of the 150th birth anniversary of the poet (here's the <a href="http://rabindranathtagore-150.gov.in/index.html">official page</a>). This is how the School of Cultural Texts and Records summarizes the project's scope:

<blockquote>The School is carrying out pioneer work in computer collation of Tagore texts and creation of electronic hypertexts incorporating all variant readings. The first software for this purpose in any Indian language, named “Pathantar” (based on the earlier version “Tafat”), has been developed by the School. Two pilot projects have been carried out using this software, for the play Bisarjan (Sacrifice) and the poetical collection Sonar Tari (The Golden Boat). The CD/DVDs contain all text files of all significant variant versions in manuscript and print, and their collation using the ”Pathantar” software. The DVD of Sonar Tari also contains image files of all the variant versions. These productions are the first output of the series “Jadavpur Electronic Tagore”.
Progressing from these early endeavours, we have now undertaken a two-year project entitled "Bichitra" for a <a href="http://rabindranathtagore-150.gov.in/online-voriourum.html">complete electronic variorum edition of all Tagores works in English and Bengali</a>. The project is funded by the Ministry of Culture, Government of India, and is being conducted in collaboration with Rabindra-Bhavana, Santiniketan. The target is to create a website which will contain (a) images of all significant variant versions, in manuscript and print, of all Tagores works; (b) text files of the same; and (c) collation of all versions applying the "Pathantar" software. To this end, the software itself is being radically redesigned. Simultaneously, manuscript and print material is being obtained and processed from Rabindra-Bhavana, downloaded from various online databases, and acquired from other sources. Work on the project commenced in March 2011 and is expected to end in March 2013, by which time the entire output will be uploaded onto a freely accessible website.</blockquote>
<p>&nbsp;</p>
<h2>A few interesting points</h2>
<br />
<li>Tagore, as Sukanta noted, "<em>wrote voluminously and revised extensively</em>". From a DH point of view this means that creating a comprehensive digital edition of his works would require <strong>a lot of effort</strong> - much more than what we could easily pay people for, if we wanted to mark up all of this text manually. For this reason it is fundamental to find some type of <strong>semi-automatic methods for aligning and collating</strong> Tagore's texts, e.g. the ”Pathantar” software. Follows a screenshot of the current collation interface.
<br />
<a href="http://www.flickr.com/photos/mikele/6241316162/" title="Tagore digital editions by MagIcReBirth, on Flickr"><img src="http://farm7.static.flickr.com/6180/6241316162_5d5920dab8_z.jpg" width="640" height="303" alt="Tagore digital editions"></a>
</li>
<li>The<a href="http://en.wikipedia.org/wiki/Bengali_language"> Bengali language</a>, which is used by Tagore, is widely spoken in the world (it is actually one of the most spoken languages, with nearly 300 million total speakers). However this language poses <strong>serious problems for a DH project</strong>. In particular, the <a href="http://en.wikipedia.org/wiki/Bengali_script">writing system</a> is extremely difficult to parse using traditional OCR technologies: its vowel graphemes are mainly realized not as independent letters but as diacritics attached to its consonant letters. Furthermore clusters of consonants are represented by different and sometimes quite irregular forms, thus learning to read is complicated by the sheer size of the full set of letters and letter combinations, numbering about 350 (from <a href="http://en.wikipedia.org/wiki/Bengali_script">wikipedia</a>).</li>
<li>One of the critical points that emerged during the discussion had to do with the <strong>visual presentation of the results of the collation</strong> software. Given the large volume of text editions they're dealing with, and the potential vast amount of variations between one edition and the others, a powerful and interactive visualization mechanism seems to be <strong>strongly needed</strong>. However it's not clear what are the possible approaches on this front.. </li>
<li><strong>Textual computing</strong>, Sukanta pointed out, is <strong>not as developed in India</strong> as it is in the rest of the world. As a consequence, in the context of the "Bichitra" project widely used approaches based on TEI and XML technologies haven't really been investigated enough. The collation software mentioned above obviously marks up the text in some way; however this markup remains hidden to the user and much likely it is not compatible with other standards. More work would thus be desirable in this area - in particular within the Indian continent.</li>


<h2>Food for thought</h2>
<br />
<li><strong>On the visualization of the results of a collation</strong>. Some inspiration could be found in the type of visualizations normally used in <a href="http://en.wikipedia.org/wiki/Revision_control">version control software systems</a>, where multiple and alternative versions of the same file must be tracked and shown to users. For example, we could think of the visualizations available on GitHub (a popular code-sharing site), which are described on this <a href="https://github.com/blog/39-say-hello-to-the-network-graph-visualizer">blog post</a> and demonstrated via an interactive tool on <a href="https://github.com/sr/git-wiki/network">this webpage</a>. Here's a screenshot: 

<a href="http://www.flickr.com/photos/mikele/6240800007/" title="Github code visualization by MagIcReBirth, on Flickr"><img src="http://farm7.static.flickr.com/6091/6240800007_c2ed6467bb.jpg" width="500" height="496" alt="Github code visualization"></a>

The <a href="http://betterexplained.com/articles/a-visual-guide-to-version-control/">situation</a> is striking similar - or not? Would it be feasible to reuse one of these approaches with textual sources? 
Another relevant visualization is the one used by popular file-comparison softwares (eg File Merge on a Mac) for showing differences between two files:

<a href="http://www.flickr.com/photos/mikele/6241316238/" title="File Merge code visualization by MagIcReBirth, on Flickr"><img src="http://farm7.static.flickr.com/6056/6241316238_b2889f8c5a_z.jpg" width="640" height="360" alt="File Merge code visualization"></a>
</li>

<li><strong>On using language technologies with Bengali</strong>. I did a quick tour of what's available online, and (quite unsurprisingly, considering the reputation Indian computer scientists have) found several research papers which seem highly relevant. Here's a few of them:

- <em>Asian language processing: current state-of-the-art</em> [<a href="http://www.hlt.utdallas.edu/~vince/papers/lre06-intro.pdf">text</a>]
- <em>Research report on Bengali NLP engine for TTS</em> [<a href="http://dspace.bracu.ac.bd/handle/10361/647">text</a>]
- The <em>Emile corpus</em>, containing fourteen monolingual corpora, including both written and (for some languages) spoken data for fourteen South Asian languages [<a href="http://www.lancs.ac.uk/fass/projects/corpus/emille/">homepage</a>]
- <em>A complete OCR system for continuous Bengali characters</em> [<a href="http://ieeexplore.ieee.org/xpls/abs_all.jsp?arnumber=1273141&tag=1">text</a>]
- <em>Parsing Bengali for Database Interface</em> [<a href="http://research.banglacomputing.net/iccit/ICCIT_pdf/5th%20ICCIT-2002_p277-p282.pdf">text</a>]
- <em>Unsupervised Morphological Parsing of Bengali</em> [<a href="http://www.hlt.utdallas.edu/~vince/papers/lre06.html">text</a>]


<li><strong>On open-source softwares that appear to be usable with Bengali text</strong>. Not a lot of stuff, but more than enough to get started (the second project in particular seems pretty serious):

- <a href="http://open-bangla-ocr.sourceforge.net/">Open Bangla OCR</a> - A BDOSDN (Bangladesh Open Source Development Network) project to develop a Bangla OCR
- <a href="http://code.google.com/p/banglaocr/">Bangla OCR project</a>, mainly focused on the research and development of an Optical Character Recognizer for Bangla / Bengali script</li>

<p>&nbsp;</p>
Any comments and/or ideas?
<p>&nbsp;</p>]]></content:encoded>
			<wfw:commentRss>http://www.michelepasin.org/techblog/2011/10/13/seminar-tagore-digital-editions-and-bengali-textual-computing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Django B_project available on gitHub</title>
		<link>http://www.michelepasin.org/techblog/2011/10/12/django-b_project-available-on-github/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=django-b_project-available-on-github</link>
		<comments>http://www.michelepasin.org/techblog/2011/10/12/django-b_project-available-on-github/#comments</comments>
		<pubDate>Wed, 12 Oct 2011 09:34:00 +0000</pubDate>
		<dc:creator>mike</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[git]]></category>

		<guid isPermaLink="false">http://www.michelepasin.org/techblog/?p=1593</guid>
		<description><![CDATA[I've put together and shared on gitHub all the files needed to get started with a Django project - essentially this is a clean file structure usable to get going with a Django project nice and easy. The idea is that after downloading this, you just have to change a couple of names (see the [...]]]></description>
			<content:encoded><![CDATA[I've put together and shared on gitHub all the files needed to get started with a <a href="https://www.djangoproject.com/">Django</a> project - essentially this is a clean file structure usable to get going with a Django project nice and easy. The idea is that after downloading this, you just have to change a couple of names (see the <a href="https://github.com/magicrebirth/b_project/tree/master/_help">README</a> file for more details) and there you go you have a complete Django project ready to be ran and customized. 

The code is here: <a href="https://github.com/magicrebirth/b_project">https://github.com/magicrebirth/b_project</a>. Feel free to download or fork it as you like!

Currently the B_project is set up to work with Django 1.3 and it has a few 'batteries' included (= commonly used apps): 
<li><a href="https://github.com/django-mptt/django-mptt/">MPTT</a>: Utilities for implementing a modified pre-order traversal tree in django</li>
<li><a href="https://bitbucket.org/ubernostrum/django-registration/">REGISTRATION</a>: A user-registration application for Django. </li>
<li><a href="https://github.com/django-extensions/django-extensions">DJANGO EXTENSIONS</a>: global custom management extensions for the Django Framework.</li>
<li><a href="http://pypi.python.org/pypi/django-picklefield">PICKLEFIELD</a>:  an implementation of a pickled object field.</li>

<a href="http://www.flickr.com/photos/mikele/6237287046/" title="Django B_project structure by MagIcReBirth, on Flickr"><img src="http://farm7.static.flickr.com/6218/6237287046_5774ef8ea7_z.jpg" width="571" height="640" alt="Django B_project structure"></a><br />


The other things included in the framework are:
<li>a <em>settings.py</em> file that calls localized settings specifications depending on parameters (eg dev server or live one)</li>
<li>a bunch of generic python utilities</li>
<li>a few 'enhanced' model classes</li>
<li>all that is needed for working with trees in the admin (as discussed here: <a href="http://www.michelepasin.org/techblog/2009/08/18/django-admin-and-mptt-2/">Django admin and MPTT</a>)</li>
<li>a javascript autocomplete framework, integrated in the admin (as discussed here: <a href="http://www.michelepasin.org/techblog/2009/10/12/autocomplete-in-django-2/">Autocomplete in Django</a>)</li>
<li>some basic templates and templatetags</li>

Enjoy!

<p>&nbsp;</p>]]></content:encoded>
			<wfw:commentRss>http://www.michelepasin.org/techblog/2011/10/12/django-b_project-available-on-github/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Event: THATcamp Kansas and Digital Humanities Forum</title>
		<link>http://www.michelepasin.org/techblog/2011/09/28/event-thatcamp-kansas-and-digital-humanities-forum/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=event-thatcamp-kansas-and-digital-humanities-forum</link>
		<comments>http://www.michelepasin.org/techblog/2011/09/28/event-thatcamp-kansas-and-digital-humanities-forum/#comments</comments>
		<pubDate>Wed, 28 Sep 2011 16:56:55 +0000</pubDate>
		<dc:creator>mike</dc:creator>
				<category><![CDATA[digitalHumanities]]></category>
		<category><![CDATA[conference]]></category>
		<category><![CDATA[gis]]></category>
		<category><![CDATA[kansas]]></category>
		<category><![CDATA[ontology]]></category>
		<category><![CDATA[paper]]></category>
		<category><![CDATA[thatcamp]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://www.michelepasin.org/techblog/?p=1567</guid>
		<description><![CDATA[The THATcamp Kansas and Digital Humanities Forum happened last week at the Institute for Digital Research in the Humanities, which is part of the University of Kansas in beautiful Lawrence. I had the opportunity to be there and give a talk about some recent stuff I've been working on regarding digital prosopography and computer ontologies, [...]]]></description>
			<content:encoded><![CDATA[The THATcamp Kansas and Digital Humanities Forum happened last week at the <a href="http://idrh.ku.edu/">Institute for Digital Research in the Humanities</a>, which is part of the <a href="http://www.ku.edu/">University of Kansas</a> in beautiful <a href="http://en.wikipedia.org/wiki/Lawrence,_Kansas">Lawrence</a>. I had the opportunity to be there and give a talk about some recent stuff I've been working on regarding digital prosopography and computer ontologies, so in this blog post I'm summing up a bit the things that caught my attention while at the conference.

The event happened on September 22-24 and consistend of three separate things: 

<li>Bootcamp Workshops: a set of in-depth workshops on digital tools and other DH topics <a href="http://kansas2011.thatcamp.org/bootcamps/">http://kansas2011.thatcamp.org/bootcamps/</a>.</li>

<li>THATCamp: an “unconference” for technologists and humanists <a href="http://kansas2011.thatcamp.org/">http://kansas2011.thatcamp.org/</a>.</li>

<li>Representing Knowledge in the DH conference: a one-day program of panels and poster sessions (<a href="https://docs.google.com/spreadsheet/pub?hl=en_US&key=0Ap2U716RmYD7dHdyR1RseWFvb0tOYzREZ1hpQWNUTkE&hl=en_US&gid=3">schedule</a> | <a href="http://kansas2011.thatcamp.org/category/representing-knowledge-conference/">abstracts</a> )</li>

The workshop and THATcamp were both packed with interesting stuff, so I strongly suggest you take a look at the online documentation, which is very comprehensive. In what follows I'll instead highlight some of the contributed papers which a) I liked and b) I was able to attend (needless to say, this list matches only my individual preference and interests). Hope you'll find something of interest there too!

<h2>A (quite subjective) list of interesting papers</h2>

<p>&nbsp;</p>

<li><strong>The Graphic Visualization of XML Documents</strong>, by <a href="http://clover.slavic.pitt.edu/~djb/">David Birnbaum</a> (<a href="http://kansas2011.thatcamp.org/07/21/the-graphic-visualization-of-xml-documents/"> abstract </a>): a quite inspiring example of how to employ visualizations in order to support philological research in the humanities. Mostly focused on Russian texts and XML-oriented technologies, but its principles easily generalizable to other contexts and technologies.</li>

<li><strong>Exploring Issues at the Intersection of Humanities and Computing with LADL</strong>, by <a href="http://www.gregoryaist.com/">Gregory Aist</a> (<a href="http://kansas2011.thatcamp.org/07/20/exploring-issues-at-the-intersection-of-humanities-and-computing-with-ladl/"> abstract </a>): the talk presented LADL, the Learning Activity Description Language, a fascinating software environment provides a way to "describe both the information structure and the interaction structure of an interactive experience", to the purpose of "constructing a single interactive Web page that allows for viewing and comparing of multiple source documents together with online tools".</li>

<li><strong>Making the most of free, unrestricted texts–a first look at the promise of the Text Creation Partnership</strong>, by <a href="http://www-personal.umich.edu/~rwelzenb/">Rebecca Welzenbach</a> (<a href="http://kansas2011.thatcamp.org/07/21/making-the-most-of-free-unrestricted-texts-a-first-look-at-the-promise-of-the-text-creation-partnership/"> abstract </a>): an interesting report on the pros and cons of making available a large repository of SGML/XML encoded texts from the Eighteenth Century Collections Online (<a href="http://gale.cengage.co.uk/product-highlights/history/eighteenth-century-collections-online.aspx">ECCO</a>) corpus.</li>

<li><strong>The hermeneutics of data representation</strong>, by <a href="http://www.w3.org/People/cmsmcq/">Michael Sperberg-McQueen</a> (<a href="http://kansas2011.thatcamp.org/07/21/the-hermeneutics-of-data-representation/"> abstract </a>): a speculative and challenging investigation of the assumptions at the root of any machine-readable representation of knowledge - and their cultural implications.</li>

<li><strong>Breaking the Historian’s Code: Finding Patterns of Historical Representation</strong>, by <a href="http://aeshin.org/">Ryan Shaw</a> (<a href="http://kansas2011.thatcamp.org/07/21/breaking-the-historian%E2%80%99s-code-finding-patterns-of-historical-representation/"> abstract </a>): an investigation on the usage of natural language processing techniques to the purpose of 'breaking down' the 'code' of historical narrative. In particular, the sets of documents used are related to the civil rights movement, and the specific NLP techniques being employed are named entity recognition, event extraction, and event chain mining.</li>

<li><strong>Employing Geospatial Genealogy to Reveal Residential and Kinship Patterns in a Pre-Holocaust Ukrainian Village</strong>, by <a href="http://www2.ku.edu/~geography/peoplepages/Egbert_S.shtml">Stephen Egbert</a>.(<a href="http://kansas2011.thatcamp.org/07/21/employing-geospatial-genealogy-to-reveal-residential-and-kinship-patterns-in-a-pre-holocaust-ukrainian-village/"> abstract </a>): this paper showed how it is possible to visualize residential and kinship patterns in the mixed-ethnic settlements of pre-Holocaust Eastern Europe by using geographic information systems (<a href="http://en.wikipedia.org/wiki/Geographic_information_system">GIS</a>), and how these results can provide useful materials for humanists to base their work on. 

<li><strong>Prosopography and Computer Ontologies: towards a formal representation of the ‘factoid’ model by means of CIDOC-CRM</strong>, by <a href="http://www.michelepasin.org/">me</a> and John Bradley (<a href="http://kansas2011.thatcamp.org/07/21/prosopography-and-computer-ontologies-towards-a-formal-representation-of-the-%e2%80%98factoid%e2%80%99-model-by-means-of-cidoc-crm/"> abstract </a>): this is the paper I presented (shameless self plug, I know). It's about the evolution of structured prosopography (= the 'study of people' in history) from a mostly single-application and database-oriented scenario towards a more interoperable and linked-data one. In particular, I talked about the recent efforts for representing the notion of 'factoids' (a conceptual model normally used in our prosopographies) using the ontological language provided by <a href="http://www.michelepasin.org/techblog/2010/08/30/kr-workshop-2-introducing-cidoc-crm-and-frbr-oo/">CIDOC-CRM</a> (a computational ontology commonly used in the museum community).</li>

<p>&nbsp;</p>

That's all! Any comments/further thoughts on such things?

<p>&nbsp;</p>]]></content:encoded>
			<wfw:commentRss>http://www.michelepasin.org/techblog/2011/09/28/event-thatcamp-kansas-and-digital-humanities-forum/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>First steps with Canvas and HTML5</title>
		<link>http://www.michelepasin.org/techblog/2011/08/25/first-steps-with-canvas-and-html5/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=first-steps-with-canvas-and-html5</link>
		<comments>http://www.michelepasin.org/techblog/2011/08/25/first-steps-with-canvas-and-html5/#comments</comments>
		<pubDate>Thu, 25 Aug 2011 14:47:35 +0000</pubDate>
		<dc:creator>mike</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[canvas]]></category>
		<category><![CDATA[drawing]]></category>
		<category><![CDATA[html5]]></category>

		<guid isPermaLink="false">http://www.michelepasin.org/techblog/?p=1503</guid>
		<description><![CDATA[I've been postponing experimenting with HTML5 for quite a while, so today I finally set aside a few hours to play with it. This is a very simple example of the graphic effects you can create using javascript and the HTML5 canvas element.. Note that the examples below will work only on HTML5-compatible browsers, such [...]]]></description>
			<content:encoded><![CDATA[<p>I've been postponing experimenting with <a href="http://en.wikipedia.org/wiki/HTML5">HTML5</a> for quite a while, so today I finally set aside a few hours to play with it. This is a very simple example of the graphic effects you can create using javascript and the HTML5 canvas element.. </p>

<p>Note that the examples below will work only on HTML5-compatible browsers, such as the latest versions of Chrome or Firefox..</p>


<h3>1. Setting up a canvas and drawing some lines on it.</h3> 

<p>This is easily done using the <em>moveTo</em> and <em>lineTo</em> functions. So let's create a simple symmetrical geometrical shape..</p>

<br />

<canvas id="myCanvas1" width="800" height="400" style="border:1px dashed #c3c3c3;">
Your browser does not support the canvas element.
</canvas>



<script type="text/javascript">

var c=document.getElementById("myCanvas1");
var cxt=c.getContext("2d");
var i=0;

for (i=1;i<=5;i++)
{
cxt.moveTo(0, 400);
cxt.lineTo(100, i * 40);
cxt.lineTo(300, i * 60);
cxt.lineTo(400, i * 30);
cxt.lineTo(500, i * 60);
cxt.lineTo(700, i * 40);
cxt.lineTo(800, 400);
}

cxt.stroke();

</script>





<br /><br />


<p>Here's the source code:</p>

<pre style='overflow:auto; color:#000020;background:#f6f8ff;'><span style='color:#004a43; '>&lt;!DOCTYPE HTML></span>
<span style='color:#0057a6; '>&lt;</span><span style='color:#200080; font-weight:bold; '>html</span><span style='color:#0057a6; '>></span>
<span style='color:#0057a6; '>&lt;</span><span style='color:#200080; font-weight:bold; '>body</span><span style='color:#0057a6; '>></span>

<span style='color:#0057a6; '>&lt;</span><span style='color:#333385; '>canvas</span><span style='color:#474796; '> </span><span style='color:#074726; '>id</span><span style='color:#308080; '>=</span><span style='color:#1060b6; '>"myCanvas1"</span><span style='color:#474796; '> </span><span style='color:#074726; '>width</span><span style='color:#308080; '>=</span><span style='color:#1060b6; '>"800"</span><span style='color:#474796; '> </span><span style='color:#074726; '>height</span><span style='color:#308080; '>=</span><span style='color:#1060b6; '>"400"</span><span style='color:#474796; '> </span><span style='color:#074726; '>style</span><span style='color:#308080; '>=</span><span style='color:#1060b6; '>"</span><span style='color:#7779bb; font-weight:bold; '>border</span><span style='color:#308080; '>:</span><span style='color:#008c00; '>1</span><span style='color:#006600; '>px</span><span style='color:#474796; '> </span><span style='color:#074726; '>dashed</span><span style='color:#474796; '> </span><span style='color:#008c00; '>#</span><span style='color:#008000; '>c3c3c3</span><span style='color:#406080; '>;</span><span style='color:#1060b6; '>"</span><span style='color:#0057a6; '>></span>
Your browser does not support the canvas element<span style='color:#008c00; '>.</span>
<span style='color:#0057a6; '>&lt;/</span><span style='color:#333385; '>canvas</span><span style='color:#0057a6; '>></span>

<span style='color:#0057a6; '>&lt;</span><span style='color:#200080; font-weight:bold; '>script type="text/javascript"</span><span style='color:#0057a6; '>></span>

<span style='color:#200080; font-weight:bold; '>var</span> c<span style='color:#308080; '>=</span>document<span style='color:#308080; '>.</span>getElementById<span style='color:#308080; '>(</span><span style='color:#1060b6; '>"myCanvas1"</span><span style='color:#308080; '>)</span><span style='color:#406080; '>;</span>
<span style='color:#200080; font-weight:bold; '>var</span> cxt<span style='color:#308080; '>=</span>c<span style='color:#308080; '>.</span>getContext<span style='color:#308080; '>(</span><span style='color:#1060b6; '>"2d"</span><span style='color:#308080; '>)</span><span style='color:#406080; '>;</span>
<span style='color:#200080; font-weight:bold; '>var</span> i<span style='color:#308080; '>=</span><span style='color:#008c00; '>0</span><span style='color:#406080; '>;</span>

<span style='color:#200080; font-weight:bold; '>for</span> <span style='color:#308080; '>(</span>i<span style='color:#308080; '>=</span><span style='color:#008c00; '>1</span><span style='color:#406080; '>;</span>i<span style='color:#308080; '>&lt;=</span><span style='color:#008c00; '>5</span><span style='color:#406080; '>;</span>i<span style='color:#308080; '>++</span><span style='color:#308080; '>)</span>
<span style='color:#406080; '>{</span>
cxt<span style='color:#308080; '>.</span>moveTo<span style='color:#308080; '>(</span><span style='color:#008c00; '>0</span><span style='color:#308080; '>,</span> <span style='color:#008c00; '>400</span><span style='color:#308080; '>)</span><span style='color:#406080; '>;</span>
cxt<span style='color:#308080; '>.</span>lineTo<span style='color:#308080; '>(</span><span style='color:#008c00; '>100</span><span style='color:#308080; '>,</span> i <span style='color:#308080; '>*</span> <span style='color:#008c00; '>40</span><span style='color:#308080; '>)</span><span style='color:#406080; '>;</span>
cxt<span style='color:#308080; '>.</span>lineTo<span style='color:#308080; '>(</span><span style='color:#008c00; '>300</span><span style='color:#308080; '>,</span> i <span style='color:#308080; '>*</span> <span style='color:#008c00; '>60</span><span style='color:#308080; '>)</span><span style='color:#406080; '>;</span>
cxt<span style='color:#308080; '>.</span>lineTo<span style='color:#308080; '>(</span><span style='color:#008c00; '>400</span><span style='color:#308080; '>,</span> i <span style='color:#308080; '>*</span> <span style='color:#008c00; '>30</span><span style='color:#308080; '>)</span><span style='color:#406080; '>;</span>
cxt<span style='color:#308080; '>.</span>lineTo<span style='color:#308080; '>(</span><span style='color:#008c00; '>500</span><span style='color:#308080; '>,</span> i <span style='color:#308080; '>*</span> <span style='color:#008c00; '>60</span><span style='color:#308080; '>)</span><span style='color:#406080; '>;</span>
cxt<span style='color:#308080; '>.</span>lineTo<span style='color:#308080; '>(</span><span style='color:#008c00; '>700</span><span style='color:#308080; '>,</span> i <span style='color:#308080; '>*</span> <span style='color:#008c00; '>40</span><span style='color:#308080; '>)</span><span style='color:#406080; '>;</span>
cxt<span style='color:#308080; '>.</span>lineTo<span style='color:#308080; '>(</span><span style='color:#008c00; '>800</span><span style='color:#308080; '>,</span> <span style='color:#008c00; '>400</span><span style='color:#308080; '>)</span><span style='color:#406080; '>;</span>
<span style='color:#406080; '>}</span>

cxt<span style='color:#308080; '>.</span>stroke<span style='color:#308080; '>(</span><span style='color:#308080; '>)</span><span style='color:#406080; '>;</span>

<span style='color:#0057a6; '>&lt;/</span><span style='color:#200080; font-weight:bold; '>script</span><span style='color:#0057a6; '>></span>

<span style='color:#0057a6; '>&lt;/</span><span style='color:#200080; font-weight:bold; '>body</span><span style='color:#0057a6; '>></span>
<span style='color:#0057a6; '>&lt;/</span><span style='color:#200080; font-weight:bold; '>html</span><span style='color:#0057a6; '>></span>
</pre>

<p>&nbsp;</p>

<h3>2. Creating a mirroring effect</h3>

<p>Now we can increase the size of the canvas to 800 and replicate these lines at the bottom of the canvas so to achieve a 'mirroring' effect.. since we know the max Y value of the canvas (800), let's just add another loop that draws the same lines but <em>inverts</em> the Y position. This is easily achieved by subtracting the constant-dependent parameter from the max value of Y.</p>

<br />

<canvas id="myCanvas2" width="800" height="800" style="border:1px dashed #c3c3c3;">
Your browser does not support the canvas element.
</canvas>



<script type="text/javascript">

var c=document.getElementById("myCanvas2");
var cxt=c.getContext("2d");
var i=0;

for (i=1;i<=5;i++)
{
cxt.moveTo(0, 400);
cxt.lineTo(100, i * 40);
cxt.lineTo(300, i * 60);
cxt.lineTo(400, i * 30);
cxt.lineTo(500, i * 60);
cxt.lineTo(700, i * 40);
cxt.lineTo(800, 400);
}


for (i=5;i>=1;i--)
{
cxt.moveTo(0, 400);
cxt.lineTo(100, 800 - (i * 40));
cxt.lineTo(300, 800 - (i * 60));
cxt.lineTo(400, 800 - (i * 30));
cxt.lineTo(500, 800 - (i * 60));
cxt.lineTo(700, 800 - (i * 40));
cxt.lineTo(800, 400);
}

cxt.stroke();

</script>



<br /><br />

<p>This is how the new source code looks like:</p>

<pre style='overflow: auto; color:#000020;background:#f6f8ff;'><span style='color:#0057a6; '>&lt;</span><span style='color:#333385; '>canvas</span><span style='color:#474796; '> </span><span style='color:#074726; '>id</span><span style='color:#308080; '>=</span><span style='color:#1060b6; '>"myCanvas2"</span><span style='color:#474796; '> </span><span style='color:#074726; '>width</span><span style='color:#308080; '>=</span><span style='color:#1060b6; '>"800"</span><span style='color:#474796; '> </span><span style='color:#074726; '>height</span><span style='color:#308080; '>=</span><span style='color:#1060b6; '>"800"</span><span style='color:#474796; '> </span><span style='color:#074726; '>style</span><span style='color:#308080; '>=</span><span style='color:#1060b6; '>"</span><span style='color:#7779bb; font-weight:bold; '>border</span><span style='color:#308080; '>:</span><span style='color:#008c00; '>1</span><span style='color:#006600; '>px</span><span style='color:#474796; '> </span><span style='color:#074726; '>dashed</span><span style='color:#474796; '> </span><span style='color:#008c00; '>#</span><span style='color:#008000; '>c3c3c3</span><span style='color:#406080; '>;</span><span style='color:#1060b6; '>"</span><span style='color:#0057a6; '>></span>
Your browser does not support the canvas element<span style='color:#008c00; '>.</span>
<span style='color:#0057a6; '>&lt;/</span><span style='color:#333385; '>canvas</span><span style='color:#0057a6; '>></span>

<span style='color:#0057a6; '>&lt;</span><span style='color:#200080; font-weight:bold; '>script type="text/javascript"</span><span style='color:#0057a6; '>></span>

<span style='color:#200080; font-weight:bold; '>var</span> c<span style='color:#308080; '>=</span>document<span style='color:#308080; '>.</span>getElementById<span style='color:#308080; '>(</span><span style='color:#1060b6; '>"myCanvas2"</span><span style='color:#308080; '>)</span><span style='color:#406080; '>;</span>
<span style='color:#200080; font-weight:bold; '>var</span> cxt<span style='color:#308080; '>=</span>c<span style='color:#308080; '>.</span>getContext<span style='color:#308080; '>(</span><span style='color:#1060b6; '>"2d"</span><span style='color:#308080; '>)</span><span style='color:#406080; '>;</span>
<span style='color:#200080; font-weight:bold; '>var</span> i<span style='color:#308080; '>=</span><span style='color:#008c00; '>0</span><span style='color:#406080; '>;</span>

<span style='color:#200080; font-weight:bold; '>for</span> <span style='color:#308080; '>(</span>i<span style='color:#308080; '>=</span><span style='color:#008c00; '>1</span><span style='color:#406080; '>;</span>i<span style='color:#308080; '>&lt;=</span><span style='color:#008c00; '>5</span><span style='color:#406080; '>;</span>i<span style='color:#308080; '>++</span><span style='color:#308080; '>)</span>
<span style='color:#406080; '>{</span>
cxt<span style='color:#308080; '>.</span>moveTo<span style='color:#308080; '>(</span><span style='color:#008c00; '>0</span><span style='color:#308080; '>,</span> <span style='color:#008c00; '>400</span><span style='color:#308080; '>)</span><span style='color:#406080; '>;</span>
cxt<span style='color:#308080; '>.</span>lineTo<span style='color:#308080; '>(</span><span style='color:#008c00; '>100</span><span style='color:#308080; '>,</span> i <span style='color:#308080; '>*</span> <span style='color:#008c00; '>40</span><span style='color:#308080; '>)</span><span style='color:#406080; '>;</span>
cxt<span style='color:#308080; '>.</span>lineTo<span style='color:#308080; '>(</span><span style='color:#008c00; '>300</span><span style='color:#308080; '>,</span> i <span style='color:#308080; '>*</span> <span style='color:#008c00; '>60</span><span style='color:#308080; '>)</span><span style='color:#406080; '>;</span>
cxt<span style='color:#308080; '>.</span>lineTo<span style='color:#308080; '>(</span><span style='color:#008c00; '>400</span><span style='color:#308080; '>,</span> i <span style='color:#308080; '>*</span> <span style='color:#008c00; '>30</span><span style='color:#308080; '>)</span><span style='color:#406080; '>;</span>
cxt<span style='color:#308080; '>.</span>lineTo<span style='color:#308080; '>(</span><span style='color:#008c00; '>500</span><span style='color:#308080; '>,</span> i <span style='color:#308080; '>*</span> <span style='color:#008c00; '>60</span><span style='color:#308080; '>)</span><span style='color:#406080; '>;</span>
cxt<span style='color:#308080; '>.</span>lineTo<span style='color:#308080; '>(</span><span style='color:#008c00; '>700</span><span style='color:#308080; '>,</span> i <span style='color:#308080; '>*</span> <span style='color:#008c00; '>40</span><span style='color:#308080; '>)</span><span style='color:#406080; '>;</span>
cxt<span style='color:#308080; '>.</span>lineTo<span style='color:#308080; '>(</span><span style='color:#008c00; '>800</span><span style='color:#308080; '>,</span> <span style='color:#008c00; '>400</span><span style='color:#308080; '>)</span><span style='color:#406080; '>;</span>
<span style='color:#406080; '>}</span>


<span style='color:#200080; font-weight:bold; '>for</span> <span style='color:#308080; '>(</span>i<span style='color:#308080; '>=</span><span style='color:#008c00; '>5</span><span style='color:#406080; '>;</span>i<span style='color:#308080; '>>=</span><span style='color:#008c00; '>1</span><span style='color:#406080; '>;</span>i<span style='color:#308080; '>--</span><span style='color:#308080; '>)</span>
<span style='color:#406080; '>{</span>
cxt<span style='color:#308080; '>.</span>moveTo<span style='color:#308080; '>(</span><span style='color:#008c00; '>0</span><span style='color:#308080; '>,</span> <span style='color:#008c00; '>400</span><span style='color:#308080; '>)</span><span style='color:#406080; '>;</span>
cxt<span style='color:#308080; '>.</span>lineTo<span style='color:#308080; '>(</span><span style='color:#008c00; '>100</span><span style='color:#308080; '>,</span> <span style='color:#008c00; '>800</span> <span style='color:#308080; '>-</span> <span style='color:#308080; '>(</span>i <span style='color:#308080; '>*</span> <span style='color:#008c00; '>40</span><span style='color:#308080; '>)</span><span style='color:#308080; '>)</span><span style='color:#406080; '>;</span>
cxt<span style='color:#308080; '>.</span>lineTo<span style='color:#308080; '>(</span><span style='color:#008c00; '>300</span><span style='color:#308080; '>,</span> <span style='color:#008c00; '>800</span> <span style='color:#308080; '>-</span> <span style='color:#308080; '>(</span>i <span style='color:#308080; '>*</span> <span style='color:#008c00; '>60</span><span style='color:#308080; '>)</span><span style='color:#308080; '>)</span><span style='color:#406080; '>;</span>
cxt<span style='color:#308080; '>.</span>lineTo<span style='color:#308080; '>(</span><span style='color:#008c00; '>400</span><span style='color:#308080; '>,</span> <span style='color:#008c00; '>800</span> <span style='color:#308080; '>-</span> <span style='color:#308080; '>(</span>i <span style='color:#308080; '>*</span> <span style='color:#008c00; '>30</span><span style='color:#308080; '>)</span><span style='color:#308080; '>)</span><span style='color:#406080; '>;</span>
cxt<span style='color:#308080; '>.</span>lineTo<span style='color:#308080; '>(</span><span style='color:#008c00; '>500</span><span style='color:#308080; '>,</span> <span style='color:#008c00; '>800</span> <span style='color:#308080; '>-</span> <span style='color:#308080; '>(</span>i <span style='color:#308080; '>*</span> <span style='color:#008c00; '>60</span><span style='color:#308080; '>)</span><span style='color:#308080; '>)</span><span style='color:#406080; '>;</span>
cxt<span style='color:#308080; '>.</span>lineTo<span style='color:#308080; '>(</span><span style='color:#008c00; '>700</span><span style='color:#308080; '>,</span> <span style='color:#008c00; '>800</span> <span style='color:#308080; '>-</span> <span style='color:#308080; '>(</span>i <span style='color:#308080; '>*</span> <span style='color:#008c00; '>40</span><span style='color:#308080; '>)</span><span style='color:#308080; '>)</span><span style='color:#406080; '>;</span>
cxt<span style='color:#308080; '>.</span>lineTo<span style='color:#308080; '>(</span><span style='color:#008c00; '>800</span><span style='color:#308080; '>,</span> <span style='color:#008c00; '>400</span><span style='color:#308080; '>)</span><span style='color:#406080; '>;</span>
<span style='color:#406080; '>}</span>

cxt<span style='color:#308080; '>.</span>stroke<span style='color:#308080; '>(</span><span style='color:#308080; '>)</span><span style='color:#406080; '>;</span>

<span style='color:#0057a6; '>&lt;/</span><span style='color:#200080; font-weight:bold; '>script</span><span style='color:#0057a6; '>></span>
</pre>


<p>&nbsp;</p>

<h3>3. Adding more graphical interest</h3>

<p>Finally, let's parametrize a bit more the construction of this geometrical pattern by including everything into another loop, and using this new counter to increment the points ordinate position. We'll add a new variable y and use it to run the external loop 20 times. Here's the result:</p>


<br />

<canvas id="myCanvas3" width="800" height="800" style="border:1px dashed #c3c3c3;">
Your browser does not support the canvas element.
</canvas>



<script type="text/javascript">

var c=document.getElementById("myCanvas3");
var cxt=c.getContext("2d");
var i=0;
var y=0;

for (y=1;y<=20;y++)
{
	
	for (i=1;i<=5;i++)
	{
	cxt.moveTo(0, 400+y);
	cxt.lineTo(100, i * (40+y));
	cxt.lineTo(300, i * (60+y));
	cxt.lineTo(400, i * (30+y));
    cxt.lineTo(500, i * (60+y));
	cxt.lineTo(700, i * (40+y));
	cxt.lineTo(800, 400+y);
	}


	for (i=5;i>=1;i--)
	{
	cxt.moveTo(0, 400);
	cxt.lineTo(100, 800 - (i * (40+y)));
	cxt.lineTo(300, 800 - (i * (60+y)));
	cxt.lineTo(400, 800 - (i * (30+y)));
	cxt.lineTo(500, 800 - (i * (60+y)));
	cxt.lineTo(700, 800 - (i * (40+y)));
	cxt.lineTo(800, 400+y);
	}

}

cxt.stroke();

</script>



<br /><br />

<p>Not too bad uh? This last modification to the code looks like this:</p>


<pre style='overflow:auto; color:#000020;background:#f6f8ff;'><span style='color:#0057a6; '>&lt;</span><span style='color:#333385; '>canvas</span><span style='color:#474796; '> </span><span style='color:#074726; '>id</span><span style='color:#308080; '>=</span><span style='color:#1060b6; '>"myCanvas3"</span><span style='color:#474796; '> </span><span style='color:#074726; '>width</span><span style='color:#308080; '>=</span><span style='color:#1060b6; '>"800"</span><span style='color:#474796; '> </span><span style='color:#074726; '>height</span><span style='color:#308080; '>=</span><span style='color:#1060b6; '>"800"</span><span style='color:#474796; '> </span><span style='color:#074726; '>style</span><span style='color:#308080; '>=</span><span style='color:#1060b6; '>"</span><span style='color:#7779bb; font-weight:bold; '>border</span><span style='color:#308080; '>:</span><span style='color:#008c00; '>1</span><span style='color:#006600; '>px</span><span style='color:#474796; '> </span><span style='color:#074726; '>dashed</span><span style='color:#474796; '> </span><span style='color:#008c00; '>#</span><span style='color:#008000; '>c3c3c3</span><span style='color:#406080; '>;</span><span style='color:#1060b6; '>"</span><span style='color:#0057a6; '>></span>
Your browser does not support the canvas element<span style='color:#008c00; '>.</span>
<span style='color:#0057a6; '>&lt;/</span><span style='color:#333385; '>canvas</span><span style='color:#0057a6; '>></span>

<span style='color:#0057a6; '>&lt;</span><span style='color:#200080; font-weight:bold; '>script type="text/javascript"</span><span style='color:#0057a6; '>></span>

<span style='color:#200080; font-weight:bold; '>var</span> c<span style='color:#308080; '>=</span>document<span style='color:#308080; '>.</span>getElementById<span style='color:#308080; '>(</span><span style='color:#1060b6; '>"myCanvas3"</span><span style='color:#308080; '>)</span><span style='color:#406080; '>;</span>
<span style='color:#200080; font-weight:bold; '>var</span> cxt<span style='color:#308080; '>=</span>c<span style='color:#308080; '>.</span>getContext<span style='color:#308080; '>(</span><span style='color:#1060b6; '>"2d"</span><span style='color:#308080; '>)</span><span style='color:#406080; '>;</span>
<span style='color:#200080; font-weight:bold; '>var</span> i<span style='color:#308080; '>=</span><span style='color:#008c00; '>0</span><span style='color:#406080; '>;</span>
<span style='color:#200080; font-weight:bold; '>var</span> y<span style='color:#308080; '>=</span><span style='color:#008c00; '>0</span><span style='color:#406080; '>;</span>

<span style='color:#200080; font-weight:bold; '>for</span> <span style='color:#308080; '>(</span>y<span style='color:#308080; '>=</span><span style='color:#008c00; '>1</span><span style='color:#406080; '>;</span>y<span style='color:#308080; '>&lt;=</span><span style='color:#008c00; '>20</span><span style='color:#406080; '>;</span>y<span style='color:#308080; '>++</span><span style='color:#308080; '>)</span>
<span style='color:#406080; '>{</span>
    
    <span style='color:#200080; font-weight:bold; '>for</span> <span style='color:#308080; '>(</span>i<span style='color:#308080; '>=</span><span style='color:#008c00; '>1</span><span style='color:#406080; '>;</span>i<span style='color:#308080; '>&lt;=</span><span style='color:#008c00; '>5</span><span style='color:#406080; '>;</span>i<span style='color:#308080; '>++</span><span style='color:#308080; '>)</span>
    <span style='color:#406080; '>{</span>
    cxt<span style='color:#308080; '>.</span>moveTo<span style='color:#308080; '>(</span><span style='color:#008c00; '>0</span><span style='color:#308080; '>,</span> <span style='color:#008c00; '>400</span><span style='color:#308080; '>+</span>y<span style='color:#308080; '>)</span><span style='color:#406080; '>;</span>
    cxt<span style='color:#308080; '>.</span>lineTo<span style='color:#308080; '>(</span><span style='color:#008c00; '>100</span><span style='color:#308080; '>,</span> i <span style='color:#308080; '>*</span> <span style='color:#308080; '>(</span><span style='color:#008c00; '>40</span><span style='color:#308080; '>+</span>y<span style='color:#308080; '>)</span><span style='color:#308080; '>)</span><span style='color:#406080; '>;</span>
    cxt<span style='color:#308080; '>.</span>lineTo<span style='color:#308080; '>(</span><span style='color:#008c00; '>300</span><span style='color:#308080; '>,</span> i <span style='color:#308080; '>*</span> <span style='color:#308080; '>(</span><span style='color:#008c00; '>60</span><span style='color:#308080; '>+</span>y<span style='color:#308080; '>)</span><span style='color:#308080; '>)</span><span style='color:#406080; '>;</span>
    cxt<span style='color:#308080; '>.</span>lineTo<span style='color:#308080; '>(</span><span style='color:#008c00; '>400</span><span style='color:#308080; '>,</span> i <span style='color:#308080; '>*</span> <span style='color:#308080; '>(</span><span style='color:#008c00; '>30</span><span style='color:#308080; '>+</span>y<span style='color:#308080; '>)</span><span style='color:#308080; '>)</span><span style='color:#406080; '>;</span>
    cxt<span style='color:#308080; '>.</span>lineTo<span style='color:#308080; '>(</span><span style='color:#008c00; '>500</span><span style='color:#308080; '>,</span> i <span style='color:#308080; '>*</span> <span style='color:#308080; '>(</span><span style='color:#008c00; '>60</span><span style='color:#308080; '>+</span>y<span style='color:#308080; '>)</span><span style='color:#308080; '>)</span><span style='color:#406080; '>;</span>
    cxt<span style='color:#308080; '>.</span>lineTo<span style='color:#308080; '>(</span><span style='color:#008c00; '>700</span><span style='color:#308080; '>,</span> i <span style='color:#308080; '>*</span> <span style='color:#308080; '>(</span><span style='color:#008c00; '>40</span><span style='color:#308080; '>+</span>y<span style='color:#308080; '>)</span><span style='color:#308080; '>)</span><span style='color:#406080; '>;</span>
    cxt<span style='color:#308080; '>.</span>lineTo<span style='color:#308080; '>(</span><span style='color:#008c00; '>800</span><span style='color:#308080; '>,</span> <span style='color:#008c00; '>400</span><span style='color:#308080; '>+</span>y<span style='color:#308080; '>)</span><span style='color:#406080; '>;</span>
    <span style='color:#406080; '>}</span>


    <span style='color:#200080; font-weight:bold; '>for</span> <span style='color:#308080; '>(</span>i<span style='color:#308080; '>=</span><span style='color:#008c00; '>5</span><span style='color:#406080; '>;</span>i<span style='color:#308080; '>>=</span><span style='color:#008c00; '>1</span><span style='color:#406080; '>;</span>i<span style='color:#308080; '>--</span><span style='color:#308080; '>)</span>
    <span style='color:#406080; '>{</span>
    cxt<span style='color:#308080; '>.</span>moveTo<span style='color:#308080; '>(</span><span style='color:#008c00; '>0</span><span style='color:#308080; '>,</span> <span style='color:#008c00; '>400</span><span style='color:#308080; '>)</span><span style='color:#406080; '>;</span>
    cxt<span style='color:#308080; '>.</span>lineTo<span style='color:#308080; '>(</span><span style='color:#008c00; '>100</span><span style='color:#308080; '>,</span> <span style='color:#008c00; '>800</span> <span style='color:#308080; '>-</span> <span style='color:#308080; '>(</span>i <span style='color:#308080; '>*</span> <span style='color:#308080; '>(</span><span style='color:#008c00; '>40</span><span style='color:#308080; '>+</span>y<span style='color:#308080; '>)</span><span style='color:#308080; '>)</span><span style='color:#308080; '>)</span><span style='color:#406080; '>;</span>
    cxt<span style='color:#308080; '>.</span>lineTo<span style='color:#308080; '>(</span><span style='color:#008c00; '>300</span><span style='color:#308080; '>,</span> <span style='color:#008c00; '>800</span> <span style='color:#308080; '>-</span> <span style='color:#308080; '>(</span>i <span style='color:#308080; '>*</span> <span style='color:#308080; '>(</span><span style='color:#008c00; '>60</span><span style='color:#308080; '>+</span>y<span style='color:#308080; '>)</span><span style='color:#308080; '>)</span><span style='color:#308080; '>)</span><span style='color:#406080; '>;</span>
    cxt<span style='color:#308080; '>.</span>lineTo<span style='color:#308080; '>(</span><span style='color:#008c00; '>400</span><span style='color:#308080; '>,</span> <span style='color:#008c00; '>800</span> <span style='color:#308080; '>-</span> <span style='color:#308080; '>(</span>i <span style='color:#308080; '>*</span> <span style='color:#308080; '>(</span><span style='color:#008c00; '>30</span><span style='color:#308080; '>+</span>y<span style='color:#308080; '>)</span><span style='color:#308080; '>)</span><span style='color:#308080; '>)</span><span style='color:#406080; '>;</span>
    cxt<span style='color:#308080; '>.</span>lineTo<span style='color:#308080; '>(</span><span style='color:#008c00; '>500</span><span style='color:#308080; '>,</span> <span style='color:#008c00; '>800</span> <span style='color:#308080; '>-</span> <span style='color:#308080; '>(</span>i <span style='color:#308080; '>*</span> <span style='color:#308080; '>(</span><span style='color:#008c00; '>60</span><span style='color:#308080; '>+</span>y<span style='color:#308080; '>)</span><span style='color:#308080; '>)</span><span style='color:#308080; '>)</span><span style='color:#406080; '>;</span>
    cxt<span style='color:#308080; '>.</span>lineTo<span style='color:#308080; '>(</span><span style='color:#008c00; '>700</span><span style='color:#308080; '>,</span> <span style='color:#008c00; '>800</span> <span style='color:#308080; '>-</span> <span style='color:#308080; '>(</span>i <span style='color:#308080; '>*</span> <span style='color:#308080; '>(</span><span style='color:#008c00; '>40</span><span style='color:#308080; '>+</span>y<span style='color:#308080; '>)</span><span style='color:#308080; '>)</span><span style='color:#308080; '>)</span><span style='color:#406080; '>;</span>
    cxt<span style='color:#308080; '>.</span>lineTo<span style='color:#308080; '>(</span><span style='color:#008c00; '>800</span><span style='color:#308080; '>,</span> <span style='color:#008c00; '>400</span><span style='color:#308080; '>+</span>y<span style='color:#308080; '>)</span><span style='color:#406080; '>;</span>
    <span style='color:#406080; '>}</span>

<span style='color:#406080; '>}</span>

cxt<span style='color:#308080; '>.</span>stroke<span style='color:#308080; '>(</span><span style='color:#308080; '>)</span><span style='color:#406080; '>;</span>

<span style='color:#0057a6; '>&lt;/</span><span style='color:#200080; font-weight:bold; '>script</span><span style='color:#0057a6; '>></span>
</pre>

<p>&nbsp;</p>


<h3>Cool! I'd like to know more..</h3>

<p>Yes, I agree. This opens up a new world for web-based graphics.. and I just scratched the surface of it! In particular I'd like to see how this type of graphical components can be used to compose visualizations in the digital humanities - provided more interactivity is added to them.

Here are a couple if learning resources I found useful:</p>

<li><a href="http://www.netmagazine.com/tutorials/learning-basics-html5-canvas">Learning the basics of HTML5</a> canvas on .Net magazine online</li>
<li><a href="https://developer.mozilla.org/en/canvas_tutorial">Canvas tutorial</a> on Mozilla.org (more advanced)</li>
<li><a href="http://ajaxpatterns.org/Javascript_Graphics_and_Effects_Frameworks">Javascript Graphics and Effects Frameworks</a>: useful document providing a list of the most common libraries for doing javascript-based graphics</li>
<li><a href="http://billmill.org/static/canvastutorial/index.html">Canvas and interactivity tutorial</a>: a step by step discussion on how to create a 'breakout' game clone that you can play in your browser, using javascript and the canvas element</li>
<li><a href="http://dev.opera.com/articles/view/html5-canvas-painting/">Creating an HTML 5 canvas painting application</a>: nice tutorial that shows how to put together several canvas drawing techniques so to build a basic 'painting' application</li>
<li><a href="http://net.tutsplus.com/articles/web-roundups/21-ridiculously-impressive-html5-canvas-experiments/">21 Ridiculously Impressive HTML5 Canvas Experiments</a>: a collection of some state-of-the-art HTML5 canvas-based experiments that will make you say, “Wow!”</li>


<p>&nbsp;</p><p>&nbsp;</p>]]></content:encoded>
			<wfw:commentRss>http://www.michelepasin.org/techblog/2011/08/25/first-steps-with-canvas-and-html5/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Inspecting an ontology with RDFLib</title>
		<link>http://www.michelepasin.org/techblog/2011/07/18/inspecting-an-ontology-with-rdflib/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=inspecting-an-ontology-with-rdflib</link>
		<comments>http://www.michelepasin.org/techblog/2011/07/18/inspecting-an-ontology-with-rdflib/#comments</comments>
		<pubDate>Mon, 18 Jul 2011 14:59:05 +0000</pubDate>
		<dc:creator>mike</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[semanticWeb]]></category>
		<category><![CDATA[ontology]]></category>
		<category><![CDATA[owl]]></category>
		<category><![CDATA[rdf]]></category>
		<category><![CDATA[rdflib]]></category>

		<guid isPermaLink="false">http://www.michelepasin.org/techblog/?p=1261</guid>
		<description><![CDATA[RDFLib (homepage) is a pretty solid and comprehensive rdf-programming kit for Python. In a previous post I already discussed what pythonic options are currently available out there for doing semantic web programming; after some more in depth testing I realized that Rdflib is the most accessible and complete of them all (in fact many of [...]]]></description>
			<content:encoded><![CDATA[RDFLib (<a href="http://www.rdflib.net/">homepage</a>) is a pretty solid and comprehensive rdf-programming kit for Python. In a <a href="http://www.michelepasin.org/techblog/2011/02/24/survey-of-pythonic-tools-for-rdf-and-linked-data-programming/">previous post</a> I already discussed what pythonic options are currently available out there for doing semantic web programming; after some more in depth testing I realized that Rdflib is the most accessible and complete of them all (in fact many of the available libraries are based on Rdflib's APIs). So.. here we go: in this post I'm giving an overview of some of the things you can do with this library. 

The <a href="http://linkeddata.org/">Linked Data</a> world is <em>primarily</em> made up of <a href="http://en.wikipedia.org/wiki/Resource_Description_Framework">RDF</a>, many would say, so the most important thing is being able to parse and extract information from this simple but versatile language. A quite well known mantra in this community is the '<a href="http://www.cs.rpi.edu/~hendler/LittleSemanticsWeb.html">a little semantics goes a long way</a>', which expresses succinctly the idea that there's no need to fixate on the construction of large-scale <a href="http://en.wikipedia.org/wiki/Cyc">CYC</a>-like knowledge-based systems in order to get something going in an open-world scenario such as the web (of data). 

In other words, this idea suggests that (for now) it's enough to make your application spit out structured data using a standard data model (RDF, that is), and possibly connect your RDF dataset to other datasets in the '<a href="http://richard.cyganiak.de/2007/10/lod/">cloud</a>' by creating <a href="http://linkeddatabook.com/editions/1.0/#htoc18">rdf-links</a>. Once you've done that, you can take it easy and stop worrying about the data integration problems your RDF might generate, or the 'big picture'. Others will figure out how to use your data; <strong>it's an incremental approach</strong>, there will be some sort of snowball effect at some stage, semantic web enthusiasts seem to suggest. This and other arguments are a bit make-believe, I have to say; but at the same time they also do make some sense: unless we have some real stuff to play with out there on the data-web, not much will <em>ever</em> happen!

<h3>Hullo, RDFlib</h3>

After quickly ascertaining that it's not a total waste of time to work with RDF, it's now time to get practical and experiment a bit with RDFlib. This is a great python library for it lets you process RDF data <em>very very easily</em>. Example: 

<pre><div class="python" style="overflow:auto; line-height: 1.5; height: 450px; font-size: 14px; font-family:monospace; color: #006; border: 1px solid #d0d0d0; background-color: #f0f0f0;"><span style="color: #808080; font-style: italic;"># open a graph</span><br />
<span style="color: #66cc66;">&gt;&gt;&gt;</span> <span style="color: #ff7700;font-weight:bold;">import</span> rdflib<br />
<span style="color: #66cc66;">&gt;&gt;&gt;</span> graph = rdflib.<span style="color: black;">Graph</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
<br />
<span style="color: #808080; font-style: italic;"># load some data</span><br />
<span style="color: #66cc66;">&gt;&gt;&gt;</span> graph.<span style="color: black;">parse</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'http://dbpedia.org/resource/Semantic_Web'</span><span style="color: black;">&#41;</span><br />
<span style="color: #66cc66;">&lt;</span>Graph identifier=pDZkOGzl0 <span style="color: black;">&#40;</span><span style="color: #66cc66;">&lt;</span>class <span style="color: #483d8b;">'rdflib.graph.Graph'</span><span style="color: #66cc66;">&gt;</span><span style="color: black;">&#41;</span><span style="color: #66cc66;">&gt;</span><br />
<span style="color: #66cc66;">&gt;&gt;&gt;</span> <span style="color: #008000;">len</span><span style="color: black;">&#40;</span>graph<span style="color: black;">&#41;</span><br />
<span style="color: #ff4500;">98</span><br />
<br />
<span style="color: #808080; font-style: italic;"># query the data</span><br />
<span style="color: #66cc66;">&gt;&gt;&gt;</span> <span style="color: #008000;">list</span><span style="color: black;">&#40;</span>graph<span style="color: black;">&#41;</span><span style="color: black;">&#91;</span>:<span style="color: #ff4500;">10</span><span style="color: black;">&#93;</span><br />
<span style="color: black;">&#91;</span><span style="color: black;">&#40;</span>rdflib.<span style="color: black;">term</span>.<span style="color: black;">URIRef</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'http://dbpedia.org/resource/SUPER'</span><span style="color: black;">&#41;</span>, rdflib.<span style="color: black;">term</span>.<span style="color: black;">URIRef</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'http://dbpedia.org/property/keywords'</span><span style="color: black;">&#41;</span>, rdflib.<span style="color: black;">term</span>.<span style="color: black;">URIRef</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'http://dbpedia.org/resource/Semantic_Web'</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>, <span style="color: black;">&#40;</span>rdflib.<span style="color: black;">term</span>.<span style="color: black;">URIRef</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'http://dbpedia.org/resource/Semantic_internet'</span><span style="color: black;">&#41;</span>, rdflib.<span style="color: black;">term</span>.<span style="color: black;">URIRef</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'http://dbpedia.org/ontology/wikiPageRedirects'</span><span style="color: black;">&#41;</span>, rdflib.<span style="color: black;">term</span>.<span style="color: black;">URIRef</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'http://dbpedia.org/resource/Semantic_Web'</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>, <span style="color: black;">&#40;</span>rdflib.<span style="color: black;">term</span>.<span style="color: black;">URIRef</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'http://dbpedia.org/resource/SW'</span><span style="color: black;">&#41;</span>, rdflib.<span style="color: black;">term</span>.<span style="color: black;">URIRef</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'http://dbpedia.org/ontology/wikiPageDisambiguates'</span><span style="color: black;">&#41;</span>, rdflib.<span style="color: black;">term</span>.<span style="color: black;">URIRef</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'http://dbpedia.org/resource/Semantic_Web'</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>, <span style="color: black;">&#40;</span>rdflib.<span style="color: black;">term</span>.<span style="color: black;">URIRef</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'http://dbpedia.org/resource/Semantic_integrity'</span><span style="color: black;">&#41;</span>, rdflib.<span style="color: black;">term</span>.<span style="color: black;">URIRef</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'http://dbpedia.org/ontology/wikiPageRedirects'</span><span style="color: black;">&#41;</span>, rdflib.<span style="color: black;">term</span>.<span style="color: black;">URIRef</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'http://dbpedia.org/resource/Semantic_Web'</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>, <span style="color: black;">&#40;</span>rdflib.<span style="color: black;">term</span>.<span style="color: black;">URIRef</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'http://dbpedia.org/resource/Ontotext'</span><span style="color: black;">&#41;</span>, rdflib.<span style="color: black;">term</span>.<span style="color: black;">URIRef</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'http://dbpedia.org/ontology/industry'</span><span style="color: black;">&#41;</span>, rdflib.<span style="color: black;">term</span>.<span style="color: black;">URIRef</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'http://dbpedia.org/resource/Semantic_Web'</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>, <span style="color: black;">&#40;</span>rdflib.<span style="color: black;">term</span>.<span style="color: black;">URIRef</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'http://mpii.de/yago/resource/Semantic_Web'</span><span style="color: black;">&#41;</span>, rdflib.<span style="color: black;">term</span>.<span style="color: black;">URIRef</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'http://www.w3.org/2002/07/owl#sameAs'</span><span style="color: black;">&#41;</span>, rdflib.<span style="color: black;">term</span>.<span style="color: black;">URIRef</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'http://dbpedia.org/resource/Semantic_Web'</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>, <span style="color: black;">&#40;</span>rdflib.<span style="color: black;">term</span>.<span style="color: black;">URIRef</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'http://dbpedia.org/resource/Deborah_McGuinness'</span><span style="color: black;">&#41;</span>, rdflib.<span style="color: black;">term</span>.<span style="color: black;">URIRef</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'http://dbpedia.org/ontology/knownFor'</span><span style="color: black;">&#41;</span>, rdflib.<span style="color: black;">term</span>.<span style="color: black;">URIRef</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'http://dbpedia.org/resource/Semantic_Web'</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>, <span style="color: black;">&#40;</span>rdflib.<span style="color: black;">term</span>.<span style="color: black;">URIRef</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'http://dbpedia.org/resource/The_semantic_web'</span><span style="color: black;">&#41;</span>, rdflib.<span style="color: black;">term</span>.<span style="color: black;">URIRef</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'http://dbpedia.org/ontology/wikiPageRedirects'</span><span style="color: black;">&#41;</span>, rdflib.<span style="color: black;">term</span>.<span style="color: black;">URIRef</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'http://dbpedia.org/resource/Semantic_Web'</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>, <span style="color: black;">&#40;</span>rdflib.<span style="color: black;">term</span>.<span style="color: black;">URIRef</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'http://dbpedia.org/resource/Access-eGov'</span><span style="color: black;">&#41;</span>, rdflib.<span style="color: black;">term</span>.<span style="color: black;">URIRef</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'http://dbpedia.org/property/keywords'</span><span style="color: black;">&#41;</span>, rdflib.<span style="color: black;">term</span>.<span style="color: black;">URIRef</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'http://dbpedia.org/resource/Semantic_Web'</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>, <span style="color: black;">&#40;</span>rdflib.<span style="color: black;">term</span>.<span style="color: black;">URIRef</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'http://dbpedia.org/resource/SOA4All'</span><span style="color: black;">&#41;</span>, rdflib.<span style="color: black;">term</span>.<span style="color: black;">URIRef</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'http://dbpedia.org/property/keywords'</span><span style="color: black;">&#41;</span>, rdflib.<span style="color: black;">term</span>.<span style="color: black;">URIRef</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'http://dbpedia.org/resource/Semantic_Web'</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><span style="color: black;">&#93;</span><br />
<br />
<span style="color: #66cc66;">&gt;&gt;&gt;</span> <span style="color: #ff7700;font-weight:bold;">for</span> s, p, o <span style="color: #ff7700;font-weight:bold;">in</span> graph:<br />
... &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">print</span> s, <span style="color: #483d8b;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>--- &quot;</span>, p, <span style="color: #483d8b;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>------ &quot;</span>, o<br />
... <br />
<span style="color: black;">http</span>://dbpedia.<span style="color: black;">org</span>/<span style="color: #dc143c;">resource</span>/SUPER <br />
--- &nbsp;http://dbpedia.<span style="color: black;">org</span>/<span style="color: #008000;">property</span>/keywords <br />
------ &nbsp;http://dbpedia.<span style="color: black;">org</span>/<span style="color: #dc143c;">resource</span>/Semantic_Web<br />
http://dbpedia.<span style="color: black;">org</span>/<span style="color: #dc143c;">resource</span>/Semantic_internet <br />
--- &nbsp;http://dbpedia.<span style="color: black;">org</span>/ontology/wikiPageRedirects <br />
------ &nbsp;http://dbpedia.<span style="color: black;">org</span>/<span style="color: #dc143c;">resource</span>/Semantic_Web<br />
http://dbpedia.<span style="color: black;">org</span>/<span style="color: #dc143c;">resource</span>/SW <br />
--- &nbsp;http://dbpedia.<span style="color: black;">org</span>/ontology/wikiPageDisambiguates <br />
------ &nbsp;http://dbpedia.<span style="color: black;">org</span>/<span style="color: #dc143c;">resource</span>/Semantic_Web<br />
http://dbpedia.<span style="color: black;">org</span>/<span style="color: #dc143c;">resource</span>/Semantic_integrity <br />
--- &nbsp;http://dbpedia.<span style="color: black;">org</span>/ontology/wikiPageRedirects <br />
------ &nbsp;http://dbpedia.<span style="color: black;">org</span>/<span style="color: #dc143c;">resource</span>/Semantic_Web<br />
http://dbpedia.<span style="color: black;">org</span>/<span style="color: #dc143c;">resource</span>/Ontotext <br />
--- &nbsp;http://dbpedia.<span style="color: black;">org</span>/ontology/industry <br />
------ &nbsp;http://dbpedia.<span style="color: black;">org</span>/<span style="color: #dc143c;">resource</span>/Semantic_Web<br />
http://mpii.<span style="color: black;">de</span>/yago/<span style="color: #dc143c;">resource</span>/Semantic_Web <br />
--- &nbsp;http://www.<span style="color: black;">w3</span>.<span style="color: black;">org</span>/<span style="color: #ff4500;">2002</span>/07/owl<span style="color: #808080; font-style: italic;">#sameAs </span><br />
------ &nbsp;http://dbpedia.<span style="color: black;">org</span>/<span style="color: #dc143c;">resource</span>/Semantic_Web<br />
http://dbpedia.<span style="color: black;">org</span>/<span style="color: #dc143c;">resource</span>/Deborah_McGuinness <br />
--- &nbsp;http://dbpedia.<span style="color: black;">org</span>/ontology/knownFor <br />
------ &nbsp;http://dbpedia.<span style="color: black;">org</span>/<span style="color: #dc143c;">resource</span>/Semantic_Web<br />
http://dbpedia.<span style="color: black;">org</span>/<span style="color: #dc143c;">resource</span>/The_semantic_web <br />
--- &nbsp;http://dbpedia.<span style="color: black;">org</span>/ontology/wikiPageRedirects <br />
------ &nbsp;http://dbpedia.<span style="color: black;">org</span>/<span style="color: #dc143c;">resource</span>/Semantic_Web<br />
http://dbpedia.<span style="color: black;">org</span>/<span style="color: #dc143c;">resource</span>/Access-eGov <br />
--- &nbsp;http://dbpedia.<span style="color: black;">org</span>/<span style="color: #008000;">property</span>/keywords <br />
------ &nbsp;http://dbpedia.<span style="color: black;">org</span>/<span style="color: #dc143c;">resource</span>/Semantic_Web<br />
http://dbpedia.<span style="color: black;">org</span>/<span style="color: #dc143c;">resource</span>/SOA4All <br />
--- &nbsp;http://dbpedia.<span style="color: black;">org</span>/<span style="color: #008000;">property</span>/keywords <br />
------ &nbsp;http://dbpedia.<span style="color: black;">org</span>/<span style="color: #dc143c;">resource</span>/Semantic_Web<br />
http://dbpedia.<span style="color: black;">org</span>/<span style="color: #dc143c;">resource</span>/DBpedia <br />
--- &nbsp;http://dbpedia.<span style="color: black;">org</span>/ontology/genre <br />
------ &nbsp;http://dbpedia.<span style="color: black;">org</span>/<span style="color: #dc143c;">resource</span>/Semantic_Web<br />
http://dbpedia.<span style="color: black;">org</span>/<span style="color: #dc143c;">resource</span>/Tabulator <br />
--- &nbsp;http://dbpedia.<span style="color: black;">org</span>/ontology/genre <br />
------ &nbsp;http://dbpedia.<span style="color: black;">org</span>/<span style="color: #dc143c;">resource</span>/Semantic_Web<br />
http://dbpedia.<span style="color: black;">org</span>/<span style="color: #dc143c;">resource</span>/Semantic_web <br />
--- &nbsp;http://dbpedia.<span style="color: black;">org</span>/ontology/wikiPageRedirects <br />
------ &nbsp;http://dbpedia.<span style="color: black;">org</span>/<span style="color: #dc143c;">resource</span>/Semantic_Web<br />
http://en.<span style="color: black;">wikipedia</span>.<span style="color: black;">org</span>/wiki/Semantic_Web <br />
--- &nbsp;http://xmlns.<span style="color: black;">com</span>/foaf/<span style="color: #ff4500;">0.1</span>/primaryTopic <br />
------ &nbsp;http://dbpedia.<span style="color: black;">org</span>/<span style="color: #dc143c;">resource</span>/Semantic_Web<br />
http://dbpedia.<span style="color: black;">org</span>/<span style="color: #dc143c;">resource</span>/Sesame_<span style="color: #66cc66;">%</span>28framework<span style="color: #66cc66;">%</span>29 <br />
--- &nbsp;http://dbpedia.<span style="color: black;">org</span>/ontology/genre <br />
------ &nbsp;http://dbpedia.<span style="color: black;">org</span>/<span style="color: #dc143c;">resource</span>/Semantic_Web<br />
http://dbpedia.<span style="color: black;">org</span>/<span style="color: #dc143c;">resource</span>/Mulgara_<span style="color: #66cc66;">%</span>28software<span style="color: #66cc66;">%</span>29 <br />
--- &nbsp;http://dbpedia.<span style="color: black;">org</span>/ontology/genre <br />
------ &nbsp;http://dbpedia.<span style="color: black;">org</span>/<span style="color: #dc143c;">resource</span>/Semantic_Web<br />
http://dbpedia.<span style="color: black;">org</span>/<span style="color: #dc143c;">resource</span>/James_Hendler <br />
--- &nbsp;http://dbpedia.<span style="color: black;">org</span>/ontology/knownFor <br />
------ &nbsp;http://dbpedia.<span style="color: black;">org</span>/<span style="color: #dc143c;">resource</span>/Semantic_Web<br />
http://dbpedia.<span style="color: black;">org</span>/<span style="color: #dc143c;">resource</span>/Jena_<span style="color: #66cc66;">%</span>28framework<span style="color: #66cc66;">%</span>29 <br />
--- &nbsp;http://dbpedia.<span style="color: black;">org</span>/ontology/genre <br />
------ &nbsp;http://dbpedia.<span style="color: black;">org</span>/<span style="color: #dc143c;">resource</span>/Semantic_Web<br />
http://dbpedia.<span style="color: black;">org</span>/<span style="color: #dc143c;">resource</span>/JRDF_<span style="color: #66cc66;">%</span>28framework<span style="color: #66cc66;">%</span>29 <br />
--- &nbsp;http://dbpedia.<span style="color: black;">org</span>/ontology/genre <br />
------ &nbsp;http://dbpedia.<span style="color: black;">org</span>/<span style="color: #dc143c;">resource</span>/Semantic_Web<br />
http://dbpedia.<span style="color: black;">org</span>/<span style="color: #dc143c;">resource</span>/Nigel_Shadbolt <br />
--- &nbsp;http://dbpedia.<span style="color: black;">org</span>/ontology/knownFor <br />
------ &nbsp;http://dbpedia.<span style="color: black;">org</span>/<span style="color: #dc143c;">resource</span>/Semantic_Web<br />
http://dbpedia.<span style="color: black;">org</span>/<span style="color: #dc143c;">resource</span>/Semantic_Web <br />
--- &nbsp;http://dbpedia.<span style="color: black;">org</span>/<span style="color: #008000;">property</span>/refimprove <br />
------ &nbsp;November <span style="color: #ff4500;">2009</span><br />
http://dbpedia.<span style="color: black;">org</span>/<span style="color: #dc143c;">resource</span>/Semantic_Web <br />
--- &nbsp;http://dbpedia.<span style="color: black;">org</span>/<span style="color: #008000;">property</span>/wikiPageUsesTemplate <br />
------ &nbsp;http://dbpedia.<span style="color: black;">org</span>/<span style="color: #dc143c;">resource</span>/Template:Multiple_issues<br />
http://dbpedia.<span style="color: black;">org</span>/<span style="color: #dc143c;">resource</span>/Semantic_Web <br />
--- &nbsp;http://www.<span style="color: black;">w3</span>.<span style="color: black;">org</span>/<span style="color: #ff4500;">2000</span>/01/rdf-schema<span style="color: #808080; font-style: italic;">#label </span><br />
------ &nbsp;Web sémantique<br />
http://dbpedia.<span style="color: black;">org</span>/<span style="color: #dc143c;">resource</span>/Semantic_Web <br />
--- &nbsp;http://www.<span style="color: black;">w3</span>.<span style="color: black;">org</span>/<span style="color: #ff4500;">2000</span>/01/rdf-schema<span style="color: #808080; font-style: italic;">#label </span><br />
------ &nbsp;<span style="color: #66cc66;">&amp;</span><span style="color: #808080; font-style: italic;">#12475;&amp;#12510;&amp;#12531;&amp;#12486;&amp;#12451;&amp;#12483;&amp;#12463;&amp;#12539;&amp;#12454;&amp;#12455;&amp;#12502;</span><br />
http://dbpedia.<span style="color: black;">org</span>/<span style="color: #dc143c;">resource</span>/Semantic_Web <br />
--- &nbsp;http://www.<span style="color: black;">w3</span>.<span style="color: black;">org</span>/<span style="color: #ff4500;">2000</span>/01/rdf-schema<span style="color: #808080; font-style: italic;">#label </span><br />
------ &nbsp;Semantic Web<br />
http://dbpedia.<span style="color: black;">org</span>/<span style="color: #dc143c;">resource</span>/Semantic_Web <br />
--- &nbsp;http://www.<span style="color: black;">w3</span>.<span style="color: black;">org</span>/<span style="color: #ff4500;">2000</span>/01/rdf-schema<span style="color: #808080; font-style: italic;">#label </span><br />
------ &nbsp;Web semantico<br />
http://dbpedia.<span style="color: black;">org</span>/<span style="color: #dc143c;">resource</span>/Semantic_Web <br />
--- &nbsp;http://www.<span style="color: black;">w3</span>.<span style="color: black;">org</span>/<span style="color: #ff4500;">2000</span>/01/rdf-schema<span style="color: #808080; font-style: italic;">#label </span><br />
------ &nbsp;Web semântica<br />
http://dbpedia.<span style="color: black;">org</span>/<span style="color: #dc143c;">resource</span>/Semantic_Web <br />
--- &nbsp;http://www.<span style="color: black;">w3</span>.<span style="color: black;">org</span>/<span style="color: #ff4500;">2000</span>/01/rdf-schema<span style="color: #808080; font-style: italic;">#label </span><br />
------ &nbsp;Semantiska webben<br />
http://dbpedia.<span style="color: black;">org</span>/<span style="color: #dc143c;">resource</span>/Semantic_Web <br />
--- &nbsp;http://www.<span style="color: black;">w3</span>.<span style="color: black;">org</span>/<span style="color: #ff4500;">2000</span>/01/rdf-schema<span style="color: #808080; font-style: italic;">#label </span><br />
------ &nbsp;Semantisches Web<br />
http://dbpedia.<span style="color: black;">org</span>/<span style="color: #dc143c;">resource</span>/Semantic_Web <br />
--- &nbsp;http://www.<span style="color: black;">w3</span>.<span style="color: black;">org</span>/<span style="color: #ff4500;">2000</span>/01/rdf-schema<span style="color: #808080; font-style: italic;">#label </span><br />
------ &nbsp;Web semántica<br />
http://dbpedia.<span style="color: black;">org</span>/<span style="color: #dc143c;">resource</span>/Semantic_Web <br />
--- &nbsp;http://www.<span style="color: black;">w3</span>.<span style="color: black;">org</span>/<span style="color: #ff4500;">2000</span>/01/rdf-schema<span style="color: #808080; font-style: italic;">#label </span><br />
------ &nbsp;<span style="color: #66cc66;">&amp;</span><span style="color: #808080; font-style: italic;">#35821;&amp;#20041;&amp;#32593;</span><br />
http://dbpedia.<span style="color: black;">org</span>/<span style="color: #dc143c;">resource</span>/Semantic_Web <br />
--- &nbsp;http://www.<span style="color: black;">w3</span>.<span style="color: black;">org</span>/<span style="color: #ff4500;">2000</span>/01/rdf-schema<span style="color: #808080; font-style: italic;">#label </span><br />
------ &nbsp;Semanttinen Web<br />
http://dbpedia.<span style="color: black;">org</span>/<span style="color: #dc143c;">resource</span>/Semantic_Web <br />
--- &nbsp;http://www.<span style="color: black;">w3</span>.<span style="color: black;">org</span>/<span style="color: #ff4500;">2000</span>/01/rdf-schema<span style="color: #808080; font-style: italic;">#label </span><br />
------ &nbsp;<span style="color: #66cc66;">&amp;</span><span style="color: #808080; font-style: italic;">#1057;&amp;#1077;&amp;#1084;&amp;#1072;&amp;#1085;&amp;#1090;&amp;#1080;&amp;#1095;&amp;#1077;&amp;#1089;&amp;#1082;&amp;#1072;&amp;#1103; &amp;#1087;&amp;#1072;&amp;#1091;&amp;#1090;&amp;#1080;&amp;#1085;&amp;#1072;</span><br />
http://dbpedia.<span style="color: black;">org</span>/<span style="color: #dc143c;">resource</span>/Semantic_Web <br />
--- &nbsp;http://dbpedia.<span style="color: black;">org</span>/<span style="color: #008000;">property</span>/tone <br />
------ &nbsp;November <span style="color: #ff4500;">2009</span><br />
http://dbpedia.<span style="color: black;">org</span>/<span style="color: #dc143c;">resource</span>/Semantic_Web <br />
--- &nbsp;http://dbpedia.<span style="color: black;">org</span>/<span style="color: #008000;">property</span>/essayLike <br />
------ &nbsp;November <span style="color: #ff4500;">2009</span><br />
http://dbpedia.<span style="color: black;">org</span>/<span style="color: #dc143c;">resource</span>/Semantic_Web <br />
--- &nbsp;http://dbpedia.<span style="color: black;">org</span>/<span style="color: #008000;">property</span>/date <br />
------ &nbsp;November <span style="color: #ff4500;">2009</span><br />
http://dbpedia.<span style="color: black;">org</span>/<span style="color: #dc143c;">resource</span>/Semantic_Web <br />
--- &nbsp;http://dbpedia.<span style="color: black;">org</span>/ontology/abstract <br />
------ &nbsp;Con il termine web semantico, termine coniato dal suo ideatore, Tim Berners-Lee, si intende la trasformazione <span style="color: #ff7700;font-weight:bold;">del</span> World Wide Web <span style="color: #ff7700;font-weight:bold;">in</span> un ambiente dove i documenti pubblicati <span style="color: black;">&#40;</span>pagine HTML, <span style="color: #008000;">file</span>, immagini, e così via<span style="color: black;">&#41;</span> siano associati ad informazioni e dati che ne specifichino il contesto semantico <span style="color: #ff7700;font-weight:bold;">in</span> un formato adatto <span style="color: #008000;">all</span><span style="color: #483d8b;">'interrogazione, all'</span>interpretazione e, più <span style="color: #ff7700;font-weight:bold;">in</span> generale, <span style="color: #008000;">all</span><span style="color: #483d8b;">'elaborazione automatica. Con l'</span>interpretazione <span style="color: #ff7700;font-weight:bold;">del</span> contenuto dei documenti che il Web Semantico propugna, saranno possibili ricerche molto più evolute delle attuali, basate sulla presenza nel documento di parole chiave, ed altre operazioni specialistiche come la costruzione di reti di relazioni e connessioni tra documenti secondo logiche più elaborate <span style="color: #ff7700;font-weight:bold;">del</span> semplice link ipertestuale.<br />
<span style="color: black;">http</span>://dbpedia.<span style="color: black;">org</span>/<span style="color: #dc143c;">resource</span>/Semantic_Web <br />
--- etc. etc etc................
</span></div></pre>

Pretty straightforward uh? In a nutshell, what we've just done is:
<strong>a)</strong> loading the RDF description of the 'Semantic Web' page on <a href="http://dbpedia.org/About">DBPedia</a> (<span style="font-family:monospace;color:#000000;">http://dbpedia.org/resource/Semantic_Web</span>);
<strong>b)</strong> showing the first 10 triples in that RDF graph;
<strong>c)</strong> iterating through all the triples in the graph and printing them out in a format that reflects the subject-predicate-object structure of RDF.

<strong>However we still don't know much about those data</strong>. Meaning: what is the abstract structure used to define them? Do they conform to some sound and thorough data-model or is it just some automatically-generated messy agglomerate of database records? In other words, what I want to know is, what's the <a href="http://en.wikipedia.org/wiki/Ontology_(information_science)">ontology</a> behind these data? How can I see it? Shall I reuse it (and thus endorse it) within my own application, or does my application require something slightly different?

I'm probably biased here, cause I personally get much more satisfaction from creating and thinking about ontologies rather than fiddling with large quantities of rdf-xml triples. Still, <strong>I think that being able to evaluate the ontology a bunch of rdf refers to is of vital importance</strong>, in order to judge whether that RDF is what you're looking for or not, and how to best integrate it in your application.

<strong>Long story short, I couldn't find anything in RdfLib that would let me print out the hierarchy tree</strong> of an ontology and other related information. So I thought, here's a good candidate-task for me to learn how to use the library better. 


<h3>Inspecting an ontology using RDFLib</h3>

I created a small class called '<strong>OntoInspector</strong>' that you can instantiate with an RDFS/OWL ontology and then query to find out basic information about that ontology. I know - all of this could have been done using one of the many (and constantly increasing) ontology editing tools - but hey this is all about learning isn't it?
You can find all the source code on <a href="https://bitbucket.org/magicrebirth/ontoinspector/overview">BitBucket</a>. Feel free to get it and modify as needed. Also, I integrated this python toolkit within a <strong>django application</strong> that let you browse ontologies online (beware - it's just a hack really). This is called - surprise - <a href="http://www.michelepasin.org/demos/ontoview/">OntoView</a>, and it's <a href="http://www.michelepasin.org/demos/ontoview/">accessible here</a>.


The first thing to do in our class definition is (obviously) loading up the RDFLib library. I've developed this using RDFlib 2.4, but recently tested it with 3.0 (the latest release available) and it all still works fine. By loading up the <span style="font-family:monospace;color:#000000; ">RDF</span> and <span style="font-family:monospace;color:#000000; ">RDFS</span> modules we'll have access to all the constants needed to query for classes and subclasses. Note that I added an <span style="font-family:monospace;color:#000000; ">OWL</span> module as that is not part of RDFLib. You can find it in the source code, it's just a list of all predicates in the <a href="http://www.w3.org/TR/owl-guide/">OWL vocabulary</a>. 

<pre><div class="python" style="overflow:auto; line-height: 1.5; font-family:monospace;color: #006; border: 1px solid #d0d0d0; background-color: #f0f0f0;"><span style="color: #ff7700;font-weight:bold;">from</span> rdflib <span style="color: #ff7700;font-weight:bold;">import</span> ConjunctiveGraph, Namespace, <span style="color: #dc143c;">exceptions</span><br />
<span style="color: #ff7700;font-weight:bold;">from</span> rdflib <span style="color: #ff7700;font-weight:bold;">import</span> URIRef, RDFS, RDF, BNode<br />
<span style="color: #ff7700;font-weight:bold;">import</span> OWL</div></pre>


Now let's set up the basic structure of the OntoInspector class. In principle, an <span style="font-family:monospace;color:#000000; ">OntoInspector</span> object should contain all the information necessary to query an ontology. An ontology is referred to using its URI, so that's all is needed for creating an instance of OntoInspector too:


<pre><div class="python" style="overflow:auto; line-height: 1.5; font-family:monospace;color: #006; border: 1px solid #d0d0d0; background-color: #f0f0f0;"><span style="color: #ff7700;font-weight:bold;">class</span> OntoInspector<span style="color: black;">&#40;</span><span style="color: #008000;">object</span><span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; <span style="color: #483d8b;">&quot;&quot;&quot;Class that includes methods for querying an RDFS/OWL ontology&quot;&quot;&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">def</span> <span style="color: #0000cd;">__init__</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, uri, language=<span style="color: #483d8b;">&quot;&quot;</span><span style="color: black;">&#41;</span>:<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">super</span><span style="color: black;">&#40;</span>OntoInspector, <span style="color: #008000;">self</span><span style="color: black;">&#41;</span>.<span style="color: #0000cd;">__init__</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">self</span>.<span style="color: black;">rdfGraph</span> = ConjunctiveGraph<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">try</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">self</span>.<span style="color: black;">rdfGraph</span>.<span style="color: black;">parse</span><span style="color: black;">&#40;</span>uri, format=<span style="color: #483d8b;">&quot;xml&quot;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">except</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">try</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">self</span>.<span style="color: black;">rdfGraph</span>.<span style="color: black;">parse</span><span style="color: black;">&#40;</span>uri, format=<span style="color: #483d8b;">&quot;n3&quot;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">except</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">raise</span> <span style="color: #dc143c;">exceptions</span>.<span style="color: black;">Error</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;Could not parse the file! Is it a valid RDF/OWL ontology?&quot;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">finally</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># let's cache some useful info for faster access</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">self</span>.<span style="color: black;">baseURI</span> = <span style="color: #008000;">self</span>.<span style="color: black;">get_OntologyURI</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span> <span style="color: #ff7700;font-weight:bold;">or</span> uri&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">self</span>.<span style="color: black;">allclasses</span> = <span style="color: #008000;">self</span>.__getAllClasses<span style="color: black;">&#40;</span>classPredicate<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">self</span>.<span style="color: black;">toplayer</span> = <span style="color: #008000;">self</span>.__getTopclasses<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">self</span>.<span style="color: black;">tree</span> = <span style="color: #008000;">self</span>.__getTree<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
<br />
<br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">def</span> get_OntologyURI<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, ....<span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># todo</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">pass</span><br />
<br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">def</span> __getAllClasses<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, ....<span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># todo</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">pass</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">def</span> __getTopclasses<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, ....<span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">pass</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">def</span> __getTree<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, ....<span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># todo</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">pass</span></div></pre>


As you can see the <span style="font-family:monospace;color:#000000; ">__init__</span> method tries to load the ontology file (which can be expressed in either rdf/xml or n3 format) and then sets up 4 class attributes. These attributes will contain some key information about the ontology: its <strong>URI</strong>, a list of <strong>all the classes</strong> available, the classes in the <strong>top layer</strong> and the main <strong>taxonomical tree</strong> of the ontology. 
We're now going to implement the methods needed to fill out these 4 attributes.


<h3>Getting the ontology URI</h3>

If we're dealing with an OWL ontology, it may be the case that the URI we have just used to retrieve the ontology file is not the 'official' URI of the ontology. In fact OWL provides a construct that can be used to 'state' which is the base URI of an ontology (essentially, this is equivalent to stating that an RDF resource has <span style="font-family:monospace;color:#000000; ">rdf:type</span> <span style="font-family:monospace;color:#000000; ">http://www.w3.org/2002/07/owl#Ontology</span>). 
So in the following method first we check if an URI of <span style="font-family:monospace;color:#000000; ">rdf:type</span> <span style="font-family:monospace;color:#000000; ">OWL:Ontology</span> exists, and return that if available (when we return None, the URI value defaults to the URI originally provided when creating the OntoInspector object - see the constructor code above): 

<pre><div class="python" style="overflow:auto; line-height: 1.5; font-family:monospace;color: #006; border: 1px solid #d0d0d0; background-color: #f0f0f0;"><br />
<span style="color: #ff7700;font-weight:bold;">def</span> get_OntologyURI<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, return_as_string=<span style="color: #008000;">True</span><span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; <span style="color: #483d8b;">&quot;&quot;&quot; <br />
&nbsp; &nbsp; In [15]: [x for x in o.rdfGraph.triples((None, RDF.type, OWL.Ontology))]<br />
&nbsp; &nbsp; Out[15]: <br />
&nbsp; &nbsp; [(rdflib.URIRef('http://purl.com/net/sails'),<br />
&nbsp; &nbsp; &nbsp; rdflib.URIRef('http://www.w3.org/1999/02/22-rdf-syntax-ns#type'),<br />
&nbsp; &nbsp; &nbsp; rdflib.URIRef('http://www.w3.org/2002/07/owl#Ontology'))]<br />
<br />
&nbsp; &nbsp; Mind that this will work only for OWL ontologies.<br />
&nbsp; &nbsp; In other cases we just return None, and use the URI passed at loading time<br />
<br />
&nbsp; &nbsp; &quot;&quot;&quot;</span><br />
&nbsp; &nbsp; <span style="color: #dc143c;">test</span> = <span style="color: black;">&#91;</span>x <span style="color: #ff7700;font-weight:bold;">for</span> x, y, z <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">self</span>.<span style="color: black;">rdfGraph</span>.<span style="color: black;">triples</span><span style="color: black;">&#40;</span><span style="color: black;">&#40;</span><span style="color: #008000;">None</span>, RDF.<span style="color: #008000;">type</span>, OWL.<span style="color: black;">Ontology</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><span style="color: black;">&#93;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #dc143c;">test</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> return_as_string:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">str</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">test</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">else</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #dc143c;">test</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">else</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">None</span></div></pre>


<h3>Extracting all the classes</h3>

Essentially, there are only <strong>two ways to define a class</strong>: you can either specify that an entity has a property <span style="font-family:monospace;color:#000000; ">RDF:type</span> with value <span style="font-family:monospace;color:#000000; ">rdfs:Class</span>, or that it has a property <span style="font-family:monospace;color:#000000; ">RDF:type</span> with value <span style="font-family:monospace;color:#000000; ">owl:Class</span>. Note that the <span style="font-family:monospace;color:#000000; ">owl:Class</span> predicate is defined as a <em>subclass</em> of <span style="font-family:monospace;color:#000000; ">rdfs:Class</span>. The rationale for having a separate OWL class construct lies in the restrictions on OWL DL (and thus also on OWL Lite), which imply that not all RDFS classes are legal OWL DL classes. In OWL Full these restrictions do not exist and therefore <span style="font-family:monospace;color:#000000; ">owl:Class</span> and <span style="font-family:monospace;color:#000000; ">rdfs:Class</span> are equivalent in OWL Full (more info here: <a href="http://www.w3.org/TR/owl-ref/">http://www.w3.org/TR/owl-ref/</a>, section 3.1).

Thus, In order to retrieve all the classes defined in an ontology we can just query the RDF graph for triples that have this form:

<span style="font-family:monospace;color:#000000; ">someURI</span> - <span style="font-family:monospace;color:#000000; ">rdf:type</span> - <span style="font-family:monospace;color:#000000; ">rdf:Class</span> OR <span style="font-family:monospace;color:#000000; ">owl:Class</span> . 

This approach will work in the majority of cases. However, things are complicated by the fact that people are sometimes sloppy when they define ontologies, or because they use different tools that automatically generate different styles of RDF code. For example, often an entity is defined as being an <span style="font-family:monospace;color:#000000; ">rdfs:subclassOf</span> another entity, without explicitly declaring that both of them are (rdfs, or owl) classes; another common case is that one of classes mentioned in the domain/range values of properties (via the <span style="font-family:monospace;color:#000000; ">rdfs.domain</span> and <span style="font-family:monospace;color:#000000; ">rdfs.range</span> properties) but not declared explicitly. 

Since we want to be as comprehensive as possible when looking for *all* the classes present in an ontology, I added a couple of methods that deal with these borderline cases. If you don't want to include all of this stuff, you can still bypass these extra checks by using the <em>classPredicate</em> argument. 

<pre><div class="python" style="overflow:auto; line-height: 1.5; font-family:monospace;color: #006; border: 1px solid #d0d0d0; background-color: #f0f0f0;"><span style="color: #ff7700;font-weight:bold;">def</span> __getAllClasses<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, classPredicate = <span style="color: #483d8b;">&quot;&quot;</span>, removeBlankNodes = <span style="color: #008000;">True</span><span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; <span style="color: #483d8b;">&quot;&quot;&quot; &nbsp;<br />
&nbsp; &nbsp; Extracts all the classes from a model<br />
&nbsp; &nbsp; We use the RDFS and OWL predicate by default; also, we extract non explicitly declared classes<br />
&nbsp; &nbsp; &quot;&quot;&quot;</span><br />
&nbsp; &nbsp; rdfGraph = <span style="color: #008000;">self</span>.<span style="color: black;">rdfGraph</span><br />
&nbsp; &nbsp; exit = <span style="color: black;">&#91;</span><span style="color: black;">&#93;</span> &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #ff7700;font-weight:bold;">not</span> classPredicate:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">for</span> s, v, o <span style="color: #ff7700;font-weight:bold;">in</span> rdfGraph.<span style="color: black;">triples</span><span style="color: black;">&#40;</span><span style="color: black;">&#40;</span><span style="color: #008000;">None</span>, RDF.<span style="color: #008000;">type</span> , OWL.<span style="color: black;">Class</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>: <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; exit.<span style="color: black;">append</span><span style="color: black;">&#40;</span>s<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">for</span> s, v, o <span style="color: #ff7700;font-weight:bold;">in</span> rdfGraph.<span style="color: black;">triples</span><span style="color: black;">&#40;</span><span style="color: black;">&#40;</span><span style="color: #008000;">None</span>, RDF.<span style="color: #008000;">type</span> , RDFS.<span style="color: black;">Class</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; exit.<span style="color: black;">append</span><span style="color: black;">&#40;</span>s<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># this extra routine makes sure we include classes not declared explicitly</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># eg when importing another onto and subclassing one of its classes...</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">for</span> s, v, o <span style="color: #ff7700;font-weight:bold;">in</span> rdfGraph.<span style="color: black;">triples</span><span style="color: black;">&#40;</span><span style="color: black;">&#40;</span><span style="color: #008000;">None</span>, RDFS.<span style="color: black;">subClassOf</span> , <span style="color: #008000;">None</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> s <span style="color: #ff7700;font-weight:bold;">not</span> <span style="color: #ff7700;font-weight:bold;">in</span> exit:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; exit.<span style="color: black;">append</span><span style="color: black;">&#40;</span>s<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> o <span style="color: #ff7700;font-weight:bold;">not</span> <span style="color: #ff7700;font-weight:bold;">in</span> exit:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; exit.<span style="color: black;">append</span><span style="color: black;">&#40;</span>o<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># this extra routine includes classes found only in rdfs:domain and rdfs:range definitions</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">for</span> s, v, o <span style="color: #ff7700;font-weight:bold;">in</span> rdfGraph.<span style="color: black;">triples</span><span style="color: black;">&#40;</span><span style="color: black;">&#40;</span><span style="color: #008000;">None</span>, RDFS.<span style="color: black;">domain</span> , <span style="color: #008000;">None</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> o <span style="color: #ff7700;font-weight:bold;">not</span> <span style="color: #ff7700;font-weight:bold;">in</span> exit:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; exit.<span style="color: black;">append</span><span style="color: black;">&#40;</span>o<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">for</span> s, v, o <span style="color: #ff7700;font-weight:bold;">in</span> rdfGraph.<span style="color: black;">triples</span><span style="color: black;">&#40;</span><span style="color: black;">&#40;</span><span style="color: #008000;">None</span>, RDFS.<span style="color: #008000;">range</span> , <span style="color: #008000;">None</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> o <span style="color: #ff7700;font-weight:bold;">not</span> <span style="color: #ff7700;font-weight:bold;">in</span> exit:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; exit.<span style="color: black;">append</span><span style="color: black;">&#40;</span>o<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">else</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> classPredicate == <span style="color: #483d8b;">&quot;rdfs&quot;</span> <span style="color: #ff7700;font-weight:bold;">or</span> classPredicate == <span style="color: #483d8b;">&quot;rdf&quot;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">for</span> s, v, o <span style="color: #ff7700;font-weight:bold;">in</span> rdfGraph.<span style="color: black;">triples</span><span style="color: black;">&#40;</span><span style="color: black;">&#40;</span><span style="color: #008000;">None</span>, RDF.<span style="color: #008000;">type</span> , RDFS.<span style="color: black;">Class</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; exit.<span style="color: black;">append</span><span style="color: black;">&#40;</span>s<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">elif</span> classPredicate == <span style="color: #483d8b;">&quot;owl&quot;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">for</span> s, v, o <span style="color: #ff7700;font-weight:bold;">in</span> rdfGraph.<span style="color: black;">triples</span><span style="color: black;">&#40;</span><span style="color: black;">&#40;</span><span style="color: #008000;">None</span>, RDF.<span style="color: #008000;">type</span> , OWL.<span style="color: black;">Class</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>: <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; exit.<span style="color: black;">append</span><span style="color: black;">&#40;</span>s<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">else</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">raise</span> <span style="color: #dc143c;">exceptions</span>.<span style="color: black;">Error</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;ClassPredicate must be either rdf, rdfs or owl&quot;</span><span style="color: black;">&#41;</span><br />
<br />
&nbsp; &nbsp; exit = remove_duplicates<span style="color: black;">&#40;</span>exit<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> removeBlankNodes:<br />
&nbsp; &nbsp; &nbsp; &nbsp; exit = <span style="color: black;">&#91;</span>x <span style="color: #ff7700;font-weight:bold;">for</span> x <span style="color: #ff7700;font-weight:bold;">in</span> exit <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #ff7700;font-weight:bold;">not</span> <span style="color: #008000;">self</span>.__isBlankNode<span style="color: black;">&#40;</span>x<span style="color: black;">&#41;</span><span style="color: black;">&#93;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> sort_uri_list_by_name<span style="color: black;">&#40;</span>exit<span style="color: black;">&#41;</span></div></pre>


You probably noticed that there are a couple of other methods mentioned in the snippet above: they are used for checking if a URI is a <span style="font-family:monospace;color:#000000; ">BlankNode</span> (which we're normally not interested in, when dealing with ontologies) and for other utility functions, such as sorting and removing duplicates from our list of classes. You'll find all the details about this stuff in the source code obviously..

Next, we want to be able to <strong>move around the ontology hierarchy</strong>. So we need methods to get <em>super</em> and <em>sub</em> classes from a given class. This is easily done by querying the graph for triples containing the <span style="font-family:monospace;color:#000000; ">rdfs.subClassOf</span> predicate:

<pre><div class="python" style="overflow: auto; line-height: 1.5;font-family:monospace;color: #006; border: 1px solid #d0d0d0; background-color: #f0f0f0;"><span style="color: #808080; font-style: italic;"># methods for getting ancestores and descendants of classes: by default, we do not include blank nodes</span><br />
<br />
<span style="color: #ff7700;font-weight:bold;">def</span> get_classDirectSupers<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, aClass, excludeBnodes = <span style="color: #008000;">True</span><span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; returnlist = <span style="color: black;">&#91;</span><span style="color: black;">&#93;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">for</span> s, v, o <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">self</span>.<span style="color: black;">rdfGraph</span>.<span style="color: black;">triples</span><span style="color: black;">&#40;</span><span style="color: black;">&#40;</span>aClass, RDFS.<span style="color: black;">subClassOf</span> , <span style="color: #008000;">None</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> excludeBnodes:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #ff7700;font-weight:bold;">not</span> <span style="color: #008000;">self</span>.__isBlankNode<span style="color: black;">&#40;</span>o<span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; returnlist.<span style="color: black;">append</span><span style="color: black;">&#40;</span>o<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">else</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; returnlist.<span style="color: black;">append</span><span style="color: black;">&#40;</span>o<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> sort_uri_list_by_name<span style="color: black;">&#40;</span>remove_duplicates<span style="color: black;">&#40;</span>returnlist<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span> <br />
<br />
<br />
<span style="color: #ff7700;font-weight:bold;">def</span> get_classDirectSubs<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, aClass, excludeBnodes = <span style="color: #008000;">True</span><span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; returnlist = <span style="color: black;">&#91;</span><span style="color: black;">&#93;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">for</span> s, v, o <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">self</span>.<span style="color: black;">rdfGraph</span>.<span style="color: black;">triples</span><span style="color: black;">&#40;</span><span style="color: black;">&#40;</span><span style="color: #008000;">None</span>, RDFS.<span style="color: black;">subClassOf</span> , aClass<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> excludeBnodes:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #ff7700;font-weight:bold;">not</span> <span style="color: #008000;">self</span>.__isBlankNode<span style="color: black;">&#40;</span>s<span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; returnlist.<span style="color: black;">append</span><span style="color: black;">&#40;</span>s<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">else</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; returnlist.<span style="color: black;">append</span><span style="color: black;">&#40;</span>s<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> sort_uri_list_by_name<span style="color: black;">&#40;</span>remove_duplicates<span style="color: black;">&#40;</span>returnlist<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><br />
<br />
<br />
<span style="color: #ff7700;font-weight:bold;">def</span> get_classAllSubs<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, aClass, returnlist = <span style="color: black;">&#91;</span><span style="color: black;">&#93;</span>, excludeBnodes = <span style="color: #008000;">True</span><span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">for</span> sub <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">self</span>.<span style="color: black;">get_classDirectSubs</span><span style="color: black;">&#40;</span>aClass, excludeBnodes<span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; returnlist.<span style="color: black;">append</span><span style="color: black;">&#40;</span>sub<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">self</span>.<span style="color: black;">get_classAllSubs</span><span style="color: black;">&#40;</span>sub, returnlist, excludeBnodes<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> sort_uri_list_by_name<span style="color: black;">&#40;</span>remove_duplicates<span style="color: black;">&#40;</span>returnlist<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><br />
<br />
<br />
<span style="color: #ff7700;font-weight:bold;">def</span> get_classAllSupers<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, aClass, returnlist = <span style="color: black;">&#91;</span><span style="color: black;">&#93;</span>, excludeBnodes = <span style="color: #008000;">True</span> <span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">for</span> ssuper <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">self</span>.<span style="color: black;">get_classDirectSupers</span><span style="color: black;">&#40;</span>aClass, excludeBnodes<span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; returnlist.<span style="color: black;">append</span><span style="color: black;">&#40;</span>ssuper<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">self</span>.<span style="color: black;">get_classAllSupers</span><span style="color: black;">&#40;</span>ssuper, returnlist, excludeBnodes<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> sort_uri_list_by_name<span style="color: black;">&#40;</span>remove_duplicates<span style="color: black;">&#40;</span>returnlist<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><br />
<br />
<br />
<span style="color: #ff7700;font-weight:bold;">def</span> get_classSiblings<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, aClass, excludeBnodes = <span style="color: #008000;">True</span><span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; returnlist = <span style="color: black;">&#91;</span><span style="color: black;">&#93;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">for</span> father <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">self</span>.<span style="color: black;">get_classDirectSupers</span><span style="color: black;">&#40;</span>aClass, excludeBnodes<span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">for</span> child <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">self</span>.<span style="color: black;">get_classDirectSubs</span><span style="color: black;">&#40;</span>father, excludeBnodes<span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> child <span style="color: #66cc66;">!</span>= aClass:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; returnlist.<span style="color: black;">append</span><span style="color: black;">&#40;</span>child<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> sort_uri_list_by_name<span style="color: black;">&#40;</span>remove_duplicates<span style="color: black;">&#40;</span>returnlist<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><br />
<br />
&nbsp;</div></pre>


<h3>Getting the top layer</h3>

We're now all set for retrieving the classes at the top of the taxonomic hierarchy of our ontology, that is, its 'top-layer'. This can be done by reusing the <span style="font-family:monospace;color:#000000; ">get_classDirectSupers</span> method previously defined, so to search for all classes that have no superclasses:

<pre><div class="python" style="overflow:auto; line-height: 1.5; font-family:monospace;color: #006; border: 1px solid #d0d0d0; background-color: #f0f0f0;"><span style="color: #ff7700;font-weight:bold;">def</span> __getTopclasses<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, classPredicate = <span style="color: #483d8b;">''</span><span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; <span style="color: #483d8b;">&quot;&quot;&quot; Finds the topclass in an ontology (works also when we have more than on superclass)<br />
<br />
&nbsp; &nbsp; &quot;&quot;&quot;</span><br />
&nbsp; &nbsp; returnlist = <span style="color: black;">&#91;</span><span style="color: black;">&#93;</span><br />
&nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># gets all the classes</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">for</span> eachclass <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">self</span>.__getAllClasses<span style="color: black;">&#40;</span>classPredicate<span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; x = <span style="color: #008000;">self</span>.<span style="color: black;">get_classDirectSupers</span><span style="color: black;">&#40;</span>eachclass<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #ff7700;font-weight:bold;">not</span> x:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; returnlist.<span style="color: black;">append</span><span style="color: black;">&#40;</span>eachclass<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> sort_uri_list_by_name<span style="color: black;">&#40;</span>returnlist<span style="color: black;">&#41;</span></div></pre>


<h3>Reconstructing the ontology tree</h3>

Now that we know which are the top classes in our taxonomy, we can parse the tree recursively using the <span style="font-family:monospace;color:#000000; ">get_classDirectSubs</span> method defined above, and reconstruct the whole taxonomical structure of the ontology.

<pre><div class="python" style="overflow:auto; line-height: 1.5;  font-family:monospace;color: #006; border: 1px solid #d0d0d0; background-color: #f0f0f0;"><span style="color: #ff7700;font-weight:bold;">def</span> __getTree<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, father=<span style="color: #008000;">None</span>, out=<span style="color: #008000;">None</span><span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; <span style="color: #483d8b;">&quot;&quot;&quot; Reconstructs the taxonomical tree of an ontology, from the 'topClasses' (= classes with no supers, see below)<br />
&nbsp; &nbsp; &nbsp; &nbsp; Returns a dictionary in which each class is a key, and its direct subs are the values.<br />
&nbsp; &nbsp; &nbsp; &nbsp; The top classes have key = 0<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; Eg.<br />
&nbsp; &nbsp; &nbsp; &nbsp; {'0' : [class1, class2], class1: [class1-2, class1-3], class2: [class2-1, class2-2]}<br />
&nbsp; &nbsp; &quot;&quot;&quot;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #ff7700;font-weight:bold;">not</span> father:<br />
&nbsp; &nbsp; &nbsp; &nbsp; out = <span style="color: black;">&#123;</span><span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; topclasses = <span style="color: #008000;">self</span>.<span style="color: black;">toplayer</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; out<span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span> = topclasses<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">for</span> top <span style="color: #ff7700;font-weight:bold;">in</span> topclasses:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; children = <span style="color: #008000;">self</span>.<span style="color: black;">get_classDirectSubs</span><span style="color: black;">&#40;</span>top<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; out<span style="color: black;">&#91;</span>top<span style="color: black;">&#93;</span> = children<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">for</span> potentialfather <span style="color: #ff7700;font-weight:bold;">in</span> children:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">self</span>.__getTree<span style="color: black;">&#40;</span>potentialfather, out<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> out<br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">else</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; children = <span style="color: #008000;">self</span>.<span style="color: black;">get_classDirectSubs</span><span style="color: black;">&#40;</span>father<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; out<span style="color: black;">&#91;</span>father<span style="color: black;">&#93;</span> = children<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">for</span> ch <span style="color: #ff7700;font-weight:bold;">in</span> children:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">self</span>.__getTree<span style="color: black;">&#40;</span>ch, out<span style="color: black;">&#41;</span></div></pre>

That's it really. Given this abstract tree representation, it can be printed out differently depending on the context (html, command line) but the core will remain intact. 


<h3>Wrapping up</h3>

The <a href="https://bitbucket.org/magicrebirth/ontoinspector/overview">source code on BitBucket</a> contains also other utilities I added, eg for handling class comments, namespaces, for nice-printing of classes' names, and for outputting the ontology tree as an image, using the <a href="http://www.graphviz.org/">Graphviz</a> library (which needs to be installed separately).

Here's an example of how OntoInspector can be used in the python interactive shell for inspecting the <a href="http://xmlns.com/foaf/spec/">Friend Of A Friend</a> (FOAF) ontology:

<pre><div class="python" style="overflow:auto; line-height: 1.5; font-family:monospace;color: #006; border: 1px solid #d0d0d0; background-color: #f0f0f0;">In <span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span>: <span style="color: #ff7700;font-weight:bold;">from</span> onto_inspector <span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #66cc66;">*</span><br />
In <span style="color: black;">&#91;</span><span style="color: #ff4500;">2</span><span style="color: black;">&#93;</span>: onto = OntoInspector<span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;http://xmlns.com/foaf/spec/20100809.rdf&quot;</span><span style="color: black;">&#41;</span> &nbsp; &nbsp; &nbsp; &nbsp; <br />
In <span style="color: black;">&#91;</span><span style="color: #ff4500;">3</span><span style="color: black;">&#93;</span>: onto.<span style="color: black;">toplayer</span><br />
Out<span style="color: black;">&#91;</span><span style="color: #ff4500;">3</span><span style="color: black;">&#93;</span>: <br />
<span style="color: black;">&#91;</span>rdflib.<span style="color: black;">URIRef</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'http://xmlns.com/foaf/0.1/Agent'</span><span style="color: black;">&#41;</span>,<br />
&nbsp;rdflib.<span style="color: black;">URIRef</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'http://www.w3.org/2000/01/rdf-schema#Class'</span><span style="color: black;">&#41;</span>,<br />
&nbsp;rdflib.<span style="color: black;">URIRef</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'http://www.w3.org/2004/02/skos/core#Concept'</span><span style="color: black;">&#41;</span>,<br />
&nbsp;rdflib.<span style="color: black;">URIRef</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'http://xmlns.com/foaf/0.1/Document'</span><span style="color: black;">&#41;</span>,<br />
&nbsp;rdflib.<span style="color: black;">URIRef</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'http://xmlns.com/foaf/0.1/LabelProperty'</span><span style="color: black;">&#41;</span>,<br />
&nbsp;rdflib.<span style="color: black;">URIRef</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'http://www.w3.org/2000/01/rdf-schema#Literal'</span><span style="color: black;">&#41;</span>,<br />
&nbsp;rdflib.<span style="color: black;">URIRef</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'http://www.w3.org/2000/10/swap/pim/contact#Person'</span><span style="color: black;">&#41;</span>,<br />
&nbsp;rdflib.<span style="color: black;">URIRef</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'http://xmlns.com/foaf/0.1/Project'</span><span style="color: black;">&#41;</span>,<br />
&nbsp;rdflib.<span style="color: black;">URIRef</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'http://www.w3.org/2003/01/geo/wgs84_pos#SpatialThing'</span><span style="color: black;">&#41;</span>,<br />
&nbsp;rdflib.<span style="color: black;">URIRef</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'http://www.w3.org/2002/07/owl#Thing'</span><span style="color: black;">&#41;</span><span style="color: black;">&#93;</span><br />
In <span style="color: black;">&#91;</span><span style="color: #ff4500;">4</span><span style="color: black;">&#93;</span>: onto.<span style="color: black;">printTree</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
foaf:Agent<br />
----foaf:Group<br />
----foaf:Organization<br />
----foaf:Person<br />
rdfs:Class<br />
http://www.<span style="color: black;">w3</span>.<span style="color: black;">org</span>/<span style="color: #ff4500;">2004</span>/02/skos/core<span style="color: #808080; font-style: italic;">#Concept</span><br />
foaf:Document<br />
----foaf:Image<br />
----foaf:PersonalProfileDocument<br />
foaf:LabelProperty<br />
rdfs:Literal<br />
http://www.<span style="color: black;">w3</span>.<span style="color: black;">org</span>/<span style="color: #ff4500;">2000</span>/<span style="color: #ff4500;">10</span>/swap/pim/contact<span style="color: #808080; font-style: italic;">#Person</span><br />
----foaf:Person<br />
foaf:Project<br />
http://www.<span style="color: black;">w3</span>.<span style="color: black;">org</span>/<span style="color: #ff4500;">2003</span>/01/geo/wgs84_pos<span style="color: #808080; font-style: italic;">#SpatialThing</span><br />
----foaf:Person<br />
owl:Thing<br />
----foaf:OnlineAccount<br />
--------foaf:OnlineChatAccount<br />
--------foaf:OnlineEcommerceAccount<br />
--------foaf:OnlineGamingAccount<br />
<br />
In <span style="color: black;">&#91;</span><span style="color: #ff4500;">5</span><span style="color: black;">&#93;</span>: document = onto.<span style="color: black;">find_class_byname</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;document&quot;</span><span style="color: black;">&#41;</span><br />
In <span style="color: black;">&#91;</span><span style="color: #ff4500;">6</span><span style="color: black;">&#93;</span>: document<br />
Out<span style="color: black;">&#91;</span><span style="color: #ff4500;">6</span><span style="color: black;">&#93;</span>: <br />
<span style="color: black;">&#91;</span>rdflib.<span style="color: black;">URIRef</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'http://xmlns.com/foaf/0.1/Document'</span><span style="color: black;">&#41;</span>,<br />
&nbsp;rdflib.<span style="color: black;">URIRef</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'http://xmlns.com/foaf/0.1/PersonalProfileDocument'</span><span style="color: black;">&#41;</span><span style="color: black;">&#93;</span><br />
<br />
In <span style="color: black;">&#91;</span><span style="color: #ff4500;">7</span><span style="color: black;">&#93;</span>: document = document<span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span><br />
In <span style="color: black;">&#91;</span><span style="color: #ff4500;">8</span><span style="color: black;">&#93;</span>: document<br />
Out<span style="color: black;">&#91;</span><span style="color: #ff4500;">8</span><span style="color: black;">&#93;</span>: rdflib.<span style="color: black;">URIRef</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'http://xmlns.com/foaf/0.1/Document'</span><span style="color: black;">&#41;</span><br />
In <span style="color: black;">&#91;</span><span style="color: #ff4500;">9</span><span style="color: black;">&#93;</span>: onto.<span style="color: black;">get_classAllSubs</span><span style="color: black;">&#40;</span>document<span style="color: black;">&#41;</span><br />
Out<span style="color: black;">&#91;</span><span style="color: #ff4500;">9</span><span style="color: black;">&#93;</span>: <br />
<span style="color: black;">&#91;</span>rdflib.<span style="color: black;">URIRef</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'http://xmlns.com/foaf/0.1/Image'</span><span style="color: black;">&#41;</span>,<br />
&nbsp;rdflib.<span style="color: black;">URIRef</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'http://xmlns.com/foaf/0.1/PersonalProfileDocument'</span><span style="color: black;">&#41;</span><span style="color: black;">&#93;</span><br />
In <span style="color: black;">&#91;</span><span style="color: #ff4500;">10</span><span style="color: black;">&#93;</span>: onto.<span style="color: black;">get_classAllSupers</span><span style="color: black;">&#40;</span>document<span style="color: black;">&#41;</span><br />
Out<span style="color: black;">&#91;</span><span style="color: #ff4500;">10</span><span style="color: black;">&#93;</span>: <span style="color: black;">&#91;</span><span style="color: black;">&#93;</span><br />
In <span style="color: black;">&#91;</span><span style="color: #ff4500;">11</span><span style="color: black;">&#93;</span>: onto.<span style="color: black;">get_classComment</span><span style="color: black;">&#40;</span>document<span style="color: black;">&#41;</span><br />
Out<span style="color: black;">&#91;</span><span style="color: #ff4500;">11</span><span style="color: black;">&#93;</span>: rdflib.<span style="color: black;">Literal</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'A document.'</span>, language=<span style="color: #008000;">None</span>, datatype=<span style="color: #008000;">None</span><span style="color: black;">&#41;</span></div></pre>

Any comments? As I said I'm still learning/improving this... so any feedback is welcome! You can also get in touch via the <a href="https://bitbucket.org/magicrebirth/ontoinspector/issues?status=new&status=open">BitBucket page</a>.

<p>&nbsp;</p>]]></content:encoded>
			<wfw:commentRss>http://www.michelepasin.org/techblog/2011/07/18/inspecting-an-ontology-with-rdflib/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Workshop on Live Coding @ RMLL-11</title>
		<link>http://www.michelepasin.org/techblog/2011/07/11/workshop-on-live-coding-rmll-11/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=workshop-on-live-coding-rmll-11</link>
		<comments>http://www.michelepasin.org/techblog/2011/07/11/workshop-on-live-coding-rmll-11/#comments</comments>
		<pubDate>Mon, 11 Jul 2011 15:13:10 +0000</pubDate>
		<dc:creator>mike</dc:creator>
				<category><![CDATA[digitalHumanities]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[livecoding]]></category>
		<category><![CDATA[strasbourg]]></category>

		<guid isPermaLink="false">http://www.michelepasin.org/techblog/?p=1445</guid>
		<description><![CDATA[I just got back from Strasbourg (France) where I gave a talk about my experience with Livecoding and Impromptu at the at the Cultures et Arts Libres Workshop, part of the 2011 Libre Software Meeting. In a nutshell, livecoding is the process of writing software in realtime, as a form of improvised time-based art. Many [...]]]></description>
			<content:encoded><![CDATA[I just got back from Strasbourg (France) where I gave a talk about my experience with <a href="http://en.wikipedia.org/wiki/Live_coding">Livecoding</a> and <a href="http://impromptu.moso.com.au/">Impromptu</a> at the at the Cultures et Arts Libres Workshop, part of the <a href="http://2011.rmll.info/">2011 Libre Software Meeting</a>. In a nutshell, livecoding is the process of writing software in realtime, as a form of improvised time-based art. Many thanks for the organizers for inviting me, it's been a quite rewarding experience. Here I'm posting the slides from the talk in case people want to follow up on the things I mentioned.

The slides are very introductory, so I strongly encourage anyone interested to find out more about the world of Impromptu by following the links provided in the presentation. 

<div style="width:510px" id="__ss_8564854"> <strong style="display:block;margin:12px 0 4px"><a href="http://www.slideshare.net/mpasin/livecoding-with-impromptu" title="Livecoding with impromptu" target="_blank">Livecoding with impromptu</a></strong> <iframe src="http://www.slideshare.net/slideshow/embed_code/8564854" width="510" height="426" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></div>

<p>&nbsp;</p>

The other two livecoders who gave talks at the workshop were <a href="http://www.nescivi.nl/">Marje Baalman</a> and <a href="http://www.mcld.co.uk/">Dan Stowell</a>; both of them do very interesting stuff with <a href="http://www.audiosynth.com/">SuperCollider</a> (another livecoding environment) so you better check them out too!

By the way, after the workshop there was also a livecoding performance - but I'm going to report about that <a href="http://www.michelepasin.org/musicblog/2011/07/08/livecoding-in-paris-stransbourg/">here</a>..

<p>&nbsp;</p>]]></content:encoded>
			<wfw:commentRss>http://www.michelepasin.org/techblog/2011/07/11/workshop-on-live-coding-rmll-11/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

