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.

206 lines
5.4 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  1. <template>
  2. <v-main>
  3. <v-container fluid>
  4. <div class="mb-2">
  5. <v-btn
  6. text
  7. outlined
  8. class="text-capitalize mr-2"
  9. @click="allowOverlapping=!allowOverlapping"
  10. >
  11. Overlapping({{ allowOverlapping }})
  12. </v-btn>
  13. <v-btn text outlined @click="rtl=!rtl">
  14. RTL(<span class="text-capitalize">{{ rtl }}</span>)
  15. </v-btn>
  16. </div>
  17. <v-row justify="center">
  18. <v-col cols="12" md="9">
  19. <v-card>
  20. <div class="annotation-text pa-4">
  21. <entity-editor
  22. :dark="$vuetify.theme.dark"
  23. :rtl="rtl"
  24. :text="currentDoc.text"
  25. :entities="currentDoc.annotations"
  26. :entity-labels="entityLabels"
  27. :relations="relations"
  28. :relation-labels="relationLabels"
  29. :allow-overlapping="allowOverlapping"
  30. @addEntity="addEntity"
  31. @click:entity="updateEntity"
  32. @contextmenu:entity="deleteEntity"
  33. @contextmenu:relation="deleteRelation"
  34. />
  35. </div>
  36. </v-card>
  37. </v-col>
  38. <v-col cols="12" md="3">
  39. <list-metadata :metadata="currentDoc.meta" />
  40. </v-col>
  41. </v-row>
  42. </v-container>
  43. </v-main>
  44. </template>
  45. <script>
  46. import EntityEditor from '@/components/tasks/sequenceLabeling/EntityEditor.vue'
  47. import ListMetadata from '@/components/tasks/metadata/ListMetadata'
  48. export default {
  49. components: {
  50. EntityEditor,
  51. ListMetadata,
  52. },
  53. layout: 'demo',
  54. data() {
  55. return {
  56. allowOverlapping: false,
  57. rtl: false,
  58. entityLabels: [
  59. {
  60. id: 4,
  61. text: 'LOC',
  62. prefixKey: null,
  63. suffixKey: 'l',
  64. color: '#7c20e0',
  65. textColor: '#ffffff',
  66. },
  67. {
  68. id: 5,
  69. text: 'MISC',
  70. prefixKey: null,
  71. suffixKey: 'm',
  72. color: '#fbb028',
  73. textColor: '#000000',
  74. },
  75. {
  76. id: 6,
  77. text: 'ORG',
  78. prefixKey: null,
  79. suffixKey: 'o',
  80. color: '#e6d176',
  81. textColor: '#000000',
  82. },
  83. {
  84. id: 7,
  85. text: 'PER',
  86. prefixKey: null,
  87. suffixKey: 'p',
  88. color: '#6a74b9',
  89. textColor: '#ffffff',
  90. }
  91. ],
  92. relations: [
  93. {
  94. id: 0,
  95. fromId: 16,
  96. toId: 17,
  97. labelId: 0,
  98. },
  99. ],
  100. relationLabels: [
  101. {
  102. id: 0,
  103. text: "isLorem",
  104. color: "#ffffff",
  105. },
  106. ],
  107. currentDoc: {
  108. id: 8,
  109. 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.',
  110. annotations: [
  111. {
  112. id: 17,
  113. prob: 0.0,
  114. label: 4,
  115. startOffset: 60,
  116. endOffset: 70,
  117. user: 1,
  118. },
  119. {
  120. id: 19,
  121. prob: 0.0,
  122. label: 4,
  123. startOffset: 164,
  124. endOffset: 171,
  125. user: 1,
  126. },
  127. {
  128. id: 16,
  129. prob: 0.0,
  130. label: 6,
  131. startOffset: 14,
  132. endOffset: 22,
  133. user: 1,
  134. },
  135. {
  136. id: 18,
  137. prob: 0.0,
  138. label: 6,
  139. startOffset: 72,
  140. endOffset: 86,
  141. user: 1,
  142. },
  143. {
  144. id: 20,
  145. prob: 0.0,
  146. label: 7,
  147. startOffset: 180,
  148. endOffset: 192,
  149. user: 1,
  150. },
  151. ],
  152. meta: { wikiPageId: 2 },
  153. annotation_approver: null
  154. }
  155. }
  156. },
  157. watch: {
  158. rtl() {
  159. this.relations = []
  160. this.currentDoc.annotations = []
  161. // this.$vuetify.rtl = this.rtl
  162. if (this.rtl) {
  163. this.currentDoc.text = 'داستان SVG Tiny 1.2 طولا ني است.'
  164. } else {
  165. this.currentDoc.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.'
  166. }
  167. }
  168. },
  169. methods: {
  170. deleteEntity(annotationId) {
  171. this.currentDoc.annotations = this.currentDoc.annotations.filter(item => item.id !== annotationId)
  172. this.relations.forEach((r) => {
  173. if (r.fromId === annotationId || r.toId === annotationId) {
  174. this.deleteRelation(r.id)
  175. }
  176. })
  177. },
  178. updateEntity(annotationId, labelId) {
  179. const index = this.currentDoc.annotations.findIndex(item => item.id === annotationId)
  180. this.currentDoc.annotations[index].label = labelId
  181. },
  182. addEntity(startOffset, endOffset, labelId) {
  183. const payload = {
  184. id: Math.floor(Math.random() * Math.floor(Number.MAX_SAFE_INTEGER)),
  185. startOffset,
  186. endOffset,
  187. label: labelId
  188. }
  189. this.currentDoc.annotations.push(payload)
  190. },
  191. deleteRelation(relationId) {
  192. this.relations = this.relations.filter(item => item.id !== relationId)
  193. }
  194. }
  195. }
  196. </script>
  197. <style scoped>
  198. .annotation-text {
  199. font-size: 1.25rem !important;
  200. font-weight: 500;
  201. line-height: 2rem;
  202. font-family: "Roboto", sans-serif !important;
  203. opacity: 0.6;
  204. }
  205. </style>