(text, tokens, startchar=None, endchar=None,
           charsbefore=0, charsafter=0)
return Fragment(text, tokens, startchar, endchar)
Returns a :class:`Fragment` object based on the :class:`analysis.Token`
    objects in ``tokens`.
Returns a :class:`Fragment` object based on the :class:`analysis.Token`
    objects in ``tokens`.
Returns a : class : Fragment object based on the : class : analysis . Token objects in tokens .
def mkfrag(text, tokens, startchar=None, endchar=None,
           charsbefore=0, charsafter=0):
    """Returns a :class:`Fragment` object based on the :class:`analysis.Token`
    objects in ``tokens`.
    """

    if startchar is None:
        startchar = tokens[0].startchar if tokens else 0
    if endchar is None:
        endchar = tokens[-1].endchar if tokens else len(text)

    startchar = max(0, startchar - charsbefore)
    endchar = min(len(text), endchar + charsafter)

    return Fragment(text, tokens, startchar, endchar)
def mkfrag ( text , tokens , startchar = None , endchar = None , charsbefore = 0 , charsafter = 0 ) : if startchar is None : startchar = tokens [ 0 ] . startchar if tokens else 0 if endchar is None : endchar = tokens [ - 1 ] . endchar if tokens else len ( text ) startchar = max ( 0 , startchar - charsbefore ) endchar = min ( len ( text ) , endchar + charsafter ) return Fragment ( text , tokens , startchar , endchar )