> AttributeError: 'StreamBackedCorpusView' object has no
attribute 'concordance'
PG,
The type behind PlainTextCorpusView has no method concordance().
text1-9 are objects of type Text-- you can see this by typing
"type(text1)". The crucial difference is between methods, e.g.,
object.call(args), and plain functions like call(object).
Type Text is designed for interactive/demo use... to be honest I
never quite understood why it's there, or why the NLTK book spends
so much time on it. My advice would be to ignore it and base your
own scripts on the rest. If you really need concordances: they're
somewhere in the nltk hierarchy, you'll have to google for it. There
was also some discussion on this list recently about capturing the
output of concordance (instead of just printing it on the screen),
so check the list archives.
Here are some python commands that will help you examine what you've
got in your hands:
help(text1), type(text1), dir(text1), dir(). Also help(dir).
I'd also recommend learning about python directly (even before
you're done with chapter 4 of the NLTK book). You'll find several
tutorials on the python website. And of course, google is always
your friend. We're always here to help if you can't find the answer
yourself.
Have fun with it,
Alexis