private bool TermsCoOccur(Sentence sentence, string w, string g) { if (TermInSentence(sentence, w) && TermInSentence(sentence, g)) return true; else return false; }
private bool TermInSentence(Sentence sentence, string term) { bool found = false; //if term appears in this sentence, count the terms (words + 2 and 3 word terms) if (term.IndexOf(" ") > -1) { string[] termWords = term.Split(' '); for (int i = 0; i < sentence.Words.Count; i++) { var t = sentence.Words[i]; if (termWords.Length == 2 && i > 2) { var t1 = sentence.Words[i - 1]; if (termWords[0] == t1.Stem && termWords[1] == t.Stem) { found = true; break; } } else if (termWords.Length == 3 && i > 3) { var t1 = sentence.Words[i - 1]; var t2 = sentence.Words[i - 2]; if (termWords[0] == t2.Stem && termWords[1] == t1.Stem && termWords[2] == t.Stem) { found = true; break; } } } } else { for (int i = 0; i < sentence.Words.Count; i++) { var t = sentence.Words[i]; if (t.Stem == term) { found = true; break; } } } return found; }