class NHKore::BasicPolisher

@author Jonathan Bradley Whited @since 0.2.0

Public Instance Methods

end_polish(str) click to toggle source
# File lib/nhkore/polisher.rb, line 60
def end_polish(str)
  # Keep Japanese dots in names:
  # - Yunibaasaru・Sutajio・Japan
  # Keep numbers next to kanji/kana, else the below kana won't make sense:
  # - Word { kanji: 20日, kana: はつか }

  str = str.gsub(/[^[[:alnum:]]・]/,'')

  # Numbers/dots by themselves (without kanji/kana) should be ignored (empty).
  str = '' if str.gsub(/[[[:digit:]]・]+/,'').empty?

  return str
end