Commit c04dc463 by Vik Paruchuri

add feedback mechanism for grammar and spelling errors

parent eff6f5f9
...@@ -43,7 +43,7 @@ class FeatureExtractor(object): ...@@ -43,7 +43,7 @@ class FeatureExtractor(object):
self._mean_spelling_errors=sum(e_set._spelling_errors)/float(len(e_set._spelling_errors)) self._mean_spelling_errors=sum(e_set._spelling_errors)/float(len(e_set._spelling_errors))
self._spell_errors_per_character=sum(e_set._spelling_errors)/float(sum([len(t) for t in e_set._text])) self._spell_errors_per_character=sum(e_set._spelling_errors)/float(sum([len(t) for t in e_set._text]))
self._grammar_errors_per_character=sum(self._get_grammar_errors self._grammar_errors_per_character=sum(self._get_grammar_errors
(e_set._pos,e_set._text,e_set._tokens))/float(len(e_set._text)) (e_set._pos,e_set._text,e_set._tokens))/float(sum([len(t) for t in e_set._text]))
ret = "ok" ret = "ok"
else: else:
raise util_functions.InputError(e_set, "needs to be an essay set of the train type.") raise util_functions.InputError(e_set, "needs to be an essay set of the train type.")
...@@ -157,3 +157,19 @@ class FeatureExtractor(object): ...@@ -157,3 +157,19 @@ class FeatureExtractor(object):
prompt_arr = numpy.array((prompt_overlap, prompt_overlap_prop, expand_overlap, expand_overlap_prop)).transpose() prompt_arr = numpy.array((prompt_overlap, prompt_overlap_prop, expand_overlap, expand_overlap_prop)).transpose()
return prompt_arr.copy() return prompt_arr.copy()
def gen_feedback(self, e_set):
set_grammar=self._get_grammar_errors(e_set._pos,e_set._text,e_set._tokens)
set_grammar_per_character=[set_grammar[m]/len(e_set._text[m]) for m in xrange(0,len(e_set._text))]
set_spell_errors_per_character=[e_set._spelling_errors[m]/len(e_set._text[m]) for m in xrange(0,len(e_set._text))]
e_set._spelling_errors
all_feedback=[]
for m in xrange(0,len(e_set._text)):
individual_feedback=[]
if set_grammar_per_character[m]<self._grammar_errors_per_character:
individual_feedback.append("Potential grammatical errors.")
if set_spell_errors_per_character[m]>self._spell_errors_per_character:
individual_feedback.append("Potential spelling errors.")
all_feedback.append(individual_feedback)
return all_feedback
...@@ -20,7 +20,7 @@ import feature_extractor ...@@ -20,7 +20,7 @@ import feature_extractor
import sklearn.ensemble import sklearn.ensemble
def grade(grader_path,submission,sandbox): def grade(grader_path,submission,sandbox):
results = {'errors': [],'tests': [],'correct': False,'score': 0} results = {'errors': [],'tests': [],'correct': False,'score': 0, 'feedback' : []}
#Try to find and load the model file #Try to find and load the model file
...@@ -40,7 +40,7 @@ def grade(grader_path,submission,sandbox): ...@@ -40,7 +40,7 @@ def grade(grader_path,submission,sandbox):
#Try to extract features from submission and assign score via the model #Try to extract features from submission and assign score via the model
try: try:
grader_feats=grader_data['extractor'].gen_feats(grader_set) grader_feats=grader_data['extractor'].gen_feats(grader_set)
results['feedback']=grader_data['extractor'].gen_feedback(grader_set)
results['score']=int(grader_data['model'].predict(grader_feats)[0]) results['score']=int(grader_data['model'].predict(grader_feats)[0])
except: except:
results['errors'].append("Could not extract features and score essay.") results['errors'].append("Could not extract features and score essay.")
......
in order to replicate this experiment i would need to know , first how to calculate the mass of the samples . i would also need t o know what the four samples are , as if is not stated in the procedure . lastly to repeat this expirement i would need to know how much vinegar was placed into each container . in order to replicate this experiment , additional information is needed . first , the amount of vinegar would be needed . also , the type of wood used would be needed because different woods have different densities . finally , the temperatures of the room , where the solutions sat , needs to be known .
\ No newline at end of file \ No newline at end of file
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