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.

134 lines
3.5 KiB

3 years ago
3 years ago
3 years ago
3 years ago
  1. <template>
  2. <v-stepper-content step="3">
  3. <v-card>
  4. <v-card-text class="pa-0">
  5. <h4 class="text-h6">Set mapping template</h4>
  6. <p class="font-weight-regular body-1">
  7. Now, you can successfuly fetch the API response.
  8. Next, you need to convert API response to doccano format with the mapping template.
  9. </p>
  10. <h4 class="text-h6">
  11. Response
  12. </h4>
  13. <v-sheet
  14. :dark="!$vuetify.theme.dark"
  15. :light="$vuetify.theme.dark"
  16. class="mb-5 pa-5"
  17. >
  18. <pre>{{ JSON.stringify(response, null, 4) }}</pre>
  19. </v-sheet>
  20. <h4 class="text-h6">
  21. doccano format
  22. </h4>
  23. <v-sheet
  24. :dark="!$vuetify.theme.dark"
  25. :light="$vuetify.theme.dark"
  26. class="mb-5 pa-5"
  27. >
  28. <pre>Text Classification</pre>
  29. <pre>[{ "label": "Cat" }, ...]</pre>
  30. <br>
  31. <pre>Sequence Labeling</pre>
  32. <pre>[{ "label": "Cat", "start_offset": 0, "end_offset": 5 }, ...]</pre>
  33. <br>
  34. <pre>Sequence to sequence</pre>
  35. <pre>[{ "text": "Cat" }, ...]</pre>
  36. </v-sheet>
  37. <h4 class="text-h6">Mapping template</h4>
  38. <p class="font-weight-regular body-1">
  39. You can set mapping template(<a href="https://jinja.palletsprojects.com/en/2.11.x/">Jinja2</a> format) to convert API response to doccano format.
  40. In the template, you can refer to the API response by the <strong>input</strong> variable.
  41. If you want to know the Jinja2 notation, please refer to the site.
  42. </p>
  43. <v-textarea
  44. :value="value"
  45. outlined
  46. label="Mapping Template"
  47. @change="$emit('input', $event)"
  48. />
  49. <v-alert
  50. v-for="(error, index) in errorMessages"
  51. :key="index"
  52. prominent
  53. type="error"
  54. >
  55. <v-row align="center">
  56. <v-col class="grow">
  57. {{ error }}
  58. </v-col>
  59. </v-row>
  60. </v-alert>
  61. <h4 class="text-h6">
  62. Result
  63. </h4>
  64. <v-sheet
  65. :dark="!$vuetify.theme.dark"
  66. :light="$vuetify.theme.dark"
  67. class="mb-5 pa-5"
  68. >
  69. <pre>{{ JSON.stringify(result, null, 4) }}</pre>
  70. </v-sheet>
  71. </v-card-text>
  72. <v-card-actions class="pa-0">
  73. <v-spacer />
  74. <v-btn
  75. text
  76. class="text-capitalize"
  77. @click="$emit('prev')"
  78. >
  79. Prev
  80. </v-btn>
  81. <v-btn
  82. v-show="!isPassed"
  83. color="primary"
  84. class="text-capitalize"
  85. @click="$emit('onTest')"
  86. >
  87. Test
  88. </v-btn>
  89. <v-btn
  90. v-show="isPassed"
  91. color="primary"
  92. class="text-capitalize"
  93. @click="$emit('next')"
  94. >
  95. Next
  96. </v-btn>
  97. </v-card-actions>
  98. </v-card>
  99. </v-stepper-content>
  100. </template>
  101. <script lang="ts">
  102. import Vue from 'vue'
  103. export default Vue.extend({
  104. props: {
  105. value: {
  106. type: String,
  107. default: '',
  108. required: true
  109. },
  110. errorMessages: {
  111. type: Array,
  112. default: () => [],
  113. required: true
  114. },
  115. isPassed: {
  116. type: Boolean,
  117. default: false,
  118. required: true
  119. },
  120. response: {
  121. type: [String, Object, Array],
  122. default: () => [],
  123. required: true
  124. },
  125. result: {
  126. type: Array,
  127. default: () => [],
  128. required: true
  129. }
  130. }
  131. })
  132. </script>