Class: NLP::Analyzer

Inherits:
Object
  • Object
show all
Defined in:
lib/analizators/analyzer.rb

Direct Known Subclasses

LIWCAnalyzer, RIDAnalyzer

Instance Method Summary collapse

Constructor Details

#initialize(dict) ⇒ Analyzer

Returns a new instance of Analyzer.



5
6
7
# File 'lib/analizators/analyzer.rb', line 5

def initialize(dict)
  @dictionary = Dictionary.new(dict)
end

Instance Method Details

#analyze(scanner) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/analizators/analyzer.rb', line 10

def analyze(scanner)

  results = TextStatistics.new

  while token = scanner.current
    word = token.lemat

    categories = @dictionary.find(word) 
    results.add(word,categories) unless categories.nil?
    results.total_words += 1
    scanner.next(:word)
  end

  results

end