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.

85 lines
3.8 KiB

  1. import DownloadSeq2seqCSV from '@/static/formats/seq2seq/download/example.csv'
  2. import DownloadSeq2seqJSONL from '@/static/formats/seq2seq/download/example.jsonl'
  3. import DownloadSequenceLabelingJSONL from '@/static/formats/sequence_labeling/download/example.jsonl'
  4. import DownloadSequenceLabelingJSONLText from '@/static/formats/sequence_labeling/download/example_text.jsonl'
  5. import DownloadTextClassificationJSONL from '@/static/formats/text_classification/download/example.jsonl'
  6. import DownloadTextClassificationCSV from '@/static/formats/text_classification/download/example.csv'
  7. import DownloadTextClassificationFastText from '@/static/formats/text_classification/download/fastText.txt'
  8. import UploadPlainText from '@/static/formats/generic/upload/example.txt'
  9. import UploadSeq2seqCSV from '@/static/formats/seq2seq/upload/example.csv'
  10. import UploadSeq2seqJSONL from '@/static/formats/seq2seq/upload/example.jsonl'
  11. import UploadSequenceLabelingCoNLL from '@/static/formats/sequence_labeling/upload/example.conll.txt'
  12. import UploadSequenceLabelingJSONL from '@/static/formats/sequence_labeling/upload/example.jsonl'
  13. import UploadTextClassificationCSV from '@/static/formats/text_classification/upload/example.csv'
  14. import UploadTextClassificationJSONL from '@/static/formats/text_classification/upload/example.jsonl'
  15. import UploadTextClassificationFastText from '@/static/formats/text_classification/upload/fastText.txt'
  16. export class FormatItem {
  17. constructor(
  18. public example: string,
  19. public type: string,
  20. public text: string,
  21. public extension: string
  22. ) {}
  23. }
  24. const CoNLLItem = (example: string) => { return new FormatItem(example, 'conll', 'CoNLL', 'txt') }
  25. const CSVItem = (example: string) => { return new FormatItem(example, 'csv', 'CSV', 'csv') }
  26. const ExcelItem = (example: string) => { return new FormatItem(example, 'excel', 'Excel', 'xlsx') }
  27. const FastTextItem = (example: string) => { return new FormatItem(example, 'txt', 'fastText', 'txt') }
  28. const JSONLItem = (example: string) => { return new FormatItem(example, 'json', 'JSONL', 'jsonl') }
  29. const JSONLLabelItem = (example: string) => { return new FormatItem(example, 'json', 'JSONL(text label)', 'jsonl') }
  30. const PlainItem = (example: string) => { return new FormatItem(example, 'plain', 'Plain text', 'txt') }
  31. export class FormatFactory {
  32. constructor(private projectType: string) {}
  33. createDownloadFormat(): FormatItem[] {
  34. if (this.projectType === 'DocumentClassification') {
  35. return [
  36. CSVItem(DownloadTextClassificationCSV),
  37. JSONLItem(DownloadTextClassificationJSONL),
  38. FastTextItem(DownloadTextClassificationFastText)
  39. ]
  40. } else if (this.projectType === 'SequenceLabeling') {
  41. return [
  42. JSONLItem(DownloadSequenceLabelingJSONL),
  43. JSONLLabelItem(DownloadSequenceLabelingJSONLText)
  44. ]
  45. } else if (this.projectType === 'Seq2seq') {
  46. return [
  47. CSVItem(DownloadSeq2seqCSV),
  48. JSONLItem(DownloadSeq2seqJSONL)
  49. ]
  50. } else {
  51. return []
  52. }
  53. }
  54. createUploadFormat() {
  55. if (this.projectType === 'DocumentClassification') {
  56. return [
  57. PlainItem(UploadPlainText),
  58. CSVItem(UploadTextClassificationCSV),
  59. JSONLItem(UploadTextClassificationJSONL),
  60. ExcelItem(UploadTextClassificationCSV),
  61. FastTextItem(UploadTextClassificationFastText)
  62. ]
  63. } else if (this.projectType === 'SequenceLabeling') {
  64. return [
  65. PlainItem(UploadPlainText),
  66. JSONLItem(UploadSequenceLabelingJSONL),
  67. CoNLLItem(UploadSequenceLabelingCoNLL)
  68. ]
  69. } else if (this.projectType === 'Seq2seq') {
  70. return [
  71. PlainItem(UploadPlainText),
  72. CSVItem(UploadSeq2seqCSV),
  73. JSONLItem(UploadSeq2seqJSONL),
  74. ExcelItem(UploadSeq2seqCSV)
  75. ]
  76. } else {
  77. return []
  78. }
  79. }
  80. }