mirror of https://github.com/doccano/doccano.git
pythondatasetsactive-learningtext-annotationdatasetnatural-language-processingdata-labelingmachine-learningannotation-tool
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
1.2 KiB
32 lines
1.2 KiB
from django.test import TestCase
|
|
from mixer.backend.django import mixer
|
|
from ..serializers import LabelSerializer
|
|
|
|
from ..models import Label, DocumentAnnotation, SequenceAnnotation, Seq2seqAnnotation
|
|
from ..serializers import ClassificationDocumentSerializer, DocumentAnnotationSerializer
|
|
from ..serializers import SequenceDocumentSerializer, SequenceAnnotationSerializer
|
|
from ..serializers import Seq2seqDocumentSerializer, Seq2seqAnnotationSerializer
|
|
|
|
|
|
class TestLabelSerializer(TestCase):
|
|
|
|
def test_create(self):
|
|
label = mixer.blend('server.Label')
|
|
serializer = LabelSerializer(label)
|
|
self.assertIsInstance(serializer.data, dict)
|
|
|
|
def test_annotation(self):
|
|
from rest_framework import serializers
|
|
from ..models import Seq2seqDocument
|
|
class HogeSerializer(serializers.ModelSerializer):
|
|
seq2seq_annotations = Seq2seqAnnotationSerializer(many=True)
|
|
|
|
class Meta:
|
|
model = Seq2seqDocument
|
|
fields = ('id', 'text', 'seq2seq_annotations')
|
|
|
|
doc = mixer.blend('server.Seq2seqDocument')
|
|
ann = mixer.blend('server.Seq2seqAnnotation')
|
|
doc.seq2seq_annotations.add(ann)
|
|
serializer = HogeSerializer(doc)
|
|
print(serializer.data)
|