Module: JLPT::BatchProcessor

Defined in:
lib/jlpt/formatters/batch_processor.rb

Overview

Batch Text, Subtitle, and Multi-Chapter Document Processor.

Processes multiple text sections or chapters, generating difficulty roadmaps and per-section metric summaries.

Class Method Summary collapse

Class Method Details

.process(sections) ⇒ Array<Hash>

Process a collection of text sections or chapters

Parameters:

  • sections (Hash, Array<Hash>, Array<String>)

    sections mapping or list

Returns:

  • (Array<Hash>)

    roadmap of processed section difficulty metrics



15
16
17
18
19
20
21
22
23
24
# File 'lib/jlpt/formatters/batch_processor.rb', line 15

def process(sections)
  return [] if sections.nil? || sections.empty?

  items = normalize_sections(sections)
  items.map do |name, text|
    res = JLPT.analyze(text)
    { name: name, recommended_level: res.recommended_level, score: res.score,
      word_count: res.word_count, sentence_count: res.sentence_count }
  end
end