Exemplo n.º 1
0
        /// <summary>
        /// Executes a SPARQL Query against the underlying Knowledge Base
        /// </summary>
        /// <param name="sparqlQuery">SPARQL Query</param>
        /// <returns></returns>
        public object ExecuteQuery(string sparqlQuery)
        {
            Type svcType = typeof(QueryService);

            if (_kb.SupportsService(svcType))
            {
                QueryService svc = (QueryService)_kb.GetService(svcType);
                return(svc.Query(sparqlQuery));
            }
            else
            {
                throw new NotSupportedException("The Knowledge Base does not support the SPARQL Query service");
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates a new Pellet Query Processor
        /// </summary>
        /// <param name="server">Pellet Server</param>
        /// <param name="kbName">Knowledge Base Name</param>
        public PelletQueryProcessor(PelletServer server, String kbName)
        {
            if (server.HasKnowledgeBase(kbName))
            {
                KnowledgeBase kb = server.GetKnowledgeBase(kbName);

                //Check SPARQL Query is supported
                if (kb.SupportsService(this._svcType))
                {
                    this._svc = (QueryService)kb.GetService(this._svcType);
                }
                else
                {
                    throw new NotSupportedException("Cannot create a Pellet Query Processor as the selected Knowledge Base does not support the Query Service");
                }
            }
            else
            {
                throw new NotSupportedException("Cannot create a Pellet Query Processor for the Knowledge Base named '" + kbName + "' as this Server does not have the named Knowledge Base");
            }
        }