linked-rolls 0.69.0 → 0.71.0

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.
Files changed (125) hide show
  1. package/README.md +20 -5
  2. package/lib/analysis/constraints.d.ts +7 -0
  3. package/lib/analysis/constraints.js +1 -0
  4. package/lib/analysis/ownPaper.d.ts +5 -1
  5. package/lib/analysis/ownPaper.js +5 -1
  6. package/lib/analysis/paper.d.ts +22 -4
  7. package/lib/analysis/paper.js +6 -0
  8. package/lib/analysis/reservations.d.ts +24 -1
  9. package/lib/analysis/reservations.js +15 -1
  10. package/lib/analysis/sigla.d.ts +6 -1
  11. package/lib/analysis/sigla.js +5 -1
  12. package/lib/analysis/stemma.d.ts +6 -1
  13. package/lib/analysis/stemma.js +6 -1
  14. package/lib/analysis/text.d.ts +16 -2
  15. package/lib/analysis/text.js +16 -2
  16. package/lib/analysis/witnesses.d.ts +20 -1
  17. package/lib/analysis/witnesses.js +4 -0
  18. package/lib/collation/Collation.d.ts +47 -8
  19. package/lib/collation/Collation.js +29 -5
  20. package/lib/collation/alignment.d.ts +16 -3
  21. package/lib/collation/alignment.js +15 -3
  22. package/lib/collation/scatter.d.ts +50 -9
  23. package/lib/collation/scatter.js +11 -1
  24. package/lib/collation/statistics.d.ts +39 -9
  25. package/lib/collation/statistics.js +27 -6
  26. package/lib/collation/substitution.d.ts +5 -0
  27. package/lib/collation/substitution.js +4 -0
  28. package/lib/emulation/Emulation.d.ts +16 -1
  29. package/lib/emulation/Emulation.js +10 -0
  30. package/lib/emulation/negotiation.d.ts +1 -0
  31. package/lib/emulation/negotiation.js +1 -0
  32. package/lib/index.d.ts +33 -2
  33. package/lib/index.js +2 -1
  34. package/lib/io/asJsonLd.d.ts +10 -0
  35. package/lib/io/asJsonLd.js +10 -0
  36. package/lib/io/context.d.ts +16 -2
  37. package/lib/io/context.js +16 -2
  38. package/lib/io/importJsonLd.d.ts +1 -0
  39. package/lib/io/importJsonLd.js +1 -0
  40. package/lib/io/migrate.d.ts +8 -0
  41. package/lib/io/migrate.js +8 -0
  42. package/lib/lookup/lookup.d.ts +29 -5
  43. package/lib/lookup/lookup.js +29 -5
  44. package/lib/lookup/paths.d.ts +23 -3
  45. package/lib/lookup/paths.js +17 -3
  46. package/lib/model/Agent.d.ts +28 -2
  47. package/lib/model/Agent.js +15 -1
  48. package/lib/model/Assumption.d.ts +96 -7
  49. package/lib/model/Assumption.js +65 -7
  50. package/lib/model/ConditionState.d.ts +1 -0
  51. package/lib/model/Edit.d.ts +10 -0
  52. package/lib/model/Edit.js +8 -0
  53. package/lib/model/Edition.d.ts +12 -1
  54. package/lib/model/Edition.js +1 -0
  55. package/lib/model/Feature.d.ts +74 -7
  56. package/lib/model/Feature.js +41 -3
  57. package/lib/model/FeatureSource.d.ts +14 -1
  58. package/lib/model/FeatureSource.js +7 -1
  59. package/lib/model/Perforator.d.ts +10 -0
  60. package/lib/model/Perforator.js +1 -0
  61. package/lib/model/Quantity.d.ts +160 -13
  62. package/lib/model/Quantity.js +110 -6
  63. package/lib/model/RollCopy.d.ts +74 -12
  64. package/lib/model/RollCopy.js +53 -10
  65. package/lib/model/Symbol.d.ts +38 -1
  66. package/lib/model/Symbol.js +16 -0
  67. package/lib/model/TrackCalibration.d.ts +10 -2
  68. package/lib/model/TrackCalibration.js +9 -2
  69. package/lib/model/Version.d.ts +24 -4
  70. package/lib/model/Version.js +19 -4
  71. package/lib/model/notes.d.ts +15 -2
  72. package/lib/model/notes.js +9 -2
  73. package/lib/model/procedures.d.ts +5 -1
  74. package/lib/model/procedures.js +5 -1
  75. package/lib/model/vocabulary.d.ts +6 -1
  76. package/lib/model/vocabulary.js +6 -1
  77. package/lib/ops/beliefs.d.ts +23 -1
  78. package/lib/ops/beliefs.js +23 -1
  79. package/lib/ops/collation.d.ts +3 -0
  80. package/lib/ops/collation.js +3 -0
  81. package/lib/ops/commands.d.ts +17 -2
  82. package/lib/ops/commands.js +17 -2
  83. package/lib/ops/copies.d.ts +37 -6
  84. package/lib/ops/copies.js +37 -6
  85. package/lib/ops/draft.d.ts +2 -0
  86. package/lib/ops/draft.js +1 -0
  87. package/lib/ops/edits.d.ts +5 -1
  88. package/lib/ops/edits.js +5 -1
  89. package/lib/ops/features.d.ts +12 -1
  90. package/lib/ops/features.js +7 -0
  91. package/lib/ops/versions.d.ts +15 -3
  92. package/lib/ops/versions.js +15 -3
  93. package/lib/readers/phillipsEroll.d.ts +12 -1
  94. package/lib/readers/phillipsEroll.js +6 -1
  95. package/lib/readers/spencerBar.d.ts +12 -1
  96. package/lib/readers/spencerBar.js +7 -1
  97. package/lib/readers/stanfordAton.d.ts +15 -0
  98. package/lib/readers/stanfordAton.js +9 -0
  99. package/lib/schema.json +13 -2
  100. package/lib/shared/utils.d.ts +12 -0
  101. package/lib/spec/context.json +8 -1
  102. package/lib/systems/ReproducingSystem.d.ts +46 -3
  103. package/lib/systems/TrackerBar.d.ts +45 -4
  104. package/lib/systems/TrackerBar.js +20 -3
  105. package/lib/systems/index.d.ts +9 -2
  106. package/lib/systems/index.js +9 -2
  107. package/lib/systems/velocity.d.ts +1 -0
  108. package/lib/systems/velocity.js +1 -0
  109. package/lib/systems/welte.d.ts +18 -3
  110. package/lib/systems/welte.js +9 -2
  111. package/lib/systems/welteLicensee/bar.d.ts +1 -0
  112. package/lib/systems/welteLicensee/bar.js +1 -0
  113. package/lib/systems/welteLicensee/system.d.ts +18 -0
  114. package/lib/systems/welteLicensee/system.js +17 -0
  115. package/lib/systems/welteT100/bar.d.ts +8 -0
  116. package/lib/systems/welteT100/bar.js +4 -0
  117. package/lib/systems/welteT100/system.d.ts +46 -5
  118. package/lib/systems/welteT100/system.js +29 -3
  119. package/lib/systems/welteT98/bar.d.ts +6 -0
  120. package/lib/systems/welteT98/bar.js +2 -0
  121. package/lib/systems/welteT98/system.d.ts +58 -5
  122. package/lib/systems/welteT98/system.js +42 -3
  123. package/lib/validate.d.ts +16 -0
  124. package/lib/validate.js +15 -0
  125. package/package.json +2 -1
@@ -2,12 +2,18 @@ import { Edit } from "../model/Edit.js";
2
2
  import { HorizontalSpan } from "../model/Feature.js";
3
3
  import { AnySymbol } from "../model/Symbol.js";
4
4
  import { Millimeters } from "../model/Quantity.js";
5
- /** A value taken at each end of a feature: where it begins and where it stops. */
5
+ /**
6
+ * A value taken at each end of a feature: where it begins and where it stops.
7
+ * @category Collation and alignment
8
+ */
6
9
  export interface BothEnds<T> {
7
10
  from: T;
8
11
  to: T;
9
12
  }
10
- /** How far one text puts a feature from where another puts it, at either end. */
13
+ /**
14
+ * How far one text puts a feature from where another puts it, at either end.
15
+ * @category Collation and alignment
16
+ */
11
17
  export type Displacement = BothEnds<Millimeters>;
12
18
  /**
13
19
  * The window two readings of one feature must fall in to be collated:
@@ -21,6 +27,7 @@ export type Displacement = BothEnds<Millimeters>;
21
27
  * tolerance stand for the scatter only. A window that names none is
22
28
  * centred on nothing, which is what every window written before the
23
29
  * offset was held here means.
30
+ * @category Format types
24
31
  */
25
32
  export interface CollationTolerance {
26
33
  /** How far the two readings may lie apart at the start of a feature, measured from `offsetStart`. */
@@ -43,10 +50,21 @@ export interface CollationTolerance {
43
50
  /** The same at the end of a feature, in the same direction. */
44
51
  offsetEnd?: Millimeters;
45
52
  }
53
+ /**
54
+ * The window a derivation that states none is collated at: five
55
+ * millimetres at either end, centred on nothing.
56
+ * @category Collation and alignment
57
+ */
46
58
  export declare const defaultCollationTolerance: CollationTolerance;
47
- /** Where the window is centred at the start of a feature, on nothing where it names no offset. */
59
+ /**
60
+ * Where the window is centred at the start of a feature, on nothing where it names no offset.
61
+ * @category Collation and alignment
62
+ */
48
63
  export declare const offsetStartOf: (tolerance: CollationTolerance) => Millimeters;
49
- /** Where the window is centred at the end of a feature. */
64
+ /**
65
+ * Where the window is centred at the end of a feature.
66
+ * @category Collation and alignment
67
+ */
50
68
  export declare const offsetEndOf: (tolerance: CollationTolerance) => Millimeters;
51
69
  /**
52
70
  * Whether the window admits the displacement at each end, taken apart.
@@ -67,23 +85,39 @@ export declare const offsetEndOf: (tolerance: CollationTolerance) => Millimeters
67
85
  * report something other than the punched slot, as a pneumatic reader
68
86
  * reports how long a valve stayed open. Long held notes are where the
69
87
  * second is likeliest, since that is where the chains are.
88
+ * @category Collation and alignment
70
89
  */
71
90
  export declare const admittedAtEnds: (tolerance: CollationTolerance, displacement: Displacement) => BothEnds<boolean>;
72
- /** Whether the window admits the displacement: within the tolerance of the offset, at both ends. */
91
+ /**
92
+ * Whether the window admits the displacement: within the tolerance of the offset, at both ends.
93
+ * @category Collation and alignment
94
+ */
73
95
  export declare const admits: (tolerance: CollationTolerance, displacement: Displacement) => boolean;
74
- /** Where a symbol lies along the roll, as its carriers put it, or nothing for a symbol without a place. */
96
+ /**
97
+ * Where a symbol lies along the roll, as its carriers put it, or nothing for a symbol without a place.
98
+ * @category Collation and alignment
99
+ */
75
100
  export type Locate = (symbol: AnySymbol) => Readonly<HorizontalSpan> | undefined;
76
101
  /**
77
102
  * Two symbols collate when they are of one kind, say the same thing
78
103
  * (pitch, or expression type and scope), and lie at about the same
79
104
  * place along the roll.
105
+ * @category Collation and alignment
80
106
  */
81
107
  export declare const isCollatable: (a: AnySymbol, b: AnySymbol, locate: Locate, tolerance?: CollationTolerance) => boolean;
108
+ /**
109
+ * One of a version's own symbols together with an inherited symbol it
110
+ * collates with, as `collationsOf` pairs them.
111
+ * @category Collation and alignment
112
+ */
82
113
  export type Collation = {
83
114
  symbol: Readonly<AnySymbol>;
84
115
  counterpart: Readonly<AnySymbol>;
85
116
  };
86
- /** Each of the own symbols with every inherited symbol it collates with, both in the order given. */
117
+ /**
118
+ * Each of the own symbols with every inherited symbol it collates with, both in the order given.
119
+ * @category Collation and alignment
120
+ */
87
121
  export declare const collationsOf: (own: readonly Readonly<AnySymbol>[], inherited: readonly Readonly<AnySymbol>[], locate: Locate, tolerance?: CollationTolerance) => Collation[];
88
122
  /**
89
123
  * The motivation a collation writes on what it makes, saying that
@@ -98,9 +132,13 @@ export declare const collationsOf: (own: readonly Readonly<AnySymbol>[], inherit
98
132
  * It does not make an edit the editor's. `isCollationsOwn` passes over
99
133
  * this motivation exactly, so a collation rewrites what it marked
100
134
  * before, and only what somebody has actually written stays.
135
+ * @category Collation and alignment
101
136
  */
102
137
  export declare const unchecked = "unchecked";
103
- /** The version's statement of what the unchecked motivation means, to stand in its `motivations`. */
138
+ /**
139
+ * The version's statement of what the unchecked motivation means, to stand in its `motivations`.
140
+ * @category Collation and alignment
141
+ */
104
142
  export declare const uncheckedMotivation: {
105
143
  readonly type: 'motivation';
106
144
  readonly id: "unchecked";
@@ -126,5 +164,6 @@ export declare const uncheckedMotivation: {
126
164
  * A recoding that only inserts or only deletes is the editor's: a
127
165
  * collation types no one-sided edit, so one typed so is a reading of
128
166
  * the transfer that collating again must not undo.
167
+ * @category Collation and alignment
129
168
  */
130
169
  export declare const isCollationsOwn: (edit: Readonly<Edit>) => boolean;
@@ -2,10 +2,21 @@ import { keyOf } from "../systems/TrackerBar.js";
2
2
  import { distance, mm } from "../model/Quantity.js";
3
3
  import { partitionPoint } from "../shared/sorted.js";
4
4
  import { groupBy } from "../shared/utils.js";
5
+ /**
6
+ * The window a derivation that states none is collated at: five
7
+ * millimetres at either end, centred on nothing.
8
+ * @category Collation and alignment
9
+ */
5
10
  export const defaultCollationTolerance = { toleranceStart: mm(5), toleranceEnd: mm(5) };
6
- /** Where the window is centred at the start of a feature, on nothing where it names no offset. */
11
+ /**
12
+ * Where the window is centred at the start of a feature, on nothing where it names no offset.
13
+ * @category Collation and alignment
14
+ */
7
15
  export const offsetStartOf = (tolerance) => tolerance.offsetStart ?? mm(0);
8
- /** Where the window is centred at the end of a feature. */
16
+ /**
17
+ * Where the window is centred at the end of a feature.
18
+ * @category Collation and alignment
19
+ */
9
20
  export const offsetEndOf = (tolerance) => tolerance.offsetEnd ?? mm(0);
10
21
  /**
11
22
  * Whether the window admits the displacement at each end, taken apart.
@@ -26,12 +37,16 @@ export const offsetEndOf = (tolerance) => tolerance.offsetEnd ?? mm(0);
26
37
  * report something other than the punched slot, as a pneumatic reader
27
38
  * reports how long a valve stayed open. Long held notes are where the
28
39
  * second is likeliest, since that is where the chains are.
40
+ * @category Collation and alignment
29
41
  */
30
42
  export const admittedAtEnds = (tolerance, displacement) => ({
31
43
  from: distance(displacement.from, offsetStartOf(tolerance)) <= tolerance.toleranceStart,
32
44
  to: distance(displacement.to, offsetEndOf(tolerance)) <= tolerance.toleranceEnd
33
45
  });
34
- /** Whether the window admits the displacement: within the tolerance of the offset, at both ends. */
46
+ /**
47
+ * Whether the window admits the displacement: within the tolerance of the offset, at both ends.
48
+ * @category Collation and alignment
49
+ */
35
50
  export const admits = (tolerance, displacement) => {
36
51
  const ends = admittedAtEnds(tolerance, displacement);
37
52
  return ends.from && ends.to;
@@ -50,6 +65,7 @@ const nearby = (here, there, tolerance) => admits(tolerance, displacementBetween
50
65
  * Two symbols collate when they are of one kind, say the same thing
51
66
  * (pitch, or expression type and scope), and lie at about the same
52
67
  * place along the roll.
68
+ * @category Collation and alignment
53
69
  */
54
70
  export const isCollatable = (a, b, locate, tolerance = defaultCollationTolerance) => {
55
71
  if (kindOf(a) !== kindOf(b))
@@ -79,7 +95,10 @@ const nearOnsetOf = (kind, span, tolerance) => {
79
95
  const end = partitionPoint(kind, candidate => candidate.horizontal.from <= highest);
80
96
  return kind.slice(first, end);
81
97
  };
82
- /** Each of the own symbols with every inherited symbol it collates with, both in the order given. */
98
+ /**
99
+ * Each of the own symbols with every inherited symbol it collates with, both in the order given.
100
+ * @category Collation and alignment
101
+ */
83
102
  export const collationsOf = (own, inherited, locate, tolerance = defaultCollationTolerance) => {
84
103
  const kinds = byKindInOrderOfOnset(placed(inherited, locate));
85
104
  return placed(own, locate).flatMap(({ symbol, horizontal }) => nearOnsetOf(kinds.get(kindOf(symbol)) ?? [], horizontal, tolerance)
@@ -102,9 +121,13 @@ const drawnByCollation = 'recoding';
102
121
  * It does not make an edit the editor's. `isCollationsOwn` passes over
103
122
  * this motivation exactly, so a collation rewrites what it marked
104
123
  * before, and only what somebody has actually written stays.
124
+ * @category Collation and alignment
105
125
  */
106
126
  export const unchecked = 'unchecked';
107
- /** The version's statement of what the unchecked motivation means, to stand in its `motivations`. */
127
+ /**
128
+ * The version's statement of what the unchecked motivation means, to stand in its `motivations`.
129
+ * @category Collation and alignment
130
+ */
108
131
  export const uncheckedMotivation = {
109
132
  type: 'motivation',
110
133
  id: unchecked,
@@ -130,6 +153,7 @@ export const uncheckedMotivation = {
130
153
  * A recoding that only inserts or only deletes is the editor's: a
131
154
  * collation types no one-sided edit, so one typed so is a reading of
132
155
  * the transfer that collating again must not undo.
156
+ * @category Collation and alignment
133
157
  */
134
158
  export const isCollationsOwn = (edit) => (edit.editType === drawnByCollation && !!edit.insert?.length && !!edit.delete?.length)
135
159
  || (edit.editType === undefined
@@ -2,9 +2,15 @@ import { FeatureOrPatch } from "../model/Feature.js";
2
2
  import { Alignment, RollCopy } from "../model/RollCopy.js";
3
3
  import { TrackerBar } from "../systems/TrackerBar.js";
4
4
  import { Millimeters } from "../model/Quantity.js";
5
- /** A place on the copy's own paper, on the edition's axis. */
5
+ /**
6
+ * A place on the copy's own paper, on the edition's axis.
7
+ * @category Collation and alignment
8
+ */
6
9
  export declare const toAxis: (alignment: Alignment | undefined) => (place: Millimeters) => Millimeters;
7
- /** A place on the edition's axis, on the copy's own paper. */
10
+ /**
11
+ * A place on the edition's axis, on the copy's own paper.
12
+ * @category Collation and alignment
13
+ */
8
14
  export declare const fromAxis: (alignment: Alignment | undefined) => (place: Millimeters) => Millimeters;
9
15
  /**
10
16
  * Carries the copy's features and tears from its own places onto the
@@ -27,7 +33,10 @@ export declare const atOwnPlaces: (copy: RollCopy) => RollCopy;
27
33
  * changed.
28
34
  */
29
35
  export declare const putOnAxis: (copy: RollCopy) => void;
30
- /** The copy's features at its own places, as it was read, whatever alignment it has. */
36
+ /**
37
+ * The copy's features at its own places, as it was read, whatever alignment it has.
38
+ * @category Collation and alignment
39
+ */
31
40
  export declare const ownFeaturesOf: (copy: RollCopy) => FeatureOrPatch[];
32
41
  /**
33
42
  * Takes the extension a pneumatic reader adds off the ends of the
@@ -63,6 +72,7 @@ export declare const ownFeaturesOf: (copy: RollCopy) => FeatureOrPatch[];
63
72
  * the port. What to do with them is an editorial question — a condition
64
73
  * on the feature, a reading of the chain, a smaller extension — and
65
74
  * `shortenChains` throws rather than answer it.
75
+ * @category Sources
66
76
  */
67
77
  export declare const tooShortToShorten: (extension: Millimeters, copy: RollCopy, leaving?: ReadonlySet<string>) => Readonly<FeatureOrPatch>[];
68
78
  /**
@@ -84,6 +94,7 @@ export declare const revertShortening: (copy: RollCopy) => void;
84
94
  * revision changes when the method does and at no other release, so
85
95
  * that an alignment found by an earlier method can be told from one
86
96
  * that would be found again as it stands.
97
+ * @category Collation and alignment
87
98
  */
88
99
  export declare const ALIGNMENT_METHOD: {
89
100
  readonly software: 'linked-rolls alignFeatures';
@@ -92,6 +103,7 @@ export declare const ALIGNMENT_METHOD: {
92
103
  /**
93
104
  * How a copy's places are carried onto another copy's:
94
105
  * `x_other = (x + shift) · scale`.
106
+ * @category Collation and alignment
95
107
  */
96
108
  export interface AlignmentResult {
97
109
  /** Applied before the scale. */
@@ -125,5 +137,6 @@ export interface AlignmentResult {
125
137
  * positions on different tracks, but they agree on the pitch each track
126
138
  * sounds, and it is the pitches that are matched. Where a copy's holes
127
139
  * have already been put onto the edition's bar, that bar reads it.
140
+ * @category Collation and alignment
128
141
  */
129
142
  export declare function alignFeatures(rollA: readonly FeatureOrPatch[], rollB: readonly FeatureOrPatch[], barA?: TrackerBar, barB?: TrackerBar): AlignmentResult | undefined;
@@ -2,9 +2,15 @@ import { featuresOf, isTear, tearsOf } from "../model/RollCopy.js";
2
2
  import { defaultTrackerBar } from "../systems/index.js";
3
3
  import { add, mm, subtract, track } from "../model/Quantity.js";
4
4
  import { partitionPoint } from "../shared/sorted.js";
5
- /** A place on the copy's own paper, on the edition's axis. */
5
+ /**
6
+ * A place on the copy's own paper, on the edition's axis.
7
+ * @category Collation and alignment
8
+ */
6
9
  export const toAxis = (alignment) => (place) => alignment ? mm((place + alignment.shift.horizontal) * alignment.scale) : place;
7
- /** A place on the edition's axis, on the copy's own paper. */
10
+ /**
11
+ * A place on the edition's axis, on the copy's own paper.
12
+ * @category Collation and alignment
13
+ */
8
14
  export const fromAxis = (alignment) => (place) => alignment ? mm(place / alignment.scale - alignment.shift.horizontal) : place;
9
15
  const acrossToAxis = (alignment) => (position) => alignment ? track(position + alignment.shift.vertical) : position;
10
16
  const acrossFromAxis = (alignment) => (position) => alignment ? track(position - alignment.shift.vertical) : position;
@@ -104,7 +110,10 @@ export const putOnAxis = (copy) => {
104
110
  if (alignment)
105
111
  moveOnto(alignment, copy);
106
112
  };
107
- /** The copy's features at its own places, as it was read, whatever alignment it has. */
113
+ /**
114
+ * The copy's features at its own places, as it was read, whatever alignment it has.
115
+ * @category Collation and alignment
116
+ */
108
117
  export const ownFeaturesOf = (copy) => {
109
118
  const alignment = copy.measurements.alignment;
110
119
  if (!alignment)
@@ -156,6 +165,7 @@ const extensionOnAxis = (extension, copy) => mm(extension * (copy.measurements.a
156
165
  * the port. What to do with them is an editorial question — a condition
157
166
  * on the feature, a reading of the chain, a smaller extension — and
158
167
  * `shortenChains` throws rather than answer it.
168
+ * @category Sources
159
169
  */
160
170
  export const tooShortToShorten = (extension, copy, leaving = new Set()) => {
161
171
  const onAxis = extensionOnAxis(extension, copy);
@@ -205,6 +215,7 @@ export const revertShortening = (copy) => {
205
215
  * revision changes when the method does and at no other release, so
206
216
  * that an alignment found by an earlier method can be told from one
207
217
  * that would be found again as it stands.
218
+ * @category Collation and alignment
208
219
  */
209
220
  export const ALIGNMENT_METHOD = { software: 'linked-rolls alignFeatures', version: '1' };
210
221
  const byPlace = (x, y) => x.at - y.at || x.pitch - y.pitch;
@@ -369,6 +380,7 @@ const resultOf = ({ line, matches }) => {
369
380
  * positions on different tracks, but they agree on the pitch each track
370
381
  * sounds, and it is the pitches that are matched. Where a copy's holes
371
382
  * have already been put onto the edition's bar, that bar reads it.
383
+ * @category Collation and alignment
372
384
  */
373
385
  export function alignFeatures(rollA, rollB, barA = defaultTrackerBar, barB = barA) {
374
386
  const a = noteOnsets(rollA, barA);
@@ -16,7 +16,10 @@ import { Edition } from "../model/Edition.js";
16
16
  * the measurement yields is a screen: it says which readings the curve
17
17
  * does not account for, and an editor says which of those are acts.
18
18
  */
19
- /** Where one copy puts a symbol, against where the copies read with it put it. */
19
+ /**
20
+ * Where one copy puts a symbol, against where the copies read with it put it.
21
+ * @category Collation and alignment
22
+ */
20
23
  export interface Reading {
21
24
  symbol: Readonly<AnySymbol>;
22
25
  /** The copies under test less the rest, at either end of the symbol. */
@@ -43,6 +46,7 @@ export interface Reading {
43
46
  *
44
47
  * A symbol only one side carries measures nothing and is passed over,
45
48
  * which leaves out exactly the insertions and the deletions.
49
+ * @category Collation and alignment
46
50
  */
47
51
  export declare const readingsOf: (edition: Edition, symbols: readonly Readonly<AnySymbol>[], copies: ReadonlySet<string>) => Reading[];
48
52
  /**
@@ -59,8 +63,14 @@ export declare const readingsOf: (edition: Edition, symbols: readonly Readonly<A
59
63
  * notes. Once the alignment carries a skew term, one sample will do,
60
64
  * which is why this is a parameter of the estimator and not a field
61
65
  * anywhere.
66
+ * @category Collation and alignment
62
67
  */
63
68
  export type Grouping = (symbol: Readonly<AnySymbol>) => string;
69
+ /**
70
+ * How `scatterOf` takes the readings apart into samples, counts them,
71
+ * and reports on them.
72
+ * @category Collation and alignment
73
+ */
64
74
  export interface ScatterOptions {
65
75
  /** What sample a reading belongs to. By default what the symbol is: a note, an expression, a text. */
66
76
  groupOf?: Grouping;
@@ -69,7 +79,10 @@ export interface ScatterOptions {
69
79
  /** The tolerance the derivation states at present, against which each departure is reported as still admitted or not. */
70
80
  stated?: CollationTolerance;
71
81
  }
72
- /** A reading the calculated tolerance does not admit. */
82
+ /**
83
+ * A reading the calculated tolerance does not admit.
84
+ * @category Collation and alignment
85
+ */
73
86
  export interface Departure {
74
87
  /** The symbol read. */
75
88
  symbol: string;
@@ -103,14 +116,20 @@ export interface Departure {
103
116
  */
104
117
  admittedAsStated?: boolean;
105
118
  }
106
- /** How far a sample departs from the normal shape the tolerance assumes of it. */
119
+ /**
120
+ * How far a sample departs from the normal shape the tolerance assumes of it.
121
+ * @category Collation and alignment
122
+ */
107
123
  export interface Normality {
108
124
  /** How much heavier its tails are than a normal sample's. Nothing for a normal shape. */
109
125
  excessKurtosis: number;
110
126
  /** What it puts beyond two, three and four times the scatter, against what a normal sample would. */
111
127
  tails: Tail[];
112
128
  }
113
- /** A histogram with the curve its counts are held to follow. */
129
+ /**
130
+ * A histogram with the curve its counts are held to follow.
131
+ * @category Collation and alignment
132
+ */
114
133
  export interface FittedHistogram extends Histogram<'mm'> {
115
134
  /**
116
135
  * The normal curve, in the counts' own units, so that an overlay is
@@ -123,7 +142,10 @@ export interface FittedHistogram extends Histogram<'mm'> {
123
142
  area: number;
124
143
  };
125
144
  }
126
- /** How far one sample of readings scatters, and the tolerance that follows from it. */
145
+ /**
146
+ * How far one sample of readings scatters, and the tolerance that follows from it.
147
+ * @category Collation and alignment
148
+ */
127
149
  export interface Scatter {
128
150
  /** The sample, as the grouping named it. */
129
151
  group: string;
@@ -157,19 +179,25 @@ export interface Scatter {
157
179
  * point beyond which fewer than one reading of a sample of this size is
158
180
  * expected to fall by chance. For the samples an edge of the stemma
159
181
  * yields, some hundreds of readings, this lands between 3.0 and 3.2.
182
+ * @category Collation and alignment
160
183
  */
161
184
  export declare const departureThreshold: (n: number) => number;
162
185
  /**
163
186
  * How the readings scatter, one sample per group. A group whose
164
187
  * readings all sit at one place yields nothing, since no scatter can be
165
188
  * read off such a sample.
189
+ * @category Collation and alignment
166
190
  */
167
191
  export declare const scatterOf: (readings: readonly Reading[], options?: ScatterOptions) => Scatter[];
168
- /** How one copy's readings of a version's text scatter against the readings of the copies it is collated with. */
192
+ /**
193
+ * How one copy's readings of a version's text scatter against the readings of the copies it is collated with.
194
+ * @category Collation and alignment
195
+ */
169
196
  export declare const scatterOfCopy: (edition: Edition, versionId: string, copyId: string, options?: ScatterOptions) => Scatter[];
170
197
  /**
171
198
  * Which side of a derivation a measurement was taken over: the version
172
199
  * derived, or the version it is read against.
200
+ * @category Collation and alignment
173
201
  */
174
202
  export type Side = 'child' | 'parent';
175
203
  /**
@@ -201,9 +229,13 @@ export type Side = 'child' | 'parent';
201
229
  * expressions show. `changesBetween` makes that visible as readings the
202
230
  * window moves; it is the price of one tolerance per derivation, and it
203
231
  * is the same skew the grouping stands in for.
232
+ * @category Collation and alignment
204
233
  */
205
234
  export declare const toleranceAcross: (scatters: readonly Scatter[], named: Side) => CollationTolerance | undefined;
206
- /** What putting one window in force in place of another would do to a collation. */
235
+ /**
236
+ * What putting one window in force in place of another would do to a collation.
237
+ * @category Collation and alignment
238
+ */
207
239
  export interface Changes {
208
240
  /** Readings the window in force joins and the proposed one would take apart. */
209
241
  separated: Reading[];
@@ -225,14 +257,21 @@ export interface Changes {
225
257
  * reading `admittedAsStated` off the departures, which sees separations
226
258
  * only. An edge both windows agree about throughout needs no
227
259
  * re-collation at all, and its tolerance may simply be stated.
260
+ * @category Collation and alignment
228
261
  */
229
262
  export declare const changesBetween: (readings: readonly Reading[], inForce: CollationTolerance, proposed: CollationTolerance) => Changes;
230
- /** How many of a side's symbols a copy bears. */
263
+ /**
264
+ * How many of a side's symbols a copy bears.
265
+ * @category Collation and alignment
266
+ */
231
267
  export interface Attestation {
232
268
  copy: string;
233
269
  symbols: number;
234
270
  }
235
- /** The copies attesting each side of a derivation, each side in order of how much it bears. */
271
+ /**
272
+ * The copies attesting each side of a derivation, each side in order of how much it bears.
273
+ * @category Collation and alignment
274
+ */
236
275
  export interface Sides {
237
276
  /** The copies bearing what the child inserts: the reading the derivation moves to. */
238
277
  child: Attestation[];
@@ -255,6 +294,7 @@ export interface Sides {
255
294
  * A fully collated edge inserts and deletes nothing and so attests
256
295
  * neither side, which is the case where the edition has genuinely
257
296
  * stopped saying and an editor has to.
297
+ * @category Collation and alignment
258
298
  */
259
299
  export declare const sidesOf: (edition: Edition, versionId: string) => Sides | undefined;
260
300
  /**
@@ -268,5 +308,6 @@ export declare const sidesOf: (edition: Edition, versionId: string) => Sides | u
268
308
  * sample only as far as the sample is normal, and a sample far from
269
309
  * that shape makes the number unreliable rather than wrong, which is
270
310
  * what `normality` is reported for.
311
+ * @category Collation and alignment
271
312
  */
272
313
  export declare const inferredTolerance: (scatters: readonly Scatter[], used?: readonly string[]) => Belief;
@@ -35,6 +35,7 @@ const sitsOn = (edition, copies) => (feature) => {
35
35
  *
36
36
  * A symbol only one side carries measures nothing and is passed over,
37
37
  * which leaves out exactly the insertions and the deletions.
38
+ * @category Collation and alignment
38
39
  */
39
40
  export const readingsOf = (edition, symbols, copies) => {
40
41
  const tested = sitsOn(edition, copies);
@@ -58,6 +59,7 @@ const DEFAULT_BIN_WIDTH = mm(0.25);
58
59
  * point beyond which fewer than one reading of a sample of this size is
59
60
  * expected to fall by chance. For the samples an edge of the stemma
60
61
  * yields, some hundreds of readings, this lands between 3.0 and 3.2.
62
+ * @category Collation and alignment
61
63
  */
62
64
  export const departureThreshold = (n) => normalQuantile(1 - 1 / (2 * n));
63
65
  const estimate = (values, binWidth) => {
@@ -118,10 +120,14 @@ const scatterIn = (group, sample, { binWidth = DEFAULT_BIN_WIDTH, stated }) => {
118
120
  * How the readings scatter, one sample per group. A group whose
119
121
  * readings all sit at one place yields nothing, since no scatter can be
120
122
  * read off such a sample.
123
+ * @category Collation and alignment
121
124
  */
122
125
  export const scatterOf = (readings, options = {}) => [...groupBy(readings, reading => (options.groupOf ?? byWhatItIs)(reading.symbol))]
123
126
  .flatMap(([group, sample]) => scatterIn(group, sample, options));
124
- /** How one copy's readings of a version's text scatter against the readings of the copies it is collated with. */
127
+ /**
128
+ * How one copy's readings of a version's text scatter against the readings of the copies it is collated with.
129
+ * @category Collation and alignment
130
+ */
125
131
  export const scatterOfCopy = (edition, versionId, copyId, options = {}) => scatterOf(readingsOf(edition, snapshotOf(edition, versionId), new Set([copyId])), options);
126
132
  const covering = (windows) => {
127
133
  const lowest = Math.min(...windows.map(window => window.offset - window.tolerance));
@@ -157,6 +163,7 @@ const covering = (windows) => {
157
163
  * expressions show. `changesBetween` makes that visible as readings the
158
164
  * window moves; it is the price of one tolerance per derivation, and it
159
165
  * is the same skew the grouping stands in for.
166
+ * @category Collation and alignment
160
167
  */
161
168
  export const toleranceAcross = (scatters, named) => {
162
169
  if (scatters.length === 0)
@@ -186,6 +193,7 @@ export const toleranceAcross = (scatters, named) => {
186
193
  * reading `admittedAsStated` off the departures, which sees separations
187
194
  * only. An edge both windows agree about throughout needs no
188
195
  * re-collation at all, and its tolerance may simply be stated.
196
+ * @category Collation and alignment
189
197
  */
190
198
  export const changesBetween = (readings, inForce, proposed) => ({
191
199
  separated: readings.filter(({ displacement }) => admits(inForce, displacement) && !admits(proposed, displacement)),
@@ -220,6 +228,7 @@ const copiesBearing = (edition, symbols) => {
220
228
  * A fully collated edge inserts and deletes nothing and so attests
221
229
  * neither side, which is the case where the edition has genuinely
222
230
  * stopped saying and an editor has to.
231
+ * @category Collation and alignment
223
232
  */
224
233
  export const sidesOf = (edition, versionId) => {
225
234
  const version = versionIn(edition, versionId);
@@ -251,6 +260,7 @@ const warrantFor = (scatters) => 'The tolerance is calculated from the scatter o
251
260
  * sample only as far as the sample is normal, and a sample far from
252
261
  * that shape makes the number unreliable rather than wrong, which is
253
262
  * what `normality` is reported for.
263
+ * @category Collation and alignment
254
264
  */
255
265
  export const inferredTolerance = (scatters, used = []) => ({
256
266
  type: 'belief',
@@ -9,9 +9,15 @@ import { Quantity } from "../model/Quantity.js";
9
9
  * stood out; a median and a median absolute deviation leave them out of
10
10
  * account.
11
11
  */
12
- /** The middle of a sample, the mean of the two middle values where it has an even number of them. */
12
+ /**
13
+ * The middle of a sample, the mean of the two middle values where it has an even number of them.
14
+ * @internal
15
+ */
13
16
  export declare const medianOf: <U extends string>(values: readonly Quantity<U>[]) => Quantity<U> | undefined;
14
- /** Where a sample sits and how far it scatters. */
17
+ /**
18
+ * Where a sample sits and how far it scatters.
19
+ * @category Collation and alignment
20
+ */
15
21
  export interface Spread<U extends string> {
16
22
  /** How many measurements it was taken over. */
17
23
  n: number;
@@ -25,27 +31,44 @@ export interface Spread<U extends string> {
25
31
  */
26
32
  sigma: Quantity<U>;
27
33
  }
28
- /** Where the sample sits and how far it scatters, or nothing for an empty sample. */
34
+ /**
35
+ * Where the sample sits and how far it scatters, or nothing for an empty sample.
36
+ * @internal
37
+ */
29
38
  export declare const spreadOf: <U extends string>(values: readonly Quantity<U>[]) => Spread<U> | undefined;
30
- /** How far the value lies from the centre of the spread, in units of its scatter. */
39
+ /**
40
+ * How far the value lies from the centre of the spread, in units of its scatter.
41
+ * @internal
42
+ */
31
43
  export declare const standardise: <U extends string>(value: Quantity<U>, spread: Spread<U>) => number;
32
- /** The share of a normal sample lying below `z` standard deviations. */
44
+ /**
45
+ * The share of a normal sample lying below `z` standard deviations.
46
+ * @internal
47
+ */
33
48
  export declare const normalBelow: (z: number) => number;
34
- /** The share of a normal sample lying further than `z` standard deviations from its centre, on either side. */
49
+ /**
50
+ * The share of a normal sample lying further than `z` standard deviations from its centre, on either side.
51
+ * @internal
52
+ */
35
53
  export declare const normalBeyond: (z: number) => number;
36
54
  /**
37
55
  * How many standard deviations out the given share of a normal sample
38
56
  * lies below, after Acklam's rational approximation, whose relative
39
57
  * error stays below 1.15e-9. The inverse of `normalBelow`.
58
+ * @internal
40
59
  */
41
60
  export declare const normalQuantile: (share: number) => number;
42
61
  /**
43
62
  * How much heavier the tails of a standardised sample are than a normal
44
63
  * sample's. Zero for a normal shape, positive where more of the sample
45
64
  * lies far out than the curve allows.
65
+ * @internal
46
66
  */
47
67
  export declare const excessKurtosisOf: (standardised: readonly number[]) => number;
48
- /** How much of a sample lies beyond a given distance from its centre, against how much would under a normal curve. */
68
+ /**
69
+ * How much of a sample lies beyond a given distance from its centre, against how much would under a normal curve.
70
+ * @category Collation and alignment
71
+ */
49
72
  export interface Tail {
50
73
  /** The distance from the centre, in standard deviations. */
51
74
  beyond: number;
@@ -54,9 +77,15 @@ export interface Tail {
54
77
  /** How many a normal sample of the same size would put there. */
55
78
  expected: number;
56
79
  }
57
- /** What the sample puts beyond the given distance, against what a normal sample would. */
80
+ /**
81
+ * What the sample puts beyond the given distance, against what a normal sample would.
82
+ * @internal
83
+ */
58
84
  export declare const tailOf: (standardised: readonly number[], beyond: number) => Tail;
59
- /** A sample counted into bins of one width. */
85
+ /**
86
+ * A sample counted into bins of one width.
87
+ * @category Collation and alignment
88
+ */
60
89
  export interface Histogram<U extends string> {
61
90
  /** The bounds of the bins, in order, one more of them than there are counts. */
62
91
  edges: Quantity<U>[];
@@ -67,5 +96,6 @@ export interface Histogram<U extends string> {
67
96
  * The sample counted into bins of the given width, laid out on
68
97
  * multiples of that width so that two histograms of one width share
69
98
  * their bounds. Nothing for an empty sample or a width of nothing.
99
+ * @internal
70
100
  */
71
101
  export declare const histogramOf: <U extends string>(values: readonly Quantity<U>[], binWidth: Quantity<U>) => Histogram<U> | undefined;