public Form2(FilmKnowledgeBase kb)//string path) { InitializeComponent(); // pathToKB = path; knowledgeBase = kb;// new FilmKnowledgeBase(pathToKB); sentence = null; }
public static void ForwardChain(FilmKnowledgeBase kb, ISentence sentence) { foreach (var kbSentence in kb.Sentences) { if (IsRenaiming(kbSentence, sentence)) { return; } } kb.Sentences.Add(sentence); foreach (var kbSentence in kb.Sentences) { var innerSentence = DropOuterQuantifiers(kbSentence); if (innerSentence.GetSentenceType() == SentenceType.SentenceConnectiveSentence) { var sentenceConnectiveSentence = innerSentence as SentenceConnectiveSentence; if (sentenceConnectiveSentence.Connective == "->") { var anticedents = SentenceConnectiveSentence.GetAnticedents(sentenceConnectiveSentence); for (int i = 0; i < anticedents.Count; ++i) { var unificationResult = Unify(anticedents[i], sentence); if (unificationResult.Successful) { FindAndInfer(kb, anticedents.Take(i).Concat(anticedents.Skip(i + 1)).ToList(), //dropping unified sentence sentenceConnectiveSentence.Sentence2, unificationResult); } } } } } }
public static void FindAndInfer(FilmKnowledgeBase kb, List <ISentence> premises, ISentence conclusion, Substitution s) { if (premises.Count == 0) { ForwardChain(kb, conclusion.Substitute(s)); } foreach (var kbSentence in kb.Sentences) { var unifyResult = Unify(kbSentence, premises.First().Substitute(s)); if (unifyResult.Successful) { FindAndInfer(kb, premises.Skip(1).ToList(), conclusion, s.Compose(unifyResult)); } } }
public Form1(FilmKnowledgeBase kb)//string path) { InitializeComponent(); knowledgeBase = kb; //pathToKB = path; }
public Main() { InitializeComponent(); pathToKB = pathToKBTextBox.Text; knowledgeBase = new FilmKnowledgeBase(pathToKB); }
public FilmRecommendationsEngine(FilmKnowledgeBase knowledgeBase) { this.knowledgeBase = knowledgeBase; }
public FilmRecommendationsEngine(string pathToKnowledgeBase) { knowledgeBase = new FilmKnowledgeBase(pathToKnowledgeBase); }