예제 #1
0
def grade_2a(text):
    import text_coherence

    # weights
    weight_2nd_person = -1
    weight_3rd_person_good = 1
    weight_3rd_person_bad = -2
    weight_3rd_person_avg = .5
    weight_sen = .2

    pronoun_biz = text_coherence.parse(text)

    first_person_pronouns = []
    second_person_pronouns = []
    third_person_pronouns = []

    score = 0

    for sentence in pronoun_biz:
        first_person_pronouns += sentence[0]
        second_person_pronouns += sentence[1]
        third_person_pronouns += sentence[2]
        for third_person_pronoun in third_person_pronouns:
            if third_person_pronoun[1] == -1:
                score += (weight_3rd_person_bad)
            elif third_person_pronoun[1] == .5:
                score += (weight_3rd_person_avg)
            else:
                score += (weight_3rd_person_good)

    return max(1, min(5, (2 + (weight_2nd_person * len(second_person_pronouns)) + score + (len(pronoun_biz) * weight_sen))))
예제 #2
0
def grade_2a(text):
    import text_coherence

    # weights
    weight_2nd_person = -1
    weight_3rd_person_good = 1
    weight_3rd_person_bad = -2
    weight_3rd_person_avg = .5
    weight_sen = .2

    pronoun_biz = text_coherence.parse(text)

    first_person_pronouns = []
    second_person_pronouns = []
    third_person_pronouns = []

    score = 0

    for sentence in pronoun_biz:
        first_person_pronouns += sentence[0]
        second_person_pronouns += sentence[1]
        third_person_pronouns += sentence[2]
        for third_person_pronoun in third_person_pronouns:
            if third_person_pronoun[1] == -1:
                score += (weight_3rd_person_bad)
            elif third_person_pronoun[1] == .5:
                score += (weight_3rd_person_avg)
            else:
                score += (weight_3rd_person_good)

    return max(
        1,
        min(5, (2 + (weight_2nd_person * len(second_person_pronouns)) + score +
                (len(pronoun_biz) * weight_sen))))
예제 #3
0
    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
    print "----------\n"

    total = 0
예제 #4
0
    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
    print "----------\n"

    total = 0