Skip to content
Sections
Personal tools
You are here: Home » Projects » Gnowsis Email

Gnowsis Email

Document Actions
An adapter to extract RDF information from emails. It uses IMAP to get its emails. Results are in emir + our own ontology

Jump to

Background

by Shen Jianping

The semantic desktop developed by The German Research Center for Artificial Intelligence intends to provide a semantic view of your computational resources such as file, music, mail, etc. The base of semantic desktop is an RDF framework named gnowsis. This underlying framework is responsible to transforms different resources into a machine understandable RDF format. Series of semantic applications (e.g. semantic desktop) can be built on, which utilize the gnowsis services and provide concrete semantic functionalities. Figure 1 illustrates the gnowsis frameworks.

Figure 1 the gnowsis frameworks

The gnowsis framework is designed to support any new resource type by implementing adequate Adapter. An Adapter is a gnowsis plug-in, which extracts the metadata from a particular resource type.

 

The Mail Adapter

The gnowsis email is an email adapter that is responsible for extract the email related metadata from an IMAP mail server.

with gnowsis mail adapter you can

  • transform an imap mail object (such as a Store, a Folder, a message) into a standard RDF Model
  • extract the attachment from a imap message

Figure 2 illustrates the internal structure of the email Adapter.

Figure2 internal Adapter structure

The mail Adapter consists of three important parts the Ontology, the StoreConfig, and the implementation.

 

Ontology

Ontology defines the vocabularies that represent the classes of the instances and their associated properties that are expected in a hosting application. The vocabularies can be defined using RDF Schema. Up to the resource type you may define your own ontology or use an existing ontology defined by another. If possible, it is recommended to use the standard vocabularies.

 

StoreConfig

The StoreConfig is responsible for building a connection to IMAP server. It contains the identification information for the connection (e.g. user name, password, etc. ). The StoreConfig should be initialized before using the mail adapter.

 

Implementation (How it works)

The Mail Adapter has a method "createCBD(String uri, Options options, Model target)". this method transforms a remote imap mail object into an RDF Model. The first parameter "uri" represents a remote imap mail object. The second parameter "options" specifies the transformation options. And the last parameter "target" is a jena RDF model, which models the imap mail object in RDF after transformation. The transformation is internal accomplished in 4 steps

 

  1. connect to the imap mail server by using the embedded StoreConfig object
  2. parse the uri to find out the object type.
  3. extract the meta data of this object
  4. model the meta information as RDF using the associated Ontology

Usage of the Mail Adapter

In this section we demonstrate how to use the Mail Adapter via a concrete example. we establish a simple executeable java program.

//first of all you should import the required classes

import com.hp.hpl.jena.rdf.model.Model; // The required Jena API import com.hp.hpl.jena.rdf.model.ModelFactory; // The required Jena API import com.hp.hpl.jena.rdf.model.Resource; // The required Jena API import com.hp.hpl.jena.rdf.model.Statement; // The required Jena API import com.hp.hpl.jena.rdf.model.StmtIterator; // The required Jena API import com.hp.hpl.jena.vocabulary.RDF; // The required Jena API import org.gnowsis.data.CBDEnhanced; // The required gnowsis API import org.gnowsis.data.adapter.AdapterConfig; // The required gnowsis API import org.gnowsis.data.adapter.impl.AdapterConfigImpl; // The required gnowsis API import org.gnowsis.data.exception.UrlParseException; // The required gnowsis API import org.gnowsis.email.cbdadapter.CBDMailAdapter; // The required gnowsis API import org.gnowsis.email.config.MAILCONFIG; // The required gnowsis API import org.gnowsis.email.vocabulary.GNOMAIL; // The required gnowsis API

public class MailAdapterCaller {

/The Mail Adapter Object/

CBDMailAdapter adapt;

CBDEnhanced.Options options = new CBDEnhanced.Options(true, true, true); // ?????

public static void main(String[] args){ // Before use of the Mail Adapter you should initialze the StoreConfig /create a RDF Model for the Configuration/ Model configModel = ModelFactory.createDefaultModel();   /create a root resource for the configuraion/ Resource configRes = configModel.createResource();

/set the resource type/ configRes.addProperty(RDF.type, ADAPTERCONF.Adapter);

/create a resource for the connection to mail server/ Resource session = configModel.createResource();

/set the resource type/ session.addProperty(RDF.type, MAILCONFIG.Session);

/set the host name as property/ session.addProperty(MAILCONFIG.host, "franse.leobard.net");

/set the user name as property/ session.addProperty(MAILCONFIG.username, "janedoe");

/set the password as property/ session.addProperty(MAILCONFIG.password, "XXX");

/set the protocol as property/ session.addProperty(MAILCONFIG.protocol, "imap");

/set the folder to be processed as property/ session.addProperty(MAILCONFIG.foldername, "INBOX");

/set the folder to be processed as property/ session.addProperty(MAILCONFIG.foldername, "Trash");

/set the folder to be processed as property/ session.addProperty(MAILCONFIG.foldername, "Sent");

/set the session resource as property of the config resource/ configRes.addProperty(MAILCONFIG.hasSession , session);

/create a config object based on the config model/ AdapterConfig config = new AdapterConfigImpl(configRes);

/create a adapter based on the config object/ adapt = new CBDMailAdapter(config);

//Now you can use the Mail Adapter to create RDF model for Mail Object

/transform a message into RDF and print it / String uri="imap://janedoe@franse.leobard.net/INBOX/;UID=2"; try { /create a model to accept the result / Model model = ModelFactory.createDefaultModel();

/transformation the mail object into the target RDF model/ adapt.createCBD(uri, options, model);

/output target RDF model/ model.write(System.out, "RDF/XML-ABBREV"); } catch (Exception x) { x.printStackTrace(); }

/transform the INBOX Folder into RDF and print it / uri="imap://janedoe@franse.leobard.net/INBOX"; try { /create a model to accept the result / Model model = ModelFactory.createDefaultModel();

/transformation the mail object into the target RDF model/ adapt.createCBD(uri, options, model);

/output target RDF model/ model.write(System.out, "RDF/XML-ABBREV"); } catch (Exception x) { x.printStackTrace(); }

/transform the Mail Store of user "janedoe" into RDF and print it / uri="imap://janedoe@franse.leobard.net";

try { /create a model to accept the result / Model model = ModelFactory.createDefaultModel();

/transformation the mail object into the target RDF model/ adapt.createCBD(uri, options, model);

/output target RDF model/ model.write(System.out, "RDF/XML-ABBREV"); } catch (Exception x) { x.printStackTrace(); } } }

 

If you use gnowsis framework, there is a graphical user interface for you to configurate the StoreConfig. The valid configuration will be saved into a config file. Your password will be encrypted there for security.

Created by leo
Last modified 2005-04-21 10:34 AM
 

Powered by Plone

This site conforms to the following standards: