Module: JLPT::Comparer
- Defined in:
- lib/jlpt/analyzers/comparer.rb
Overview
Text Similarity and Lesson Vocabulary Comparer.
Compares two Japanese texts for vocabulary overlap (Jaccard similarity), shared kanji characters, and relative JLPT difficulty differences.
Class Method Summary collapse
-
.compare(text_a, text_b) ⇒ Hash
Compare two Japanese texts.
Class Method Details
.compare(text_a, text_b) ⇒ Hash
Compare two Japanese texts
16 17 18 19 20 21 22 |
# File 'lib/jlpt/analyzers/comparer.rb', line 16 def compare(text_a, text_b) lem_a = Tokenizer.lemmata(text_a).to_set lem_b = Tokenizer.lemmata(text_b).to_set return empty_comparison if lem_a.empty? || lem_b.empty? compute_metrics(lem_a, lem_b, text_a, text_b) end |