[tmql-wg] tolog solutions to use cases
Lars Marius Garshol
larsga@ontopia.net
Wed, 28 Jan 2004 16:04:23 +0100
I've now finally had time to sit down and write up the solutions to
the TMQL use cases in tolog. For fun I wrote it up as LTM, so you can
either read this inline or put it into your Omnigator. Omnigator won't
respect the formatting, so just reading it inline may be best. If
people prefer I can produce a pretty HTML version of this as well.
Anyway, here it is. Comments of course muchly welcome.
/* ===========================================================================
TMQL Use Case solutions
=========================================================================== */
/* --- Topic types */
[use-case = "Use case"
@"http://www.isotopicmaps.org/tmql/psis/#use-case"]
[query-language = "Query language"
@"http://www.isotopicmaps.org/tmql/psis/#query-language"]
/* --- Occurrence types */
[solution = "Solution"
@"http://www.isotopicmaps.org/tmql/psis/#solution"]
/* --- Themes */
[incomplete = "Incomplete"
@"http://www.isotopicmaps.org/tmql/psis/#incomplete"]
/* --- Queries */
[q522.1 : use-case = "Retrieve all author names"
@"http://www.isotopicmaps.org/tmql/psis/#uc-522.1"]
[q522.2 : use-case = "Retrieve all author names sorted"
@"http://www.isotopicmaps.org/tmql/psis/#uc-522.2"]
[q522.3 : use-case = "Retrieve the titles of all tutorials in scope"
@"http://www.isotopicmaps.org/tmql/psis/#uc-522.3"]
[q522.4 : use-case = "Retrieve the names of all persons who have not authored anything"
@"http://www.isotopicmaps.org/tmql/psis/#uc-522.4"]
[q522.5 : use-case = "Retrieve a list of all author names together with the title of their publications"
@"http://www.isotopicmaps.org/tmql/psis/#uc-522.5"]
[q522.6 : use-case = "Retrieve a list of all titles of documents which are tutorials"
@"http://www.isotopicmaps.org/tmql/psis/#uc-522.6"]
[q522.7 : use-case = "Retrieve a list of documents, sorted by publication date (ascending), only number 3 to 5"
@"http://www.isotopicmaps.org/tmql/psis/#uc-522.7"]
[q522.8 : use-case = "Retrieve all topic identifiers of documents which have a download URL"
@"http://www.isotopicmaps.org/tmql/psis/#uc-522.8"]
[q522.9 : use-case = "Retrieve a list of author's email addresses where the author has authored documents for which no download URL exists"
@"http://www.isotopicmaps.org/tmql/psis/#uc-522.9"]
[q522.10 : use-case = "Retrieve a list of author names where the author has written more than 1 document"
@"http://www.isotopicmaps.org/tmql/psis/#uc-522.10"]
[q522.11 : use-case = "A list of author names where the author has not written a single document with someone else"
@"http://www.isotopicmaps.org/tmql/psis/#uc-522.11"]
[q522.12 : use-case = "Retrieve all topic identifiers of documents and their URLs which have a non-working URL at query time"
@"http://www.isotopicmaps.org/tmql/psis/#uc-522.12"]
[q522.13 : use-case = "Retrieve all topic identifiers for documents for which the abstract in english (i.e. the occurrence of type abstract in scope en) contains the phrase 'topic map' or 'topic maps', case-insensitive"
@"http://www.isotopicmaps.org/tmql/psis/#uc-522.13"]
[q522.14 : use-case = "Retrieve all documents which have a title in german"
@"http://www.isotopicmaps.org/tmql/psis/#uc-522.14"]
[q522.15 : use-case = "Retrieve all topic identifiers of the pairs of documents which share at least one word in the title, ignoring stopwords like 'and', 'of', 'the'"
@"http://www.isotopicmaps.org/tmql/psis/#uc-522.15"]
[q522.16 : use-case = "Retrieve the identifiers of all topics which represent information resources on the ontopia.net server(s)"
@"http://www.isotopicmaps.org/tmql/psis/#uc-522.16"]
[q522.17 : use-case = "Retrieve the topic identifiers of all documents which are not written in the language English"
@"http://www.isotopicmaps.org/tmql/psis/#uc-522.17"]
[q522.18 : use-case = "Retrieve the topic identifiers of all documents which are directly or indirectly influenced by something which Steve Pepper wrote"
@"http://www.isotopicmaps.org/tmql/psis/#uc-522.18"]
[q522.19 : use-case = "Retrieve all identifiers of topics which are either instances of paper or tutorial"
@"http://www.isotopicmaps.org/tmql/psis/#uc-522.19"]
[q522.20 : use-case = "Retrieve all titles of all publications (regardless their scope) together with their most specific class"
@"http://www.isotopicmaps.org/tmql/psis/#uc-522.20"]
[q522.21 : use-case = "Retrieve all authors"
@"http://www.isotopicmaps.org/tmql/psis/#uc-522.21"]
[q522.22 : use-case = "Retrieve all basename items of authors"
@"http://www.isotopicmaps.org/tmql/psis/#uc-522.22"]
[q522.23 : use-case = "Retrieve a list of all occurrence items being of type email"
@"http://www.isotopicmaps.org/tmql/psis/#uc-522.23"]
[q53.1 : use-case = "Return all titles of papers together with the author names"
@"http://www.isotopicmaps.org/tmql/psis/#uc-53.1"]
[q53.2 : use-case = "Return the name(s) of all authors who have authored more than one paper"
@"http://www.isotopicmaps.org/tmql/psis/#uc-53.2"]
[q53.3 : use-case = "Select only the tutorial documents from the topic map and return an RDF document containing the title and the author information"
@"http://www.isotopicmaps.org/tmql/psis/#uc-53.3"]
[q53.4 : use-case = "Return all persons with their name and a bibliography as nested elements"
@"http://www.isotopicmaps.org/tmql/psis/#uc-53.4"]
/* --- tolog */
[tolog : query-language = "tolog"]
{q522.1, solution, [[select $NAME from
is-author-of($AUTHOR : author, $WORK : opus),
name($AUTHOR, $NAME)?]]} / tolog
{q522.2, solution, [[select $AUTHOR from
is-author-of($AUTHOR : author, $WORK : opus)
order by $AUTHOR?]]} / tolog
{q522.4, solution, [[select $PERSON from
instance-of($PERSON, person),
not(is-author-of($PERSON : author, $WORK : opus))?]]} / tolog
{q522.5, solution, [[is-author-of($PERSON : author, $WORK : opus)?]]} / tolog
{q522.6, solution, [[instance-of($TUTORIAL, tutorial)?]]} / tolog
{q522.7, solution, [[ instance-of($DOCUMENT, document),
publication-date($DOCUMENT, $PUBDATE)
order by $PUBDATE limit 2 offset 3?]]} / tolog incomplete
{q522.8, solution, [[select $DOCUMENT from
instance-of($DOCUMENT, document), download($DOCUMENT, $URL)?]]} / tolog
{q522.9, solution, [[select $EMAIL, $DOCUMENT from
is-author-of($AUTHOR : autor, $DOCUMENT : opus),
email($AUTHOR, $EMAIL),
not(download($DOCUMENT, $URL))?]]} / tolog
{q522.10, solution, [[select $AUTHOR from
is-author-of($AUTHOR : autor, $DOCUMENT1 : opus),
is-author-of($AUTHOR : autor, $DOCUMENT2 : opus),
$DOCUMENT1 /= $DOCUMENT2?]]} / tolog
{q522.11, solution, [[select $AUTHOR1 from
is-author-of($AUTHOR1 : author, $DOCUMENT : opus),
not(is-author-of($AUTHOR2 : author, $DOCUMENT : opus),
$AUTHOR1 /= $AUTHOR2)?]]} / tolog
{q522.14, solution, [[select $DOCUMENT from
instance-of($DOCUMENT, document),
topic-name($DOCUMENT, $NAME),
scope($NAME, de)?]]} / tolog
{q522.17, solution, [[instance-of($DOCUMENT, document),
not(language($DOCUMENT, "english"))?]]} / tolog
{q522.18, solution, [[indirect-influence($INFLUENCED, $INFLUENCE) :- {
is-influenced-by($INFLUENCED : influenced, $INFLUENCE : influence) |
is-influenced-by($INFLUENCED : influenced, $MID : influence),
indirect-influence($MID, $INFLUENCE)
}.
indirect-influence($INFLUENCED, $INFLUENCE),
is-author-of($INFLUENCE : opus, steve-pepper : author)?]]} / tolog
{q522.19, solution, [[{ instance-of($DOCUMENT, tutorial) |
instance-of($DOCUMENT, paper) }?]]} / tolog
{q522.20, solution, [[instance-of($DOCUMENT, document),
direct-instance-of($DOCUMENT, $CLASS),
topic-name($DOCUMENT, $TITLE)?]]} / tolog
{q522.21, solution, [[select $AUTHOR from
is-author-of($AUTHOR : author, $WORK : opus)?]]} / tolog
{q522.22, solution, [[select $TNAME from
is-author-of($AUTHOR : author, $WORK : opus),
topic-name($AUTHOR, $TNAME)?]]} / tolog
{q522.23, solution, [[select $OCC from
occurrence($TOPIC, $OCC),
type($OCC, email)?]]} / tolog
{q53.1, solution, [[<tmtl:page xmlns:tmtl="http://psi.ontopia.net/tmtl/">
<papers>
<tmtl:foreach select="instance-of($PAPER, paper), name($PAPER, $TITLE)?">
<paper>
<head>{$TITLE}</head>
<tmtl:foreach select="is-author-of($AUTHOR : author, %PAPER% : opus),
name($AUTHOR, $NAME)?">
<author>{$NAME}</author>
</tmtl:foreach>
</paper>
</tmtl:foreach>
</papers>
</tmtl:page>]]} / tolog
{q53.2, solution, [[<tmtl:page xmlns:tmtl="http://psi.ontopia.net/tmtl/">
<recidivists
><tmtl:foreach select="select $NAME from
is-author-of($AUTHOR : author, $WORK1 : opus),
is-author-of($AUTHOR : author, $WORK2 : opus),
$WORK1 /= $WORK2, name($AUTHOR, $NAME)?">
<author>{$NAME}</author>
</tmtl:foreach
></recidivists>
</tmtl:page>]]} / tolog
{q53.3, solution, [[<tmtl:page xmlns:tmtl="http://psi.ontopia.net/tmtl/">
<rdf:RDF xmlns:rdf="http://www.w3c.org/RDF/"
xmlns:lit="http://www.isotopicmaps.org/tmql/use-cases/literature/">
<tmtl:foreach select="instance-of($TUTORIAL, tutorial),
is-author-of($TUTORIAL : opus, $AUTHOR : author),
name($TUTORIAL, $TITLE), name($AUTHOR, $NAME),
subject-locator($TUTORIAL, $URI)?">
<lit:tutorial rdf:about="{$URI}">
<lit:title>{$TITLE}</lit:title>
<lit:author>{$NAME}</lit:author>
</lit:tutorial>
</tmtl:foreach>
</rdf:RDF>
</tmtl:page>
]]} / tolog
{q53.4, solution, [[<tmtl:page xmlns:tmtl="http://psi.ontopia.net/tmtl/">
<persons>
<tmtl:foreach select="instance-of($PERSON, person),
topic-name($PERSON, $TNAME),
scope($TNAME, sort),
value($TNAME, $NAME)?">
<person id="can't do this">
<name>{$NAME}</name>
<bibliography>
<tmtl:foreach select="is-author-of(%PERSON% : author, $WORK : opus),
name($WORK, $TITLE)?">
<publication>{$TITLE} (<tmtl:if select="language(%WORK%, $LANG)?"
>{$LANG}</tmtl:if
><tmtl:if select="not(language(%WORK%, $LANG))?"
>unknown</tmtl:if>)</publication>
</tmtl:foreach>
</bibliography>
</person>
</tmtl:foreach>
</persons>
</tmtl:page>]]} / tolog incomplete
--
Lars Marius Garshol, Ontopian <URL: http://www.ontopia.net >
GSM: +47 98 21 55 50 <URL: http://www.garshol.priv.no >