Be smart, attempt to fix what the user wrote.
484625
private function fixSmartSearch($value)
    {
        //
        // OK, this needs some bits of explaination. We have the following behavior:
        //
        //   - in a site, there's a lot of city names in text,
        //   - lots are "Saint-Something",
        //   - when the client types "Saint A" in the search query, all
        //     "Saint Something" will match, and "Saint" will have a higher
        //     score than "A",
        //
        // To fix this, we convert every "any number of words" queries to:
        //
        //     @todo separate with the first 2
        //     "any number of words"^20 or "any number"^20 or (any number of words)^1
        //
        // Which literally means:
        //
        //     "The phrase with all the words in the right order matches 10 times
        //     more score than those with all the words placed anywhere in any
        //     order."
        //
        // And it does seem to fix it, now "Saint A" comes first in the results
        // instead of being lowered than text with many times the name "Saint".
        //
        $value = trim($value);

        if (\preg_match('/^[^\+\(\)"]+$/ims', $value)) {
            return '"'.$value.'"^10 or ('.$value.')^1';
        }

        return $value;
    }
1079283
function fixUnicode(txt) {
    txt = txt.replace(/\003/g, ' ');
    txt = txt.replace(/\004/g, ' ');
    txt = txt.replace(/(\r|\n)/g, ' ');
    txt = txt.replace(/[\u007f-\uffff]/g, function (c) {
        return '\\u' + ('0000' + c.charCodeAt(0).toString(16)).slice(-4);
    });
    return txt;
}
1310366
def fix_e131(self, result):
        """"""
        num_indent_spaces = int(result['info'].split()[1])
        line_index = result['line'] - 1
        target = self.source[line_index]

        spaces_to_add = num_indent_spaces - len(_get_indentation(target))

        if spaces_to_add >= 0:
            self.source[line_index] = (' ' * spaces_to_add +
                                       self.source[line_index])
        else:
            offset = abs(spaces_to_add)
            self.source[line_index] = self.source[line_index][offset:]
957487
function writePrompt () {
        charm.position(1,1);
        charm.display('bright');
        charm.write(promptStart);
        charm.write(' ');
        charm.display('reset');
    }
946416
def _report_spelling_error(error, file_path):
    """"""
    line = error.line_offset + 1
    code = "file/spelling_error"
    description = _SPELLCHECK_MESSAGES[error.error_type].format(error.word)
    if error.suggestions is not None:
        description = (description +
                       ", perhaps you meant: " +
                       ", ".join(error.suggestions))

    sys.stdout.write("{0}:{1} [{2}] {3}\n".format(file_path,
                                                  line,
                                                  code,
                                                  description))
765014
def fix_e704(self, result):
        """"""
        (line_index, _, target) = get_index_offset_contents(result,
                                                            self.source)
        match = STARTSWITH_DEF_REGEX.match(target)
        if match:
            self.source[line_index] = '{}\n{}{}'.format(
                match.group(0),
                _get_indentation(target) + self.indent_word,
                target[match.end(0):].lstrip())
1248369
public static void fixNoSentences(JCas jCas) {
        Collection<Sentence> sentences = select(jCas, Sentence.class);
        if (sentences.size() == 0) {
            String text = jCas.getDocumentText();
            Sentence sentence = new Sentence(jCas, 0, text.length());
            sentence.addToIndexes();
        }
    }
671799
def correct_entry(self, entry):
        
        entry.correction.update(self.get_correction(entry))
        return entry
544602
def check_sentence():
    """"""
    text = ''
    if request.method == 'POST':
        text = request.form['text']
        if not text:
            error = 'No input'
            flash_message = error
        else:
            fb = check(request.form['text'])
            correct = False
            if request.form.get('is_correct') and not fb.primary_error:
                correct = True
            elif not request.form.get('is_correct') and fb.primary_error:
                correct = True
            sub = Submission(text=text, correct=correct, primary_error=fb.primary_error,
                    specific_error=fb.specific_error)
            session.add(sub)
            session.commit()
            # TODO: remove the hack below
            if not fb.primary_error:
                fb.human_readable = "No errors were found."
            flash_message = fb.human_readable

        flash(flash_message)
    return render_template('check_sentence.html', text=text)
1181731
function shouldCommitValueSemicolon(text, cursorPosition)
        {
            // FIXME: should this account for semicolons inside comments?
            var openQuote = "";
            for (var i = 0; i < cursorPosition; ++i) {
                var ch = text[i];
                if (ch === "\\" && openQuote !== "")
                    ++i; // skip next character inside string
                else if (!openQuote && (ch === "\"" || ch === "'"))
                    openQuote = ch;
                else if (openQuote === ch)
                    openQuote = "";
            }
            return !openQuote;
        }
616194
def fix_e305(self, result):
        """"""
        cr = '\n'
        # check comment line
        offset = result['line'] - 2
        while True:
            if offset < 0:
                break
            line = self.source[offset].lstrip()
            if len(line) == 0:
                break
            if line[0] != '#':
                break
            offset -= 1
        offset += 1
        self.source[offset] = cr + self.source[offset]
283590
def fix_one_step_and_explain(text):
    
    if isinstance(text, bytes):
        raise UnicodeError(BYTES_ERROR_TEXT)
    if len(text) == 0:
        return text, []

    # The first plan is to return ASCII text unchanged.
    if possible_encoding(text, 'ascii'):
        return text, []

    # As we go through the next step, remember the possible encodings
    # that we encounter but don't successfully fix yet. We may need them
    # later.
    possible_1byte_encodings = []

    # Suppose the text was supposed to be UTF-8, but it was decoded using
    # a single-byte encoding instead. When these cases can be fixed, they
    # are usually the correct thing to do, so try them next.
    for encoding in CHARMAP_ENCODINGS:
        if possible_encoding(text, encoding):
            encoded_bytes = text.encode(encoding)
            encode_step = ('encode', encoding, ENCODING_COSTS.get(encoding, 0))
            transcode_steps = []

            # Now, find out if it's UTF-8 (or close enough). Otherwise,
            # remember the encoding for later.
            try:
                decoding = 'utf-8'
                # Check encoded_bytes for sequences that would be UTF-8,
                # except they have b' ' where b'\xa0' would belong.
                if ALTERED_UTF8_RE.search(encoded_bytes):
                    encoded_bytes = restore_byte_a0(encoded_bytes)
                    cost = encoded_bytes.count(0xa0) * 2
                    transcode_steps.append(('transcode', 'restore_byte_a0', cost))

                # Check for the byte 0x1a, which indicates where one of our
                # 'sloppy' codecs found a replacement character.
                if encoding.startswith('sloppy') and 0x1a in encoded_bytes:
                    encoded_bytes = replace_lossy_sequences(encoded_bytes)
                    transcode_steps.append(('transcode', 'replace_lossy_sequences', 0))

                if 0xed in encoded_bytes or 0xc0 in encoded_bytes:
                    decoding = 'utf-8-variants'

                decode_step = ('decode', decoding, 0)
                steps = [encode_step] + transcode_steps + [decode_step]
                fixed = encoded_bytes.decode(decoding)
                return fixed, steps

            except UnicodeDecodeError:
                possible_1byte_encodings.append(encoding)

    # Look for a-hat-euro sequences that remain, and fix them in isolation.
    if PARTIAL_UTF8_PUNCT_RE.search(text):
        steps = [('transcode', 'fix_partial_utf8_punct_in_1252', 1)]
        fixed = fix_partial_utf8_punct_in_1252(text)
        return fixed, steps

    # The next most likely case is that this is Latin-1 that was intended to
    # be read as Windows-1252, because those two encodings in particular are
    # easily confused.
    if 'latin-1' in possible_1byte_encodings:
        if 'windows-1252' in possible_1byte_encodings:
            # This text is in the intersection of Latin-1 and
            # Windows-1252, so it's probably legit.
            return text, []
        else:
            # Otherwise, it means we have characters that are in Latin-1 but
            # not in Windows-1252. Those are C1 control characters. Nobody
            # wants those. Assume they were meant to be Windows-1252. Don't
            # use the sloppy codec, because bad Windows-1252 characters are
            # a bad sign.
            encoded = text.encode('latin-1')
            try:
                fixed = encoded.decode('windows-1252')
                steps = []
                if fixed != text:
                    steps = [('encode', 'latin-1', 0),
                             ('decode', 'windows-1252', 1)]
                return fixed, steps
            except UnicodeDecodeError:
                # This text contained characters that don't even make sense
                # if you assume they were supposed to be Windows-1252. In
                # that case, let's not assume anything.
                pass

    # The cases that remain are mixups between two different single-byte
    # encodings, and not the common case of Latin-1 vs. Windows-1252.
    #
    # These cases may be unsolvable without adding false positives, though
    # I have vague ideas about how to optionally address them in the future.

    # Return the text unchanged; the plan is empty.
    return text, []
1353078
private function correctInputs()
    {
        if (($diff = array_diff_key($this->rules, $this->inputs))) {
            foreach ($diff as $key => $value) {
                $this->inputs[ $key ] = '';
            }
        }
    }
206876
def _construct_user_dictionary(global_options, tool_options):
    """"""
    del global_options

    spellchecker_cache_path = tool_options.get("spellcheck_cache", None)
    valid_words_dictionary_helper.create(spellchecker_cache_path)
1135961
def fix_e701(self, result):
        """"""
        line_index = result['line'] - 1
        target = self.source[line_index]
        c = result['column']

        fixed_source = (target[:c] + '\n' +
                        _get_indentation(target) + self.indent_word +
                        target[c:].lstrip('\n\r \t\\'))
        self.source[result['line'] - 1] = fixed_source
        return [result['line'], result['line'] + 1]
353650
def fix(self, value=None):
        

        if value is None:
            self._impl.fix()
        else:
            self._impl.fix(value)
53467
def fix_header_comment(filename, timestamp):
    """"""
    # Fix input file.
    name = os.path.basename( filename )
    for line in fileinput.input( filename, inplace=1, mode="rU" ):
        # If header-comment already contains anything for '$Id$', remove it.
        line = re.sub(r'\$Id:[^$]+\$', r'$Id$', line.rstrip())
        # Replace '$Id$' by a string containing the file's name (and a timestamp)!
        line = re.sub(re.escape(r'$Id$'), r'$Id: ' + name + r' ' + timestamp.isoformat() + r' $', line.rstrip())
        print(line)