Programmatically install NLTK corpora / models, i.e. without the GUI downloader?

后端 未结 4 650
盖世英雄少女心
盖世英雄少女心 2020-12-12 15:56

My project uses the NLTK. How can I list the project\'s corpus & model requirements so they can be automatically installed? I don\'t want to click through the nltk

4条回答
  •  自闭症患者
    2020-12-12 16:31

    To install all NLTK corpora & models:

    python -m nltk.downloader all
    

    Alternatively, on Linux, you can use:

    sudo python -m nltk.downloader -d /usr/local/share/nltk_data all
    

    Replace all by popular if you just want to list the most popular corpora & models.


    You may also browse the corpora & models through the command line:

    mlee@server:/scratch/jjylee/tests$ sudo python -m nltk.downloader
    [sudo] password for jjylee:
    NLTK Downloader
    ---------------------------------------------------------------------------
        d) Download   l) List    u) Update   c) Config   h) Help   q) Quit
    ---------------------------------------------------------------------------
    Downloader> d
    
    Download which package (l=list; x=cancel)?
      Identifier> l
    Packages:
      [ ] averaged_perceptron_tagger_ru Averaged Perceptron Tagger (Russian)
      [ ] basque_grammars..... Grammars for Basque
      [ ] bllip_wsj_no_aux.... BLLIP Parser: WSJ Model
      [ ] book_grammars....... Grammars from NLTK Book
      [ ] cess_esp............ CESS-ESP Treebank
      [ ] chat80.............. Chat-80 Data Files
      [ ] city_database....... City Database
      [ ] cmudict............. The Carnegie Mellon Pronouncing Dictionary (0.6)
      [ ] comparative_sentences Comparative Sentence Dataset
      [ ] comtrans............ ComTrans Corpus Sample
      [ ] conll2000........... CONLL 2000 Chunking Corpus
      [ ] conll2002........... CONLL 2002 Named Entity Recognition Corpus
      [ ] conll2007........... Dependency Treebanks from CoNLL 2007 (Catalan
                               and Basque Subset)
      [ ] crubadan............ Crubadan Corpus
      [ ] dependency_treebank. Dependency Parsed Treebank
      [ ] europarl_raw........ Sample European Parliament Proceedings Parallel
                               Corpus
      [ ] floresta............ Portuguese Treebank
      [ ] framenet_v15........ FrameNet 1.5
    Hit Enter to continue: 
      [ ] framenet_v17........ FrameNet 1.7
      [ ] gazetteers.......... Gazeteer Lists
      [ ] genesis............. Genesis Corpus
      [ ] gutenberg........... Project Gutenberg Selections
      [ ] hmm_treebank_pos_tagger Treebank Part of Speech Tagger (HMM)
      [ ] ieer................ NIST IE-ER DATA SAMPLE
      [ ] inaugural........... C-Span Inaugural Address Corpus
      [ ] indian.............. Indian Language POS-Tagged Corpus
      [ ] jeita............... JEITA Public Morphologically Tagged Corpus (in
                               ChaSen format)
      [ ] kimmo............... PC-KIMMO Data Files
      [ ] knbc................ KNB Corpus (Annotated blog corpus)
      [ ] large_grammars...... Large context-free and feature-based grammars
                               for parser comparison
      [ ] lin_thesaurus....... Lin's Dependency Thesaurus
      [ ] mac_morpho.......... MAC-MORPHO: Brazilian Portuguese news text with
                               part-of-speech tags
      [ ] machado............. Machado de Assis -- Obra Completa
      [ ] masc_tagged......... MASC Tagged Corpus
      [ ] maxent_ne_chunker... ACE Named Entity Chunker (Maximum entropy)
      [ ] moses_sample........ Moses Sample Models
    Hit Enter to continue: x
    
    
    Download which package (l=list; x=cancel)?
      Identifier> conll2002
        Downloading package conll2002 to
            /afs/mit.edu/u/m/mlee/nltk_data...
          Unzipping corpora/conll2002.zip.
    
    ---------------------------------------------------------------------------
        d) Download   l) List    u) Update   c) Config   h) Help   q) Quit
    ---------------------------------------------------------------------------
    Downloader>
    

提交回复
热议问题