Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Audio transcript review #11

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
.DS_Store
.AppleDouble
.LSOverride
env/
*.wav
.env
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe the env/ and .env lines can be removed since they should already be git-ignored:

doccano/.gitignore

Lines 114 to 121 in 5942bbf

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/


# Icon must end with two \r
Icon
Expand Down Expand Up @@ -200,3 +203,4 @@ bundle/
webpack-stats.json

.vscode
local.env
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider moving this to the # Environments block in the git-ignore file to maintain a nice organization of the file.

12 changes: 9 additions & 3 deletions app/api/filters.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
from django.db.models import Count, Q
from django_filters.rest_framework import FilterSet, BooleanFilter
from django_filters.rest_framework import FilterSet, BooleanFilter, NumberFilter

from .models import Document
from .models import Document, ConversationItem


class DocumentFilter(FilterSet):
seq_annotations__isnull = BooleanFilter(field_name='seq_annotations', method='filter_annotations')
doc_annotations__isnull = BooleanFilter(field_name='doc_annotations', method='filter_annotations')
seq2seq_annotations__isnull = BooleanFilter(field_name='seq2seq_annotations', method='filter_annotations')
conversation = NumberFilter(method='filter_conversation')

def filter_conversation(self, queryset, name, value):
if value:
return queryset.filter(conversationitem__conversation=value)
return queryset

def filter_annotations(self, queryset, field_name, value):
queryset = queryset.annotate(num_annotations=
Expand All @@ -24,6 +30,6 @@ def filter_annotations(self, queryset, field_name, value):

class Meta:
model = Document
fields = ('project', 'text', 'meta', 'created_at', 'updated_at',
fields = ('project', 'conversation', 'text', 'meta', 'created_at', 'updated_at',
'doc_annotations__label__id', 'seq_annotations__label__id',
'doc_annotations__isnull', 'seq_annotations__isnull', 'seq2seq_annotations__isnull')
47 changes: 47 additions & 0 deletions app/api/migrations/0002_auto_20191218_0134.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Generated by Django 2.1.11 on 2019-12-18 01:34
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider squashing these migrations (see manage.py squashmigrations) so that we have a single/atomic migration for the new functionality.


from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('api', '0001_initial'),
]

operations = [
migrations.CreateModel(
name='Conversation',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('meta', models.TextField(default='{}')),
('created_at', models.DateTimeField(auto_now_add=True)),
('updated_at', models.DateTimeField(auto_now=True)),
('audio_url', models.TextField(default='')),
('audio_file', models.FileField(upload_to='')),
('documents', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='conversation', to='api.Document')),
],
),
migrations.CreateModel(
name='ConversationsProject',
fields=[
('project_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='api.Project')),
],
options={
'abstract': False,
'base_manager_name': 'objects',
},
bases=('api.project',),
),
migrations.AlterField(
model_name='project',
name='project_type',
field=models.CharField(choices=[('DocumentClassification', 'document classification'), ('SequenceLabeling', 'sequence labeling'), ('Seq2seq', 'sequence to sequence'), ('Conversations', 'conversations validation and labelling')], max_length=30),
),
migrations.AddField(
model_name='conversation',
name='project',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='conversations', to='api.ConversationsProject'),
),
]
22 changes: 22 additions & 0 deletions app/api/migrations/0003_auto_20191218_0203.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Generated by Django 2.1.11 on 2019-12-18 02:03

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('api', '0002_auto_20191218_0134'),
]

operations = [
migrations.RenameField(
model_name='conversation',
old_name='documents',
new_name='document',
),
migrations.AlterUniqueTogether(
name='conversation',
unique_together={('project', 'document')},
),
]
36 changes: 36 additions & 0 deletions app/api/migrations/0004_auto_20191218_0244.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Generated by Django 2.1.11 on 2019-12-18 02:44

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('api', '0003_auto_20191218_0203'),
]

operations = [
migrations.CreateModel(
name='ConversationItem',
fields=[
('document_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='api.Document')),
('start_timestamp', models.TimeField()),
('end_timestamp', models.TimeField()),
],
bases=('api.document',),
),
migrations.AlterUniqueTogether(
name='conversation',
unique_together=set(),
),
migrations.AddField(
model_name='conversationitem',
name='conversation',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='conversation_item', to='api.Conversation'),
),
migrations.RemoveField(
model_name='conversation',
name='document',
),
]
60 changes: 60 additions & 0 deletions app/api/migrations/0005_auto_20191218_1704.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Generated by Django 2.1.11 on 2019-12-18 17:04

from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone


class Migration(migrations.Migration):

dependencies = [
('contenttypes', '0002_remove_content_type_name'),
('api', '0004_auto_20191218_0244'),
]

operations = [
migrations.AlterModelOptions(
name='conversationitem',
options={'base_manager_name': 'objects'},
),
migrations.AlterModelOptions(
name='document',
options={'base_manager_name': 'objects'},
),
migrations.RemoveField(
model_name='conversationitem',
name='end_timestamp',
),
migrations.RemoveField(
model_name='conversationitem',
name='start_timestamp',
),
migrations.AddField(
model_name='conversationitem',
name='end_time',
field=models.FloatField(default=0),
preserve_default=False,
),
migrations.AddField(
model_name='conversationitem',
name='machine_text',
field=models.TextField(default=''),
preserve_default=False,
),
migrations.AddField(
model_name='conversationitem',
name='start_time',
field=models.FloatField(default=0),
preserve_default=False,
),
migrations.AddField(
model_name='document',
name='polymorphic_ctype',
field=models.ForeignKey(editable=False, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='polymorphic_api.document_set+', to='contenttypes.ContentType'),
),
migrations.AlterField(
model_name='conversationitem',
name='conversation',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='conversation_items', to='api.Conversation'),
),
]
47 changes: 47 additions & 0 deletions app/api/migrations/0006_auto_20191218_1740.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Generated by Django 2.1.11 on 2019-12-18 17:40

from django.conf import settings
import django.contrib.postgres.fields.jsonb
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('api', '0005_auto_20191218_1704'),
]

operations = [
migrations.CreateModel(
name='ConversationItemAnnotation',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('prob', models.FloatField(default=0.0)),
('manual', models.BooleanField(default=False)),
('created_at', models.DateTimeField(auto_now_add=True)),
('updated_at', models.DateTimeField(auto_now=True)),
('text', models.TextField()),
('start_offset', models.IntegerField()),
('end_offset', models.IntegerField()),
('document', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='conversation_annotations', to='api.Document')),
('label', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='api.Label')),
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
),
migrations.AlterField(
model_name='conversation',
name='audio_file',
field=models.FileField(upload_to='audio'),
),
migrations.AlterField(
model_name='conversation',
name='meta',
field=django.contrib.postgres.fields.jsonb.JSONField(blank=True),
),
migrations.AlterUniqueTogether(
name='conversationitemannotation',
unique_together={('start_offset', 'end_offset', 'label', 'document')},
),
]
18 changes: 18 additions & 0 deletions app/api/migrations/0007_conversationitem_text_validated.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 2.1.11 on 2019-12-19 00:05

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('api', '0006_auto_20191218_1740'),
]

operations = [
migrations.AddField(
model_name='conversationitem',
name='text_validated',
field=models.BooleanField(default=False),
),
]
18 changes: 18 additions & 0 deletions app/api/migrations/0008_auto_20191220_1329.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 2.1.11 on 2019-12-20 13:29

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('api', '0007_conversationitem_text_validated'),
]

operations = [
migrations.AlterField(
model_name='conversation',
name='meta',
field=models.TextField(default='{}'),
),
]
23 changes: 23 additions & 0 deletions app/api/migrations/0009_auto_20200113_0950.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 2.1.11 on 2020-01-13 09:50

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('api', '0008_auto_20191220_1329'),
]

operations = [
migrations.RenameField(
model_name='conversationitem',
old_name='text_validated',
new_name='is_validated',
),
migrations.AddField(
model_name='conversationitem',
name='is_ignored',
field=models.BooleanField(default=False),
),
]
Loading