Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
# Natural Language Toolkit: Toolbox Reader # # Copyright (C) 2001-2012 NLTK Project # Author: Greg Aumann <greg_aumann@sil.org> # Stuart Robinson <Stuart.Robinson@mpi.nl> # Steven Bird <sb@csse.unimelb.edu.au> # URL: <http://www.nltk.org/> # For license information, see LICENSE.TXT
Module for reading, writing and manipulating Toolbox databases and settings fileids. """
return concat([ToolboxData(path, enc).parse(key) for (path, enc) in self.abspaths(fileids, True)])
errors='strict', unicode_fields=None): return concat([list(ToolboxData(fileid,enc).fields( strip, unwrap, encoding, errors, unicode_fields)) for (fileid, enc) in self.abspaths(fileids, include_encoding=True)])
# should probably be done lazily: if 'key' in kwargs: key = kwargs['key'] del kwargs['key'] else: key = 'lx' # the default key in MDF entries = [] for marker, contents in self.fields(fileids, **kwargs): if marker == key: entries.append((contents, [])) else: try: entries[-1][-1].append((marker, contents)) except IndexError: pass return entries
return [contents for marker, contents in self.fields(fileids) if marker == key]
if fileids is None: fileids = self._fileids elif isinstance(fileids, compat.string_types): fileids = [fileids] return concat([self.open(f).read() for f in fileids])
pass
demo() |