slopless 0.2.26 → 0.2.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -159,7 +159,7 @@ function matchWhatFrame(words) {
159
159
  function matchAbstractFrame(text) {
160
160
  const words = tokens(text);
161
161
  return (matchRelativeDiscourseFrame(text, words) ??
162
- matchExpandedDiscourseFrame(words) ??
162
+ matchExpandedDiscourseFrame(text, words) ??
163
163
  matchModifiedAbstractFrame(words) ??
164
164
  matchDiscourseEvaluationFrame(words) ??
165
165
  matchPointIsToFrame(words) ??
@@ -221,6 +221,7 @@ function matchSignposting(sentence) {
221
221
  const generatedFormula = matchGeneratedFormula(stripped);
222
222
  if (abstract !== undefined &&
223
223
  (abstract === "what-matters-is" ||
224
+ abstract.startsWith("deictic-evaluative-") ||
224
225
  abstract.startsWith("relative-") ||
225
226
  !concreteImplementation)) {
226
227
  return { kind: "abstract-evaluation-frame", signal: abstract };
@@ -5,6 +5,53 @@ const DISCOURSE_WORK_TAILS = [
5
5
  ["load", "bearing"]
6
6
  ];
7
7
  const DETERMINERS = new Set(["a", "an", "the", "this", "that"]);
8
+ const DEICTIC_OPENERS = new Set(["here", "this", "that"]);
9
+ const DEICTIC_CONTRACTIONS = new Map([
10
+ ["here's", "here"],
11
+ ["this's", "this"],
12
+ ["that's", "that"]
13
+ ]);
14
+ const DEICTIC_EVALUATIVE_ADJECTIVES = new Set([
15
+ "best",
16
+ "better",
17
+ "biggest",
18
+ "central",
19
+ "core",
20
+ "crucial",
21
+ "funny",
22
+ "good",
23
+ "great",
24
+ "hard",
25
+ "important",
26
+ "interesting",
27
+ "key",
28
+ "main",
29
+ "neat",
30
+ "nice",
31
+ "odd",
32
+ "obvious",
33
+ "remarkable",
34
+ "strange",
35
+ "surprising",
36
+ "tricky",
37
+ "useful",
38
+ "weird",
39
+ "wild"
40
+ ]);
41
+ const DEICTIC_DISCOURSE_NOUNS = new Set([
42
+ "angle",
43
+ "aspect",
44
+ "bit",
45
+ "catch",
46
+ "detail",
47
+ "element",
48
+ "idea",
49
+ "part",
50
+ "piece",
51
+ "point",
52
+ "thing",
53
+ "twist"
54
+ ]);
8
55
  const FRAME_ADJECTIVES = new Set([
9
56
  "basic",
10
57
  "best",
@@ -202,13 +249,45 @@ function matchEvaluativeFrame(words) {
202
249
  ? `the-${adjective}-${noun}-${verb}`
203
250
  : undefined;
204
251
  }
252
+ function matchDeicticEvaluativeFrame(text, words) {
253
+ const contractedOpener = DEICTIC_CONTRACTIONS.get(words[0] ?? "");
254
+ const opener = contractedOpener ?? words[0];
255
+ const determinerIndex = contractedOpener === undefined ? 2 : 1;
256
+ if (opener === undefined ||
257
+ !DEICTIC_OPENERS.has(opener) ||
258
+ (contractedOpener === undefined &&
259
+ !["is", "was"].includes(words[1] ?? "")) ||
260
+ !["a", "an", "the"].includes(words[determinerIndex] ?? "")) {
261
+ return undefined;
262
+ }
263
+ const adjective = words[determinerIndex + 1];
264
+ const noun = words[determinerIndex + 2];
265
+ const frame = adjective !== undefined && noun !== undefined
266
+ ? words.slice(0, determinerIndex + 3).join(" ")
267
+ : undefined;
268
+ const boundary = frame === undefined ? undefined : text.at(frame.length);
269
+ return adjective !== undefined &&
270
+ noun !== undefined &&
271
+ (boundary === undefined ||
272
+ boundary === "." ||
273
+ boundary === "!" ||
274
+ boundary === "?" ||
275
+ boundary === ":" ||
276
+ boundary === ";" ||
277
+ boundary === ",") &&
278
+ DEICTIC_EVALUATIVE_ADJECTIVES.has(adjective) &&
279
+ DEICTIC_DISCOURSE_NOUNS.has(noun)
280
+ ? `deictic-evaluative-${opener}-${adjective}-${noun}`
281
+ : undefined;
282
+ }
205
283
  export function isAbstractAuditFrame(words) {
206
284
  return words[0] === "the" && frameNounIndex(words) > 0
207
285
  ? words[frameNounIndex(words)] === "audit"
208
286
  : false;
209
287
  }
210
- export function matchExpandedDiscourseFrame(words) {
211
- return (matchWorthAttentionFrame(words) ??
288
+ export function matchExpandedDiscourseFrame(text, words) {
289
+ return (matchDeicticEvaluativeFrame(text, words) ??
290
+ matchWorthAttentionFrame(words) ??
212
291
  matchVagueFrameLocation(words) ??
213
292
  matchEvaluativeFrame(words));
214
293
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "slopless",
3
- "version": "0.2.26",
3
+ "version": "0.2.27",
4
4
  "description": "Deterministic textlint rules and CLI for catching prose slop in English Markdown.",
5
5
  "keywords": [
6
6
  "textlint",