| 1 |
# |
| 2 |
# Licensed to the Apache Software Foundation (ASF) under one or more |
| 3 |
# contributor license agreements. See the NOTICE file distributed with |
| 4 |
# this work for additional information regarding copyright ownership. |
| 5 |
# The ASF licenses this file to You under the Apache License, Version 2.0 |
| 6 |
# (the "License"); you may not use this file except in compliance with |
| 7 |
# the License. You may obtain a copy of the License at |
| 8 |
# |
| 9 |
# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 |
# |
| 11 |
# Unless required by applicable law or agreed to in writing, software |
| 12 |
# distributed under the License is distributed on an "AS IS" BASIS, |
| 13 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 |
# See the License for the specific language governing permissions and |
| 15 |
# limitations under the License. |
| 16 |
# |
| 17 |
# |
| 18 |
# Parses Myanmar text, with syllable as token. |
| 19 |
# |
| 20 |
|
| 21 |
$Consonant = [:Indic_Syllabic_Category = Consonant:]; |
| 22 |
$ConsonantPlaceholder = [:Indic_Syllabic_Category = Consonant_Placeholder:]; |
| 23 |
$VowelIndependent = [:Indic_Syllabic_Category = Vowel_Independent:]; |
| 24 |
$Virama = [:Indic_Syllabic_Category = Invisible_Stacker:]; |
| 25 |
$Asat = [:Indic_Syllabic_Category = Pure_Killer:]; |
| 26 |
# for our purposes, $Cons means 'base' |
| 27 |
$Cons = $Consonant | $ConsonantPlaceholder | $VowelIndependent; |
| 28 |
$WordJoin = [:Line_Break=Word_Joiner:]; |
| 29 |
|
| 30 |
# |
| 31 |
# default numerical definitions |
| 32 |
# |
| 33 |
$Extend = [\p{Word_Break = Extend}]; |
| 34 |
$Format = [\p{Word_Break = Format}]; |
| 35 |
$MidNumLet = [\p{Word_Break = MidNumLet}]; |
| 36 |
$MidNum = [\p{Word_Break = MidNum}]; |
| 37 |
$Numeric = [\p{Word_Break = Numeric}]; |
| 38 |
$ExtendNumLet = [\p{Word_Break = ExtendNumLet}]; |
| 39 |
$MidNumLetEx = $MidNumLet ($Extend | $Format)*; |
| 40 |
$MidNumEx = $MidNum ($Extend | $Format)*; |
| 41 |
$NumericEx = $Numeric ($Extend | $Format)*; |
| 42 |
$ExtendNumLetEx = $ExtendNumLet ($Extend | $Format)*; |
| 43 |
|
| 44 |
$ConsEx = $Cons ($Extend | $Format)*; |
| 45 |
$AsatEx = $Cons $Asat ($Virama $ConsEx)? ($Extend | $Format)*; |
| 46 |
$MyanmarSyllableEx = $ConsEx ($Virama $ConsEx)? ($AsatEx)*; |
| 47 |
$MyanmarJoinedSyllableEx = $MyanmarSyllableEx ($WordJoin $MyanmarSyllableEx)*; |
| 48 |
|
| 49 |
!!forward; |
| 50 |
$MyanmarJoinedSyllableEx {200}; |
| 51 |
|
| 52 |
# default numeric rules |
| 53 |
$NumericEx $ExtendNumLetEx? (($MidNumEx | $MidNumLetEx)? $NumericEx $ExtendNumLetEx?)* {100}; |