I have successfully used the concordance()
method in NLTK with my own text file that I read in through the Gutenberg Corpus:
bom = open('sentences-with-emoji.txt')
from nltk.text import Text
bom = Text(nltk.corpus.gutenberg.words('/my-own-text-file.txt'))
bom.concordance('messiah')
I say "through" because the concordance()
method only reads words through the specified corpus, which is the Gutenberg. The Gutenberg corpus doesn't have emoji in it. So when I try a different file containing emoji like this:
bom = open('sentences-with-emoji.txt’)
from nltk.text import Text
bom = Text(nltk.corpus.gutenberg.words('/sentences-with-emoji.txt'))
bom.concordance('')
I get the response:
No matches
Do I have to create an annotated corpus (using the process here: Creating a new corpus with NLTK) with my /sentences-with-emoji.txt
file in order to use the concordance()
method with emoji?