@yegor256/dogent 0.7.7 → 0.7.8
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.
- package/package.json +1 -1
- package/src/rules/atomic.js +9 -11
package/package.json
CHANGED
package/src/rules/atomic.js
CHANGED
|
@@ -12,18 +12,20 @@ const Region = require('../region');
|
|
|
12
12
|
* Atomic.
|
|
13
13
|
*
|
|
14
14
|
* Demands that every line carry exactly one instruction. A standalone
|
|
15
|
-
* checker only
|
|
16
|
-
* mid-line with more text after it, or two
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
15
|
+
* checker spots only the unambiguous signs: a sentence terminator
|
|
16
|
+
* sitting mid-line with more text after it, or two clauses welded
|
|
17
|
+
* together by a semicolon. An " and " or " then " is left alone, since
|
|
18
|
+
* no suffix heuristic can tell a second verb from a coordinated object
|
|
19
|
+
* or temporal adverb without reading the word as language. The prompt
|
|
20
|
+
* hands that subtler clause-counting to the AI oracle, which weighs the
|
|
21
|
+
* full sentence before judging a line as multi-instruction.
|
|
20
22
|
*/
|
|
21
23
|
class Atomic {
|
|
22
24
|
constructor() {
|
|
23
25
|
this.id = 'atomic';
|
|
24
26
|
}
|
|
25
27
|
prompt() {
|
|
26
|
-
return `${this.id}: flag any line that carries more than one instruction, counting distinct clauses
|
|
28
|
+
return `${this.id}: flag any line that carries more than one instruction, counting distinct clauses whether or not a semicolon, "and", or "then" welds them, yet never count a coordinated object or noun phrase trailing "and" or "then" as a second instruction`;
|
|
27
29
|
}
|
|
28
30
|
violations(document) {
|
|
29
31
|
const uri = document.uri();
|
|
@@ -37,11 +39,7 @@ class Atomic {
|
|
|
37
39
|
}
|
|
38
40
|
judge(text, line, uri) {
|
|
39
41
|
const clean = text.replace(/^\s*(?:[-*+]|\d+\.)\s+/u, '').trimEnd();
|
|
40
|
-
|
|
41
|
-
const welded = weld !== null &&
|
|
42
|
-
!/^(?:the|a|an)$/u.test(weld.groups.verb) &&
|
|
43
|
-
!/(?:ly|al|ial|ous|ive|less|ic|ary|ory|able|ible|ate)$/u.test(weld.groups.verb);
|
|
44
|
-
if (!/[.!?]\s+\S/u.test(clean) && !/;/u.test(clean) && !welded) {
|
|
42
|
+
if (!/[.!?]\s+\S/u.test(clean) && !/;/u.test(clean)) {
|
|
45
43
|
return [];
|
|
46
44
|
}
|
|
47
45
|
return [new Violation(
|