• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# SparqlEvaluationContext类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中SparqlEvaluationContext的典型用法代码示例。如果您正苦于以下问题:C# SparqlEvaluationContext类的具体用法?C# SparqlEvaluationContext怎么用?C# SparqlEvaluationContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



SparqlEvaluationContext类属于命名空间,在下文中一共展示了SparqlEvaluationContext类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Evaluate

 /// <summary>
 /// Gets the value of the function in the given Evaluation Context for the given Binding ID
 /// </summary>
 /// <param name="context">Evaluation Context</param>
 /// <param name="bindingID">Binding ID</param>
 /// <returns></returns>
 public override IValuedNode Evaluate(SparqlEvaluationContext context, int bindingID)
 {
     INode temp = this._expr.Evaluate(context, bindingID);
     if (temp != null)
     {
         if (temp.NodeType == NodeType.Uri)
         {
             IUriNode u = (IUriNode)temp;
             if (!u.Uri.Fragment.Equals(String.Empty))
             {
                 return new StringNode(null, u.Uri.Fragment.Substring(1));
             }
             else
             {
     #if SILVERLIGHT
                 return new StringNode(null, u.Uri.Segments().Last());
     #else
                 return new StringNode(null, u.Uri.Segments.Last());
     #endif
             }
         }
         else
         {
             throw new RdfQueryException("Cannot find the Local Name for a non-URI Node");
         }
     }
     else
     {
         throw new RdfQueryException("Cannot find the Local Name for a null");
     }
 }
开发者ID:jmahmud,项目名称:RDFer,代码行数:37,代码来源:LocalNameFunction.cs


示例2: Evaluate

        /// <summary>
        /// Evaluates the Select Distinct Graphs optimisation
        /// </summary>
        /// <param name="context">Evaluation Context</param>
        /// <returns></returns>
        public BaseMultiset Evaluate(SparqlEvaluationContext context)
        {
            context.OutputMultiset = new Multiset();
            String var;
            if (context.Query != null)
            {
                var = context.Query.Variables.First(v => v.IsResultVariable).Name;
            }
            else
            {
                var = this._graphVar;
            }

            foreach (Uri graphUri in context.Data.GraphUris)
            {
                Set s = new Set();
                if (graphUri == null)
                {
                    s.Add(var, null);
                }
                else
                {
                    s.Add(var, new UriNode(null, graphUri));
                }
                context.OutputMultiset.Add(s);
            }

            return context.OutputMultiset;
        }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:34,代码来源:SpecialQueryClasses.cs


示例3: NumericValue

 /// <summary>
 ///   Gets the numeric value of the function in the given Evaluation Context for the given Binding ID
 /// </summary>
 /// <param name = "context">Evaluation Context</param>
 /// <param name = "bindingID">Binding ID</param>
 /// <returns></returns>
 public override object NumericValue(SparqlEvaluationContext context, int bindingID)
 {
     INode temp = _expr.Value(context, bindingID);
     if (temp != null)
     {
         if (temp.NodeType == NodeType.Literal)
         {
             ILiteralNode lit = (ILiteralNode) temp;
             if (lit.DataType != null)
             {
                 if (lit.DataType.ToString().Equals(XmlSpecsHelper.XmlSchemaDataTypeDateTime) ||
                     lit.DataType.ToString().Equals(XmlSpecsHelper.XmlSchemaDataTypeDate))
                 {
                     DateTimeOffset dt;
                     if (DateTimeOffset.TryParse(lit.Value, out dt))
                     {
                         return NumericValueInternal(dt);
                     }
                     throw new RdfQueryException(
                         "Unable to evaluate an XPath Date Time function as the value of the Date Time typed literal couldn't be parsed as a Date Time");
                 }
                 throw new RdfQueryException(
                     "Unable to evaluate an XPath Date Time function on a typed literal which is not a Date Time");
             }
             throw new RdfQueryException(
                 "Unable to evaluate an XPath Date Time function on an untyped literal argument");
         }
         throw new RdfQueryException(
             "Unable to evaluate an XPath Date Time function on a non-literal argument");
     }
     throw new RdfQueryException("Unable to evaluate an XPath Date Time function on a null argument");
 }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:38,代码来源:XPathDateTimeFunctions.cs


示例4: NumericValue

        /// <summary>
        /// Calculates the Numeric Value of this Expression as evaluated for a given Binding
        /// </summary>
        /// <param name="context">Evaluation Context</param>
        /// <param name="bindingID">Binding ID</param>
        /// <returns></returns>
        public override object NumericValue(SparqlEvaluationContext context, int bindingID)
        {
            if (this._leftExpr is ISparqlNumericExpression && this._rightExpr is ISparqlNumericExpression)
            {
                ISparqlNumericExpression a, b;
                a = (ISparqlNumericExpression)this._leftExpr;
                b = (ISparqlNumericExpression)this._rightExpr;

                SparqlNumericType type = (SparqlNumericType)Math.Max((int)a.NumericType(context, bindingID), (int)b.NumericType(context, bindingID));

                switch (type)
                {
                    case SparqlNumericType.Integer:
                        return a.IntegerValue(context, bindingID) + b.IntegerValue(context, bindingID);
                    case SparqlNumericType.Decimal:
                        return a.DecimalValue(context, bindingID) + b.DecimalValue(context, bindingID);
                    case SparqlNumericType.Float:
                        return a.FloatValue(context, bindingID) + b.FloatValue(context, bindingID);
                    case SparqlNumericType.Double:
                        return a.DoubleValue(context, bindingID) + b.DoubleValue(context, bindingID);
                    default:
                        throw new RdfQueryException("Cannot evalute an Arithmetic Expression when the Numeric Type of the expression cannot be determined");
                }
            }
            else
            {
                throw new RdfQueryException("Cannot evalute an Arithmetic Expression where the two sub-expressions are not Numeric Expressions");
            }
        }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:35,代码来源:SparqlNumericExpressions.cs


示例5: Evaluate

        /// <summary>
        /// Gets the Timezone of the Argument Expression as evaluated for the given Binding in the given Context
        /// </summary>
        /// <param name="context">Evaluation Context</param>
        /// <param name="bindingID">Binding ID</param>
        /// <returns></returns>
        public override IValuedNode Evaluate(SparqlEvaluationContext context, int bindingID)
        {
            IValuedNode temp = this._expr.Evaluate(context, bindingID);
            if (temp != null)
            {
                DateTimeOffset dt = temp.AsDateTime();
                //Regex based check to see if the value has a Timezone component
                //If not then the result is a null
                if (!Regex.IsMatch(temp.AsString(), "(Z|[+-]\\d{2}:\\d{2})$")) return new StringNode(null, string.Empty);

                //Now we have a DateTime we can try and return the Timezone
                if (dt.Offset.Equals(TimeSpan.Zero))
                {
                    //If Zero it was specified as Z (which means UTC so zero offset)
                    return new StringNode(null, "Z");
                }
                else
                {
                    //If the Offset is outside the range -14 to 14 this is considered invalid
                    if (dt.Offset.Hours < -14 || dt.Offset.Hours > 14) return null;

                    //Otherwise it has an offset which is a given number of hours (and minutes)
                    return new StringNode(null, dt.Offset.Hours.ToString("00") + ":" + dt.Offset.Minutes.ToString("00"));
                }
            }
            else
            {
                throw new RdfQueryException("Unable to evaluate a Date Time function on a null argument");
            }
        }
开发者ID:jmahmud,项目名称:RDFer,代码行数:36,代码来源:TZFunction.cs


示例6: EffectiveBooleanValue

 /// <summary>
 /// Computes the Effective Boolean Value of this Expression as evaluated for a given Binding
 /// </summary>
 /// <param name="context">Evaluation Context</param>
 /// <param name="bindingID">Binding ID</param>
 /// <returns></returns>
 public override bool EffectiveBooleanValue(SparqlEvaluationContext context, int bindingID)
 {
     //Lazy Evaluation for efficiency
     try
     {
         bool leftResult = this._leftExpr.EffectiveBooleanValue(context, bindingID);
         if (leftResult)
         {
             //If the LHS is true it doesn't matter about any subsequenct results
             return true;
         }
         else
         {
             //If the LHS is false then we have to evaluate the RHS
             return this._rightExpr.EffectiveBooleanValue(context, bindingID);
         }
     }
     catch
     {
         //If there's an Error on the LHS we return true only if the RHS evaluates to true
         //Otherwise we throw the Error
         bool rightResult = this._rightExpr.EffectiveBooleanValue(context, bindingID);
         if (rightResult)
         {
             return true;
         }
         else
         {
             throw;
         }
     }
 }
开发者ID:jbunzel,项目名称:MvcRQ_git,代码行数:38,代码来源:SPARQLExpressionClasses.cs


示例7: Evaluate

        /// <summary>
        /// Returns the value of the Expression as evaluated for a given Binding as a Literal Node
        /// </summary>
        /// <param name="context">Evaluation Context</param>
        /// <param name="bindingID">Binding ID</param>
        /// <returns></returns>
        public override IValuedNode Evaluate(SparqlEvaluationContext context, int bindingID)
        {
            INode result = this._expr.Evaluate(context, bindingID);
            if (result == null)
            {
                throw new RdfQueryException("Cannot return the Data Type URI of a NULL");
            }
            else
            {
                switch (result.NodeType)
                {
                    case NodeType.Literal:
                        ILiteralNode lit = (ILiteralNode)result;
                        if (lit.DataType == null)
                        {
                            if (!lit.Language.Equals(string.Empty))
                            {
                                return new UriNode(null, UriFactory.Create(RdfSpecsHelper.RdfLangString));
                            }
                            else
                            {
                                return new UriNode(null, UriFactory.Create(XmlSpecsHelper.XmlSchemaDataTypeString));
                            }
                        }
                        else
                        {
                            return new UriNode(null, lit.DataType);
                        }

                    default:
                        throw new RdfQueryException("Cannot return the Data Type URI of Nodes which are not Literal Nodes");
                }
            }
        }
开发者ID:jmahmud,项目名称:RDFer,代码行数:40,代码来源:DataTypeFunction.cs


示例8: Evaluate

        /// <summary>
        /// Calculates the Numeric Value of this Expression as evaluated for a given Binding
        /// </summary>
        /// <param name="context">Evaluation Context</param>
        /// <param name="bindingID">Binding ID</param>
        /// <returns></returns>
        public override IValuedNode Evaluate(SparqlEvaluationContext context, int bindingID)
        {
            IValuedNode a = this._leftExpr.Evaluate(context, bindingID);
            IValuedNode b = this._rightExpr.Evaluate(context, bindingID);
            if (a == null || b == null) throw new RdfQueryException("Cannot apply division when one/both arguments are null");

            SparqlNumericType type = (SparqlNumericType)Math.Max((int)a.NumericType, (int)b.NumericType);

            try
            {
                switch (type)
                {
                    case SparqlNumericType.Integer:
                    case SparqlNumericType.Decimal:
                        //For Division Integers are treated as decimals
                        decimal d = a.AsDecimal() / b.AsDecimal();
                        if (Decimal.Floor(d).Equals(d) && d >= Int64.MinValue && d <= Int64.MaxValue)
                        {
                            return new LongNode(null, Convert.ToInt64(d));
                        }
                        return new DecimalNode(null, d);
                    case SparqlNumericType.Float:
                        return new FloatNode(null, a.AsFloat() / b.AsFloat());
                    case SparqlNumericType.Double:
                        return new DoubleNode(null, a.AsDouble() / b.AsDouble());
                    default:
                        throw new RdfQueryException("Cannot evalute an Arithmetic Expression when the Numeric Type of the expression cannot be determined");
                }
            }
            catch (DivideByZeroException)
            {
                throw new RdfQueryException("Cannot evaluate a Division Expression where the divisor is Zero");
            }
        }
开发者ID:jmahmud,项目名称:RDFer,代码行数:40,代码来源:DivisionExpression.cs


示例9: PathEvaluationContext

 /// <summary>
 /// Creates a new Path Evaluation Context
 /// </summary>
 /// <param name="context">SPARQL Evaluation Context</param>
 /// <param name="end">Start point of the Path</param>
 /// <param name="start">End point of the Path</param>
 public PathEvaluationContext(SparqlEvaluationContext context, PatternItem start, PatternItem end)
 {
     this._context = context;
     this._start = start;
     this._end = end;
     if (this._start.VariableName == null && this._end.VariableName == null) this._earlyAbort = true;
 }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:13,代码来源:PathEvaluationContext.cs


示例10: Evaluate

        /// <summary>
        /// Gets the Numeric Value of the function as evaluated in the given Context for the given Binding ID
        /// </summary>
        /// <param name="context">Evaluation Context</param>
        /// <param name="bindingID">Binding ID</param>
        /// <returns></returns>
        public override IValuedNode Evaluate(SparqlEvaluationContext context, int bindingID)
        {
            IValuedNode a = this._expr.Evaluate(context, bindingID);
            if (a == null) throw new RdfQueryException("Cannot calculate an arithmetic expression on a null");

            switch (a.NumericType)
            {
                case SparqlNumericType.Integer:
                    return new LongNode(null, Math.Abs(a.AsInteger()));

                case SparqlNumericType.Decimal:
                    return new DecimalNode(null, Math.Abs(a.AsDecimal()));

                case SparqlNumericType.Float:
                    try
                    {
                        return new FloatNode(null, Convert.ToSingle(Math.Abs(a.AsDouble())));
                    }
                    catch (RdfQueryException)
                    {
                        throw;
                    }
                    catch (Exception ex)
                    {
                        throw new RdfQueryException("Unable to cast absolute value of float to a float", ex);
                    }

                case SparqlNumericType.Double:
                    return new DoubleNode(null, Math.Abs(a.AsDouble()));

                default:
                    throw new RdfQueryException("Cannot evalute an Arithmetic Expression when the Numeric Type of the expression cannot be determined");
            }
        }
开发者ID:jmahmud,项目名称:RDFer,代码行数:40,代码来源:AbsFunction.cs


示例11: NumericValue

        /// <summary>
        /// Gets the Numeric Value of the function as evaluated in the given Context for the given Binding ID
        /// </summary>
        /// <param name="context">Evaluation Context</param>
        /// <param name="bindingID">Binding ID</param>
        /// <returns></returns>
        public override object NumericValue(SparqlEvaluationContext context, int bindingID)
        {
            if (this._expr is ISparqlNumericExpression)
            {
                ISparqlNumericExpression a = (ISparqlNumericExpression)this._expr;

                switch (a.NumericType(context, bindingID))
                {
                    case SparqlNumericType.Integer:
                        return Math.Abs(a.IntegerValue(context, bindingID));

                    case SparqlNumericType.Decimal:
                        return Math.Abs(a.DecimalValue(context, bindingID));

                    case SparqlNumericType.Float:
                        return (float)Math.Abs(a.DoubleValue(context, bindingID));

                    case SparqlNumericType.Double:
                        return Math.Abs(a.DoubleValue(context, bindingID));
                        
                    default:
                        throw new RdfQueryException("Cannot evalute an Arithmetic Expression when the Numeric Type of the expression cannot be determined");
                }
            }
            else
            {
                throw new RdfQueryException("Cannot evalute an Arithmetic Expression where the sub-expression is not a Numeric Expressions");
            }
        }
开发者ID:jbunzel,项目名称:MvcRQ_git,代码行数:35,代码来源:XPathNumericFunctions.cs


示例12: DescribeInternal

        /// <summary>
        /// Generates the Description for each of the Nodes to be described
        /// </summary>
        /// <param name="handler">RDF Handler</param>
        /// <param name="context">SPARQL Evaluation Context</param>
        /// <param name="nodes">Nodes to be described</param>
        protected override void DescribeInternal(IRdfHandler handler, SparqlEvaluationContext context, IEnumerable<INode> nodes)
        {
            //Rewrite Blank Node IDs for DESCRIBE Results
            Dictionary<String, INode> bnodeMapping = new Dictionary<string, INode>();

            //Get Triples for this Subject
            Queue<INode> bnodes = new Queue<INode>();
            HashSet<INode> expandedBNodes = new HashSet<INode>();
            INode rdfsLabel = handler.CreateUriNode(UriFactory.Create(NamespaceMapper.RDFS + "label"));
            foreach (INode n in nodes)
            {
                //Get Triples where the Node is the Subject
                foreach (Triple t in context.Data.GetTriplesWithSubject(n))
                {
                    if (t.Object.NodeType == NodeType.Blank)
                    {
                        if (!expandedBNodes.Contains(t.Object)) bnodes.Enqueue(t.Object);
                    }
                    if (!handler.HandleTriple((this.RewriteDescribeBNodes(t, bnodeMapping, handler)))) ParserHelper.Stop();
                }

                //Compute the Blank Node Closure for this Subject
                while (bnodes.Count > 0)
                {
                    INode bsubj = bnodes.Dequeue();
                    if (expandedBNodes.Contains(bsubj)) continue;
                    expandedBNodes.Add(bsubj);

                    foreach (Triple t2 in context.Data.GetTriplesWithSubjectPredicate(bsubj, rdfsLabel))
                    {
                        if (!handler.HandleTriple((this.RewriteDescribeBNodes(t2, bnodeMapping, handler)))) ParserHelper.Stop();
                    }
                }
            }
        }
开发者ID:jmahmud,项目名称:RDFer,代码行数:41,代码来源:LabelledDescription.cs


示例13: Evaluate

        /// <summary>
        /// Calculates the Numeric Value of this Expression as evaluated for a given Binding
        /// </summary>
        /// <param name="context">Evaluation Context</param>
        /// <param name="bindingID">Binding ID</param>
        /// <returns></returns>
        public override IValuedNode Evaluate(SparqlEvaluationContext context, int bindingID)
        {
            IValuedNode a = this._expr.Evaluate(context, bindingID);
            if (a == null) throw new RdfQueryException("Cannot apply unary minus to a null");

            switch (a.NumericType)
            {
                case SparqlNumericType.Integer:
                    return new LongNode(null, -1 * a.AsInteger());

                case SparqlNumericType.Decimal:
                    decimal decvalue = a.AsDecimal();
                    if (decvalue == Decimal.Zero)
                    {
                        return new DecimalNode(null, Decimal.Zero);
                    }
                    else
                    {
                        return new DecimalNode(null, -1 * decvalue);
                    }
                case SparqlNumericType.Float:
                    float fltvalue = a.AsFloat();
                    if (Single.IsNaN(fltvalue))
                    {
                        return new FloatNode(null, Single.NaN);
                    }
                    else if (Single.IsPositiveInfinity(fltvalue))
                    {
                        return new FloatNode(null, Single.NegativeInfinity);
                    }
                    else if (Single.IsNegativeInfinity(fltvalue))
                    {
                        return new FloatNode(null, Single.PositiveInfinity);
                    }
                    else
                    {
                        return new FloatNode(null, -1.0f * fltvalue);
                    }
                case SparqlNumericType.Double:
                    double dblvalue = a.AsDouble();
                    if (Double.IsNaN(dblvalue))
                    {
                        return new DoubleNode(null, Double.NaN);
                    }
                    else if (Double.IsPositiveInfinity(dblvalue))
                    {
                        return new DoubleNode(null, Double.NegativeInfinity);
                    }
                    else if (Double.IsNegativeInfinity(dblvalue))
                    {
                        return new DoubleNode(null, Double.PositiveInfinity);
                    }
                    else
                    {
                        return new DoubleNode(null, -1.0 * dblvalue);
                    }
                default:
                    throw new RdfQueryException("Cannot evalute an Arithmetic Expression when the Numeric Type of the expression cannot be determined");
            }
        }
开发者ID:jmahmud,项目名称:RDFer,代码行数:66,代码来源:MinusExpression.cs


示例14: Evaluate

        /// <summary>
        /// Evaluates a Filter in the given Evaluation Context
        /// </summary>
        /// <param name="context">Evaluation Context</param>
        public override void Evaluate(SparqlEvaluationContext context)
        {
            if (context.InputMultiset is NullMultiset)
            {
                //If we get a NullMultiset then the FILTER has no effect since there are already no results
            }
            else if (context.InputMultiset is IdentityMultiset)
            {
                if (!this._filter.Variables.Any())
                {
                    //If we get an IdentityMultiset then the FILTER only has an effect if there are no
                    //variables - otherwise it is not in scope and is ignored

                    try
                    {
                        if (!this._filter.Expression.EffectiveBooleanValue(context, 0))
                        {
                            context.OutputMultiset = new NullMultiset();
                            return;
                        }
                    }
                    catch
                    {
                        context.OutputMultiset = new NullMultiset();
                        return;
                    }
                }
            }
            else
            {
                this._filter.Evaluate(context);
            }
            context.OutputMultiset = new IdentityMultiset();
        }
开发者ID:jbunzel,项目名称:MvcRQ_git,代码行数:38,代码来源:FilterPattern.cs


示例15: NumericValue

        /// <summary>
        /// Gets the Numeric Value of the Function as evaluated in the given Context for the given Binding ID
        /// </summary>
        /// <param name="context">Evaluation Context</param>
        /// <param name="bindingID">Binding ID</param>
        /// <returns></returns>
        public override object NumericValue(SparqlEvaluationContext context, int bindingID)
        {
            if (this._expr is ISparqlNumericExpression)
            {
                ISparqlNumericExpression a = (ISparqlNumericExpression)this._expr;

                SparqlNumericType type = a.NumericType(context, bindingID);
                switch (type)
                {
                    case SparqlNumericType.Integer:
                        return this.IntegerValueInternal(a.IntegerValue(context, bindingID));
                    case SparqlNumericType.Decimal:
                        return this.DecimalValueInternal(a.DecimalValue(context, bindingID));
                    case SparqlNumericType.Double:
                        return this.DoubleValueInternal(a.DoubleValue(context, bindingID));
                    case SparqlNumericType.NaN:
                    default:
                        throw new RdfQueryException("Unable to evaluate a Leviathan Numeric Expression since the inner expression did not evaluate to a Numeric Value");
                }
            }
            else
            {
                throw new RdfQueryException("Unable to evaluate a Leviathan Numeric Expression since the inner expression is not a Numeric Expression");
            }
        }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:31,代码来源:LeviathanNumericFunctions.cs


示例16: Evaluate

        /// <summary>
        /// Evaluates an ExistsJoin
        /// </summary>
        /// <param name="context">Evaluation Context</param>
        /// <returns></returns>
        public BaseMultiset Evaluate(SparqlEvaluationContext context)
        {
            BaseMultiset initialInput = context.InputMultiset;
            BaseMultiset lhsResult = context.Evaluate(this._lhs);//this._lhs.Evaluate(context);
            context.CheckTimeout();

            if (lhsResult is NullMultiset)
            {
                context.OutputMultiset = lhsResult;
            }
            else if (lhsResult.IsEmpty)
            {
                context.OutputMultiset = new NullMultiset();
            }
            else
            {
                //Only execute the RHS if the LHS had results
                context.InputMultiset = lhsResult;
                BaseMultiset rhsResult = context.Evaluate(this._rhs);//this._rhs.Evaluate(context);
                context.CheckTimeout();

                context.OutputMultiset = lhsResult.ExistsJoin(rhsResult, this._mustExist);
                context.CheckTimeout();
            }

            context.InputMultiset = context.OutputMultiset;
            return context.OutputMultiset;
        }
开发者ID:jbunzel,项目名称:MvcRQ_git,代码行数:33,代码来源:AlgebraJoinClasses.cs


示例17: Value

 /// <summary>
 /// Gets the Value of the function as evaluated in the given Context for the given Binding ID
 /// </summary>
 /// <param name="context">Context</param>
 /// <param name="bindingID">Binding ID</param>
 /// <returns></returns>
 public INode Value(SparqlEvaluationContext context, int bindingID)
 {
     INode temp = this._expr.Value(context, bindingID);
     if (temp != null)
     {
         if (temp.NodeType == NodeType.Literal)
         {
             ILiteralNode lit = (ILiteralNode)temp;
             if (lit.DataType != null)
             {
                 if (lit.DataType.ToString().Equals(XmlSpecsHelper.XmlSchemaDataTypeString))
                 {
                     return this.ValueInternal(lit);
                 }
                 else
                 {
                     throw new RdfQueryException("Unable to evalaute an XPath String function on a non-string typed Literal");
                 }
             }
             else
             {
                 return this.ValueInternal(lit);
             }
         }
         else
         {
             throw new RdfQueryException("Unable to evaluate an XPath String function on a non-Literal input");
         }
     }
     else
     {
         throw new RdfQueryException("Unable to evaluate an XPath String function on a null input");
     }
 }
开发者ID:jbunzel,项目名称:MvcRQ_git,代码行数:40,代码来源:XPathStringFunctions.cs


示例18: Describe

        /// <summary>
        /// Returns the Graph which is the Result of the Describe Query by computing the Concise Bounded Description for all Results
        /// </summary>
        /// <param name="context">SPARQL Evaluation Context</param>
        /// <returns></returns>
        public override IGraph Describe(SparqlEvaluationContext context)
        {
            //Get a new empty Graph and import the Base Uri and Namespace Map of the Query
            Graph g = new Graph();
            g.BaseUri = context.Query.BaseUri;
            g.NamespaceMap.Import(context.Query.NamespaceMap);

            //Build a list of INodes to describe
            List<INode> nodes = new List<INode>();
            foreach (IToken t in context.Query.DescribeVariables)
            {
                switch (t.TokenType)
                {
                    case Token.QNAME:
                    case Token.URI:
                        //Resolve Uri/QName
                        nodes.Add(new UriNode(g, new Uri(Tools.ResolveUriOrQName(t, g.NamespaceMap, g.BaseUri))));
                        break;

                    case Token.VARIABLE:
                        //Get Variable Values
                        String var = t.Value.Substring(1);
                        if (context.OutputMultiset.ContainsVariable(var))
                        {
                            foreach (Set s in context.OutputMultiset.Sets)
                            {
                                INode temp = s[var];
                                if (temp != null) nodes.Add(temp);
                            }
                        }
                        break;

                    default:
                        throw new RdfQueryException("Unexpected Token '" + t.GetType().ToString() + "' in DESCRIBE Variables list");
                }
            }

            //Rewrite Blank Node IDs for DESCRIBE Results
            Dictionary<String, INode> bnodeMapping = new Dictionary<string, INode>();

            //Get Triples for this Subject
            foreach (INode n in nodes)
            {
                //Get Triples where the Node is the Subject
                foreach (Triple t in context.Data.GetTriplesWithSubject(n))
                {
                    g.Assert(this.RewriteDescribeBNodes(t, bnodeMapping, g));
                }
                //Get Triples where the Node is the Object
                foreach (Triple t in context.Data.GetTriplesWithObject(n))
                {
                    g.Assert(this.RewriteDescribeBNodes(t, bnodeMapping, g));
                }
            }

            //Return the Graph
            g.BaseUri = null;
            return g;
        }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:64,代码来源:SimpleSubjectObjectDescription.cs


示例19: Evaluate

        /// <summary>
        /// Evaluates the expression
        /// </summary>
        /// <param name="context">Evaluation Context</param>
        /// <param name="bindingID">Binding ID</param>
        /// <returns></returns>
        public override IValuedNode Evaluate(SparqlEvaluationContext context, int bindingID)
        {
            IValuedNode temp = this._expr.Evaluate(context, bindingID);
            if (temp == null) throw new RdfQueryException("Cannot apply a trigonometric function to a null");

            if (temp.NumericType == SparqlNumericType.NaN) throw new RdfQueryException("Cannot apply a trigonometric function to a non-numeric argument");

            return new DoubleNode(null, this._func(temp.AsDouble()));
        }
开发者ID:jmahmud,项目名称:RDFer,代码行数:15,代码来源:BaseTrigonometricFunction.cs


示例20: Evaluate

        /// <summary>
        /// Evaluates the subquery in the given context
        /// </summary>
        /// <param name="context">Evaluation Context</param>
        /// <returns></returns>
        public BaseMultiset Evaluate(SparqlEvaluationContext context)
        {
            //Use the same algebra optimisers as the parent query (if any)
            if (context.Query != null)
            {
                this._subquery.AlgebraOptimisers = context.Query.AlgebraOptimisers;
            }

            if (context.InputMultiset is NullMultiset)
            {
                context.OutputMultiset = context.InputMultiset;
            }
            else if (context.InputMultiset.IsEmpty)
            {
                context.OutputMultiset = new NullMultiset();
            }
            else
            {
                SparqlEvaluationContext subcontext = new SparqlEvaluationContext(this._subquery, context.Data, context.Processor);
                subcontext.InputMultiset = context.InputMultiset;

                //Add any Named Graphs to the subquery
                if (context.Query != null)
                {
                    foreach (Uri u in context.Query.NamedGraphs)
                    {
                        this._subquery.AddNamedGraph(u);
                    }
                }

                ISparqlAlgebra query = this._subquery.ToAlgebra();
                try
                {
                    //Evaluate the Subquery
                    context.OutputMultiset = subcontext.Evaluate(query);

                    //If the Subquery contains a GROUP BY it may return a Group Multiset in which case we must flatten this to a Multiset
                    if (context.OutputMultiset is GroupMultiset)
                    {
                        context.OutputMultiset = new Multiset((GroupMultiset)context.OutputMultiset);
                    }

                    //Strip out any Named Graphs from the subquery
                    if (this._subquery.NamedGraphs.Any())
                    {
                        this._subquery.ClearNamedGraphs();
                    }
                }
                catch (RdfQueryException queryEx)
                {
                    throw new RdfQueryException("Query failed due to a failure in Subquery Execution:\n" + queryEx.Message, queryEx);
                }
            }

            return context.OutputMultiset;
        }
开发者ID:jbunzel,项目名称:MvcRQ_git,代码行数:61,代码来源:SubQuery.cs



注:本文中的SparqlEvaluationContext类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# SparqlResultSet类代码示例发布时间:2022-05-24
下一篇:
C# SparkleGit类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap