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.

118 lines
3.5 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. get taskNames(): string[] {
  49. if (this.projectType === 'IntentDetectionAndSlotFilling') {
  50. return [
  51. 'DocumentClassification',
  52. 'SequenceLabeling',
  53. ]
  54. }
  55. return [this.projectType]
  56. }
  57. }
  58. export class ProjectWriteItem {
  59. constructor(
  60. public id: number,
  61. public name: string,
  62. public description: string,
  63. public guideline: string,
  64. public project_type: ProjectType,
  65. public random_order: boolean,
  66. public collaborative_annotation: boolean,
  67. public single_class_classification: boolean,
  68. public allow_overlapping: boolean,
  69. public grapheme_mode: boolean
  70. ) {}
  71. get resourceType(): string {
  72. const mapping = {
  73. DocumentClassification: 'TextClassificationProject',
  74. SequenceLabeling : 'SequenceLabelingProject',
  75. Seq2seq : 'Seq2seqProject',
  76. IntentDetectionAndSlotFilling: 'IntentDetectionAndSlotFillingProject',
  77. ImageClassification : 'ImageClassificationProject',
  78. Speech2text : 'Speech2textProject',
  79. }
  80. return mapping[this.project_type]
  81. }
  82. toObject(): Object {
  83. return {
  84. id: this.id,
  85. name: this.name,
  86. description: this.description,
  87. guideline: this.guideline,
  88. project_type: this.project_type,
  89. random_order: this.random_order,
  90. collaborative_annotation: this.collaborative_annotation,
  91. single_class_classification: this.single_class_classification,
  92. allow_overlapping: this.allow_overlapping,
  93. grapheme_mode: this.grapheme_mode,
  94. resourcetype: this.resourceType
  95. }
  96. }
  97. }