SemWeb : SemWeb Namespace
KnowledgeModel

A store for combining multiple stores and inference engines.

public class KnowledgeModel : Store


Remarks

Resources and stores can be associated with KnowledgeModels through their constructors. Associating a KnowledgeModel is optional, but doing so enables the default accessor of Resources, which allows for easy traversal of the RDF graph.

Associating resources and stores with KnowledgeModels can only be done through their constructors. But, doing so to stores does not add the store into the KnowledgeModel to make the statements available for calls to SemWeb.Store.Select(SemWeb.Statement,SemWeb.StatementSink). SemWeb.KnowledgeModel.Add(SemWeb.Store) must be called separately. Likewise, calling SemWeb.KnowledgeModel.Add(SemWeb.Store) does not change which KnowledgeModel a store is associate with (if any).

The following is a basic example of an RDF application using a KnowledgeModel. It reads an RDF/XML file on standard input and writes an N3 version of the statements to standard output.

C# Example
// Compile with: mcs -r:../bin/SemWeb.dll simple.cs
// Execute with: MONO_PATH=../bin mono simple.exe < testfile.rdf

using System;
using SemWeb;
using SemWeb.IO;
using SemWeb.Stores;

public class Simple {
	public static void Main() {
		KnowledgeModel model = new KnowledgeModel();
		
		MemoryStore store = new MemoryStore(model);
		model.Add(store);
		
		store.Import(new RdfXmlParser(Console.In));
		store.Write(new N3Writer(Console.Out));
	}
}
Members

See Also: Inherited members from Store.

Constructors
Constructs a new empty KnowledgeModel.
Creates a new KnowledgeModel, adds to it a SemWeb.Stores.MemoryStore, and loads in the statements from the given parser.
Properties
Storage [read-only]
SemWeb.Stores.MultiStore . The MultiStore that maintains the list of stores within this KnowledgeModel.
Methods
Add (Store)
Adds a store into the KnowledgeModel.
AddReasoning (ReasoningEngine)
Adds an inference engine to the KnowledgeModel.
Member Details
KnowledgeModel Constructor
public KnowledgeModel ()

Constructs a new empty KnowledgeModel.

Remarks
None.

KnowledgeModel Constructor
public KnowledgeModel (RdfParser parser)

Creates a new KnowledgeModel, adds to it a SemWeb.Stores.MemoryStore, and loads in the statements from the given parser.

Parameters
parser
A parser containing statements to load into the memory store.
Remarks
This is a convenience function.

Add
public void Add (Store storage)

Adds a store into the KnowledgeModel.

Parameters
storage
The store to add into the model.
Remarks

The statements in store become available through calls to this KnowledgeModel's select and contains methods.

The store should have been created passing this KnowledgeModel to its constructor so that the store is associated with this KnowledgeModel.


AddReasoning
public void AddReasoning (ReasoningEngine engine)

Adds an inference engine to the KnowledgeModel.

Parameters
engine
An inference engine.
Remarks

Calls to Select and Contains on this KnowledgeModel will reflect the capabilities of the added inference engine.

Inference engines are executed in the order in which they were added. The inferences made by a later engine are not available as input to an earlier engine.


Storage
public SemWeb.Stores.MultiStore Storage { get; }

The MultiStore that maintains the list of stores within this KnowledgeModel.

Value
The list of stores within this KnowledgeModel.
Remarks

It is safe to manipulate the object returned by this property to change the stores associated with the KnowledgeModel.

Calls to Contains and Select on the MultiStore reflect the contents of the stores contained in it without the application of the KnowledgeModel's inference engines.