Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
ease
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
ease
Commits
44738c16
Commit
44738c16
authored
Nov 28, 2012
by
Vik Paruchuri
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pull templating and path assignment out of ML functions
parent
91b194c0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
73 deletions
+17
-73
create.py
+5
-8
grade.py
+12
-65
No files found.
create.py
View file @
44738c16
...
...
@@ -11,7 +11,6 @@ import model_creator
import
util_functions
def
create
(
text
,
score
,
prompt_string
,
model_path
):
model_path
=
util_functions
.
create_model_path
(
model_path
)
results
=
{
'errors'
:
[],
'created'
:
False
}
try
:
...
...
@@ -22,15 +21,13 @@ def create(text,score,prompt_string,model_path):
feature_ext
,
classifier
=
model_creator
.
extract_features_and_generate_model
(
e_set
)
except
:
results
[
'errors'
]
.
append
(
"feature extraction and model creation failed."
)
full_path
=
os
.
path
.
join
(
base_path
,
model_path
)
util_functions
.
create_directory
(
full_path
)
model_creator
.
dump_model_to_file
(
prompt_string
,
feature_ext
,
classifier
,
text
,
score
,
full_path
)
results
[
'created'
]
=
True
"""
try
:
full_path
=
os
.
path
.
join
(
base_path
,
model_path
)
util_functions
.
create_directory
(
full_path
)
model_creator
.
dump_model_to_file
(
prompt_string
,
feature_ext
,
classifier
,
text
,
score
,
full_path
)
results
[
'created'
]
=
True
except
:
results
[
'errors'
]
.
append
(
"could not write model to: {0}"
.
format
(
model_path
))
"""
return
results
...
...
grade.py
View file @
44738c16
...
...
@@ -25,62 +25,9 @@ log = logging.getLogger(__name__)
TEMPORARY_WANTS_CONFIG
=
True
feedback_template
=
u"""
<section>
<header>Feedback</header>
<div class="shortform">
<div class="result-output">
<p>Score: {score}</p>
<p>Number of potential problem areas identified: {problem_areas}</p>
</div>
</div>
<div class="longform">
<div class="result-output">
<div class="topicality">
Topicality: {topicality}
</div>
<div class="prompt_overlap">
Prompt Overlap : {prompt_overlap}
</div>
<div class="spelling">
Spelling: {spelling}
</div>
<div class="grammar">
Grammar: {grammar}
</div>
<div class="markup-text">
{markup_text}
</div>
</div>
</div>
</section>
"""
error_template
=
u"""
<section>
<div class="shortform">
<div class="result-errors">
There was an error with your submission. Please contact course staff.
</div>
</div>
<div class="longform">
<div class="result-errors">
{errors}
</div>
</div>
</section>
"""
def
grade
(
grader_path
,
grader_config
,
submission
,
sandbox
=
None
):
grader_path
=
os
.
path
.
join
(
base_path
,
util_functions
.
create_model_path
(
grader_path
))
log
.
debug
(
"Grader path: {0}
\n
Submission: {1}"
.
format
(
grader_path
,
submission
))
results
=
{
'errors'
:
[],
'tests'
:
[],
'score'
:
0
,
'feedback'
:
""
,
'success'
:
False
}
has_error
=
False
...
...
@@ -125,20 +72,20 @@ def grade(grader_path,grader_config,submission,sandbox=None):
if
tag
is
not
'markup_text'
:
problem_areas
+=
len
(
feedback
[
tag
])
>
5
#Add feedback t
emplate t
o results
results
[
'feedback'
]
=
feedback_template
.
format
(
topicality
=
feedback
[
'topicality'
],
spelling
=
feedback
[
'spelling'
],
grammar
=
feedback
[
'grammar'
],
markup_text
=
feedback
[
'markup_text'
],
problem_areas
=
problem_areas
,
score
=
results
[
'score'
],
prompt_overlap
=
feedback
[
'prompt_overlap'
],
)
#Add feedback to results
results
[
'feedback'
]
=
{
'topicality'
:
feedback
[
'topicality'
],
'spelling'
:
feedback
[
'spelling'
],
'grammar'
:
feedback
[
'grammar'
],
'markup_text'
:
feedback
[
'markup_text'
],
'problem_areas'
:
problem_areas
,
'score'
:
results
[
'score'
],
'prompt_overlap'
:
feedback
[
'prompt_overlap'
],
}
else
:
#If error,
add errors to templat
e.
results
[
'
feedback'
]
=
error_template
.
format
(
errors
=
' '
.
join
(
results
[
'errors'
]))
#If error,
success is Fals
e.
results
[
'
success'
]
=
False
return
results
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment