def annotate_single_unlabeled(request): """ save the labeled annotation to DB :return: """ # read file text = request.POST.get("text", "") label = request.POST.get("label", "") uuid = request.POST.get("uuid", "") ca = get_mongo_client(uri='mongodb://localhost:27017/') raw_text = ca["annotation_raw_data"].find_one({"uuid": uuid}) if raw_text: ca["annotation_raw_data"].update({"uuid": uuid}, {"$set": { "labeled": True }}) annotation_data = AnnotationData( text=text, label=label, uuid=uuid, dataset_uuid=raw_text.get("dataset_uuid")) annotation_data_serializer = AnnotationDataSerializer(annotation_data) ca["annotation_data"].insert_one(annotation_data_serializer.data) response = APIResponse() response.data = {"status": "success"} response.code = 200 response.message = "SUCCESS" serializer = APIResponseSerializer(response) return JsonResponse(serializer.data)
def create(self, validated_data): """ Create and return a new `Snippet` instance, given the validated data. """ return AnnotationData(**validated_data)