Supply a sentence or fragment and recieve feedback
331647
def check(sentence):
    """"""

    # How we decide what to put as the human readable feedback
    #
    # Our order of prefence is,
    #
    # 1. Spelling errors.
    #   - A spelling error can change the sentence meaning
    # 2. Subject-verb agreement errors
    # 3. Subordinate conjunction starting a sentence
    # 4. Participle phrase fragment
    # 5. Other errors

    result = Feedback()
    is_missing_verb = detect_missing_verb(sentence)
    is_infinitive = detect_infinitive_phrase(sentence)
    is_participle = is_participle_clause_fragment(sentence)
    lang_tool_feedback = get_language_tool_feedback(sentence)
    subject_and_verb_agree = get_subject_verb_agreement_feedback(sentence)
    ####
    if is_missing_verb: # Lowest priority
        result.matches['missing_verb'] = True 
        result.human_readable = MISSING_VERB_ADVICE.replace('\n', '') 
        result.primary_error = 'MISSING_VERB_ERROR'
        result.specific_error = 'MISSING_VERB'
    if is_participle > .5: 
        result.matches['participle_phrase'] = is_participle
        result.human_readable = PARTICIPLE_FRAGMENT_ADVICE.replace('\n', '')
        result.primary_error = 'FRAGMENT_ERROR'
        result.specific_error = 'PARTICIPLE_PHRASE'
    if lang_tool_feedback:
        result.matches['lang_tool'] = lang_tool_feedback
        for ltf in lang_tool_feedback:
            if ltf['rule']['id'] == 'SENTENCE_FRAGMENT':
                result.human_readable = lang_tool_feedback[0]['message']
                result.primary_error = 'FRAGMENT_ERROR'
                result.specific_error = 'SUBORDINATE_CLAUSE'
    if is_infinitive:
        result.matches['infinitive_phrase'] = True 
        result.human_readable = INFINITIVE_PHRASE_ADVICE.replace('\n', '') 
        result.primary_error = 'INFINITIVE_PHRASE_ERROR'
        result.specific_error = 'INFINITIVE_PHRASE'
    if not subject_and_verb_agree:
        result.matches['subject_verb_agreement'] = subject_and_verb_agree
        result.human_readable = SUBJECT_VERB_AGREEMENT_ADVICE.replace('\n', '') 
        result.primary_error = 'SUBJECT_VERB_AGREEMENT_ERROR'
        result.specific_error = 'SUBJECT_VERB_AGREEMENT'
    if lang_tool_feedback: # Highest priority (spelling, other lang tool errors)
        result.matches['lang_tool'] = lang_tool_feedback
        for ltf in lang_tool_feedback:
            if ltf['rule']['id'] == 'MORFOLOGIK_RULE_EN_US':
                result.human_readable = ltf['message']
                result.primary_error = 'SPELLING_ERROR'
                result.specific_error = 'SPELLING_ERROR'
        if not result.primary_error:
            result.human_readable = ltf['message']
            result.primary_error = 'OTHER_ERROR'
            result.specific_error = ltf['rule']['id']

         
    ####
    if not result.matches:
        result.human_readable = STRONG_SENTENCE_ADVICE.replace('\n', '')

    return result
708739
function showIntro() {
    write("Welcome to the Recognizer's Sample console application!");
    write("To try the recognizers enter a phrase and let us show you the different outputs for each recognizer or just type 'exit' to leave the application.");
    write();
    write("Here are some examples you could try:");
    write();
    write("\" I want twenty meters of cable for tomorrow\"");
    write("\" I'll be available tomorrow from 11am to 2pm to receive up to 5kg of sugar\"");
    write("\" I'll be out between 4 and 22 this month\"");
    write("\" I was the fifth person to finish the 10 km race\"");
    write("\" The temperature this night will be of 40 deg celsius\"");
    write("\" The american stock exchange said a seat was sold for down $ 5,000 from the previous sale last friday\"");
    write("\" It happened when the baby was only ten months old\"");
    write("\" No, I don't think that we can make 100k USD today\"");
    write();
}
1074746
@Controller(events = EventType.QUICK_REPLY, pattern = "(yes|no)")
    public void onReceiveQuickReply(Event event) {
        if ("yes".equals(event.getMessage().getQuickReply().getPayload())) {
            reply(event, "Cool! You can type: \n 1) Show Buttons \n 2) Show List \n 3) Setup meeting");
        } else {
            reply(event, "See you soon!");
        }
    }
31904
def sent2features(sentence, template):
    
    return [word2features(sentence, i, template) for i in range(len(sentence))]
552548
def set_global_feedback(feedback, append=False):
    
    rdict = load_feedback()
    rdict['text'] = rdict.get('text', '') + feedback if append else feedback
    save_feedback(rdict)
8701
def listen(self):
        """"""
        while True:
            message = self.pull.recv()
            logger.debug("received message of length %d" % len(message))
            uuid, message = message[:32], message[32:]
            response = uuid + self.handle(message)
            self.push.send(response)
875097
def say_response(speech, end_session = true, ssml = false)
      output_speech = add_speech(speech,ssml)
      { :outputSpeech => output_speech, :shouldEndSession => end_session }
    end
555935
def handle(self,
               t_input: inference.TranslatorInput,
               t_output: inference.TranslatorOutput,
               t_walltime: float = 0.):
        
        line = "{sent_id} ||| {target} ||| {score:f} ||| {source} ||| {source_len:d} ||| {target_len:d}\n"
        self.stream.write(line.format(sent_id=t_input.sentence_id,
                                      target=" ".join(t_output.tokens),
                                      score=t_output.score,
                                      source=" ".join(t_input.tokens),
                                      source_len=len(t_input.tokens),
                                      target_len=len(t_output.tokens)))
        attention_matrix = t_output.attention_matrix.T
        for i in range(0, attention_matrix.shape[0]):
            attention_vector = attention_matrix[i]
            self.stream.write(" ".join(["%f" % value for value in attention_vector]))
            self.stream.write("\n")

        self.stream.write("\n")
        self.stream.flush()
481700
def listen
      perform_with_bot do |bot|
        bot.listen do |message|
          next if message.nil?
          text = message.text
          next if text.nil?
          yield text
        end
      end
    end
1180578
def sent_tokenize(self, text, **kwargs):
        
        sentences = self.sent_tok.tokenize(
            text,
            realign_boundaries=kwargs.get(
                "realign_boundaries",
                True))
        return sentences
1043908
function ask(questions, finish, answers, input, output) {
    finish = finish || function() {};
    input = input || function(cb) {process.stdin.on('data', cb);};
    output = output || function(a) {console.log(a);};

    var i = 0;
    var ret = {};
    var e = questions[0];
    var v = match(ops, e);

    output(getOutput(e, v));
    input(getInput);

    function getOutput(e, v) {
        var o = f.isFunction(v.output)? v.output(e): '';

        return e.q + o;
    }

    function getInput(t) {
        t = t.trim();
        var r = v.exec(t, e);

        if(f.isDefined(r)) {
            ret[e.id] = r;
            i++;

            if(i >= questions.length) {
                // XXX: separate this somehow
                process.stdin.removeListener('data', getInput);
                process.stdin.pause();

                finish(ret);
            }
            else {
                e = questions[i];
                v = match(ops, e);
                output(getOutput(e, v));
            }
        }
    }
}
510148
def participate(self):
        """"""
        try:
            logger.info("Entering participate method")
            ready = WebDriverWait(self.driver, 10).until(
                EC.element_to_be_clickable((By.ID, "finish-reading"))
            )
            stimulus = self.driver.find_element_by_id("stimulus")
            story = stimulus.find_element_by_id("story")
            story_text = story.text
            logger.info("Stimulus text:")
            logger.info(story_text)
            ready.click()
            submit = WebDriverWait(self.driver, 10).until(
                EC.element_to_be_clickable((By.ID, "submit-response"))
            )
            textarea = WebDriverWait(self.driver, 10).until(
                EC.element_to_be_clickable((By.ID, "reproduction"))
            )
            textarea.clear()
            text = self.transform_text(story_text)
            logger.info("Transformed text:")
            logger.info(text)
            textarea.send_keys(text)
            submit.click()
            return True
        except TimeoutException:
            return False
110316
function prompt(question, isYesDefault) {
  if (typeof isYesDefault !== 'boolean') {
    throw new Error(
      'Provide explicit boolean isYesDefault as second argument.'
    );
  }
  return new Promise(resolve => {
    var rlInterface = rl.createInterface({
      input: process.stdin,
      output: process.stdout,
    });

    var hint = isYesDefault === true ? '[Y/n]' : '[y/N]';
    var message = question + ' ' + hint + '\n';

    rlInterface.question(message, function(answer) {
      rlInterface.close();

      var useDefault = answer.trim().length === 0;
      if (useDefault) {
        return resolve(isYesDefault);
      }

      var isYes = answer.match(/^(yes|y)$/i);
      return resolve(isYes);
    });
  });
}
423561
def assist_with(submission)
      @rules
        .select { |it| it.matches?(submission) }
        .map { |it| it.message_for(submission.attemps_count) }
    end
1188549
def get_language_tool_feedback(sentence):
    """"""
    payload = {'language':'en-US', 'text':sentence}
    try:
        r = requests.post(LT_SERVER, data=payload)
    except requests.exceptions.ConnectionError as e:
        raise requests.exceptions.ConnectionError('''The languagetool server is
        not running.  Try starting it with "ltserver" ''')
    if r.status_code >= 200 and r.status_code < 300:
        return r.json().get('matches', [])
    return []
1188631
def echo(bot, update):
    """"""
    message = update.get_effective_message()
    bot.reply(update, message)
382344
def reply(self, text):
        
        # pylint: disable=W0212
        response = self.reddit_session._add_comment(self.fullname, text)
        # pylint: enable=W0212
        urls = [self.reddit_session.config['inbox']]
        if isinstance(self, Comment):
            urls.append(self.submission._api_link)  # pylint: disable=W0212
        elif isinstance(self, Message):
            urls.append(self.reddit_session.config['sent'])
        self.reddit_session.evict(urls)
        return response