Class: BrownCorpusFile
- Inherits:
-
Object
- Object
- BrownCorpusFile
- Defined in:
- lib/ruby_nlp/corpus_files/brown.rb
Instance Method Summary collapse
-
#initialize(path) ⇒ BrownCorpusFile
constructor
A new instance of BrownCorpusFile.
- #sentences ⇒ Object
Constructor Details
#initialize(path) ⇒ BrownCorpusFile
Returns a new instance of BrownCorpusFile.
2 3 4 |
# File 'lib/ruby_nlp/corpus_files/brown.rb', line 2 def initialize(path) @path = path end |
Instance Method Details
#sentences ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 |
# 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 |