Exemplo n.º 1
0
 public WordOccurenceFactory(ILogger <WordOccurenceFactory> log, IContextWordsHandler wordsHandlers, IRawTextExtractor extractor, IInquirerManager inquirerManager)
 {
     this.wordsHandlers   = wordsHandlers ?? throw new ArgumentNullException(nameof(wordsHandlers));
     this.extractor       = extractor ?? throw new ArgumentNullException(nameof(extractor));
     this.inquirerManager = inquirerManager ?? throw new ArgumentNullException(nameof(inquirerManager));
     this.log             = log ?? throw new ArgumentNullException(nameof(log));
 }
Exemplo n.º 2
0
 public StyleFactory(IPOSTagger tagger, INRCDictionary nrcDictionary, IFrequencyListManager frequency, IInquirerManager inquirer)
 {
     this.nrcDictionary = nrcDictionary ?? throw new ArgumentNullException(nameof(nrcDictionary));
     this.frequency     = frequency ?? throw new ArgumentNullException(nameof(frequency));
     this.inquirer      = inquirer ?? throw new ArgumentNullException(nameof(inquirer));
     this.tagger        = tagger ?? throw new ArgumentNullException(nameof(tagger));
 }
Exemplo n.º 3
0
 public InquirerFingerPrint(TextBlock text, IInquirerManager inquirer)
 {
     Text          = text ?? throw new ArgumentNullException(nameof(text));
     this.inquirer = inquirer ?? throw new ArgumentNullException(nameof(inquirer));
 }
Exemplo n.º 4
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);
        }