nltk/nltk — Issue #120: XMLCorpusView
Author: alexrudnick
Created: 2012-01-17 06:26:32+00:00
State: open

What version of NLTK are you using? (See nltk.__version__). Please only
submit bug reports for the current version.
Nltk version 2.0b8

What steps will reproduce the problem? (e.g. include Python source code)

import unittest
from CategorizedXMLCorpusReader import CategorizedXMLCorpusReader
from nltk.corpus.reader.xmldocs import XMLCorpusView

class TestCategorizedXMLCorpusReader(unittest.TestCase):

def setUp(self):
self.root = "../articles/"
self.pattern = r'(neg|pos)/.*'
self.regexpr = '.*\.xml'

self.corpus = CategorizedXMLCorpusReader(self.root, self.regexpr, cat_pattern=self.pattern)

def testArticleView(self):
view = XMLCorpusView(self.root + 'neg/20511063.xml', 'PubmedArticle')
iter = view.iterate_from(0)
print iter.next()

What is the expected output? What do you see instead?
Expected output: Not sure about the concept of a XMLCorpusView

Output:
ERROR: testArticleView (tests.test_categorizedXMLCorpusReader.TestCategorizedXMLCorpusReader)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/silvio/programming/eclipse_workspace/BioClassifier/src/tests/test_categorizedXMLCorpusReader.py", line 57, in testArticleView
print iter.next()
File "/usr/local/lib/python2.6/dist-packages/nltk/corpus/reader/util.py", line 279, in iterate_from
self._open()
File "/usr/local/lib/python2.6/dist-packages/nltk/corpus/reader/util.py", line 208, in _open
self._stream = SeekableUnicodeStreamReader(
NameError: global name 'SeekableUnicodeStreamReader' is not defined

Please use labels and text to provide additional information.
Inside util.py the _open() function is called which calls SeekableUnicodeStreamReader, but in the import section it is not imported?

Migrated from http://code.google.com/p/nltk/issues/detail?id=576

earlier comments

StevenBird1 said, at 2010-07-18T12:31:26.000Z:

Would you please provide a complete program so I can reproduce the problem?