Exemple #1
0
        public List<questionAnswer> executeQueries(List<QueryBucket> queryBuckets)
        {
            List<questionAnswer> answers = new List<questionAnswer>();

            foreach (QueryBucket queryBucket in queryBuckets)
            {
                foreach (string queryString in queryBucket.BucketQueryList)
                {
                    SparqlResultSet resultSet = QueryHandler.ExecuteQueryWithString(queryString);
                    if (resultSet.Count > 0)
                    {
                        questionAnswer answer = new questionAnswer(queryBucket.QuestionType);
                        answer.answerCount = resultSet.Results.Count();

                        foreach (LexiconToken token in queryBucket.tokens.Distinct<LexiconToken>())
                        {
                            if (token is LexiconPredicate)
                            {
                                answer.predicateList.Add(token as LexiconPredicate);
                                answer.predicateUriList.Add(token.URI, token.QuestionMatch);
                                answer.predicateLabelList.Add(token.label, token.QuestionMatch);
                            }
                            else if (token is LexiconLiteral)
                            {
                                answer.subjectList.Add(token as LexiconLiteral);
                                answer.subjectUriList.Add(token.URI, token.QuestionMatch);
                                answer.subjectLabelList.Add(token.label, token.QuestionMatch);
                            }
                        }

                        foreach (SparqlResult result in resultSet)
                        {
                            INode subjectNode = result[0];
                            INode objectNode = result[1];
                            Type resultType = objectNode.GetType();

                            if (answer.questiontype == util.questionTypes.literalOrURIAnswer)
                            {
                                if (resultType.Name == "LiteralNode")
                                {
                                    answer.questiontype = util.questionTypes.literalAnswer;
                                }
                                else if (resultType.Name == "UriNode")
                                {
                                    answer.questiontype = util.questionTypes.URIAsnwer;
                                }
                            }
                            answer.objectNodetList.Add(objectNode);
                            answer.objectUriList.Add(objectNode.ToString());
                            answer.objectLabelList.Add(QueryHandler.getLabelIfAny(objectNode.ToString()));
                        }
                        answers.Add(answer);
                    }
                }
            }

            return answers;
        }
Exemple #2
0
        public PartialAnswer(questionAnswer answer)
        {
            this.questiontype = answer.questiontype;

            this.answerCount = answer.answerCount;

            this.objectUriList = answer.objectUriList;

            this.objectLabelList = answer.objectLabelList;
        }