private static LinkedUtterance[] cachedLinkedUtterancesTrain(SimpleQuestionDumpProcessor simpleQuestions, FreebaseDbProvider db, QuestionDialog[] trainDialogs) { var linkedUtterances = ComputationCache.Load("linked_all_train", 1, () => { var linker = new GraphDisambiguatedLinker(db, "./verbs.lex"); var linkedUtterancesList = new List <LinkedUtterance>(); foreach (var dialog in trainDialogs) { var linkedUtterance = linker.LinkUtterance(dialog.Question, 1).First(); linkedUtterancesList.Add(linkedUtterance); } return(linkedUtterancesList); }).ToArray(); return(linkedUtterances); }
private static ComposedGraph cachedEntityGraph(SimpleQuestionDumpProcessor simpleQuestions, QuestionDialog[] trainDialogs, LinkedUtterance[] linkedUtterances) { return(ComputationCache.Load("knowledge_all_train", 1, () => { var trainEntities = getQAEntities(trainDialogs, linkedUtterances); //var layer = simpleQuestions.GetLayerFromIds(trainEntities); foreach (var entityId in trainEntities) { simpleQuestions.AddTargetMid(FreebaseDbProvider.GetMid(entityId)); } simpleQuestions.RunIteration(); var layer = simpleQuestions.GetLayerFromIds(simpleQuestions.AllIds); var graph = new ComposedGraph(layer); return graph; })); }