Returns a Parser object specific to the language specified by :param:`lang`.

    :param lang: A string naming the desired parser.  See the keys in :var:`class_`
    for valid strings.

    :Example:

    >>> chinese_parser = parser_factory('zh-Hans')
    >>> isinstance(chinese_parser, ChineseSimplifiedParser)
    True

    >>> cantonese_parser = parser_factory('yue-Hant')
    >>> isinstance(cantonese_parser, CantoneseTraditionalParser)
    True

def parser_factory(lang):
    """Returns a Parser object specific to the language specified by :param:`lang`.

    :param lang: A string naming the desired parser.  See the keys in :var:`class_`
    for valid strings.

    :Example:

    >>> chinese_parser = parser_factory('zh-Hans')
    >>> isinstance(chinese_parser, ChineseSimplifiedParser)
    True

    >>> cantonese_parser = parser_factory('yue-Hant')
    >>> isinstance(cantonese_parser, CantoneseTraditionalParser)
    True

    """

    class_ = {
            'zh-Hans' : ChineseSimplifiedParser,
            'zh-Hant' : ChineseTraditionalParser,
            'zh' : ChineseParser,
            'yue-Hans' : CantoneseSimplifiedParser,
            'yue-Hant' : CantoneseTraditionalParser,
            'yue' : CantoneseParser,
            'thai' : ThaiParser,
            'th' : ThaiParser,
            }.get(lang)
    return class_()