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.
40 lines
1.5 KiB
40 lines
1.5 KiB
import { AnnotationRepository } from '@/domain/models/tasks/annotationRepository'
|
|
import { SegmentationItem } from '~/domain/models/tasks/segmentation'
|
|
|
|
export class ApiSegmentationRepository extends AnnotationRepository<SegmentationItem> {
|
|
constructor() {
|
|
super(SegmentationItem)
|
|
}
|
|
|
|
async list(projectId: string, exampleId: number): Promise<SegmentationItem[]> {
|
|
const url = `/projects/${projectId}/examples/${exampleId}/segments`
|
|
const response = await this.request.get(url)
|
|
return response.data.map((box: any) => SegmentationItem.valueOf(box))
|
|
}
|
|
|
|
async create(projectId: string, exampleId: number, item: SegmentationItem): Promise<void> {
|
|
const url = `/projects/${projectId}/examples/${exampleId}/segments`
|
|
await this.request.post(url, item.toObject())
|
|
}
|
|
|
|
async update(
|
|
projectId: string,
|
|
exampleId: number,
|
|
boxId: number,
|
|
item: SegmentationItem
|
|
): Promise<SegmentationItem> {
|
|
const url = `/projects/${projectId}/examples/${exampleId}/segments/${boxId}`
|
|
const response = await this.request.patch(url, item.toObject())
|
|
return SegmentationItem.valueOf(response.data)
|
|
}
|
|
|
|
async delete(projectId: string, exampleId: number, boxId: number): Promise<void> {
|
|
const url = `/projects/${projectId}/examples/${exampleId}/segments/${boxId}`
|
|
await this.request.delete(url)
|
|
}
|
|
|
|
async bulkDelete(projectId: string, exampleId: number, boxIds: number[]): Promise<void> {
|
|
const url = `/projects/${projectId}/examples/${exampleId}/segments`
|
|
await this.request.delete(url, { ids: boxIds })
|
|
}
|
|
}
|