Skip to content

Commit

Permalink
Started adapting the error classification
Browse files Browse the repository at this point in the history
The fields in html are now dynamic
  • Loading branch information
David Vilar committed Sep 17, 2012
1 parent ea6a290 commit a2cfe12
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 20 deletions.
2 changes: 1 addition & 1 deletion appraise/bin/addEvaluationTask.py
Expand Up @@ -25,7 +25,7 @@ def print_help(self):
optparse.OptionParser.print_help(self)
out = sys.stdout
out.write("\nFollowing task types are recognized:\n")
out.write("\n".join(["\t%s" % t for t in validTaskTypes.keys()]))
out.write("\n".join(["\t%s" % t for t in taskTypes.keys()]))
out.write("\nNote that the types are case-insensitive\n")

optionParser = customHelpOptionParser(usage="%s [options] -n <NAME> -t <TASKTYPE> -s <SYSTEMS> -l <LANGUAGE> -c <CORPUS> -u <USERS>" % os.environ["ESMT_PROG_NAME"], add_help_option=False)
Expand Down
15 changes: 14 additions & 1 deletion appraise/evaluation/models.py
Expand Up @@ -40,7 +40,7 @@
class EvaluationTask(models.Model):
"""
Evaluation Task object model.
"""
: """
task_id = models.CharField(
max_length=32,
db_index=True,
Expand Down Expand Up @@ -409,6 +409,19 @@ class SelectAndPostEditResult(NewEvaluationResult):
fromScratch = models.BooleanField()
system = models.ForeignKey(corpusM.TranslationSystem, null=True)

class ErrorClassificationResult(NewEvaluationResult):
tooManyErrors = models.BooleanField()
missingWords = models.BooleanField()

class ErrorClassificationType(models.Model):
name = models.CharField(max_length=100)

class _ErrorClassificationEntry(models.Model):
type = models.ForeignKey(ErrorClassificationType)
isSevere = models.BooleanField()
wordPosition = models.IntegerField()
result = models.ForeignKey(ErrorClassificationResult)

class EvaluationResult(models.Model):
"""
Evaluation Result object model.
Expand Down
14 changes: 8 additions & 6 deletions appraise/evaluation/views.py
Expand Up @@ -27,8 +27,9 @@
LOGGER.addHandler(LOG_HANDLER)


ERROR_CLASSES = ("terminology", "lexical_choice", "syntax", "insertion",
"morphology", "misspelling", "punctuation", "other")
ERROR_CLASSES = ["terminology", "lexical choice", "syntax", "insertion",
"morphology", "misspelling", "punctuation", "other"]
#ERROR_CLASSES = ["aaa", "bbb", "ccc"];


def _save_results(item, user, duration, raw_result):
Expand Down Expand Up @@ -78,8 +79,8 @@ def _compute_context_for_item(item):
source_text = [None, None, None]
reference_text = [None, None, None]

left_context = EvaluationItem.objects.filter(task=item.task, pk=item.id-1)
right_context = EvaluationItem.objects.filter(task=item.task, pk=item.id+1)
#left_context = EvaluationItem.objects.filter(task=item.task, pk=item.id-1)
#right_context = EvaluationItem.objects.filter(task=item.task, pk=item.id+1)

sourceSentenceId = item.source_sentence.id
sourceDocument = item.source_sentence.document
Expand Down Expand Up @@ -444,13 +445,14 @@ def _handle_error_classification(request, task, items):
source_text, reference_text = _compute_context_for_item(item)
_finished, _total = task.get_finished_for_user(request.user)

translation = item.translations[0][0]
words = item.translations[0][0].split(' ')
translation = item.translations[0].text
words = translation.split(' ')
dictionary = {'title': 'Error Classification', 'item_id': item.id,
'source_text': source_text, 'reference_text': reference_text,
'translation': translation,
'words': words,
'description': task.description,
'error_classes': ERROR_CLASSES,
'task_progress': '{0:03d}/{1:03d}'.format(_finished+1, _total),
'action_url': request.path, 'commit_tag': COMMIT_TAG}

Expand Down
5 changes: 2 additions & 3 deletions appraise/templates/evaluation/error_classification.html
Expand Up @@ -10,8 +10,7 @@
<script src="/appraise/site_media/jquery-1.7.1.min.js"></script>
<script>
<!--
var ERROR_CLASSES = ["terminology", "lexical_choice", "syntax", "insertion",
"morphology", "misspelling", "punctuation", "other"];
var ERROR_CLASSES = {{error_classes|safe}};

$(document).ready(function() {
for (var i=0; i<{{words|length}}; i++)
Expand All @@ -25,7 +24,7 @@
function update_error_summary()
{
var _errors = new Array();
for (var i=0; i<ERROR_CLASSES.length; i++) {
for (var i=0; i<{{error_classes|length}}; i++) {
_total_errors_of_this_class = 0;
for (var j=0; j<{{words|length}}; j++) {
var _error = $('input[name="'+ERROR_CLASSES[i]+'_'+j+'"]:checked').val();
Expand Down
16 changes: 7 additions & 9 deletions appraise/templates/evaluation/word_classification.html
@@ -1,11 +1,9 @@
<span id="edit_{{word_id}}" style="display:none;">
<span class="error-class">Terminology:</span> <input type="radio" name="terminology_{{word_id}}" value="NONE" checked="checked" /> None <input type="radio" name="terminology_{{word_id}}" value="MINOR" /> Minor <input type="radio" name="terminology_{{word_id}}" value="SEVERE" /> Severe<br/>
<span class="error-class">Lexical choice:</span> <input type="radio" name="lexical_choice_{{word_id}}" value="NONE" checked="checked" /> None <input type="radio" name="lexical_choice_{{word_id}}" value="MINOR" /> Minor <input type="radio" name="lexical_choice_{{word_id}}" value="SEVERE" /> Severe<br/>
<span class="error-class">Syntax (ordering):</span> <input type="radio" name="syntax_{{word_id}}" value="NONE" checked="checked" /> None <input type="radio" name="syntax_{{word_id}}" value="MINOR" /> Minor <input type="radio" name="syntax_{{word_id}}" value="SEVERE" /> Severe<br/>
<span class="error-class">Insertion (extra word):</span> <input type="radio" name="insertion_{{word_id}}" value="NONE" checked="checked" /> None <input type="radio" name="insertion_{{word_id}}" value="MINOR" /> Minor <input type="radio" name="insertion_{{word_id}}" value="SEVERE" /> Severe<br/>
<span class="error-class">Morphology:</span> <input type="radio" name="morphology_{{word_id}}" value="NONE" checked="checked" /> None <input type="radio" name="morphology_{{word_id}}" value="MINOR" /> Minor <input type="radio" name="morphology_{{word_id}}" value="SEVERE" /> Severe<br/>
<span class="error-class">Misspelling:</span> <input type="radio" name="misspelling_{{word_id}}" value="NONE" checked="checked" /> None <input type="radio" name="misspelling_{{word_id}}" value="MINOR" /> Minor <input type="radio" name="misspelling_{{word_id}}" value="SEVERE" /> Severe<br/>
<span class="error-class">Punctuation:</span> <input type="radio" name="punctuation_{{word_id}}" value="NONE" checked="checked" /> None <input type="radio" name="punctuation_{{word_id}}" value="MINOR" /> Minor <input type="radio" name="punctuation_{{word_id}}" value="SEVERE" /> Severe<br/>
<span class="error-class">Other (idiom, etc.):</span> <input type="radio" name="other_{{word_id}}" value="NONE" checked="checked" /> None <input type="radio" name="other_{{word_id}}" value="MINOR" /> Minor <input type="radio" name="other_{{word_id}}" value="SEVERE" /> Severe<br/>
{% for error_class in error_classes %}
<span class="error-class">{{error_class}}</span>
<input type="radio" name="{{error_class}}_{{word_id}}" value="NONE" checked="checked" /> None
<input type="radio" name="{{error_class}}_{{word_id}}" value="MINOR" /> Minor
<input type="radio" name="{{error_class}}_{{word_id}}" value="SEVERE" /> Severe<br/>
{% endfor %}
</span>
<span id="view_{{word_id}}" onclick="javascript:toggle_classification({{word_id}});"></span>
<span id="view_{{word_id}}" onclick="javascript:toggle_classification({{word_id}});"></span>

0 comments on commit a2cfe12

Please sign in to comment.