|
From: <to...@us...> - 2008-01-17 20:28:22
|
Revision: 102
http://xoperator.svn.sourceforge.net/xoperator/?rev=102&view=rev
Author: tomatop
Date: 2008-01-17 12:28:15 -0800 (Thu, 17 Jan 2008)
Log Message:
-----------
Added Paths:
-----------
trunk/xOperator/src/net/sf/xoperator/ui/aiml/conf/templates/foafGroupAttributes.groovy
trunk/xOperator/src/net/sf/xoperator/ui/aiml/conf/templates/foafGroupMember.groovy
trunk/xOperator/src/net/sf/xoperator/ui/aiml/conf/templates/foafPersonAttributes.groovy
trunk/xOperator/src/net/sf/xoperator/ui/aiml/conf/templates/iCalWhereNow.groovy
trunk/xOperator/src/net/sf/xoperator/ui/aiml/conf/templates/sample.groovy
trunk/xOperator/src/net/sf/xoperator/ui/aiml/conf/templates/tellMeMoreAbout.groovy
Added: trunk/xOperator/src/net/sf/xoperator/ui/aiml/conf/templates/foafGroupAttributes.groovy
===================================================================
--- trunk/xOperator/src/net/sf/xoperator/ui/aiml/conf/templates/foafGroupAttributes.groovy (rev 0)
+++ trunk/xOperator/src/net/sf/xoperator/ui/aiml/conf/templates/foafGroupAttributes.groovy 2008-01-17 20:28:15 UTC (rev 102)
@@ -0,0 +1,58 @@
+/////////////////////////////////////////////
+/// Implementation of the simple template "Tell me * of *"
+/////////////////////////////////////////////
+sparqlresult=""
+//context.sendMessageToUser("ok, I'll try find out this.")
+
+// fetching the log
+log = context.getLog()
+
+// the wildcards
+wildcard1 = match.wildcard(bitoflife.chatterbean.Match.Section.PATTERN,1).trim();
+wildcard2 = match.wildcard(bitoflife.chatterbean.Match.Section.PATTERN,2).trim();
+
+//FROM = "http://demo.ontowiki.net/model/export/?m=http%3A%2F%2Fbis.ontowiki.net%2F&output=xml"
+//FROM = "http://sebastian.dietzold.de/rdf/foaf.rdf"
+FromPart = "FROM <http://xmlns.com/foaf/spec/index.rdf> "
+
+// where can we find infos about the subject
+documentQuery = "SELECT DISTINCT ?document "+
+ FromPart+
+ "WHERE{?s ?p1 ?subjectpattern. ?s <http://www.w3.org/2000/01/rdf-schema#seeAlso> ?document."+
+ "FILTER regex(?subjectpattern, '.*"+wildcard2+".*', 'i').}"
+log.info(documentQuery)
+//context.sendMessageToUser(documentQuery)
+
+documents = context.queryForTable(documentQuery,null,null)
+FromNamedPart = ""
+documents.each(){
+ res = it
+ log.info(res.getResultCount())
+ // res.getResultRows returns a List of Maps. Each map represents a row, with the headline as key.
+ res.getResultRows().each(){
+ //log.info("Hohoho: ${it["ypsilon"]} is a ${it["x"]}")
+ FromNamedPart += "FROM <${it["document"]}> \n"
+ log.info(it["document"])
+ }
+}
+
+valueQuery = "SELECT DISTINCT ?value "+
+ FromPart+
+ FromNamedPart+
+ "WHERE {?s ?p1 ?subjectpattern. ?s ?p2 ?value. ?p2 ?property ?propertypattern. FILTER regex(?subjectpattern, '.*"+wildcard2+".*', 'i'). FILTER regex(?propertypattern, '.*"+wildcard1+".*', 'i')}"
+log.info(valueQuery)
+//context.sendMessageToUser(valueQuery)
+
+counter = 0;
+values = context.queryForTable(valueQuery,null,null)
+values.each(){
+ res = it
+ counter = counter + res.getResultCount()
+ log.info(res.getResultCount())
+ res.getResultRows().each(){
+ log.info(it["value"])
+ context.sendMessageToUser(it["value"])
+ }
+}
+if(counter == 0) context.sendMessageToUser("Sorry, I can't answer your question.")
+
Added: trunk/xOperator/src/net/sf/xoperator/ui/aiml/conf/templates/foafGroupMember.groovy
===================================================================
--- trunk/xOperator/src/net/sf/xoperator/ui/aiml/conf/templates/foafGroupMember.groovy (rev 0)
+++ trunk/xOperator/src/net/sf/xoperator/ui/aiml/conf/templates/foafGroupMember.groovy 2008-01-17 20:28:15 UTC (rev 102)
@@ -0,0 +1,36 @@
+/////////////////////////////////////////////
+/// Who is member of *
+/////////////////////////////////////////////
+sparqlresult=""
+//context.sendMessageToUser("ok, I'll try find out this.")
+
+//now = new java.text.SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss").format(new Date())
+//context.sendMessageToUser(now)
+
+// fetching the log
+log = context.getLog()
+
+// the wildcards
+wildcard1 = match.wildcard(bitoflife.chatterbean.Match.Section.PATTERN,1).trim();
+
+// query for member names
+memberQuery = "SELECT DISTINCT ?name FROM <http://xmlns.com/foaf/spec/index.rdf> WHERE {"+
+ "?s ?p1 ?subjectpattern. ?s <http://xmlns.com/foaf/0.1/member> ?person. ?person <http://xmlns.com/foaf/0.1/name> ?name."+
+ "FILTER regex(?subjectpattern, '.*"+wildcard1+".*', 'i').}"
+log.info(memberQuery)
+//context.sendMessageToUser(documentQuery)
+
+counter = 0;
+members = context.queryForTable(memberQuery,null,null)
+members.each(){
+ res = it
+ counter = counter + res.getResultCount()
+ if (res.getResultCount() > 0) context.sendMessageToUser("From " + res.getStoreName() + ":")
+ log.info(res.getResultCount())
+ res.getResultRows().each(){
+ log.info(it["name"])
+ context.sendMessageToUser(" * "+it["name"])
+ }
+}
+if(counter == 0) context.sendMessageToUser("Sorry, I can't answer your question.")
+
Added: trunk/xOperator/src/net/sf/xoperator/ui/aiml/conf/templates/foafPersonAttributes.groovy
===================================================================
--- trunk/xOperator/src/net/sf/xoperator/ui/aiml/conf/templates/foafPersonAttributes.groovy (rev 0)
+++ trunk/xOperator/src/net/sf/xoperator/ui/aiml/conf/templates/foafPersonAttributes.groovy 2008-01-17 20:28:15 UTC (rev 102)
@@ -0,0 +1,60 @@
+/////////////////////////////////////////////
+/// Implementation of the simple template "Tell me * of *"
+/////////////////////////////////////////////
+sparqlresult=""
+//context.sendMessageToUser("ok, I'll try find out this.")
+
+//now = new java.text.SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss").format(new Date())
+//context.sendMessageToUser(now)
+
+// fetching the log
+log = context.getLog()
+
+// the wildcards
+wildcard1 = match.wildcard(bitoflife.chatterbean.Match.Section.PATTERN,1).trim();
+wildcard2 = match.wildcard(bitoflife.chatterbean.Match.Section.PATTERN,2).trim();
+
+//FROM = "http://demo.ontowiki.net/model/export/?m=http%3A%2F%2Fbis.ontowiki.net%2F&output=xml"
+//FROM = "http://sebastian.dietzold.de/rdf/foaf.rdf"
+//FromPart = "FROM <http:xmlns.com/foaf/spec/index.rdf> "
+//
+// where can we find infos about the subject
+//documentQuery = "SELECT DISTINCT ?document "+
+// FromPart+
+// "WHERE{?s ?p1 ?subjectpattern. ?s <http:www.w3.org/2000/01/rdf-schema#seeAlso> ?document."+
+// "FILTER regex(?subjectpattern, '.*"+wildcard2+".*', 'i').}"
+//log.info(documentQuery)
+//context.sendMessageToUser(documentQuery)
+//
+//documents = context.queryForTable(documentQuery,null,null)
+//FromNamedPart = ""
+//documents.each(){
+// res = it
+// log.info(res.getResultCount())
+// res.getResultRows().each(){
+// FromNamedPart += "FROM <${it["document"]}> \n"
+// log.info(it["document"])
+// }
+//}
+
+valueQuery = "SELECT DISTINCT ?value "+
+// FromPart+
+// FromNamedPart+
+ "WHERE {?s ?p1 ?subjectpattern. ?s ?p2 ?value. ?p2 ?property ?propertypattern. FILTER regex(?subjectpattern, '.*"+wildcard2+".*', 'i'). FILTER regex(?propertypattern, '.*"+wildcard1+".*', 'i')}"
+log.info(valueQuery)
+//context.sendMessageToUser(valueQuery)
+
+counter = 0;
+values = context.queryForTable(valueQuery,["ontowiki"],null)
+values.each(){
+ res = it
+ counter = counter + res.getResultCount()
+ if (res.getResultCount() > 0) context.sendMessageToUser("From " + res.getStoreName() + ":")
+ log.info(res.getResultCount())
+ res.getResultRows().each(){
+ log.info(it["value"])
+ context.sendMessageToUser(" * "+it["value"])
+ }
+}
+if(counter == 0) context.sendMessageToUser("Sorry, I can't answer your question.")
+
Added: trunk/xOperator/src/net/sf/xoperator/ui/aiml/conf/templates/iCalWhereNow.groovy
===================================================================
--- trunk/xOperator/src/net/sf/xoperator/ui/aiml/conf/templates/iCalWhereNow.groovy (rev 0)
+++ trunk/xOperator/src/net/sf/xoperator/ui/aiml/conf/templates/iCalWhereNow.groovy 2008-01-17 20:28:15 UTC (rev 102)
@@ -0,0 +1,70 @@
+/////////////////////////////////////////////
+/// Implementation of "WHERE IS * NOW"
+/////////////////////////////////////////////
+sparqlresult=""
+//context.sendMessageToUser("ok, I'll try find out this.")
+
+now = new java.text.SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss").format(new Date())
+//context.sendMessageToUser(now)
+
+// fetching the log
+log = context.getLog()
+
+// the wildcards
+wildcard1 = match.wildcard(bitoflife.chatterbean.Match.Section.PATTERN,1).trim();
+
+//FROM = "http://demo.ontowiki.net/model/export/?m=http%3A%2F%2Fbis.ontowiki.net%2F&output=xml"
+//FROM = "http://sebastian.dietzold.de/rdf/foaf.rdf"
+PREFIX = "PREFIX ical: <http://www.w3.org/2002/12/cal/ical#>\nPREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n"
+FromPart = "FROM <http://xmlns.com/foaf/spec/index.rdf> "
+
+// where can we find infos about the subject
+documentQuery = PREFIX + "SELECT DISTINCT ?document "+
+// FromPart+
+ "WHERE{?s ?p1 ?subjectpattern. ?s rdfs:seeAlso ?document.\n"+
+ "?document rdf:type ical:Vcalendar.\n"+
+ "FILTER regex(?subjectpattern, '.*"+wildcard1+".*', 'i').}"
+log.info(documentQuery)
+//context.sendMessageToUser(documentQuery)
+
+documents = context.queryForTable(documentQuery,["ontowiki"],null)
+counter = 0;
+FromNamedPart = ""
+documents.each(){
+ res = it
+ counter = counter + res.getResultCount()
+ log.info(res.getResultCount())
+ res.getResultRows().each(){
+ FromNamedPart += "FROM NAMED <${it["document"]}> \n"
+ log.info(it["document"])
+ }
+}
+
+if(counter < 1) context.sendMessageToUser("Sorry, I did not found any calendar in relation to '"+wildcard1+"'")
+else{
+ context.sendMessageToUser("I have found "+counter+" calendar documents which are in relation '"+wildcard1+"' ...")
+ whereQuery = PREFIX + "SELECT DISTINCT ?location ?graph ?g ?summary\n"+
+ FromNamedPart+
+ "WHERE { GRAPH ?g { \n"+
+ "?s ical:dtstart ?sbn. ?sbn ical:dateTime ?stime. \n"+
+ "?s ical:dtend ?ebn. ?ebn ical:dateTime ?etime. \n"+
+ "?s ical:location ?location. \n"+
+ "?s ical:summary ?summary. \n"+
+ "FILTER (?stime < '"+now+"') \n"+
+ "FILTER (?etime > '"+now+"') \n"+
+ "} OPTIONAL {?g rdfs:label ?graph} }"
+
+ //context.sendMessageToUser(whereQuery)
+ locations = context.queryForTable(whereQuery,["generic"],null)
+ counter = 0;
+ locations.each(){
+ res = it
+ counter = counter + res.getResultCount()
+ log.info(res.getResultCount())
+ res.getResultRows().each(){
+ log.info(it["location"])
+ context.sendMessageToUser(it["location"] + " (summary: " + it["summary"] + ")")
+ }
+ }
+}
+
Added: trunk/xOperator/src/net/sf/xoperator/ui/aiml/conf/templates/sample.groovy
===================================================================
--- trunk/xOperator/src/net/sf/xoperator/ui/aiml/conf/templates/sample.groovy (rev 0)
+++ trunk/xOperator/src/net/sf/xoperator/ui/aiml/conf/templates/sample.groovy 2008-01-17 20:28:15 UTC (rev 102)
@@ -0,0 +1,38 @@
+// fetching the log
+log = context.getLog()
+
+//sample query
+
+//context is a instance of net.sf.xoperator.ui.aiml.TemplateExecutionContext
+
+resultset = context.queryForTable("select distinct ?x, ?ypsilon WHERE {?ypsilon a ?x } LIMIT 10",null,[])
+
+resultset.each(){
+
+ res = it
+ log.info(res.getResultCount())
+ // res.getResultRows returns a List of Maps. Each map represents a row, with the headline as key.
+ res.getResultRows().each(){
+ log.info("Hohoho: ${it["ypsilon"]} is a ${it["x"]}")
+
+ }
+
+
+ res.getHeadlines().each{
+ log.info("Headline: ${it} contains:");
+
+ res.getResultColumnAsStrings(it).each(){
+ log.info(it)
+ }
+
+ res.getResultColumnAsElements(it).each(){
+ log.info("${it.text} is of type ${it.name}")
+ }
+ }
+}
+
+sparqlresult ="select distinct ?x WHERE {?y a ?x } LIMIT 10"
+
+
+
+
Added: trunk/xOperator/src/net/sf/xoperator/ui/aiml/conf/templates/tellMeMoreAbout.groovy
===================================================================
--- trunk/xOperator/src/net/sf/xoperator/ui/aiml/conf/templates/tellMeMoreAbout.groovy (rev 0)
+++ trunk/xOperator/src/net/sf/xoperator/ui/aiml/conf/templates/tellMeMoreAbout.groovy 2008-01-17 20:28:15 UTC (rev 102)
@@ -0,0 +1,36 @@
+/////////////////////////////////////////////
+/// Tell me more about *
+/////////////////////////////////////////////
+sparqlresult=""
+//context.sendMessageToUser("ok, I'll try find out this.")
+
+//now = new java.text.SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss").format(new Date())
+//context.sendMessageToUser(now)
+
+// fetching the log
+log = context.getLog()
+
+// the wildcards
+wildcard1 = match.wildcard(bitoflife.chatterbean.Match.Section.PATTERN,1).trim();
+
+// query for member names
+memberQuery = "SELECT DISTINCT ?name FROM <http://xmlns.com/foaf/spec/index.rdf> WHERE {"+
+ "?s ?p1 ?subjectpattern. ?s <http://xmlns.com/foaf/0.1/member> ?person. ?person <http://xmlns.com/foaf/0.1/name> ?name."+
+ "FILTER regex(?subjectpattern, '.*"+wildcard1+".*', 'i').}"
+log.info(memberQuery)
+//context.sendMessageToUser(documentQuery)
+
+counter = 0;
+members = context.queryForTable(memberQuery,null,null)
+members.each(){
+ res = it
+ counter = counter + res.getResultCount()
+ if (res.getResultCount() > 0) context.sendMessageToUser("From " + res.getStoreName() + ":")
+ log.info(res.getResultCount())
+ res.getResultRows().each(){
+ log.info(it["name"])
+ context.sendMessageToUser(" * "+it["name"])
+ }
+}
+if(counter == 0) context.sendMessageToUser("Sorry, I can't answer your question.")
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|