Commit 6f6617ba by Vik Paruchuri

Fix problem area pluralization by rewording text, use span tags instead of…

Fix problem area pluralization by rewording text, use span tags instead of custom tags for spell/grammar.
parent 5e05459f
...@@ -210,12 +210,12 @@ class FeatureExtractor(object): ...@@ -210,12 +210,12 @@ class FeatureExtractor(object):
bad_pos_ends=[z[1]-1 for z in bad_pos_positions[m]] bad_pos_ends=[z[1]-1 for z in bad_pos_positions[m]]
for z in xrange(0,len(markup_tokens)): for z in xrange(0,len(markup_tokens)):
if z in bad_pos_starts: if z in bad_pos_starts:
markup_tokens[z]="<badgrammar>" + markup_tokens[z] markup_tokens[z]='<span class="badgrammar">' + markup_tokens[z]
elif z in bad_pos_ends: elif z in bad_pos_ends:
markup_tokens[z]=markup_tokens[z] + "</badgrammar>" markup_tokens[z]=markup_tokens[z] + "</span>"
if(len(bad_pos_ends)>0 and len(bad_pos_starts)>0 and len(markup_tokens)>1): if(len(bad_pos_ends)>0 and len(bad_pos_starts)>0 and len(markup_tokens)>1):
if max(bad_pos_ends)>(len(markup_tokens)-1) and max(bad_pos_starts)<(len(markup_tokens)-1): if max(bad_pos_ends)>(len(markup_tokens)-1) and max(bad_pos_starts)<(len(markup_tokens)-1):
markup_tokens[len(markup_tokens)-1]+="</badgrammar>" markup_tokens[len(markup_tokens)-1]+="</span>"
if set_grammar_per_character[m]>(self._grammar_errors_per_character*modifier_ratio): if set_grammar_per_character[m]>(self._grammar_errors_per_character*modifier_ratio):
individual_feedback['grammar']="Potential grammar errors." individual_feedback['grammar']="Potential grammar errors."
......
...@@ -28,7 +28,7 @@ feedback_template = u""" ...@@ -28,7 +28,7 @@ feedback_template = u"""
<section> <section>
<div class="shortform"> <div class="shortform">
<div class="result-output"> <div class="result-output">
There are {problem_areas} potential problem areas in your submission. Number of potential problem areas identified: {problem_areas}
</div> </div>
</div> </div>
<div class="longform"> <div class="longform">
...@@ -104,6 +104,7 @@ def grade(grader_path,submission,sandbox=None): ...@@ -104,6 +104,7 @@ def grade(grader_path,submission,sandbox=None):
#Generate short form output--number of problem areas identified in feedback #Generate short form output--number of problem areas identified in feedback
problem_areas=0 problem_areas=0
for tag in feedback: for tag in feedback:
if tag is not 'markup_text':
problem_areas+=len(feedback[tag])>5 problem_areas+=len(feedback[tag])>5
#Determine maximum score and correctness of response #Determine maximum score and correctness of response
......
...@@ -90,7 +90,7 @@ def spell_correct(string): ...@@ -90,7 +90,7 @@ def spell_correct(string):
sub_comp = re.compile(sub_pat) sub_comp = re.compile(sub_pat)
newstring = re.sub(sub_comp, correct_spelling[i], newstring) newstring = re.sub(sub_comp, correct_spelling[i], newstring)
if incorrect_words[i] not in already_subbed: if incorrect_words[i] not in already_subbed:
markup_string=re.sub(sub_comp,"<badspelling>" + incorrect_words[i] + "</badspelling>", markup_string) markup_string=re.sub(sub_comp,'<span class="badspelling">' + incorrect_words[i] + "</span>", markup_string)
already_subbed.append(incorrect_words[i]) already_subbed.append(incorrect_words[i])
return newstring,len(incorrect_words),markup_string return newstring,len(incorrect_words),markup_string
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment