@zukhruf/evals 0.0.0-stage → 0.8.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 -0
- package/NOTICE +82 -0
- package/README.md +528 -2
- package/dist/aggregation/counts.d.ts +11 -0
- package/dist/aggregation/counts.d.ts.map +1 -0
- package/dist/aggregation/counts.js +14 -0
- package/dist/aggregation/counts.js.map +1 -0
- package/dist/aggregation/f1-ratio.d.ts +8 -0
- package/dist/aggregation/f1-ratio.d.ts.map +1 -0
- package/dist/aggregation/f1-ratio.js +24 -0
- package/dist/aggregation/f1-ratio.js.map +1 -0
- package/dist/aggregation/ratio-of-sums.d.ts +8 -0
- package/dist/aggregation/ratio-of-sums.d.ts.map +1 -0
- package/dist/aggregation/ratio-of-sums.js +21 -0
- package/dist/aggregation/ratio-of-sums.js.map +1 -0
- package/dist/aggregation/ratio.d.ts +8 -0
- package/dist/aggregation/ratio.d.ts.map +1 -0
- package/dist/aggregation/ratio.js +20 -0
- package/dist/aggregation/ratio.js.map +1 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -0
- package/dist/promptfoo/assertion-module.d.ts +23 -0
- package/dist/promptfoo/assertion-module.d.ts.map +1 -0
- package/dist/promptfoo/assertion-module.js +45 -0
- package/dist/promptfoo/assertion-module.js.map +1 -0
- package/dist/promptfoo/index.d.ts +3 -0
- package/dist/promptfoo/index.d.ts.map +1 -0
- package/dist/promptfoo/index.js +3 -0
- package/dist/promptfoo/index.js.map +1 -0
- package/dist/promptfoo/promptfoo-assertion.d.ts +18 -0
- package/dist/promptfoo/promptfoo-assertion.d.ts.map +1 -0
- package/dist/promptfoo/promptfoo-assertion.js +31 -0
- package/dist/promptfoo/promptfoo-assertion.js.map +1 -0
- package/dist/scorers/at-least.d.ts +9 -0
- package/dist/scorers/at-least.d.ts.map +1 -0
- package/dist/scorers/at-least.js +18 -0
- package/dist/scorers/at-least.js.map +1 -0
- package/dist/scorers/f1.d.ts +9 -0
- package/dist/scorers/f1.d.ts.map +1 -0
- package/dist/scorers/f1.js +12 -0
- package/dist/scorers/f1.js.map +1 -0
- package/dist/scorers/gate.d.ts +7 -0
- package/dist/scorers/gate.d.ts.map +1 -0
- package/dist/scorers/gate.js +10 -0
- package/dist/scorers/gate.js.map +1 -0
- package/dist/scorers/matches.d.ts +5 -0
- package/dist/scorers/matches.d.ts.map +1 -0
- package/dist/scorers/matches.js +2 -0
- package/dist/scorers/matches.js.map +1 -0
- package/dist/scorers/mean-of.d.ts +8 -0
- package/dist/scorers/mean-of.d.ts.map +1 -0
- package/dist/scorers/mean-of.js +15 -0
- package/dist/scorers/mean-of.js.map +1 -0
- package/dist/scorers/penalized.d.ts +9 -0
- package/dist/scorers/penalized.d.ts.map +1 -0
- package/dist/scorers/penalized.js +28 -0
- package/dist/scorers/penalized.js.map +1 -0
- package/dist/scorers/penalty.d.ts +7 -0
- package/dist/scorers/penalty.d.ts.map +1 -0
- package/dist/scorers/penalty.js +11 -0
- package/dist/scorers/penalty.js.map +1 -0
- package/dist/scorers/precision.d.ts +9 -0
- package/dist/scorers/precision.d.ts.map +1 -0
- package/dist/scorers/precision.js +13 -0
- package/dist/scorers/precision.js.map +1 -0
- package/dist/scorers/recall.d.ts +9 -0
- package/dist/scorers/recall.d.ts.map +1 -0
- package/dist/scorers/recall.js +13 -0
- package/dist/scorers/recall.js.map +1 -0
- package/dist/scorers/sample-averaged.d.ts +10 -0
- package/dist/scorers/sample-averaged.d.ts.map +1 -0
- package/dist/scorers/sample-averaged.js +17 -0
- package/dist/scorers/sample-averaged.js.map +1 -0
- package/dist/scorers/scorer.d.ts +5 -0
- package/dist/scorers/scorer.d.ts.map +1 -0
- package/dist/scorers/scorer.js +2 -0
- package/dist/scorers/scorer.js.map +1 -0
- package/dist/scorers/shortfall-penalty.d.ts +11 -0
- package/dist/scorers/shortfall-penalty.d.ts.map +1 -0
- package/dist/scorers/shortfall-penalty.js +25 -0
- package/dist/scorers/shortfall-penalty.js.map +1 -0
- package/dist/scoring/bootstrap.d.ts +16 -0
- package/dist/scoring/bootstrap.d.ts.map +1 -0
- package/dist/scoring/bootstrap.js +31 -0
- package/dist/scoring/bootstrap.js.map +1 -0
- package/dist/scoring/scorecard-scorer.d.ts +11 -0
- package/dist/scoring/scorecard-scorer.d.ts.map +1 -0
- package/dist/scoring/scorecard-scorer.js +2 -0
- package/dist/scoring/scorecard-scorer.js.map +1 -0
- package/dist/scoring/scorecard.d.ts +15 -0
- package/dist/scoring/scorecard.d.ts.map +1 -0
- package/dist/scoring/scorecard.js +2 -0
- package/dist/scoring/scorecard.js.map +1 -0
- package/dist/scoring/totals.d.ts +9 -0
- package/dist/scoring/totals.d.ts.map +1 -0
- package/dist/scoring/totals.js +23 -0
- package/dist/scoring/totals.js.map +1 -0
- package/dist/structured/comparison/alignment.d.ts +9 -0
- package/dist/structured/comparison/alignment.d.ts.map +1 -0
- package/dist/structured/comparison/alignment.js +2 -0
- package/dist/structured/comparison/alignment.js.map +1 -0
- package/dist/structured/comparison/alignments/by-best-match.d.ts +9 -0
- package/dist/structured/comparison/alignments/by-best-match.d.ts.map +1 -0
- package/dist/structured/comparison/alignments/by-best-match.js +25 -0
- package/dist/structured/comparison/alignments/by-best-match.js.map +1 -0
- package/dist/structured/comparison/alignments/by-position.d.ts +6 -0
- package/dist/structured/comparison/alignments/by-position.d.ts.map +1 -0
- package/dist/structured/comparison/alignments/by-position.js +9 -0
- package/dist/structured/comparison/alignments/by-position.js.map +1 -0
- package/dist/structured/comparison/bag-of-words.d.ts +10 -0
- package/dist/structured/comparison/bag-of-words.d.ts.map +1 -0
- package/dist/structured/comparison/bag-of-words.js +48 -0
- package/dist/structured/comparison/bag-of-words.js.map +1 -0
- package/dist/structured/comparison/comparator.d.ts +5 -0
- package/dist/structured/comparison/comparator.d.ts.map +1 -0
- package/dist/structured/comparison/comparator.js +2 -0
- package/dist/structured/comparison/comparator.js.map +1 -0
- package/dist/structured/comparison/comparators/json-equality.d.ts +7 -0
- package/dist/structured/comparison/comparators/json-equality.d.ts.map +1 -0
- package/dist/structured/comparison/comparators/json-equality.js +18 -0
- package/dist/structured/comparison/comparators/json-equality.js.map +1 -0
- package/dist/structured/comparison/comparators/normalized-text.d.ts +7 -0
- package/dist/structured/comparison/comparators/normalized-text.d.ts.map +1 -0
- package/dist/structured/comparison/comparators/normalized-text.js +13 -0
- package/dist/structured/comparison/comparators/normalized-text.js.map +1 -0
- package/dist/structured/comparison/comparators/normalized.d.ts +2 -0
- package/dist/structured/comparison/comparators/normalized.d.ts.map +1 -0
- package/dist/structured/comparison/comparators/normalized.js +3 -0
- package/dist/structured/comparison/comparators/normalized.js.map +1 -0
- package/dist/structured/comparison/comparators/number-within.d.ts +9 -0
- package/dist/structured/comparison/comparators/number-within.d.ts.map +1 -0
- package/dist/structured/comparison/comparators/number-within.js +18 -0
- package/dist/structured/comparison/comparators/number-within.js.map +1 -0
- package/dist/structured/comparison/comparators/python-equality.d.ts +7 -0
- package/dist/structured/comparison/comparators/python-equality.d.ts.map +1 -0
- package/dist/structured/comparison/comparators/python-equality.js +15 -0
- package/dist/structured/comparison/comparators/python-equality.js.map +1 -0
- package/dist/structured/comparison/comparators/token-overlap-at-least.d.ts +9 -0
- package/dist/structured/comparison/comparators/token-overlap-at-least.d.ts.map +1 -0
- package/dist/structured/comparison/comparators/token-overlap-at-least.js +20 -0
- package/dist/structured/comparison/comparators/token-overlap-at-least.js.map +1 -0
- package/dist/structured/comparison/comparators/typed-comparator.d.ts +8 -0
- package/dist/structured/comparison/comparators/typed-comparator.d.ts.map +1 -0
- package/dist/structured/comparison/comparators/typed-comparator.js +10 -0
- package/dist/structured/comparison/comparators/typed-comparator.js.map +1 -0
- package/dist/structured/comparison/comparison-spec.d.ts +17 -0
- package/dist/structured/comparison/comparison-spec.d.ts.map +1 -0
- package/dist/structured/comparison/comparison-spec.js +36 -0
- package/dist/structured/comparison/comparison-spec.js.map +1 -0
- package/dist/structured/comparison/comparison.d.ts +25 -0
- package/dist/structured/comparison/comparison.d.ts.map +1 -0
- package/dist/structured/comparison/comparison.js +94 -0
- package/dist/structured/comparison/comparison.js.map +1 -0
- package/dist/structured/comparison/field.d.ts +10 -0
- package/dist/structured/comparison/field.d.ts.map +1 -0
- package/dist/structured/comparison/field.js +29 -0
- package/dist/structured/comparison/field.js.map +1 -0
- package/dist/structured/comparison/item-pairs.d.ts +8 -0
- package/dist/structured/comparison/item-pairs.d.ts.map +1 -0
- package/dist/structured/comparison/item-pairs.js +2 -0
- package/dist/structured/comparison/item-pairs.js.map +1 -0
- package/dist/structured/comparison/json-path-query.d.ts +7 -0
- package/dist/structured/comparison/json-path-query.d.ts.map +1 -0
- package/dist/structured/comparison/json-path-query.js +133 -0
- package/dist/structured/comparison/json-path-query.js.map +1 -0
- package/dist/structured/comparison/json-value.d.ts +10 -0
- package/dist/structured/comparison/json-value.d.ts.map +1 -0
- package/dist/structured/comparison/json-value.js +47 -0
- package/dist/structured/comparison/json-value.js.map +1 -0
- package/dist/structured/comparison/leaf-pair.d.ts +24 -0
- package/dist/structured/comparison/leaf-pair.d.ts.map +1 -0
- package/dist/structured/comparison/leaf-pair.js +2 -0
- package/dist/structured/comparison/leaf-pair.js.map +1 -0
- package/dist/structured/comparison/match.d.ts +5 -0
- package/dist/structured/comparison/match.d.ts.map +1 -0
- package/dist/structured/comparison/match.js +2 -0
- package/dist/structured/comparison/match.js.map +1 -0
- package/dist/structured/comparison/name-selector.d.ts +6 -0
- package/dist/structured/comparison/name-selector.d.ts.map +1 -0
- package/dist/structured/comparison/name-selector.js +41 -0
- package/dist/structured/comparison/name-selector.js.map +1 -0
- package/dist/structured/comparison/path.d.ts +10 -0
- package/dist/structured/comparison/path.d.ts.map +1 -0
- package/dist/structured/comparison/path.js +27 -0
- package/dist/structured/comparison/path.js.map +1 -0
- package/dist/structured/comparison/tree-walk.d.ts +10 -0
- package/dist/structured/comparison/tree-walk.d.ts.map +1 -0
- package/dist/structured/comparison/tree-walk.js +136 -0
- package/dist/structured/comparison/tree-walk.js.map +1 -0
- package/dist/structured/cpython/python-text.d.ts +5 -0
- package/dist/structured/cpython/python-text.d.ts.map +1 -0
- package/dist/structured/cpython/python-text.js +79 -0
- package/dist/structured/cpython/python-text.js.map +1 -0
- package/dist/structured/index.d.ts +39 -0
- package/dist/structured/index.d.ts.map +1 -0
- package/dist/structured/index.js +29 -0
- package/dist/structured/index.js.map +1 -0
- package/dist/structured/promptfoo/scorer-assertion.d.ts +22 -0
- package/dist/structured/promptfoo/scorer-assertion.d.ts.map +1 -0
- package/dist/structured/promptfoo/scorer-assertion.js +34 -0
- package/dist/structured/promptfoo/scorer-assertion.js.map +1 -0
- package/dist/structured/schema/draft-07-schema.d.ts +3 -0
- package/dist/structured/schema/draft-07-schema.d.ts.map +1 -0
- package/dist/structured/schema/draft-07-schema.js +243 -0
- package/dist/structured/schema/draft-07-schema.js.map +1 -0
- package/dist/structured/schema/draft-2020-12-schema.d.ts +4 -0
- package/dist/structured/schema/draft-2020-12-schema.d.ts.map +1 -0
- package/dist/structured/schema/draft-2020-12-schema.js +280 -0
- package/dist/structured/schema/draft-2020-12-schema.js.map +1 -0
- package/dist/structured/schema/is-record.d.ts +2 -0
- package/dist/structured/schema/is-record.d.ts.map +1 -0
- package/dist/structured/schema/is-record.js +3 -0
- package/dist/structured/schema/is-record.js.map +1 -0
- package/dist/structured/schema/json-schema.d.ts +20 -0
- package/dist/structured/schema/json-schema.d.ts.map +1 -0
- package/dist/structured/schema/json-schema.js +244 -0
- package/dist/structured/schema/json-schema.js.map +1 -0
- package/dist/structured/schema/schema-type-walk.d.ts +11 -0
- package/dist/structured/schema/schema-type-walk.d.ts.map +1 -0
- package/dist/structured/schema/schema-type-walk.js +196 -0
- package/dist/structured/schema/schema-type-walk.js.map +1 -0
- package/dist/structured/scorers/all-matched.d.ts +10 -0
- package/dist/structured/scorers/all-matched.d.ts.map +1 -0
- package/dist/structured/scorers/all-matched.js +36 -0
- package/dist/structured/scorers/all-matched.js.map +1 -0
- package/dist/structured/scorers/exact-match.d.ts +7 -0
- package/dist/structured/scorers/exact-match.d.ts.map +1 -0
- package/dist/structured/scorers/exact-match.js +13 -0
- package/dist/structured/scorers/exact-match.js.map +1 -0
- package/dist/structured/scorers/item-matches.d.ts +7 -0
- package/dist/structured/scorers/item-matches.d.ts.map +1 -0
- package/dist/structured/scorers/item-matches.js +17 -0
- package/dist/structured/scorers/item-matches.js.map +1 -0
- package/dist/structured/scorers/leaf-matches.d.ts +14 -0
- package/dist/structured/scorers/leaf-matches.d.ts.map +1 -0
- package/dist/structured/scorers/leaf-matches.js +28 -0
- package/dist/structured/scorers/leaf-matches.js.map +1 -0
- package/dist/structured/scorers/parse-success.d.ts +7 -0
- package/dist/structured/scorers/parse-success.d.ts.map +1 -0
- package/dist/structured/scorers/parse-success.js +11 -0
- package/dist/structured/scorers/parse-success.js.map +1 -0
- package/dist/structured/scorers/path-matches.d.ts +5 -0
- package/dist/structured/scorers/path-matches.d.ts.map +1 -0
- package/dist/structured/scorers/path-matches.js +9 -0
- package/dist/structured/scorers/path-matches.js.map +1 -0
- package/dist/structured/scorers/required-key-recall.d.ts +8 -0
- package/dist/structured/scorers/required-key-recall.d.ts.map +1 -0
- package/dist/structured/scorers/required-key-recall.js +50 -0
- package/dist/structured/scorers/required-key-recall.js.map +1 -0
- package/dist/structured/scorers/schema-compliance.d.ts +8 -0
- package/dist/structured/scorers/schema-compliance.d.ts.map +1 -0
- package/dist/structured/scorers/schema-compliance.js +29 -0
- package/dist/structured/scorers/schema-compliance.js.map +1 -0
- package/dist/structured/scorers/token-f1.d.ts +14 -0
- package/dist/structured/scorers/token-f1.d.ts.map +1 -0
- package/dist/structured/scorers/token-f1.js +44 -0
- package/dist/structured/scorers/token-f1.js.map +1 -0
- package/dist/structured/scorers/type-precision.d.ts +10 -0
- package/dist/structured/scorers/type-precision.d.ts.map +1 -0
- package/dist/structured/scorers/type-precision.js +30 -0
- package/dist/structured/scorers/type-precision.js.map +1 -0
- package/dist/structured/scorers/valid-schema.d.ts +7 -0
- package/dist/structured/scorers/valid-schema.d.ts.map +1 -0
- package/dist/structured/scorers/valid-schema.js +11 -0
- package/dist/structured/scorers/valid-schema.js.map +1 -0
- package/dist/structured/scorers/value-matches.d.ts +6 -0
- package/dist/structured/scorers/value-matches.d.ts.map +1 -0
- package/dist/structured/scorers/value-matches.js +9 -0
- package/dist/structured/scorers/value-matches.js.map +1 -0
- package/dist/structured/scoring/case.d.ts +14 -0
- package/dist/structured/scoring/case.d.ts.map +1 -0
- package/dist/structured/scoring/case.js +14 -0
- package/dist/structured/scoring/case.js.map +1 -0
- package/dist/structured/scoring/config-case.d.ts +11 -0
- package/dist/structured/scoring/config-case.d.ts.map +1 -0
- package/dist/structured/scoring/config-case.js +22 -0
- package/dist/structured/scoring/config-case.js.map +1 -0
- package/dist/structured/scoring/per-field.d.ts +9 -0
- package/dist/structured/scoring/per-field.d.ts.map +1 -0
- package/dist/structured/scoring/per-field.js +23 -0
- package/dist/structured/scoring/per-field.js.map +1 -0
- package/dist/structured/scoring/scorer-set.d.ts +15 -0
- package/dist/structured/scoring/scorer-set.d.ts.map +1 -0
- package/dist/structured/scoring/scorer-set.js +60 -0
- package/dist/structured/scoring/scorer-set.js.map +1 -0
- package/dist/structured/scoring/text-vars-case.d.ts +12 -0
- package/dist/structured/scoring/text-vars-case.d.ts.map +1 -0
- package/dist/structured/scoring/text-vars-case.js +31 -0
- package/dist/structured/scoring/text-vars-case.js.map +1 -0
- package/package.json +78 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recall.d.ts","sourceRoot":"","sources":["../../src/scorers/recall.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAChD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAG1C,qBAAa,MAAM,CAAC,KAAK,CAAE,YAAW,MAAM,CAAC,KAAK,CAAC;;gBAGrC,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC;IAInC,KAAK,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK;CAI3B"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Ratio } from "../aggregation/ratio.js";
|
|
2
|
+
// The hits of the expected values: Ratio(hits, expected).
|
|
3
|
+
export class Recall {
|
|
4
|
+
#matches;
|
|
5
|
+
constructor(matches) {
|
|
6
|
+
this.#matches = matches;
|
|
7
|
+
}
|
|
8
|
+
score(input) {
|
|
9
|
+
const { hits, expected } = this.#matches.counts(input);
|
|
10
|
+
return new Ratio(hits, expected);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=recall.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recall.js","sourceRoot":"","sources":["../../src/scorers/recall.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAIhD,0DAA0D;AAC1D,MAAM,OAAO,MAAM;IACR,QAAQ,CAAiB;IAElC,YAAY,OAAuB;QACjC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC1B,CAAC;IAED,KAAK,CAAC,KAAY;QAChB,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACvD,OAAO,IAAI,KAAK,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IACnC,CAAC;CACF"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Ratio } from '../aggregation/ratio.ts';
|
|
2
|
+
import type { Scorer } from './scorer.ts';
|
|
3
|
+
export declare class SampleAveraged<Input> implements Scorer<Input> {
|
|
4
|
+
#private;
|
|
5
|
+
constructor(scorer: Scorer<Input>, { whenEmpty }: {
|
|
6
|
+
readonly whenEmpty: number;
|
|
7
|
+
});
|
|
8
|
+
score(input: Input): Ratio;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=sample-averaged.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sample-averaged.d.ts","sourceRoot":"","sources":["../../src/scorers/sample-averaged.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAChD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAK1C,qBAAa,cAAc,CAAC,KAAK,CAAE,YAAW,MAAM,CAAC,KAAK,CAAC;;gBAKvD,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,EACrB,EAAE,SAAS,EAAE,EAAE;QAAE,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;KAAE;IAM/C,KAAK,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK;CAI3B"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Ratio } from "../aggregation/ratio.js";
|
|
2
|
+
// The value of a scorer over 1, so a ratio of sums of many records is the
|
|
3
|
+
// mean of their values: scikit-learn's average='samples'. A record whose
|
|
4
|
+
// ratio has the whole 0 gives whenEmpty (Decorator).
|
|
5
|
+
export class SampleAveraged {
|
|
6
|
+
#scorer;
|
|
7
|
+
#whenEmpty;
|
|
8
|
+
constructor(scorer, { whenEmpty }) {
|
|
9
|
+
this.#scorer = scorer;
|
|
10
|
+
this.#whenEmpty = whenEmpty;
|
|
11
|
+
}
|
|
12
|
+
score(input) {
|
|
13
|
+
const ratio = this.#scorer.score(input);
|
|
14
|
+
return new Ratio(ratio.whole === 0 ? this.#whenEmpty : ratio.value, 1);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=sample-averaged.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sample-averaged.js","sourceRoot":"","sources":["../../src/scorers/sample-averaged.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAGhD,0EAA0E;AAC1E,yEAAyE;AACzE,qDAAqD;AACrD,MAAM,OAAO,cAAc;IAChB,OAAO,CAAgB;IACvB,UAAU,CAAS;IAE5B,YACE,MAAqB,EACrB,EAAE,SAAS,EAAkC;QAE7C,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;IAC9B,CAAC;IAED,KAAK,CAAC,KAAY;QAChB,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACxC,OAAO,IAAI,KAAK,CAAC,KAAK,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;IACzE,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scorer.d.ts","sourceRoot":"","sources":["../../src/scorers/scorer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAKrD,MAAM,WAAW,MAAM,CAAC,KAAK;IAC3B,KAAK,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK,CAAC;CAC5B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scorer.js","sourceRoot":"","sources":["../../src/scorers/scorer.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Penalty } from './penalty.ts';
|
|
2
|
+
import type { Scorer } from './scorer.ts';
|
|
3
|
+
export declare class ShortfallPenalty<Input> extends Penalty<Input> {
|
|
4
|
+
#private;
|
|
5
|
+
constructor(scorer: Scorer<Input>, { target, power }: {
|
|
6
|
+
readonly target: number;
|
|
7
|
+
readonly power: number;
|
|
8
|
+
});
|
|
9
|
+
factor(input: Input): number;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=shortfall-penalty.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shortfall-penalty.d.ts","sourceRoot":"","sources":["../../src/scorers/shortfall-penalty.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAO1C,qBAAa,gBAAgB,CAAC,KAAK,CAAE,SAAQ,OAAO,CAAC,KAAK,CAAC;;gBAMvD,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,EACrB,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE;QAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;KAAE;IAYxE,MAAM,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM;CAM7B"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Penalty } from "./penalty.js";
|
|
2
|
+
// The penalty min(1, (value / target) ** power) of the value of a scorer: 1
|
|
3
|
+
// when the value reaches the target, and below it the fraction of the target
|
|
4
|
+
// to the power. SOB gives image and audio records the factor of the key F1
|
|
5
|
+
// with the target 0.90 and the power 2 (compute_coverage_gate,
|
|
6
|
+
// sob-bench/evaluate.py:615-618), with the same arithmetic.
|
|
7
|
+
export class ShortfallPenalty extends Penalty {
|
|
8
|
+
#scorer;
|
|
9
|
+
#target;
|
|
10
|
+
#power;
|
|
11
|
+
constructor(scorer, { target, power }) {
|
|
12
|
+
super();
|
|
13
|
+
if (!(target > 0))
|
|
14
|
+
throw new RangeError(`The target ${target} is not more than 0.`);
|
|
15
|
+
if (!(power > 0))
|
|
16
|
+
throw new RangeError(`The power ${power} is not more than 0.`);
|
|
17
|
+
this.#scorer = scorer;
|
|
18
|
+
this.#target = target;
|
|
19
|
+
this.#power = power;
|
|
20
|
+
}
|
|
21
|
+
factor(input) {
|
|
22
|
+
return Math.min(1, (this.#scorer.score(input).value / this.#target) ** this.#power);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=shortfall-penalty.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shortfall-penalty.js","sourceRoot":"","sources":["../../src/scorers/shortfall-penalty.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAGvC,4EAA4E;AAC5E,6EAA6E;AAC7E,2EAA2E;AAC3E,+DAA+D;AAC/D,4DAA4D;AAC5D,MAAM,OAAO,gBAAwB,SAAQ,OAAc;IAChD,OAAO,CAAgB;IACvB,OAAO,CAAS;IAChB,MAAM,CAAS;IAExB,YACE,MAAqB,EACrB,EAAE,MAAM,EAAE,KAAK,EAAuD;QAEtE,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;YACf,MAAM,IAAI,UAAU,CAAC,cAAc,MAAM,sBAAsB,CAAC,CAAC;QACnE,IAAI,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC;YACd,MAAM,IAAI,UAAU,CAAC,aAAa,KAAK,sBAAsB,CAAC,CAAC;QACjE,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACtB,CAAC;IAED,MAAM,CAAC,KAAY;QACjB,OAAO,IAAI,CAAC,GAAG,CACb,CAAC,EACD,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC,MAAM,CAChE,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type ConfidenceInterval, type ConfidenceIntervalMethod } from '@zukhruf/statistics';
|
|
2
|
+
import type { Scorecard } from './scorecard.ts';
|
|
3
|
+
export type WeightedScorecard = {
|
|
4
|
+
readonly scorecard: Scorecard;
|
|
5
|
+
readonly weight: number;
|
|
6
|
+
};
|
|
7
|
+
export declare class Bootstrap {
|
|
8
|
+
#private;
|
|
9
|
+
constructor({ nResamples, randomIndex, interval, }: {
|
|
10
|
+
readonly nResamples: number;
|
|
11
|
+
readonly randomIndex: (n: number) => number;
|
|
12
|
+
readonly interval: ConfidenceIntervalMethod;
|
|
13
|
+
});
|
|
14
|
+
interval(rows: readonly WeightedScorecard[], name: string): ConfidenceInterval;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=bootstrap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bootstrap.d.ts","sourceRoot":"","sources":["../../src/scoring/bootstrap.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,wBAAwB,EAE9B,MAAM,qBAAqB,CAAC;AAI7B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB,CAAC;AAQF,qBAAa,SAAS;;gBAIR,EACV,UAAU,EACV,WAAW,EACX,QAAQ,GACT,EAAE;QACD,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;QAC5B,QAAQ,CAAC,WAAW,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;QAC5C,QAAQ,CAAC,QAAQ,EAAE,wBAAwB,CAAC;KAC7C;IAKD,QAAQ,CACN,IAAI,EAAE,SAAS,iBAAiB,EAAE,EAClC,IAAI,EAAE,MAAM,GACX,kBAAkB;CAkBtB"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { IidBootstrap, } from '@zukhruf/statistics';
|
|
2
|
+
import { RatioOfSums } from "../aggregation/ratio-of-sums.js";
|
|
3
|
+
import { Ratio } from "../aggregation/ratio.js";
|
|
4
|
+
// The bootstrap interval of the mean of one name over many scorecards: each
|
|
5
|
+
// resample draws as many scorecards as there are, with replacement, and gives
|
|
6
|
+
// the ratio of sums of the name, each scorecard with its weight. The caller
|
|
7
|
+
// gives the random generator, the number of resamples and the method of the
|
|
8
|
+
// interval, such as SOB's (ADR 0010). The generator keeps its state between
|
|
9
|
+
// calls, so the order of the calls is the order of the draws.
|
|
10
|
+
export class Bootstrap {
|
|
11
|
+
#bootstrap;
|
|
12
|
+
#interval;
|
|
13
|
+
constructor({ nResamples, randomIndex, interval, }) {
|
|
14
|
+
this.#bootstrap = new IidBootstrap({ nResamples, randomIndex });
|
|
15
|
+
this.#interval = interval;
|
|
16
|
+
}
|
|
17
|
+
interval(rows, name) {
|
|
18
|
+
return this.#bootstrap.interval(rows, (resample) => Bootstrap.#mean(resample, name), this.#interval);
|
|
19
|
+
}
|
|
20
|
+
static #mean(rows, name) {
|
|
21
|
+
const sum = new RatioOfSums();
|
|
22
|
+
for (const { scorecard, weight } of rows) {
|
|
23
|
+
const ratio = scorecard.ratios.get(name);
|
|
24
|
+
if (ratio === undefined)
|
|
25
|
+
throw new Error(`No scorecard ratio named "${name}"`);
|
|
26
|
+
sum.add(new Ratio(ratio.value, 1).times(weight));
|
|
27
|
+
}
|
|
28
|
+
return sum.value;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=bootstrap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bootstrap.js","sourceRoot":"","sources":["../../src/scoring/bootstrap.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,YAAY,GACb,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAQhD,4EAA4E;AAC5E,8EAA8E;AAC9E,4EAA4E;AAC5E,4EAA4E;AAC5E,4EAA4E;AAC5E,8DAA8D;AAC9D,MAAM,OAAO,SAAS;IACX,UAAU,CAAe;IACzB,SAAS,CAA2B;IAE7C,YAAY,EACV,UAAU,EACV,WAAW,EACX,QAAQ,GAKT;QACC,IAAI,CAAC,UAAU,GAAG,IAAI,YAAY,CAAC,EAAE,UAAU,EAAE,WAAW,EAAE,CAAC,CAAC;QAChE,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;IAC5B,CAAC;IAED,QAAQ,CACN,IAAkC,EAClC,IAAY;QAEZ,OAAO,IAAI,CAAC,UAAU,CAAC,QAAQ,CAC7B,IAAI,EACJ,CAAC,QAAQ,EAAE,EAAE,CAAC,SAAS,CAAC,KAAK,CAAC,QAAQ,EAAE,IAAI,CAAC,EAC7C,IAAI,CAAC,SAAS,CACf,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,IAAkC,EAAE,IAAY;QAC3D,MAAM,GAAG,GAAG,IAAI,WAAW,EAAE,CAAC;QAC9B,KAAK,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,IAAI,EAAE,CAAC;YACzC,MAAM,KAAK,GAAG,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YACzC,IAAI,KAAK,KAAK,SAAS;gBACrB,MAAM,IAAI,KAAK,CAAC,6BAA6B,IAAI,GAAG,CAAC,CAAC;YACxD,GAAG,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;QACnD,CAAC;QACD,OAAO,GAAG,CAAC,KAAK,CAAC;IACnB,CAAC;CACF"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Scorecard } from './scorecard.ts';
|
|
2
|
+
export type Weighted = {
|
|
3
|
+
readonly weight: number;
|
|
4
|
+
};
|
|
5
|
+
export interface ScorecardScorer<Case extends Weighted> {
|
|
6
|
+
score(stated: unknown, testCase: Case): Scorecard;
|
|
7
|
+
}
|
|
8
|
+
export interface CaseReader<Case extends Weighted> {
|
|
9
|
+
from(config: Readonly<Record<string, unknown>>): Case;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=scorecard-scorer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scorecard-scorer.d.ts","sourceRoot":"","sources":["../../src/scoring/scorecard-scorer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAIhD,MAAM,MAAM,QAAQ,GAAG;IAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAInD,MAAM,WAAW,eAAe,CAAC,IAAI,SAAS,QAAQ;IACpD,KAAK,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,GAAG,SAAS,CAAC;CACnD;AAKD,MAAM,WAAW,UAAU,CAAC,IAAI,SAAS,QAAQ;IAC/C,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;CACvD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scorecard-scorer.js","sourceRoot":"","sources":["../../src/scoring/scorecard-scorer.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Ratio } from '../aggregation/ratio.ts';
|
|
2
|
+
export type Check = {
|
|
3
|
+
readonly name: string;
|
|
4
|
+
readonly passed: boolean;
|
|
5
|
+
readonly score: number;
|
|
6
|
+
readonly reason: string;
|
|
7
|
+
};
|
|
8
|
+
export type Scorecard = {
|
|
9
|
+
readonly passed: boolean;
|
|
10
|
+
readonly score: number;
|
|
11
|
+
readonly reason: string;
|
|
12
|
+
readonly ratios: ReadonlyMap<string, Ratio>;
|
|
13
|
+
readonly checks: readonly Check[];
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=scorecard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scorecard.d.ts","sourceRoot":"","sources":["../../src/scoring/scorecard.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAIrD,MAAM,MAAM,KAAK,GAAG;IAClB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB,CAAC;AAIF,MAAM,MAAM,SAAS,GAAG;IACtB,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAC5C,QAAQ,CAAC,MAAM,EAAE,SAAS,KAAK,EAAE,CAAC;CACnC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scorecard.js","sourceRoot":"","sources":["../../src/scoring/scorecard.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { RatioOfSums } from '../aggregation/ratio-of-sums.ts';
|
|
2
|
+
import type { Scorecard } from './scorecard.ts';
|
|
3
|
+
export declare class Totals {
|
|
4
|
+
#private;
|
|
5
|
+
add(scorecard: Scorecard, weight: number): void;
|
|
6
|
+
get(name: string): RatioOfSums;
|
|
7
|
+
names(): IterableIterator<string>;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=totals.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"totals.d.ts","sourceRoot":"","sources":["../../src/scoring/totals.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAIhD,qBAAa,MAAM;;IAGjB,GAAG,CAAC,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI;IAQ/C,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW;IAO9B,KAAK,IAAI,gBAAgB,CAAC,MAAM,CAAC;CAGlC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { RatioOfSums } from "../aggregation/ratio-of-sums.js";
|
|
2
|
+
// The ratio of sums of each name over many scorecards: what a runner keeps
|
|
3
|
+
// for a run.
|
|
4
|
+
export class Totals {
|
|
5
|
+
#sums = new Map();
|
|
6
|
+
add(scorecard, weight) {
|
|
7
|
+
for (const [name, ratio] of scorecard.ratios) {
|
|
8
|
+
this.#sums
|
|
9
|
+
.getOrInsertComputed(name, () => new RatioOfSums())
|
|
10
|
+
.add(ratio.times(weight));
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
get(name) {
|
|
14
|
+
const sum = this.#sums.get(name);
|
|
15
|
+
if (sum === undefined)
|
|
16
|
+
throw new Error(`No scorecard gave a ratio named "${name}"`);
|
|
17
|
+
return sum;
|
|
18
|
+
}
|
|
19
|
+
names() {
|
|
20
|
+
return this.#sums.keys();
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=totals.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"totals.js","sourceRoot":"","sources":["../../src/scoring/totals.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAG9D,2EAA2E;AAC3E,aAAa;AACb,MAAM,OAAO,MAAM;IACR,KAAK,GAAG,IAAI,GAAG,EAAuB,CAAC;IAEhD,GAAG,CAAC,SAAoB,EAAE,MAAc;QACtC,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,SAAS,CAAC,MAAM,EAAE,CAAC;YAC7C,IAAI,CAAC,KAAK;iBACP,mBAAmB,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC,IAAI,WAAW,EAAE,CAAC;iBAClD,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;QAC9B,CAAC;IACH,CAAC;IAED,GAAG,CAAC,IAAY;QACd,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACjC,IAAI,GAAG,KAAK,SAAS;YACnB,MAAM,IAAI,KAAK,CAAC,oCAAoC,IAAI,GAAG,CAAC,CAAC;QAC/D,OAAO,GAAG,CAAC;IACb,CAAC;IAED,KAAK;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;IAC3B,CAAC;CACF"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { JsonData } from '@zukhruf/python';
|
|
2
|
+
export type Pairs = readonly (readonly [stated: number, expected: number])[];
|
|
3
|
+
export interface Agreement {
|
|
4
|
+
count(stated: JsonData, expected: JsonData): number;
|
|
5
|
+
}
|
|
6
|
+
export interface Alignment {
|
|
7
|
+
pairs(stated: readonly JsonData[], expected: readonly JsonData[], agreement: Agreement): Pairs;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=alignment.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"alignment.d.ts","sourceRoot":"","sources":["../../../src/structured/comparison/alignment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAGhD,MAAM,MAAM,KAAK,GAAG,SAAS,CAAC,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC;AAI7E,MAAM,WAAW,SAAS;IACxB,KAAK,CAAC,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,GAAG,MAAM,CAAC;CACrD;AAGD,MAAM,WAAW,SAAS;IACxB,KAAK,CACH,MAAM,EAAE,SAAS,QAAQ,EAAE,EAC3B,QAAQ,EAAE,SAAS,QAAQ,EAAE,EAC7B,SAAS,EAAE,SAAS,GACnB,KAAK,CAAC;CACV"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"alignment.js","sourceRoot":"","sources":["../../../src/structured/comparison/alignment.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { JsonData } from '@zukhruf/python';
|
|
2
|
+
import type { Agreement, Alignment, Pairs } from '../alignment.ts';
|
|
3
|
+
import type { Match } from '../match.ts';
|
|
4
|
+
export declare class ByBestMatch implements Alignment {
|
|
5
|
+
#private;
|
|
6
|
+
constructor(match?: Match);
|
|
7
|
+
pairs(stated: readonly JsonData[], expected: readonly JsonData[], agreement: Agreement): Pairs;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=by-best-match.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"by-best-match.d.ts","sourceRoot":"","sources":["../../../../src/structured/comparison/alignments/by-best-match.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAEhD,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACnE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAMzC,qBAAa,WAAY,YAAW,SAAS;;gBAG/B,KAAK,CAAC,EAAE,KAAK;IAIzB,KAAK,CACH,MAAM,EAAE,SAAS,QAAQ,EAAE,EAC3B,QAAQ,EAAE,SAAS,QAAQ,EAAE,EAC7B,SAAS,EAAE,SAAS,GACnB,KAAK;CAmBT"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { munkres } from 'munkres';
|
|
2
|
+
// A set array: of all pairings, the one with the most agreeing leaves (the
|
|
3
|
+
// Hungarian algorithm, ADR 0002). A pair that the match forbids is no pair.
|
|
4
|
+
// Without a match, a pair that agrees on nothing is no pair; with a match,
|
|
5
|
+
// the match alone makes a pair.
|
|
6
|
+
export class ByBestMatch {
|
|
7
|
+
#match;
|
|
8
|
+
constructor(match) {
|
|
9
|
+
this.#match = match;
|
|
10
|
+
}
|
|
11
|
+
pairs(stated, expected, agreement) {
|
|
12
|
+
if (stated.length === 0 || expected.length === 0)
|
|
13
|
+
return [];
|
|
14
|
+
const weights = stated.map((statedItem) => expected.map((expectedItem) => this.#weight(statedItem, expectedItem, agreement)));
|
|
15
|
+
return munkres(weights.map((row) => row.map((weight) => -weight)), { finite: true }).filter(([row, column]) => (weights[row]?.[column] ?? 0) > 0);
|
|
16
|
+
}
|
|
17
|
+
#weight(stated, expected, agreement) {
|
|
18
|
+
if (this.#match === undefined)
|
|
19
|
+
return agreement.count(stated, expected);
|
|
20
|
+
return this.#match.canPair(stated, expected)
|
|
21
|
+
? agreement.count(stated, expected) + 1
|
|
22
|
+
: 0;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=by-best-match.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"by-best-match.js","sourceRoot":"","sources":["../../../../src/structured/comparison/alignments/by-best-match.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAOlC,2EAA2E;AAC3E,4EAA4E;AAC5E,2EAA2E;AAC3E,gCAAgC;AAChC,MAAM,OAAO,WAAW;IACb,MAAM,CAAoB;IAEnC,YAAY,KAAa;QACvB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACtB,CAAC;IAED,KAAK,CACH,MAA2B,EAC3B,QAA6B,EAC7B,SAAoB;QAEpB,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,EAAE,CAAC;QAC5D,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CACxC,QAAQ,CAAC,GAAG,CAAC,CAAC,YAAY,EAAE,EAAE,CAC5B,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,YAAY,EAAE,SAAS,CAAC,CAClD,CACF,CAAC;QACF,OAAO,OAAO,CACZ,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,EAClD,EAAE,MAAM,EAAE,IAAI,EAAE,CACjB,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,EAAE,MAAM,CAAC,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IACjE,CAAC;IAED,OAAO,CAAC,MAAgB,EAAE,QAAkB,EAAE,SAAoB;QAChE,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS;YAAE,OAAO,SAAS,CAAC,KAAK,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;QACxE,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,QAAQ,CAAC;YAC1C,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,MAAM,EAAE,QAAQ,CAAC,GAAG,CAAC;YACvC,CAAC,CAAC,CAAC,CAAC;IACR,CAAC;CACF"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { JsonData } from '@zukhruf/python';
|
|
2
|
+
import type { Alignment, Pairs } from '../alignment.ts';
|
|
3
|
+
export declare class ByPosition implements Alignment {
|
|
4
|
+
pairs(stated: readonly JsonData[], expected: readonly JsonData[]): Pairs;
|
|
5
|
+
}
|
|
6
|
+
//# sourceMappingURL=by-position.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"by-position.d.ts","sourceRoot":"","sources":["../../../../src/structured/comparison/alignments/by-position.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAEhD,OAAO,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAKxD,qBAAa,UAAW,YAAW,SAAS;IAC1C,KAAK,CAAC,MAAM,EAAE,SAAS,QAAQ,EAAE,EAAE,QAAQ,EAAE,SAAS,QAAQ,EAAE,GAAG,KAAK;CAMzE"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// An ordered array: item 0 pairs with item 0, item 1 with item 1, and so on.
|
|
2
|
+
// It is the default, and SOB's rule (evaluate.py writes the path of an item
|
|
3
|
+
// with its index).
|
|
4
|
+
export class ByPosition {
|
|
5
|
+
pairs(stated, expected) {
|
|
6
|
+
return Array.from({ length: Math.min(stated.length, expected.length) }, (_, index) => [index, index]);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=by-position.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"by-position.js","sourceRoot":"","sources":["../../../../src/structured/comparison/alignments/by-position.ts"],"names":[],"mappings":"AAIA,6EAA6E;AAC7E,4EAA4E;AAC5E,mBAAmB;AACnB,MAAM,OAAO,UAAU;IACrB,KAAK,CAAC,MAA2B,EAAE,QAA6B;QAC9D,OAAO,KAAK,CAAC,IAAI,CACf,EAAE,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,EAAE,EACpD,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,EAAE,KAAK,CAAU,CACtC,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Counts } from '../../aggregation/counts.ts';
|
|
2
|
+
import type { LeafValue } from './leaf-pair.ts';
|
|
3
|
+
export declare class BagOfWords {
|
|
4
|
+
#private;
|
|
5
|
+
readonly size: number;
|
|
6
|
+
private constructor();
|
|
7
|
+
static of(value: LeafValue): BagOfWords;
|
|
8
|
+
shared(stated: BagOfWords): Counts;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=bag-of-words.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bag-of-words.d.ts","sourceRoot":"","sources":["../../../src/structured/comparison/bag-of-words.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAErD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAMhD,qBAAa,UAAU;;IAarB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAGtB,OAAO;IAOP,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,SAAS,GAAG,UAAU;IAavC,MAAM,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM;CAanC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { PYTHON_SPACE, PYTHON_WORD } from '@zukhruf/python';
|
|
2
|
+
import { Counts } from "../../aggregation/counts.js";
|
|
3
|
+
import { pythonStr } from "../cpython/python-text.js";
|
|
4
|
+
// The words of a leaf, each with how often it occurs, as SQuAD's
|
|
5
|
+
// normalize_answer reads them: str() of the value, lower case, punctuation
|
|
6
|
+
// and the articles a, an, the as spaces, then the runs of Python's \w
|
|
7
|
+
// (normalize_tokens of SOB's evaluate.py).
|
|
8
|
+
export class BagOfWords {
|
|
9
|
+
static #punctuation = new RegExp(`[^${PYTHON_WORD}${PYTHON_SPACE}]`, 'gu');
|
|
10
|
+
// Python's \b is a border between \w and not \w; JavaScript's \b knows only
|
|
11
|
+
// ASCII words.
|
|
12
|
+
static #articles = new RegExp(`(?<![${PYTHON_WORD}])(?:a|an|the)(?![${PYTHON_WORD}])`, 'gu');
|
|
13
|
+
static #spaces = new RegExp(`[${PYTHON_SPACE}]+`, 'u');
|
|
14
|
+
size;
|
|
15
|
+
#counts;
|
|
16
|
+
constructor(words) {
|
|
17
|
+
const counts = new Map();
|
|
18
|
+
for (const word of words)
|
|
19
|
+
counts.set(word, (counts.get(word) ?? 0) + 1);
|
|
20
|
+
this.size = words.length;
|
|
21
|
+
this.#counts = counts;
|
|
22
|
+
}
|
|
23
|
+
static of(value) {
|
|
24
|
+
return new BagOfWords(BagOfWords.#text(value)
|
|
25
|
+
.toLowerCase()
|
|
26
|
+
.replaceAll(BagOfWords.#punctuation, ' ')
|
|
27
|
+
.replaceAll(BagOfWords.#articles, ' ')
|
|
28
|
+
.split(BagOfWords.#spaces)
|
|
29
|
+
.filter((word) => word !== ''));
|
|
30
|
+
}
|
|
31
|
+
// The words that this expected bag shares with a stated bag, as often as
|
|
32
|
+
// both have them (Counter & Counter), with the size of each bag.
|
|
33
|
+
shared(stated) {
|
|
34
|
+
let hits = 0;
|
|
35
|
+
for (const [word, count] of this.#counts)
|
|
36
|
+
hits += Math.min(count, stated.#counts.get(word) ?? 0);
|
|
37
|
+
return new Counts({ hits, stated: stated.size, expected: this.size });
|
|
38
|
+
}
|
|
39
|
+
// str() of a leaf, with None and bool as evaluate.py names them.
|
|
40
|
+
static #text(value) {
|
|
41
|
+
if (value === null)
|
|
42
|
+
return 'null';
|
|
43
|
+
if (typeof value === 'boolean')
|
|
44
|
+
return value ? 'true' : 'false';
|
|
45
|
+
return pythonStr(value);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=bag-of-words.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bag-of-words.js","sourceRoot":"","sources":["../../../src/structured/comparison/bag-of-words.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE5D,OAAO,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAGtD,iEAAiE;AACjE,2EAA2E;AAC3E,sEAAsE;AACtE,2CAA2C;AAC3C,MAAM,OAAO,UAAU;IACrB,MAAM,CAAU,YAAY,GAAG,IAAI,MAAM,CACvC,KAAK,WAAW,GAAG,YAAY,GAAG,EAClC,IAAI,CACL,CAAC;IACF,4EAA4E;IAC5E,eAAe;IACf,MAAM,CAAU,SAAS,GAAG,IAAI,MAAM,CACpC,QAAQ,WAAW,qBAAqB,WAAW,IAAI,EACvD,IAAI,CACL,CAAC;IACF,MAAM,CAAU,OAAO,GAAG,IAAI,MAAM,CAAC,IAAI,YAAY,IAAI,EAAE,GAAG,CAAC,CAAC;IAEvD,IAAI,CAAS;IACb,OAAO,CAA8B;IAE9C,YAAoB,KAAwB;QAC1C,MAAM,MAAM,GAAG,IAAI,GAAG,EAAkB,CAAC;QACzC,KAAK,MAAM,IAAI,IAAI,KAAK;YAAE,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;QACxE,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC,MAAM,CAAC;QACzB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACxB,CAAC;IAED,MAAM,CAAC,EAAE,CAAC,KAAgB;QACxB,OAAO,IAAI,UAAU,CACnB,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC;aACpB,WAAW,EAAE;aACb,UAAU,CAAC,UAAU,CAAC,YAAY,EAAE,GAAG,CAAC;aACxC,UAAU,CAAC,UAAU,CAAC,SAAS,EAAE,GAAG,CAAC;aACrC,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC;aACzB,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,EAAE,CAAC,CACjC,CAAC;IACJ,CAAC;IAED,yEAAyE;IACzE,iEAAiE;IACjE,MAAM,CAAC,MAAkB;QACvB,IAAI,IAAI,GAAG,CAAC,CAAC;QACb,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,IAAI,CAAC,OAAO;YACtC,IAAI,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QACzD,OAAO,IAAI,MAAM,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;IACxE,CAAC;IAED,iEAAiE;IACjE,MAAM,CAAC,KAAK,CAAC,KAAgB;QAC3B,IAAI,KAAK,KAAK,IAAI;YAAE,OAAO,MAAM,CAAC;QAClC,IAAI,OAAO,KAAK,KAAK,SAAS;YAAE,OAAO,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC;QAChE,OAAO,SAAS,CAAC,KAAK,CAAC,CAAC;IAC1B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"comparator.d.ts","sourceRoot":"","sources":["../../../src/structured/comparison/comparator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAIhD,MAAM,WAAW,UAAU;IACzB,MAAM,CAAC,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,GAAG,OAAO,CAAC;CACzD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"comparator.js","sourceRoot":"","sources":["../../../src/structured/comparison/comparator.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Comparator } from '../comparator.ts';
|
|
2
|
+
import type { LeafValue } from '../leaf-pair.ts';
|
|
3
|
+
export declare class JsonEquality implements Comparator {
|
|
4
|
+
#private;
|
|
5
|
+
agrees(stated: LeafValue, expected: LeafValue): boolean;
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=json-equality.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-equality.d.ts","sourceRoot":"","sources":["../../../../src/structured/comparison/comparators/json-equality.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAKjD,qBAAa,YAAa,YAAW,UAAU;;IAC7C,MAAM,CAAC,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,GAAG,OAAO;CAaxD"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// Two leaves agree when JSON Schema calls them equal (2020-12, Core section
|
|
2
|
+
// 4.2.2): the same type and the same value. A number is one type, so the int
|
|
3
|
+
// 1 agrees with the float 1.0, exactly; true does not agree with 1.
|
|
4
|
+
export class JsonEquality {
|
|
5
|
+
agrees(stated, expected) {
|
|
6
|
+
if (typeof stated === 'bigint' && typeof expected === 'number')
|
|
7
|
+
return JsonEquality.#intIsFloat(stated, expected);
|
|
8
|
+
if (typeof stated === 'number' && typeof expected === 'bigint')
|
|
9
|
+
return JsonEquality.#intIsFloat(expected, stated);
|
|
10
|
+
return stated === expected;
|
|
11
|
+
}
|
|
12
|
+
// An int equals a float when the float is integral and has the same value,
|
|
13
|
+
// exactly.
|
|
14
|
+
static #intIsFloat(int, float) {
|
|
15
|
+
return Number.isInteger(float) && BigInt(float) === int;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=json-equality.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-equality.js","sourceRoot":"","sources":["../../../../src/structured/comparison/comparators/json-equality.ts"],"names":[],"mappings":"AAGA,4EAA4E;AAC5E,6EAA6E;AAC7E,oEAAoE;AACpE,MAAM,OAAO,YAAY;IACvB,MAAM,CAAC,MAAiB,EAAE,QAAmB;QAC3C,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,OAAO,QAAQ,KAAK,QAAQ;YAC5D,OAAO,YAAY,CAAC,WAAW,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;QACpD,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,OAAO,QAAQ,KAAK,QAAQ;YAC5D,OAAO,YAAY,CAAC,WAAW,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QACpD,OAAO,MAAM,KAAK,QAAQ,CAAC;IAC7B,CAAC;IAED,2EAA2E;IAC3E,WAAW;IACX,MAAM,CAAC,WAAW,CAAC,GAAW,EAAE,KAAa;QAC3C,OAAO,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC;IAC1D,CAAC;CACF"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { LeafValue } from '../leaf-pair.ts';
|
|
2
|
+
import { TypedComparator } from './typed-comparator.ts';
|
|
3
|
+
export declare class NormalizedText extends TypedComparator<string> {
|
|
4
|
+
protected accepts(value: LeafValue): value is string;
|
|
5
|
+
protected compare(stated: string, expected: string): boolean;
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=normalized-text.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalized-text.d.ts","sourceRoot":"","sources":["../../../../src/structured/comparison/comparators/normalized-text.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAIxD,qBAAa,cAAe,SAAQ,eAAe,CAAC,MAAM,CAAC;IACzD,SAAS,CAAC,OAAO,CAAC,KAAK,EAAE,SAAS,GAAG,KAAK,IAAI,MAAM;IAIpD,SAAS,CAAC,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO;CAG7D"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { normalized } from "./normalized.js";
|
|
2
|
+
import { TypedComparator } from "./typed-comparator.js";
|
|
3
|
+
// Two texts agree when they are the same after Unicode NFKC, lower case, and
|
|
4
|
+
// one space between words.
|
|
5
|
+
export class NormalizedText extends TypedComparator {
|
|
6
|
+
accepts(value) {
|
|
7
|
+
return typeof value === 'string';
|
|
8
|
+
}
|
|
9
|
+
compare(stated, expected) {
|
|
10
|
+
return normalized(stated) === normalized(expected);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=normalized-text.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalized-text.js","sourceRoot":"","sources":["../../../../src/structured/comparison/comparators/normalized-text.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,6EAA6E;AAC7E,2BAA2B;AAC3B,MAAM,OAAO,cAAe,SAAQ,eAAuB;IAC/C,OAAO,CAAC,KAAgB;QAChC,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC;IACnC,CAAC;IAES,OAAO,CAAC,MAAc,EAAE,QAAgB;QAChD,OAAO,UAAU,CAAC,MAAM,CAAC,KAAK,UAAU,CAAC,QAAQ,CAAC,CAAC;IACrD,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalized.d.ts","sourceRoot":"","sources":["../../../../src/structured/comparison/comparators/normalized.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,UAAU,GAAI,MAAM,MAAM,WAC+B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalized.js","sourceRoot":"","sources":["../../../../src/structured/comparison/comparators/normalized.ts"],"names":[],"mappings":"AAAA,yDAAyD;AACzD,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,IAAY,EAAE,EAAE,CACzC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { LeafValue } from '../leaf-pair.ts';
|
|
2
|
+
import { TypedComparator } from './typed-comparator.ts';
|
|
3
|
+
export declare class NumberWithin extends TypedComparator<bigint | number> {
|
|
4
|
+
#private;
|
|
5
|
+
constructor(tolerance: number);
|
|
6
|
+
protected accepts(value: LeafValue): value is bigint | number;
|
|
7
|
+
protected compare(stated: bigint | number, expected: bigint | number): boolean;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=number-within.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"number-within.d.ts","sourceRoot":"","sources":["../../../../src/structured/comparison/comparators/number-within.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAKxD,qBAAa,YAAa,SAAQ,eAAe,CAAC,MAAM,GAAG,MAAM,CAAC;;gBAGpD,SAAS,EAAE,MAAM;IAK7B,SAAS,CAAC,OAAO,CAAC,KAAK,EAAE,SAAS,GAAG,KAAK,IAAI,MAAM,GAAG,MAAM;IAI7D,SAAS,CAAC,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM;CAGrE"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { TypedComparator } from "./typed-comparator.js";
|
|
2
|
+
// Two numbers agree when they differ by at most the tolerance. An int and a
|
|
3
|
+
// float compare as JavaScript numbers, so an int past 2^53 loses its last
|
|
4
|
+
// digits.
|
|
5
|
+
export class NumberWithin extends TypedComparator {
|
|
6
|
+
#tolerance;
|
|
7
|
+
constructor(tolerance) {
|
|
8
|
+
super();
|
|
9
|
+
this.#tolerance = tolerance;
|
|
10
|
+
}
|
|
11
|
+
accepts(value) {
|
|
12
|
+
return typeof value === 'bigint' || typeof value === 'number';
|
|
13
|
+
}
|
|
14
|
+
compare(stated, expected) {
|
|
15
|
+
return Math.abs(Number(stated) - Number(expected)) <= this.#tolerance;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=number-within.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"number-within.js","sourceRoot":"","sources":["../../../../src/structured/comparison/comparators/number-within.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,4EAA4E;AAC5E,0EAA0E;AAC1E,UAAU;AACV,MAAM,OAAO,YAAa,SAAQ,eAAgC;IACvD,UAAU,CAAS;IAE5B,YAAY,SAAiB;QAC3B,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;IAC9B,CAAC;IAES,OAAO,CAAC,KAAgB;QAChC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,QAAQ,CAAC;IAChE,CAAC;IAES,OAAO,CAAC,MAAuB,EAAE,QAAyB;QAClE,OAAO,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC;IACxE,CAAC;CACF"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Comparator } from '../comparator.ts';
|
|
2
|
+
import type { LeafValue } from '../leaf-pair.ts';
|
|
3
|
+
export declare class PythonEquality implements Comparator {
|
|
4
|
+
#private;
|
|
5
|
+
agrees(stated: LeafValue, expected: LeafValue): boolean;
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=python-equality.d.ts.map
|