Skip to content

Commit 272f016

Browse files
committed
Bump to 0.08
1 parent ff51cd7 commit 272f016

File tree

7 files changed

+54
-51
lines changed

7 files changed

+54
-51
lines changed

README.md

+20-20
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@ vue2-text-annotation is an easy-to-use component for text annotation and data ma
1313

1414
# Installation
1515
```bash
16-
npm install --save vue-manual-data-masking
16+
npm install --save vue2-text-annotation
1717
```
1818

1919
# 1. Text annotation
2020

2121
### Operation
22-
1. Select or double click the content which you want to add an annotation to, then an input dialog will pop up.
23-
2. Enter annotation content.
24-
3. Click "ok" button or just press the enter key to accomplish the annotation.
25-
4. If you want to remove an annoation, hover on annotation entity and click the delete button.
22+
1. Select or double click the content which you want to annotate, then an input dialog will pop up.
23+
2. Enter content of annotation.
24+
3. Click "ok" button or just press the enter key to annotate.
25+
4. If you want to remove an annoation, hover on annotation entity and click the delete button to remove.
2626

2727
### Demo
2828

@@ -32,31 +32,31 @@ npm install --save vue-manual-data-masking
3232

3333
[![Edit on CodeSandbox](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/vue2-text-annotation-yt6cc?file=/src/App.vue)
3434

35-
### labeled data
35+
### Labeled data
3636

3737
```js
3838
[
3939
{
40-
content:"Vue.js",
41-
category:"framework",
40+
content: "Vue.js",
41+
annotation: "framework",
4242
start:0,
4343
end:6,
4444
},
4545
{
46-
content:"Evan You",
47-
category:"name",
46+
content: "Evan You",
47+
annotation: "name",
4848
start:521,
4949
end:529,
5050
},
5151
{
52-
content:"JavaScript",
53-
category:"language",
52+
content: "JavaScript",
53+
annotation: "language",
5454
start:24,
5555
end:34,
5656
}
5757
]
5858
```
59-
The labeled data generated by `vue2-text-annotation` can be used as the training data set of Natural Language Processing (NLP) model.
59+
The labeled data generated by `vue2-text-annotation` can be used to build a data set of Natural Language Processing (NLP) model.
6060

6161
### Usage
6262
```js
@@ -79,7 +79,7 @@ export default {
7979
text: "Vue.js is a progressive JavaScript framework, which is used to build UIs (User Interfaces) and SPAs (Single-page Applications). This framework is famous for its fast-paced learning curve. It is such an easy to learn and approachable library that with the knowledge of HTML, CSS, and JavaScript, we can start building web applications in Vue.js. The fast learning curve is kind of a signature of this framework. It is a versatile framework for our need as a library or a full-fledged framework for building huge web apps.\nEvan You have created this framework. The idea of Evan You behind this framework is to build the best framework by combining the best features from already existing Angular and react Frameworks. Before building Vue.js, Evan You was working at Google. Inc and worked on Angular based projects. So, he came up with the idea of building his own framework. He picked the best parts of Angular, like template syntax, easy to use, and picked the best parts of React as well, like two-way data binding, the concept of props, component-based approach, and combined them to make a new framework Vue.js better than both of them.",
8080
textAnnotations: [{
8181
content: "Vue.js",
82-
category: "framework",
82+
annotation: "framework",
8383
start:0,
8484
end:6,
8585
}]
@@ -89,7 +89,7 @@ export default {
8989
```
9090

9191
# 2. Data masking
92-
Data masking mode in `vue2-text-annotation` is used for labeling sensitive data and creating new text that hides (masks) sensitive information.
92+
Data masking is used to label and hide sensitive data and create new text that hides (masks) sensitive information.
9393

9494
### Demo
9595
Before data masking: <br/>
@@ -107,7 +107,7 @@ After data masking: <br/>
107107
```js
108108
<template>
109109
<TextAnnotation
110-
v-model="dataSet"
110+
v-model="textAnnotations"
111111
data-masking="true"
112112
:text="text"
113113
@afterDataMasking="updateTextAfterDataMasking"
@@ -123,7 +123,7 @@ export default {
123123
},
124124
data() {
125125
return {
126-
dataSet: [],
126+
textAnnotations: [],
127127
text:
128128
"James lives at 4 Chome-2-8 Shibakoen, his phone number is 080080080, His full name is Lebron James",
129129
textAfterDataMasking: "",
@@ -143,14 +143,14 @@ export default {
143143

144144
| Property | Description | Type | Required | Default |
145145
| -------- | ----------- | ---- | -------- | ------- |
146-
| v-model | Bind to text annotations<br>e.g. <br>[{ content: "080080080", category: "phone number", start: 0, end: 5 }] | Annotation: <br>{<br> content: string, <br> category: string, <br> start: number,<br> end: number<br>} | true | [] |
146+
| v-model | Bind to text annotations<br>e.g. <br>[{ content: "080080080", annotation: "phone number", start: 0, end: 5 }] | Annotation: <br>{<br> content: string, <br> annotation: string, <br> start: number,<br> end: number<br>} | true | [] |
147147
| annotation-text-color | Font color of annotation entity | string | false |"#35495e" |
148148
| annotation-bg-color | Background color of annotation entity | string | false | "#41b883"|
149149
| data-masking | Set to `true` to start data masking mode | boolean | false | false |
150150
| data-masking-charactor | Charactor in data masking entity| string | false | '●' |
151151
| maxHeight | Max height of data masking container | Number or Null | false | null | |
152-
| text | Text | String | true | '' |
153-
| text-replace-charactor | Charactor be used to replace the sensitive data | string | false | '*" |
152+
| replace-charactor | Charactor be used to replace the sensitive data | string | false | '*" |
153+
| text | Text (Notice: please use `\n` in where you want to wrap a new line) | String | true | '' |
154154

155155

156156

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "vue2-text-annotation",
33
"description": "A vue2 component for text annotation",
4-
"version": "0.0.7",
4+
"version": "0.0.8",
55
"private": false,
66
"author": "HC200ok",
77
"license": "MIT",

src/App.vue

+14-14
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,16 @@
44
class="text-container"
55
v-model="labeledData"
66
:text="text"
7-
:data-masking="false"
8-
@afterDataMasking="afterMasking"
7+
:data-masking="true"
8+
@afterDataMasking="updateTextAfterDataMasking"
99
/>
10-
<div class="annotations">
11-
data set: {{ labeledData }}
12-
</div>
10+
<br />
11+
labeled data: <br />
12+
{{ labeledData }}
13+
<br />
14+
<br />
15+
text after data masking:<br />
16+
{{ textAfterMasking }}
1317
</div>
1418
</template>
1519

@@ -19,7 +23,7 @@ import TextContainer from "./components/TextContainer.vue";
1923
2024
@Component({
2125
components: {
22-
TextContainer
26+
TextContainer,
2327
},
2428
})
2529
export default class App extends Vue {
@@ -29,20 +33,16 @@ export default class App extends Vue {
2933
labeledData = [
3034
{
3135
content: "Vue.js",
32-
category: "framework",
33-
start:0,
34-
end:6,
36+
annotation: "framework",
37+
start: 0,
38+
end: 6,
3539
},
3640
];
3741
3842
textAfterMasking = this.text;
3943
40-
afterMasking(textAfterMasking: string): void {
44+
updateTextAfterDataMasking(textAfterMasking: string): void {
4145
this.textAfterMasking = textAfterMasking;
4246
}
4347
}
4448
</script>
45-
46-
<style>
47-
48-
</style>

src/components/InputDialog.vue

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
id="input-dialog"
1010
class="input-dialog"
1111
autocomplete="off"
12-
v-model="category"
12+
v-model="annotation"
1313
ref="input"
1414
type="text"
1515
v-on:mouseup.stop
@@ -41,11 +41,11 @@ export default class InputDialog extends Vue {
4141
@Prop({ required: true }) align!: string;
4242
@Prop({ required: true }) inputDialogWidth!: number;
4343
44-
category = "";
44+
annotation = "";
4545
4646
@Emit()
4747
addAnnotation(): string {
48-
return this.category;
48+
return this.annotation;
4949
}
5050
}
5151
</script>

src/components/TextAnnotation.vue

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020
</span>
2121
</span>
2222
<span
23-
class="text-annotation__category"
23+
class="text-annotation__annotation"
2424
:style="{ backgroundColor: annotationBgColor }"
2525
>
26-
{{ textAnnotation.category }}
26+
{{ textAnnotation.annotation }}
2727
</span>
2828
<button class="text-annotation__delete" @click="deleteAnnotation">x</button>
2929
</span>
@@ -75,7 +75,7 @@ export default class TextAnnotation extends Vue {
7575
}
7676
}
7777
}
78-
&__category {
78+
&__annotation {
7979
display: inline-block;
8080
font-weight: 700;
8181
height: 1.3em;

src/components/TextContainer.vue

+11-8
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export default class TextContainer extends Vue {
5454
@Prop({ default: "#41b883" }) readonly annotationBgColor!: string;
5555
@Prop({ default: false }) readonly dataMasking!: boolean;
5656
@Prop({ default: "" }) readonly dataMaskingCharactor!: string;
57-
@Prop({ default: "*" }) readonly textReplaceCharactor!: string;
57+
@Prop({ default: "*" }) readonly replaceCharactor!: string;
5858
@Prop({ default: null }) readonly maxHeight!: string | null;
5959
6060
textAnnotations: Array<Annotation> = [];
@@ -91,7 +91,7 @@ export default class TextContainer extends Vue {
9191
this.showInputDialog = !(newVal === "" || newVal === null);
9292
}
9393
94-
isTextIndent(index: number, isText = true): boolean {
94+
isTextIndent(index: number): boolean {
9595
if (index === 0) return true;
9696
const previousChunk = this.chunks[index - 1];
9797
if (previousChunk.type === "wrap") {
@@ -105,7 +105,7 @@ export default class TextContainer extends Vue {
105105
textAnnotations.forEach((item) => {
106106
afterMasking =
107107
afterMasking.substr(0, item.start) +
108-
this.textReplaceCharactor.repeat(item.content.length) +
108+
this.replaceCharactor.repeat(item.content.length) +
109109
afterMasking.substr(item.start + item.content.length);
110110
});
111111
return afterMasking;
@@ -149,7 +149,7 @@ export default class TextContainer extends Vue {
149149
type: "annotation",
150150
content: piece,
151151
start: entity.start,
152-
category: entity.category,
152+
annotation: entity.annotation,
153153
});
154154
}
155155
// add the rest of text.
@@ -179,7 +179,10 @@ export default class TextContainer extends Vue {
179179
// if click on `ok` button, pass
180180
if (target.classList.contains("add-annotation-button")) return;
181181
// effective when mouseover on class `text-for-annotation`, expecially unavailable on `annotation`
182-
if (target.classList.contains("text-for-annotation") || target.classList.contains("text-annotation-container")) {
182+
if (
183+
target.classList.contains("text-for-annotation") ||
184+
target.classList.contains("text-annotation-container")
185+
) {
183186
const selection = window.getSelection();
184187
if (selection !== null && selection.toString().length) {
185188
const range = selection.getRangeAt(0).cloneRange();
@@ -231,16 +234,16 @@ export default class TextContainer extends Vue {
231234
);
232235
}
233236
234-
addAnnotation(category: string): void {
237+
addAnnotation(annotation: string): void {
235238
if (
236-
category.length &&
239+
annotation.length &&
237240
typeof this.selectingContent == "string" &&
238241
this.selectingContent.length &&
239242
this.selectingContentStartIndex !== null
240243
) {
241244
this.textAnnotations = this.textAnnotations.concat({
242245
content: this.selectingContent,
243-
category,
246+
annotation,
244247
start: this.selectingContentStartIndex,
245248
end: this.selectingContentStartIndex + this.selectingContent.length,
246249
});

src/type.d.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
export interface Annotation {
22
content: string;
3-
category: string;
3+
annotation: string;
44
start: number;
55
end: number;
66
}
77
export interface Chunk {
88
type: string;
9-
category?: string;
9+
annotation?: string;
1010
content: string;
1111
start?: number;
1212
end?: number;

0 commit comments

Comments
 (0)