Commit 412a6ad3 by Vik Paruchuri

Change tags used for grammar and spelling to not have spaces. Modify grade and…

Change tags used for grammar and spelling to not have spaces.  Modify grade and create to append .p to passed in model path
parent 9ad3a9ef
......@@ -10,6 +10,9 @@ sys.path.append(one_up_path)
import model_creator
def create(text,scores,prompt,model_path):
if not model_path.endswith(".p"):
model_path+=".p"
results = {'errors': [],'created' : False}
try:
e_set = model_creator.create_essay_set(text, score, prompt_string)
......
......@@ -210,12 +210,12 @@ class FeatureExtractor(object):
bad_pos_ends=[z[1]-1 for z in bad_pos_positions[m]]
for z in xrange(0,len(markup_tokens)):
if z in bad_pos_starts:
markup_tokens[z]='<feedback class="badgrammar">' + markup_tokens[z]
markup_tokens[z]='<bg>' + markup_tokens[z]
elif z in bad_pos_ends:
markup_tokens[z]=markup_tokens[z] + "</feedback>"
markup_tokens[z]=markup_tokens[z] + "</bg>"
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):
markup_tokens[len(markup_tokens)-1]+="</feedback>"
markup_tokens[len(markup_tokens)-1]+="</bg>"
if set_grammar_per_character[m]>(self._grammar_errors_per_character*modifier_ratio):
individual_feedback['grammar']="Potential grammar errors."
......
......@@ -22,6 +22,8 @@ import sklearn.ensemble
log = logging.getLogger(__name__)
TEMPORARY_WANTS_CONFIG=True
feedback_template = u"""
<header>Feedback</header>
......@@ -69,7 +71,10 @@ error_template = u"""
"""
def grade(grader_path,submission,sandbox=None):
def grade(grader_path,grader_config,submission,sandbox=None):
if not grader_path.endswith(".p"):
model_path+=".p"
log.debug("Grader path: {0}\n Submission: {1}".format(grader_path,submission))
results = {'errors': [],'tests': [],'correct': False,'score': 0, 'feedback' : ""}
......
......@@ -90,7 +90,7 @@ def spell_correct(string):
sub_comp = re.compile(sub_pat)
newstring = re.sub(sub_comp, correct_spelling[i], newstring)
if incorrect_words[i] not in already_subbed:
markup_string=re.sub(sub_comp,'<feedback class="badspelling">' + incorrect_words[i] + "</feedback>", markup_string)
markup_string=re.sub(sub_comp,'<bs>' + incorrect_words[i] + "</bs>", markup_string)
already_subbed.append(incorrect_words[i])
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