code: def _detect_quotes( sentence_text, wid, fromRight = True ):
      ''' Searches for quotation marks (both opening and closing) closest to 
          given location in sentence (given as word index *wid*);
          
          If *fromRight == True* (default), searches from the right (all the 
          words having index greater than *wid*), otherwise, searches from the 
          left (all the words having index smaller than *wid*);
          
          Returns index of the closest quotation mark found, or -1, if none was
          found;
      '''
      i = wid
      while (i > -1 and i < len(sentence_text[WORDS])):
          token = sentence_text[WORDS][i]
          if _pat_starting_quote.match(token[TEXT]) or \
             _pat_ending_quote.match(token[TEXT]):
              return i
          i += 1 if fromRight else -1
      return -f _detect_quotes( sentence_text, wid, fromRight = True ):
      ''' Searches for quotation marks (both opening and closing) closest to 
          given location in sentence (given as word index *wid*);
          
          If *fromRight == True* (default), searches from the right (all the 
          words having index greater than *wid*), otherwise, searches from the 
          left (all the words having index smaller than *wid*);
          
          Returns index of the closest quotation mark found, or -1, if none was
          found;
      '''
      i = wid
      while (i > -1 and i < len(sentence_text[WORDS])):
          token = sentence_text[WORDS][i]
          if _pat_starting_quote.match(token[TEXT]) or \
             _pat_ending_quote.match(token[TEXT]):
              return i
          i += 1 if fromRight else -1
      return -1
docs: Searches for quotation marks (both opening and closing) closest to 
          given location in sentence (given as word index *wid*);
          
          If *fromRight == True* (default), searches from the right (all the 
          words having index greater than *wid*), otherwise, searches from the 
          left (all the words having index smaller than *wid*);
          
          Returns index of the closest quotation mark found, or -1, if none was
          found;