本文整理汇总了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