Class: NHKore::BasicPolisher

Inherits:
Polisher show all
Defined in:
lib/nhkore/polisher.rb

Overview

Author:

  • Jonathan Bradley Whited

Since:

  • 0.2.0

Direct Known Subclasses

BestPolisher

Instance Method Summary collapse

Methods inherited from Polisher

#begin_polish, #polish, polish_any

Instance Method Details

#end_polish(str) ⇒ Object

Since:

  • 0.2.0



60
61
62
63
64
65
66
67
68
69
70
71
72
# 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