|
| 1 | +{ |
| 2 | + "cells": [ |
| 3 | + { |
| 4 | + "cell_type": "markdown", |
| 5 | + "metadata": { |
| 6 | + "deletable": true, |
| 7 | + "editable": true |
| 8 | + }, |
| 9 | + "source": [ |
| 10 | + "The CLTK has a distributed infrastructure that lets you download official CLTK texts or other corpora shared by others. For full docs, see <http://docs.cltk.org/en/latest/importing_corpora.html>.\n", |
| 11 | + "\n", |
| 12 | + "To get started, from the Terminal, open a new Jupyter notebook from within your `~/cltk` directory (see notebook 1 for instructions): `jupyter notebook`. Then go to <http://localhost:8888>." |
| 13 | + ] |
| 14 | + }, |
| 15 | + { |
| 16 | + "cell_type": "markdown", |
| 17 | + "metadata": { |
| 18 | + "deletable": true, |
| 19 | + "editable": true |
| 20 | + }, |
| 21 | + "source": [ |
| 22 | + "# See what corpora are available\n", |
| 23 | + "\n", |
| 24 | + "First we need to \"import\" the right part of the CLTK library. Think of this as pulling just the book you need off the shelf and having it ready to read." |
| 25 | + ] |
| 26 | + }, |
| 27 | + { |
| 28 | + "cell_type": "code", |
| 29 | + "execution_count": 1, |
| 30 | + "metadata": { |
| 31 | + "collapsed": true, |
| 32 | + "deletable": true, |
| 33 | + "editable": true |
| 34 | + }, |
| 35 | + "outputs": [], |
| 36 | + "source": [ |
| 37 | + "# this is the import of the right part of the CLTK library\n", |
| 38 | + "from cltk.corpus.utils.importer import CorpusImporter" |
| 39 | + ] |
| 40 | + }, |
| 41 | + { |
| 42 | + "cell_type": "code", |
| 43 | + "execution_count": 2, |
| 44 | + "metadata": { |
| 45 | + "collapsed": false, |
| 46 | + "deletable": true, |
| 47 | + "editable": true |
| 48 | + }, |
| 49 | + "outputs": [], |
| 50 | + "source": [ |
| 51 | + "# See https://github.com/cltk for all official corpora\n", |
| 52 | + "\n", |
| 53 | + "my_latin_downloader = CorpusImporter('latin')\n", |
| 54 | + "\n", |
| 55 | + "# 'my_latin_downloader' is the variable by which we now call the CorpusImporter" |
| 56 | + ] |
| 57 | + }, |
| 58 | + { |
| 59 | + "cell_type": "code", |
| 60 | + "execution_count": 3, |
| 61 | + "metadata": { |
| 62 | + "collapsed": false, |
| 63 | + "deletable": true, |
| 64 | + "editable": true |
| 65 | + }, |
| 66 | + "outputs": [ |
| 67 | + { |
| 68 | + "data": { |
| 69 | + "text/plain": [ |
| 70 | + "['latin_text_perseus',\n", |
| 71 | + " 'latin_treebank_perseus',\n", |
| 72 | + " 'latin_treebank_perseus',\n", |
| 73 | + " 'latin_text_latin_library',\n", |
| 74 | + " 'phi5',\n", |
| 75 | + " 'phi7',\n", |
| 76 | + " 'latin_proper_names_cltk',\n", |
| 77 | + " 'latin_models_cltk',\n", |
| 78 | + " 'latin_pos_lemmata_cltk',\n", |
| 79 | + " 'latin_treebank_index_thomisticus',\n", |
| 80 | + " 'latin_lexica_perseus',\n", |
| 81 | + " 'latin_training_set_sentence_cltk',\n", |
| 82 | + " 'latin_word2vec_cltk',\n", |
| 83 | + " 'latin_text_antique_digiliblt',\n", |
| 84 | + " 'latin_text_corpus_grammaticorum_latinorum']" |
| 85 | + ] |
| 86 | + }, |
| 87 | + "execution_count": 3, |
| 88 | + "metadata": {}, |
| 89 | + "output_type": "execute_result" |
| 90 | + } |
| 91 | + ], |
| 92 | + "source": [ |
| 93 | + "my_latin_downloader.list_corpora" |
| 94 | + ] |
| 95 | + }, |
| 96 | + { |
| 97 | + "cell_type": "markdown", |
| 98 | + "metadata": { |
| 99 | + "deletable": true, |
| 100 | + "editable": true |
| 101 | + }, |
| 102 | + "source": [ |
| 103 | + "# Import several corpora" |
| 104 | + ] |
| 105 | + }, |
| 106 | + { |
| 107 | + "cell_type": "code", |
| 108 | + "execution_count": 4, |
| 109 | + "metadata": { |
| 110 | + "collapsed": true, |
| 111 | + "deletable": true, |
| 112 | + "editable": true |
| 113 | + }, |
| 114 | + "outputs": [], |
| 115 | + "source": [ |
| 116 | + "my_latin_downloader.import_corpus('latin_text_latin_library')\n", |
| 117 | + "my_latin_downloader.import_corpus('latin_models_cltk')" |
| 118 | + ] |
| 119 | + }, |
| 120 | + { |
| 121 | + "cell_type": "markdown", |
| 122 | + "metadata": { |
| 123 | + "deletable": true, |
| 124 | + "editable": true |
| 125 | + }, |
| 126 | + "source": [ |
| 127 | + "You can verify the files were downloaded in the Terminal with `$ ls -l ~/cltk_data/latin/text/latin_text_latin_library/`" |
| 128 | + ] |
| 129 | + }, |
| 130 | + { |
| 131 | + "cell_type": "code", |
| 132 | + "execution_count": 5, |
| 133 | + "metadata": { |
| 134 | + "collapsed": false, |
| 135 | + "deletable": true, |
| 136 | + "editable": true |
| 137 | + }, |
| 138 | + "outputs": [ |
| 139 | + { |
| 140 | + "data": { |
| 141 | + "text/plain": [ |
| 142 | + "['greek_software_tlgu',\n", |
| 143 | + " 'greek_text_perseus',\n", |
| 144 | + " 'phi7',\n", |
| 145 | + " 'tlg',\n", |
| 146 | + " 'greek_proper_names_cltk',\n", |
| 147 | + " 'greek_models_cltk',\n", |
| 148 | + " 'greek_treebank_perseus',\n", |
| 149 | + " 'greek_lexica_perseus',\n", |
| 150 | + " 'greek_training_set_sentence_cltk',\n", |
| 151 | + " 'greek_word2vec_cltk',\n", |
| 152 | + " 'greek_text_lacus_curtius']" |
| 153 | + ] |
| 154 | + }, |
| 155 | + "execution_count": 5, |
| 156 | + "metadata": {}, |
| 157 | + "output_type": "execute_result" |
| 158 | + } |
| 159 | + ], |
| 160 | + "source": [ |
| 161 | + "# Let's get a Greek corpus, too\n", |
| 162 | + "\n", |
| 163 | + "my_greek_downloader = CorpusImporter('greek')\n", |
| 164 | + "my_greek_downloader.list_corpora" |
| 165 | + ] |
| 166 | + }, |
| 167 | + { |
| 168 | + "cell_type": "code", |
| 169 | + "execution_count": 6, |
| 170 | + "metadata": { |
| 171 | + "collapsed": false, |
| 172 | + "deletable": true, |
| 173 | + "editable": true |
| 174 | + }, |
| 175 | + "outputs": [], |
| 176 | + "source": [ |
| 177 | + "my_greek_downloader.import_corpus('greek_text_lacus_curtius')" |
| 178 | + ] |
| 179 | + }, |
| 180 | + { |
| 181 | + "cell_type": "markdown", |
| 182 | + "metadata": { |
| 183 | + "deletable": true, |
| 184 | + "editable": true |
| 185 | + }, |
| 186 | + "source": [ |
| 187 | + "Likewise, verify with `ls -l ~/cltk_data/greek/text/greek_text_lacus_curtius/plain/`" |
| 188 | + ] |
| 189 | + } |
| 190 | + ], |
| 191 | + "metadata": { |
| 192 | + "kernelspec": { |
| 193 | + "display_name": "Python 3", |
| 194 | + "language": "python", |
| 195 | + "name": "python3" |
| 196 | + }, |
| 197 | + "language_info": { |
| 198 | + "codemirror_mode": { |
| 199 | + "name": "ipython", |
| 200 | + "version": 3 |
| 201 | + }, |
| 202 | + "file_extension": ".py", |
| 203 | + "mimetype": "text/x-python", |
| 204 | + "name": "python", |
| 205 | + "nbconvert_exporter": "python", |
| 206 | + "pygments_lexer": "ipython3", |
| 207 | + "version": "3.6.0" |
| 208 | + } |
| 209 | + }, |
| 210 | + "nbformat": 4, |
| 211 | + "nbformat_minor": 1 |
| 212 | +} |
0 commit comments