Thursday, November 20, 2008

Acroynms

Not only is the pen is mightier than the sword, but the acronym is mightier than the military / industrial / research complex.

Comic from PhD Comics

Hat tip to PhDComics.

Wednesday, November 19, 2008

Semantic and Wiki

Just wanted to respond to Jack's post, Challenges using Semantic Wiki's for Knowledge Engineering, to clarify my intention a bit.
  1. I agree that you should stick with the wiki and skip the formal relationships during the knowledge elicitation phase.
  2. I do not expect that "a single correct and uniform world view that all stakeholders should share and will share with a little effort."
  3. I do not want to use Semantic Wikis to create some type of process for model driven engineering.
  4. I'm not interested in "mixing knowledge elicitation with design to the detriment of both."
What I like about semantic wikis is that they are both semantic and wiki. The wiki can be used as a tool that "captures differences, reconciles them when reasonable but not when unreasonable." I see wikipedia as a good example of this. Wikipedia's controlled vocabulary is constantly changing (I changed an entry yesterday) and is able to accommodate a wide variety of opinions and respond to the latest ideas and trends.

So what about the semantic part? I see this coming in as we move into the design phase. Why put it into the Wiki? I see this as a good way to facilitate communication between the stakeholders and system designers and expose a symbolic AI system's "mental model" of the world. Just as the various stakeholders' knowledge is captured in the wiki, I give the developing AI system it's own voice along side (rather than replacing) the human voices.

Where they all agree, you can have a single wiki entry. Where they disagree you can list all viewpoints. The semantic wiki tagging system allows you to differentiate between them, just as tagging in other forums facilitates other multi-perspective folksonomies.

What this implies, I think, is that you may be able to start with a standard Wiki and use it for quite a while and then add semantic entries on in addition to the others.

Challenges using Semantic Wiki's for Knowledge Engineering

Jack here...I've been thinking about about Keith's post about Semantic Wiki's and thought I'd chime in. I'm a big fan of anything that makes requirement gathering and/or knowledge elicitation easier, but I'm nervous about the semantic wiki approach.

My understanding is that a Semantic Wiki is a Wiki where the links between pages have been given formally defined (e.g. ontological) relationships. Keith talked about this in his post on controlled Vocabulary when he cited wikipedia "a carefully selected list of words and phrases, which are used to tag units of information. ... Controlled vocabularies solve the problems of homographs, synonyms and polysemes by ensuring that each concept is described using only one authorized term and each authorized term in the controlled vocabulary describes only one concept. In short, controlled vocabularies reduce ambiguity inherent in normal human languages where the same concept can be given different names and ensure consistency."

Sounds good, right? Gathering information is about reducing ambiguity, right? Good old Occam's Razor says otherwise. Any explanation should be as simple as possible, but no simpler. There is a big assumption built into controlled vocabularies and ontologies which is that it is possible and desirable to develop a controlled vocabulary that can be uniformly agreed on by all stake holders (or that any disagreements are minor and can be reconciled within the structure of the formal representation.) This concept implies that there is a single correct and uniform world view that all stakeholders should share and will share with a little effort. This is a large claim that is not supported by any formal model development process or activity of which I’m aware. In fact, getting stakeholders to agree on things as basic as word meanings is immensely difficult, and is so for good reaons. Different stakeholder's may have radically different, but equally useful ways of understanding a domain of interest. These differences may depending on their cultural background, their training and experience and the specifics of their work practice.

While a formal model can be developed even in groups with legitimate conceptual differences, it usually does so at the expense of one of the parties or by the creation of artificial compromises. This may be an acceptable outcome in some situations but not others. In the requirement gathering phase of user interface design, this seems like an overly constraining starting point. If we are to accurately elicit information we need a method that initially captures differences, reconciles them when reasonable but not when unreasonable. Otherwise we are mixing knowledge elicitation with design to the detriment of both.

My vote ... stick with the wiki and skip the formal relationships. This messes up part of why Keith wants formal relationships... that they'll be useful for providing knowledge to AI systems. I've got concerns about that too, but will write about that tomorrow.

jSoar

As part of an investigation into rule based systems, today I downloaded jSoar, a java implementation of the Soar kernel.

jSoar is currently under heavy development and there are no releases on the downloads page so the only way to get it is by checking out the code directly through the subversion server. Once you check out the code, you can build it either with the included Ant build.xml build script or by importing the code into Eclipse. I tried both and had no problems.

Next on to my test case. I want to build a simple Soar agent that responds to a single, simple rule from the soccer domain: "If the ball is controlled by me, then shoot the ball." Here is my Soar rule:

jSoar comes with a set of unit tests that both test the validity of the system as it continues to develop and serve as samples for how the system is to be used. In particular, InputOutputImplTest.java shows how to create and initialize a new Soar agent, attach to the input and output cycle through agent listeners, send data to the agent on the input link and receive the agent's output.

Having an input and output link and a regular decision cycle makes Soar much more friendly to agent developers than other rules engines like Drools. On the flip side, the syntax for spoon-feeding changes into working memory is no fun.

Support for jSoar is provided through the jsoar-dev Google Groups web page.

Here's my simple test java code:

package com.referata.soccer;

import org.jsoar.kernel.Agent;
import org.jsoar.kernel.RunType;
import org.jsoar.kernel.events.InputCycleEvent;
import org.jsoar.kernel.io.InputBuilder;
import org.jsoar.tcl.SoarTclInterface;
import org.jsoar.util.events.SoarEvent;
import org.jsoar.util.events.SoarEventListener;

public class SoccerSoarTest implements SoarEventListener {

private Agent agent;

public SoccerSoarTest() throws Exception {
agent = new Agent();
SoarTclInterface ifc = new SoarTclInterface(agent);
agent.initialize();
agent.getEventManager().addListener(
InputCycleEvent.class, this);
ifc.sourceFile("/res/soccer.soar");
agent.runFor(3, RunType.DECISIONS);
}

/**
* @param args
*/
public static void main(String[] args) throws Exception {
new SoccerSoarTest();
}

@Override
public void onEvent(SoarEvent arg0) {
InputBuilder builder = InputBuilder.create(agent.io);
builder.push("ball").markId("b1").
add("controlledBy", "me");
}
}

Thursday, November 13, 2008

Soccer Narrative 2

As part of my continuing experimentation with narrative inquiry, I'm posting another example of a soccer narrative. This example was created several months ago. The narrative is in the form of a comic and was inspired by Understanding Comics by Scout McCloud. My intention is to use this to help teach a soccer concept to my sons' soccer team, but I also think it serves as a decent example of a visual and verbal narrative.

Soccer Narrative 1

This post is a narrative interview with a friend of mine about soccer. It's a continuation of an earlier post about narrative inquiry. I've included my directions (D) and imagined responses (R). This interview was conducted fact-to-face and I typed the responses in real-time so there may be some information lost. For future inquiries, I may use instant messenger software or a digital audio recorder to better capture the exact transcript.

D: Think of a time when you were playing soccer.
R: Okay.
D: Tell me about it.
R: First thing that came to mind. It was when I was playing on my HS soccer team as a senior. It was the only game I lost that season. My buddy crossed the ball to me in front of the goal and I headed the ball and didn't score. I never scored in high school. That was my first chance.
D: Were you trying to score a goal?
R: Yes.
D: What was happening before you missed the goal?
R: CJ dribbled the ball up to the corner. I ran up alone. It was just me, a defender and the goalie in front of the goal.
D: Tell me about "crossing the ball".
R: My buddy was in the corner with the ball. He kicked the ball up into the air all the way in front of the net and I had a chance to head it into the net.
D: Why did you miss the goal?
R: I tried too hard to aim for the corner of the net and missed the net by about a foot. I was so close I could have hit it anywhere, but I tried to aim and missed.
D: Think of another time when you were trying to score a goal. What was different/similar about the two situations?
R: Another time I was trying to score a goal in the rec leagues. Most of the time I would dribble the ball up myself, fake out the goalie and score.
D: Why were you able to score?
R: I became much better at soccer.

Narrative Inquiry

Much of the data that I've gathered so far for the development of my soccer semantic wiki has been from authoritative sources such as published books and videos, wikipedia and some web site about soccer and coaching soccer. This is a great source of information and it's readily accessible (for soccer), but it has limitations.

First, it's got a limited perspective. Almost all of the authors are older (30+ yrs) men who having been playing, coaching and writing about soccer for a long time. Compared to the population of the world that plays and watches soccer, this is a rather limited sample. Furthermore, this group tends to read each others' work so you'll find a lot of overlap and repetition. Certainly, there is a danger that you're reducing your chances of discovering novelty.

Second, there are many domains of human behavior for which there are not many (if any) authoritative sources. Even when there are, these sources often have gaps. As I've discussed before, there are a number of techniques for gathering data directly from people who are active participants in the domain. One such methodology is narrative inquiry (and the related discourse analysis).

In the past, I've done some reading on narratology (including the classic Morphology of the Folktale by Vladimir Propp) and narrative intelligence, but I haven't done much reading on how to perform the narrative inquiry -- a form of data gathering based on analyzing stories. A quick search has produced a nice long list of books that I can draw on, but first I'm going to lay out a naive method and do some experimentation to get a firsthand feel for the issues.

Below is a naive script that I might use in an interview to elicit a story about a particular domain (in this case I'll use soccer). I'll include my directions (D) and imagined responses (R).

D: Think of a time when you were playing soccer. (Set the domain)
R: Okay, I have one.
D: Tell me about it. (Open ended elicitation of the story)
R: I was playing soccer and I scored a goal.
D: Were you trying to score a goal? (What was the person trying to do at the time?)
R: Yes.
D: What was happening before you scored the goal? (What was the situation?)
R: ...
D: Who else was involved? Anyone else? What were they doing?
D: What could you have done differently to score a goal?
D: Where were you?
D: What enabled you to score a goal?
D: Was any part of this incident surprising and/or unexpected? If so, what normally happens?
D: Think of another time when you were trying to score a goal. What was different/similar about the two situations?

Hmm... well that's a good start. Let's try it out and see what happens.

Support Wikipedia

As you can probably tell, I like Wikipedia a lot and use it quite extensively. They are a donation-driven, non-profit organization and are currently running a fund-raising campaign. I just made a donation and encourage others to do the same by clicking the button below.

Wikipedia Affiliate Button

Wednesday, November 12, 2008

Graphics2D Rotate

Here's another Java hobbyist how-to post. I showed in my last post how to animate a little square by moving it around on a JComponent. In this post, I'm going to look into how to rotate the square to always point toward another square as it moves across the screen.

The basic function that I'll be calling is Graphics2D.rotate(double theta). This function causes "Subsequent rendering is rotated by the specified radians (theta) relative to the previous origin."

A radian is defined as the angle subtended at the center of a circle by an arc that is equal in length to the radius of the circle, or 180/PI degrees. A full circle is 2 PI radians. A half circle is PI radians. Therefore, if I wanted to turn 45 degrees (1/8 circle), I would call Graphics2D.rotate(Math.PI/4).

Now, if I want to rotate my square to point at another square, the easiest thing to do is to calculate the slope between the two squares (double slope = squareY2 - squareY1 / squareX2 - squareX1) and then convert the slope to an angle using Math.atan() function. I could go into more depth on atan, but I'll leave that for another time. UPDATE: the Math.atan2() function effectively combines the slope and atan calculations and deals with some messy edge cases like divide by zero. See below for an example of its use.

Here's the new code:


import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.Timer;

/**
* A very simple panel that demonstrates
* how to create a Swing component that updates
* and repaints itself with a Timer.
*
* @author Keith Knudsen
*/
public class JSimpleAnimationComponent extends JComponent
implements ActionListener {

/**
* @param args
*/
public static void main(String[] args) {
JFrame frame = new JFrame("AnimationPanel");
frame.setDefaultCloseOperation(
JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add(
new JSimpleAnimationComponent(),
BorderLayout.CENTER);
frame.setSize(200,200);
frame.setVisible(true);
}

public JSimpleAnimationComponent () {
Timer timer = new Timer(50, this);
timer.start();
}

/* position of our little moving square */
double squareX1 = 10;
double squareY1 = 10;

/* ... and our fixed square that we point to */
double squareX2 = 100;
double squareY2 = 50;

/**
* Called by the timer. Update the position of
* our little moving square and then call repaint.
*/
public void actionPerformed(ActionEvent e) {
squareX1++;
// keep the little square from running off the edge
if(squareX1 > this.getWidth()) {
squareX1 = 10;
}
repaint();
}

/*
* Paint the background and the little square
* at it's current position.
*/
public void paintComponent ( Graphics g )
{
// clean up the background from the previous draw
super.paintComponent(g);

// need this for rotate function
Graphics2D g2 = (Graphics2D) g;

// draw fixed square
g2.setColor(Color.BLUE);
g2.drawRect((int)squareX2, (int)squareY2, 10, 10);

// draw sprite
g2.translate(squareX1, squareY1);
g2.setColor(Color.RED);
// rotate square1 to point at square2
double radians = Math.atan2(
squareY2-squareY1, squareX2-squareX1);
g2.rotate(radians);

g2.drawRect(0, 0, 10, 10);
}
}

JSimpleAnimationComponent

One of the other things that I do from time to time is some Java programming, typically in the areas of user interface development and visualization. In particular, I'm often writing editors and visualization tools for knowledge engineering and AI systems.

This is not my full time job, so I should be considered more of a hobbyist than a professional, but I'm effective enough to develop prototype systems for demonstration or limited use.

Recently, for my semantic soccer wiki, I've been exploring the concept of developing little animated applets to visualize soccer tactics. Longer term, I'm interested in developing a soccer simulation that's (at least partly) driven by the semantic content of the wiki. In the near term, I'd just like to get some dots moving around on soccer field background image.

I've always had a bit of trouble with getting my Java applications to repaint properly, especially when I want things to move around. I spent an evening researching it and was more confused than ever. Finally, this morning I talked to a friend of mine who is more experienced in such things and he showed me that it is fairly simple after all.

Essentially, you need to do the following things:
  1. Create a subclass of a JComponent,
  2. Create a swing Timer to trigger an update message on a periodic basis,
  3. In the update message, move your sprites around and call the repaint() method, and
  4. Override paintComponent() to draw your sprites in the updated location.
It's so simple, but it took me a long time to work through it (and maybe never would have without my buddy). Therefore, I created a simple example that I thought I would share with the world called JSimpleAnimationComponent.

Here's the code:


import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.Timer;

/**
* A very simple panel that demonstrates
* how to create a Swing component that updates
* and repaints itself with a Timer.
*
* @author Keith Knudsen
*/
public class JSimpleAnimationComponent extends JComponent
implements ActionListener {

/**
* @param args
*/
public static void main(String[] args) {
JFrame frame = new JFrame("AnimationPanel");
frame.setDefaultCloseOperation(
JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add(
new JSimpleAnimationComponent(),
BorderLayout.CENTER);
frame.setSize(200,200);
frame.setVisible(true);
}

public JSimpleAnimationComponent () {
Timer timer = new Timer(50, this);
timer.start();
}

/* position of our little moving square */
int x = 10;
int y = 10;

/**
* Called by the timer. Update the position of
* our little moving square and then call repaint.
*/
public void actionPerformed(ActionEvent e) {
x++;
// keep the little square from running off the edge
if(x > this.getWidth()) {
x = 10;
}
repaint();
}

/*
* Paint the background and the little square
* at it's current position.
*/
public void paintComponent ( Graphics g )
{
// clean up the background from the previous draw
super.paintComponent(g);

// draw sprite
g.setColor(Color.RED);
g.drawRect(x, y, 10, 10);
}
}

Thursday, November 6, 2008

Semantic MediaWiki and Referata

As I discussed in my last post on Semantic Wikis, I've identified several good semantic wiki software applications. After reviewing them in more depth, I decided to try Semantic MediaWiki first because: 1) it's an extension of MediaWiki, the software behind Wikipedia (which I really like), 2) it seems very stable and well-supported, and 3) I can get a free hosted Semantic MediaWiki site at referata.com.

My intention is to evaluate this software as part of a larger project to develop a new user centered methodology for knowledge engineering of artificial intelligence systems. The process is still evolving but my loose concept of it contains roughly the following steps executed in a spiral model.

  1. Develop a human-readable knowledge base for the domain that looks something like Wikipedia, but constrained to a particular domain and scope. This serves the purposes of: a) requirements analysis, b) developing a controlled vocabulary, and c) can serve as explanatory and/or training material for users of the new system. Keep track of references and where multiple sources disagree.
  2. Take a first pass over the human-readable knowledge base to begin to identify the elements that would be important to a software system. Important nouns often become classes (in the computer science or ontology senses of the word). For each of these classes, you're looking for the important properties, relationships, rules and constraints. Ideally, all of this information can be captured back into the knowledge base in a form that can be read by both humans and computers.
  3. Use the knowledge base to drive some type of simulation that can be viewed and verified by subject matter experts. This shows that the computer has correctly understood and can generalize the information. Ideally, you maintain the link between the simulation and the knowledge base so that the computer can use the knowledge base to justify and/or explain its results.
So far, I've gotten started on step #1 above in the domain of "Youth Soccer." You can view the ongoing development at http://soccer.referata.com. I'm just starting to look at step #2. The results of that effort will be posted in a later blog.

See you next time!

-Keith

Monday, November 3, 2008

Semantic Wikis

As discussed in my previous post on Controlled Vocabularies, I'd really like to find a semantic wiki that can provide a nice repository for domain knowledge and can serve as an intermediary between subject matter experts (SMEs) and artificial intelligence (AI) systems. The key issue will be whether I can find a semantic wiki that is usable enough for SMEs yet expressive enough that they can provide value to the AI software.

After sifting through a much longer list, I narrowed it down to the following list of candidates that I'll be considering in more depth:
As I evaluate these tools, I'll be using soccer as my test case concept with a goal of creating a semantic wiki about soccer (I've recently started coaching my sons' team).

IkeWiki
From the screencast, it seems very usable. Allows the user to type first and then go back and tag content. Has a nice WYSIWYG editor such that the user doesn't have to remember the arcane Wiki codes for the most common tasks. No hosted options are available so I'm going to have to download and install this to try it out in more depth.

OntoWiki
The screencast looks pretty good. Seems very flexible. The user interface is a bit confusing to me. For example, they have "Register New User" in the search box instead of the login box. I couldn't really figure out the demo. Again there are no hosted versions, so I'll have to install this locally to really try it out.

Semantic MediaWiki
This is a product which adds semantic ontology extensions to the MediaWiki software. The website itself is also run with the Semantic MediaWiki software. Supposedly, Referata also uses the Semantic MediaWiki, but the two sites look very different. Perhaps it's just stylesheets or maybe Referata is running an older version?

I'm finding the user manual to be very useful.

Referata
Referata is a website that hosts the Sematic MediaWiki software. I tried their scratchpad wiki demo but I couldn't figure out how to construct a taxonomy. They support custom properties, but I couldn't see how to create relationships like "IsA" or synonyms. Update: The page on importing Ontologies showed me how to map ontology terms to MediaWiki terms.

I signed up for an account and will try to create my soccer wiki.