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.

108 lines
3.3 KiB

  1. import { Expose } from 'class-transformer'
  2. export type ProjectType = 'DocumentClassification' | 'SequenceLabeling' | 'Seq2seq' | 'IntentDetectionAndSlotFilling' | 'ImageClassification' | 'Speech2text'
  3. export class ProjectReadItem {
  4. id: number;
  5. name: string;
  6. description: string;
  7. guideline: string;
  8. users: number[];
  9. tags: Object[];
  10. @Expose({ name: 'project_type' })
  11. projectType: ProjectType;
  12. @Expose({ name: 'updated_at' })
  13. updatedAt: string;
  14. @Expose({ name: 'random_order' })
  15. randomOrder: boolean;
  16. @Expose({ name: 'collaborative_annotation' })
  17. collaborative_annotation: boolean;
  18. @Expose({ name: 'single_class_classification' })
  19. exclusiveCategories: boolean;
  20. @Expose({ name: 'resourcetype' })
  21. resourceType: string;
  22. @Expose({ name: 'allow_overlapping' })
  23. allowOverlapping: boolean;
  24. @Expose({ name: 'grapheme_mode' })
  25. graphemeMode: boolean;
  26. @Expose({ name: 'is_text_project'})
  27. isTextProject: boolean;
  28. @Expose({ name: 'can_define_label' })
  29. canDefineLabel: boolean;
  30. @Expose({ name: 'can_define_relation' })
  31. canDefineRelation: boolean;
  32. @Expose({ name: 'can_define_span'})
  33. canDefineSpan: boolean;
  34. @Expose({ name: 'can_define_category' })
  35. canDefineCategory: boolean;
  36. get annotationPageLink(): string {
  37. const mapping = {
  38. DocumentClassification: 'text-classification',
  39. SequenceLabeling : 'sequence-labeling',
  40. Seq2seq : 'sequence-to-sequence',
  41. IntentDetectionAndSlotFilling: 'intent-detection-and-slot-filling',
  42. ImageClassification : 'image-classification',
  43. Speech2text : 'speech-to-text',
  44. }
  45. const url = `/projects/${this.id}/${mapping[this.projectType]}`
  46. return url
  47. }
  48. }
  49. export class ProjectWriteItem {
  50. constructor(
  51. public id: number,
  52. public name: string,
  53. public description: string,
  54. public guideline: string,
  55. public project_type: ProjectType,
  56. public random_order: boolean,
  57. public collaborative_annotation: boolean,
  58. public single_class_classification: boolean,
  59. public allow_overlapping: boolean,
  60. public grapheme_mode: boolean
  61. ) {}
  62. get resourceType(): string {
  63. const mapping = {
  64. DocumentClassification: 'TextClassificationProject',
  65. SequenceLabeling : 'SequenceLabelingProject',
  66. Seq2seq : 'Seq2seqProject',
  67. IntentDetectionAndSlotFilling: 'IntentDetectionAndSlotFillingProject',
  68. ImageClassification : 'ImageClassificationProject',
  69. Speech2text : 'Speech2textProject',
  70. }
  71. return mapping[this.project_type]
  72. }
  73. toObject(): Object {
  74. return {
  75. id: this.id,
  76. name: this.name,
  77. description: this.description,
  78. guideline: this.guideline,
  79. project_type: this.project_type,
  80. random_order: this.random_order,
  81. collaborative_annotation: this.collaborative_annotation,
  82. single_class_classification: this.single_class_classification,
  83. allow_overlapping: this.allow_overlapping,
  84. grapheme_mode: this.grapheme_mode,
  85. resourcetype: this.resourceType
  86. }
  87. }
  88. }