public static bool IsKnown(this IContextWordsHandler instance, IWordItem word) { return(instance.IsQuestion(word) || instance.IsFeature(word) || instance.IsInvertAdverb(word) || instance.IsSentiment(word) || instance.MeasureQuantifier(word) > 0); }
public IParsedReview Create() { if (review != null) { return(review); } review = new ParsedReview(nrcDictionary, document, manager.Context); foreach (var sentence in document.Sentences) { CreateSentence(sentence); IPhrase phrase = null; string phraseWord = null; for (var i = 0; i < sentence.Words.Count; i++) { var documentWord = sentence.Words[i]; if (documentWord.Phrase != null) { if (phraseWord != documentWord.Phrase) { phraseWord = documentWord.Phrase; phrase = documentWord.UnderlyingWord as IPhrase ?? wordsFactory.CreatePhrase(phraseWord); } } else { phrase = null; phraseWord = null; } // !! we need to create new - because if we use underlying // we can lose if words is changed to aspect IWordItem word = wordsFactory.CreateWord(documentWord.Text, documentWord.POS); word.NormalizedEntity = documentWord.NormalizedEntity; word.Entity = documentWord.EntityType; word.CustomEntity = documentWord.CustomEntity; word.WordIndex = i; AddWord(word, i == sentence.Words.Count - 1); phrase?.Add(word); } } foreach (var sentence in review.Sentences) { foreach (var phrase in sentence.Occurrences.GetPhrases().Where(item => item.AllWords.Count() > 1)) { phrase.IsSentiment = manager.IsSentiment(phrase); phrase.IsFeature = manager.IsFeature(phrase); phrase.IsTopAttribute = manager.IsAttribute(phrase); } } return(review); }