Module: JLPT::StyleProfiler

Defined in:
lib/jlpt/analyzers/style_profiler.rb

Overview

Style and Speech Register Profiler.

Analyzes polite vs plain form usage, Keigo honorifics (Sonkeigo/Kenjougo), dialect markers, and internet slang in Japanese text.

Constant Summary collapse

POLITE_ENDINGS =
/(?:です|ます|でした|ました|ではありません|ではありませんでした|でしょう)\b/.freeze
KEIGO_SONKEIGO_PATTERNS =
/(?:お|ご)\p{L}+(?:になる|なさる|くださる)|いらっしゃる|おっしゃる|ご覧/.freeze
KEIGO_KENJOUGO_PATTERNS =
/(?:お|ご)\p{L}+(?:する|いたします)|申す|申し上げ|参る|参り|いただく|いただき|存じる|存じ/.freeze
SLANG_PATTERNS =
/(?:[wW]{2,}|笑|ww|やねん|やで|ほんま)/.freeze

Class Method Summary collapse

Class Method Details

.profile(text) ⇒ Hash

Analyze text style and return detailed profile hash

Parameters:

  • text (String)

    Japanese text

Returns:

  • (Hash)

    style profile with formality, keigo, and register metrics



20
21
22
23
24
25
# File 'lib/jlpt/analyzers/style_profiler.rb', line 20

def profile(text)
  cleaned = Preprocessor.clean(text)
  return empty_profile if cleaned.empty?

  build_style_profile(cleaned)
end