示例#1
0
        /// <summary>Examines the supplied ConciseBoundedDescription and attempts to locate more information about the described resource.</summary>
        /// <param name="resourceDescription">A ConciseBoundedDescription about which more information is required.</param>
        /// <param name="investigator">An investigator that encapsulates the algorithm to be used to locate more information.</param>
        public virtual void Investigate(ConciseBoundedDescription resourceDescription, Investigator investigator)
        {
            SemPlan.Spiral.Core.ResourceFactory resourceFactory = itsTripleStoreFactory.MakeResourceFactory();

            investigator.NewStatement += itsAssertions.GetStatementHandler();
            investigator.investigate(resourceDescription, this, itsParserFactory, resourceFactory, itsStatementFactory, itsDereferencer);
            investigator.NewStatement -= itsAssertions.GetStatementHandler();
        }
示例#2
0
        private ResourceDescription GetDescriptionOf(Resource theResource, TripleStore store, Hashtable processedResources)
        {
            ConciseBoundedDescription cbd = new ConciseBoundedDescription(theResource);

            IList denotingNodes = store.GetNodesDenoting(theResource);

            processedResources[theResource] = denotingNodes;

            foreach (GraphMember member in  denotingNodes)
            {
                cbd.AddDenotation(member, theResource);
            }

            Query query = new Query();

            query.AddPattern(new Pattern(store.GetBestDenotingNode(theResource), new Variable("pred"), new Variable("obj")));

            IEnumerator solutions = store.Solve(query);

            while (solutions.MoveNext())
            {
                QuerySolution solution = (QuerySolution)solutions.Current;

                foreach (GraphMember member in store.GetNodesDenoting(solution["pred"]))
                {
                    cbd.AddDenotation(member, solution["pred"]);
                }

                foreach (GraphMember member in store.GetNodesDenoting(solution["obj"]))
                {
                    cbd.AddDenotation(member, solution["obj"]);
                }

                cbd.Add(new ResourceStatement(theResource, solution["pred"], solution["obj"]));

                if (store.GetBestDenotingNode(solution["obj"]) is BlankNode)
                {
                    if (!processedResources.ContainsKey(solution["obj"]))
                    {
                        cbd.Add((ConciseBoundedDescription)GetDescriptionOf(solution["obj"], store, processedResources));
                    }
                }
            }

            return(cbd);
        }
示例#3
0
 public virtual Resource GetResourceDescribedBy(ConciseBoundedDescription externalDescription)
 {
     if (TripleStore.HasNodeDenoting(externalDescription.Resource))
     {
         return(externalDescription.Resource);
     }
     else
     {
         foreach (Node node in externalDescription.DenotingNodes)
         {
             if (TripleStore.HasResourceDenotedBy(node))
             {
                 return(TripleStore.GetResourceDenotedBy(node));
             }
         }
         return(externalDescription.Resource);
     }
 }
示例#4
0
        public virtual void Replace(ConciseBoundedDescription description)
        {
            Resource  internalSubjectResource = GetResourceDescribedBy(description);
            ArrayList statementsToRemove      = new ArrayList();

            IEnumerator statementEnumerator = itsAssertions.GetStatementEnumerator();

            while (statementEnumerator.MoveNext())
            {
                ResourceStatement statement = (ResourceStatement)statementEnumerator.Current;
                if (statement.GetSubject().Equals(internalSubjectResource))
                {
                    statementsToRemove.Add(statement);
                }
            }

            foreach (ResourceStatement statement in statementsToRemove)
            {
                itsAssertions.Remove(statement);
            }

            Add(description);
        }
 public void Add(ConciseBoundedDescription description)
 {
     itsStore.Add(description.itsStore);
 }