Exemplo n.º 1
0
        private void AddWord(IWordItem occurrence, bool last)
        {
            if (occurrence is null)
            {
                throw new ArgumentNullException(nameof(occurrence));
            }

            if (!occurrence.IsSimple)
            {
                throw new ArgumentOutOfRangeException(nameof(occurrence));
            }

            if (!last &&
                CanSplit &&
                occurrence.IsConjunction())
            {
                review.CurrentSentence.CreateNewPart();
            }

            review.CurrentSentence.CurrentPart.AddItem(occurrence);
        }
        public static bool CanNotBeAttribute(this IWordItem word)
        {
            if (word.IsEmoticon())
            {
                return(false);
            }

            return
                (word.IsFixed ||
                 word.IsQuestion ||
                 word.IsInvertor ||
                 word.IsStopWord ||
                 word.QuantValue.HasValue ||
                 word.IsItemBelonging() ||
                 !word.Text.HasLetters() ||
                 word.Text.Length < 2 || // feature is at least 3 letters
                 word.Entity != NamedEntities.None ||
                 word.POS.WordType == WordType.Symbol ||
                 word.IsConjunction() ||
                 IsNoise(word));
        }
        public static bool CanNotBeFeature(this IWordItem word)
        {
            if (word.Entity == NamedEntities.Location ||
                word.Entity == NamedEntities.Organization ||
                word.Entity == NamedEntities.Person ||
                word.Entity == NamedEntities.Hashtag)
            {
                return(false);
            }

            // it was successfully trimmed
            return(word.IsVerbLook() ||
                   word.IsConjunction() ||
                   !word.Text.HasLetters() ||

                   // named entities can't be features
                   // named entities except organizations
                   word.POS.WordType == WordType.Symbol ||
                   word.POS.WordType == WordType.Number ||
                   word.IsStopWord ||
                   word.IsInvertor ||
                   word.QuantValue.HasValue ||
                   word.IsQuestion ||
                   word.Entity == NamedEntities.Number ||
                   word.Entity == NamedEntities.Percent ||
                   word.Entity == NamedEntities.Money ||
                   word.Entity == NamedEntities.Date ||
                   word.Entity == NamedEntities.Duration ||
                   word.Entity == NamedEntities.Ordinal ||
                   word.Entity == NamedEntities.Time ||
                   word.Text.Length < 2 ||        // feature is at least 3 letters
                   word.IsItemBelonging() ||
                   word.Text.IsEnding("thing") || // things are too generic to be features
                   word.IsEmoticon() ||
                   word.POS.Tag == "IN" ||
                   word.IsNoise());
        }