Beispiel #1
0
        private static void linkOnAnswerHint(string utterance, GraphDisambiguatedLinker linker, QuestionDialogDatasetReader dataset)
        {
            var utteranceWords = utterance.ToLowerInvariant().Split(' ').Distinct();

            QuestionDialog dialogToLink = null;

            foreach (var dialog in dataset.Dialogs)
            {
                if (!dialog.HasCorrectAnswer)
                {
                    continue;
                }

                var questionWords = dialog.Question.ToLowerInvariant().Split(' ');
                if (utteranceWords.Except(questionWords).Count() == 0)
                {
                    dialogToLink = dialog;
                }

                foreach (var turn in dialog.AnswerTurns)
                {
                    var words = turn.InputChat.ToLowerInvariant().Split(' ').Distinct();
                    if (utteranceWords.Except(words).Count() == 0)
                    {
                        dialogToLink = dialog;
                        break;
                    }
                }

                if (dialogToLink != null)
                {
                    break;
                }
            }

            Console.WriteLine(dialogToLink.Question);

            var answerPhrase   = getAnswerPhrase(dialogToLink);
            var linkedQuestion = linker.LinkUtterance(dialogToLink.Question);

            Console.WriteLine(linkedQuestion);

            var contextEntities = linkedQuestion.Parts.SelectMany(p => p.Entities).ToArray();
            var result          = linker.LinkUtterance(answerPhrase, contextEntities);

            Console.WriteLine(result);
        }
Beispiel #2
0
        private static ILinker getFullDataLinker(FreebaseDbProvider db)
        {
            var coreLinker = new GraphDisambiguatedLinker(db, "./verbs.lex", useGraphDisambiguation: true);
            var linker     = new DiskCachedLinker("../full.link", 1, (u, c) => coreLinker.LinkUtterance(u, c), db);

            linker.CacheResult = false;
            return(linker);
        }
Beispiel #3
0
        private static ILinker getBlacklistedLinker()
        {
            var phrases = GraphNavigationExperiment.LoadPhrases(Configuration.GetQuestionDialogsTrain(), Configuration.Db);

            var coreLinker = new GraphDisambiguatedLinker(Configuration.Db, "./verbs.lex", useGraphDisambiguation: true);

            coreLinker.SetBlacklistLabels(phrases);

            var linker = new DiskCachedLinker("graph_navigation_blacklisted_linker.link", 1, (u, c) => coreLinker.LinkUtterance(u, c), coreLinker.Db);

            return(linker);
        }