Esempio n. 1
0
        // Find an opinion word target 90%
        protected string GetOpinionWordTarget(string OpinionWord, int index, string sentence)
        {
            FillConjunctions();
            FillAdverbs();
            FillComparatives();
            FillDecreasers();
            FillFutureWords();
            FillIncreasers();
            FillVerbs();
            FillPronouns();
            FillNegations();
            OpinionWord = WordsInSentence[index];
            if (OpinionWord != null)
            {
                if (sentence.Contains(OpinionWord))
                {
                    int myvalue = WordsInSentence.GetUpperBound(0);
                    if (myvalue >= index + 1)
                    {
                        Target = WordsInSentence[index + 1];
                        Target = Target.ToLower();
                        if ((!OpinionLexicon.Contains(Target)) && (!Conjunctions.Contains(Target)) &&
                            (!Comparatives.Contains(Target)) &&
                            (!FutureWords.Contains(Target)) &&
                            (!Adverbs.Contains(Target)) &&
                            (!Increasers.Contains(Target)) &&
                            (!Decreasers.Contains(Target)) &&
                            (!Verbs.Contains(Target)) &&
                            (!Pronouns.Contains(Target)) &&
                            (!Negations.Contains(Target)))
                        {
                            return(Target);
                        }
                        {
                            if (Conjunctions.Contains(WordsInSentence[index + 1]))
                            {
                                Target = WordsInSentence[index + 2];
                                if ((!OpinionLexicon.Contains(Target)) && (!Conjunctions.Contains(Target)) &&
                                    (!Comparatives.Contains(Target)) &&
                                    (!FutureWords.Contains(Target)) &&
                                    (!Adverbs.Contains(Target)) &&
                                    (!Increasers.Contains(Target)) &&
                                    (!Decreasers.Contains(Target)) &&
                                    (!Verbs.Contains(Target)) &&
                                    (!Pronouns.Contains(Target)) &&
                                    (!Negations.Contains(Target)))
                                {
                                    return(Target);
                                }
                            }
                        }
                    }
                    else
                    {
                        return(null);
                    }
                }
            }

            return(null);
        }
Esempio n. 2
0
        //Orientation=> if pos = true else false 80%
        protected bool GetOpinionWordOrientation(string word, int position, string sentence)
        {
            FillPositiveWords();
            FillNegativeWords();
            FillAdverbs();
            FillComparatives();
            FillConjunctions();
            FillDecreasers();
            FillFutureWords();
            FillIncreasers();
            FillVerbs();
            FillNegations();
            //{pos}
            if (PositiveWords.Contains(word))
            {
                WordOrientation = true;
            }

            if (NegativeWords.Contains(word))
            {
                WordOrientation = false;
            }

            if (position != 0)
            {
                //{pos} {pos}
                if (PositiveWords.Contains(WordsInSentence[position - 1]))
                {
                    WordOrientation = true;
                }

                //{neg} {pos}
                if (NegativeWords.Contains(WordsInSentence[position - 1]))
                {
                    WordOrientation = false;
                }

                if (position >= 2)
                {
                    //{fut} {verb} {pos}
                    if (FutureWords.Contains(WordsInSentence[position - 2]) &&
                        Verbs.Contains(WordsInSentence[position - 1]) &&
                        PositiveWords.Contains(WordsInSentence[position]))
                    {
                        WordOrientation = true;
                    }

                    //{pos} {neg}
                    if (PositiveWords.Contains(WordsInSentence[position - 1]) &&
                        NegativeWords.Contains(WordsInSentence[position]))
                    {
                        WordOrientation = false;
                    }

                    //{decr} {comp} {pos}
                    if (Decreasers.Contains(WordsInSentence[position - 2]) && Comparatives.Contains(
                            WordsInSentence[position - 1]) &&
                        PositiveWords.Contains(
                            WordsInSentence[position]))
                    {
                        WordOrientation = true;
                    }

                    if (position >= 3)
                    {
                        //{pos} {conj} {nego} {cpos}
                        if (PositiveWords.Contains(WordsInSentence[position - 3]) && Conjunctions.Contains(
                                WordsInSentence[position - 2]) &&
                            Negations.Contains(
                                WordsInSentence[position - 1]) &&
                            PositiveWords.Contains(
                                WordsInSentence[position]))
                        {
                            WordOrientation = true;
                        }

                        //{neg} {conj} {incr} {cneg}
                        if (NegativeWords.Contains(WordsInSentence[position - 3]) && Conjunctions.Contains(
                                WordsInSentence[position - 2]) &&
                            Increasers.Contains(
                                WordsInSentence[position - 1]) &&
                            NegativeWords.Contains(
                                WordsInSentence[position]))
                        {
                            WordOrientation = false;
                        }
                    }
                }
            }

            return(WordOrientation);
        }