本文整理汇总了C#中StatementSink类的典型用法代码示例。如果您正苦于以下问题:C# StatementSink类的具体用法?C# StatementSink怎么用?C# StatementSink使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
StatementSink类属于命名空间,在下文中一共展示了StatementSink类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SemWebTripleCollection
/// <summary>
/// Creates a new Triple Collection as a wrapper around a SemWeb StatementSink and StatementSource
/// </summary>
/// <param name="g">Graph</param>
/// <param name="sink">Sink</param>
/// <param name="source">Source</param>
public SemWebTripleCollection(IGraph g, StatementSink sink, StatementSource source)
{
this._g = g;
this._sink = sink;
this._source = source;
this._mapping = new SemWebMapping(this._g);
}
示例2: Select
public void Select (Statement template, StatementSink sink)
{
// extract the fields for easy access
Entity subj = template.Subject;
Entity pred = template.Predicate;
Resource obj = template.Object;
// convert the SemWeb fields to the RDFQuery fields
Uri s;
string p, o;
rdf_to_beagle_hook (subj, pred, obj, out s, out p, out o);
RDFQuery query = new RDFQuery (s, p, o);
RDFQueryResult result = (RDFQueryResult) query.Send ();
foreach (Hit hit in result.Hits) {
Entity subject = new Entity (hit.Uri.ToString ()); //FIXME: Do we have to use strings here?
foreach (Property prop in hit.Properties) {
Entity predicate = BeaglePropertyToEntity (prop.Type, prop.Key);
Resource _object;
property_to_rdf_hook (prop, out _object);
// now create a the statement and add it to the result
Statement st = new Statement (subject, predicate, _object);
sink.Add (st);
}
}
}
示例3: Select
public override void Select(StatementSink storage) {
// Read past the processing instructions to
// the document element. If it is rdf:RDF,
// then process the description nodes within it.
// Otherwise, the document element is itself a
// description.
this.storage = storage;
while (xml.Read()) {
if (xml.NamespaceURI == NS.RDF && xml.LocalName == "RDF" ) {
// If there is an xml:base here, set BaseUri so
// the application can recover it. It doesn't
// affect parsing since the xml:base attribute
// will override BaseUri.
string xmlbase = xml.GetAttribute("xml:base");
if (xmlbase != null) BaseUri = xmlbase;
while (xml.Read()) {
if (xml.NodeType == XmlNodeType.Element)
ParseDescription();
}
break;
}
}
xml.Close();
}
示例4: Select
public void Select (StatementSink sink)
{
using (Stream stream = Open ()) {
Header header = new Header (stream);
MetadataStore.AddLiteral (sink, "tiff:ImageWidth", header.Width.ToString ());
MetadataStore.AddLiteral (sink, "tiff:ImageLength", header.Height.ToString ());
string bits = header.IsDeep ? "16" : "8";
MetadataStore.Add (sink, "tiff:BitsPerSample", "rdf:Seq", new string [] { bits, bits, bits });
}
}
示例5: Select
bool Select(Entity[] subjects, Entity[] predicates, Resource[] objects, Entity[] metas, LiteralFilter[] litFilters, int limit, StatementSink sink, bool ask) {
// TODO: Change meta into named graphs. Anything but a null or DefaultMeta
// meta returns no statements immediately.
if (metas != null && (metas.Length != 1 || metas[0] != Statement.DefaultMeta))
return false;
string query;
bool nonull = false;
if (subjects != null && subjects.Length == 1
&& predicates != null && predicates.Length == 1
&& objects != null && objects.Length == 1) {
query = "ASK WHERE { " + S(subjects[0], null) + " " + S(predicates[0], null) + " " + S(objects[0], null) + "}";
nonull = true;
} else {
if (ask)
query = "ASK { ";
else
query = "SELECT * WHERE { ";
query += S(subjects, "?subject");
query += " ";
query += S(predicates, "?predicate");
query += " ";
query += S(objects, "?object");
query += " . ";
query += SL(subjects, "?subject", false);
query += SL(predicates, "?predicate", false);
query += SL(objects, "?object", false);
query += " }";
// TODO: Pass literal filters to server.
}
if (limit >= 1)
query += " LIMIT " + limit;
Statement d = new Statement(
(subjects != null && subjects.Length == 1) ? subjects[0] : null,
(predicates != null && predicates.Length == 1) ? predicates[0] : null,
(objects != null && objects.Length == 1) ? objects[0] : null);
if (ask || nonull) {
BooleanWrap bw = new BooleanWrap();
Load(query, bw);
if (ask)
return bw.value;
else if (bw.value)
sink.Add(new Statement(subjects[0], predicates[0], objects[0]));
return false;
} else {
Load(query, new QueryToStatements(sink, litFilters, d));
return true;
}
}
示例6: Select
public override void Select(StatementSink store) {
ParseContext context = new ParseContext();
context.source = new MyReader(sourcestream);
context.store = GetDupCheckSink(store);
context.namespaces = namespaces;
context.namedNode = new UriMap();
context.anonymous = new Hashtable();
context.meta = Meta;
while (ReadStatement(context)) { }
}
示例7: ToSemWeb
/// <summary>
/// Takes the contents of a dotNetRDF Graph and inputs it into a SemWeb StatementSink
/// </summary>
/// <param name="g">Graph</param>
/// <param name="mapping">Blank Node Mapping</param>
/// <param name="sink">Statement Sink</param>
public static void ToSemWeb(IGraph g, SemWebMapping mapping, StatementSink sink)
{
Statement stmt;
foreach (Triple t in g.Triples)
{
stmt = ToSemWeb(t, mapping);
//Stop adding statements if the sink tells up to stop
if (!sink.Add(stmt)) return;
}
}
示例8: Select
bool Select(Statement template, StatementSink sink, bool ask) {
return Select(
template.Subject == null ? null : new Entity[] { template.Subject },
template.Predicate == null ? null : new Entity[] { template.Predicate },
template.Object == null ? null : new Resource[] { template.Object },
template.Meta == null ? null : new Entity[] { template.Meta },
null,
0,
sink,
ask
);
}
示例9: Select
public override bool Distinct { get { return false; } } // not sure...
public override void Select(SelectFilter filter, SelectableSource targetModel, StatementSink sink) {
if (filter.Subjects == null) filter.Subjects = new Entity[] { new Variable("subject") };
if (filter.Predicates == null) filter.Predicates = new Entity[] { new Variable("predicate") };
if (filter.Objects == null) filter.Objects = new Entity[] { new Variable("object") };
if (filter.Metas == null) filter.Metas = new Entity[] { Statement.DefaultMeta };
foreach (Statement s in filter) { // until we can operate on filter directly
ArrayList evidence = prove(rules, targetModel, new Statement[] { s }, -1);
if (evidence == null)
continue; // not provable (in max number of steps, if that were given)
foreach (EvidenceItem ei in evidence) {
foreach (Statement h in ei.head) { // better be just one statement
if (filter.LiteralFilters != null
&& !LiteralFilter.MatchesFilters(h.Object, filter.LiteralFilters, targetModel))
continue;
sink.Add(h);
}
}
}
}
示例10: Select
public void Select(Statement template, StatementSink result) {
if (result == null) throw new ArgumentNullException();
Select(template.Subject, template.Predicate, template.Object, template.Meta, null, result, 0);
}
示例11: Add
public static void Add (StatementSink sink, Entity subject, string predicate, string type, string [] values)
{
if (values == null) {
System.Console.WriteLine ("{0} has no values; skipping", predicate);
return;
}
Entity empty = new SemWeb.BNode();
Statement top = new Statement (subject, (Entity)MetadataStore.Namespaces.Resolve (predicate), empty);
Statement desc = new Statement (empty,
(Entity)MetadataStore.Namespaces.Resolve ("rdf:type"),
(Entity)MetadataStore.Namespaces.Resolve (type));
sink.Add (desc);
foreach (string value in values) {
Statement literal = new Statement (empty,
(Entity)MetadataStore.Namespaces.Resolve ("rdf:li"),
new SemWeb.Literal (value, null, null));
sink.Add (literal);
}
sink.Add (top);
}
示例12: AddLiteral
public static void AddLiteral (StatementSink sink, string predicate, string value)
{
Statement stmt = new Statement (FSpotXMPBase,
(Entity)MetadataStore.Namespaces.Resolve (predicate),
new SemWeb.Literal (value));
sink.Add (stmt);
}
示例13: Select
public abstract void Select(SelectFilter filter, SelectableSource targetModel, StatementSink sink);
示例14: Select
public void Select (StatementSink sink)
{
MetadataStore.AddLiteral (sink, "tiff:Orientation", ((int)Info.Orientation).ToString ());
MetadataStore.AddLiteral (sink, "tiff:ImageWidth", Info.Width.ToString ());
MetadataStore.AddLiteral (sink, "tiff:ImageLength", Info.Height.ToString ());
}
示例15: Select
/// <summary>
/// Selects Statements from the Source based on a Template
/// </summary>
/// <param name="template">Statement Template</param>
/// <param name="sink">Sink to stream results to</param>
public void Select(Statement template, StatementSink sink)
{
//Convert Template to an Enumerable
IEnumerable<Triple> ts = Enumerable.Empty<Triple>();
int hash;
if (template.Meta != Statement.DefaultMeta && template.Meta != null)
{
//Select from the specific Graph if it exists
Uri graphUri;
if (template.Meta.Uri == null)
{
hash = new Uri(GraphCollection.DefaultGraphUri).GetEnhancedHashCode();
graphUri = null;
}
else
{
graphUri = new Uri(template.Meta.Uri);
hash = graphUri.GetEnhancedHashCode();
}
if (this._store.HasGraph(graphUri))
{
ts = this.TemplateToEnumerable(template, this._store.Graph(graphUri));
SemWebMapping mapping = this.GetMapping(hash, this._store.Graph(graphUri));
foreach (Triple t in ts)
{
//Keep streaming Triples until the sink tells us to stop
Statement stmt = SemWebConverter.ToSemWeb(t, mapping);
if (!sink.Add(stmt)) return;
}
}
}
else
{
//Output the results from each Graph in turn
foreach (IGraph g in this._store.Graphs)
{
Entity graphUri;
if (g.BaseUri == null)
{
hash = new Uri(GraphCollection.DefaultGraphUri).GetEnhancedHashCode();
graphUri = new Entity(GraphCollection.DefaultGraphUri);
}
else
{
hash = g.BaseUri.GetEnhancedHashCode();
graphUri = new Entity(g.BaseUri.ToString());
}
SemWebMapping mapping = this.GetMapping(hash, g);
foreach (Triple t in this.TemplateToEnumerable(template, g))
{
Statement stmt = SemWebConverter.ToSemWeb(t, mapping);
stmt.Meta = graphUri;
if (!sink.Add(stmt)) return;
}
}
}
}