an Introduction to Object Classifier/Object Browser


written by omura@computer.org

contents

  1. The aim
  2. simple sample
  3. complicated sample
  4. Object Browser(an application of OC /Allogro Common Lisp)
  5. Syntax and Semantics of Object Classifier's define form
  6. Demo

The aim

The first intension of mine of object classifier is that I view the objects in browser as file browser, but I can chooese the displayed structure dependent on the property/attribute of the objects. It will be an object browser as class browser. But it shows the objects not as some inspector of objects.

The classification structure of object is tree in this system. Given an object x, the classifier place x on an appropriate node of the tree. If the node is not exist, the classifier make a node that holds the object x.

Which object is hold in an node is described as predicate. The objects on an node N satisfy the predicate which associate to N and the all predicates which are associated with the node that is on the path from root to N.

For the indefinite length tree such as directory is specified with finite description for tree, the classification definition specifies slots for every nodes. The slots behaves as state of the node, and help the recursive construction of the nodes.

The Object Browser(OB) is an application of OC.
That supplies an GUI for OC. But now, it run on Allegro Common Lisp only.
(Allegro CL Lite for Windows Version: 3.0.2 Lite (Franz Inc.))

simple example

Let's think classification of books. First I define a class document represents a book.
(defclass document ()
  ((title    :initarg :title    :reader doc-title)
   (lang     :initarg :lang     :reader doc-lang)
   (author   :initarg :author   :reader doc-author)
   (thema    :initarg :thema    :reader doc-thema)
   (keyword  :initarg :keyword  :reader doc-keyword :initform nil)
   (pub-year :initarg :pub-year :reader doc-pub-year :initform 1997)
   )
  )
the function display shows the information of the document.
(defmethod display ((doc document))
  (format t "{~A by ~A#~A#~A#~S}"
    (and (slot-boundp doc 'title)   (doc-title doc))
    (and (slot-boundp doc 'author)  (doc-author doc))
    (and (slot-boundp doc 'thema)   (doc-thema doc))
    (and (slot-boundp doc 'lang)    (doc-lang doc))
    (and (slot-boundp doc 'keyword) (doc-keyword doc))
    (and (slot-boundp doc 'pub-year)(doc-pub-year doc))
    )
  )
Now, I define the classification definition as classifiy the document with thema, author, and lang in this order.
(defclassifier
    simple-classifier1
    nil
   (thema (t)
         (lambda (obj part) (doc-thema obj))
         (lambda (obj part) (slot-exists-boundp obj 'thema)))
   (author (thema)
         (lambda (obj part) (slot-value obj 'author))
         (lambda (obj part) (slot-exists-boundp obj 'author) ))
   (lang (author)
         (lambda (obj part) (doc-lang obj) )
         (lambda (obj part) (slot-exists-boundp obj 'lang)))
   )

description

defclassifier makes a classifier.
An instance of a classifier(this is a class) is a tree structured container for objects.

In this example, simple-classifier1 is the classifier.
The next nil will be explained later.
The following codes are the definition for the classification.
The first part:

   (thema ()
         (lambda (obj part) (doc-thema obj))
         (lambda (obj part) (slot-exists-boundp obj 'thema)))

Such a construct is called as category.
An object is classified by these categories
thema is the name of this category. It means the thema of the document.

The next (t) means the parent category of theme.
Where, category t is the root category which is the parent for all of categories. If you already see the demo of file browser, y have seen it in file browser's first view.

The next function will see later, skipped it now. The last function:

(lambda (obj part) (slot-exists-boundp obj 'thema)
is the constraint for the objects belong to the category theme.

constraint function's interface: it has 2 arguments. 1st argument is the object that is classified. 2nd argument is a little complicated, so explain later. constraint function's return value is boolean(i.e. t or nil)

In this example, the constraint says "the object has a slot thema, and it must be bound"

Now, before go back to the function (lambda (obj part) (doc-thema obj)), I would explain the representation and partition.

A object which satisfies the constraint of a category, is thought as belonging to that category. But more over, these objects are grouped in some partitions. Representation is the name of such a partition.
In the above example, the individual values "novel", "computer science" are suitable for the representaion, and the intuitively make partitions.

Important point is there are many partitions in a category. Every partition have children partitions in respect to the category's definition.

For example, when there are "omura" and "tanaka" as author's value, there may be these partitions as children of "novel", and while there may be there partitions as children of "computer sciennce".

Now, return to the explanation of (lambda (x) (doc-thema x)). This defines the representation, and partition as the set with the same representation.

the representation has 1 argument. It is object, it's value is any object.

There is only one partition of category t. The partition is called representation t or partition t. This is the root of all partitions.

sample of run

Let's think the document's instances.
(setf doc (list
            (make-instance 'document
                           :title "reference manual"
                           :lang  'japan
                           :author "omura"
                           :thema "Computer Science"
                           :keyword '("Object Oriented" "Lisp")
                           )
            (make-instance 'document
                           :title "user's manual"
                           :lang  'japan
                           :author "omura"
                           :thema "mathematics"
                           :keyword '("Object Oriented" "Lisp")
                           )
            (make-instance 'document
                           :title "Quick Start"
                           :lang  'japan
                           :author "tanaka"
                           :thema "Novel"
                           :keyword '("Object Oriented" "Lisp")
                           )))
We can see a classification as the following picture by ObjectBrowser with simple-classifier1 on doc.

<xmp>#<Document...><xmp> at every leaf represent the object.
Such a representation of object may be changed by put the method to ObjectBrowser with argument that display the object.

complicated example

Here, let's examine the File Browser(filebrow.lsp).
The classifier is below.

In this example, the second argument of defclassifier is specified.
The variable (level) that is specified as 2nd arg, is assigned to the every partition.
In this example, level has the level number of the directory hierarchy.


(defun max-level (part)
   (if part
      (loop for parent in (parent* part) maximize (level parent))
      0
      )
   )

(defun my-dir-name (obj part)
   (setf (level part) (1+ (max-level part)))
   (nth (level part)(pathname-directory obj))
   )

(defun dir-p (obj part)
   (nth (1+ (max-level part)) (pathname-directory obj))
   )

(defclassifier
  filelist2
  '((level :initform 0 :accessor level))
  (directory (t directory)
    my-dir-name
    dir-p
    )
  )

(filebrowser 'filelist2  "K:\\ALLEGRO\\lispwork\\testdir\\")

Here the representation of objects is raw object format in ACL, for change therepresentation as below.

(filebrowser 'filelist2  "K:\\ALLEGRO\\lispwork\\testdir\\" 'file-namestring)

Syntax and Semantics of Object Classifier's define form

specification

Next step

I want to expand the theory of OC from tree structure to graph structure.

caution and ...

  1. In category defintion, when a node has many parents, there must not cycle between them.
    Namely, {a, b} is the parents of the category c, a>b and b>a must not stand. Where a>b means for a is a parent of b.
  2. I can't see the full means of cyclics in category definition(as file browser). Some complex definitions with cycles may go in unexpected results. If you see it, please let know me it.

Demo

For most impressive demonstration, please use Allegro CL for Windows. (Allegro CL for Windows is a trade mark of Franz Inc, Berkeley, CA, USA.)
  1. load the files "filebrow.lsp", show the directory tree in current directory.
  2. load the file "democ.lsp", and open the file. this demos show how customize the classification by simple definitions. see the defclassifier description in the sources.

Without ACL, some test programs(testc1-1.lsp, testc1-2.lsp) show ObjectClassifier's ability, but not so impressive...