Strip leading and trailing punctuation from an input string.
195097
def strip_punctuation(text, exclude='', include=''):
        """"""
        chars_to_strip = ''.join(
            set(list(punctuation)).union(set(list(include))) - set(list(exclude))
        )
        return text.strip(chars_to_strip)
658401
private static String stripSingleDoubleQuote(String input) {
    if (StringUtils.isEmpty(input)) {
      return input;
    }

    if (input.startsWith(SINGLE_QUOTE_STRING)
        || input.startsWith(DOUBLE_QUOTE_STRING)) {
      input = input.substring(1);
    }

    if (input.endsWith(SINGLE_QUOTE_STRING)
        || input.endsWith(DOUBLE_QUOTE_STRING)) {
      input = input.substring(0, input.length() - 1);
    }

    return input;
  }
1001650
def _strip(text):
        """"""
        text = text.strip()
        text = text.replace('  ', ' ')  # remove duplicate spaces
        text = text.lower()
        for joiner in TextTitle.JOINERS:
            text = text.replace(joiner, 'and')
        for article in TextTitle.ARTICLES:
            if text.startswith(article + ' '):
                text = text[len(article) + 1:]
                break
        return text
228120
def _add_punctuation_spacing(self, input):
        '''
        
        '''
        for replacement in punct_spacing:
            input = re.sub(replacement[0], replacement[1], input)

        return input
544245
def stripQuotes(value):

    """"""

    if value[:1] == '"':
        value = value[1:]
        if value[-1:] == '"':
            value = value[:-1]
        # replace "" with "
        value = re.sub(_re_doubleq2, '"', value)
    elif value[:1] == "'":
        value = value[1:]
        if value[-1:] == "'":
            value = value[:-1]
        # replace '' with '
        value = re.sub(_re_singleq2, "'", value)
    return value
289422
private String normalize(String str){
		str = StringUtils.trimToEmpty(str);
		str = StringUtils.normalizeSpace(str);

		// remove whitespace before punctuation. not using \p{Punct},
		// because it includes to many special characters.
		str = str.replaceAll("\\s+(?=[.!,\\?;:])", "");

		return str;
	}
671494
def clean(string):
    '''  '''
    # manual fixes in the source
    # 24/1.png
    # 9/1.png
    # 3/1.png
    #if ')' in string:  # fix in the source data
        #string = string.split(')')[0] + ')'  # remove trailing garbage
    return (string
            .replace('_', '')
            .replace('-', '')
            .replace('—', '')
            .replace('.', '')
            .replace('=', '')
            .replace('\u2018',"'")  # LEFT SINGLE QUOTATION MARK
            .replace('\u2019', "'")  # RIGHT SINGLE QUOTATION MARK
            .strip())
813732
def preprocess(string):
    
    string = unicode(string, encoding="utf-8")
    return regex.sub('', string).encode('utf-8')
1192056
def _preprocess(text, tab=4):
    """"""
    text = re.sub(r'\r\n|\r', '\n', text)
    text = text.replace('\t', ' ' * tab)
    text = text.replace('\u00a0', ' ')
    text = text.replace('\u2424', '\n')
    pattern = re.compile(r'^ +$', re.M)
    text = pattern.sub('', text)
    text = _rstrip_lines(text)
    return text
1336307
def clean_string(text):
    
    if isinstance(text, six.string_types):
        return text.translate(UNI_SPECIAL_CHARS).strip()
    return text.translate(None, STR_SPECIAL_CHARS).strip()
1176173
def strip_end(text, suffix):
    """"""
    if not text.endswith(suffix):
        return text
    return text[:len(text)-len(suffix)]
198445
def preprocess(input)
      input = input.to_s.encode('UTF-8',
        :invalid => :replace,
        :undef   => :replace)

      input.gsub!(/(?:\r\n|[\r\f])/, "\n")
      input.gsub!("\u0000", "\ufffd")
      input
    end
882935
def endswith_strip(s, endswith='.txt', ignorecase=True):
    
    if ignorecase:
        if s.lower().endswith(endswith.lower()):
            return s[:-len(endswith)]
    else:
        if s.endswith(endswith):
            return s[:-len(endswith)]
    return s
86091
def _convert_punctuation(punctuation, conversion_table):
    """"""
    if punctuation in conversion_table:
        return conversion_table[punctuation]
    return re.escape(punctuation)
65552
def _normalize(self, string):
		'''  '''

		string = string.replace(u'\xa0', '')
		string = string.strip()
		return string
59293
def _preprocess_input(self, input):
        '''
        
        '''
        if not re.search(preprocess_chars, input):
            # No characters that we need to preprocess, so continue without.
            return input

        input = self._add_punctuation_spacing(input)

        return input
555563
public static String stripNonAlphaNumericCharacters(String input) {
    StringBuilder output = new StringBuilder();
    for (int i = 0; i < input.length(); i++) {
      char current = input.charAt(i);
      if ("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 ".indexOf(current) >= 0)
        output.append(current);
    }
    return output.toString();
  }