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-content>
  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. <metadata-box :metadata="JSON.parse(currentDoc.meta)" />
  21. </v-col>
  22. </v-row>
  23. </v-container>
  24. </v-content>
  25. </template>
  26. <script>
  27. import EntityItemBox from '~/components/organisms/annotation/EntityItemBox'
  28. import MetadataBox from '@/components/organisms/annotation/MetadataBox'
  29. export default {
  30. layout: 'demo',
  31. components: {
  32. EntityItemBox,
  33. MetadataBox
  34. },
  35. data() {
  36. return {
  37. items: [
  38. {
  39. id: 4,
  40. text: 'LOC',
  41. prefix_key: null,
  42. suffix_key: 'l',
  43. background_color: '#7c20e0',
  44. text_color: '#ffffff'
  45. },
  46. {
  47. id: 5,
  48. text: 'MISC',
  49. prefix_key: null,
  50. suffix_key: 'm',
  51. background_color: '#fbb028',
  52. text_color: '#000000'
  53. },
  54. {
  55. id: 6,
  56. text: 'ORG',
  57. prefix_key: null,
  58. suffix_key: 'o',
  59. background_color: '#e6d176',
  60. text_color: '#000000'
  61. },
  62. {
  63. id: 7,
  64. text: 'PER',
  65. prefix_key: null,
  66. suffix_key: 'p',
  67. background_color: '#6a74b9',
  68. text_color: '#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. start_offset: 60,
  80. end_offset: 70,
  81. user: 1,
  82. document: 8
  83. },
  84. {
  85. id: 19,
  86. prob: 0.0,
  87. label: 4,
  88. start_offset: 165,
  89. end_offset: 172,
  90. user: 1,
  91. document: 8
  92. },
  93. {
  94. id: 16,
  95. prob: 0.0,
  96. label: 6,
  97. start_offset: 14,
  98. end_offset: 22,
  99. user: 1,
  100. document: 8
  101. },
  102. {
  103. id: 18,
  104. prob: 0.0,
  105. label: 6,
  106. start_offset: 73,
  107. end_offset: 87,
  108. user: 1,
  109. document: 8
  110. },
  111. {
  112. id: 20,
  113. prob: 0.0,
  114. label: 7,
  115. start_offset: 181,
  116. end_offset: 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. start_offset: startOffset,
  138. end_offset: endOffset,
  139. label: labelId
  140. }
  141. this.currentDoc.annotations.push(payload)
  142. }
  143. }
  144. }
  145. </script>