private EntityInfo entityInfo(FreebaseEntry entity)
        {
            var db = _linker.GetDb();

            var entityInfo = db.GetEntityInfoFromMid(FreebaseDbProvider.GetMid(entity.Id));

            return(entityInfo);
        }
예제 #2
0
        public static string EntryLink(FreebaseEntry entry)
        {
            if (entry == null)
            {
                return("NOT FOUND");
            }

            return(string.Format("<a href='/database?query={0}'>{1} ({0})</a>", entry.Id, entry.Label));
        }
예제 #3
0
        internal QuestionReport(QuestionInfo info, string answerId, LinkBasedExtractor extractor)
        {
            var linker = extractor.Linker;

            Question = linker.LinkUtterance(info.Utterance.OriginalSentence);

            AnswerLabel = extractor.Db.GetEntryFromId(answerId);
            var denotations = new List <Tuple <LinkedUtterance, EntityInfo, bool> >();

            foreach (var answerHint in info.AnswerHints)
            {
                var linkedHint = linker.LinkUtterance(answerHint.OriginalSentence, Question.Entities);
                var denotation = extractor.ExtractAnswerEntity(info.Utterance.OriginalSentence, answerHint.OriginalSentence).FirstOrDefault();

                var item = Tuple.Create(linkedHint, denotation, answerId == FreebaseDbProvider.GetId(denotation.Mid));
                denotations.Add(item);
            }

            CollectedDenotations = denotations;

            var denotationCounts = from denotation in denotations
                                   group denotation by FreebaseDbProvider.GetId(denotation.Item2.Mid)
                                   into grouped
                                   select Tuple.Create(grouped.Key, grouped.Count());

            var maxDenotation = denotationCounts.OrderByDescending(t => t.Item2).FirstOrDefault();

            if (maxDenotation != null && AnswerLabel != null)
            {
                HasCorrectDenotation = maxDenotation.Item1 == AnswerLabel.Id;
            }

            if (maxDenotation != null)
            {
                TopDenotationEvidence = maxDenotation.Item2;
            }
        }
 private bool isGoodSample(FreebaseEntry entry)
 {
     return(entry != null && entry.Label != null && getWords(entry.Label).Length < 4);
 }