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.

150 lines
3.7 KiB

  1. <template>
  2. <v-main>
  3. <v-container fluid>
  4. <v-row justify="center">
  5. <v-col cols="12" md="9">
  6. <v-card>
  7. <v-card-text class="title">
  8. <entity-item-box
  9. :labels="items"
  10. :text="currentDoc.text"
  11. :entities="currentDoc.annotations"
  12. :delete-annotation="removeEntity"
  13. :update-entity="updateEntity"
  14. :add-entity="addEntity"
  15. />
  16. </v-card-text>
  17. </v-card>
  18. </v-col>
  19. <v-col cols="12" md="3">
  20. <list-metadata :metadata="JSON.parse(currentDoc.meta)" />
  21. </v-col>
  22. </v-row>
  23. </v-container>
  24. </v-main>
  25. </template>
  26. <script>
  27. import ListMetadata from '@/components/tasks/metadata/ListMetadata'
  28. import EntityItemBox from '~/components/tasks/sequenceLabeling/EntityItemBox'
  29. export default {
  30. layout: 'demo',
  31. components: {
  32. EntityItemBox,
  33. ListMetadata
  34. },
  35. data() {
  36. return {
  37. items: [
  38. {
  39. id: 4,
  40. text: 'LOC',
  41. prefixKey: null,
  42. suffixKey: 'l',
  43. backgroundColor: '#7c20e0',
  44. textColor: '#ffffff'
  45. },
  46. {
  47. id: 5,
  48. text: 'MISC',
  49. prefixKey: null,
  50. suffixKey: 'm',
  51. backgroundColor: '#fbb028',
  52. textColor: '#000000'
  53. },
  54. {
  55. id: 6,
  56. text: 'ORG',
  57. prefixKey: null,
  58. suffixKey: 'o',
  59. backgroundColor: '#e6d176',
  60. textColor: '#000000'
  61. },
  62. {
  63. id: 7,
  64. text: 'PER',
  65. prefixKey: null,
  66. suffixKey: 'p',
  67. backgroundColor: '#6a74b9',
  68. textColor: '#ffffff'
  69. }
  70. ],
  71. currentDoc: {
  72. id: 8,
  73. text: 'After bowling Somerset out for 83 on the opening morning at Grace Road , Leicestershire extended their first innings by 94 runs before being bowled out for 296 with England discard Andy Caddick taking three for 83 .',
  74. annotations: [
  75. {
  76. id: 17,
  77. prob: 0.0,
  78. label: 4,
  79. startOffset: 60,
  80. endOffset: 70,
  81. user: 1,
  82. document: 8
  83. },
  84. {
  85. id: 19,
  86. prob: 0.0,
  87. label: 4,
  88. startOffset: 165,
  89. endOffset: 172,
  90. user: 1,
  91. document: 8
  92. },
  93. {
  94. id: 16,
  95. prob: 0.0,
  96. label: 6,
  97. startOffset: 14,
  98. endOffset: 22,
  99. user: 1,
  100. document: 8
  101. },
  102. {
  103. id: 18,
  104. prob: 0.0,
  105. label: 6,
  106. startOffset: 73,
  107. endOffset: 87,
  108. user: 1,
  109. document: 8
  110. },
  111. {
  112. id: 20,
  113. prob: 0.0,
  114. label: 7,
  115. startOffset: 181,
  116. endOffset: 193,
  117. user: 1,
  118. document: 8
  119. }
  120. ],
  121. meta: '{"wikiPageId":2}',
  122. annotation_approver: null
  123. }
  124. }
  125. },
  126. methods: {
  127. removeEntity(annotationId) {
  128. this.currentDoc.annotations = this.currentDoc.annotations.filter(item => item.id !== annotationId)
  129. },
  130. updateEntity(labelId, annotationId) {
  131. const index = this.currentDoc.annotations.findIndex(item => item.id === annotationId)
  132. this.currentDoc.annotations[index].label = labelId
  133. },
  134. addEntity(startOffset, endOffset, labelId) {
  135. const payload = {
  136. id: Math.floor(Math.random() * Math.floor(Number.MAX_SAFE_INTEGER)),
  137. startOffset,
  138. endOffset,
  139. label: labelId
  140. }
  141. this.currentDoc.annotations.push(payload)
  142. }
  143. }
  144. }
  145. </script>