Generate pinyin for chars, if char is not chinese character,
    itself will be returned.
    Chars must be unicode list.
518658
def _pinyin_generator(chars, format):
    
    for char in chars:
        key = "%X" % ord(char)
        pinyin = pinyin_dict.get(key, char)
        tone = pinyin_tone.get(key, 0)

        if tone == 0 or format == "strip":
            pass
        elif format == "numerical":
            pinyin += str(tone)
        elif format == "diacritical":
            # Find first vowel -- where we should put the diacritical mark
            vowels = itertools.chain((c for c in pinyin if c in "aeo"),
                                     (c for c in pinyin if c in "iuv"))
            vowel = pinyin.index(next(vowels)) + 1
            pinyin = pinyin[:vowel] + tonemarks[tone] + pinyin[vowel:]
        else:
            error = "Format must be one of: numerical/diacritical/strip"
            raise ValueError(error)

        yield unicodedata.normalize('NFC', pinyin)
1276042
def get_accent_char(char):
    
    index = utils.VOWELS.find(char.lower())
    if (index != -1):
        return 5 - index % 6
    else:
        return Accent.NONE
508646
def soundexCode(self, char):
        '''
        '''
        lang = get_language(char)
        try:
            if lang == "en_US":
                return _soundex_map["soundex_en"][charmap[lang].index(char)]
            else:
                return _soundex_map["soundex"][charmap[lang].index(char)]
        except:
            # Case of exception KeyError because we don't have soundex
            # mapping for the character
            pass

        return 0
92602
def pinyin_to_zhuyin(s):
    
    return _convert(s, zhon.pinyin.syllable, pinyin_syllable_to_zhuyin,
                    remove_apostrophes=True, separate_syllables=True)
1151199
static CharInput asCharInput(final CharSequence chars) {
    checkNotNull(chars);
    return new CharInput() {
      int index = 0;

      @Override
      public int read() {
        if (index < chars.length()) {
          return chars.charAt(index++);
        } else {
          return -1;
        }
      }

      @Override
      public void close() {
        index = chars.length();
      }
    };
  }
392506
def _numbered_vowel_to_accented(vowel, tone):
    """"""
    if isinstance(tone, int):
        tone = str(tone)
    return _PINYIN_TONES[vowel + tone]
844072
public static List<Pinyin> convert(String complexText, boolean removeTone)
    {
        List<Pinyin> pinyinList = convert(complexText);
        if (removeTone)
        {
            makeToneToTheSame(pinyinList);
        }
        return pinyinList;
    }
916887
public static boolean findChinese(String str) {
        Matcher m = pattern.matcher(str);
        return m.find();
    }
204582
def _tokenize_chinese_chars(self, text):
        """"""
        output = []
        for char in text:
            cp = ord(char)
            if self._is_chinese_char(cp):
                output.append(" ")
                output.append(char)
                output.append(" ")
            else:
                output.append(char)
        return "".join(output)
1300140
public static List<Character> collectPrintableCharactersOf(Charset charset) {
        List<Character> chars = new ArrayList<>();
        for (int i = Character.MIN_VALUE; i < Character.MAX_VALUE; i++) {
            char character = (char) i;
            if (isPrintable(character)) {
                String characterAsString = Character.toString(character);
                byte[] encoded = characterAsString.getBytes(charset);
                String decoded = new String(encoded, charset);
                if (characterAsString.equals(decoded)) {
                    chars.add(character);
                }
            }
        }
        return chars;
    }
429868
function(pinyinWithoutTone)
        {
            var newToneMap = {};
            for(var i in toneMap) newToneMap[toneMap[i]] = i;
            return (pinyinWithoutTone || '').replace(/[a-z]\d/g, function(m) {
                return newToneMap[m] || m;
            });
        }
613405
public static StrMatcher charSetMatcher(final String chars) {
        if (StringUtils.isEmpty(chars)) {
            return NONE_MATCHER;
        }
        if (chars.length() == 1) {
            return new CharMatcher(chars.charAt(0));
        }
        return new CharSetMatcher(chars.toCharArray());
    }
988385
def get_initials(pinyin, strict):
    
    if strict:
        _initials = _INITIALS
    else:
        _initials = _INITIALS_NOT_STRICT

    for i in _initials:
        if pinyin.startswith(i):
            return i
    return ''
410236
def is_traditional(s):
    
    chinese = _get_hanzi(s)
    if not chinese:
        return False
    elif chinese.issubset(_SHARED_CHARACTERS):
        return True
    elif chinese.issubset(_TRADITIONAL_CHARACTERS):
        return True
    return False
170699
def chars(string: any) -> str:
        """"""
        return ''.join([c if c.isalpha() else '' for c in str(string)])
1137049
public static String convertToPinyinString(String text, String separator, boolean remainNone)
    {
        List<Pinyin> pinyinList = PinyinDictionary.convertToPinyin(text, true);
        int length = pinyinList.size();
        StringBuilder sb = new StringBuilder(length * (5 + separator.length()));
        int i = 1;
        for (Pinyin pinyin : pinyinList)
        {

            if (pinyin == Pinyin.none5 && !remainNone)
            {
                sb.append(text.charAt(i - 1));
            }
            else sb.append(pinyin.getPinyinWithoutTone());
            if (i < length)
            {
                sb.append(separator);
            }
            ++i;
        }
        return sb.toString();
    }
1228093
def _switch_charset_list(characters, target=''):
    '''
    
    '''
    # Copy the list to avoid modifying the existing one.
    characters = characters[:]
    offset = block_offset * offsets[target]['direction']
    for n in range(len(characters)):
        chars = list(characters[n])

        for m in range(len(chars)):
            char = chars[m]
            char_offset = ord(char) + offset
            # Verify that the offset character is within the valid range.
            if in_range(char_offset, target):
                chars[m] = chr(char_offset)
            else:
                chars[m] = char

        characters[n] = ''.join(chars)

    return characters