Spaces:
Sleeping
Sleeping
File size: 622 Bytes
d916065 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
.. Copyright (C) 2001-2023 NLTK Project
.. For license information, see LICENSE.TXT
===========
Collections
===========
>>> import nltk
>>> from nltk.collections import *
Trie
----
Trie can be pickled:
>>> import pickle
>>> trie = nltk.collections.Trie(['a'])
>>> s = pickle.dumps(trie)
>>> pickle.loads(s)
{'a': {True: None}}
LazyIteratorList
----------------
Fetching the length of a LazyIteratorList object does not throw a StopIteration exception:
>>> lil = LazyIteratorList(i for i in range(1, 11))
>>> lil[-1]
10
>>> len(lil)
10
|