Exemple #1
0
        private RelevantNodes GetRelevantNodes(string situationName)
        {
            var relevantNodes = new RelevantNodes();
            var situation     = _ontology.Nodes.Get(situationName).ToIsA();

            relevantNodes.Actions   = situation.SelectMany(x => x.ToIsANestedFromAction()).ToNodeCollection();
            relevantNodes.Objects   = situation.SelectMany(x => x.ToIsANestedFromObject()).ToNodeCollection();
            relevantNodes.Locatives = situation.SelectMany(x => x.ToIsANestedFromLocative()).ToNodeCollection();
            relevantNodes.Agents    = situation
                                      .SelectMany(x => x.ToIsANestedFromAgent())
                                      .Union(situation
                                             .SelectMany(x => x.ToIsANestedFromAgent())
                                             .SelectMany(x => x.ToIsANested()))
                                      .Distinct()
                                      .ToNodeCollection();

            return(relevantNodes);
        }
Exemple #2
0
        private static RelevantNodes GetRelevantNodes(RelevantNodes relevantNodes, Situation situation, string relation)
        {
            var node = GetNodeByRelation(relation, situation);

            if (relation == Relations.Agent)
            {
                node = GetParentAgent(node);
            }

            if (relation != Relations.Agent)
            {
                var relevantAgents = GetRelevant(node, relation, Relations.Agent).ToList();
                relevantNodes.Agents = relevantNodes.Agents
                                       .Intersect(relevantAgents
                                                  .Union(relevantAgents.SelectMany(x => x.ToIsANested()))
                                                  .Distinct()
                                                  );
            }

            if (relation != Relations.Action)
            {
                relevantNodes.Actions = relevantNodes.Actions
                                        .Intersect(GetRelevant(node, relation, Relations.Action));
            }

            if (relation != Relations.Object)
            {
                relevantNodes.Objects = relevantNodes.Objects
                                        .Intersect(GetRelevant(node, relation, Relations.Object));
            }

            if (relation != Relations.Locative)
            {
                relevantNodes.Locatives = relevantNodes.Locatives
                                          .Intersect(GetRelevant(node, relation, Relations.Locative));
            }

            return(relevantNodes);
        }