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
19010224
Commit
19010224
authored
Nov 15, 2012
by
Vik Paruchuri
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add in ability to check if model file exists.
parent
ab6de5d9
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
4 deletions
+25
-4
create.py
+12
-2
grade.py
+2
-2
util_functions.py
+11
-0
No files found.
create.py
View file @
19010224
...
...
@@ -8,10 +8,10 @@ one_up_path = os.path.abspath(os.path.join(os.path.dirname(__file__),'..'))
sys
.
path
.
append
(
one_up_path
)
import
model_creator
import
util_functions
def
create
(
text
,
scores
,
prompt
,
model_path
):
if
not
model_path
.
endswith
(
".p"
):
model_path
+=
".p"
model_path
=
util_functions
.
create_model_path
(
model_path
)
results
=
{
'errors'
:
[],
'created'
:
False
}
try
:
...
...
@@ -30,4 +30,14 @@ def create(text,scores,prompt,model_path):
return
results
def
check
(
model_path
):
model_path
=
util_functions
.
create_model_path
(
model_path
)
try
:
with
open
(
model_path
)
as
f
:
pass
except
IOError
as
e
:
return
False
return
True
grade.py
View file @
19010224
...
...
@@ -15,6 +15,7 @@ base_path = os.path.dirname(__file__)
sys
.
path
.
append
(
base_path
)
from
essay_set
import
EssaySet
import
util_functions
#Imports needed to unpickle grader data
import
feature_extractor
...
...
@@ -73,8 +74,7 @@ error_template = u"""
def
grade
(
grader_path
,
grader_config
,
submission
,
sandbox
=
None
):
if
not
grader_path
.
endswith
(
".p"
):
grader_path
+=
".p"
grader_path
=
util_functions
.
create_model_path
(
grader_path
)
log
.
debug
(
"Grader path: {0}
\n
Submission: {1}"
.
format
(
grader_path
,
submission
))
results
=
{
'errors'
:
[],
'tests'
:
[],
'correct'
:
False
,
'score'
:
0
,
'feedback'
:
""
}
...
...
util_functions.py
View file @
19010224
...
...
@@ -13,6 +13,17 @@ import nltk
import
random
import
pickle
def
create_model_path
(
model_path
):
if
not
model_path
.
startswith
(
"/"
)
and
not
model_path
.
startswith
(
"models/"
):
model_path
=
"/"
+
model_path
if
not
model
.
path
.
startswith
(
"models"
):
model_path
=
"models"
+
model_path
if
not
model_path
.
endswith
(
".p"
):
model_path
+=
".p"
return
model_path
def
sub_chars
(
string
):
"""
Strips illegal characters from a string. Used to sanitize input essays.
...
...
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