dravoice 0.1.1 → 0.1.3
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/LICENSE +21 -21
- package/README.md +102 -36
- package/bin/dravoice.js +11 -10
- package/package.json +47 -45
- package/src/index.js +874 -197
- package/src/v2/analyzers/discourse.js +63 -52
- package/src/v2/analyzers/evidence.js +73 -38
- package/src/v2/analyzers/lexical.js +114 -58
- package/src/v2/analyzers/register.js +46 -34
- package/src/v2/analyzers/rhetorical-shape.js +59 -48
- package/src/v2/analyzers/rhythm.js +39 -47
- package/src/v2/analyzers/structure.js +24 -24
- package/src/v2/benchmark.js +574 -568
- package/src/v2/brief.js +154 -146
- package/src/v2/config.js +78 -0
- package/src/v2/document-model.js +351 -260
- package/src/v2/inspect.js +67 -67
- package/src/v2/io-utils.js +51 -0
- package/src/v2/profile.js +155 -129
- package/src/v2/prompt.js +65 -64
- package/src/v2/review.js +177 -219
- package/src/v2/revise-plan.js +130 -33
- package/src/v2/stylometry.js +123 -17
- package/src/v2/text-utils.js +123 -123
|
@@ -1,47 +1,39 @@
|
|
|
1
|
-
import { distribution, rate } from "../text-utils.js";
|
|
2
|
-
|
|
3
|
-
export function analyzeRhythm(documents) {
|
|
4
|
-
const sentences = documents.flatMap((document) => document.sentences);
|
|
5
|
-
const paragraphs = documents.flatMap((document) => document.paragraphs);
|
|
6
|
-
const blocks = documents.flatMap((document) => document.blocks);
|
|
7
|
-
|
|
8
|
-
return {
|
|
9
|
-
family: "rhythm",
|
|
10
|
-
confidence: confidenceFor(sentences.length),
|
|
11
|
-
features: {
|
|
12
|
-
documentCount: documents.length,
|
|
13
|
-
sentenceCount: sentences.length,
|
|
14
|
-
paragraphCount: paragraphs.length,
|
|
15
|
-
sentenceWords: distribution(sentences.map((sentence) => sentence.tokens.length)),
|
|
16
|
-
paragraphWords: distribution(paragraphs.map((paragraph) => paragraph.text.split(/\s+/).filter(Boolean).length)),
|
|
17
|
-
paragraphSentences: distribution(paragraphs.map((paragraph) =>
|
|
18
|
-
headingDensity: rate(documents.reduce((sum, document) => sum + document.headings.length, 0), sentences.length, 2),
|
|
19
|
-
listDensity: rate(blocks.filter((block) => block.type === "list").length, paragraphs.length, 2),
|
|
20
|
-
quoteDensity: rate(blocks.filter((block) => block.type === "quote").length, paragraphs.length, 2),
|
|
21
|
-
},
|
|
22
|
-
examples: [
|
|
23
|
-
`sentenceWords.median: ${distribution(sentences.map((sentence) => sentence.tokens.length)).median}`,
|
|
24
|
-
`paragraphWords.median: ${distribution(paragraphs.map((paragraph) => paragraph.text.split(/\s+/).filter(Boolean).length)).median}`,
|
|
25
|
-
],
|
|
26
|
-
warnings: sentences.length < 12 ? ["Rhythm confidence is limited because the corpus has fewer than 12 usable sentences."] : [],
|
|
27
|
-
revisionHandles: ["Compare sentence and paragraph pacing against the learned range."],
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
if (sentenceCount >= 30) {
|
|
41
|
-
return "high";
|
|
42
|
-
}
|
|
43
|
-
if (sentenceCount >= 8) {
|
|
44
|
-
return "medium";
|
|
45
|
-
}
|
|
46
|
-
return "low";
|
|
47
|
-
}
|
|
1
|
+
import { distribution, rate, splitSentences } from "../text-utils.js";
|
|
2
|
+
|
|
3
|
+
export function analyzeRhythm(documents) {
|
|
4
|
+
const sentences = documents.flatMap((document) => document.sentences);
|
|
5
|
+
const paragraphs = documents.flatMap((document) => document.paragraphs);
|
|
6
|
+
const blocks = documents.flatMap((document) => document.blocks);
|
|
7
|
+
|
|
8
|
+
return {
|
|
9
|
+
family: "rhythm",
|
|
10
|
+
confidence: confidenceFor(sentences.length),
|
|
11
|
+
features: {
|
|
12
|
+
documentCount: documents.length,
|
|
13
|
+
sentenceCount: sentences.length,
|
|
14
|
+
paragraphCount: paragraphs.length,
|
|
15
|
+
sentenceWords: distribution(sentences.map((sentence) => sentence.tokens.length)),
|
|
16
|
+
paragraphWords: distribution(paragraphs.map((paragraph) => paragraph.text.split(/\s+/).filter(Boolean).length)),
|
|
17
|
+
paragraphSentences: distribution(paragraphs.map((paragraph) => Math.max(1, splitSentences(paragraph.text).length))),
|
|
18
|
+
headingDensity: rate(documents.reduce((sum, document) => sum + document.headings.length, 0), sentences.length, 2),
|
|
19
|
+
listDensity: rate(blocks.filter((block) => block.type === "list").length, paragraphs.length, 2),
|
|
20
|
+
quoteDensity: rate(blocks.filter((block) => block.type === "quote").length, paragraphs.length, 2),
|
|
21
|
+
},
|
|
22
|
+
examples: [
|
|
23
|
+
`sentenceWords.median: ${distribution(sentences.map((sentence) => sentence.tokens.length)).median}`,
|
|
24
|
+
`paragraphWords.median: ${distribution(paragraphs.map((paragraph) => paragraph.text.split(/\s+/).filter(Boolean).length)).median}`,
|
|
25
|
+
],
|
|
26
|
+
warnings: sentences.length < 12 ? ["Rhythm confidence is limited because the corpus has fewer than 12 usable sentences."] : [],
|
|
27
|
+
revisionHandles: ["Compare sentence and paragraph pacing against the learned range."],
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function confidenceFor(sentenceCount) {
|
|
32
|
+
if (sentenceCount >= 30) {
|
|
33
|
+
return "high";
|
|
34
|
+
}
|
|
35
|
+
if (sentenceCount >= 8) {
|
|
36
|
+
return "medium";
|
|
37
|
+
}
|
|
38
|
+
return "low";
|
|
39
|
+
}
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import { distribution, rate } from "../text-utils.js";
|
|
2
|
-
import { moveFor } from "./rhetorical-shape.js";
|
|
3
|
-
|
|
4
|
-
export function analyzeStructure(documents) {
|
|
5
|
-
const sectionLengths = documents.flatMap((document) =>
|
|
6
|
-
document.sections.map((section) => section.blocks.reduce((sum, block) => sum + block.lines.join(" ").split(/\s+/).filter(Boolean).length, 0))
|
|
7
|
-
);
|
|
8
|
-
const openingMoves = documents.flatMap((document) => document.sentences.slice(0, 2).map((sentence) => moveFor(sentence.text)));
|
|
9
|
-
|
|
10
|
-
return {
|
|
11
|
-
family: "structure",
|
|
12
|
-
confidence: documents.length >= 3 ? "medium" : "low",
|
|
13
|
-
features: {
|
|
14
|
-
sectionWords: distribution(sectionLengths),
|
|
15
|
-
headingCount: distribution(documents.map((document) => document.headings.length)),
|
|
16
|
-
openingMoves,
|
|
17
|
-
listDocumentRate: rate(documents.filter((document) => document.blocks.some((block) => block.type === "list")).length, documents.length, 2),
|
|
18
|
-
quoteDocumentRate: rate(documents.filter((document) => document.blocks.some((block) => block.type === "quote")).length, documents.length, 2),
|
|
19
|
-
},
|
|
20
|
-
examples: openingMoves.slice(0, 5),
|
|
21
|
-
warnings: documents.length < 3 ? ["Structure confidence is limited because the corpus has fewer than 3 documents."] : [],
|
|
22
|
-
revisionHandles: ["Compare headings, list/quote use, section size, and opening structure."],
|
|
23
|
-
};
|
|
24
|
-
}
|
|
1
|
+
import { distribution, rate } from "../text-utils.js";
|
|
2
|
+
import { moveFor } from "./rhetorical-shape.js";
|
|
3
|
+
|
|
4
|
+
export function analyzeStructure(documents) {
|
|
5
|
+
const sectionLengths = documents.flatMap((document) =>
|
|
6
|
+
document.sections.map((section) => section.blocks.reduce((sum, block) => sum + block.lines.join(" ").split(/\s+/).filter(Boolean).length, 0))
|
|
7
|
+
);
|
|
8
|
+
const openingMoves = documents.flatMap((document) => document.sentences.slice(0, 2).map((sentence) => moveFor(sentence.text)));
|
|
9
|
+
|
|
10
|
+
return {
|
|
11
|
+
family: "structure",
|
|
12
|
+
confidence: documents.length >= 3 ? "medium" : "low",
|
|
13
|
+
features: {
|
|
14
|
+
sectionWords: distribution(sectionLengths),
|
|
15
|
+
headingCount: distribution(documents.map((document) => document.headings.length)),
|
|
16
|
+
openingMoves,
|
|
17
|
+
listDocumentRate: rate(documents.filter((document) => document.blocks.some((block) => block.type === "list")).length, documents.length, 2),
|
|
18
|
+
quoteDocumentRate: rate(documents.filter((document) => document.blocks.some((block) => block.type === "quote")).length, documents.length, 2),
|
|
19
|
+
},
|
|
20
|
+
examples: openingMoves.slice(0, 5),
|
|
21
|
+
warnings: documents.length < 3 ? ["Structure confidence is limited because the corpus has fewer than 3 documents."] : [],
|
|
22
|
+
revisionHandles: ["Compare headings, list/quote use, section size, and opening structure."],
|
|
23
|
+
};
|
|
24
|
+
}
|