Repository navigation
Expand file tree
/
Copy pathrulesets.ts
More file actions
164 lines (138 loc) · 7.1 KB
/
Copy pathrulesets.ts
File metadata and controls
164 lines (138 loc) · 7.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
export interface Rulesets {
weakQualifiers: Record<string, string>;
jargon: Record<string, string>;
complexity: Record<string, string>;
redundancies: Record<string, string>;
}
export const enum RuleType {
WeakQualifier = "WeakQualifier",
Jargon = "Jaron",
Complexity = "Complexity",
Redundancy = "Redudancy",
Custom = "Custom"
}
export class Rule {
match: string;
//alternatives: string[];
highlightLength: number | null;
highlightOffset: number;
type: RuleType;
constructor(type: RuleType, match: string, highLightOffset: number = 0, highlightLength: number | null = null) {
this.type = type;
this.match = match.toLowerCase();
this.highlightOffset = highLightOffset;
this.highlightLength = highlightLength;
}
}
export class Rules {
rules: Record<string, Rule> = {};
customRules: Record<string, Rule> = {};
constructor() {
this.addRule(new Rule(RuleType.WeakQualifier, "a bit"));
this.addRule(new Rule(RuleType.WeakQualifier, "a little"));
this.addRule(new Rule(RuleType.WeakQualifier, "actual"));
this.addRule(new Rule(RuleType.WeakQualifier, "actually"));
this.addRule(new Rule(RuleType.WeakQualifier, "basically"));
this.addRule(new Rule(RuleType.WeakQualifier, "just"));
this.addRule(new Rule(RuleType.WeakQualifier, "kind of"));
this.addRule(new Rule(RuleType.WeakQualifier, "like"));
this.addRule(new Rule(RuleType.WeakQualifier, "literally"));
this.addRule(new Rule(RuleType.WeakQualifier, "quite"));
this.addRule(new Rule(RuleType.WeakQualifier, "really"));
this.addRule(new Rule(RuleType.WeakQualifier, "simply"));
this.addRule(new Rule(RuleType.WeakQualifier, "sort of"));
this.addRule(new Rule(RuleType.WeakQualifier, "very"));
this.addRule(new Rule(RuleType.WeakQualifier, "somewhat"));
this.addRule(new Rule(RuleType.Jargon, "at the end of the day"));
this.addRule(new Rule(RuleType.Jargon, "boil the ocean"));
this.addRule(new Rule(RuleType.Jargon, "double-edged sword"));
this.addRule(new Rule(RuleType.Jargon, "going forward"));
this.addRule(new Rule(RuleType.Jargon, "i beg to differ"));
this.addRule(new Rule(RuleType.Jargon, "ideate"));
this.addRule(new Rule(RuleType.Jargon, "move the needle"));
this.addRule(new Rule(RuleType.Jargon, "moving forward"));
this.addRule(new Rule(RuleType.Jargon, "paradigm"));
this.addRule(new Rule(RuleType.Jargon, "paradigm shift"));
this.addRule(new Rule(RuleType.Jargon, "rightsizing"));
this.addRule(new Rule(RuleType.Jargon, "singing from the same hymn sheet"));
this.addRule(new Rule(RuleType.Jargon, "touch base"));
this.addRule(new Rule(RuleType.Jargon, "unpack"));
this.addRule(new Rule(RuleType.Jargon, "north star"));
this.addRule(new Rule(RuleType.Complexity, "as of yet"));
this.addRule(new Rule(RuleType.Complexity, "at the present time"));
this.addRule(new Rule(RuleType.Complexity, "close proximity"));
this.addRule(new Rule(RuleType.Complexity, "commence"));
this.addRule(new Rule(RuleType.Complexity, "deem"));
this.addRule(new Rule(RuleType.Complexity, "dialogue"));
this.addRule(new Rule(RuleType.Complexity, "due to the fact that"));
this.addRule(new Rule(RuleType.Complexity, "endeavor"));
this.addRule(new Rule(RuleType.Complexity, "endeavour"));
this.addRule(new Rule(RuleType.Complexity, "enumerate"));
this.addRule(new Rule(RuleType.Complexity, "equitable"));
this.addRule(new Rule(RuleType.Complexity, "erroneous"));
this.addRule(new Rule(RuleType.Complexity, "facilitate"));
this.addRule(new Rule(RuleType.Complexity, "For all intents and purposes"));
this.addRule(new Rule(RuleType.Complexity, "henceforth"));
this.addRule(new Rule(RuleType.Complexity, "herewith"));
this.addRule(new Rule(RuleType.Complexity, "honestly"));
this.addRule(new Rule(RuleType.Complexity, "in a sense"));
this.addRule(new Rule(RuleType.Complexity, "in lieu of"));
this.addRule(new Rule(RuleType.Complexity, "in my humble opinion"));
this.addRule(new Rule(RuleType.Complexity, "in order to"));
this.addRule(new Rule(RuleType.Complexity, "in regard to"));
this.addRule(new Rule(RuleType.Complexity, "in relation to"));
this.addRule(new Rule(RuleType.Complexity, "in the event of"));
this.addRule(new Rule(RuleType.Complexity, "inception"));
this.addRule(new Rule(RuleType.Complexity, "leverage"));
this.addRule(new Rule(RuleType.Complexity, "numerous"));
this.addRule(new Rule(RuleType.Complexity, "per se"));
this.addRule(new Rule(RuleType.Complexity, "pertaining to"));
this.addRule(new Rule(RuleType.Complexity, "prior to"));
this.addRule(new Rule(RuleType.Complexity, "subsequently"));
this.addRule(new Rule(RuleType.Complexity, "utilise"));
this.addRule(new Rule(RuleType.Complexity, "utilize"));
this.addRule(new Rule(RuleType.Complexity, "of the opinion that"));
this.addRule(new Rule(RuleType.Complexity, "with reference to"));
this.addRule(new Rule(RuleType.Complexity, "with the exception of"));
this.addRule(new Rule(RuleType.Complexity, "i might add"));
this.addRule(new Rule(RuleType.Complexity, "it is interesting to note"));
this.addRule(new Rule(RuleType.Redundancy, "combine together", 7));
this.addRule(new Rule(RuleType.Redundancy, "critically important", 8));
this.addRule(new Rule(RuleType.Redundancy, "each and every", 0, 9));
this.addRule(new Rule(RuleType.Redundancy, "successfully complete", 0, 13));
this.addRule(new Rule(RuleType.Redundancy, "basic fundamentals"));
this.addRule(new Rule(RuleType.Redundancy, "in the event that"));
this.addRule(new Rule(RuleType.Redundancy, "one and the same", 0, 8));
this.addRule(new Rule(RuleType.Redundancy, "final conclusion", 0, 6));
}
private addRule(rule: Rule) : void {
this.rules[rule.match] = rule;
}
public resetCustomRules() : void {
this.customRules = {};
}
public addCustomRule(match: string) : void {
this.customRules[match] = new Rule(RuleType.Custom, match);
}
public getRuleByMatchString(match: string): Rule {
match = match.toLowerCase();
if(match in this.rules) {
return this.rules[match];
} else {
return this.customRules[match];
}
}
public getMatchStrings(types: RuleType[], exclusions: string[]): string[] {
let toReturn: string[] = [];
for (let key in this.rules) {
if (types.includes(this.rules[key].type) && !exclusions.includes(key)) {
toReturn.push(key);
}
}
for (let key in this.customRules) {
toReturn.push(key);
}
// Sort by length so more precise matches take priority
return toReturn.sort((a, b) => b.length - a.length);;
}
}