Exemplo n.º 1
0
 public void Load()
 {
     TotalCharacters = Sentences.Sum(item => item.CountCharacters());
     Sentiment.Load();
     Surface.Load();
     InquirerFinger.Load();
     SyntaxFeatures.Load();
     VocabularyObscurity.Load();
     Readability.Load();
 }
Exemplo n.º 2
0
        public TextBlock(IPOSTagger tagger, IInquirerManager inquirer, IFrequencyListManager frequency, SentenceItem[] sentences)
        {
            if (tagger is null)
            {
                throw new ArgumentNullException(nameof(tagger));
            }

            if (inquirer is null)
            {
                throw new ArgumentNullException(nameof(inquirer));
            }

            if (frequency is null)
            {
                throw new ArgumentNullException(nameof(frequency));
            }

            if (sentences is null)
            {
                throw new ArgumentNullException(nameof(sentences));
            }

            if (sentences is null)
            {
                throw new ArgumentNullException(nameof(sentences));
            }

            if (sentences.Length == 0)
            {
                throw new ArgumentException("Value cannot be an empty collection.", nameof(sentences));
            }

            Sentences   = sentences;
            Surface     = new SurfaceData(this);
            Readability = new ReadabilityDataSource(this);
            Words       = (from sentence in Sentences from word in sentence.Words select word).ToArray();
            if (Words.Length == 0)
            {
                throw new ArgumentException("Value cannot be an empty collection.", nameof(Words));
            }

            var pure = new List <WordEx>();

            foreach (var word in Words)
            {
                if (word.Text.HasLetters() ||
                    word.Text.Length > 0 && char.IsDigit(word.Text[0]))
                {
                    pure.Add(word);
                }

                if (!string.IsNullOrEmpty(word.Raw))
                {
                    lemmaDictionary.GetSafeCreate(word.Raw).Add(word);
                }

                wordDictionary.GetSafeCreate(word.Text).Add(word);
            }

            PureWords           = pure.ToArray();
            VocabularyObscurity = new VocabularyObscurity(this, frequency);
            SyntaxFeatures      = new SyntaxFeatures(this, tagger);
            InquirerFinger      = new InquirerFingerPrint(this, inquirer);
            Sentiment           = new SentimentFeatures(this);
        }