mirror of https://github.com/doccano/doccano.git
pythondatasetnatural-language-processingdata-labelingmachine-learningannotation-tooldatasetsactive-learningtext-annotation
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.
39 lines
1.2 KiB
39 lines
1.2 KiB
import { AnnotationApplicationService } from '../annotationApplicationService'
|
|
import { SegmentationDTO } from './segmentationData'
|
|
import { Segment } from '@/domain/models/tasks/segmentation'
|
|
|
|
export class SegmentationApplicationService extends AnnotationApplicationService<Segment> {
|
|
public async list(projectId: string, exampleId: number): Promise<SegmentationDTO[]> {
|
|
const items = await this.repository.list(projectId, exampleId)
|
|
return items.map((item) => new SegmentationDTO(item))
|
|
}
|
|
|
|
public async create(
|
|
projectId: string,
|
|
exampleId: number,
|
|
uuid: string,
|
|
label: number,
|
|
points: number[]
|
|
): Promise<void> {
|
|
const item = new Segment(0, uuid, label, points)
|
|
try {
|
|
await this.repository.create(projectId, exampleId, item)
|
|
} catch (e: any) {
|
|
console.log(e.response.data.detail)
|
|
}
|
|
}
|
|
|
|
public async update(
|
|
projectId: string,
|
|
exampleId: number,
|
|
annotationId: number,
|
|
item: SegmentationDTO
|
|
): Promise<void> {
|
|
const bbox = new Segment(item.id, item.uuid, item.label, item.points)
|
|
try {
|
|
await this.repository.update(projectId, exampleId, annotationId, bbox)
|
|
} catch (e: any) {
|
|
console.log(e.response.data.detail)
|
|
}
|
|
}
|
|
}
|