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
e1e52e8f
Commit
e1e52e8f
authored
Nov 15, 2012
by
Vik Paruchuri
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add directory creation for model file if it isn't found
parent
19010224
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
3 deletions
+11
-3
create.py
+2
-1
util_functions.py
+9
-2
No files found.
create.py
View file @
e1e52e8f
...
...
@@ -10,7 +10,7 @@ sys.path.append(one_up_path)
import
model_creator
import
util_functions
def
create
(
text
,
score
s
,
prompt
,
model_path
):
def
create
(
text
,
score
,
prompt_string
,
model_path
):
model_path
=
util_functions
.
create_model_path
(
model_path
)
results
=
{
'errors'
:
[],
'created'
:
False
}
...
...
@@ -23,6 +23,7 @@ def create(text,scores,prompt,model_path):
except
:
results
[
'errors'
]
.
append
(
"feature extraction and model creation failed."
)
try
:
util_functions
.
create_directory
(
model_path
)
model_creator
.
dump_model_to_file
(
prompt_string
,
feature_ext
,
classifier
,
text
,
score
,
args
.
model_path
)
results
[
'created'
]
=
True
except
:
...
...
util_functions.py
View file @
e1e52e8f
...
...
@@ -12,18 +12,25 @@ import math
import
nltk
import
random
import
pickle
from
path
import
path
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"
):
if
not
model
_
path
.
startswith
(
"models"
):
model_path
=
"models"
+
model_path
if
not
model_path
.
endswith
(
".p"
):
model_path
+=
".p"
return
model_path
def
create_directory
(
model_path
):
directory
=
path
(
model_path
)
.
dirname
()
if
not
os
.
path
.
exists
(
directory
):
os
.
makedirs
(
directory
)
return
True
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