Return a set of words with edit distance of 2 from the input word
483314
def _edits2(word: str) -> Set[str]:
    
    return set(e2 for e1 in _edits1(word) for e2 in _edits1(e1))
1162442
function(word)
		{
			var c = word[0];
			for (var i = 0; i < 3; i++)
				word[i] = word[i+1];
			word[3] = c;
			
			return word;
		}
969700
function (s, positions) {
		var i, p, words = s.split(" ");

		if (positions === undefined) {
			positions = [];
			for (i = 0; i < words.length; i += 1) {
				positions.push(i);
			}
		} else if (typeof positions === 'number') {
			p = positions;
			positions = [];
			positions.push(p);
		}
		
		for (p = 0; p < positions.length; p += 1) {
			i = positions[p];
			if (words[i] !== undefined) {
				words[i] = words[i].substr(0, 1).toUpperCase() +
					words[i].substr(1);
			}
		}
		return words.join(" ");
	}
379184
def edits1(word):
    ""
    letters = 'qwertyuiopasdfghjklzxcvbnm'
    splits = [(word[:i], word[i:]) for i in range(len(word) + 1)]
    print('splits = ', splits)
    deletes = [L + R[1:] for L, R in splits if R]
    print('deletes = ', deletes)
    transposes = [L + R[1] + R[0] + R[2:] for L, R in splits if len(R) > 1]
    print('transposes = ', transposes)
    replaces = [L + c + R[1:] for L, R in splits if R for c in letters]
    print('replaces = ', replaces)
    inserts = [L + c + R for L, R in splits for c in letters]
    print('inserts = ', inserts)
    print(deletes + transposes + replaces + inserts)
    print(len(set(deletes + transposes + replaces + inserts)))
    return deletes + transposes + replaces + inserts
190306
def _get(self, word1, word2):
        
        key = self._WSEP.join([self._sanitize(word1), self._sanitize(word2)])
        key = key.lower()
        if key not in self._db:
            return

        return sample(self._db[key], 1)[0]
1232993
def censor(self, input_text):
        """"""
        bad_words = self.get_profane_words()
        res = input_text

        for word in bad_words:
            # Apply word boundaries to the bad word
            regex_string = r'{0}' if self._no_word_boundaries else r'\b{0}\b'
            regex_string = regex_string.format(word)  
            regex = re.compile(regex_string, re.IGNORECASE)
            res = regex.sub(self._censor_char * len(word), res)

        return res
558350
def join(self, words):
        """"""
        chars = list(u"".join(words))
        start = True

        for i in xrange(len(chars)):
            char = chars[i]
            if char.isalpha():
                if start:
                    chars[i] = char.upper()
                else:
                    chars[i] = char.lower()

                start = False
            else:
                if i > 2 and chars[i - 1] in ".?!" and char.isspace():
                    start = True

        return u"".join(chars)
1359491
def _cover2exprs(inputs, noutputs, cover):
    """"""
    fs = list()
    for i in range(noutputs):
        terms = list()
        for invec, outvec in cover:
            if outvec[i]:
                term = list()
                for j, v in enumerate(inputs):
                    if invec[j] == 1:
                        term.append(~v)
                    elif invec[j] == 2:
                        term.append(v)
                terms.append(term)
        fs.append(Or(*[And(*term) for term in terms]))

    return tuple(fs)
655719
function (words, length) {
		words = words || this.exports.generate.integer(10, 52);
		var ret = this.exports.generate.word();
		for (var i = 0; i < words; ++i) {
			ret += ' ' + this.exports.generate.word();
			if (this.exports.generate.integer(0, 100) <= 10) {
				ret += '.';
			}
			else if (this.exports.generate.integer(0, 100) <= 20) {
				ret += ',';
			}
			if (ret.length + 10 >= length) {
				ret += ' ' + this.exports.generate.word((length - ret.length) - 2);
				break;
			}
		}
		ret += '.';
		return ret;
	}
889638
function unit(input){
  var word = S(input).stripPunctuation().s.toLowerCase().trim();
  if(!word){ return 0; }
  if(word.length <= 3) { return 1; }
  word = word.replace(/(?:[^laeiouy]es|ed|[^laeiouy]e)$/, '');
  word = word.replace(/^y/, '');
  var syllbs = word.match(/[aeiouy]{1,2}/g);
  return (syllbs ? syllbs.length : 0);
}
443201
def build_input_data(sentences, labels, vocabulary):
    """"""
    x = np.array([[vocabulary[word] for word in sentence] for sentence in sentences])
    y = np.array(labels)
    return [x, y]
1161617
def align(self,inputwords, outputwords):
        """"""
        alignment = []
        cursor = 0
        for inputword in inputwords:
            if len(outputwords) > cursor and outputwords[cursor] == inputword:
                alignment.append(cursor)
                cursor += 1
            elif len(outputwords) > cursor+1 and outputwords[cursor+1] == inputword:
                alignment.append(cursor+1)
                cursor += 2
            else:
                alignment.append(None)
                cursor += 1
        return alignment
319600
def generate_clinamen(self, input_word, list_of_dict_words, swerve):
        
 
        results = []
        selected_list = []
        for i in list_of_dict_words: #produce a subset for efficency
            if len(i) < len(input_word)+1 and len(i) > len(input_word)/2:
                if '_' not in i:
                    selected_list.append(i)
        for i in selected_list:
            match = self.damerau_levenshtein_distance(input_word,i)
            if match == swerve:
                results.append(i)
        results = {'input' : input_word, 'results' : results, 'category' : 'clinamen'} 
        return results
1085567
def _updateWordSet(self):
        
        self._wordSet = set(self._keywords) | set(self._customCompletions)

        start = time.time()

        for line in self._qpart.lines:
            for match in _wordRegExp.findall(line):
                self._wordSet.add(match)
            if time.time() - start > self._WORD_SET_UPDATE_MAX_TIME_SEC:
                """It is better to have incomplete word set, than to freeze the GUI"""
                break
1266667
def split_into_words(s):
  """"""
  s = re.sub(r"\W+", " ", s)
  s = re.sub(r"[_0-9]+", " ", s)
  return s.split()
151654
def _bounded(p1, p2, line, pos, line_no, lines):
    """"""
    substrings = []
    start_line_no = line_no
    end = pos
    while not line.startswith(p2, end):
        if line[end] == '\\':
            end += 2
        else:
            end += 1
        if end >= len(line):
            substrings.append(line[pos:])
            try:
                line_no, line = next(lines)
            except StopIteration:
                pattern = 'docstring' if p1 == '"""' else 'block comment'
                raise TdlParsingError('Unterminated {}'.format(pattern),
                                      line_number=start_line_no)
            pos = end = 0
    substrings.append(line[pos:end])
    end += len(p2)
    return ''.join(substrings), start_line_no, line_no, line, end
927004
function computeWords(text) {
    var words = text.split(/\s+/g); // To hyphenate: /\s+|(?<=-)/
    if (!words[words.length - 1]) words.pop();
    if (!words[0]) words.shift();
    return words;
}