class BrownCorpusFile

Public Class Methods

new(path) click to toggle source
# File lib/ruby_nlp/corpus_files/brown.rb, line 2
def initialize(path)
  @path = path
end

Public Instance Methods

sentences() click to toggle source
# File lib/ruby_nlp/corpus_files/brown.rb, line 6
def sentences
  @sentences ||= File.open(@path) do |file|
    file.each_line.each_with_object([]) do |line, acc|
      stripped_line = line.strip

      unless stripped_line.nil? || stripped_line.empty?
        acc << line.split(' ').map do |word|
          word.split('/').first
        end.join(' ')
      end
    end
  end
end