8 class LanguageJa
extends Language
{
9 function wordSegmentation( $string ) {
10 // Strip known punctuation ?
11 // $s = preg_replace( '/\xe3\x80[\x80-\xbf]/', '', $s ); # U3000-303f
13 // Space strings of like hiragana/katakana/kanji
14 $hiragana = '(?:\xe3(?:\x81[\x80-\xbf]|\x82[\x80-\x9f]))'; # U3040-309f
15 $katakana = '(?:\xe3(?:\x82[\xa0-\xbf]|\x83[\x80-\xbf]))'; # U30a0-30ff
16 $kanji = '(?:\xe3[\x88-\xbf][\x80-\xbf]'
17 . '|[\xe4-\xe8][\x80-\xbf]{2}'
18 . '|\xe9[\x80-\xa5][\x80-\xbf]'
19 . '|\xe9\xa6[\x80-\x99])';
20 # U3200-9999 = \xe3\x88\x80-\xe9\xa6\x99
21 $reg = "/({$hiragana}+|{$katakana}+|{$kanji}+)/";
22 $s = self
::insertSpace( $string, $reg );
26 function normalizeForSearch( $string ) {
27 // Double-width roman characters
28 $s = self
::convertDoubleWidth( $string );
30 # Do general case folding and UTF-8 armoring
31 return parent
::normalizeForSearch( $s );
34 # Italic is not appropriate for Japanese script
35 # Unfortunately most browsers do not recognise this, and render <em> as italic
36 function emphasize( $text ) {