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.

210 lines
5.5 KiB

3 years ago
3 years ago
3 years ago
3 years ago
  1. <template>
  2. <base-card
  3. :disabled="!valid"
  4. :title="$t('overview.createProjectTitle')"
  5. :agree-text="$t('generic.save')"
  6. :cancel-text="$t('generic.cancel')"
  7. @agree="$emit('save')"
  8. @cancel="$emit('cancel')"
  9. >
  10. <template #content>
  11. <v-form v-model="valid">
  12. <v-text-field
  13. :value="name"
  14. :rules="projectNameRules($t('rules.projectNameRules'))"
  15. :label="$t('overview.projectName')"
  16. :prepend-icon="mdiAccountMultiple"
  17. required
  18. autofocus
  19. @input="updateValue('name', $event)"
  20. />
  21. <v-text-field
  22. :value="description"
  23. :rules="descriptionRules($t('rules.descriptionRules'))"
  24. :label="$t('generic.description')"
  25. :prepend-icon="mdiClipboardText"
  26. required
  27. @input="updateValue('description', $event)"
  28. />
  29. <v-select
  30. :value="projectType"
  31. :items="projectTypes"
  32. :rules="projectTypeRules($t('rules.projectTypeRules'))"
  33. :label="$t('overview.projectType')"
  34. :prepend-icon="mdiKeyboard"
  35. required
  36. @input="updateValue('projectType', $event)"
  37. >
  38. <template #item="props">
  39. {{ translateTypeName(props.item, $t('overview.projectTypes')) }}
  40. </template>
  41. <template #selection="props">
  42. {{ translateTypeName(props.item, $t('overview.projectTypes')) }}
  43. </template>
  44. </v-select>
  45. <v-checkbox
  46. v-if="hasSingleLabelOption"
  47. :value="singleClassClassification"
  48. label="Allow single label"
  49. @change="updateValue('singleClassClassification', $event === true)"
  50. />
  51. <v-checkbox
  52. v-if="isSequenceLabelingProject"
  53. :value="allowOverlapping"
  54. label="Allow overlapping entity"
  55. @change="updateValue('allowOverlapping', $event === true)"
  56. />
  57. <v-img
  58. v-if="isSequenceLabelingProject"
  59. :src="require('~/assets/project/creation.gif')"
  60. height="200"
  61. position="left"
  62. contain
  63. />
  64. <v-checkbox
  65. v-if="isSequenceLabelingProject"
  66. :value="useRelation"
  67. label="Use relation labeling"
  68. @change="updateValue('useRelation', $event === true)"
  69. />
  70. <v-checkbox
  71. v-if="isSequenceLabelingProject"
  72. :value="graphemeMode"
  73. @change="updateValue('graphemeMode', $event === true)"
  74. >
  75. <template #label>
  76. <div>
  77. Count
  78. <v-tooltip bottom>
  79. <template #activator="{ on }">
  80. <a
  81. target="_blank"
  82. href="https://unicode.org/reports/tr29/"
  83. @click.stop
  84. v-on="on"
  85. >
  86. grapheme clusters
  87. </a>
  88. </template>
  89. Like emoji(🌷, 💩, and 👍), CRLF(\r\n), and so on.
  90. </v-tooltip>
  91. as one character
  92. </div>
  93. </template>
  94. </v-checkbox>
  95. <v-checkbox
  96. :value="enableRandomOrder"
  97. :label="$t('overview.randomizeDocOrder')"
  98. @change="updateValue('enableRandomOrder', $event === true)"
  99. />
  100. <v-checkbox
  101. :value="enableShareAnnotation"
  102. :label="$t('overview.shareAnnotations')"
  103. @change="updateValue('enableShareAnnotation', $event === true)"
  104. />
  105. </v-form>
  106. </template>
  107. </base-card>
  108. </template>
  109. <script lang="ts">
  110. import Vue from 'vue'
  111. import { mdiAccountMultiple, mdiClipboardText, mdiKeyboard } from '@mdi/js'
  112. import BaseCard from '@/components/utils/BaseCard.vue'
  113. import { projectNameRules, descriptionRules, projectTypeRules } from '@/rules/index'
  114. export default Vue.extend({
  115. components: {
  116. BaseCard
  117. },
  118. props: {
  119. name: {
  120. type: String,
  121. default: '',
  122. required: true
  123. },
  124. description: {
  125. type: String,
  126. default: '',
  127. required: true
  128. },
  129. projectType: {
  130. type: String,
  131. default: '',
  132. required: true
  133. },
  134. enableRandomOrder: {
  135. type: Boolean,
  136. default: false,
  137. required: true
  138. },
  139. enableShareAnnotation: {
  140. type: Boolean,
  141. default: false,
  142. required: true
  143. },
  144. singleClassClassification: {
  145. type: Boolean,
  146. default: false,
  147. required: true
  148. },
  149. allowOverlapping: {
  150. type: Boolean,
  151. default: false
  152. },
  153. graphemeMode: {
  154. type: Boolean,
  155. default: false
  156. },
  157. useRelation: {
  158. type: Boolean,
  159. default: false
  160. }
  161. },
  162. data() {
  163. return {
  164. valid: false,
  165. projectNameRules,
  166. projectTypeRules,
  167. descriptionRules,
  168. mdiAccountMultiple,
  169. mdiClipboardText,
  170. mdiKeyboard
  171. }
  172. },
  173. computed: {
  174. projectTypes() {
  175. return [
  176. 'DocumentClassification',
  177. 'SequenceLabeling',
  178. 'Seq2seq',
  179. 'IntentDetectionAndSlotFilling',
  180. 'ImageClassification',
  181. 'Speech2text',
  182. ]
  183. },
  184. hasSingleLabelOption() {
  185. return [
  186. 'DocumentClassification',
  187. 'ImageClassification',
  188. ].includes(this.projectType)
  189. },
  190. isSequenceLabelingProject() {
  191. return this.projectType === 'SequenceLabeling'
  192. }
  193. },
  194. methods: {
  195. updateValue(key: string, value: string) {
  196. this.$emit(`update:${key}`, value);
  197. },
  198. translateTypeName(type: string, types: string[]): string {
  199. const index = this.projectTypes.indexOf(type)
  200. return types[index]
  201. }
  202. }
  203. })
  204. </script>