# -*- coding: utf-8 -*-
# $Id: Keywords.py 1634 2013-04-12 15:36:36Z amelung $
#
# Copyright (c) 2007-2011 Otto-von-Guericke-Universität Magdeburg
#
# This file is part of ECSpooler.
import logging
# local imports
#from backends.keywords import config
# input schema
'inverted',
'the keywords must not appear in the text and '
'matches result in a lower score.',
),
'keywords',
#accessor = # must return a list; default is one element per line
),
))
# test environsments
'keywords',
),
'regexp',
),
))
"""
The keywords backends was designed to give an example of how
simple a backend can be implemented. This backend checks wether
or not a given number of keywords is used within a student's
submission. Therefore regulare expressions will be created and
executed. The result is a numeric value between 0 and 100 percent;
depending on how many keywords were actually found. As an
altenative teachers can also define regular expressions which will
be executed with the student's submission.
"""
"""
"""
# -- internal methods used by subclasses ----------------------------------
"""
Executes a test job using the given test data in job.
@param: job: a BackendJob
@return: a BackendResult
@see: lib.Backend._process_execute
@see: lib.data.BackendJob, lib.data.BackendResult
"""
try:
except Exception, e:
#log.error(traceback.format_exc())
#log.debug('Returning result: %s' % repr(result))
return result
# -- run tests ------------------------------------------------------------
"""
For each keyowrd given by the teacher a regular expression
will be created and executed with the student's submission.
@return: a BackendResult object
"""
# test for available test specs
msg = 'No test specification selected.'
# test for defined repeat fields in the schema definition
assert repeatFields, 'No RepeatField found.'
# test for available test data
msg = 'No test data defined.'
# we have some test data -> lets start the evaluation
UnicodeType), \
"Tests require valid 'student solution' (%s)" % \
# define default result values
#feedback = BackendResult.UNKNOWN
#solved = 0 # percentage of keywords found
# run selected tests (e.g., "simple", cf. schema definition)
# run with all test data
for t in testdata:
try:
# t contains a keyword or a regular expression
# submission contains the text
matches += 1
except Exception, e:
msg = 'Internal error during test: %s: %s' % \
# end inner for loop
#end outer for loop
solved = 0
# -- some testing -------------------------------------------------------------
if __name__ == "__main__":
"""
"""
if (lenTestdata) != 0:
print "solved:", solved