def grade_1b(text): import agreement_utils rs = agreement_utils.parse(text) num_agreements, num_non_agreements, num_unsure = rs num_agreements_tested = sum(rs) if num_agreements_tested == 0: log("No possible agreements found in text", 2) return 0 else: log("Sub Scores: %s" % (rs,), 2) prob = float(num_agreements) / sum(rs) log("%d/%d -> %f" % (num_agreements, sum(rs), prob), 2) return floor(prob * 5)
def grade_1b(text): import agreement_utils rs = agreement_utils.parse(text) num_agreements, num_non_agreements, num_unsure = rs num_agreements_tested = sum(rs) if num_agreements_tested == 0: log("No possible agreements found in text", 2) return 0 else: log("Sub Scores: %s" % (rs, ), 2) prob = float(num_agreements) / sum(rs) log("%d/%d -> %f" % (num_agreements, sum(rs), prob), 2) return floor(prob * 5)
elif syntactic_formation_stdin: import syntactic_formation import math text = cmd_utils.get_stdin().strip() sentence_problems = syntactic_formation.parse(text) num_sentences_with_problems = sum([1 if count > 0 else 0 for count in sentence_problems]) num_sentences = len(sentence_problems) print "Num Sentences: {0}".format(num_sentences) print "Num Problems: {0}".format(sum(sentence_problems)) print "Sentences with problems: {0}".format(num_sentences_with_problems) print "Percent Correct: {0}/{1} ({2})".format(num_sentences - num_sentences_with_problems, num_sentences, 1 - (float(num_sentences_with_problems)/num_sentences)) print "Score: {0}".format(math.floor((1 - (float(num_sentences_with_problems)/num_sentences)) * 5)) elif agreement_stdin: import agreement_utils text = cmd_utils.get_stdin().strip() print agreement_utils.parse(text) elif pronoun_stdin: import text_coherence text = cmd_utils.get_stdin().strip() print text_coherence.parse(text) elif topic_stdin: import topic_coherence text = cmd_utils.get_stdin().strip() print topic_coherence.parse(text) elif final_score_stdin: import grade_utils text = cmd_utils.get_stdin().strip() print "Grading" print "----------" print text
num_sentences_with_problems = sum( [1 if count > 0 else 0 for count in sentence_problems]) num_sentences = len(sentence_problems) print "Num Sentences: {0}".format(num_sentences) print "Num Problems: {0}".format(sum(sentence_problems)) print "Sentences with problems: {0}".format(num_sentences_with_problems) print "Percent Correct: {0}/{1} ({2})".format( num_sentences - num_sentences_with_problems, num_sentences, 1 - (float(num_sentences_with_problems) / num_sentences)) print "Score: {0}".format( math.floor( (1 - (float(num_sentences_with_problems) / num_sentences)) * 5)) elif agreement_stdin: import agreement_utils text = cmd_utils.get_stdin().strip() print agreement_utils.parse(text) elif pronoun_stdin: import text_coherence text = cmd_utils.get_stdin().strip() print text_coherence.parse(text) elif topic_stdin: import topic_coherence text = cmd_utils.get_stdin().strip() print topic_coherence.parse(text) elif final_score_stdin: import grade_utils text = cmd_utils.get_stdin().strip() print "Grading" print "----------" print text