@@ -0,0 +1,998 @@
+##%0A# Corpus reader for Akoma Ntoso documents.%0A#%0A# import nltk.text, aknnltk%0A# t = nltk.text.Text(aknnltk.AKNCorpusReader('/tmp/openlaw-test', '.*%5C.xml').words('pen.xml'))%0A# t.plot(20)%0A#%0A%0Afrom nltk.tokenize import WordPunctTokenizer%0Afrom nltk.corpus.reader.xmldocs import XMLCorpusReader%0A%0Aclass AKNCorpusReader(XMLCorpusReader):%0A%09%22%22%22%0A%09Corpus reader for Akoma Ntoso documents.%0A%0A%09%22%22%22%0A%09def __init__(self, root, fileids):%0A%09%09XMLCorpusReader.__init__(self, root, fileids)%0A%09%0A%09def xml(self, fileid=None):%0A%09%09return XMLCorpusReader.xml(self, fileid)%0A%09%0A%09def words(self, fileid=None):%0A%09%09%22%22%22%0A%09%09Returns all of the words and puncuation symbols in the specified file%0A%09%09that were in 'section//p' text nodes.%0A%09%09%22%22%22%0A%09%09elt = self.xml(fileid).iterfind('.//section//p')%0A%09%09word_tokenizer = WordPunctTokenizer()%0A%09%09return %5Bval for subl in %5Bword_tokenizer.tokenize(nodetext) for nodetext in %5B''.join(el.itertext()) for el in elt%5D%5D for val in subl%5D%0A%09%0A%09def raw(self, fileids=None):%0A%09%09return XMLCorpusReader.raw(self, fileids)%0A%0A

Add NLTK parser