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.

26 lines
1.2 KiB

  1. import { AnnotationApplicationService } from '../annotationApplicationService'
  2. import { SequenceLabelingDTO } from './sequenceLabelingData'
  3. import { APISequenceLabelingRepository } from '~/repositories/tasks/sequenceLabeling/apiSequenceLabeling'
  4. import { SequenceLabelingLabel } from '~/domain/models/tasks/sequenceLabeling'
  5. export class SequenceLabelingApplicationService extends AnnotationApplicationService<SequenceLabelingLabel> {
  6. constructor(
  7. readonly repository: APISequenceLabelingRepository
  8. ) {
  9. super(new APISequenceLabelingRepository())
  10. }
  11. public async list(projectId: string, docId: number): Promise<SequenceLabelingDTO[]> {
  12. const items = await this.repository.list(projectId, docId)
  13. return items.map(item => new SequenceLabelingDTO(item))
  14. }
  15. public async create(projectId: string, docId: number, labelId: number, startOffset: number, endOffset: number): Promise<void> {
  16. const item = new SequenceLabelingLabel(0, labelId, 0, startOffset, endOffset)
  17. await this.repository.create(projectId, docId, item)
  18. }
  19. public async changeLabel(projectId: string, docId: number, annotationId: number, labelId: number): Promise<void> {
  20. await this.repository.update(projectId, docId, annotationId, labelId)
  21. }
  22. }