Esempio n. 1
0
        public InferenceResult ask(Sentence query)
        {
            // Want to standardize apart the query to ensure
            // it does not clash with any of the sentences
            // in the database
            StandardizeApartResult saResult = _standardizeApart.standardizeApart(query, queryIndexical);

            // Need to map the result variables (as they are standardized apart)
            // to the original queries variables so that the caller can easily
            // understand and use the returned set of substitutions
            InferenceResult infResult = getInferenceProcedure().ask(this, saResult.getStandardized());

            foreach (Proof p in infResult.getProofs())
            {
                IMap <Variable, Term> im = p.getAnswerBindings();
                IMap <Variable, Term> em = CollectionFactory.CreateInsertionOrderedMap <Variable, Term>();
                foreach (Variable rev in saResult.getReverseSubstitution().GetKeys())
                {
                    em.Put((Variable)saResult.getReverseSubstitution().Get(rev), im.Get(rev));
                }
                p.replaceAnswerBindings(em);
            }

            return(infResult);
        }
Esempio n. 2
0
        public InferenceResult ask(Sentence aQuery)
        {
            // Want to standardize apart the query to ensure
            // it does not clash with any of the sentences
            // in the database
            StandardizeApartResult saResult = _standardizeApart.standardizeApart(
                aQuery, queryIndexical);

            // Need to map the result variables (as they are standardized apart)
            // to the original queries variables so that the caller can easily
            // understand and use the returned set of substitutions
            InferenceResult infResult = getInferenceProcedure().ask(this,
                                                                    saResult.getStandardized());
            List <Proof> proofs = infResult.getProofs();

            foreach (Proof p in proofs)
            {
                Dictionary <Variable, Term> im = p.getAnswerBindings();
                Dictionary <Variable, Term> em = new Dictionary <Variable, Term>();
                foreach (Variable rev in saResult.getReverseSubstitution().Keys)
                {
                    Term toInsert = im.ContainsKey(rev) ? im[rev] : null;
                    em.Add((Variable)saResult.getReverseSubstitution()[rev], toInsert);
                }
                p.replaceAnswerBindings(em);
            }
            return(infResult);
        }