//Extract new opinion words 70% public List <OpinionWord> ExtractOpinionWords() { FillPositiveWords(); FillNegativeWords(); Lexicon(); PositionOfReview = 0; lists.DoublePropagationList = new List <OpinionWord>(); foreach (var opinion in Opinions) { SentenceIndex = 0; SentencesInReview = SentencesSeparator(SentencesInReview, PositionOfReview); foreach (var sentence in SentencesInReview) { WordsInSentence = EachWordInSentence(WordsInSentence, SentencesInReview, SentenceIndex); var i = -1; foreach (var word in WordsInSentence) { i++; var tempWord = word.ToLower(); var opinionWord = new OpinionWord(tempWord, WordOrientation) { OpWord = tempWord, Orientation = WordOrientation }; var position = i; Target = GetOpinionWordTarget(tempWord, position, sentence); if (lists.OpinionTargetList.Contains(Target)) { tempWord = GetDoublePropagationOpinionWord(tempWord, position, sentence); if ((dictionary.PositiveWords.Contains(tempWord) || dictionary.NegativeWords.Contains(tempWord)) && tempWord != null) { WordOrientation = GetOpinionWordOrientation(tempWord, position, sentence); if (!lists.OpinionLexicon.Contains(tempWord)) { lists.DoublePropagationList.Add(new OpinionWord(opinionWord.OpWord, opinionWord.Orientation)); } } else { if (tempWord != null) { lists.DoublePropagationList.Add(new OpinionWord(tempWord, opinionWord.Orientation)); } } } } SentenceIndex++; } PositionOfReview++; } return(lists.DoublePropagationList); }
//Filter seed extraction process 100% public List <OpinionWord> ExtractFilteredSeedOpinionWords() { FillPositiveWords(); FillNegativeWords(); Lexicon(); PositionOfReview = 0; lists.FilteredSeed = new List <OpinionWord>(); foreach (var opinion in Opinions) { SentenceIndex = 0; SentencesInReview = SentencesSeparator(SentencesInReview, PositionOfReview); foreach (var sentence in SentencesInReview) { WordsInSentence = EachWordInSentence(WordsInSentence, SentencesInReview, SentenceIndex); var i = -1; foreach (var word in WordsInSentence) { i++; var tempWord = word.ToLower(); var opinionWord = new OpinionWord(tempWord, WordOrientation) { OpWord = tempWord, Orientation = WordOrientation }; if (dictionary.PositiveWords.Contains(tempWord) || dictionary.NegativeWords.Contains(tempWord)) { var position = i; WordOrientation = GetOpinionWordOrientation(tempWord, position, sentence); if (!lists.OpinionLexicon.Contains(tempWord)) { lists.FilteredSeed.Add(new OpinionWord(tempWord, WordOrientation) { OpWord = tempWord, Orientation = WordOrientation }); } else { lists.FilteredSeed.Add(opinionWord); } //in documentation says that we have to add only oriantation..how to implement that? } } SentenceIndex++; Array.Clear(WordsInSentence, 0, WordsInSentence.Length); } PositionOfReview++; } return(lists.FilteredSeed); }
//double check the opinion word orientations 80% protected bool GetDoublePropagationOpWordOrientation(string OpionionTarget, int index, string sentence) { var tempOpinionWord = new OpinionWord(OpinionWord, WordOrientation); if (sentence.Contains(OpinionWord)) { WordOrientation = GetOpinionWordOrientation(OpinionWord, index, sentence); } else { SentenceIndex++; SentencesSeparator(SentencesInReview, SentenceIndex); sentence = SentencesInReview[SentenceIndex]; if (sentence.Contains(OpinionWord)) { WordOrientation = GetOpinionWordOrientation(OpinionWord, index, sentence); } } return(WordOrientation); }
//Conjunction based extraction process 90% public List <OpinionWord> ExtractConjunctionBasedOpinionWords() { FillPositiveWords(); FillNegativeWords(); PositionOfReview = 0; SentenceIndex = 0; lists.ConjunctionList = new List <OpinionWord>(); foreach (var Opinion in Opinions) { SentenceIndex = 0; SentencesInReview = SentencesSeparator(SentencesInReview, PositionOfReview); foreach (var sentence in SentencesInReview) { WordsInSentence = EachWordInSentence(WordsInSentence, SentencesInReview, SentenceIndex); var i = -1; foreach (var word in WordsInSentence) { i++; var tempWord = word.ToLower(); var position = i; var opinionWord = new OpinionWord(tempWord, WordOrientation) { OpWord = tempWord, Orientation = WordOrientation }; //check if the opinion word is included in filteredSeed list var matches = lists.FilteredSeed.Find(Didaxto => opinionWord.OpWord == tempWord); // var matches = FilteredSeed.Where(OpinionWord => OpinionWord.OpWord == tempWord); if (lists.FilteredSeed.Contains(matches)) //matches.OfType<OpinionWord>().Equals(opinionWord) { if (position + 1 < WordsInSentence.Length) { if (dictionary.Conjunctions.Contains(WordsInSentence[position + 1])) { tempWord = GetConjunctionBaseOpinionWord(tempWord, position, sentence); { if (dictionary.PositiveWords.Contains(tempWord) || dictionary.NegativeWords.Contains(tempWord)) { WordOrientation = GetOpinionWordOrientation(tempWord, position, sentence); if (!lists.OpinionLexicon.Contains(tempWord)) { lists.ConjunctionList.Add(new OpinionWord(tempWord, WordOrientation) { OpWord = tempWord, Orientation = WordOrientation }); } else { lists.ConjunctionList.Add(new OpinionWord(tempWord, opinionWord.Orientation)); } } } } } } } } SentenceIndex++; Array.Clear(WordsInSentence, 0, WordsInSentence.Length); } PositionOfReview++; return(lists.ConjunctionList); }