#NEWLINE# @ classmethod #NEWLINE# def expand( cls , starts , winlens , excludezero = False ) : #NEWLINE# #INDENT# '\n        Return a list of features, one for each start point in starts\n        and for each window length in winlen. If excludezero is True,\n        no Features containing 0 in its positions will be generated\n        (many tbl trainers have a special representation for the\n        target feature at [0])\n\n        For instance, importing a concrete subclass (Feature is abstract)\n        >>> from nltk.tag.brill import Word\n\n        First argument gives the possible start positions, second the\n        possible window lengths\n        >>> Word.expand([-3,-2,-1], [1])\n        [Word([-3]), Word([-2]), Word([-1])]\n\n        >>> Word.expand([-2,-1], [1])\n        [Word([-2]), Word([-1])]\n\n        >>> Word.expand([-3,-2,-1], [1,2])\n        [Word([-3]), Word([-2]), Word([-1]), Word([-3, -2]), Word([-2, -1])]\n\n        >>> Word.expand([-2,-1], [1])\n        [Word([-2]), Word([-1])]\n\n        a third optional argument excludes all Features whose positions contain zero\n        >>> Word.expand([-2,-1,0], [1,2], excludezero=False)\n        [Word([-2]), Word([-1]), Word([0]), Word([-2, -1]), Word([-1, 0])]\n\n        >>> Word.expand([-2,-1,0], [1,2], excludezero=True)\n        [Word([-2]), Word([-1]), Word([-2, -1])]\n\n        All window lengths must be positive\n        >>> Word.expand([-2,-1], [0])\n        Traceback (most recent call last):\n          File "<stdin>", line 1, in <module>\n          File "nltk/tag/tbl/template.py", line 371, in expand\n            :param starts: where to start looking for Feature\n        ValueError: non-positive window length in [0]\n\n        :param starts: where to start looking for Feature\n        :type starts: list of ints\n        :param winlens: window lengths where to look for Feature\n        :type starts: list of ints\n        :param excludezero: do not output any Feature with 0 in any of its positions.\n        :type excludezero: bool\n        :returns: list of Features\n        :raises ValueError: for non-positive window lengths\n        ' #NEWLINE# if ( not all ( ( ( x > 0 ) for x in winlens ) ) ) : #NEWLINE# #INDENT# raise ValueError ( 'non-positive window length in {0}' . format ( winlens ) ) #NEWLINE# #UNINDENT# xs = ( starts [ i : ( i + w ) ] for w in winlens for i in range ( ( ( len ( starts ) - w ) + 1 ) ) ) #NEWLINE# return [ cls ( x ) for x in xs if ( not ( excludezero and ( 0 in x ) ) ) ]