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
a5ba0de3
Commit
a5ba0de3
authored
Oct 25, 2012
by
Vik Paruchuri
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added maximum essay length check to prevent abuse
parent
b9137228
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
1 deletions
+6
-1
essay_set.py
+6
-1
No files found.
essay_set.py
View file @
a5ba0de3
...
...
@@ -13,6 +13,7 @@ base_path = os.path.dirname(__file__)
sys
.
path
.
append
(
base_path
)
import
util_functions
MAXIMUM_ESSAY_LENGTH
=
20000
class
EssaySet
(
object
):
def
__init__
(
self
,
type
=
"train"
):
...
...
@@ -52,7 +53,11 @@ class EssaySet(object):
self
.
_id
.
append
(
max_id
+
1
)
self
.
_score
.
append
(
essay_score
)
# Clean text by removing non digit/work/punctuation characters
self
.
_text
.
append
(
util_functions
.
sub_chars
(
essay_text
)
.
lower
())
cleaned_essay
=
util_functions
.
sub_chars
(
essay_text
)
.
lower
()
if
(
len
(
cleaned_essay
)
>
MAXIMUM_ESSAY_LENGTH
):
raise
util_functions
.
InputError
(
essay_text
,
(
"essay longer than {0} characters."
.
format
(
MAXIMUM_ESSAY_LENGTH
)))
self
.
_text
.
append
(
cleaned_essay
)
# Spell correct text using aspell
self
.
_clean_text
.
append
(
util_functions
.
spell_correct
(
self
.
_text
[
len
(
self
.
_text
)
-
1
]))
# Tokenize text
...
...
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