textstat/resources/TextStat.py
def textKWIC(text, token, contextchars=15, wordboundary=True):
   """Returns a list of left and right context tuples for token.
      The context is default of length 15,
      the context obeys word boundaries in the default.
      !!! TODO !!!
   """
   pos = text.find(token)
   res = []
   while pos > -1:
      left = text[max(0,pos-contextchars):pos].strip()
      right = text[pos+len(token):max(contextchars,len(text)+pos+len(token))].strip()
      res.append( (left, right) )
      if pos + 1 < len(text) + len(token):
         pos = text.find(token, pos + 1)
      else:
         break
   return tuple(res)
Returns a list of left and right context tuples for token.
      The context is default of length 15,
      the context obeys word boundaries in the default.
      !!! TODO !!!
   
Returns a list of left and right context tuples for token.
The context is default of length 15,
the context obeys word boundaries in the default.
TODO
Returns a list of left and right context tuples for token . The context is default of length 15 the context obeys word boundaries in the default . TODO
def textKWIC(text, token, contextchars=15, wordboundary=True):
   pos = text.find(token)
   res = []
   while pos > -1:
      left = text[max(0,pos-contextchars):pos].strip()
      right = text[pos+len(token):max(contextchars,len(text)+pos+len(token))].strip()
      res.append( (left, right) )
      if pos + 1 < len(text) + len(token):
         pos = text.find(token, pos + 1)
      else:
         break
   return tuple(res)
def textKWIC ( text , token , contextchars = 15 , wordboundary = True ) : pos = text . find ( token ) res = [ ] while pos > - 1 : left = text [ max ( 0 , pos - contextchars ) : pos ] . strip ( ) right = text [ pos + len ( token ) : max ( contextchars , len ( text ) + pos + len ( token ) ) ] . strip ( ) res . append ( ( left , right ) ) if pos + 1 < len ( text ) + len ( token ) : pos = text . find ( token , pos + 1 ) else : break return tuple ( res )
Returns a list of left and right context tuples for token.
Returns a list of left and right context tuples for token .
"""Returns a list of left and right context tuples for token.
      The context is default of length 15,
      the context obeys word boundaries in the default.
      !!! TODO !!!
   """
text
token
contextchars
wordboundary