Skip to content

Instantly share code, notes, and snippets.

@muranava
Forked from bbengfort/concordance.py
Last active August 29, 2015 14:13

Revisions

  1. @bbengfort bbengfort created this gist Jun 27, 2013.
    15 changes: 15 additions & 0 deletions concordance.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    #!/usr/bin/env python

    from nltk import Text
    from nltk.corpus import PlaintextCorpusReader


    CORPUS_ROOT = '/Users/benjamin/Development/corpora/gutenburg/'

    if __name__ == "__main__":
    reader = PlaintextCorpusReader(CORPUS_ROOT, '.*')
    text = Text(reader.words())
    while True:
    word = raw_input('Enter word: ')
    print (word);
    text.concordance(word)