|
15 | 15 | from rest_framework_csv.renderers import CSVRenderer |
16 | 16 |
|
17 | 17 | from .filters import DocumentFilter |
18 | | -from .models import Project, Label, Document |
| 18 | +from .models import Project, Label, Document, Seq2seqAnnotation |
19 | 19 | from .permissions import IsAdminUserAndWriteOnly, IsProjectUser, IsOwnAnnotation |
20 | 20 | from .serializers import ProjectSerializer, LabelSerializer, DocumentSerializer, UserSerializer |
21 | 21 | from .serializers import ProjectPolymorphicSerializer |
@@ -90,9 +90,14 @@ def label_per_data(self, project): |
90 | 90 | annotation_class = project.get_annotation_class() |
91 | 91 | docs = project.documents.all() |
92 | 92 | annotations = annotation_class.objects.filter(document_id__in=docs.all()) |
93 | | - for d in annotations.values('label__text', 'user__username').annotate(Count('label'), Count('user')): |
94 | | - label_count[d['label__text']] += d['label__count'] |
95 | | - user_count[d['user__username']] += d['user__count'] |
| 93 | + if annotation_class == Seq2seqAnnotation: |
| 94 | + for d in annotations.values('text', 'user__username').annotate(Count('text'), Count('user')): |
| 95 | + label_count[d['text']] += d['text__count'] |
| 96 | + user_count[d['user__username']] += d['user__count'] |
| 97 | + else: |
| 98 | + for d in annotations.values('label__text', 'user__username').annotate(Count('label'), Count('user')): |
| 99 | + label_count[d['label__text']] += d['label__count'] |
| 100 | + user_count[d['user__username']] += d['user__count'] |
96 | 101 | return label_count, user_count |
97 | 102 |
|
98 | 103 |
|
|
0 commit comments