class Corpus
Public Class Methods
new(glob, klass)
click to toggle source
# File lib/ruby_nlp/corpus.rb, line 4 def initialize(glob, klass) @glob = glob @klass = klass end
Public Instance Methods
bigrams()
click to toggle source
# File lib/ruby_nlp/corpus.rb, line 31 def bigrams ngrams(2) end
files()
click to toggle source
# File lib/ruby_nlp/corpus.rb, line 9 def files @files ||= Dir[@glob].map do |file| @klass.new(file) end end
ngrams(n)
click to toggle source
# File lib/ruby_nlp/corpus.rb, line 21 def ngrams(n) sentences.map do |sentence| Ngram.new(sentence).ngrams(n) end.flatten(1) end
sentences()
click to toggle source
# File lib/ruby_nlp/corpus.rb, line 15 def sentences files.map do |file| file.sentences end.flatten end
trigrams()
click to toggle source
# File lib/ruby_nlp/corpus.rb, line 35 def trigrams ngrams(3) end
unigrams()
click to toggle source
# File lib/ruby_nlp/corpus.rb, line 27 def unigrams ngrams(1) end