All Projects → vincent-paing → myanmar-phonenumber-kt

vincent-paing / myanmar-phonenumber-kt

Licence: Apache-2.0 license
Port of myanmar-phonenumber(https://github.com/kaungmyatlwin/myanmar-phonenumber) written in Kotlin to check valid myanmar mobile numbers, get mobile operator's name, sanitize mobile numbers and get mobile network types.

Programming Languages

kotlin
9241 projects

Projects that are alternatives of or similar to myanmar-phonenumber-kt

Myanmar-Unicode-Fonts
Myanmar Unicode Fonts
Stars: ✭ 88 (+282.61%)
Mutual labels:  myanmar
TALPCo
TUFS Asian Language Parallel Corpus
Stars: ✭ 32 (+39.13%)
Mutual labels:  myanmar
sylbreak
Syllable segmentation tool for Myanmar language (Burmese) by Ye.
Stars: ✭ 44 (+91.3%)
Mutual labels:  myanmar
SulfurKeyboard
Android Gingerbread Keyboard with Myanmar(Zawgyi-one) Language
Stars: ✭ 18 (-21.74%)
Mutual labels:  myanmar
kuu-pyaung
Laravel package to convert files and database from zawgyi to unicode.
Stars: ✭ 13 (-43.48%)
Mutual labels:  myanmar
myG2P
Myanmar (Burmese) Language Grapheme to Phoneme (myG2P) Conversion Dictionary for speech recognition (ASR) and speech synthesis (TTS).
Stars: ✭ 43 (+86.96%)
Mutual labels:  myanmar

Download Build Status

Kotlin port of myanmar-phonenumber to check valid myanmar mobile numbers, get mobile operator's name, sanitize mobile numbers and get mobile network types.

Features

Phone Number Normalization

An extensible normalizier allows you to normalize the phone number into a standardized format you want. The default out of the box provides

  • Trimming whit spaces, dashes, and decimals
  • Converting to English numbers
  • Replacing and standardizing to 09
val input = "+၉၅၉၇၈၄၁၂၃၄၅၆"
val normalizer = MyanmarPhoneNumberNormalizer()
val result = normalizer.normalize(input)
print(result) //: 09784123456
Custom Rules

You can also use the builder provided to add custom rules. This allows you to create your own standardized format such as using "+959" instead of "09", or converting other languages to English numerals etc.

class NineFiveNineRule : Rule {
  private val possibleCases = Regex("(09-)|(\\+959)|(09\\s)|(959)|(09\\.)")
  
  override fun convert(input: String): String {
    if (possibleCases.containsMatchIn(input)) {
      return input.replaceFirst(possibleCases, "+959")
    }
    return input
  }
  
}

val builder = MyanmarPhoneNumberNormalizer.Builder()
builder.addRule(NineFiveNineRule())

val input = "09784123456"

val output = builder.build().normalize(input)

print(output) //+959784123456

Phone number Validaiton

Check whether a phone number is a valid Myanmar phone number

MyanmarPhoneNumberUtils.isValidMyanmarPhoneNumber("09978412345") //true
MyanmarPhoneNumberUtils.isValidMyanmarPhoneNumber("14155552671") //false

Opreator Checking

Check which opreator the number is from

MyanmarPhoneNumberUtils.getTelecomOperator("09958412345") //Ooredoo
MyanmarPhoneNumberUtils.getTelecomOperator("09784123456") //Telenor
MyanmarPhoneNumberUtils.getTelecomOperator("09420012345") //MPT
MyanmarPhoneNumberUtils.getTelecomOperator("09690000966") //MyTel

Network Type Checking

Check which network the numer belongs to

MyanmarPhoneNumberUtils.getNetworkType("09978412345") //GSM
MyanmarPhoneNumberUtils.getNetworkType("09451212123") //WCDMA
MyanmarPhoneNumberUtils.getNetworkType("096355555") //CDMA 450Hz
MyanmarPhoneNumberUtils.getNetworkType("0973123456") //CDMA 800Hz

Phone Number Extraction

Extract the list of burmese phone numbers within an input. This is experimental features, so feel free to report bugs if you use it!

val extractor = MyanmarPhoneNumberExtractor()
val input = "၀၉၁၂၃၄၅၆၇ (မောင်မောင်)၊ ၀၉၁၂၃၄၅၆၆ (အောင်အောင်)"
val result = extractor.extract(input) //[091234567, 091234566]

Usage

If you use gradle, include

repositories {
    mavenCentral()
}

implementation 'dev.aungkyawpaing.mmphonenumber:mmphonenumber:1.1.1'

VERSION LOWER THAN 1.1.1 IS PUBLISHED ON JCENTER

Credit

License

Copyright 2019 Aung Kyaw Paing

Licensed under the Apache License, Version 2.0 (the "License"); 
you may not use this file except in compliance with the License. 
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software 
distributed under the License is distributed on an "AS IS" BASIS, 
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
See the License for the specific language governing permissions and 
limitations under the License.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].