Files
Hotel-Booking/Backend/venv/lib/python3.12/site-packages/nltk/test/collections.doctest
Iliyan Angelov 62c1fe5951 updates
2025-12-01 06:50:10 +02:00

32 lines
591 B
Plaintext

.. Copyright (C) 2001-2025 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