Thursday, November 13, 2008
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.
Wednesday, November 12, 2008
Graphics2D Rotate
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:
Here's the code:
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:
- Create a subclass of a JComponent,
- Create a swing Timer to trigger an update message on a periodic basis,
- In the update message, move your sprites around and call the repaint() method, and
- Override paintComponent() to draw your sprites in the updated location.
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.
See you next time!
-Keith
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.
- 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.
- 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.
- 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.
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.
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.
Wednesday, October 22, 2008
Controlled Vocabularies
In my mind, computer software is a type of tool created to help people perform some task. I use the word "task" in a broad sense to include non-work activities such as shopping, entertainment, etc. The design and creation of any tool requires an understanding of the end user, the task, the domain, and the context of use.
More fundamentally, the designer must ask, "What problem is this tool trying to solve and what aspects of the world are relevant?" Earlier, I posted Things, Properties, Actions and Relationships in which I listed a number of fields of study relevant to answering this question. In this post, I will focus on one such field, controlled vocabularies.
According to Wikipedia, a controlled vocabulary is "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."
Consistency is a good thing, but it can also become a rigid trap. Clay Shirky makes this point clearly in his article, Ontology is Overrated. Nevertheless, the act of writing computer software code typically imposes its own fairly rigid, formal specification and I would argue that this type of thinking is better done explicitly in the analysis / knowledge engineering phase rather than implicitly during the implementation phase. I'd like the systems that I design to be logical, consistent and embody concepts and language that map closely to that of the domain and end user.
Methods for Constructing Vocabularies
This section will discuss how controlled vocabularies are generated. I'm most familiar with end user interviewing techniques such as contextual inquiry. Concept mapping is another end user interactive techinue, and Boxes and arrows has a nice, web-focused description in their article, Creating a Controlled Vocabulary. When available, written documents and books can be mined. Essentially, these methods all boil down to:
I'd love to have a piece of software that could analyze a set of documents and produce a set of candidate terms to start my controlled vocabulary. I spent a few hours today surfing the web but didn't find exactly what I need. TermeXtractor is close to what I'm looking for, but it seemed to miss some important an obvious terms from my test case. When I ran the FIFA Laws of the Game PDF through TermeXtractor, it extracted useful terms like "goal line", "free kick" and "official", but it didn't extract some obvious terms like "football" which appears quite frequently and in the title. I also tried a similar online tool for terminology extraction by translated.net, but it had real problems with the hyphenation in my PDF and only returned the top 20 terms.
The Unstructured Information Management Architecture looks promising. In my experience, most software from the Apache foundation turns out to be worthwhile. However, the documentation is for developers rather than end-users and I'm not ready to spend days hacking code, yet. Similarly, while GATE provides more of a graphical user interface, it still assumes a level of technical knowledge (or time commitment to develop it) that I just don't have.
Interestingly, while I can find quite a bit of material on how this is done by a computer, I'm having a hard time finding detailed descriptions of how a human would go about doing this by hand. I guess it just falls under the broad category of reading. In a future post, I'm going to delve into this deeper with some more exhaustive searching and perhaps by attempting to roll my own methodology.
Tools for Organizing Vocabularies
The boxsandarrows.com article suggests the following tools:
Honestly, the best tool that I've found so far is Wikipedia, but I don't think that you can get that software as a tool for personal use. Luckily, it looks like I'm not the only one that's thought of this. A quick search on Google for "how to develop your own wikipedia" lists at least four articles on the topic. Next week I'm going to check into these and perhaps build my own wikipedia as part of my new controlled vocabulary methodology. Update: I just found that you can get the open source software that runs Wikipedia. It's called MediaWiki and you can even find free sites where you can create your own hosted wiki. I also found an extension of MediaWiki that sounds even more appropriate, called Semantic MediaWiki. More on this in a later post.
Stay tuned!
-Keith
More fundamentally, the designer must ask, "What problem is this tool trying to solve and what aspects of the world are relevant?" Earlier, I posted Things, Properties, Actions and Relationships in which I listed a number of fields of study relevant to answering this question. In this post, I will focus on one such field, controlled vocabularies.
According to Wikipedia, a controlled vocabulary is "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."
Consistency is a good thing, but it can also become a rigid trap. Clay Shirky makes this point clearly in his article, Ontology is Overrated. Nevertheless, the act of writing computer software code typically imposes its own fairly rigid, formal specification and I would argue that this type of thinking is better done explicitly in the analysis / knowledge engineering phase rather than implicitly during the implementation phase. I'd like the systems that I design to be logical, consistent and embody concepts and language that map closely to that of the domain and end user.
Methods for Constructing Vocabularies
This section will discuss how controlled vocabularies are generated. I'm most familiar with end user interviewing techniques such as contextual inquiry. Concept mapping is another end user interactive techinue, and Boxes and arrows has a nice, web-focused description in their article, Creating a Controlled Vocabulary. When available, written documents and books can be mined. Essentially, these methods all boil down to:
- Gather samples of domain language use (through verbal interviewing and other end user techniques or finding written documents and books).
- Extract terminology.
- Review and refine with subject matter experts.
I'd love to have a piece of software that could analyze a set of documents and produce a set of candidate terms to start my controlled vocabulary. I spent a few hours today surfing the web but didn't find exactly what I need. TermeXtractor is close to what I'm looking for, but it seemed to miss some important an obvious terms from my test case. When I ran the FIFA Laws of the Game PDF through TermeXtractor, it extracted useful terms like "goal line", "free kick" and "official", but it didn't extract some obvious terms like "football" which appears quite frequently and in the title. I also tried a similar online tool for terminology extraction by translated.net, but it had real problems with the hyphenation in my PDF and only returned the top 20 terms.
The Unstructured Information Management Architecture looks promising. In my experience, most software from the Apache foundation turns out to be worthwhile. However, the documentation is for developers rather than end-users and I'm not ready to spend days hacking code, yet. Similarly, while GATE provides more of a graphical user interface, it still assumes a level of technical knowledge (or time commitment to develop it) that I just don't have.
Interestingly, while I can find quite a bit of material on how this is done by a computer, I'm having a hard time finding detailed descriptions of how a human would go about doing this by hand. I guess it just falls under the broad category of reading. In a future post, I'm going to delve into this deeper with some more exhaustive searching and perhaps by attempting to roll my own methodology.
Tools for Organizing Vocabularies
The boxsandarrows.com article suggests the following tools:
- a thesaurus maintenance program like Multites, Term Tree, ThManager or Lexico,
- Microsof Excel,
- Post-it Notes, or even
- a wiki or semantic wiki
Honestly, the best tool that I've found so far is Wikipedia, but I don't think that you can get that software as a tool for personal use. Luckily, it looks like I'm not the only one that's thought of this. A quick search on Google for "how to develop your own wikipedia" lists at least four articles on the topic. Next week I'm going to check into these and perhaps build my own wikipedia as part of my new controlled vocabulary methodology. Update: I just found that you can get the open source software that runs Wikipedia. It's called MediaWiki and you can even find free sites where you can create your own hosted wiki. I also found an extension of MediaWiki that sounds even more appropriate, called Semantic MediaWiki. More on this in a later post.
Stay tuned!
-Keith
Tuesday, October 21, 2008
Things, Properties, Actions and Relationships
I'm at a nice place right now on a number of my projects: the beginning.
Right after the proposal is accepted and before you really realize how hard the problem is going to be and how little you'll actually be able to accomplish in the grand scheme of things, it's a wonderful time of hope and promise. This is also known as the analysis phase.
In this blog post, I'm going to delve into a particular aspect of the analysis phase where you try to capture the important things, properties, actions and relationships. In other words, you try to capture the taxonomy/glossary/schema used by the important stakeholders in your problem space.
A number of fields have defined processes to address this problem: HCI uses contextual inquiry, information architecture or cognitive task analysis (CTA), software engineering uses requirements analysis or object oriented analysis, artificial intelligence uses CTA or knowledge engineering, etc. As a side note, I'm continually amazed by how each field uses terms and methods that are so eerily similar, yet often without seeming to realize it. I'll have to go deeper on this topic in another post.
So what are we really talking about here? At a deeper level, we're really talking about language and meaning. What are the words and symbols that people use and what is the underlying conceptual meaning that they attach to those words?
In philosophy, ontology is the study of what things exist and of the basic categories and relationships between those things. In information science and artificial intelligence ontology is a formal representation of a set of concepts and their interrelationships. This is closely related to concept learning from psychology and the concepts of taxonomy and controlled vocabulary.
I don't really want to go into depth on each of these topics right now, but I will say that after a bit of exploration, controlled vocabulary seems to have the closest match to what I'm looking to develop for each of the projects that I'm working on. I found a nice series of articles on boxes and arrows starting with What is a controlled vocabulary? that I'm currently reading.
In my next blog entry, I want to explore some specific methods and tools for capturing and sharign controlled vocabularies. I currently have the following two specific leads:
See you next time!
-Keith
Right after the proposal is accepted and before you really realize how hard the problem is going to be and how little you'll actually be able to accomplish in the grand scheme of things, it's a wonderful time of hope and promise. This is also known as the analysis phase.
In this blog post, I'm going to delve into a particular aspect of the analysis phase where you try to capture the important things, properties, actions and relationships. In other words, you try to capture the taxonomy/glossary/schema used by the important stakeholders in your problem space.
A number of fields have defined processes to address this problem: HCI uses contextual inquiry, information architecture or cognitive task analysis (CTA), software engineering uses requirements analysis or object oriented analysis, artificial intelligence uses CTA or knowledge engineering, etc. As a side note, I'm continually amazed by how each field uses terms and methods that are so eerily similar, yet often without seeming to realize it. I'll have to go deeper on this topic in another post.
So what are we really talking about here? At a deeper level, we're really talking about language and meaning. What are the words and symbols that people use and what is the underlying conceptual meaning that they attach to those words?
In philosophy, ontology is the study of what things exist and of the basic categories and relationships between those things. In information science and artificial intelligence ontology is a formal representation of a set of concepts and their interrelationships. This is closely related to concept learning from psychology and the concepts of taxonomy and controlled vocabulary.
I don't really want to go into depth on each of these topics right now, but I will say that after a bit of exploration, controlled vocabulary seems to have the closest match to what I'm looking to develop for each of the projects that I'm working on. I found a nice series of articles on boxes and arrows starting with What is a controlled vocabulary? that I'm currently reading.
In my next blog entry, I want to explore some specific methods and tools for capturing and sharign controlled vocabularies. I currently have the following two specific leads:
See you next time!
-Keith
Subscribe to:
Posts (Atom)