code: function getRegularityScale(charpinyin, phoneticpinyin) {
    if (charpinyin == null || phoneticpinyin == null) {
      return null;
    }
    var regularity = 0;
    charpinyin = new PinyinSyllable(charpinyin.toLowerCase());
    phoneticpinyin = new PinyinSyllable(phoneticpinyin.toLowerCase());
  
    // Regularity Scale: 1 = Exact Match (with tone), 2 = Syllable Match (without tone)
    // 3 = Similar in Initial, 4 = Similar in Final, 0 = No regularity
  
    //First test for Scale 1 & 2
    if (charpinyin.syllable() == phoneticpinyin.syllable()) {
      regularity = 2;
      if (charpinyin.raw_syllable == phoneticpinyin.raw_syllable) {
        regularity = 1;
      }
    }
  
    //If still no regularity found, test for initial & final regularity (scale 3 & 4)
    if (regularity == 0) {
      if (charpinyin.final() == phoneticpinyin.final()) {
        regularity = 4;
      } else {
        if (charpinyin.initial() == phoneticpinyin.initial()) {
          regularity = 3;
        }
      }
    }
  
    return regularity;
  }
docs: Helper Functions