beagle r4595 - branches/beagle-rdf/RDFAdapter
- From: dbera svn gnome org
- To: svn-commits-list gnome org
- Subject: beagle r4595 - branches/beagle-rdf/RDFAdapter
- Date: Sun, 9 Mar 2008 00:10:55 +0000 (GMT)
Author: dbera
Date: Sun Mar 9 00:10:55 2008
New Revision: 4595
URL: http://svn.gnome.org/viewvc/beagle?rev=4595&view=rev
Log:
Add another Euler reasoning and move the common operations to its own functions.
Modified:
branches/beagle-rdf/RDFAdapter/SemWebClient.cs
Modified: branches/beagle-rdf/RDFAdapter/SemWebClient.cs
==============================================================================
--- branches/beagle-rdf/RDFAdapter/SemWebClient.cs (original)
+++ branches/beagle-rdf/RDFAdapter/SemWebClient.cs Sun Mar 9 00:10:55 2008
@@ -26,9 +26,12 @@
//
using System;
+using System.IO;
using Beagle;
using Beagle.Util;
using SemWeb;
+using SemWeb.Query;
+using SemWeb.Inference;
public class SemWebClient {
public static void Main (string[] args)
@@ -36,10 +39,11 @@
BeagleSource source = new BeagleSource ();
TestSource (source);
- TestEmailThreads (source);
+ //TestEmailThreads (source);
+ //TestReceipients (source);
}
- private static void TestSource (SelectableSource source)
+ private static void TestSource (BeagleSource source)
{
source.RDFToBeagle = new BeagleSource.RDFToBeagleHook (RDFToBeagle);
source.BeagleToRDF = new BeagleSource.BeagleToRDFHook (EmailToEntity);
@@ -63,15 +67,15 @@
}
// WARNING! This will generate all threads, pretty expensive
- private static void TestEmailThreads (SelectableSource source)
+ private static void TestEmailThreads (BeagleSource source)
{
source.BeagleToRDF = new BeagleSource.BeagleToRDFHook (MsgIdToEntity);
- Store store = new Store (source);
-
+ source.RDFToBeagle = new BeagleSource.RDFToBeagleHook (RDFToBeagle);
Entity inthread = BeagleSource.BeaglePropertyToEntity ("inthread");
/* NOTE: change the subject to whatever email subject you wish */
const string Subject = "beagle";
+
string rules = "@prefix : <http://beagle-project.org/property#>.\n" +
"\n" +
/* every message is in its own thread */
@@ -79,12 +83,43 @@
/* if any email refers to some email in thread, then this email is also in thread */
"{ ?ref :inthread ?parent . ?email1 :prop:k:fixme:reference ?ref . ?email1 :prop:k:fixme:msgid ?msg .} => {?msg :inthread ?parent} .\n";
- Euler engine = new Euler(new N3Reader(new StringReader(rules)));
-
Statement msg_in_thread = new Statement (new Variable ("msg"), inthread, new Variable ("parent"));
+ Console.WriteLine ("Proof of 'threads in email with subject :{0}'", Subject);
+ EulerQuery (source, rules, new Statement[] {msg_in_thread});
+ }
+
+ private static void TestReceipients (BeagleSource source)
+ {
+ source.BeagleToRDF = new BeagleSource.BeagleToRDFHook (EmailToEntity);
+ source.RDFToBeagle = new BeagleSource.RDFToBeagleHook (RDFToBeagle);
+
+ Entity recvd = BeagleSource.BeaglePropertyToEntity ("recvd");
+
+ string rules = "@prefix : <http://beagle-project.org/property#>.\n" +
+ "\n" +
+ "{ ?email :prop:t:fixme:from_address ?from . ?email :prop:t:fixme:to_address ?to . } => {?from :recvd ?to .}.\n" +
+ "{ ?email :prop:t:fixme:from_address ?from . ?email :prop:t:fixme:cc_address ?to . } => {?from :recvd ?to .}.\n";
+
+ /* NOTE: change the sender to whatever email address you wish */
+ const string Sender = "dbera web gmail com";
+
+ Entity from = new Entity ("mailto://" + Sender);
+ Variable to = new Variable ("recpt");
+ Statement q = new Statement(from, recvd, to);
+
+ Console.WriteLine ("Proof of 'receipients of emails from :{0}'", Sender);
+ EulerQuery (source, rules, new Statement[] {q});
+ }
+
+ private static void EulerQuery (SelectableSource source, string rules, Statement[] queries)
+ {
+ Store store = new Store (source);
+
+ Euler engine = new Euler(new N3Reader(new StringReader(rules)));
- foreach (Proof p in engine.Prove (store, new Statement[] { msg_in_thread })) {
- Console.WriteLine(p);
+ foreach (Proof p in engine.Prove (store, queries)) {
+ foreach (Statement s in p.Proved)
+ Console.WriteLine(s);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]