本文整理匯總了Python中collections.deque.__init__方法的典型用法代碼示例。如果您正苦於以下問題:Python deque.__init__方法的具體用法?Python deque.__init__怎麽用?Python deque.__init__使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類collections.deque
的用法示例。
在下文中一共展示了deque.__init__方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __init__
# 需要導入模塊: from collections import deque [as 別名]
# 或者: from collections.deque import __init__ [as 別名]
def __init__(self, n, cutoff=1, backoff=None):
"""
Construct an I{n}-gram stochastic tagger. The tagger must be trained
using the L{train()} method before being used to tag data.
@param n: The order of the new C{tagger.Ngram}.
@type n: int
@type cutoff: C{int}
@param cutoff: A count-cutoff for the tagger's frequency
distribution. If the tagger saw fewer than
C{cutoff} examples of a given context in training,
then it will return a tag of C{None} for that context.
"""
if n < 2: raise ValueError('n must be greater than 1')
self._model = {}
self._n = n
self._cutoff = cutoff
self._history = Window(n-1)
self._backoff = backoff
示例2: test_basics
# 需要導入模塊: from collections import deque [as 別名]
# 或者: from collections.deque import __init__ [as 別名]
def test_basics(self):
d = deque(xrange(-5125, -5000))
d.__init__(xrange(200))
for i in xrange(200, 400):
d.append(i)
for i in reversed(xrange(-200, 0)):
d.appendleft(i)
self.assertEqual(list(d), range(-200, 400))
self.assertEqual(len(d), 600)
left = [d.popleft() for i in xrange(250)]
self.assertEqual(left, range(-200, 50))
self.assertEqual(list(d), range(50, 400))
right = [d.pop() for i in xrange(250)]
right.reverse()
self.assertEqual(right, range(150, 400))
self.assertEqual(list(d), range(50, 150))
示例3: test_basics
# 需要導入模塊: from collections import deque [as 別名]
# 或者: from collections.deque import __init__ [as 別名]
def test_basics(self):
d = deque(range(-5125, -5000))
d.__init__(range(200))
for i in range(200, 400):
d.append(i)
for i in reversed(range(-200, 0)):
d.appendleft(i)
self.assertEqual(list(d), list(range(-200, 400)))
self.assertEqual(len(d), 600)
left = [d.popleft() for i in range(250)]
self.assertEqual(left, list(range(-200, 50)))
self.assertEqual(list(d), list(range(50, 400)))
right = [d.pop() for i in range(250)]
right.reverse()
self.assertEqual(right, list(range(150, 400)))
self.assertEqual(list(d), list(range(50, 150)))
示例4: test_basics
# 需要導入模塊: from collections import deque [as 別名]
# 或者: from collections.deque import __init__ [as 別名]
def test_basics(self):
d = deque(xrange(100))
d.__init__(xrange(100, 200))
for i in xrange(200, 400):
d.append(i)
for i in reversed(xrange(-200, 0)):
d.appendleft(i)
self.assertEqual(list(d), range(-200, 400))
self.assertEqual(len(d), 600)
left = [d.popleft() for i in xrange(250)]
self.assertEqual(left, range(-200, 50))
self.assertEqual(list(d), range(50, 400))
right = [d.pop() for i in xrange(250)]
right.reverse()
self.assertEqual(right, range(150, 400))
self.assertEqual(list(d), range(50, 150))
示例5: __init__
# 需要導入模塊: from collections import deque [as 別名]
# 或者: from collections.deque import __init__ [as 別名]
def __init__(self, deque, result):
self.deque = deque
self.result = result