def get_corpus_reader(corpus_name: str = None, language: str = None) -> CorpusReader:
    """
    Corpus reader factory method
    :param corpus_name: the name of the supported corpus, available as: [package].SUPPORTED_CORPORA
    :param langugage: the language for search in
    :return: NLTK compatible corpus reader
    """
    BASE = '~/cltk_data/{}/text'.format(language)
    root = os.path.join(os.path.expanduser(BASE), corpus_name)

    if not os.path.exists(root) or corpus_name not in SUPPORTED_CORPORA.get(language):
        raise ValueError(
            'Specified corpus data not found, please install {} for language: {}'.format(
                corpus_name, language))

    sentence_tokenizer = TokenizeSentence(language)
    the_word_tokenizer = WordTokenizer(language)
    doc_pattern = r'.*\.txt'  #: Generic file ending, override below in your own CorpusReader implementation

    if language == 'latin':
        if corpus_name == 'latin_text_latin_library':
            skip_keywords = ['Latin', 'Library']
            return FilteredPlaintextCorpusReader(root=root, fileids=doc_pattern,
                                                 sent_tokenizer=sentence_tokenizer,
                                                 word_tokenizer=the_word_tokenizer,
                                                 skip_keywords=skip_keywords)
        if corpus_name == 'latin_text_perseus':
            valid_json_root = os.path.join(root, 'cltk_json')  #: we only support this subsection
            return JsonfileCorpusReader(root=valid_json_root,
                                        sent_tokenizer=sentence_tokenizer,
                                        word_tokenizer=the_word_tokenizer,
                                        target_language='latin')  # perseus also contains English

    if language == 'greek':
        if corpus_name == 'greek_text_perseus':
            valid_json_root = os.path.join(root, 'cltk_json')  #: we only support this subsection
            return JsonfileCorpusReader(root=valid_json_root,
                                        sent_tokenizer=sentence_tokenizer,
                                        word_tokenizer=the_word_tokenizer,
                                        target_language='grc')  #: this abbreviation is required

        if corpus_name == 'greek_text_tesserae':
            # tokenizers/taggers need to be replaced with CLTK version
            # most obv. for POS tagging!
            return TesseraeCorpusReader(root=root, fileids=r'.*\.tess',
                                        sent_tokenizer=sent_tokenize,
                                        word_tokenizer=word_tokenize,
                                        pos_tagger=pos_tag,
                                        target_language='grc')
def get_corpus_reader ( corpus_name : str = None , language : str = None ) -> CorpusReader : BASE = '~/cltk_data/{}/text' . format ( language ) root = os . path . join ( os . path . expanduser ( BASE ) , corpus_name ) if not os . path . exists ( root ) or corpus_name not in SUPPORTED_CORPORA . get ( language ) : raise ValueError ( 'Specified corpus data not found, please install {} for language: {}' . format ( corpus_name , language ) ) sentence_tokenizer = TokenizeSentence ( language ) the_word_tokenizer = WordTokenizer ( language ) doc_pattern = r'.*\.txt' if language == 'latin' : if corpus_name == 'latin_text_latin_library' : skip_keywords = [ 'Latin' , 'Library' ] return FilteredPlaintextCorpusReader ( root = root , fileids = doc_pattern , sent_tokenizer = sentence_tokenizer , word_tokenizer = the_word_tokenizer , skip_keywords = skip_keywords ) if corpus_name == 'latin_text_perseus' : valid_json_root = os . path . join ( root , 'cltk_json' ) return JsonfileCorpusReader ( root = valid_json_root , sent_tokenizer = sentence_tokenizer , word_tokenizer = the_word_tokenizer , target_language = 'latin' ) if language == 'greek' : if corpus_name == 'greek_text_perseus' : valid_json_root = os . path . join ( root , 'cltk_json' ) return JsonfileCorpusReader ( root = valid_json_root , sent_tokenizer = sentence_tokenizer , word_tokenizer = the_word_tokenizer , target_language = 'grc' ) if corpus_name == 'greek_text_tesserae' : return TesseraeCorpusReader ( root = root , fileids = r'.*\.tess' , sent_tokenizer = sent_tokenize , word_tokenizer = word_tokenize , pos_tagger = pos_tag , target_language = 'grc' )
Corpus reader factory method
    :param corpus_name: the name of the supported corpus, available as: [package].SUPPORTED_CORPORA
    :param langugage: the language for search in
    :return: NLTK compatible corpus reader