1 %;; arxana.tex -*- mode: Emacs-Lisp; -*-
2 %;; Copyright (C) 2005-2009 Joe Corneli <holtzermann17@gmail.com>
4 %;; This program is free software: you can redistribute it and/or modify
5 %;; it under the terms of the GNU Affero General Public License as published by
6 %;; the Free Software Foundation, either version 3 of the License, or
7 %;; (at your option) any later version.
9 %;; This program is distributed in the hope that it will be useful,
10 %;; but WITHOUT ANY WARRANTY; without even the implied warranty of
11 %;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 %;; GNU Affero General Public License for more details.
14 %;; You should have received a copy of the GNU Affero General Public License
15 %;; along with this program. If not, see <http://www.gnu.org/licenses/>.
18 % (find-file "~/arxana.tex")
20 % (goto-char (point-max))
21 % (let ((beg (progn (search-backward "\\begin{verbatim}")
23 % (end (progn (search-forward "\\end{verbatim}")
24 % (match-beginning 0))))
25 % (eval-region beg end)
30 %% To load: remove %'s above and evaluate with C-x C-e.
32 %% Alternatively, run this:
33 % head -n 13 arxana.tex | sed -e "/%/s///" > arxana-loader.el
34 %% on the command line to produce something you can use
35 %% to load Arxana when you start Emacs:
36 % emacs -l arxana-loader.el
38 %% Or put the expression in your ~/.emacs (perhaps wrapped
39 %% in function like `eval-arxana').
41 %% Or search for a similar form below and evaluate there!
43 %% Q. Where exactly are we supposed to store the most
44 %% up-to-date Arxana files when they are ready to go?
46 %% A. Copy them into /usr/lib/sbcl/site-systems/arxana/
47 %% and that should be enough. Make sure that arxana.asd
48 %% is in that directory and that you have a symbolic link,
51 %% ln -s ./arxana/arxana.asd .
53 %% in the directory /usr/lib/sbcl/site-systems/
54 %% -- Make sure to load once as root to generate new fasls.
56 %% Q. How to run the remote slime after that?
58 %% A. Make sure that Emacs `slime-protocol-version' matches
59 %% Common Lisp's `swank::*swank-wire-protocol-version*', then,
62 %% ssh -L 4005:127.0.0.1:4005 joe@li23-125.members.linode.com
64 %% M-x slime-connect RET RET
68 \documentclass{article
}
74 \newcommand{\meta}[1]{$
\langle$
{\it #1}$
\rangle$
}
76 \theoremstyle{definition
}
77 \newtheorem{nota
}{Note
}[section
]
81 \newenvironment{notate
}[1]
82 {\begin{nota
}[{\bf {\em #1}}]}%
86 \newenvironment{elisp
}
87 {\let\ORGverbatim@font
\verbatim@font
88 \def\verbatim@font
{\ttfamily\scshape}%
91 \let\verbatim@font
\ORGverbatim@font
}
95 \newenvironment{common
}[1]
96 {\let\ORGverbatim@font
\verbatim@font
97 \def\verbatim@font
{\ttfamily\scshape}%
100 \let\verbatim@font
\ORGverbatim@font
}
104 \newenvironment{idea
}
105 {\let\ORGverbatim@font
\verbatim@font
106 \def\verbatim@font
{\ttfamily\slshape}%
109 \let\verbatim@font
\ORGverbatim@font
}
114 \title{\emph{Arxana
}}
116 \author{Joseph Corneli
\thanks{Copyright (C)
2005-
2010
117 Joseph Corneli
{\tt <holtzermann17@gmail.com>
}\newline
118 $
\longrightarrow$ transferred to the public domain.
}}
119 \date{Last revised:
\today}
123 \abstract{A tool for building hackable semantic hypertext
124 platforms. Source code and mailing lists are at
{\tt
125 http://common-lisp.net/project/arxana
}.
}
129 \section{Introduction
}
131 \begin{notate
}{What is ``Arxana''?
} \label{arxana
}
132 \emph{Arxana
} is the name of a ``next generation''
133 hypertext system that emphasizes annotation. Every object
134 in this system is annotatable. Because of this, I
135 sometimes call Arxana's core ``the scholium system'', but
136 the name ``Arxana'' better reflects our aim: to explore
137 the mysterious world of links, attachments,
138 correspondences, and side-effects.
141 \begin{notate
}{The idea
} \label{theoretical-context
}
142 A scholia-based
document model for commons-based peer
143 production will inform the development of our
144 system.
\footnote{{\tt
145 http://www.metascholar.org/events/
2005/freeculture/viewabstract.php?id=
19
147 % http://br.endernet.org/~akrowne/planetmath/papers/corneli\_fcdl/corneli-krowne.pdf
148 \label{corneli-krowne
}
150 In this model, texts are made up of smaller texts until
151 you get to atomic texts; user actions are built in the
152 same way. Multiple users should interact with a shared
153 persistent data-store, through functional annotation, not
154 destructive modification. We should pursue the
155 asynchronous interaction model until we arrive at live,
156 synchronous, settings, where we facilitate real-time
157 computer-mediated interactions between users, and between
158 users and running hackable programs.
161 \begin{notate
}{The data model
} \label{data-model
}
162 Start by storing a collection of
\emph{strings
}. Now add
163 in
\emph{pairs
} and
\emph{triples
} which point at
2 and
3
164 objects respectively. (We can extend to n-tuples if that
165 turns out to be convenient.) Finally, we will maintain a
166 collection of
\emph{lists
}, each of which points at an
167 unlimited number of objects.
170 \begin{notate
}{History
}
171 Thinking about how to improve existing systems for
172 peer-based collaboration in
2004, I designed a simple
173 version of the scholium system that treated textual
174 commentary and markup as scholia.
\footnote{{\tt
175 http://wiki.planetmath.org/AsteroidMeta/old
\_draft\_of\_scholium\_system}}
176 In
2006, I put together a single-user version of this
177 system that ran exclusively under Emacs.
\footnote{{\tt
178 http://metameso.org/files/sbdm4cbpp.tex
} \label{old-version
}}
179 The current system is an almost-completely rewritten
180 variant, bringing in a shared database and various other
181 enhancements to support multi-user interaction.
184 \begin{notate
}{A brisk review of the programming literature
} \label{prog-lit-review
}
185 Many years before I started working on this project, there
186 was something called the Emacs HyperText
187 System.
\footnote{{\tt
188 http://www.aue.aau.dk/\~
{}kock/Publications/HyperBase/
}}
189 What we're doing here updates for modern database methods,
190 uses a more interesting data storage format, and also
191 considers multiple front-ends to the same database (for
192 example, a web interface).
194 Contemporary Emacs-based hypertext creation systems
195 include Muse and Emacs Wiki.
\footnote{{\tt
196 http://mwolson.org/projects/EmacsMuse.html
}}$^,$
\footnote{{\tt
197 http://mwolson.org/projects/EmacsWiki.html
}} The
198 browsing side features old standbys, Info and
199 Emacs/w3m
\footnote{Not to be confused with Emacs-w3m,
200 which is not entirely ``Emacs-based''.
}. These packages
201 provide ways to author or view what what we should now
202 call ``traditional'' hypertext documents.
204 An another legacy tool worth mentioning is
205 HyperCard
\footnote{{\tt
206 http://en.wikipedia.org/wiki/HyperCard
}}. This system
207 was oriented around the idea of using hypertext to create
208 software, a vision we share, but like just about everyone
209 else working in the field at the time, it used
210 uni-directional links.
212 Hypertext
\emph{nouveau
} is based on semantic triples.
213 The Semantic Web standard provides one specification of
214 the features we can expect from triples.
\footnote{{\tt
215 http://www.w3.org/TR/
2004/REC-rdf-primer-
20040210/
}}
216 Triples provide a framework for knowledge representation
217 with more depth and flexibility than the popular
218 ``tagging'' methodology. For example, suitable
219 collections of triples implement AI-style ``frames''. The
220 idea of using triples to organize archival material is
221 generating some interest as Semantic Web ideas
222 spread.
\footnote{Cf. recent museum and library
223 conferences
}$^,$
\footnote{Even among academic computer
224 scientists! (Josh Grochow, p.c.)
}
226 An abstractly similar project to Arxana with some grand
227 goals is being developed by Chris Hanson at MIT under the
228 name ``Web-scale Environments for Deduction
229 Systems''.
\footnote{{\tt
230 http://publications.csail.mit.edu/abstracts/abstracts07/cph2/cph2.html
}}
232 Another technically similar project is Freebase, a hand
233 rolled database of open content, organized on frame-based,
234 triple driven, principles. The developer of the Freebase
235 graphd database has some interesting things to say about
236 old and new ways of handling triples.
\footnote{{\tt
237 http://blog.freebase.com/
2008/
04/
09/a-brief-tour-of-graphd/
}}
240 \begin{notate
}{Fitting in
}
241 My current development goal is to use this system to
242 create a more flexible multiuser interaction platform than
243 those currently available to web-based collaborative
244 projects (such as PlanetMath
\footnote{{\tt
245 http://planetmath.org
}}). As an intermediate stage,
246 I'm using Arxana to help organize material for a book I'm
247 writing. Arxana's theoretical generality, active
248 development status, detailed documentation, and
249 superlatively liberal terms of use may make it an
250 attractive option for you to try as well!
253 \begin{notate
}{What you get
}
254 Arxana has an Emacs frontend, a Common Lisp middle-end,
255 and a SQL backend. If you want to do some work, any one
256 of these components can be swapped out and replaced with
257 the engine of your choice. I've released all of the
258 implementation work on this system into the public domain,
259 and it runs on an entirely free/libre/open source software
263 \begin{notate
}{Acknowledgements
}
264 Ted Nelson's ``Literary Machines'' and Marvin Minsky's
265 ``Society of Mind'' are cornerstones in the historical and
266 social contextualization of this work. Alfred Korzybski's
267 ``Science and Sanity'' and Gilles Deleuze's ``The Logic of
268 Sense'' provided grounding and encouragement.
\TeX\ and
269 GNU Emacs have been useful not just in prototyping this
270 system, but also as exemplary projects in the genre I'm
271 aiming for. John McCarthy's Elephant
2000 was an
272 inspiring thing to look at and think about
\footnote{{\tt
273 http://www-formal.stanford.edu/jmc/elephant/elephant.html
}}, and of course Lisp has been a vital ingredient.
275 Thanks also to everyone who's talked about this project
279 \section{Using the program
}
281 \begin{notate
}{Dependencies
} \label{dependencies
}
282 Our interface is embedded in Emacs. Backend processing is
283 done with Common Lisp. We are currently using the
284 PostgreSQL database. These packages should be available
285 to you through the usual channels. (I've been using SBCL,
286 but any Lisp should do; please make sure you are using a
287 contemporary Emacs version.)
289 We will connect Emacs to Lisp via Slime
\footnote{{\tt
290 http://common-lisp.net/project/slime/
}}, and Lisp to
291 PostgreSQL via CLSQL.
\footnote{{\tt http://clsql.b9.com/
}}
292 CLSQL also talks directly to the Sphinx search engine,
293 which we use for text-based search.
\footnote{{\tt
294 http://www.sphinxsearch.com/
}} Once all of these
295 things are installed and working together, you should be
296 able to begin to use Arxana.
298 Setting up all of these packages can be a somewhat
299 time-consuming and confusing task, especially if you
300 haven't done it before! See Appendix
\ref{appendix-setup
}
304 \begin{notate
}{Export code and set up the interface
}
305 If you are looking at the source version of this
document
306 in Emacs, evaluate the following s-expression (type
307 \emph{C-x C-e
} with the cursor positioned just after its
308 final parenthesis). This exports the Common Lisp
309 components of the program to suitable files for subsequent
310 use, and prepares the Emacs environment. (The code that
311 does this is in Appendix
\ref{appendix-lit
}.)
316 (let ((beg (search-forward "\
\begin{verbatim
}"))
317 (end (progn (search-forward "\
\end{verbatim
}")
318 (match-beginning
0))))
319 (eval-region beg end)
323 \begin{notate
}{To load Common Lisp components at run-time
} \label{load-at-runtime
}
324 Link
{\tt arxana.asd
} somewhere where Lisp can find it.
325 Then run commands like these in your Lisp; if you like,
326 you can place all of this stuff in your config file to
327 automatically load Arxana when Lisp starts. The final
328 form is only necessary if you plan to use CLSQL's special
329 syntax on the Lisp command-line.
333 (asdf:operate 'asdf:load-op 'clsql)
334 (asdf:operate 'asdf:load-op 'arxana)
336 (connect-to-database)
337 (locally-enable-sql-reader-syntax)
340 \begin{notate
}{To connect Emacs to Lisp
}
341 Either run
{\tt M-x slime RET
} to start and connect to
342 Lisp locally, or
{\tt M-x slime-connect RET RET
} after you
343 have opened a remote connection to your remote server with
344 a command like this:
{\tt ssh -L
4005:
127.0.0.1:
4005
345 <username>@<host>
} and started Lisp and the Swank server
346 on the remote machine. To have Swank start automatically
347 when you start Lisp, put commands like this in your config
352 (asdf:operate 'asdf:load-op 'swank)
353 (setf swank:*use-dedicated-output-stream* nil)
354 (setf swank:*communication-style* :fd-handler)
355 (swank:create-server :dont-close t)
358 \begin{notate
}{To define database structures
}
359 If you haven't yet defined the basic database structures,
360 make sure to load them now! (Using
{\tt tabledefs.lisp
},
361 or the SQL code in Section
\ref{sql-code
})
364 \begin{notate
}{Importing this
document into system
}
365 You can browse this
document inside Arxana: after loading
366 the code, run
\emph{M-x autoimport-arxana
}.
369 %%%% START OF BACKEND
370 \input{arxana-reboot-backend
}
373 \section{Emacs-side
} \label{emacs-side
}
375 \subsection{The interface to Common Lisp
}
377 \begin{notate
}{On `Defun'
} \label{defun-interface
}
378 A way to define Elisp functions whose bodies are evaluated
379 by Common Lisp. Trust me, this is a good idea. Besides,
380 it exhibits some facinating backquote and comma tricks.
381 But be careful: this definition of `Defun' did not work on
384 If we want to be able to feed in a standard arglist to
385 Common Lisp (with optional elements and so forth), we'd
386 have define how these arguments are handled here!
390 (defmacro Defun (name arglist &rest body)
391 (declare (indent defun))
392 `(defun ,name ,arglist
393 (let* ((outbound-string
394 (translate-emacs-syntax-to-common-syntax
398 (append (list 'lambda ',arglist)
401 (lambda (arg) `',arg)
410 ;; we now specify the right package!
412 (list 'swank:eval-and-grab-output
415 (process-slime-output returned-string))))
418 \begin{notate
}{On `process-slime-output'
}
419 This should downcase all constituent symbols, but for
420 expediency I'm just downcasing `NIL' at the moment. Will
421 come back for more testing and downcasing shortly. (I
422 suspect the general case is just about as easy as what
427 (defun process-slime-output (str)
429 (let ((read-value (read str)))
430 (if (symbolp read-value)
431 (read (downcase str)))
432 (nsubst nil 'NIL read-value))
437 (defun translate-emacs-syntax-to-common-syntax (str)
440 (dolist (swap '(("(\\` " "`")
442 (goto-char (point-min))
443 (while (search-forward (first swap) nil t)
444 (goto-char (match-beginning
0))
447 (goto-char (match-beginning
0))
448 (delete-region (match-beginning
0)
450 (insert (second swap))))
451 (buffer-substring-no-properties (point-min)
455 \begin{notate
}{Interactive `Defun'
}
456 Note, an improved version of this macro would allow me to
457 specify that some Defuns are interactive and some are not.
458 This could be done by examining the submitted body, and
459 adjusting the defun if its car is an `interactive' form.
460 Most of the Defuns will be things that people will want to
461 use interactively, so making this change would probably be
462 a good idea. What I'm doing in the mean time is just
463 writing
2 functions each time I need to make an
464 interactive function that accesses Common Lisp data!
467 \begin{notate
}{Common Lisp evaluation of code chunks
}
468 Another potentially beneficial and simple approach is to
469 write a form like `progn' that evaluates its contents on
470 Common Lisp. This saves us from having to rewrite all of
471 the `defun' facilities into `Defun' (e.g. interactivity).
472 But... the problem with
\emph{this
} is that Common Lisp
473 doesn't know the names of all the variables that are
474 defined in Emacs! I'm not sure how to get all of the
475 values of these variable substituted
\emph{first
}, before
476 the call to Common Lisp is made.
479 \begin{notate
}{Debugging `Defun'
}
480 In order to make debugging go easier, it might be nice to
481 have an option to make the code that is supposed to be
482 evaluated by Defun actually
\emph{print
} on the REPL
483 instead of being processed through an invisible back-end.
484 There could be a couple of different ways to do that, one
485 would be to simulate just what a user might do, the other
486 would be a happy medium between that and what we're doing
487 now: just put our computery auto-generated code on the
488 REPL and evaluate it. (To some extent, I think the
489 *slime-events* buffer captures this information, but it is
490 not particularly easy to read.)
493 \begin{notate
}{Interactive Common Lisp?
}
494 Suppose we set up some kind of interactive environment in
495 Common Lisp; how would we go about passing this
496 environment along to a user interacting via Emacs? (Note
497 that SLIME's presentation of the debugging loop is one
501 \subsection{Database interaction
} \label{interaction
}
503 \begin{notate
}{The `article' function
} \label{the-article-function
}
504 You can use this function to create an article with a
505 given name and contents. If you like you can put it in a
510 (Defun article (name contents &optional heading)
511 (let ((coordinates (add-triple name
514 (when theory (add-triple coordinates "in" heading))
515 (when place (if (numberp place)
516 (put-in-place coordinates place)
517 (put-in-place coordinates)))
521 \begin{notate
}{The `scholium' function
} \label{the-scholium-function
}
522 You can use this function to link annotations to objects.
523 As with the `article' function, you can optionally
524 categorize the connection on a given list (cf. Note
525 \ref{the-article-function
}).
529 (Defun scholium (beginning link end &optional heading)
530 (let ((coordinates (add-triple beginning
533 (when list (add-triple coordinates "in" heading))
534 (when place (if (numberp place)
535 (put-in-place coordinates place)
536 (put-in-place coordinates)))
540 \begin{notate
}{Uses of coordinates
}
541 Note that, if desired, you can feed input of the form
542 '(
\meta{code
} \meta{ref
}) into `article' and `scholium'.
543 It's convenient to do further any processing of the object
544 we've created, while we still have ahold of the coordinates
545 returned by `add-triple' (cf. Note
546 \ref{import-code-continuations
} for an example).
549 \begin{notate
}{Finding all the members of a list by type?
}
550 We just narrow according to type.
553 \begin{notate
}{On `get-article'
} \label{get-article
}
554 Get the contents of the article named `name'. Optional
555 argument `list' lets us find and use the position on the
556 given list that holds the name, and use that instead of
559 We do not yet deal well with the ambiguous case in which
560 there are several positions that correspond to the given
561 name that appear on the same list.
563 Note also that out of the data returned by
564 `triples-given-beginning-and-middle', we should pick the
565 (hopefully just) ONE that corresponds to the given list.
567 This means we need to pick over the list of triples
568 returned here, and test each one to see if it is in our
569 heading. As to WHY there might be more than one ``has
570 content'' for a place that we know to be in our
571 heading... I'm not sure. I guess we can go with the
572 assumption that there is just one, for now.
576 (Defun get-article (name &optional heading)
577 (let* ((place-pseudonyms
579 (get-places-subject-to-constraint
580 name `(nil "in" ,heading))
583 ((eq (length place-pseudonyms)
1)
584 `(
1 ,(car place-pseudonyms)))
591 ;; it might be nice to also return `goes-by'
592 ;; so we can access the appropriate place again.
595 (triples-given-beginning-and-middle
596 goes-by "has content"))
600 \begin{notate
}{On `get-names'
} \label{get-names
}
601 This function simply gets the names of articles that have
602 names -- in other words, every triple built around the
603 ``has content'' relation.
607 (Defun get-names (&optional heading)
608 (let ((conditions (list (list nil "has content" t))))
612 (list (list nil "in" heading)))))
614 (lambda (place-or-string)
617 ((eq (first place-or-string)
1)
619 (place-lookup (second place-or-string))))
621 ((eq (first place-or-string)
0)
622 (print-system-object place-or-string))))
625 (isolate-beginning triple))
626 (satisfy-conditions conditions)))))
629 \begin{notate
}{Contrasting cases
} \label{contrasting-cases
}
630 Consider the difference between
632 (? ``has author'' ``Arthur C. Clarke'') \\
633 (? ``has genre'' ``fiction'')
637 (
\emph{name
} ``has content'' *) \\
638 (
\emph{name
} ``in'' ``heading'')
640 where, in the latter case, we know
\emph{who
} we're
641 talking about, and we just want to limit the list of items
642 generated by the ``*'' by the second condition. This
643 should help illustrate the difference between `get-names'
644 (which is making a general query) and `get-article' (which
645 already knows the name of a specific article), and the
649 \begin{notate
}{Placing items from Emacs
} \label{place-item
}
650 We periodically need to place items from within Emacs.
651 The function `place-item' is a wrapper for `put-in-place'
652 that makes this possible (it also provides the user with
653 an extra option, namely to put the place itself under a
656 Notice that when the symbol is placed in some pre-existing
657 place (which can only happen when `id' is not nil), that
658 place may already be under some other heading. We will ignore
659 this case for now (since it seems that putting objects
660 into
\emph{new
} places will be the preferred action), but
661 later we will have to look at what to do in this other
666 (Defun place-item (symbol &optional id heading)
667 (let ((coordinates (put-in-place symbol id)))
668 (when heading (add-triple coordinates "in" heading))
672 \begin{notate
}{Automatic classifications
} \label{classifications
}
673 It will presumably make sense to offer increasingly
674 ``automatic'' classifications for new objects. At this
675 point, we've set things up so that the user can optionally
676 supply the name of
\emph{one
} heading that their new object
679 It may make more sense to allow an `\&rest theories'
680 argument, and add the triple to all of the specified
681 theories. This would require modifying `Defun' to
682 accommodate the `\&rest' idiom; see Note
683 \ref{defun-interface
}.
686 \begin{notate
}{Postconditions and provenance
}
687 After adding something to the database, we may want to do
688 something extra; perhaps generating provenance
689 information, perhaps checking or enforcing database
690 consistency, or perhaps running a hook that causes some
691 update in the frontend (cf. Note
\ref{provenance
}).
692 Provisions of this sort will come later, as will
693 short-hand convenience functions for making particularly
694 common complex entries.
697 \subsection{Importing
\LaTeX\ documents
} \label{importing
}
699 \begin{notate
}{Importing sketch
} \label{importing-sketch
}
700 The code in this section imports a
document as a
701 collection of (sub-)sections and notes. It gathers the
702 sections, sub-sections, and notes recursively and records
703 their content in a tree whose nodes are places (Note
704 \ref{places
}) and whose links express the ``component-of''
705 relation described in Note
\ref{order-of-order
}.
707 This representation lets us see the geometric,
708 hierarchical, structure of the
document we've imported.
709 It exemplifies a general principle, that geometric data
710 should be represented by relationships between places, not
711 direct relationships between strings. This is because
712 ``the same'' string often appears in ``different'' places
713 in any given
document (e.g. a paper's many sub-sections
714 titled ``Introduction'' will not all have the same
717 What goes into the places is in some sense arbitrary. The
718 key is that whatever is
\emph{in
} or
\emph{attached
} to
719 these places must tell us everything we need to know about
720 the part of the
document associated with that place
721 (e.g. in the case of a note, its title and contents).
722 That's over and above the
\emph{structural
} links which
723 say how the places relate to one another. Finally, all of
724 these places and structural links will be added to a
725 heading that represents the
document as a whole.
727 A natural convention we'll use will be to put the name
728 of any
document component that's associated with a given
729 place into that place, and add all other information as
733 \begin{notate
}{Ordered versus unordered data
} \label{ordered-vs-unordered
}
734 The code in this section is an example of one way to work
735 with ordered data (i.e.
\LaTeX\ documents are not just
736 hierarchical, but the elements at each level of the
737 hierarchy are also ordered).
739 Since
\emph{many
} artifacts are hierachical (e.g. Lisp
740 code), we should try to be compatible with
\emph{native
}
741 methods for working with order (in the case of Lisp, feed
742 the code into a Lisp processor and use CDR and CAR, etc.).
744 We
\emph{can
} use triples such as (``rank'' ``
1''
745 ``Fred'') and (``rank'' ``
2'' ``Barney'') to talk about
746 order. There may be some SQL techniques that would help.
747 (FYI, order can be handled very explicitly in Elephant!)
749 In order to account for
\emph{different
} orderings, we
750 need one more piece of data -- some explicit treatment of
751 where the order
\emph{is
}; in other words, theories.
752 (This table illustrates the fact that a heading is not so
753 different from ``an additional triple''; indeed, the only
754 reason to make them different is to have the extra
755 convenience of having their elements be numbered.)
758 \begin{tabular
}{|lll|l|
}
760 rank &
1 & Fred & Friday \\
761 rank &
2 & Barney & Friday \\
762 rank &
1 & Barney & Saturday \\
763 rank &
2 & Fred & Saturday \\
769 \begin{notate
}{The order of order
} \label{order-of-order
}
770 The triples (``rank'' ``
1'' ``Fred'') and (``rank'' ``
2''
771 ``Barney'') mentioned in Note
\ref{ordered-vs-unordered
}
772 are easy enough to read and understand; it might be more
773 natural in some ways for us to say (``Fred'' ``rank''
774 ``
1'') -- Fred has rank
1. In this section, we're
775 concerned with talking about the ordered parts of a
776 document, and ($A$ $n$ $B$) seems like an intuitive way to
777 say ``$A$'s $n$th component is $B$''.
780 \begin{notate
}{It's not overdoing it, right?
}
781 When importing
\emph{this
} document, we see links like the
782 following. I hope that's not ``overdoing it''. (Take a
783 look at Note
\ref{get-article
} and Note
\ref{get-names
} to
784 see how we go about getting information out of the
785 database.) We could get rid of one link if theories were
786 database objects (cf. Note
787 \ref{theories-as-database-objects
}).
791 "T557
[P135|Web interface|.in.arxana.tex
]"
792 "T558
[Future plans
.9.P135|Web interface|
]"
793 "T559
[T558
[Future plans
.9.P135|Web interface|
].in.arxana.tex
]"
796 \begin{notate
}{Importing in general
} \label{importing-generally
}
797 We will eventually have a collection of parsers to get
798 various kinds of documents into the system in various
799 different ways (Note
\ref{parsing
}). For now, this
800 section gives a simple way to get some sorts of
801 \LaTeX\ documents into the system, namely documents
802 structured along the same lines as the
document you're
805 An interesting approach to parsing
\emph{math
} documents
806 has been undertaken in the
\LaTeX ML
807 project.
\footnote{{\tt http://dlmf.nist.gov/LaTeXML/
}}
808 Eventually it would be nice to get that level of detail
809 here, too! Emacsspeak is another example of a
810 \LaTeX\ parser that deals with large-scale textual
811 structures as well as smaller bits and
812 pieces.
\footnote{{\tt
813 http://www.cs.cornell.edu/home/raman/aster/aster-thesis.ps
}}
815 It would probably be useful to put together some parsers
816 for HTML and wiki code soon.
819 \begin{notate
}{On `import-buffer'
}
820 This function imports
\LaTeX\ documents, taking care of
821 the non-recursive aspects of this operation. It imports
822 frontmatter (everything up to the first
823 \verb+
\begin{section
}+), but assumes ``backmatter'' is
824 trivial, and does not import it. The imported material is
825 classified as a ``
document'' with the same name as the
830 (defun import-buffer (&optional buffername)
832 (set-buffer (get-buffer (or buffername
834 (goto-char (point-min))
835 (search-forward-regexp "\\\
\begin{document}")
836 (search-forward-regexp "\\\
\section")
837 (goto-char (match-beginning
0))
838 ;; other links will be made in the "heading of this
839 ;;
document", but here we make a broader assertion.
840 (scholium buffername "is a" "
document")
843 (buffer-substring-no-properties
847 ;;; These should maybe be scholia attached to
848 ;; root-coords (below), but for some reason that
849 ;; wasn't working so well -- investigate later --
850 ;; maybe it just wasn't good to run after running
852 (let* ((root-coords (place-item buffername nil
855 '("section" "subsection" "subsubsection"))
856 (current-parent buffername)
858 (sections (import-within levels))
861 (let ((coords (car sections)))
862 (setq index (
1+ index))
863 (scholium root-coords
867 (setq sections (cdr sections))))))
870 \begin{notate
}{On `import-within'
}
871 Recurse through levels of sectioning to import
874 It would be good if we could do something about sections
875 that contain neither subsections nor notes (for example, a
876 preface), or, more generally, about text that is not
877 contained in any environment (possibly that appears before
878 any section). We'll save things like this for another
881 For the moment, we've decided to build the
document
882 hierarchy with links that are blind to whether the $k$th
883 component of a section is a note or a subsection.
884 Children that are notes are attached in the subroutine
885 `import-notes' and those that are sections are attached in
886 `import-within'. Users can find out what type of object
887 they are looking at based on whether or not it ``has
890 Incidentally, when looking for the end of an importing
891 level, `nil' is an OK result -- if this is the
\emph{last
}
892 section at this level
\emph{and
} there is no subsequent
893 section at a higher level.
897 (defun import-within (levels)
898 (let ((this-level (car levels))
899 (next-level (car (cdr levels))) answer)
900 (while (re-search-forward
902 "^\\\\" this-level "
{\\(
[^
}\n]*\\)
}"
903 "\\( +\\\
\label{\\)?"
906 (let* ((name (match-string-no-properties
1))
907 (at (place-item name nil buffername))
910 (search-forward-regexp
911 (concat "^\\\\" this-level "
{.*")
918 (search-forward-regexp
924 (index (let ((current-parent at))
925 (import-notes notes-end)))
926 (subsections (let ((current-parent at))
927 (import-within (cdr levels)))))
929 (let ((coords (car subsections)))
930 (setq index (
1+ index))
935 (setq subsections (cdr subsections))))
936 (setq answer (cons at answer))))
940 \begin{notate
}{On `import-notes'
} \label{import-notes
}
941 We're going to make the daring assumption that the
942 ``textual'' portions of incoming
\LaTeX\ documents are
943 contained in ``Notes''. That assumption is true, at
944 least, for the current
document. The function returns the
945 count of the number of notes imported, so that
946 `import-within' knows where to start counting this
947 section's non-note children.
949 Would this same function work to import all notes from a
950 buffer without examining its sectioning structure? Not
951 quite, but close! (Could be a fun exercise to fix this.)
955 (defun import-notes (end)
957 (while (re-search-forward (concat "\\\
\begin{notate
}"
959 "\\( +\\\
\label{\\)?"
963 (match-string-no-properties
1))
964 (tag (match-string-no-properties
3))
967 (line-beginning-position)))
969 (progn (search-forward-regexp
971 (match-beginning
0)))
972 (coords (place-item name nil buffername)))
973 (setq index (
1+ index))
974 (scholium current-parent
978 ;; not in the heading
981 (buffer-substring-no-properties
983 (import-code-continuations coords)))
987 \begin{notate
}{On `import-code-continuations'
} \label{import-code-continuations
}
988 This runs within the scope of `import-notes', to turn the
989 series of Lisp chunks or other code snippets that follow a
990 given note into a scholium attached to that note. Each
991 separate snippet becomes its own annotation.
993 The ``conditional regexps'' used here only work with Emacs
994 version
23 or higher.
996 I'm noticing a problem with the way the `looking-at'
997 form behaves. It matches the expression in question,
998 but then the match-end is reported as one character
999 less than it supposed to be. Maybe `looking-at' is
1000 just not as good as `re-search-forward'? But it's
1001 what seems easiest to use.
1005 (defun import-code-continuations (coords)
1006 (let ((possible-environments
1007 "\\(
1?:lisp\\|idea\\|common\\)"))
1009 (concat "
\n*?\\\
\begin{"
1010 possible-environments
1012 (let* ((beg (match-end
0))
1013 (environment (match-string
1))
1014 (end (progn (search-forward-regexp
1018 (match-beginning
0)))
1019 (content (buffer-substring-no-properties
1022 (scholium (scholium coords
1029 \begin{notate
}{On `autoimport-arxana'
} \label{autoimport-arxana
}
1030 This just calls `import-buffer', and imports this
document
1035 (defun autoimport-arxana ()
1037 (import-buffer "arxana.tex"))
1040 \begin{notate
}{Importing textual links
}
1041 Of course, it would be good to import the links that users
1042 make between articles, since then we can quickly navigate
1043 from an article to the various articles that cite that
1044 article, as well as follow the usual forward-directional
1045 links. Indeed, we should be able to browse each article
1046 within a ``neighborhood'' of other related articles.
1047 (We'll need to import labels as well, of course.)
1050 \subsection{Browsing database contents
} \label{browsing
}
1052 \begin{notate
}{Browsing sketch
} \label{browsing-sketch
}
1053 This section facilitates browsing of documents represented
1054 with structures like those created in Section
1055 \ref{importing
}, and sets the ground for browsing other
1056 sorts of contents (e.g. collections of tasks, as in
1057 Section
\ref{managing-tasks
}).
1059 In order to facilitate general browsing, it is not enough
1060 to simply use `get-article' (Note
\ref{get-article
}) and
1061 `get-names' (Note
\ref{get-names
}), although these
1062 functions provide our defaults. We must provide the means
1063 to find and display different things differently -- for
1064 example, a section's table of contents will typically
1065 be displayed differently from its actual contents.
1067 Indeed, the ability to display and select elements of
1068 document sections (Note
\ref{display-section
}) is
1069 basically the core browsing deliverable. In the process
1070 we develop a re-usable article selector (Note
1071 \ref{selector
}; cf. Note
\ref{browsing-tasks
}). This in
1072 turn relies on a flexible function for displaying
1073 different kinds of articles (Note
\ref{display-article
}).
1076 \begin{notate
}{On `display-article'
} \label{display-article
}
1077 This function takes in the name of the article to display.
1078 Furthermore, it takes optional arguments `retriever' and
1079 `formatter', which tell it how to look up and/or format
1080 the information for display, respectively.
1082 Thus, either we make some statement up front (choosing our
1083 `formatter' based on what we already know about the
1084 article), or we decide what to display after making some
1085 investigation of information attached to the article, some
1086 of which may be retrieved and displayed (this requires
1087 that we specify a suitable `retriever' and a complementary
1090 For example, the major mode in which to display the
1091 article's contents could be stored as a scholium attached
1092 to the article; or we might maintain some information
1093 about ``areas'' of the database that would tell us up
1094 front what which mode is associated with the current area.
1095 (The default is to simply insert the data with no markup
1098 Observe that this works when no heading argument is given,
1099 because in that case `get-article' looks for
\emph{all
}
1100 place pseudonyms. (But of course that won't work well
1101 when we have multiple theories containing things with the
1102 same names, so we should get used to using the heading
1105 (The business about requiring the data to be a sequence
1106 before engaging in further formatting is, of course, just
1107 a matter of expediency for making things work with the
1112 (defun display-article
1113 (name &optional heading retriever formatter)
1114 (interactive "Mname: ")
1115 (let* ((data (if retriever
1116 (funcall retriever name heading)
1117 (get-article name heading))))
1118 (when (and data (sequencep data))
1121 (funcall formatter data heading)
1122 (pop-to-buffer (get-buffer-create
1123 "*Arxana Display*"))
1124 (delete-region (point-min) (point-max))
1125 (insert "NAME: " name "
\n\n")
1127 (goto-char (point-min)))))))
1130 \begin{notate
}{An interactive article selector
} \label{selector
}
1131 The function `get-names' (Note
\ref{get-names
}) and
1132 similar functions can give us a collection of articles.
1133 The next few functions provide an interactive
1134 functionality for moving through this collection to find
1135 the article we want to look at.
1137 We define a ``display style'' that the article selector
1138 uses to determine how to display various articles. These
1139 display styles are specified by text properties attached
1140 to each option the selector provides. Similarly, when
1141 we're working within a given heading, the relevant heading
1142 is also specified as a text property.
1144 At selection time, these text properties are checked to
1145 determine which information to pass along to
1150 (defvar display-style '((nil . (nil nil))))
1152 (defun thing-name-at-point ()
1153 (buffer-substring-no-properties
1154 (line-beginning-position)
1155 (line-end-position)))
1157 (defun get-display-type ()
1158 (get-text-property (line-beginning-position)
1159 'arxana-display-type))
1161 (defun get-relevant-heading ()
1162 (get-text-property (line-beginning-position)
1163 'arxana-relevant-heading))
1165 (defun arxana-list-select ()
1167 (apply 'display-article
1168 (thing-name-at-point)
1169 (get-relevant-heading)
1170 (cdr (assoc (get-display-type)
1173 (define-derived-mode arxana-list-mode fundamental-mode
1174 "arxana-list" "Arxana List Mode.
1176 \\
{arxana-list-mode-map
}")
1178 (define-key arxana-list-mode-map (kbd "RET")
1179 'arxana-list-select)
1182 \begin{notate
}{On `pick-a-name'
} \label{pick-a-name
}
1183 Here `generate' is the name of a function to call to
1184 generate a list of items to display, and `format' is a
1185 function to put these items (including any mark-up) into
1186 the buffer from which individiual items can then be
1189 One simple way to get a list of names to display would be
1190 to reuse a list that we had already produced (this would
1191 save querying the database each time). We could, in fact,
1192 store a history list of lists of names that had been
1193 displayed previously (cf. Note
\ref{local-storage
}).
1195 We'll eventually want versions of `generate' that provide
1196 various useful views into the data, e.g., listing all of
1197 the elements of a given section (Note
1198 \ref{display-section
}).
1200 Finding all the elements that match a given search term,
1201 whether that's just normal text search or some kind of
1202 structured search would be worthwhile too. Upgrading the
1203 display to e.g.
color-code listed elements according to
1204 their type would be another nice feature to add.
1208 (defun pick-a-name (&optional generate format heading)
1210 (let ((items (if generate
1212 (get-names heading))))
1214 (set-buffer (get-buffer-create "*Arxana Articles*"))
1215 (toggle-read-only -
1)
1216 (delete-region (point-min)
1219 (funcall format items)
1220 (mapc (lambda (item) (insert item "
\n")) items))
1221 (toggle-read-only t)
1223 (goto-char (point-min))
1224 (pop-to-buffer (get-buffer "*Arxana Articles*")))))
1227 \begin{notate
}{On `display-section'
} \label{display-section
}
1228 When browsing a
document, if you select a section, you
1229 should display a list of that section's constituent
1230 elements, be they notes or subsections. The question
1231 comes up: when you go to display something, how do you
1232 know whether you're looking at the name of a section, or
1233 the name of an article?
1235 When you get the section's contents out of the database
1236 (Note
\ref{get-section-contents
})
1240 (defun display-section (name heading)
1241 (interactive (list (read-string
1244 (buffer-name) "): ")
1245 nil nil (buffer-name))))
1246 ;; should this pop to the Articles window?
1247 (pick-a-name `(lambda ()
1248 (get-section-contents
1251 (format-section-contents
1254 (add-to-list 'display-style
1255 '(section . (display-section
1259 \begin{notate
}{On `get-section-contents'
} \label{get-section-contents
}
1260 Sent by `display-section' (Note
\ref{display-section
})
1261 to `pick-a-name' as a generator for the table of contents
1262 of the section with the given name in the given heading.
1264 This function first finds the triples that begin with the
1265 (placed) name of the section, then checks to see which of
1266 these are in the heading of the
document we're examinining
1267 (in other words, which of these links represent structural
1268 information about that
document). It also looks at the
1269 items found at the end of these links to see if they are
1270 sections or notes (``noteness'' is determined by them
1271 having content). The links are then sorted by their
1272 middles (which show the order in which these components
1273 have in the section we're examining). After this ordering
1274 information has been used for sorting, it is deleted, and
1275 we're left with just a list of names in the apropriate
1276 order together with an indication of their noteness.
1280 (Defun get-section-contents (name heading)
1282 (dolist (triple (triples-given-beginning
1283 `(
1 ,(resolve-ambiguity
1284 (get-places name)))))
1285 (when (triple-exact-match
1286 `(
2 ,(car triple)) "in" heading)
1287 (let* ((number (print-middle triple))
1288 (site (isolate-end triple))
1290 (when (triples-given-beginning-and-middle
1295 (print-system-object
1296 (place-contents site))
1301 (lambda (component1 component2)
1302 (< (parse-integer (car component1))
1303 (parse-integer (car component2))))))))
1306 \begin{notate
}{On `format-section-contents'
} \label{format-section-contents
}
1307 A formatter for
document contents, used by
1308 `display-
document' (Note
\ref{display-
document}) as input
1309 for `pick-a-name' (Note
\ref{pick-a-name
}).
1311 Instead of just printing the items one by one,
1312 like the default formatter in `pick-a-name' does,
1313 this version adds appropriate text properties, which
1314 we determine based the second component of
1315 of `items' to format.
1319 (defun format-section-contents (items heading)
1320 ;; just replicating the default and building on that.
1321 (mapc (lambda (item)
1323 (let* ((beg (line-beginning-position))
1325 (unless (second item)
1326 (put-text-property beg end
1327 'arxana-display-type
1329 (put-text-property beg end
1330 'arxana-relevant-heading
1336 \begin{notate
}{On `display-
document'
} \label{display-
document}
1337 When browsing a
document, you should first display its
1338 top-level table of contents. (Most typically, a list of
1339 all of that
document's major sections.) In order to do
1340 this, we must find the triples that are begin at the node
1341 representing this
document \emph{and
} that are in the
1342 heading of this
document. This boils down to treating the
1343 document's root as if it was a section and using the
1344 function `display-section' (Note
\ref{display-section
}).
1348 (defun display-
document (name)
1349 (interactive (list (read-string
1352 (buffer-name) "): ")
1353 nil nil (buffer-name))))
1354 (display-section name name))
1357 \begin{notate
}{Work with `heading' argument
}
1358 We should make sure that if we know the heading we're
1359 working with (e.g. the name of the
document we're
1360 browsing) that this information gets communicated in the
1361 background of the user interaction with the article
1365 \begin{notate
}{Selecting from a hierarchical display
} \label{hierarchical-display
}
1366 A fancier ``article selector'' would be able to display
1367 several sections with nice indenting to show their
1371 \begin{notate
}{Browser history tricks
} \label{history-tricks
}
1372 I want to put together (or put back together) something
1373 similar to the multihistoried browser that I had going in
1374 the previous version of Arxana and my Emacs/Lynx-based web
1375 browser, Nero
\footnote{{\tt http://metameso.org/~joe/nero.el
}}.
1376 The basic features are:
1377 (
1) forward, back, and up inside the structure of a given
1378 document; (
2) switch between tabs. More advanced features
1379 might include: (
3) forward and back globally across all
1380 tabs; (
4) explicit understanding of paths that loop.
1382 These sorts of features are independent of the exact
1383 details of what's printed to the screen each time
1384 something is displayed. So, for instance, you could flip
1385 between section manifests a la Note
\ref{display-section
},
1386 or between hierarchical displays a la Note
1387 \ref{hierarchical-display
}, or some combination; the key
1388 thing is just to keep track in some sensible way of
1389 whatever's been displayed!
1392 \begin{notate
}{Local storage for browsing purposes
} \label{local-storage
}
1393 Right now, in order to browse the contents of the
1394 database, you need to query the database every time. It
1395 might be handy to offer the option to cache names of
1396 things locally, and only sync with the database from time
1397 to time. Indeed, the same principle could apply in
1398 various places; however, it may also be somewhat
1399 complicated to set up. Using two systems for storage, one
1400 local and one permanent, is certainly more heavy-duty than
1401 just using one permanent storage system and the local
1402 temporary display. However, one thing in favor of local
1403 storage systems is that that's what I used in the the
1404 previous prototype of Arxana -- so some code already
1405 exists for local storage! (Caching the list of
1406 \emph{names
} we just made a selection from would be one
1407 simple expedient, see Note
\ref{pick-a-name
}.)
1410 \begin{notate
}{Hang onto absolute references
}
1411 Since `get-article' (Note
\ref{get-article
}) translates
1412 strings into their ``place pseudonyms'', we may want to
1413 hang onto those pseudonyms, because they are, in fact, the
1414 absolute references to the objects we end up working with.
1415 In particular, they should probably go into the
1416 text-property background of the article selector, so it
1417 will know right away what to select!
1420 \subsection{Exporting
\LaTeX\ documents$^*$
}
1422 \begin{notate
}{Roundtripping
}
1423 The easiest test is: can we import a
document into the
1424 system and then export it again, and find it unchanged?
1427 \begin{notate
}{Data format
}
1428 We should be able to
\emph{stably
} import and export a
1429 document, as well as export any modifications to the
1430 document that were generated within Arxana. This means
1431 that the exporting functions will have to read the data
1432 format that the importing functions use,
\emph{and
} that
1433 any functions that edit
document contents (or structure)
1434 will also have to use the same format. Furthermore,
1435 \emph{browsing
} functions will have to be somewhat aware
1436 of this format. So, this is a good time to ask -- did we
1440 \subsection{Editing database contents$^*$
} \label{editing
}
1442 \begin{notate
}{Roundtripping, with changes
}
1443 Here, we should import a
document into the system and then
1444 make some simple changes, and after exporting, check with
1445 diff to make sure the changes are correct.
1448 \begin{notate
}{Re-importing
}
1449 One nice feature would be a function to ``re-import'' a
1450 document that has changed outside of the system, and make
1451 changes in the system's version whereever changes appeared
1452 in the source version.
1455 \begin{notate
}{Editing
document structure
}
1456 The way we have things set up currently, it is one thing
1457 to make a change to a
document's textual components, and
1458 another to change its structure. Both types of changes
1459 must, of course, be supported.
1462 \section{Applications
}
1464 \subsection{Managing tasks
} \label{managing-tasks
}
1466 \begin{notate
}{What are tasks?
}
1467 Each task tends to have a
\emph{name
}, a
1468 \emph{description
}, a collection of
\emph{prerequisite
1469 tasks
}, a description of other
\emph{material
1470 dependencies
}, a
\emph{status
}, some
\emph{justification
1471 of that status
}, a
\emph{creation date
}, and an
1472 \emph{estimated time of completion
}. There might actually
1473 be several ``estimated times of completion'', since the
1474 estimate would tend to improve over time. To really
1475 understand a task, one should keep track of revisions like
1479 \begin{notate
}{On `store-task-data'
} \label{store-task-data
}
1480 Here, we're just filling in a frame. Since ``filling in a
1481 frame'' seems like the sort of operation that might happen
1482 over and over again in different contexts, to save space,
1483 it would probably be nice to have a macro (or similar)
1484 that would do a more general version of what this function
1489 (Defun store-task-data
1490 (name description prereqs materials status
1491 justification submitted eta)
1492 (add-triple name "is a" "task")
1493 (add-triple name "description" description)
1494 (add-triple name "prereqs" prereqs)
1495 (add-triple name "materials" materials)
1496 (add-triple name "status" status)
1497 (add-triple name "status justification" justification)
1498 (add-triple name "date submitted" submitted)
1499 (add-triple name "estimated time of completion" eta))
1502 \begin{notate
}{On `generate-task-data'
} \label{generate-task-data
}
1503 This is a simple function to create a new task matching
1504 the description above.
1508 (defun generate-task-data ()
1510 (let ((name (read-string "Name: "))
1511 (description (read-string "Description: "))
1512 (prereqs (read-string
1513 "Task(s) this task depends on: "))
1514 (materials (read-string "Material dependencies: "))
1515 (status (completing-read
1516 "Status (tabled, in progress, completed):
1517 " '("tabled" "in progress" "completed")))
1518 (justification (read-string "Why this status? "))
1521 (concat "Date submitted (default "
1522 (substring (current-time-string)
0 10)
1524 nil nil (substring (current-time-string)
0 10)))
1526 (read-string "Estimated date of completion:")))
1527 (store-task-data name description prereqs materials
1529 justification submitted eta)))
1532 \begin{notate
}{Possible enhancements to `generate-task-data'
}
1533 In order to make this function very nice, it would be good
1534 to allow ``completing read'' over known tasks when filling
1535 in the prerequisites. Indeed, it might be especially nice
1536 to offer a type of completing read that is similar in some
1537 sense to the tab-completion you get when completing a file
1538 name, i.e., quickly completing certain sub-strings of the
1539 final string (in this case, these substrings would
1540 correspond to task areas we are progressively zooming down
1543 As for the task description, rather than forcing the user
1544 to type the description into the minibuffer, it might be
1545 nice to pop up a separate buffer instead (a la the
1546 Emacs/w3m textarea). If we had a list of all the known
1547 tasks, we could offer completing-read over the names of
1548 existing tasks to generate the list of `prereqs'. It
1549 might be nice to systematize date data, so we could more
1550 easily e.g. sort and display task info ``by date''.
1551 (Perhaps we should be working with predefined database
1552 types for dates and so on; but see Note
1553 \ref{choice-of-database
}.)
1555 Also, before storing the task, it might be nice to offer
1556 the user the chance to review the data they entered.
1559 \begin{notate
}{On `get-filler'
} \label{get-filler
}
1560 Just a wrapper for `triples-given-beginning-and-middle'.
1561 (Maybe add `heading' as an option here.)
1565 (Defun get-filler (frame slot)
1568 (triples-given-beginning-and-middle frame
1572 \begin{notate
}{On `get-task'
} \label{get-task
}
1573 Uses `get-filler' (Note
\ref{get-filler
}) to assemble the
1574 elements of a task's frame.
1578 (Defun get-task (name)
1579 (when (triple-exact-match name "is a" "task")
1580 (list (get-filler name "description")
1581 (get-filler name "prereqs")
1582 (get-filler name "materials")
1583 (get-filler name "status")
1584 (get-filler name "status justification")
1585 (get-filler name "date submitted")
1587 "estimated time of completion"))))
1590 \begin{notate
}{On `review-task'
} \label{review-task
}
1591 This is a function to review a task by name.
1595 (defun review-task (name)
1596 (interactive "MName: ")
1597 (let ((task-data (get-task name)))
1599 (display-task task-data)
1600 (message "No data."))))
1602 (defun display-task (data)
1604 (pop-to-buffer (get-buffer-create
1605 "*Arxana Display*"))
1606 (delete-region (point-min) (point-max))
1607 (insert "NAME: " name "
\n\n")
1608 (insert "DESCRIPTION: " (first data) "
\n\n")
1609 (insert "TASKS THIS TASK DEPENDS ON: "
1610 (second data) "
\n\n")
1611 (insert "MATERIAL DEPENDENCIES: "
1612 (third data) "
\n\n")
1613 (insert "STATUS: " (fourth data) "
\n\n")
1614 (insert "WHY THIS STATUS?: " (fifth data) "
\n\n")
1615 (insert "DATE SUBMITTED:" (sixth data) "
\n\n")
1616 (insert "ESTIMATED TIME OF COMPLETION: "
1617 (seventh data) "
\n\n")
1618 (goto-char (point-min))
1619 (fill-individual-paragraphs (point-min) (point-max))))
1622 \begin{notate
}{Possible enhancements to `review-task'
}
1623 Breaking this down into a function to select the task and
1624 another function to display the task would be nice. Maybe
1625 we should have a generic function for selecting any object
1626 ``by name'', and then special-purpose functions for
1627 displaying objects with different properties.
1629 Using text properties, we could set up a ``field-editing
1630 mode'' that would enable you to select a particular field
1631 and edit it independently of the others. Another more
1632 complex editing mode would
\emph{know
} which fields the
1633 user had edited, and would store all edits back to the
1634 database properly. See Section
\ref{editing
} for more on
1638 \begin{notate
}{Browsing tasks
} \label{browsing-tasks
}
1639 The function `pick-a-name' (Note
\ref{pick-a-name
}) takes
1640 two functions, one that finds the names to choose from,
1641 and the other that says how to present these names. We
1642 can therefore build `pick-a-task' on top of `pick-a-name'.
1649 (triples-given-middle-and-end "is a" "task")
1652 (defun pick-a-task ()
1657 (mapc (lambda (item)
1658 (let ((pos (line-beginning-position)))
1660 (put-text-property pos (
1+ pos)
1661 'arxana-display-type
1663 (insert "
\n"))) items))))
1665 (add-to-list 'display-style
1666 '(task . (get-task display-task)))
1669 \begin{notate
}{Working with theories
}
1670 Presumably, like other related functions, `get-tasks'
1671 should take a heading argument.
1674 \begin{notate
}{Check display style
}
1675 Check if this works, and make style consistent between
1676 this usage and earlier usage.
1679 \begin{notate
}{Example tasks
}
1680 It might be fun to add some tasks associated with
1681 improving Arxana, just to show that it can be done...
1682 maybe along with a small importer to show how importing
1683 something without a whole lot of structure can be easy.
1686 \subsection{Other ideas$^*$
}
1688 \begin{notate
}{A browser within a browser
} \label{browser-within
}
1689 All the stuff we're doing with triples can be superimposed
1690 over the existing web and existing web interfaces, by, for
1691 example, writing a web browser as a web app, and in this
1692 ``browser within a browser'' offer the ability to annotate
1693 and rewrite other people's web pages, produce
3rd-party
1694 redirects, and so forth, sharing these mods with other
1695 subscribers to the service. (Already websites such as the
1696 short-lived scrum.diddlyumptio.us have offered limited
1697 versions of ``web annotation'', but, so far, what one can
1698 do with such services seems quite weak compared with
1702 \begin{notate
}{Improvements to the PlanetMath backend
}
1703 From one point of view, the SQL tables are the main thing
1704 in Noosphere. We could say that getting the things out of
1705 SQL and storing new things there is what Noosphere mainly
1706 does. Following this line of thought, anything that
1707 adjusts these tables will do just as well, e.g., it
1708 shouldn't be terribly hard to develop an email-based
1709 front-end. But rather than making Arxana work with the
1710 Noosphere relational table system, it is probably
1711 advantageous to translate the data from these tables into
1712 the scholium system.
1715 \begin{notate
}{A new communication platform
}
1716 One of the premier applications I have in mind is a new
1717 way to handle communications in an online-forum. I have
1718 previously called this ``subchanneling'', but really,
1719 joining channels is just as important.
1722 \begin{notate
}{Some tutorials
}
1723 It would be interesting to write a tutorial for Common
1724 Lisp or just about any other topic with this system. For
1725 example, some little ``worksheets'' or ``gymnasia'' that
1726 will help solidify user knowledge in topics on which
1727 questions keep appearing.
1730 \section{Topics of philosophical interest
}
1732 \begin{notate
}{Research and development
}
1733 In Note
\ref{theoretical-context
}, I mentioned a model
1734 that could apply in many contexts; it is an essentially
1735 metaphysical conception. I'm pretty sure that the data
1736 model of Note
\ref{data-model
} provides a general-enough
1737 framework to represent anything we might find ``out
1738 there''. However, even if this is the case, questions as
1739 to
\emph{efficient
} means of working with such data still
1740 abound (cf. Note
\ref{models-of-theories
}, Note
1741 \ref{use-of-views
}).
1743 I propose that along with
\emph{development
} of Arxana as
1744 a useful system for
\emph{doing
} ``commons-based peer
1745 production'' should come a
\emph{research
} programme for
1746 understanding in much greater detail what ``commons-based
1747 peer production''
\emph{is
}. Eventually we may want to
1748 change the name of the subject of study to reflect still
1749 more general ideas of resource use.
1751 While the ``frontend'' of this research project is
1752 anthropological, the ``backend'' is much closer to
1753 artificial intelligence. On this level, the project is
1754 about understanding
\emph{effective
} means for solving
1755 human problems. Often this will involve decomposing
1756 events and processes into constituent elements, making
1757 increasingly detailed treatments along the lines described
1758 in Note
\ref{arxana
}.
1761 \begin{notate
}{The relationship between text and commentary
}
1762 Text under revision might be marked up by a copyeditor: in
1763 cases like these, the interpretation is clear. However,
1764 what about marginalia with looser interpretations? These
1765 seem to become part of the copy of the text they are
1766 attached to. What about steering processes applied to a
1767 given course of action? How about the relationship of
1768 thoughts or words to perception and action? How can we
1769 lower the barrier between conception and action, while
1770 still maintaining some purchase on wisdom?
1772 You see, a lot of issues in life have to do with overlays,
1773 multi-tracking, interchange between different systems; and
1774 in these terms, a lot of philosophy reduces to ``media
1775 awareness'' which extends into more and more immediate
1776 contexts (Note
\ref{theoretical-context
}).
1779 \begin{notate
}{Heuristic flow
}
1780 Continuing the notion above: one does not need a
1781 fully-developed ``heading'' of work in order to do work --
1782 instead, one wants some straightforward heuristics that
1783 will enable the desired work to get done. So, even
1784 supposing the work is ``heading building'', it can progress
1785 without becoming overwhelmed in abstractions -- because
1786 theories and heuristics are different things.
1789 \begin{notate
}{Limits of simple languages
} \label{simple-languages
}
1790 Triples are frequently ``subject, verb, object''
1791 statements, although with the annotation features, we can
1792 modify any part of any such statement; for example, we
1793 can apply an adverb to a given verb.
1795 ``Tags'', of course, already provide ``subject,
1796 predicate'' relationships. It will be interesting to
1797 examine the degree to which human languages can be mapped
1798 down into these sorts of simple languages. What features
1799 are needed to make such languages
\emph{useful
}? (Lisp's
1800 `car' and `cdr' seem related to the idea of making
1803 How are triples and predicates ``enough''? What, if
1804 anything, do they lack? The difference between triples
1805 and predicates illustrates the issue. How should we
1806 characterize Arxana's additions to Lisp?
1809 \begin{notate
}{Higher dimensions
}
1810 Why stop with three components? Why not have $(A, B, C,
1811 D, T)$ represent a semantic relationship between all of
1812 $A$, $B$, $C$, and $D$ (in heading $T$, of course)?
1813 Actually, there is no reason to stop apart from the fact
1814 that I want to explore simple languages (Note
1815 \ref{simple-languages
}). In real life, things are not as
1816 simple, and we should be ready to deal with the
1817 complexities! (Cf., for example, Note
\ref{pointing
}).
1820 \section{Future plans
}
1822 \begin{notate
}{Development pathways
}
1823 To the extent that it's possible, I'd like to maintain a
1824 succinct non-linear roadmap in which tasks are outlined
1825 and prioritized, and some procedural details are made
1826 concrete. Whenever relevant this map should point into
1827 the current
document. I'll begin by revising the plans
1828 I've used so far!
\footnote{{\tt
1829 http://metameso.org/files/plan-arxana.pdf
}} Over the
1830 next several months, I'd like to see these plans develop
1831 into a genuine production machine, and see the machine
1832 begin to stabilize its operations.
1835 \begin{notate
}{Theories as database objects
} \label{theories-as-database-objects
}
1836 We're just beginning to treat theories as database
1837 objects; I expect there will be more work to do to make
1838 this work really well. We'll want to make some test
1839 cases, like building a ``theory of chess'', or even just
1840 describing a particular chess board; cf. Note
1841 \ref{partial-image
}.
1844 \begin{notate
}{Search engine/elements
} \label{search-engine
}
1845 One of the features that came very easy in the Emacs-only
1846 prototype was textual search. With the strings stored in
1847 a database, Sphinx seems to be the most suitable search
1848 engine to use. It is tempting to try to make our own
1849 inverted index using triples, so that text-based search
1850 can be even more directly integrated with semantic search.
1851 (Since the latest version(s) of Sphinx can act to some
1852 extent like a MySQL database, we almost have a direct
1853 connection in the backend, but since Sphinx is not
1854 \emph{the same
} database, one would at least need some
1855 glue code to effect joins and so forth.)
1857 More to the point, it is important for this project that
1858 the scholia-based
document model be transparently extended
1859 down to the level of words and characters. It may be
1860 helpful to think about text as
\emph{always being
}
1861 hypertext; a
document as a heading; and a word in the
1862 inverted index as a frame.
1865 \begin{notate
}{Pointing at database elements and other things
} \label{pointing
}
1866 We will want to be able to point at other tables and at
1867 other sorts of objects and make use of their contents.
1868 The plan is that our triples will provide a sort of guide
1869 or backbone superimposed over a much larger data system.
1872 \begin{notate
}{Feature-chase
}
1873 There are lots of different features that could be
1874 explored, for example: multi-dimensional history lists; a
1875 useful treatment of ``clusions''; MS Word-like colorful
1876 annotations; etc. Many of these features are already
1877 prototyped.
\footnote{See footnote
\ref{old-version
}.
}
1880 \begin{notate
}{Regression testing
}
1881 Along with any major feature chase, we should provide
1882 and maintain a regression testing suite.
1885 \begin{notate
}{Deleting and changing things
}
1886 How will we deal with unlinking, disassociating,
1887 forgetting, entropy, and the like? Changes can perhaps
1888 be modeled by an insertion following a deletion, and,
1889 as noted, we'll need effective ways to represent and
1890 manage change (Note
\ref{change
}).
1893 \begin{notate
}{Tutorial
}
1894 Right now the system is simple enough to be pretty much
1895 self-explanatory, but if it becomes much more complicated,
1896 it might be helpful to put together a simple guide to some
1897 likely-to-be-interesting features.
1900 \begin{notate
}{Computing possible paths and connections
}
1901 If we can find all the
\emph{direct
} paths from one node
1902 to another using `triples-given-beginning-and-end', can we
1903 inject some algorthms for finding longer, indirect paths
1904 into the system, and find ways to make them useful?
1906 Similarly, we can satisfy local conditions (Note
1907 \ref{satisfy-conditions
}), but we'll want to deal with
1908 increasingly ``non-local'' conditions (even just using the
1909 logical operator ``or'', instead of ``and'', for example).
1912 \begin{notate
}{Monster Mountain
}
1913 In Summer
2007, we checked out the Monster Mountain MUD
1914 server
\footnote{{\tt http://code.google.com/p/mmtn/
}},
1915 which would enable several users to interact with one
1916 LISP, instead of just one database. This would have a
1917 number of advantages, particularly for exploring
1918 ``scholiumific programming'', but also towards fulfilling
1919 the user-to-user interaction objective stated in Note
1920 \ref{theoretical-context
}. I plan to explore this after
1921 the primary goal of multi-user interaction with the
1922 database has been solidly completed.
1925 \begin{notate
}{Web interface
}
1926 A finished web interface may take a considerable amount of
1927 work (if the complexity of an interesting Emacs interface
1928 is any indication), but the basics shouldn't be hard to
1932 \begin{notate
}{Parsing input
} \label{parsing
}
1933 Complicated objects specified in long-hand (e.g. triples
1934 pointing to triples) can be read by a relatively simple
1935 parser -- which we'll have to write! The simplest goal
1936 for the parser would be to be able to distinguish between
1937 a triple and a string -- presumably that much isn't hard.
1938 And of course, building complexes of triples that
1939 represent statements from natural language is a good
1940 long-term goal. (Right now, our granularity level is set
1944 \begin{notate
}{Choice of database
} \label{choice-of-database
}
1945 I expect Elephant
\footnote{{\tt
1946 http://common-lisp.net/project/elephant/
}} may become
1947 our preferred database at some point in the future; we are
1948 currently awaiting changes to Elephant that make nested
1949 queries possible and efficient. Some core queries related
1950 to managing a database of semantic links with the current
1951 Elephant were constructed by Ian Eslick, Elephant's
1952 maintainer.
\footnote{{\tt
1953 http://planetx.cc.vt.edu/\~
{}jcorneli/arxana/variant-
4.lisp
}}
1955 On the other hand, it might be reasonable to use an Emacs
1956 database and redo the whole thing to work in Emacs
1957 (again), e.g. for single-user applications or users who
1958 want to work offline a lot of the time.
1961 \begin{notate
}{Different kinds of theories
}
1962 Theories or variants thereof are of course already popular
1963 in other knowledge representation contexts.
\footnote{{\tt
1964 http://www.cyc.com/cycdoc/vocab/mt-expansion-vocab.html
}}$^
{,
}$
\footnote{{\tt
1965 http://www.stanford.edu/\~
{}kdevlin/HHL
\_SituationTheory.pdf
}}
1966 We'll want to adopt some useful techniques for knowledge
1967 management as soon as the core systems are ready.
1969 Various notions of a mathematical theory
1970 exist.
\footnote{{\tt
1971 http://planetmath.org/encyclopedia/Theory.html
}} It
1972 would be nice to be able to assign specific logic to
1973 theories in Arxana, following the ``little theories''
1974 design of e.g. IMPS.
\footnote{{\tt
1975 http://imps.mcmaster.ca/manual/node13.html
}}
1978 \section{Conclusion
} \label{conclusion
}
1980 \begin{notate
}{Ending and beginning again
}
1981 This is the end of the Arxana system itself; the
1982 appendices provide some ancillary tools, and some further
1983 discussion. Contributions that support the development of
1984 the Arxana project are welcome.
1989 \section{Appendix: Auto-setup
} \label{appendix-setup
}
1991 \begin{notate
}{Setting up auto-setup
}
1992 This section provides code for satifying dependencies and
1993 setting up the program. This code assumes that you are
1994 using a Debian/APT-based system (but things are not so
1995 different using say, Fedora or Fink; writing a
1996 multi-package-manager-friendly installer shouldn't be
1997 hard). Of course, feel free to set things up differently
1998 if you have something else in mind!
2002 (defalias 'set-up 'shell-command)
2004 (defun alternative-set-up (string)
2006 (pop-to-buffer (get-buffer-create "*Arxana Help*"))
2007 (goto-char (point-max))
2008 (insert string "
\n")))
2010 (defun set-up-arxana-environment ()
2013 "Run commands (y) (or just show instructions)? ")
2014 (fset 'set-up 'shell-command)
2015 (fset 'set-up 'alternative-set-up))
2016 (when (y-or-n-p "Install dependencies? ")
2017 (set-up "mkdir ~/arxana")
2018 (set-up "cd arxana"))
2020 (when (y-or-n-p "Download latest Arxana? ")
2021 (set-up "wget http://metameso.org/files/arxana.tex"))
2023 (unless (y-or-n-p "Is your emacs good enough?... ")
2025 (concat "cvs -z3 -d"
2026 ":pserver:anonymous@cvs.savannah.gnu.org:"
2027 "/sources/emacs co emacs"))
2028 (set-up "mv emacs ~")
2029 (set-up "cd ~/emacs")
2030 (set-up "./configure && make bootstrap")
2031 (set-up "cd ~/arxana"))
2033 (defvar pac-man nil)
2036 "Do you use an apt-based package manager? ")
2037 (setq pac-man "apt-get"))
2039 "OK, get Lisp and SQL on your own, then!")))
2042 (when (y-or-n-p "Install Common Lisp? ")
2043 (set-up (concat pac-man " install sbcl")))
2045 (when (y-or-n-p "Install Postgresql? ")
2046 (set-up (concat pac-man " install postgresql"))
2047 (when (y-or-n-p "Help setting up PostgreSQL? ")
2049 (pop-to-buffer (get-buffer-create "*Arxana Help*"))
2050 (insert "As superuser (root),
2051 edit /etc/postgresql/
7.4/main/pg_hba.conf
2052 make sure it says this:
2053 host all all
127.0.0.1 255.255.255.255 trust
2054 then edit /etc/postgresql/
7.4/main/postgresql.conf
2058 /etc/init.d/postgresql-
7.4 restart
2063 createdb -U username
\n")))))
2065 (when (y-or-n-p "Install SLIME...? ")
2066 (set-up (concat "cvs -d :pserver:anonymous"
2067 ":anonymous@common-lisp.net:"
2068 "/project/slime/cvsroot co slime"))
2070 (concat "echo \";; Added to ~/.emacs for Arxana:
\n\n"
2071 "(add-to-list 'load-path \"~/slime/\")
\n"
2072 "(setq inferior-lisp-program \"/usr/bin/sbcl\")
\n"
2073 "(require 'slime)
\n"
2074 "(slime-setup '(slime-repl))
\n\n\""
2075 "| cat - ~/.emacs > ~/updated.emacs &&"
2076 "mv ~/updated.emacs ~/.emacs")))
2078 (when (y-or-n-p "Set up Common Lisp environment? ")
2079 (set-up "mkdir ~/.sbcl")
2080 (set-up "mkdir ~/.sbcl/site")
2081 (set-up "mkdir ~/.sbcl/systems")
2082 (set-up "cd ~/.sbcl/site")
2083 (set-up (concat "wget http://files.b9.com/"
2084 "clsql/clsql-latest.tar.gz"))
2085 (set-up "tar -zxf clsql-
4.0.3.tar.gz")
2086 (set-up (concat "wget http://files.b9.com/"
2087 "uffi/uffi-latest.tar.gz"))
2088 (set-up "tar -zxf uffi-
1.6.0.tar.gz")
2089 (set-up (concat "wget http://files.b9.com/"
2090 "md5/md5-
1.8.5.tar.gz"))
2091 (set-up "tar -zxf md5-
1.8.5.tar.gz")
2092 (set-up "cd ~/.sbcl/systems")
2093 (set-up "ln -s ../site/md5-
1.8.5/md5.asd .")
2094 (set-up "ln -s ../site/uffi-
1.6.0/uffi.asd .")
2095 (set-up "ln -s ../site/clsql-
4.0.3/clsql.asd .")
2096 (set-up "ln -s ../site/clsql-
4.0.3/clsql-uffi.asd .")
2097 (set-up (concat "ln -s ../site/clsql-
4.0.3/"
2098 "clsql-postgresql-socket.asd ."))
2099 (set-up "ln -s ~/arxana/arxana.asd ."))
2101 (when (y-or-n-p "Modify ~/.sbclrc so CL always starts Arxana? ")
2103 (concat "echo \";; Added to ~/.sbclrc for Arxana:
\n\n"
2104 "(require 'asdf)
\n\n"
2105 "(asdf:operate 'asdf:load-op 'swank)
\n"
2106 "(setf swank:*use-dedicated-output-stream* nil)
\n"
2107 "(setf swank:*communication-style* :fd-handler)
\n"
2108 "(swank:create-server :port
4006 :dont-close t)
\n\n"
2109 "(asdf:operate 'asdf:load-op 'clsql)
\n"
2110 "(asdf:operate 'asdf:load-op 'arxana)
\n"
2111 "(in-package arxana)
\n"
2112 "(connect-to-database)
\n"
2113 "(locally-enable-sql-reader-syntax)
\n\n\""
2114 "| cat ~/.sbclrc - > ~/updated.sbclrc &&"
2115 "mv ~/updated.sbclrc ~/.sbclrc")))
2117 (when (y-or-n-p "Install Monster Mountain? ")
2118 (set-up "cd ~/.sbcl/systems")
2120 "darcs get http://common-lisp.net/project/"
2121 "bordeaux-threads/darcs/bordeaux-threads/"))
2123 "svn checkout svn://common-lisp.net/project/"
2124 "usocket/svn/usocket/trunk usocket-svn"))
2125 ;; I've had problems with this approach to setting cclan
2129 "wget \"http://ww.telent.net/cclan-choose-mirror"
2130 "?M=http
%3A%2F%2Fthingamy.com%2Fcclan%2F\""))
2131 (set-up (concat "wget http://ww.telent.net/cclan/"
2132 "split-sequence.tar.gz"))
2133 (set-up "tar -zxf split-sequence.tar.gz")
2135 (concat "svn checkout http://mmtn.googlecode.com/"
2136 "svn/trunk/ mmtn-read-only"))
2138 "ln -s ~/bordeaux-threads/bordeaux-threads.asd .")
2139 (set-up "ln -s ~/usocket-svn/usocket.asd .")
2140 (set-up "ln -s ~/split-sequence/split-sequence.asd .")
2141 (set-up "ln -s ~/mmtn/src/mmtn.asd .")))
2144 \begin{notate
}{Postgresql on Fedora
}
2145 There are some slightly different instructions for
2146 installing postgresql on Fedora; the above will be
2147 changed to include them, but for now, check them
2149 web.
\footnote{{\tt http://www.flmnh.ufl.edu/linux/install
\_postgresql.htm
}}
2152 \begin{notate
}{Using MySQL and CLISP instead
} \label{backend-variant
}
2153 Since my OS X box seems to have a variety of confusing
2154 PostgreSQL systems already installed (which I'm not sure
2155 how to configure), and CLISP is easy to install with fink,
2156 I thought I'd try a different set up for simplicity and
2159 In order to make it work, I enabled root user on Mac OS X
2160 per instructions on web, and installed and configured
2161 mysql; used a slight modification of the strings table
2162 described previously; download and installed
2164 http://common-lisp.net/project/cffi/releases/cffi
\_latest.tar.gz
}};
2165 changed the definition of `connect-to-database' in
2166 Arxana's utilities.lisp; doctored up my ~/.clisprc.lisp;
2167 and changed how I started Lisp. Details below.
2171 ;; on the shell prompt
2172 sudo apt-get install mysql
2173 sudo mysqld_safe --user=mysql &
2174 sudo daemonic enable mysql
2175 sudo mysqladmin -u root password root
2176 mysql --user=root --password=root -D test
2177 create database joe; grant all on joe.* to joe@localhost
2180 ;; in tabledefs.lisp
2181 (execute-command "CREATE TABLE strings (
2182 id SERIAL PRIMARY KEY,
2184 UNIQUE INDEX (text(
255))
2187 ;; in ~/asdf-registry/ or whatever you've designated as
2188 ;; your asdf:*central-registry*
2189 ln -s ~/cffi_0.10
.4/cffi-uffi-compat.asd .
2190 ln -s ~/cffi_0.10
.4/cffi.asd .
2192 ;; In utilities.lisp
2193 (defun connect-to-database ()
2194 (connect `("localhost" "joe" "joe" "joe")
2195 :database-type :mysql))
2197 ;; In ~/.clisprc.lisp
2198 (asdf:operate 'asdf:load-op 'clsql)
2199 (push "/sw/lib/mysql/"
2200 CLSQL-SYS:*FOREIGN-LIBRARY-SEARCH-PATHS*)
2202 ;; From SLIME prompt, and not in ~/.clisprc.lisp
2203 (in-package #:arxana)
2204 (connect-to-database)
2205 (locally-enable-sql-reader-syntax)
2208 \begin{notate
}{Installing Sphinx
}
2209 Here are some tips on how to install and configure
2214 ;; Fedora/Postgresql flavor
2215 yum install postgresql-devel
2216 ./configure --without-mysql
2218 --with-pgsql-libs=/usr/lib/pgsql/
2219 --with-pgsql-includes=/usr/include/pgsql
2221 ;; Fink/MySQL flavor
2222 ./configure --with-mysql
2223 --with-mysql-includes=/sw/include/mysql
2224 --with-mysql-libs=/sw/lib/mysql
2227 \begin{notate
}{Getting Sphinx set up
} \label{sphinx-setup
}
2228 Here are some instructions I've used to get Sphinx set
2232 \begin{notate
}{Create a sphinx.conf
}
2233 I want a very minimal sphinx.conf, this seems to work.
2234 (We should probably set this up so that it gets written
2235 to a file when the Arxana is set up.)
2239 ## Copy this to /usr/local/etc/sphinx.conf when you want
2245 sql_host = localhost
2249 sql_query = SELECT id, text FROM strings
2257 path = /Users/planetmath/sphinx/search-testing
2273 listen = localhost:
3307:mysql41
2274 log = /Users/planetmath/sphinx/searchd.log
2275 query_log = /Users/planetmath/sphinx/searchd_query.log
2278 pid_file = /Users/planetmath/sphinx/searchd.pid
2283 \begin{notate
}{Working from the command line
}
2284 Then you can run commands like these.
2288 /usr/local/bin/indexer strings
2289 /usr/local/bin/search "but, then"
2291 % mysql -h 127.0.0.1 -P 3307
2292 mysql> SELECT * FROM strings WHERE MATCH('but, then');
2295 \begin{notate
}{Integrating this with Lisp
}
2296 Since we can talk to Sphinx via Mysql
2297 protocol, it seems reasonable that we should be able to talk to
2298 it from CLSQL, too. With a little fussing to get the format
2299 right, I found something that works!
2303 (connect `("
127.0.0.1" "" "" "" "
3307") :database-type :mysql)
2304 (mapcar (lambda (elt) (floor (car elt)))
2305 (query "select * from strings where match('text')"))
2308 \begin{notate
}{Some added difficulty with Postgresql
}
2309 When I try to index things on the server, I get an
2310 error, as below. The question is a good one... I'm
2311 not sure
\emph{how
} postgresql is set up on the server,
2316 ERROR: index 'strings': sql_connect: could not connect to server:
2318 Is the server running on host "localhost" and accepting
2319 TCP/IP connections on port
5432?
2322 \section{Appendix: A simple literate programming system
} \label{appendix-lit
}
2324 \begin{notate
}{The literate programming system used in this paper
}
2325 This code defines functions that grab all the Lisp
2326 portions of this
document, evaluate the Emacs Lisp
2327 sections in Emacs, and save the Common Lisp sections in
2328 suitable files.
\footnote{{\tt
2329 Cf. http://mmm-mode.sourceforge.net/
}} It requires
2330 that the
\LaTeX\ be written in a certain consistent way.
2331 The function assumes that this
document is the current
2335 (defvar lit-code-beginning-regexp
2336 "^\\\
\begin{elisp
}\\|^\\\
\begin{common
}{\\(
[^
}\n]*\\)
}")
2338 (defvar lit-code-end-regexp
2339 "^\\\
\end{elisp
}\\|^\\\
\end{common
}")
2341 (defun lit-process ()
2344 (let ((to-buffer "*Lit Code*")
2345 (from-buffer (buffer-name (current-buffer)))
2346 (start-buffers (buffer-list)))
2347 (set-buffer (get-buffer-create to-buffer))
2349 (set-buffer (get-buffer-create from-buffer))
2350 (goto-char (point-min))
2351 (while (re-search-forward
2352 lit-code-beginning-regexp nil t)
2353 (let* ((file (match-string
1))
2355 (end (save-excursion
2356 (search-forward-regexp
2357 lit-code-end-regexp nil t)
2358 (match-beginning
0)))
2359 (match (buffer-substring-no-properties
2363 (concat "*Lit Code*: " file)
2366 (set-buffer (get-buffer-create
2370 (buffer (set-difference (buffer-list)
2374 (if (string= (buffer-name buffer)
2377 (write-region (point-min)
2384 (kill-buffer buffer)))))
2388 \begin{notate
}{Emacs-export?
}
2389 It wouldn't be hard to export the Elisp sections so
2390 that those who wanted to could ditch the literate
2394 \begin{notate
}{Bidirectional updating
}
2395 Eventually it would be nice to have a code repository set
2396 up, and make it so that changes to the code can get
2400 \begin{notate
}{A literate style
}
2401 Ideally, each function will have its own Note to introduce
2402 it, and will not be called before it has been defined. I
2403 sometimes make an exception to this rule, for example,
2404 functions used to form recursions may appear with no
2405 further introduction, and may be called before they are
2409 \section{Appendix: Hypertext platforms
} \label{appendix-hyper
}
2411 \begin{notate
}{The hypertextual canon
} \label{canon
}
2412 There is a core library of texts that come up in
2413 discussions of hypertext.
2416 \item The Rosetta stone
2417 \item The Talmud (Judah haNasi, Rav Ashi, and many others)
2418 \item Monadology (Wilhelm Leibniz)
2419 \item The Life and Opinions of Tristam Shandy, Gentleman
2421 \item Middlemarch (George Eliot)
2422 % \item The Gay Science (Freidrich Nietzsche)
2423 % \item (Wittgenstein)
2424 % \item (Alan Turing)
2425 \item The Nova Trilogy (William S. Burroughs)
2426 \item The Logic of Sense (Gilles Deleuze)
2427 % \item Open Creation and its Enemies (Asger Jorn)
2428 \item Labyrinths (Jorge Luis Borges)
2429 \item Literary Machines (Ted Nelson)
2430 % \item Simulation and Simulacra (Jean Baudrillard)
2431 \item Lila (Robert M. Pirsig)
2432 % \item \TeX: the program (Donald Knuth)
2433 \item Dirk Gently's Holistic Detective Agency
2435 \item Pussy, King of the Pirates (Kathy Acker)
2436 % \item Rachel Blau DuPlessis,
2437 % \item Emily Dickinson
2438 % \item Gertrude Stein
2439 % \item Zora Neale Hurston
2441 At the same time, it is somewhat ironic that none of the
2442 items on this list are themselves hypertexts in the
2443 contemporary sense of the word. It's also a bit funny
2444 that certain other works (even some by the same authors)
2445 aren't on this list. Perhaps we begin to get a sense of
2446 what's going on in this quote from Kathleen
2447 Burnett:
\footnote{{\tt http://www.iath.virginia.edu/pmc/text-only/issue
.193/burnett
.193}}
2449 ``Multiplicity, as a hypertextual principle, recognizes a
2450 multiplicity of relationships beyond the canonical
2451 (hierarchical). Thus, the traditional concept of
2452 literary authorship comes under attack from two
2453 quarters--as connectivity blurs the boundary between
2454 author and reader, multiplicity problematizes the
2455 hierarchy that is canonicity.''
2457 It seems quite telling that non-hypertextual canons remain
2458 mostly-non-hypertextual even today, despite the existence
2459 of catalogs, indexes, and online access.
\footnote{{\tt
2460 http://www.gutenberg.org/wiki/Category:Bookshelf
}}
2463 \begin{notate
}{A geek's guide to literature
}
2464 This title is a riff on Slasov
\v{Z
}i
\v{z
}ek's ``A
2465 pervert's guide to cinema''. Taking Note
\ref{canon
} as a
2466 jumping-off point, why don't we make a survey of
2467 historical texts from the point of view of an aficionado
2468 of hypertext! Just what does one have to do to ``get on
2469 the list''? Just what is ``the hypertextual
2470 perspective''? And, if
\v{Z
}i
\v{z
}ek is correct and we're
2471 to look for the hyperreal in the world of cinematic
2472 fictions -- what's left over for the world of literature?
2476 \begin{notate
}{The number
3}
2477 This is the number of things present if we count carefully
2478 the items $A$, $B$, and a connection $C$ between them.
2479 [Picture of $A
\xrightarrow{C
} B$.
]
2481 (Or even: given $A$ and $B$, we use Wittgenstein counting,
2482 and
\emph{intuit
} that $C$ exists as the collection $\
{A,
2484 some connection must exist precisely because we were
2485 presented with $A$ and $B$ together -- and lest the
2486 connections proliferate infinitely, we lump them all
2487 together as one.
[Picture of $A$, $B$,
2488 with the
\emph{frame
} labeled $C$.
])
2491 \begin{notate
}{Surfaces
}
2492 Deleuze talks about a theory of surfaces associated with
2493 verbs and events. His surfaces represent the evanescence
2494 of events in time, and of their descriptions in language.
2495 An event is seen as a vanishingly-thin boundary between
2496 one state of being and another.
2498 Certainly, a statement that is true
\emph{now
} may not be
2499 true five minutes from now. It is easier to think and
2500 talk about things that are coming up and things that have
2501 already happened. ``Living in the moment'' is regarded as
2502 special or even ``Zen''.
2504 We can begin to put these musings on a more solid
2505 mathematical basis. We first examine two types of
2508 \item $A
\xrightarrow{C
} B$, $A
\xrightarrow{D
} B$,
2509 $A
\xrightarrow{E
} B$
2510 (the interface of $A$ and $B$ across $C$, $D$, and $E$);
2511 \item $A
\xrightarrow{C
} B$, $D
\xrightarrow{C
} E$,
2512 $F
\xrightarrow{C
} G$
2513 (the interface of various terms across $C$).
2517 \begin{notate
}{Comic books
}
2518 No geek's guide to literature would be complete without
2519 putting comics in a hallowed place.
[Framed picture of
2520 $A$, $B$ next to framed
2521 picture of $A$, $B$, $a$.
] What happened?
2525 \begin{notate
}{Intersecting triples
}
2526 Diagrammatically, it is tempting to portray
2527 $(ACB)_
{\mathrm{mid
}}DE$ as if it was closely related to
2528 $A(CDE)_
{\mathrm{beg
}}B$, despite the fact that they are
2529 notationally very different. I'll have to think more
2530 about what this means.
2533 \section{Appendix: Computational Linguistics
} \label{appendix-linguistics
}
2535 \begin{notate
}{What is this?
}
2536 It might be reasonable to make annotating sentences part
2537 of our writeup on hypertext platforms -- but I'm putting
2538 it here for now. If hypertext is what deals with language
2539 artifacts on the ``bulky'' level (saying, for example,
2540 that a subsection is part of a section, and so on), then
2541 computational linguistics is what deals with the finer
2542 levels. However, the distinction is in some ways
2543 arbitrary, and many of the techniques should be at least
2547 \begin{notate
}{Annotation sensibilities
}\label{sense
}
2548 We will want to be able to make at least two different
2549 kinds of annotations of verbs. For example, given the
2552 \item[$S$.
] (``Who'' ``is on'' ``first''),
2554 I'd like to be able to say
2556 \item[I.
](``is on'' ``means'' ``the position of a base runner in baseball'').
2558 However, I'd also like to be able to say
2560 \item[II.
] (``is on'' ``because'' ``he was walked'').
2562 Annotation I is meant to apply to the term ``is on''
2563 itself (in a context that might be more general than just
2564 this one sentence). If Who is also on steroids, that's
2565 another matter -- as this type of annotation helps make
2568 Annotation II is meant to apply to the term ``is on''
2570 appears in sentence $S$
}. In particular, Annotation II
2571 seems to work best in a context in which we've already
2572 accepted the ontological status of the verb-phrase ``is
2575 Whereas Annotation I should presumably exist before
2576 statement $S$ is ever made (and it certainly helps make
2577 that statement make sense), Annotation II is most properly
2578 understood with reference to the fully-formed statement
2579 $S$. However, Annotation II is different from a statement
2580 like ($S$ ``has truth value'' $F$) in that it looks into
2584 \begin{notate
}{Comparison of places and ontological status
} \label{places-and-onto-status
}
2585 The difference between (I) a ``global'' annotation, and
2586 (II) the annotation of a specific sentence is analogous to
2587 the difference between (a) relationships between objects
2588 without a place, and (b) relationships between objects in
2589 specific places. (Cf. Note
\ref{sense
}: ``global''
2590 statements are of course made ``local'' by the theories
2593 For example, in a descriptive ontology of research
2594 documents, I might make the ``placeless'' statement,
2596 \item[a.
] (``Introduction'' ``names'' ``a section'')
2598 On the other hand, the statement
2600 \item[b.
] (``Introduction'' ``has subject'' ``American
2603 seems likely to be about a specific Introduction. (And
2604 somewhere in the backend, this triple should be expressed
2605 in terms of places!)
2608 \begin{notate
}{Semantics
}
2611 (((``I'' ``saw'' ``myself'')$_
{\mathrm{mid
}}$ ``as if''
2612 ``through a glass'')$_
{\mathrm{beg
}}$ ``but'' ``darkly'')
2614 first of all, there may be different parenthesizations,
2615 and second of all, the semantics of links like ``as if''
2616 and ``but'' may shape, to some extent, the ways in
2617 which we parethesize.
2620 \section{Appendix: Resource use
} \label{appendix-resources
}
2622 \begin{notate
}{Free culture in action
}
2623 I thought it worthwhile to include this quote from
2624 a joint paper with Aaron Krowne:
\footnote{See Footnote
2625 \ref{corneli-krowne
}.
}
2627 ``
[F
]ree content typically
2628 manifests aspects of a common resource as well as an
2629 open access resource; while anyone can do essentially
2630 whatever they wish with the content offline, in its
2631 online life, the content is managed in a
2632 socially-mediated way. In particular, rights to
2633 \emph{in situ
} modification tend to be strictly
2634 controlled.
[...
] By finding new ways to support
2635 freedom of speech within CBPP documents, we embrace
2636 subjectivity as a way to enhance the content of an
2637 intersubjectively valued corpus. In the context of
2638 ``hackable'' media and maintenance protocols, the
2639 semantics with which scholia are handled can be improved
2640 upon indefinitely on a user-by-user basis and a
2641 resource-wide basis. This is free culture in action.''
2645 \begin{notate
}{Learning
}
2646 The learner, confronted with a learning resource, or the
2647 consumer of any other information resource (or indeed,
2648 practically any resource whatsoever) may want a chance to
2649 respond to the questions ``was this what you were looking
2650 for?'' and ``did you find this helpful?''. In some cases,
2651 an independent answer to that question could be generated
2652 (e.g. if a student is seen to come up with a correct
2656 \begin{notate
}{Connections
}
2657 A useful communication goal is to expose some of the
2658 connections between disparate resources. Some existing
2659 connections may be far more explicit than others. It's
2660 important to facilitate the making and explicating of
2661 connections by ``third parties'' (Note
2662 \ref{browser-within
}). The search for connections between
2663 ostensibly unrelated things is a key part of both
2664 creativity and learning. In addition, connecting with
2665 what others are doing is an important part of being a
2669 \begin{notate
}{Boundaries
}
2670 Notice that the departmentalization of knowledge is
2671 similar to any regime that oversees and administers
2672 boundaries. In addition to bridging different areas,
2673 learning often involves pushing one's boundaries and
2674 getting out of one's comfort zone. The ``sociological
2675 imagination'' involves seeing oneself as part of something
2676 bigger; this goes along with the idea of a discourse that
2677 lowers or transcends the boundaries between participants.
2678 Imagination of any form can challenge myopic patterns of
2679 resource use, although there are also myopic fictions
2680 which neglect to look at what's going on in reality!