linked-rolls 0.75.0 → 0.76.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.
@@ -1,8 +1,7 @@
1
1
  import { Edition } from "../model/Edition.js";
2
- import { Edit, EditType } from "../model/Edit.js";
2
+ import { EditShape } from "../model/Edit.js";
3
3
  import { Millimeters } from "../model/Quantity.js";
4
4
  import { EditionOp } from "../ops/draft.js";
5
- import { Run } from "./record.js";
6
5
  /**
7
6
  * How far a perforation may be put from where it stood for the two to be
8
7
  * one move. WM 225 moves commands by up to about 60 mm.
@@ -70,8 +69,8 @@ export interface ProposedEdit {
70
69
  insert: string[];
71
70
  /** The ids of the symbols it deletes, in the order of their places. */
72
71
  delete: string[];
73
- /** The kind of change, where its shape says. */
74
- editType?: EditType;
72
+ /** The shape of the change, where it takes one the program knows. */
73
+ shape?: EditShape;
75
74
  grouping: EditGrouping;
76
75
  }
77
76
  /**
@@ -95,8 +94,8 @@ export interface ProposedEdit {
95
94
  * punched across three lines or more at one place are one edit, as a
96
95
  * cancel row is.
97
96
  *
98
- * The type is read off the shape: a pair the bar spells an accent with is
99
- * an additional accent, as is a note set off from its chord by a few
97
+ * The shape is read off the group: a pair the bar spells an accent with
98
+ * is an additional accent, as is a note set off from its chord by a few
100
99
  * millimetres where the version puts an accent's On; a perforation put
101
100
  * elsewhere is a shift, or where it begins about where the other did,
102
101
  * shortened or prolonged; a note struck again is shortened, two tied
@@ -111,35 +110,41 @@ export interface ProposedEdit {
111
110
  */
112
111
  export declare const proposeEdits: (edition: Edition, versionId: string, options?: EditOptions) => ProposedEdit[];
113
112
  /**
114
- * Whether the edit is left for a proposal to group again: one a
115
- * collation or an adoption wrote, that nobody has given a motivation.
113
+ * The motivation a program states for each change the version makes,
114
+ * by the id of the symbol it inserts or deletes: the one the shape of
115
+ * the proposed edit it belongs to calls for (`motivationProposedFor`),
116
+ * musical or technical. A version that derives from none makes no
117
+ * change, and its symbols are given none.
116
118
  * @category Filiation
117
119
  */
118
- export declare const isRegroupable: (edit: Readonly<Edit>) => boolean;
120
+ export declare const proposedMotivations: (edition: Edition, versionId: string, options?: EditOptions) => ReadonlyMap<string, string>;
119
121
  /**
120
- * Puts the proposed edits (`proposeEdits`) in place of those of the
121
- * versions that a collation or an adoption wrote and nobody has given a
122
- * motivation, every version but the root where none are named. An edit
123
- * someone motivated, typed beyond what a collation types, or held under a
124
- * belief stays as it is, and what a proposed edit shares with it stands
125
- * symbol by symbol beside it. An edit stated already over the very same
126
- * symbols as a proposed one is kept with its id and what was written on
127
- * it, the proposed type filled in where it states none; the others are
128
- * new, with ids that adopting again gives again, and marked unchecked,
129
- * so that what is left to the editor is to say why.
122
+ * The motivation a program states for an edit making these changes:
123
+ * the generic musical one where any of them is a musical change, or one
124
+ * the proposal does not see, and the technical one where all are
125
+ * technical.
126
+ */
127
+ export declare const motivationOfChanges: (motivations: ReadonlyMap<string, string>, symbolIds: readonly string[]) => string;
128
+ /**
129
+ * Puts the proposed edits (`proposeEdits`) in place of the program's
130
+ * edits of the versions, every version but the root where none are
131
+ * named: those that say nothing of why they were made, or only that they
132
+ * are musical or technical changes (`isCollationsOwn`). An edit with a
133
+ * motivation of the editor's or held under a belief stays as it is, and
134
+ * what a proposed edit shares with it stands symbol by symbol beside it.
135
+ * An edit stated already over the very same symbols as a proposed one
136
+ * is kept with its id and the kind of change it states, which the
137
+ * editor may have said otherwise than the program read it; the others
138
+ * are new, with ids that adopting again gives again. An edit that
139
+ * states no kind has the motivation its shape calls for
140
+ * (`motivationProposedFor`): the generic musical one for a musical
141
+ * change, whose reason is left to the editor, and the technical one for
142
+ * a technical change.
130
143
  *
131
144
  * Applied on the same draft after `adoptStemma`, it proposes the edits of
132
- * the stemma adopted, as one undo step.
133
- *
134
- * The edits it proposes are recorded as one proposition set, held under
135
- * one belief, likely unless the run says otherwise, whose reason is the
136
- * inference the program drew: it names this library and its release,
137
- * the versions it read, the rule that keeps an edit at one place and, in
138
- * its note, the distances it grouped with, and it rests on the beliefs
139
- * the derivations of the versions are held with. An edit of the set
140
- * that nobody has motivated is the program's, typed and all, and a
141
- * later proposal groups it again. The run gives who ran the program and
142
- * when (`Run`).
145
+ * the stemma adopted, as one undo step. The edition's creation comes to
146
+ * name the rule that keeps an edit at one place among its principles,
147
+ * and this release among its software.
143
148
  * @category Operations
144
149
  */
145
- export declare const adoptEdits: (versionIds?: readonly string[], options?: EditOptions, run?: Run) => EditionOp;
150
+ export declare const adoptEdits: (versionIds?: readonly string[], options?: EditOptions) => EditionOp;
@@ -1,23 +1,24 @@
1
1
  /**
2
2
  * The edits of a version, proposed from what it inserts and deletes:
3
- * which of its changes belong together, and what kind of change each
4
- * group is. Why a change was made is left to the editor.
3
+ * which of its changes belong together, and what shape each group
4
+ * takes, from which the motivation a program can give it follows. Why
5
+ * a musical change was made is left to the editor.
5
6
  */
6
7
  import { v5 } from "uuid";
7
- import { beliefIn } from "../model/Assumption.js";
8
- import { deletedBy, editsOf, insertedBy, principalDerivationOf } from "../model/Version.js";
8
+ import { motivationProposedFor, musicalChange, technicalChange } from "../model/Edit.js";
9
+ import { deletedBy, editsOf, insertedBy } from "../model/Version.js";
9
10
  import { distance, mm, subtract } from "../model/Quantity.js";
10
11
  import { trackerBarOf } from "../systems/index.js";
11
12
  import { operationOf, substitutionsBetween } from "../collation/substitution.js";
12
- import { isCollationsOwn, unchecked } from "../collation/Collation.js";
13
+ import { isCollationsOwn } from "../collation/Collation.js";
13
14
  import { predecessorOf } from "../analysis/stemma.js";
14
15
  import { placeOf, snapshotOf } from "../analysis/text.js";
15
16
  import { symbolsIn, versionIn } from "../lookup/lookup.js";
16
17
  import { groupBy } from "../shared/utils.js";
17
- import { declaring, reading } from "../ops/draft.js";
18
+ import { reading } from "../ops/draft.js";
18
19
  import { ineffectiveAmong } from "./presence.js";
19
20
  import { reads } from "./readings.js";
20
- import { editRules, inMillimetres, keptSets, memberOf, recorded } from "./record.js";
21
+ import { editRules, madeWith } from "./record.js";
21
22
  /**
22
23
  * How far a perforation may be put from where it stood for the two to be
23
24
  * one move. WM 225 moves commands by up to about 60 mm.
@@ -280,8 +281,8 @@ const rowsAmong = (groups, within) => {
280
281
  };
281
282
  /** Whether the bar spells an accent with exactly these commands. */
282
283
  const spellsAccent = (bar, types) => (bar?.accents ?? []).some(accent => sameSequence(types, accent));
283
- /** What kind of change a group is, where its shape says. */
284
- const typeOf = (group, bar, accentsAt, options) => {
284
+ /** The shape a group of changes takes, where it is one the program knows. */
285
+ const shapeOfGroup = (group, bar, accentsAt, options) => {
285
286
  const inserted = inOrder(ofSide(group.changes, 'insert'));
286
287
  const deleted = inOrder(ofSide(group.changes, 'delete'));
287
288
  if (group.grouping === 'substitution' || group.changes.some(change => change.foreign))
@@ -345,8 +346,8 @@ const settingsOf = (options) => ({
345
346
  * punched across three lines or more at one place are one edit, as a
346
347
  * cancel row is.
347
348
  *
348
- * The type is read off the shape: a pair the bar spells an accent with is
349
- * an additional accent, as is a note set off from its chord by a few
349
+ * The shape is read off the group: a pair the bar spells an accent with
350
+ * is an additional accent, as is a note set off from its chord by a few
350
351
  * millimetres where the version puts an accent's On; a perforation put
351
352
  * elsewhere is a shift, or where it begins about where the other did,
352
353
  * shortened or prolonged; a note struck again is shortened, two tied
@@ -429,11 +430,11 @@ export const proposeEdits = (edition, versionId, options = {}) => {
429
430
  const proposed = [...substituted, ...recoded, ...lines, ...rows]
430
431
  .sort((a, b) => byPlace(inOrder(a.changes)[0], inOrder(b.changes)[0]))
431
432
  .map((group) => {
432
- const editType = typeOf(group, bar, accentsAt, settings);
433
+ const shape = shapeOfGroup(group, bar, accentsAt, settings);
433
434
  return {
434
435
  insert: inOrder(ofSide(group.changes, 'insert')).map(change => change.symbol.id),
435
436
  delete: inOrder(ofSide(group.changes, 'delete')).map(change => change.symbol.id),
436
- ...(editType && { editType }),
437
+ ...(shape && { shape }),
437
438
  grouping: group.grouping
438
439
  };
439
440
  });
@@ -443,98 +444,102 @@ export const proposeEdits = (edition, versionId, options = {}) => {
443
444
  const EDITS = '3c9e0f62-1d4b-4a7e-9b55-8e2f7a6d1c04';
444
445
  const exchangeKey = (inserted, deleted) => `${[...inserted].sort().join(',')}/${[...deleted].sort().join(',')}`;
445
446
  /**
446
- * Whether the edit is left for a proposal to group again: one a
447
- * collation or an adoption wrote, that nobody has given a motivation.
447
+ * The motivation a program states for each change the version makes,
448
+ * by the id of the symbol it inserts or deletes: the one the shape of
449
+ * the proposed edit it belongs to calls for (`motivationProposedFor`),
450
+ * musical or technical. A version that derives from none makes no
451
+ * change, and its symbols are given none.
448
452
  * @category Filiation
449
453
  */
450
- export const isRegroupable = (edit) => isCollationsOwn(edit) && (edit.motivation === undefined || edit.motivation === unchecked);
454
+ export const proposedMotivations = (edition, versionId, options = {}) => {
455
+ const motivations = new Map();
456
+ if (!predecessorOf(edition, versionId))
457
+ return motivations;
458
+ for (const edit of proposeEdits(edition, versionId, options)) {
459
+ const motivation = motivationProposedFor(edit.shape);
460
+ for (const id of [...edit.insert, ...edit.delete])
461
+ motivations.set(id, motivation);
462
+ }
463
+ return motivations;
464
+ };
465
+ /**
466
+ * The motivation a program states for an edit making these changes:
467
+ * the generic musical one where any of them is a musical change, or one
468
+ * the proposal does not see, and the technical one where all are
469
+ * technical.
470
+ */
471
+ export const motivationOfChanges = (motivations, symbolIds) => symbolIds.some(id => (motivations.get(id) ?? musicalChange) === musicalChange) ? musicalChange : technicalChange;
451
472
  /**
452
473
  * The edits the version comes to state when the proposal is adopted:
453
474
  * those it keeps, and those put in place of the rest.
454
475
  */
455
476
  const adoptedEditsOf = (edition, version, options) => {
456
477
  const edits = editsOf(version);
457
- const held = edits.filter(edit => !isRegroupable(edit));
478
+ const held = edits.filter(edit => !isCollationsOwn(edit));
458
479
  const spoken = new Set(held.flatMap(edit => [...(edit.insert ?? []).map(symbol => symbol.id), ...(edit.delete ?? [])]));
459
480
  const symbolOf = new Map(insertedBy(version).map(symbol => [symbol.id, symbol]));
460
481
  const stated = new Map(edits.map(edit => [exchangeKey((edit.insert ?? []).map(symbol => symbol.id), edit.delete ?? []), edit]));
461
- const made = (inserted, deleted, editType) => {
482
+ const made = (inserted, deleted, motivation) => {
462
483
  const key = exchangeKey(inserted, deleted);
463
484
  const same = stated.get(key);
485
+ // An edit over the same changes stays, with the kind of change it states, which the editor may have said.
464
486
  if (same)
465
- return same.editType || !editType ? same : { ...same, editType };
487
+ return same.motivation === undefined ? { ...same, motivation } : same;
466
488
  return {
467
489
  type: 'edit',
468
490
  id: v5(`edit|${version.id}|${key}`, EDITS),
469
- ...(editType && { editType }),
470
- motivation: unchecked,
491
+ motivation,
471
492
  ...(inserted.length > 0 && { insert: inserted.map(id => symbolOf.get(id)) }),
472
493
  ...(deleted.length > 0 && { delete: [...deleted] })
473
494
  };
474
495
  };
475
496
  const proposed = proposeEdits(edition, version.id, options).flatMap(edit => {
497
+ const motivation = motivationProposedFor(edit.shape);
476
498
  const free = (ids) => ids.filter(id => !spoken.has(id));
477
499
  const [inserted, deleted] = [free(edit.insert), free(edit.delete)];
478
500
  if (inserted.length === edit.insert.length && deleted.length === edit.delete.length) {
479
- return [made(inserted, deleted, edit.editType)];
501
+ return [made(inserted, deleted, motivation)];
480
502
  }
481
503
  // What an edit that stays leaves of a proposed one stands symbol by symbol.
482
- return [...inserted.map(id => made([id], [])), ...deleted.map(id => made([], [id]))];
504
+ return [...inserted.map(id => made([id], [], motivation)), ...deleted.map(id => made([], [id], motivation))];
483
505
  });
484
506
  return { held, proposed };
485
507
  };
486
508
  /**
487
- * What the run of `proposeEdits` was computed with, in words, so that it
488
- * can be run again.
489
- */
490
- const noteOn = (settings) => 'The changes of each version against the version it derives from, grouped line by line and never across a command both texts keep. '
491
- + `A perforation put elsewhere within ${inMillimetres(settings.shiftWithin)} is one move with the one it replaces, `
492
- + `an Off within ${inMillimetres(settings.pairWithin)} of an On one function turned on and off again, `
493
- + `a perforation beginning within ${inMillimetres(settings.resizeWithin)} of the one it replaces a shortened or prolonged one, `
494
- + `and perforations within ${inMillimetres(settings.samePlaceWithin)} of each other at one place.`;
495
- /**
496
- * Puts the proposed edits (`proposeEdits`) in place of those of the
497
- * versions that a collation or an adoption wrote and nobody has given a
498
- * motivation, every version but the root where none are named. An edit
499
- * someone motivated, typed beyond what a collation types, or held under a
500
- * belief stays as it is, and what a proposed edit shares with it stands
501
- * symbol by symbol beside it. An edit stated already over the very same
502
- * symbols as a proposed one is kept with its id and what was written on
503
- * it, the proposed type filled in where it states none; the others are
504
- * new, with ids that adopting again gives again, and marked unchecked,
505
- * so that what is left to the editor is to say why.
509
+ * Puts the proposed edits (`proposeEdits`) in place of the program's
510
+ * edits of the versions, every version but the root where none are
511
+ * named: those that say nothing of why they were made, or only that they
512
+ * are musical or technical changes (`isCollationsOwn`). An edit with a
513
+ * motivation of the editor's or held under a belief stays as it is, and
514
+ * what a proposed edit shares with it stands symbol by symbol beside it.
515
+ * An edit stated already over the very same symbols as a proposed one
516
+ * is kept with its id and the kind of change it states, which the
517
+ * editor may have said otherwise than the program read it; the others
518
+ * are new, with ids that adopting again gives again. An edit that
519
+ * states no kind has the motivation its shape calls for
520
+ * (`motivationProposedFor`): the generic musical one for a musical
521
+ * change, whose reason is left to the editor, and the technical one for
522
+ * a technical change.
506
523
  *
507
524
  * Applied on the same draft after `adoptStemma`, it proposes the edits of
508
- * the stemma adopted, as one undo step.
509
- *
510
- * The edits it proposes are recorded as one proposition set, held under
511
- * one belief, likely unless the run says otherwise, whose reason is the
512
- * inference the program drew: it names this library and its release,
513
- * the versions it read, the rule that keeps an edit at one place and, in
514
- * its note, the distances it grouped with, and it rests on the beliefs
515
- * the derivations of the versions are held with. An edit of the set
516
- * that nobody has motivated is the program's, typed and all, and a
517
- * later proposal groups it again. The run gives who ran the program and
518
- * when (`Run`).
525
+ * the stemma adopted, as one undo step. The edition's creation comes to
526
+ * name the rule that keeps an edit at one place among its principles,
527
+ * and this release among its software.
519
528
  * @category Operations
520
529
  */
521
- export const adoptEdits = (versionIds, options = {}, run = {}) => reading(edition => {
530
+ export const adoptEdits = (versionIds, options = {}) => reading(edition => {
522
531
  const targets = (versionIds ?? edition.versions.map(version => version.id))
523
532
  .map(id => versionIn(edition, id))
524
533
  .filter((version) => version !== undefined && predecessorOf(edition, version.id) !== undefined);
525
- const regrouped = targets.map(version => ({ version, ...adoptedEditsOf(edition, version, options) }));
526
- const set = editSetOf(edition, regrouped, options, run);
527
- const adopted = new Map(regrouped.flatMap(({ version, held, proposed }) => {
528
- const edits = [...held, ...proposed.map(edit => memberOf(set.id, edit))];
534
+ const adopted = new Map(targets.flatMap(version => {
535
+ const { held, proposed } = adoptedEditsOf(edition, version, options);
536
+ const edits = [...held, ...proposed];
529
537
  const stated = editsOf(version);
530
538
  if (edits.length === stated.length && edits.every((edit, index) => edit === stated[index]))
531
539
  return [];
532
- return [[version.id, { ...version, edits, motivations: declaring(version.motivations, edits) }]];
540
+ return [[version.id, { ...version, edits }]];
533
541
  }));
534
- const sets = keptSets({
535
- ...edition,
536
- versions: edition.versions.map(version => adopted.get(version.id) ?? version)
537
- }, [set]);
542
+ const creation = madeWith(edition.creation, [editRules.onePlace]);
538
543
  // Each version is put in place whole: one that an operation before put
539
544
  // on the same draft, as adopting a stemma does, is no draft to write to.
540
545
  return draft => {
@@ -543,27 +548,7 @@ export const adoptEdits = (versionIds, options = {}, run = {}) => reading(editio
543
548
  if (changed)
544
549
  draft.versions[index] = changed;
545
550
  });
546
- if (sets)
547
- draft.propositionSets = sets;
548
- else
549
- delete draft.propositionSets;
551
+ if (adopted.size > 0)
552
+ draft.creation = creation;
550
553
  };
551
554
  });
552
- /**
553
- * The set the run of `proposeEdits` concluded: the edits it proposed for
554
- * the versions, held with the belief the run gives them. Its premises
555
- * are the beliefs the derivations of those versions are held with, since
556
- * what a version changes is read against the version it derives from: a
557
- * proposed stemma's, where the derivation belongs to one.
558
- */
559
- const editSetOf = (edition, regrouped, options, run) => {
560
- const settings = settingsOf(options);
561
- const proposing = regrouped.filter(({ proposed }) => proposed.length > 0);
562
- const premises = [...new Set(proposing.flatMap(({ version }) => {
563
- const derivation = principalDerivationOf(version);
564
- const belief = derivation && beliefIn(edition, derivation);
565
- return belief ? [belief.id] : [];
566
- }))];
567
- const used = [...new Set(proposing.flatMap(({ version }) => [predecessorOf(edition, version.id).id, version.id]))];
568
- return recorded('edits', [settings, premises, proposing.map(({ version, proposed }) => [version.id, proposed.map(edit => edit.id)])], { note: noteOn(settings), premises, used, applies: [editRules.onePlace] }, run);
569
- };
@@ -9,7 +9,7 @@ export { defaultCosts, type Costs, type Scored, type Support } from "./search.js
9
9
  export { transfersOf, systemAbove } from "./systems.js";
10
10
  export { proposeStemma, defaultMovedWithin, type FiliationOptions, type ProposedVersion, type StemmaProposal, type Unpinned } from "./proposal.js";
11
11
  export { adoptionOf, adoptStemma, type Adoption } from "./adoption.js";
12
- export { stemmaRules, editRules, type Run } from "./record.js";
12
+ export { stemmaRules, editRules } from "./record.js";
13
13
  export { stemmaChanges, type VersionChange } from "./changes.js";
14
14
  export { sharedTexts, differencesBetween, defaultSameText, type SharedText, type KeptApart } from "./texts.js";
15
- export { proposeEdits, adoptEdits, isRegroupable, defaultShiftWithin, defaultPairWithin, defaultResizeWithin, defaultSamePlaceWithin, type EditOptions, type EditGrouping, type ProposedEdit } from "./edits.js";
15
+ export { proposeEdits, adoptEdits, proposedMotivations, defaultShiftWithin, defaultPairWithin, defaultResizeWithin, defaultSamePlaceWithin, type EditOptions, type EditGrouping, type ProposedEdit } from "./edits.js";
@@ -12,4 +12,4 @@ export { adoptionOf, adoptStemma } from "./adoption.js";
12
12
  export { stemmaRules, editRules } from "./record.js";
13
13
  export { stemmaChanges } from "./changes.js";
14
14
  export { sharedTexts, differencesBetween, defaultSameText } from "./texts.js";
15
- export { proposeEdits, adoptEdits, isRegroupable, defaultShiftWithin, defaultPairWithin, defaultResizeWithin, defaultSamePlaceWithin } from "./edits.js";
15
+ export { proposeEdits, adoptEdits, proposedMotivations, defaultShiftWithin, defaultPairWithin, defaultResizeWithin, defaultSamePlaceWithin } from "./edits.js";
@@ -1,5 +1,9 @@
1
- import { ActorAssignment, Assumption, Certainty, PropositionSet, TimeSpan } from "../model/Assumption.js";
2
- import { Edition } from "../model/Edition.js";
1
+ /**
2
+ * What adopting a proposal records of how it was found: the published
3
+ * rules the proposal follows, among the principles of the edition, and
4
+ * the release of this library, among the software it was made with.
5
+ */
6
+ import { EditionCreation } from "../model/Edition.js";
3
7
  /**
4
8
  * The published rules the proposal of a stemma follows, by IRI, each
5
9
  * under the cost or the step that carries it out. They are the
@@ -34,46 +38,12 @@ export declare const editRules: {
34
38
  readonly onePlace: 'https://welte225.org/rules#one-place';
35
39
  };
36
40
  /**
37
- * What is known of a run of a program beside what it computed: who ran
38
- * it, when, how firmly what it concluded is held, and by which
39
- * published rules. An adoption records the run with it; whatever is left
40
- * out is not stated.
41
- * @category Filiation
42
- */
43
- export interface Run {
44
- /** Who ran the program and so holds what it concluded: the editor. */
45
- actor?: ActorAssignment;
46
- /** When it ran. */
47
- date?: TimeSpan;
48
- /** How firmly what it concluded is held: likely, where nothing else is said. */
49
- certainty?: Certainty;
50
- /** The rules it followed, by IRI, in place of those the library names (`stemmaRules`, `editRules`). */
51
- applies?: string[];
52
- }
53
- /** What a recorded run concluded besides its statements: what the inference says of itself. */
54
- export interface Concluded {
55
- /** What the run is, and what it was computed with, in words. */
56
- note: string;
57
- premises: string[];
58
- used: string[];
59
- applies: string[];
60
- }
61
- /**
62
- * The proposition set of a run, with its belief and the inference it
63
- * rests on. Its id follows from what it is given, so that recording the
64
- * same run again gives the same set.
65
- */
66
- export declare const recorded: (kind: string, identity: unknown, concluded: Concluded, run: Run) => PropositionSet;
67
- /** The statement as one of the set: its annotation names the set, and it carries no belief of its own. */
68
- export declare const memberOf: <T extends Assumption>(set: string, statement: T) => T;
69
- /**
70
- * The sets the edition keeps, with those given added where it holds none
71
- * with their id: a set already recorded stays as it was recorded, by
72
- * whom and when it was first concluded. Kept are the sets a statement
73
- * belongs to, and those whose belief the reasons of another kept
74
- * statement or set name as a premise. A set nothing names any longer is
75
- * the record of a run whose conclusions have all been replaced.
41
+ * The edition's creation as adopting a proposal leaves it. Its
42
+ * principles come to name the rules the proposal follows, in place of
43
+ * those given to be replaced, which are the rules of the same kind that
44
+ * it no longer follows; the principles the editor named stay. Its
45
+ * software comes to name this release of the library, in place of any
46
+ * other release of it, so that the release named finds again what the
47
+ * edition states.
76
48
  */
77
- export declare const keptSets: (edition: Edition, adding: readonly PropositionSet[]) => PropositionSet[] | undefined;
78
- /** A distance in millimetres as a note gives it. */
79
- export declare const inMillimetres: (value: number) => string;
49
+ export declare const madeWith: (creation: Readonly<EditionCreation>, rules: readonly string[], replacing?: readonly string[]) => EditionCreation;
@@ -1,12 +1,4 @@
1
- /**
2
- * What adopting a proposal records of the run that made it: the
3
- * proposition set the statements it concluded belong to, held under one
4
- * belief, and the reasoning that belief rests on.
5
- */
6
- import { v5 } from "uuid";
7
1
  import { linkedRolls } from "../software.js";
8
- /** The namespace the ids of recorded sets and beliefs are minted in, so that recording the same run again gives them again. */
9
- const RECORDED = 'b7e2a4d1-5c3f-4e86-9a0b-1d2f3e4c5a67';
10
2
  /**
11
3
  * The published rules the proposal of a stemma follows, by IRI, each
12
4
  * under the cost or the step that carries it out. They are the
@@ -41,80 +33,17 @@ export const editRules = {
41
33
  onePlace: 'https://welte225.org/rules#one-place'
42
34
  };
43
35
  /**
44
- * The proposition set of a run, with its belief and the inference it
45
- * rests on. Its id follows from what it is given, so that recording the
46
- * same run again gives the same set.
47
- */
48
- export const recorded = (kind, identity, concluded, run) => {
49
- const id = `propositions_${v5(JSON.stringify([kind, linkedRolls, identity]), RECORDED)}`;
50
- const inference = {
51
- type: 'inference',
52
- ...(run.actor && { actor: run.actor }),
53
- note: concluded.note,
54
- premises: concluded.premises,
55
- ...(concluded.used.length > 0 && { used: concluded.used }),
56
- applies: run.applies ?? concluded.applies,
57
- software: [linkedRolls],
58
- ...(run.date && { date: run.date })
59
- };
60
- return {
61
- type: 'propositionSet',
62
- id,
63
- belief: {
64
- type: 'belief',
65
- id: `belief_${v5(id, RECORDED)}`,
66
- certainty: run.certainty ?? 'likely',
67
- reasons: [inference]
68
- }
69
- };
70
- };
71
- /** The statement as one of the set: its annotation names the set, and it carries no belief of its own. */
72
- export const memberOf = (set, statement) => statement['@annotation']?.id === set && statement['@annotation'].belief === undefined
73
- ? statement
74
- : { ...statement, '@annotation': { id: set } };
75
- /** The ids every annotation of the value names a set by, and every premise names a belief by. */
76
- const namedIn = (value, names) => {
77
- if (Array.isArray(value)) {
78
- value.forEach(item => namedIn(item, names));
79
- return;
80
- }
81
- if (value === null || typeof value !== 'object' || value instanceof Date)
82
- return;
83
- const record = value;
84
- const annotation = record['@annotation'];
85
- if (annotation?.id !== undefined && annotation.belief === undefined)
86
- names.add(annotation.id);
87
- if (Array.isArray(record.premises))
88
- record.premises.forEach(premise => typeof premise === 'string' && names.add(premise));
89
- Object.values(record).forEach(child => namedIn(child, names));
90
- };
91
- /**
92
- * The sets the edition keeps, with those given added where it holds none
93
- * with their id: a set already recorded stays as it was recorded, by
94
- * whom and when it was first concluded. Kept are the sets a statement
95
- * belongs to, and those whose belief the reasons of another kept
96
- * statement or set name as a premise. A set nothing names any longer is
97
- * the record of a run whose conclusions have all been replaced.
36
+ * The edition's creation as adopting a proposal leaves it. Its
37
+ * principles come to name the rules the proposal follows, in place of
38
+ * those given to be replaced, which are the rules of the same kind that
39
+ * it no longer follows; the principles the editor named stay. Its
40
+ * software comes to name this release of the library, in place of any
41
+ * other release of it, so that the release named finds again what the
42
+ * edition states.
98
43
  */
99
- export const keptSets = (edition, adding) => {
100
- const held = edition.propositionSets ?? [];
101
- const known = new Set(held.map(set => set.id));
102
- const sets = [...held, ...adding.filter(set => !known.has(set.id))];
103
- const named = new Set();
104
- namedIn({ ...edition, propositionSets: [] }, named);
105
- const kept = new Set();
106
- for (let grown = true; grown;) {
107
- grown = false;
108
- for (const set of sets) {
109
- if (kept.has(set) || !(named.has(set.id) || named.has(set.belief.id)))
110
- continue;
111
- kept.add(set);
112
- namedIn(set.belief, named);
113
- grown = true;
114
- }
115
- }
116
- const keeping = sets.filter(set => kept.has(set));
117
- return keeping.length > 0 ? keeping : undefined;
44
+ export const madeWith = (creation, rules, replacing = []) => {
45
+ const replaced = new Set(replacing);
46
+ const principles = [...new Set([...(creation.principles ?? []).filter(rule => !replaced.has(rule)), ...rules])];
47
+ const software = [...(creation.software ?? []).filter(program => program.name !== linkedRolls.name), linkedRolls];
48
+ return { ...creation, principles, software };
118
49
  };
119
- /** A distance in millimetres as a note gives it. */
120
- export const inMillimetres = (value) => `${Math.round(value * 100) / 100} mm`;
@@ -12,11 +12,7 @@ export declare const exportDate: (date: Date) => string;
12
12
  * and every version carries the context of its own reproducing system.
13
13
  * A reference the edition holds possible, unlikely or false is quoted
14
14
  * rather than stated, so that a reader of the RDF does not take it for
15
- * a fact, and so is one that belongs to a proposition set held so. A
16
- * statement that belongs to a set names the set in its annotation,
17
- * which in RDF makes the set its reifier, and the set, stated once
18
- * beside the document, carries the belief. The edition given is not
19
- * changed.
15
+ * a fact. The edition given is not changed.
20
16
  * @category Reading and writing
21
17
  */
22
18
  export declare const asJsonLd: (edition: Edition) => any;