コード例 #1
0
        /// <summary>
        /// Creates a new Full Text Pattern
        /// </summary>
        /// <param name="matchVar">Match Variable</param>
        /// <param name="scoreVar">Score Variable</param>
        /// <param name="searchTerm">Search Term</param>
        public FullTextPattern(PatternItem matchVar, PatternItem scoreVar, PatternItem searchTerm)
        {
            this._matchVar   = matchVar;
            this._scoreVar   = scoreVar;
            this._searchTerm = searchTerm;

            NodeFactory factory = new NodeFactory();

            if (this._scoreVar != null)
            {
                BlankNodePattern a = new BlankNodePattern(factory.GetNextBlankNodeID());
                BlankNodePattern b = new BlankNodePattern(factory.GetNextBlankNodeID());
                this._origPatterns.Add(new TriplePattern(a, new NodeMatchPattern(factory.CreateUriNode(new Uri(FullTextHelper.FullTextMatchPredicateUri))), this._searchTerm));
                this._origPatterns.Add(new TriplePattern(a, new NodeMatchPattern(factory.CreateUriNode(new Uri(RdfSpecsHelper.RdfListFirst))), this._matchVar));
                this._origPatterns.Add(new TriplePattern(a, new NodeMatchPattern(factory.CreateUriNode(new Uri(RdfSpecsHelper.RdfListRest))), b));
                this._origPatterns.Add(new TriplePattern(b, new NodeMatchPattern(factory.CreateUriNode(new Uri(RdfSpecsHelper.RdfListFirst))), this._scoreVar));
                this._origPatterns.Add(new TriplePattern(b, new NodeMatchPattern(factory.CreateUriNode(new Uri(RdfSpecsHelper.RdfListRest))), new NodeMatchPattern(factory.CreateUriNode(new Uri(RdfSpecsHelper.RdfListNil)))));
            }
            else
            {
                this._origPatterns.Add(new TriplePattern(this._matchVar, new NodeMatchPattern(factory.CreateUriNode(new Uri(FullTextHelper.FullTextMatchPredicateUri))), this._searchTerm));
            }
        }
コード例 #2
0
 /// <summary>
 /// Helper method which converts a SemWeb resource into a PatternItem for use in a SPARQL Triple Pattern
 /// </summary>
 /// <param name="r">Resource</param>
 /// <param name="mapping">Mapping of Variables &amp; Blank Nodes to Pattern Items</param>
 /// <param name="g">Graph</param>
 /// <returns></returns>
 private PatternItem FromSemWeb(Resource r, IGraph g, Dictionary<String, PatternItem> mapping)
 {
     if (r is Variable)
     {
         if (mapping.ContainsKey(r.ToString()))
         {
             return mapping[r.ToString()];
         }
         else
         {
             PatternItem temp = new VariablePattern(r.ToString());
             mapping.Add(r.ToString(), temp);
             return temp;
         }
     }
     else if (r is BNode)
     {
         if (mapping.ContainsKey(r.ToString()))
         {
             return mapping[r.ToString()];
         }
         else
         {
             PatternItem temp = new BlankNodePattern(r.ToString().Substring(2));
             mapping.Add(r.ToString(), temp);
             return temp;
         }
     }
     else
     {
         return new NodeMatchPattern(SemWebConverter.FromSemWeb(r, this.GetMapping(g)));
     }
 }
コード例 #3
0
ファイル: FullTextPattern.cs プロジェクト: jbunzel/MvcRQ_git
        /// <summary>
        /// Creates a new Full Text Pattern
        /// </summary>
        /// <param name="matchVar">Match Variable</param>
        /// <param name="scoreVar">Score Variable</param>
        /// <param name="searchTerm">Search Term</param>
        public FullTextPattern(PatternItem matchVar, PatternItem scoreVar, PatternItem searchTerm)
        {
            this._matchVar = matchVar;
            this._scoreVar = scoreVar;
            this._searchTerm = searchTerm;

            NodeFactory factory = new NodeFactory();
            if (this._scoreVar != null)
            {
                BlankNodePattern a = new BlankNodePattern(factory.GetNextBlankNodeID());
                BlankNodePattern b = new BlankNodePattern(factory.GetNextBlankNodeID());
                this._origPatterns.Add(new TriplePattern(a, new NodeMatchPattern(factory.CreateUriNode(new Uri(FullTextHelper.FullTextMatchPredicateUri))), this._searchTerm));
                this._origPatterns.Add(new TriplePattern(a, new NodeMatchPattern(factory.CreateUriNode(new Uri(RdfSpecsHelper.RdfListFirst))), this._matchVar));
                this._origPatterns.Add(new TriplePattern(a, new NodeMatchPattern(factory.CreateUriNode(new Uri(RdfSpecsHelper.RdfListRest))), b));
                this._origPatterns.Add(new TriplePattern(b, new NodeMatchPattern(factory.CreateUriNode(new Uri(RdfSpecsHelper.RdfListFirst))), this._scoreVar));
                this._origPatterns.Add(new TriplePattern(b, new NodeMatchPattern(factory.CreateUriNode(new Uri(RdfSpecsHelper.RdfListRest))), new NodeMatchPattern(factory.CreateUriNode(new Uri(RdfSpecsHelper.RdfListNil)))));
            }
            else
            {
                this._origPatterns.Add(new TriplePattern(this._matchVar, new NodeMatchPattern(factory.CreateUriNode(new Uri(FullTextHelper.FullTextMatchPredicateUri))), this._searchTerm));
            }
        }