Skip to content

Commit

Permalink
Final formatting changes to source files
Browse files Browse the repository at this point in the history
  • Loading branch information
Rahul-Khanna committed Sep 29, 2020
1 parent dc1cfb6 commit ec8c542
Show file tree
Hide file tree
Showing 15 changed files with 343 additions and 575 deletions.
45 changes: 0 additions & 45 deletions annotation/src/server/admin.py

This file was deleted.

5 changes: 0 additions & 5 deletions annotation/src/server/managers.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import json
from django.db import models
# from django.db import connection

from django.db.models import Prefetch
from .constants import NAMED_ENTITY_RECOGNITION_VALUE, RELATION_EXTRACTION_VALUE, SENTIMENT_ANALYSIS_VALUE
from .utils import convert_task_name_to_annotation_type, convert_explanation_int_to_explanation_type, SPACY_WRAPPER
Expand Down Expand Up @@ -208,7 +206,4 @@ def get_project_docs_with_labels(self, project_id):
project_docs = queryset.filter(project_id=project_id) \
.prefetch_related("annotations__label",
"annotations__user")
# project_docs = queryset.filter(project_id=project_id) \
# .prefetch_related("annotations__label__text",
# "annotations__user__username")
return project_docs
8 changes: 1 addition & 7 deletions annotation/src/server/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def get_absolute_url(self):
def get_documents(self):
return self.documents.all()

# # don't love this, the need to update annotated, but I conceed here
# don't love this, the need to update annotated, but I conceed here
def get_annotated_documents(self):
docs = self.documents.all()
docs = docs.filter(annotated=True)
Expand Down Expand Up @@ -80,10 +80,6 @@ def get_annotation_serializer(self):
def get_dataset_for_user(self, user_id, explanation, explanation_type):
if self.task.name == NAMED_ENTITY_RECOGNITION_VALUE:
return Document.objects.export_ner_project_user_documents(self.id, user_id, explanation, explanation_type)

# TODO: add ability to get dataset by project
# def get_data_set(self):
# Annotation.objects.raw()

def __str__(self):
return self.name
Expand Down Expand Up @@ -259,7 +255,6 @@ class NamedEntityAnnotation(models.Model):
start_offset = models.PositiveIntegerField()
end_offset = models.PositiveIntegerField()

# TODO: need to make sure start and end are less than length
def clean(self):
if self.start_offset >= self.end_offset:
raise ValidationError('start_offset is after end_offset')
Expand Down Expand Up @@ -302,7 +297,6 @@ class SentimentAnalysisAnnotation(models.Model):
annotation = models.OneToOneField(to=Annotation, on_delete=models.CASCADE, related_name='sentiment_analysis_annotation', primary_key=True)


# TODO: phrases per trigger must be sorted by start_offset before insertion
class TriggerExplanation(models.Model):
annotation = models.ForeignKey(to=Annotation, on_delete=models.CASCADE, related_name='trigger_explanations')
trigger_id = models.PositiveIntegerField()
Expand Down
4 changes: 0 additions & 4 deletions annotation/src/server/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ class Meta:


class ProjectSerializer(serializers.ModelSerializer):
# TODO: would like to see what the users field looks like
class Meta:
model = Project
fields = ('id', 'name', 'description', 'guideline', 'users', 'task', 'image', 'updated_at', 'explanation_type')
Expand All @@ -40,7 +39,6 @@ class Meta:
fields = ('id', 'text', 'shortcut', 'background_color', 'text_color')


# # TODO: Strange that this is for a group of docs
class DocumentSerializer(serializers.ModelSerializer):
def __init__(self, *args, **kwargs):
many = kwargs.pop('many', True)
Expand Down Expand Up @@ -68,8 +66,6 @@ def create(self, validated_data):

class Meta:
model = Annotation
# fields = ('id', 'prob', 'via_recommendation', 'task', 'document', 'user', 'label',
# 'extended_annotation', 'raw_explanations', 'formatted_explanations')
fields = ('id', 'via_recommendation', 'label')


Expand Down
42 changes: 0 additions & 42 deletions annotation/src/server/static/js/state.js

This file was deleted.

66 changes: 33 additions & 33 deletions annotation/src/server/templates/admin/admin_base.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,28 @@
{% endblock %}
{% block navigation %}
<span id="headers">
<a class="navbar-item" href="{% url 'annotation' view.kwargs.project_id %}">
<span class="icon">
<i class="fas fa-user-edit"></i>
</span>
{% comment %} <div id="headers"> {% endcomment %}
<b>[[ annotationHeading ]]</b>
{% comment %} </div> {% endcomment %}
</a>
<a class="navbar-item" href="{% url 'upload' view.kwargs.project_id %}">
<span class="icon">
<i class="fas fa-upload"></i>
</span>
{% comment %} <div id="headers"> {% endcomment %}
<b>[[ importDataHeading ]]</b>
{% comment %} </div> {% endcomment %}
</a>
<a class="navbar-item" href="{% url 'download' view.kwargs.project_id %}">
<span class="icon">
<i class="fas fa-download"></i>
</span>
<b>Export Annotations</b>
</a>
<a class="navbar-item" href="{% url 'annotation' view.kwargs.project_id %}">
<span class="icon">
<i class="fas fa-user-edit"></i>
</span>
{% comment %} <div id="headers"> {% endcomment %}
<b>[[ annotationHeading ]]</b>
{% comment %} </div> {% endcomment %}
</a>
<a class="navbar-item" href="{% url 'upload' view.kwargs.project_id %}">
<span class="icon">
<i class="fas fa-upload"></i>
</span>
{% comment %} <div id="headers"> {% endcomment %}
<b>[[ importDataHeading ]]</b>
{% comment %} </div> {% endcomment %}
</a>
<a class="navbar-item" href="{% url 'download' view.kwargs.project_id %}">
<span class="icon">
<i class="fas fa-download"></i>
</span>
<b>Export Annotations</b>
</a>
</span>
{% endblock %}
{% block content %}
Expand Down Expand Up @@ -69,17 +69,17 @@
</aside>
<div class="column is-10 messages hero is-fullheight" id="message-feed">
{% if messages %}
<div>
<article class='message is-danger'>
<div class='message-body'>
<ul>
{% for message in messages %}
<li>{{ message }}</li>
{% endfor %}
</ul>
</div>
</article>
</div>
<div>
<article class='message is-danger'>
<div class='message-body'>
<ul>
{% for message in messages %}
<li>{{ message }}</li>
{% endfor %}
</ul>
</div>
</article>
</div>
{% endif %}
{% block content-area %}{% endblock %}
</div>
Expand Down
23 changes: 15 additions & 8 deletions annotation/src/server/templates/admin/annotation_history.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,13 @@
</header>
<div class="card-content">
<ul>
<li>You can upload a json file of seed annotations to be matched to current unlabled examples as recommendations for the annotator.</li>
<li>You can choose to <b>merge</b> your uploaded file or <b>replace</b> all previously uploaded annotations. <b>Note:</b> this will not delete previous annotator
provided annotations, just the previously uploaded annotations from this process.</li>
<li><b>It is imperative</b> that the <b>label names match the label space</b> you created. We will lower case and match names, so case-sensitivity is not needed.</li>
<li>You can upload a json file of seed annotations to be matched to current unlabled examples as recommendations
for the annotator.</li>
<li>You can choose to <b>merge</b> your uploaded file or <b>replace</b> all previously uploaded annotations.
<b>Note:</b> this will not delete previous annotator
provided annotations, just the previously uploaded annotations from this process.</li>
<li><b>It is imperative</b> that the <b>label names match the label space</b> you created. We will lower case and
match names, so case-sensitivity is not needed.</li>
<li>The format of the file you must upload is as follows:</li>
</ul>
<pre>
Expand Down Expand Up @@ -50,7 +53,8 @@
<div class="field" style="display: inline-block">
<div class="file is-small has-name">
<label class="file-label">
<input id="file-upload" class="file-input" type="file" ref="file" name="dataset" v-on:change="updateFileName()">
<input id="file-upload" class="file-input" type="file" ref="file" name="dataset"
v-on:change="updateFileName()">
<span class="file-cta">
<span class="file-icon">
<i class="fas fa-upload"></i>
Expand All @@ -66,9 +70,12 @@
</div>
</div>
<div class="buttons" style="display: inline-block">
<button class="button is-small is-success" v-bind:disabled="!canUpload" v-on:click="uploadFile('merge')">Merge</button>
<button class="button is-small is-warning" v-bind:disabled="!canUpload" v-on:click="uploadFile('replace')">Replace</button>
<button class="button is-small is-primary" style="font-size: 0.8rem" v-show="leadUserToAnnotation" v-on:click="goToAnnotations()"><b>Continue To Annotations</b></button>
<button class="button is-small is-success" v-bind:disabled="!canUpload"
v-on:click="uploadFile('merge')">Merge</button>
<button class="button is-small is-warning" v-bind:disabled="!canUpload"
v-on:click="uploadFile('replace')">Replace</button>
<button class="button is-small is-primary" style="font-size: 0.8rem" v-show="leadUserToAnnotation"
v-on:click="goToAnnotations()"><b>Continue To Annotations</b></button>
</div>
<div v-show="errorMessage.length > 0">
${errorMessage}
Expand Down
Loading

0 comments on commit ec8c542

Please sign in to comment.