chaffjs 0.29.0 → 0.31.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.
- package/dist/announced-count.d.ts +2 -0
- package/dist/announced-count.d.ts.map +1 -1
- package/dist/announced-count.js +4 -3
- package/dist/announced-count.js.map +1 -1
- package/dist/contacts/addresses.d.ts +21 -0
- package/dist/contacts/addresses.d.ts.map +1 -0
- package/dist/contacts/addresses.js +144 -0
- package/dist/contacts/addresses.js.map +1 -0
- package/dist/contacts/emails.d.ts +11 -0
- package/dist/contacts/emails.d.ts.map +1 -0
- package/dist/contacts/emails.js +51 -0
- package/dist/contacts/emails.js.map +1 -0
- package/dist/contacts/variants.d.ts +14 -0
- package/dist/contacts/variants.d.ts.map +1 -0
- package/dist/contacts/variants.js +25 -0
- package/dist/contacts/variants.js.map +1 -0
- package/dist/derived/battery-runtime.d.ts +85 -0
- package/dist/derived/battery-runtime.d.ts.map +1 -0
- package/dist/derived/battery-runtime.js +217 -0
- package/dist/derived/battery-runtime.js.map +1 -0
- package/dist/derived/period-counts.d.ts +48 -0
- package/dist/derived/period-counts.d.ts.map +1 -0
- package/dist/derived/period-counts.js +128 -0
- package/dist/derived/period-counts.js.map +1 -0
- package/dist/derived/session-hours.d.ts +26 -0
- package/dist/derived/session-hours.d.ts.map +1 -0
- package/dist/derived/session-hours.js +29 -0
- package/dist/derived/session-hours.js.map +1 -0
- package/dist/derived/time-lengths.d.ts +37 -0
- package/dist/derived/time-lengths.d.ts.map +1 -0
- package/dist/derived/time-lengths.js +171 -0
- package/dist/derived/time-lengths.js.map +1 -0
- package/dist/derived/unit-counts.d.ts +7 -0
- package/dist/derived/unit-counts.d.ts.map +1 -0
- package/dist/derived/unit-counts.js +13 -0
- package/dist/derived/unit-counts.js.map +1 -0
- package/dist/derived/use-interval.d.ts +33 -0
- package/dist/derived/use-interval.d.ts.map +1 -0
- package/dist/derived/use-interval.js +93 -0
- package/dist/derived/use-interval.js.map +1 -0
- package/dist/derived/working-hours.d.ts +36 -0
- package/dist/derived/working-hours.d.ts.map +1 -0
- package/dist/derived/working-hours.js +55 -0
- package/dist/derived/working-hours.js.map +1 -0
- package/dist/detectors/acronym-expansion.d.ts +1 -1
- package/dist/detectors/acronym-expansion.d.ts.map +1 -1
- package/dist/detectors/acronym-expansion.js +46 -2
- package/dist/detectors/acronym-expansion.js.map +1 -1
- package/dist/detectors/announced-count.d.ts.map +1 -1
- package/dist/detectors/announced-count.js +1 -0
- package/dist/detectors/announced-count.js.map +1 -1
- package/dist/detectors/capacity-runtime.d.ts +7 -0
- package/dist/detectors/capacity-runtime.d.ts.map +1 -0
- package/dist/detectors/capacity-runtime.js +98 -0
- package/dist/detectors/capacity-runtime.js.map +1 -0
- package/dist/detectors/capitalised-term.d.ts +44 -0
- package/dist/detectors/capitalised-term.d.ts.map +1 -0
- package/dist/detectors/capitalised-term.js +101 -0
- package/dist/detectors/capitalised-term.js.map +1 -0
- package/dist/detectors/contact-variant.d.ts +3 -0
- package/dist/detectors/contact-variant.d.ts.map +1 -0
- package/dist/detectors/contact-variant.js +21 -0
- package/dist/detectors/contact-variant.js.map +1 -0
- package/dist/detectors/count-over-capacity.d.ts +4 -0
- package/dist/detectors/count-over-capacity.d.ts.map +1 -0
- package/dist/detectors/count-over-capacity.js +26 -0
- package/dist/detectors/count-over-capacity.js.map +1 -0
- package/dist/detectors/date-outside-period.d.ts.map +1 -1
- package/dist/detectors/date-outside-period.js +5 -1
- package/dist/detectors/date-outside-period.js.map +1 -1
- package/dist/detectors/date-stamp-order.d.ts +3 -0
- package/dist/detectors/date-stamp-order.d.ts.map +1 -0
- package/dist/detectors/date-stamp-order.js +24 -0
- package/dist/detectors/date-stamp-order.js.map +1 -0
- package/dist/detectors/defined-term-form.d.ts.map +1 -1
- package/dist/detectors/defined-term-form.js +57 -7
- package/dist/detectors/defined-term-form.js.map +1 -1
- package/dist/detectors/definition-use.d.ts +1 -1
- package/dist/detectors/definition-use.d.ts.map +1 -1
- package/dist/detectors/definition-use.js +4 -2
- package/dist/detectors/definition-use.js.map +1 -1
- package/dist/detectors/derived-numbers.d.ts +11 -1
- package/dist/detectors/derived-numbers.d.ts.map +1 -1
- package/dist/detectors/derived-numbers.js +74 -20
- package/dist/detectors/derived-numbers.js.map +1 -1
- package/dist/detectors/due-date.d.ts.map +1 -1
- package/dist/detectors/due-date.js +6 -0
- package/dist/detectors/due-date.js.map +1 -1
- package/dist/detectors/en-shape.d.ts.map +1 -1
- package/dist/detectors/en-shape.js +7 -4
- package/dist/detectors/en-shape.js.map +1 -1
- package/dist/detectors/event-deadline.d.ts +3 -0
- package/dist/detectors/event-deadline.d.ts.map +1 -0
- package/dist/detectors/event-deadline.js +24 -0
- package/dist/detectors/event-deadline.js.map +1 -0
- package/dist/detectors/fact-consistency.d.ts +1 -1
- package/dist/detectors/fact-consistency.d.ts.map +1 -1
- package/dist/detectors/fact-consistency.js +52 -3
- package/dist/detectors/fact-consistency.js.map +1 -1
- package/dist/detectors/heading-case.d.ts +5 -2
- package/dist/detectors/heading-case.d.ts.map +1 -1
- package/dist/detectors/heading-case.js +12 -4
- package/dist/detectors/heading-case.js.map +1 -1
- package/dist/detectors/heading-echo.d.ts +5 -0
- package/dist/detectors/heading-echo.d.ts.map +1 -1
- package/dist/detectors/heading-echo.js +14 -1
- package/dist/detectors/heading-echo.js.map +1 -1
- package/dist/detectors/layout-code.d.ts +5 -0
- package/dist/detectors/layout-code.d.ts.map +1 -0
- package/dist/detectors/layout-code.js +124 -0
- package/dist/detectors/layout-code.js.map +1 -0
- package/dist/detectors/measured-facts.d.ts +8 -0
- package/dist/detectors/measured-facts.d.ts.map +1 -0
- package/dist/detectors/measured-facts.js +18 -0
- package/dist/detectors/measured-facts.js.map +1 -0
- package/dist/detectors/name-variant-model-codes.d.ts +11 -0
- package/dist/detectors/name-variant-model-codes.d.ts.map +1 -0
- package/dist/detectors/name-variant-model-codes.js +21 -0
- package/dist/detectors/name-variant-model-codes.js.map +1 -0
- package/dist/detectors/name-variant.d.ts.map +1 -1
- package/dist/detectors/name-variant.js +78 -10
- package/dist/detectors/name-variant.js.map +1 -1
- package/dist/detectors/orthographic-variant.d.ts.map +1 -1
- package/dist/detectors/orthographic-variant.js +62 -7
- package/dist/detectors/orthographic-variant.js.map +1 -1
- package/dist/detectors/orthography.d.ts.map +1 -1
- package/dist/detectors/orthography.js +12 -6
- package/dist/detectors/orthography.js.map +1 -1
- package/dist/detectors/party-order.d.ts +3 -0
- package/dist/detectors/party-order.d.ts.map +1 -0
- package/dist/detectors/party-order.js +46 -0
- package/dist/detectors/party-order.js.map +1 -0
- package/dist/detectors/quantity-range.d.ts +3 -0
- package/dist/detectors/quantity-range.d.ts.map +1 -0
- package/dist/detectors/quantity-range.js +35 -0
- package/dist/detectors/quantity-range.js.map +1 -0
- package/dist/detectors/range-band.d.ts +5 -0
- package/dist/detectors/range-band.d.ts.map +1 -0
- package/dist/detectors/range-band.js +80 -0
- package/dist/detectors/range-band.js.map +1 -0
- package/dist/detectors/registry/capacity-runtime-mismatch.d.ts +3 -0
- package/dist/detectors/registry/capacity-runtime-mismatch.d.ts.map +1 -0
- package/dist/detectors/registry/capacity-runtime-mismatch.js +3 -0
- package/dist/detectors/registry/capacity-runtime-mismatch.js.map +1 -0
- package/dist/detectors/registry/connection-time-short.d.ts +3 -0
- package/dist/detectors/registry/connection-time-short.d.ts.map +1 -0
- package/dist/detectors/registry/connection-time-short.js +3 -0
- package/dist/detectors/registry/connection-time-short.js.map +1 -0
- package/dist/detectors/registry/contact-variant.d.ts +3 -0
- package/dist/detectors/registry/contact-variant.d.ts.map +1 -0
- package/dist/detectors/registry/contact-variant.js +3 -0
- package/dist/detectors/registry/contact-variant.js.map +1 -0
- package/dist/detectors/registry/count-over-capacity.d.ts +3 -0
- package/dist/detectors/registry/count-over-capacity.d.ts.map +1 -0
- package/dist/detectors/registry/count-over-capacity.js +3 -0
- package/dist/detectors/registry/count-over-capacity.js.map +1 -0
- package/dist/detectors/registry/date-stamp-order.d.ts +3 -0
- package/dist/detectors/registry/date-stamp-order.d.ts.map +1 -0
- package/dist/detectors/registry/date-stamp-order.js +3 -0
- package/dist/detectors/registry/date-stamp-order.js.map +1 -0
- package/dist/detectors/registry/duration-product-mismatch.d.ts +3 -0
- package/dist/detectors/registry/duration-product-mismatch.d.ts.map +1 -0
- package/dist/detectors/registry/duration-product-mismatch.js +3 -0
- package/dist/detectors/registry/duration-product-mismatch.js.map +1 -0
- package/dist/detectors/registry/event-deadline.d.ts +3 -0
- package/dist/detectors/registry/event-deadline.d.ts.map +1 -0
- package/dist/detectors/registry/event-deadline.js +3 -0
- package/dist/detectors/registry/event-deadline.js.map +1 -0
- package/dist/detectors/registry/interval-count-mismatch.d.ts +3 -0
- package/dist/detectors/registry/interval-count-mismatch.d.ts.map +1 -0
- package/dist/detectors/registry/interval-count-mismatch.js +3 -0
- package/dist/detectors/registry/interval-count-mismatch.js.map +1 -0
- package/dist/detectors/registry/layout-code-mismatch.d.ts +3 -0
- package/dist/detectors/registry/layout-code-mismatch.d.ts.map +1 -0
- package/dist/detectors/registry/layout-code-mismatch.js +3 -0
- package/dist/detectors/registry/layout-code-mismatch.js.map +1 -0
- package/dist/detectors/registry/party-order.d.ts +3 -0
- package/dist/detectors/registry/party-order.d.ts.map +1 -0
- package/dist/detectors/registry/party-order.js +3 -0
- package/dist/detectors/registry/party-order.js.map +1 -0
- package/dist/detectors/registry/quantity-range.d.ts +3 -0
- package/dist/detectors/registry/quantity-range.d.ts.map +1 -0
- package/dist/detectors/registry/quantity-range.js +3 -0
- package/dist/detectors/registry/quantity-range.js.map +1 -0
- package/dist/detectors/registry/range-band-mismatch.d.ts +3 -0
- package/dist/detectors/registry/range-band-mismatch.d.ts.map +1 -0
- package/dist/detectors/registry/range-band-mismatch.js +3 -0
- package/dist/detectors/registry/range-band-mismatch.js.map +1 -0
- package/dist/detectors/registry/rent-multiple-mismatch.d.ts +3 -0
- package/dist/detectors/registry/rent-multiple-mismatch.d.ts.map +1 -0
- package/dist/detectors/registry/rent-multiple-mismatch.js +3 -0
- package/dist/detectors/registry/rent-multiple-mismatch.js.map +1 -0
- package/dist/detectors/registry/requirement-lists.d.ts +3 -0
- package/dist/detectors/registry/requirement-lists.d.ts.map +1 -0
- package/dist/detectors/registry/requirement-lists.js +3 -0
- package/dist/detectors/registry/requirement-lists.js.map +1 -0
- package/dist/detectors/registry/return-type.d.ts +3 -0
- package/dist/detectors/registry/return-type.d.ts.map +1 -0
- package/dist/detectors/registry/return-type.js +3 -0
- package/dist/detectors/registry/return-type.js.map +1 -0
- package/dist/detectors/registry/scaled-quantity-mismatch.d.ts +3 -0
- package/dist/detectors/registry/scaled-quantity-mismatch.d.ts.map +1 -0
- package/dist/detectors/registry/scaled-quantity-mismatch.js +3 -0
- package/dist/detectors/registry/scaled-quantity-mismatch.js.map +1 -0
- package/dist/detectors/registry/step-time-sum-mismatch.d.ts +3 -0
- package/dist/detectors/registry/step-time-sum-mismatch.d.ts.map +1 -0
- package/dist/detectors/registry/step-time-sum-mismatch.js +3 -0
- package/dist/detectors/registry/step-time-sum-mismatch.js.map +1 -0
- package/dist/detectors/registry/time-range-reversed.d.ts +3 -0
- package/dist/detectors/registry/time-range-reversed.d.ts.map +1 -0
- package/dist/detectors/registry/time-range-reversed.js +3 -0
- package/dist/detectors/registry/time-range-reversed.js.map +1 -0
- package/dist/detectors/registry/unlisted-item-used.d.ts +3 -0
- package/dist/detectors/registry/unlisted-item-used.d.ts.map +1 -0
- package/dist/detectors/registry/unlisted-item-used.js +3 -0
- package/dist/detectors/registry/unlisted-item-used.js.map +1 -0
- package/dist/detectors/registry/walk-time-distance-mismatch.d.ts +3 -0
- package/dist/detectors/registry/walk-time-distance-mismatch.d.ts.map +1 -0
- package/dist/detectors/registry/walk-time-distance-mismatch.js +3 -0
- package/dist/detectors/registry/walk-time-distance-mismatch.js.map +1 -0
- package/dist/detectors/rent-multiple-mismatch.d.ts +3 -0
- package/dist/detectors/rent-multiple-mismatch.d.ts.map +1 -0
- package/dist/detectors/rent-multiple-mismatch.js +39 -0
- package/dist/detectors/rent-multiple-mismatch.js.map +1 -0
- package/dist/detectors/requirement-lists.d.ts +3 -0
- package/dist/detectors/requirement-lists.d.ts.map +1 -0
- package/dist/detectors/requirement-lists.js +46 -0
- package/dist/detectors/requirement-lists.js.map +1 -0
- package/dist/detectors/return-type.d.ts +3 -0
- package/dist/detectors/return-type.d.ts.map +1 -0
- package/dist/detectors/return-type.js +24 -0
- package/dist/detectors/return-type.js.map +1 -0
- package/dist/detectors/scaled-quantity.d.ts +3 -0
- package/dist/detectors/scaled-quantity.d.ts.map +1 -0
- package/dist/detectors/scaled-quantity.js +37 -0
- package/dist/detectors/scaled-quantity.js.map +1 -0
- package/dist/detectors/signals.d.ts.map +1 -1
- package/dist/detectors/signals.js +3 -1
- package/dist/detectors/signals.js.map +1 -1
- package/dist/detectors/step-time-sum.d.ts +3 -0
- package/dist/detectors/step-time-sum.d.ts.map +1 -0
- package/dist/detectors/step-time-sum.js +46 -0
- package/dist/detectors/step-time-sum.js.map +1 -0
- package/dist/detectors/structure-tree.d.ts +2 -0
- package/dist/detectors/structure-tree.d.ts.map +1 -1
- package/dist/detectors/structure-tree.js +31 -6
- package/dist/detectors/structure-tree.js.map +1 -1
- package/dist/detectors/structure.js +1 -1
- package/dist/detectors/structure.js.map +1 -1
- package/dist/detectors/technical-docs.d.ts +5 -0
- package/dist/detectors/technical-docs.d.ts.map +1 -1
- package/dist/detectors/technical-docs.js +12 -0
- package/dist/detectors/technical-docs.js.map +1 -1
- package/dist/detectors/time-order.d.ts +2 -0
- package/dist/detectors/time-order.d.ts.map +1 -1
- package/dist/detectors/time-order.js +33 -5
- package/dist/detectors/time-order.js.map +1 -1
- package/dist/detectors/undefined-term.d.ts.map +1 -1
- package/dist/detectors/undefined-term.js +19 -3
- package/dist/detectors/undefined-term.js.map +1 -1
- package/dist/detectors/unit-consistency.d.ts +1 -1
- package/dist/detectors/unit-consistency.d.ts.map +1 -1
- package/dist/detectors/unit-consistency.js +46 -38
- package/dist/detectors/unit-consistency.js.map +1 -1
- package/dist/detectors/unlisted-items.d.ts +3 -0
- package/dist/detectors/unlisted-items.d.ts.map +1 -0
- package/dist/detectors/unlisted-items.js +57 -0
- package/dist/detectors/unlisted-items.js.map +1 -0
- package/dist/detectors/use-count-words.d.ts +8 -0
- package/dist/detectors/use-count-words.d.ts.map +1 -0
- package/dist/detectors/use-count-words.js +20 -0
- package/dist/detectors/use-count-words.js.map +1 -0
- package/dist/detectors/use-interval.d.ts +3 -0
- package/dist/detectors/use-interval.d.ts.map +1 -0
- package/dist/detectors/use-interval.js +39 -0
- package/dist/detectors/use-interval.js.map +1 -0
- package/dist/detectors/walk-time-distance-mismatch.d.ts +4 -0
- package/dist/detectors/walk-time-distance-mismatch.d.ts.map +1 -0
- package/dist/detectors/walk-time-distance-mismatch.js +38 -0
- package/dist/detectors/walk-time-distance-mismatch.js.map +1 -0
- package/dist/document.d.ts.map +1 -1
- package/dist/document.js +4 -1
- package/dist/document.js.map +1 -1
- package/dist/facts/approximate-tolerance.d.ts +7 -0
- package/dist/facts/approximate-tolerance.d.ts.map +1 -0
- package/dist/facts/approximate-tolerance.js +16 -0
- package/dist/facts/approximate-tolerance.js.map +1 -0
- package/dist/facts/item-amounts.d.ts +18 -0
- package/dist/facts/item-amounts.d.ts.map +1 -0
- package/dist/facts/item-amounts.js +67 -0
- package/dist/facts/item-amounts.js.map +1 -0
- package/dist/facts/labelled-facts.d.ts +4 -0
- package/dist/facts/labelled-facts.d.ts.map +1 -1
- package/dist/facts/labelled-facts.js +21 -6
- package/dist/facts/labelled-facts.js.map +1 -1
- package/dist/facts/measure-units.d.ts +5 -0
- package/dist/facts/measure-units.d.ts.map +1 -0
- package/dist/facts/measure-units.js +28 -0
- package/dist/facts/measure-units.js.map +1 -0
- package/dist/facts/measures.d.ts +23 -4
- package/dist/facts/measures.d.ts.map +1 -1
- package/dist/facts/measures.js +68 -19
- package/dist/facts/measures.js.map +1 -1
- package/dist/facts/retention-periods.d.ts +51 -0
- package/dist/facts/retention-periods.d.ts.map +1 -0
- package/dist/facts/retention-periods.js +148 -0
- package/dist/facts/retention-periods.js.map +1 -0
- package/dist/facts/table-facts.d.ts +2 -0
- package/dist/facts/table-facts.d.ts.map +1 -1
- package/dist/facts/table-facts.js +2 -0
- package/dist/facts/table-facts.js.map +1 -1
- package/dist/facts/unit-conflicts.d.ts +3 -2
- package/dist/facts/unit-conflicts.d.ts.map +1 -1
- package/dist/facts/unit-conflicts.js +15 -7
- package/dist/facts/unit-conflicts.js.map +1 -1
- package/dist/facts/unit-equivalents.d.ts +13 -0
- package/dist/facts/unit-equivalents.d.ts.map +1 -0
- package/dist/facts/unit-equivalents.js +56 -0
- package/dist/facts/unit-equivalents.js.map +1 -0
- package/dist/facts/unit-tolerance.d.ts +4 -0
- package/dist/facts/unit-tolerance.d.ts.map +1 -0
- package/dist/facts/unit-tolerance.js +13 -0
- package/dist/facts/unit-tolerance.js.map +1 -0
- package/dist/facts/unit-word.d.ts +8 -0
- package/dist/facts/unit-word.d.ts.map +1 -0
- package/dist/facts/unit-word.js +34 -0
- package/dist/facts/unit-word.js.map +1 -0
- package/dist/facts/written-precision.d.ts +10 -0
- package/dist/facts/written-precision.d.ts.map +1 -0
- package/dist/facts/written-precision.js +20 -0
- package/dist/facts/written-precision.js.map +1 -0
- package/dist/kana-spelling.d.ts +12 -0
- package/dist/kana-spelling.d.ts.map +1 -1
- package/dist/kana-spelling.js +23 -0
- package/dist/kana-spelling.js.map +1 -1
- package/dist/model-codes.d.ts +23 -0
- package/dist/model-codes.d.ts.map +1 -0
- package/dist/model-codes.js +81 -0
- package/dist/model-codes.js.map +1 -0
- package/dist/name-spelling-chars.d.ts +16 -0
- package/dist/name-spelling-chars.d.ts.map +1 -0
- package/dist/name-spelling-chars.js +14 -0
- package/dist/name-spelling-chars.js.map +1 -0
- package/dist/name-variants.d.ts +8 -2
- package/dist/name-variants.d.ts.map +1 -1
- package/dist/name-variants.js +72 -7
- package/dist/name-variants.js.map +1 -1
- package/dist/name-word-order.d.ts +49 -0
- package/dist/name-word-order.d.ts.map +1 -0
- package/dist/name-word-order.js +114 -0
- package/dist/name-word-order.js.map +1 -0
- package/dist/phone-numbers.d.ts.map +1 -1
- package/dist/phone-numbers.js +22 -5
- package/dist/phone-numbers.js.map +1 -1
- package/dist/place-names.d.ts +12 -5
- package/dist/place-names.d.ts.map +1 -1
- package/dist/place-names.js +34 -14
- package/dist/place-names.js.map +1 -1
- package/dist/plugin.d.ts +12 -0
- package/dist/plugin.d.ts.map +1 -1
- package/dist/preamble-paragraphs.d.ts +2 -1
- package/dist/preamble-paragraphs.d.ts.map +1 -1
- package/dist/preamble-paragraphs.js +16 -1
- package/dist/preamble-paragraphs.js.map +1 -1
- package/dist/profile/parse.d.ts.map +1 -1
- package/dist/profile/parse.js +11 -0
- package/dist/profile/parse.js.map +1 -1
- package/dist/return-type.d.ts +33 -0
- package/dist/return-type.d.ts.map +1 -0
- package/dist/return-type.js +302 -0
- package/dist/return-type.js.map +1 -0
- package/dist/spacing-code.d.ts +6 -0
- package/dist/spacing-code.d.ts.map +1 -0
- package/dist/spacing-code.js +16 -0
- package/dist/spacing-code.js.map +1 -0
- package/dist/structure/amount-range.d.ts +2 -2
- package/dist/structure/amount-range.d.ts.map +1 -1
- package/dist/structure/amount-range.js +12 -5
- package/dist/structure/amount-range.js.map +1 -1
- package/dist/structure/capacity-count.d.ts +59 -0
- package/dist/structure/capacity-count.d.ts.map +1 -0
- package/dist/structure/capacity-count.js +118 -0
- package/dist/structure/capacity-count.js.map +1 -0
- package/dist/structure/connection-times.d.ts +56 -0
- package/dist/structure/connection-times.d.ts.map +1 -0
- package/dist/structure/connection-times.js +165 -0
- package/dist/structure/connection-times.js.map +1 -0
- package/dist/structure/counted-amounts.d.ts +6 -0
- package/dist/structure/counted-amounts.d.ts.map +1 -1
- package/dist/structure/counted-amounts.js +4 -4
- package/dist/structure/counted-amounts.js.map +1 -1
- package/dist/structure/date-order-tie.d.ts +13 -0
- package/dist/structure/date-order-tie.d.ts.map +1 -0
- package/dist/structure/date-order-tie.js +61 -0
- package/dist/structure/date-order-tie.js.map +1 -0
- package/dist/structure/date-order.d.ts +2 -2
- package/dist/structure/date-order.d.ts.map +1 -1
- package/dist/structure/date-order.js +26 -9
- package/dist/structure/date-order.js.map +1 -1
- package/dist/structure/date-outside-period.d.ts +8 -0
- package/dist/structure/date-outside-period.d.ts.map +1 -1
- package/dist/structure/date-outside-period.js +52 -3
- package/dist/structure/date-outside-period.js.map +1 -1
- package/dist/structure/date-range.d.ts +6 -2
- package/dist/structure/date-range.d.ts.map +1 -1
- package/dist/structure/date-range.js +37 -9
- package/dist/structure/date-range.js.map +1 -1
- package/dist/structure/deadline-after-event.d.ts +23 -0
- package/dist/structure/deadline-after-event.d.ts.map +1 -0
- package/dist/structure/deadline-after-event.js +42 -0
- package/dist/structure/deadline-after-event.js.map +1 -0
- package/dist/structure/definition-use.d.ts +1 -1
- package/dist/structure/definition-use.d.ts.map +1 -1
- package/dist/structure/definition-use.js +55 -2
- package/dist/structure/definition-use.js.map +1 -1
- package/dist/structure/due-date.d.ts.map +1 -1
- package/dist/structure/due-date.js +5 -27
- package/dist/structure/due-date.js.map +1 -1
- package/dist/structure/labelled-date-order.d.ts +38 -0
- package/dist/structure/labelled-date-order.d.ts.map +1 -0
- package/dist/structure/labelled-date-order.js +41 -0
- package/dist/structure/labelled-date-order.js.map +1 -0
- package/dist/structure/layout-codes.d.ts +68 -0
- package/dist/structure/layout-codes.d.ts.map +1 -0
- package/dist/structure/layout-codes.js +161 -0
- package/dist/structure/layout-codes.js.map +1 -0
- package/dist/structure/leg-times.d.ts +2 -0
- package/dist/structure/leg-times.d.ts.map +1 -1
- package/dist/structure/leg-times.js +13 -0
- package/dist/structure/leg-times.js.map +1 -1
- package/dist/structure/measured-amounts.d.ts +17 -0
- package/dist/structure/measured-amounts.d.ts.map +1 -0
- package/dist/structure/measured-amounts.js +110 -0
- package/dist/structure/measured-amounts.js.map +1 -0
- package/dist/structure/party-order.d.ts +33 -0
- package/dist/structure/party-order.d.ts.map +1 -0
- package/dist/structure/party-order.js +79 -0
- package/dist/structure/party-order.js.map +1 -0
- package/dist/structure/quantity-range.d.ts +8 -0
- package/dist/structure/quantity-range.d.ts.map +1 -0
- package/dist/structure/quantity-range.js +36 -0
- package/dist/structure/quantity-range.js.map +1 -0
- package/dist/structure/range-bands.d.ts +75 -0
- package/dist/structure/range-bands.d.ts.map +1 -0
- package/dist/structure/range-bands.js +244 -0
- package/dist/structure/range-bands.js.map +1 -0
- package/dist/structure/rent-multiple.d.ts +76 -0
- package/dist/structure/rent-multiple.d.ts.map +1 -0
- package/dist/structure/rent-multiple.js +186 -0
- package/dist/structure/rent-multiple.js.map +1 -0
- package/dist/structure/requirement-lists.d.ts +37 -0
- package/dist/structure/requirement-lists.d.ts.map +1 -0
- package/dist/structure/requirement-lists.js +89 -0
- package/dist/structure/requirement-lists.js.map +1 -0
- package/dist/structure/scaled-quantities.d.ts +50 -0
- package/dist/structure/scaled-quantities.d.ts.map +1 -0
- package/dist/structure/scaled-quantities.js +153 -0
- package/dist/structure/scaled-quantities.js.map +1 -0
- package/dist/structure/stamp-order.d.ts +16 -0
- package/dist/structure/stamp-order.d.ts.map +1 -0
- package/dist/structure/stamp-order.js +78 -0
- package/dist/structure/stamp-order.js.map +1 -0
- package/dist/structure/step-times.d.ts +49 -0
- package/dist/structure/step-times.d.ts.map +1 -0
- package/dist/structure/step-times.js +128 -0
- package/dist/structure/step-times.js.map +1 -0
- package/dist/structure/term-deadline.d.ts +19 -0
- package/dist/structure/term-deadline.d.ts.map +1 -0
- package/dist/structure/term-deadline.js +28 -0
- package/dist/structure/term-deadline.js.map +1 -0
- package/dist/structure/time-order.d.ts +21 -0
- package/dist/structure/time-order.d.ts.map +1 -1
- package/dist/structure/time-order.js +5 -6
- package/dist/structure/time-order.js.map +1 -1
- package/dist/structure/time-range.d.ts +16 -0
- package/dist/structure/time-range.d.ts.map +1 -0
- package/dist/structure/time-range.js +57 -0
- package/dist/structure/time-range.js.map +1 -0
- package/dist/structure/total-line.d.ts +16 -0
- package/dist/structure/total-line.d.ts.map +1 -0
- package/dist/structure/total-line.js +44 -0
- package/dist/structure/total-line.js.map +1 -0
- package/dist/structure/total.d.ts +7 -1
- package/dist/structure/total.d.ts.map +1 -1
- package/dist/structure/total.js +28 -5
- package/dist/structure/total.js.map +1 -1
- package/dist/structure/unlisted-items.d.ts +70 -0
- package/dist/structure/unlisted-items.d.ts.map +1 -0
- package/dist/structure/unlisted-items.js +152 -0
- package/dist/structure/unlisted-items.js.map +1 -0
- package/dist/structure/version-order.d.ts +2 -0
- package/dist/structure/version-order.d.ts.map +1 -1
- package/dist/structure/version-order.js +10 -0
- package/dist/structure/version-order.js.map +1 -1
- package/dist/structure/walk-time.d.ts +87 -0
- package/dist/structure/walk-time.d.ts.map +1 -0
- package/dist/structure/walk-time.js +195 -0
- package/dist/structure/walk-time.js.map +1 -0
- package/dist/surname-near.d.ts +6 -0
- package/dist/surname-near.d.ts.map +1 -0
- package/dist/surname-near.js +31 -0
- package/dist/surname-near.js.map +1 -0
- package/dist/table-cells.d.ts +13 -0
- package/dist/table-cells.d.ts.map +1 -0
- package/dist/table-cells.js +36 -0
- package/dist/table-cells.js.map +1 -0
- package/dist/table-names.d.ts +42 -0
- package/dist/table-names.d.ts.map +1 -0
- package/dist/table-names.js +94 -0
- package/dist/table-names.js.map +1 -0
- package/package.json +3 -3
- package/profiles/listing.yaml +20 -0
- package/rules/announced-count-mismatch.yaml +2 -2
- package/rules/capacity-runtime-mismatch.yaml +66 -0
- package/rules/connection-time-short.yaml +52 -0
- package/rules/contact-variant.yaml +76 -0
- package/rules/count-over-capacity.yaml +55 -0
- package/rules/date-outside-period.yaml +4 -4
- package/rules/date-stamp-order.yaml +82 -0
- package/rules/deadline-after-event.yaml +67 -0
- package/rules/defined-name-repeated.yaml +2 -2
- package/rules/due-before-issue.yaml +11 -7
- package/rules/duration-mismatch.yaml +7 -4
- package/rules/duration-product-mismatch.yaml +73 -0
- package/rules/fact-conflict.yaml +9 -4
- package/rules/heading-echo.yaml +2 -2
- package/rules/interval-count-mismatch.yaml +54 -0
- package/rules/latin-spacing.yaml +2 -2
- package/rules/layout-code-mismatch.yaml +68 -0
- package/rules/name-variant.yaml +14 -2
- package/rules/no-em-dash.yaml +2 -2
- package/rules/party-order.yaml +84 -0
- package/rules/preamble-length.yaml +2 -2
- package/rules/quantity-range-reversed.yaml +53 -0
- package/rules/range-band-mismatch.yaml +70 -0
- package/rules/rent-multiple-mismatch.yaml +61 -0
- package/rules/required-listed-as-preferred.yaml +102 -0
- package/rules/return-type-mismatch.yaml +79 -0
- package/rules/scaled-quantity-mismatch.yaml +69 -0
- package/rules/step-time-sum-mismatch.yaml +65 -0
- package/rules/time-range-reversed.yaml +48 -0
- package/rules/title-case-consistency.yaml +2 -2
- package/rules/total-mismatch.yaml +2 -2
- package/rules/undefined-term.yaml +21 -7
- package/rules/unit-mismatch.yaml +12 -4
- package/rules/unlisted-item-used.yaml +90 -0
- package/rules/unused-definition.yaml +2 -2
- package/rules/use-before-definition.yaml +2 -2
- package/rules/walk-time-distance-mismatch.yaml +55 -0
- package/src/announced-count.ts +6 -3
- package/src/contacts/addresses.ts +179 -0
- package/src/contacts/emails.ts +63 -0
- package/src/contacts/variants.ts +33 -0
- package/src/derived/battery-runtime.ts +284 -0
- package/src/derived/period-counts.ts +178 -0
- package/src/derived/session-hours.ts +62 -0
- package/src/derived/time-lengths.ts +229 -0
- package/src/derived/unit-counts.ts +18 -0
- package/src/derived/use-interval.ts +151 -0
- package/src/derived/working-hours.ts +97 -0
- package/src/detectors/acronym-expansion.ts +57 -2
- package/src/detectors/announced-count.ts +1 -0
- package/src/detectors/capacity-runtime.ts +128 -0
- package/src/detectors/capitalised-term.ts +147 -0
- package/src/detectors/contact-variant.ts +24 -0
- package/src/detectors/count-over-capacity.ts +37 -0
- package/src/detectors/date-outside-period.ts +5 -1
- package/src/detectors/date-stamp-order.ts +28 -0
- package/src/detectors/defined-term-form.ts +63 -7
- package/src/detectors/definition-use.ts +6 -2
- package/src/detectors/derived-numbers.ts +97 -24
- package/src/detectors/due-date.ts +10 -2
- package/src/detectors/en-shape.ts +11 -4
- package/src/detectors/event-deadline.ts +29 -0
- package/src/detectors/fact-consistency.ts +64 -3
- package/src/detectors/heading-case.ts +13 -4
- package/src/detectors/heading-echo.ts +17 -1
- package/src/detectors/layout-code.ts +174 -0
- package/src/detectors/measured-facts.ts +20 -0
- package/src/detectors/name-variant-model-codes.ts +27 -0
- package/src/detectors/name-variant.ts +99 -15
- package/src/detectors/orthographic-variant.ts +78 -9
- package/src/detectors/orthography.ts +16 -6
- package/src/detectors/party-order.ts +50 -0
- package/src/detectors/quantity-range.ts +47 -0
- package/src/detectors/range-band.ts +125 -0
- package/src/detectors/registry/capacity-runtime-mismatch.ts +4 -0
- package/src/detectors/registry/connection-time-short.ts +4 -0
- package/src/detectors/registry/contact-variant.ts +4 -0
- package/src/detectors/registry/count-over-capacity.ts +4 -0
- package/src/detectors/registry/date-stamp-order.ts +4 -0
- package/src/detectors/registry/duration-product-mismatch.ts +4 -0
- package/src/detectors/registry/event-deadline.ts +4 -0
- package/src/detectors/registry/interval-count-mismatch.ts +4 -0
- package/src/detectors/registry/layout-code-mismatch.ts +4 -0
- package/src/detectors/registry/party-order.ts +4 -0
- package/src/detectors/registry/quantity-range.ts +4 -0
- package/src/detectors/registry/range-band-mismatch.ts +4 -0
- package/src/detectors/registry/rent-multiple-mismatch.ts +4 -0
- package/src/detectors/registry/requirement-lists.ts +4 -0
- package/src/detectors/registry/return-type.ts +4 -0
- package/src/detectors/registry/scaled-quantity-mismatch.ts +4 -0
- package/src/detectors/registry/step-time-sum-mismatch.ts +4 -0
- package/src/detectors/registry/time-range-reversed.ts +4 -0
- package/src/detectors/registry/unlisted-item-used.ts +4 -0
- package/src/detectors/registry/walk-time-distance-mismatch.ts +4 -0
- package/src/detectors/rent-multiple-mismatch.ts +56 -0
- package/src/detectors/requirement-lists.ts +65 -0
- package/src/detectors/return-type.ts +30 -0
- package/src/detectors/scaled-quantity.ts +49 -0
- package/src/detectors/signals.ts +3 -1
- package/src/detectors/step-time-sum.ts +55 -0
- package/src/detectors/structure-tree.ts +42 -6
- package/src/detectors/structure.ts +1 -1
- package/src/detectors/technical-docs.ts +12 -0
- package/src/detectors/time-order.ts +45 -6
- package/src/detectors/undefined-term.ts +20 -3
- package/src/detectors/unit-consistency.ts +50 -38
- package/src/detectors/unlisted-items.ts +72 -0
- package/src/detectors/use-count-words.ts +32 -0
- package/src/detectors/use-interval.ts +51 -0
- package/src/detectors/walk-time-distance-mismatch.ts +45 -0
- package/src/document.ts +4 -1
- package/src/facts/approximate-tolerance.ts +19 -0
- package/src/facts/item-amounts.ts +94 -0
- package/src/facts/labelled-facts.ts +29 -7
- package/src/facts/measure-units.ts +31 -0
- package/src/facts/measures.ts +113 -25
- package/src/facts/retention-periods.ts +216 -0
- package/src/facts/table-facts.ts +3 -0
- package/src/facts/unit-conflicts.ts +22 -9
- package/src/facts/unit-equivalents.ts +70 -0
- package/src/facts/unit-tolerance.ts +17 -0
- package/src/facts/unit-word.ts +35 -0
- package/src/facts/written-precision.ts +23 -0
- package/src/kana-spelling.ts +25 -0
- package/src/model-codes.ts +104 -0
- package/src/name-spelling-chars.ts +34 -0
- package/src/name-variants.ts +83 -7
- package/src/name-word-order.ts +149 -0
- package/src/phone-numbers.ts +26 -6
- package/src/place-names.ts +53 -14
- package/src/plugin.ts +7 -0
- package/src/preamble-paragraphs.ts +21 -2
- package/src/profile/parse.ts +10 -0
- package/src/return-type.ts +361 -0
- package/src/spacing-code.ts +26 -0
- package/src/structure/amount-range.ts +16 -7
- package/src/structure/capacity-count.ts +196 -0
- package/src/structure/connection-times.ts +226 -0
- package/src/structure/counted-amounts.ts +5 -4
- package/src/structure/date-order-tie.ts +86 -0
- package/src/structure/date-order.ts +41 -14
- package/src/structure/date-outside-period.ts +77 -7
- package/src/structure/date-range.ts +45 -9
- package/src/structure/deadline-after-event.ts +67 -0
- package/src/structure/definition-use.ts +59 -2
- package/src/structure/due-date.ts +8 -32
- package/src/structure/labelled-date-order.ts +84 -0
- package/src/structure/layout-codes.ts +210 -0
- package/src/structure/leg-times.ts +15 -0
- package/src/structure/measured-amounts.ts +138 -0
- package/src/structure/party-order.ts +115 -0
- package/src/structure/quantity-range.ts +54 -0
- package/src/structure/range-bands.ts +316 -0
- package/src/structure/rent-multiple.ts +277 -0
- package/src/structure/requirement-lists.ts +145 -0
- package/src/structure/scaled-quantities.ts +225 -0
- package/src/structure/stamp-order.ts +100 -0
- package/src/structure/step-times.ts +169 -0
- package/src/structure/term-deadline.ts +35 -0
- package/src/structure/time-order.ts +8 -7
- package/src/structure/time-range.ts +64 -0
- package/src/structure/total-line.ts +63 -0
- package/src/structure/total.ts +41 -6
- package/src/structure/unlisted-items.ts +207 -0
- package/src/structure/version-order.ts +10 -0
- package/src/structure/walk-time.ts +285 -0
- package/src/surname-near.ts +31 -0
- package/src/table-cells.ts +41 -0
- package/src/table-names.ts +113 -0
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
// required-listed-as-preferred: one skill or qualification listed under a required heading or label and again under a
|
|
2
|
+
// preferred one. The headings and labels, the units and words of a length of experience, and the words that only end an
|
|
3
|
+
// item come from the lexicons. Pure.
|
|
4
|
+
import { escapeRegExp } from "../orthography.js";
|
|
5
|
+
const MARKS = /[*_`~]/gu;
|
|
6
|
+
const LATIN = /^[a-z]/u;
|
|
7
|
+
const plain = (text) => text.normalize("NFKC").toLowerCase().replace(MARKS, "").replace(/\s+/gu, " ").trim();
|
|
8
|
+
/** A Latin word is matched at word edges; other scripts as written. */
|
|
9
|
+
const wordPattern = (word) => {
|
|
10
|
+
const escaped = escapeRegExp(plain(word));
|
|
11
|
+
return LATIN.test(plain(word)) ? `(?<![a-z])${escaped}(?![a-z])` : escaped;
|
|
12
|
+
};
|
|
13
|
+
const alternation = (words) => words
|
|
14
|
+
.toSorted((left, right) => right.length - left.length)
|
|
15
|
+
.map(wordPattern)
|
|
16
|
+
.join("|");
|
|
17
|
+
/** The text without the characters at either end that the test accepts (no backtracking regex on long lines). */
|
|
18
|
+
const trimWhere = (text, isEdge) => {
|
|
19
|
+
const chars = [...text];
|
|
20
|
+
const start = chars.findIndex((char) => !isEdge(char));
|
|
21
|
+
return start === -1 ? "" : chars.slice(start, chars.findLastIndex((char) => !isEdge(char)) + 1).join("");
|
|
22
|
+
};
|
|
23
|
+
const LABEL_EDGE = /[\s【[[「((】]\]」))::]/u;
|
|
24
|
+
const asLabel = (text) => trimWhere(plain(text).replace(/[-‐–]/gu, " "), (char) => LABEL_EDGE.test(char)).replace(/\s+/gu, " ");
|
|
25
|
+
const kindOfLabel = (label, words) => {
|
|
26
|
+
if (label === "")
|
|
27
|
+
return undefined;
|
|
28
|
+
if (words.required.some((word) => asLabel(word) === label))
|
|
29
|
+
return "required";
|
|
30
|
+
return words.preferred.some((word) => asLabel(word) === label) ? "preferred" : undefined;
|
|
31
|
+
};
|
|
32
|
+
const HEADING_PARTS = /[・//、,,((::]/u;
|
|
33
|
+
/** A heading names its kind by its first part (必須スキル・経験, 歓迎(あれば尚可)); a line standing alone, by all of it. */
|
|
34
|
+
const kindOfHeading = (text, words) => kindOfLabel(asLabel(text.split(HEADING_PARTS)[0] ?? ""), words);
|
|
35
|
+
/** A heading opens a scope that its subheadings inherit unless they name their own kind; a label holds until the next heading or label. */
|
|
36
|
+
const step = (walk, block, words) => {
|
|
37
|
+
if (block.kind === "heading") {
|
|
38
|
+
const outer = walk.scopes.filter((scope) => scope.depth < block.depth);
|
|
39
|
+
const kind = kindOfHeading(block.text, words) ?? outer.at(-1)?.kind;
|
|
40
|
+
return { ...walk, scopes: [...outer, { depth: block.depth, kind, offset: block.offset }], label: undefined };
|
|
41
|
+
}
|
|
42
|
+
if (block.kind === "line") {
|
|
43
|
+
const kind = kindOfLabel(asLabel(block.text), words);
|
|
44
|
+
return kind === undefined ? walk : { ...walk, label: kind };
|
|
45
|
+
}
|
|
46
|
+
const kind = walk.label ?? walk.scopes.at(-1)?.kind;
|
|
47
|
+
const container = walk.scopes.findLast((scope) => scope.kind === undefined)?.offset ?? -1;
|
|
48
|
+
return kind === undefined ? walk : { ...walk, items: [...walk.items, { kind, text: block.text.trim(), offset: block.offset, container }] };
|
|
49
|
+
};
|
|
50
|
+
const numberPattern = (words) => [String.raw `\d+(?:\.\d+)?`, alternation(words.numbers.map((entry) => entry.word))].filter((part) => part !== "").join("|");
|
|
51
|
+
const lengthPattern = (words) => {
|
|
52
|
+
if (words.units.length === 0)
|
|
53
|
+
return undefined;
|
|
54
|
+
const before = words.before.length === 0 ? "" : `(?:(?:${alternation(words.before)})\\s*)?`;
|
|
55
|
+
const after = words.after.length === 0 ? "" : `(?:\\s*(?:${alternation(words.after)}))*`;
|
|
56
|
+
return new RegExp(`${before}(${numberPattern(words)})\\s*\\+?\\s*(${alternation(words.units.map((unit) => unit.word))})['’]?${after}`, "gu");
|
|
57
|
+
};
|
|
58
|
+
const valueOf = (written, words) => words.find((entry) => plain(entry.word) === written)?.value ?? Number(written);
|
|
59
|
+
/** Punctuation, symbols and spaces, but not the + and # that end a name (C++, C#). */
|
|
60
|
+
const PUNCTUATION = /(?<![\p{L}\p{N}+#])[+#]|[^\p{L}\p{N}+#]/gu;
|
|
61
|
+
const EDGE_PUNCTUATION = /[\p{P}\s]/u;
|
|
62
|
+
const withoutEnding = (written, endings) => {
|
|
63
|
+
const text = trimWhere(written, (char) => char !== "#" && EDGE_PUNCTUATION.test(char));
|
|
64
|
+
const ending = endings.map(plain).find((word) => word !== "" && text.endsWith(word) && text.length > word.length);
|
|
65
|
+
return ending === undefined ? text : withoutEnding(text.slice(0, -ending.length), endings);
|
|
66
|
+
};
|
|
67
|
+
const readingOf = (text, words) => {
|
|
68
|
+
const written = plain(text);
|
|
69
|
+
const pattern = lengthPattern(words);
|
|
70
|
+
const lengths = pattern === undefined ? [] : [...written.matchAll(pattern)];
|
|
71
|
+
const months = lengths.map((match) => valueOf(match[1] ?? "", words.numbers) * (words.units.find((unit) => plain(unit.word) === match[2])?.value ?? 0));
|
|
72
|
+
const rest = pattern === undefined ? written : written.replace(pattern, " ");
|
|
73
|
+
return { core: withoutEnding(rest.replace(/\s+/gu, " ").trim(), words.endings).replace(PUNCTUATION, ""), months: Math.max(0, ...months) };
|
|
74
|
+
};
|
|
75
|
+
/** A preferred item repeats a required one when it names the same skill and asks for no longer experience. */
|
|
76
|
+
const repeats = (preferred, required) => preferred.core !== "" && preferred.core === required.core && preferred.months <= required.months;
|
|
77
|
+
/** The preferred items that repeat a required item of the same document, once each, in document order. */
|
|
78
|
+
export const requiredListedAsPreferred = (blocks, words) => {
|
|
79
|
+
const { items } = blocks.reduce((walk, block) => step(walk, block, words), { scopes: [], label: undefined, items: [] });
|
|
80
|
+
const required = items.filter((item) => item.kind === "required").map((item) => ({ item, reading: readingOf(item.text, words) }));
|
|
81
|
+
return items
|
|
82
|
+
.filter((item) => item.kind === "preferred")
|
|
83
|
+
.flatMap((item) => {
|
|
84
|
+
const reading = readingOf(item.text, words);
|
|
85
|
+
const match = required.find((candidate) => candidate.item.container === item.container && repeats(reading, candidate.reading));
|
|
86
|
+
return match === undefined ? [] : [{ offset: item.offset, values: { item: item.text, required: match.item.text } }];
|
|
87
|
+
});
|
|
88
|
+
};
|
|
89
|
+
//# sourceMappingURL=requirement-lists.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"requirement-lists.js","sourceRoot":"","sources":["../../src/structure/requirement-lists.ts"],"names":[],"mappings":"AAAA,sHAAsH;AACtH,wHAAwH;AACxH,qCAAqC;AACrC,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAkCjD,MAAM,KAAK,GAAG,UAAU,CAAC;AAEzB,MAAM,KAAK,GAAG,SAAS,CAAC;AAExB,MAAM,KAAK,GAAG,CAAC,IAAY,EAAU,EAAE,CAAC,IAA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QAAQ,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC;IAClI,OAAO,KAAK;SACT,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,WAAW,CAAC;SAC3C,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;QAChB,MAAM,OAAO,GAAG,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QAC5C,MAAM,KAAK,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,SAAS,KAAK,IAAI,CAAC,SAAS,IAAI,OAAO,CAAC,OAAO,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC;QAC/H,OAAO,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,QAAQ,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IACtH,CAAC,CAAC,CAAC;AACP,CAAC,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { type Cell } from "../facts/table-facts.ts";
|
|
2
|
+
import { type MeasureUnit } from "../facts/measures.ts";
|
|
3
|
+
import type { Mark } from "./time-marks.ts";
|
|
4
|
+
/**
|
|
5
|
+
* A table with one column per number of servings or batch size (4人分 / 8人分, Serves 4 / Serves 8, ×1 / ×2), and the one
|
|
6
|
+
* row that does not grow by the columns' ratio while the others do. The words come from the language packages. Pure.
|
|
7
|
+
*/
|
|
8
|
+
export type ScaleWords = {
|
|
9
|
+
/** What marks a column as a number of servings (人分 after the number, Serves before it). */
|
|
10
|
+
readonly columns: readonly Mark[];
|
|
11
|
+
/** An amount that is left to the cook (少々, to taste): its row may stay as it is. */
|
|
12
|
+
readonly unscaled: readonly string[];
|
|
13
|
+
/** Spellings of one unit (teaspoon, teaspoons, tsp), each named by its group. */
|
|
14
|
+
readonly unitForms: readonly {
|
|
15
|
+
readonly pattern: string;
|
|
16
|
+
readonly group: string;
|
|
17
|
+
}[];
|
|
18
|
+
/** Units with a factor to a base unit (g and kg), so 1 kg and 1000 g read as one amount. */
|
|
19
|
+
readonly measures: readonly MeasureUnit[];
|
|
20
|
+
};
|
|
21
|
+
/** amount is in the base unit when the unit has a factor (1 kg is 1000); written is the number as written (1). */
|
|
22
|
+
export type Amount = {
|
|
23
|
+
readonly amount: number;
|
|
24
|
+
readonly written: number;
|
|
25
|
+
readonly unit: string;
|
|
26
|
+
};
|
|
27
|
+
export type ScaleSlip = {
|
|
28
|
+
/** The row's first cell: the item. */
|
|
29
|
+
readonly item: Cell;
|
|
30
|
+
/** The cell that does not scale, and the column it is in. */
|
|
31
|
+
readonly cell: Cell;
|
|
32
|
+
readonly heading: string;
|
|
33
|
+
/** The cell it is compared with, and that column. */
|
|
34
|
+
readonly other: Cell;
|
|
35
|
+
readonly otherHeading: string;
|
|
36
|
+
/** What the cell would hold if it scaled like the other rows, in the unit it is written in. */
|
|
37
|
+
readonly expected: number;
|
|
38
|
+
readonly scaledRows: number;
|
|
39
|
+
};
|
|
40
|
+
/** Fewer rows than this that scale exactly are no evidence that the table scales at all. */
|
|
41
|
+
export declare const MIN_SCALED_ROWS = 3;
|
|
42
|
+
/** The number of servings a column heading names (4人分, Serves 8, ×2), or undefined. */
|
|
43
|
+
export declare const servingsOf: (heading: string, marks: readonly Mark[]) => number | undefined;
|
|
44
|
+
/** One cell's amount and the unit it is in. undefined when the cell holds no number, or more than one (1と1/2, 2 (300 g)). */
|
|
45
|
+
export declare const amountOf: (cellText: string, words: ScaleWords) => Amount | undefined;
|
|
46
|
+
/** What `amount` would be if it were `ratio` times `from`, in the unit `amount` is written in. */
|
|
47
|
+
export declare const expectedOf: (from: Amount, amount: Amount, ratio: number) => number;
|
|
48
|
+
/** Every table of the source with two or more servings columns, and the cells in them that do not scale. */
|
|
49
|
+
export declare const scaleSlips: (source: string, words: ScaleWords) => ScaleSlip[];
|
|
50
|
+
//# sourceMappingURL=scaled-quantities.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scaled-quantities.d.ts","sourceRoot":"","sources":["../../src/structure/scaled-quantities.ts"],"names":[],"mappings":"AAEA,OAAO,EAAqB,KAAK,IAAI,EAAE,MAAM,yBAAyB,CAAC;AACvE,OAAO,EAAkB,KAAK,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAGxE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAE5C;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB,2FAA2F;IAC3F,QAAQ,CAAC,OAAO,EAAE,SAAS,IAAI,EAAE,CAAC;IAClC,oFAAoF;IACpF,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC,iFAAiF;IACjF,QAAQ,CAAC,SAAS,EAAE,SAAS;QAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACpF,4FAA4F;IAC5F,QAAQ,CAAC,QAAQ,EAAE,SAAS,WAAW,EAAE,CAAC;CAC3C,CAAC;AAEF,kHAAkH;AAClH,MAAM,MAAM,MAAM,GAAG;IAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAElG,MAAM,MAAM,SAAS,GAAG;IACtB,sCAAsC;IACtC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;IACpB,6DAA6D;IAC7D,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;IACpB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,qDAAqD;IACrD,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC;IACrB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,+FAA+F;IAC/F,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B,CAAC;AAEF,4FAA4F;AAC5F,eAAO,MAAM,eAAe,IAAI,CAAC;AAMjC,uFAAuF;AACvF,eAAO,MAAM,UAAU,GAAI,SAAS,MAAM,EAAE,OAAO,SAAS,IAAI,EAAE,KAAG,MAAM,GAAG,SAW7E,CAAC;AAoCF,6HAA6H;AAC7H,eAAO,MAAM,QAAQ,GAAI,UAAU,MAAM,EAAE,OAAO,UAAU,KAAG,MAAM,GAAG,SAavE,CAAC;AAmDF,kGAAkG;AAClG,eAAO,MAAM,UAAU,GAAI,MAAM,MAAM,EAAE,QAAQ,MAAM,EAAE,OAAO,MAAM,KAAG,MAGxE,CAAC;AAsDF,4GAA4G;AAC5G,eAAO,MAAM,UAAU,GAAI,QAAQ,MAAM,EAAE,OAAO,UAAU,KAAG,SAAS,EAKpE,CAAC"}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { escapeRegExp } from "../orthography.js";
|
|
2
|
+
import { cellsOf, tablesOf } from "../facts/table-facts.js";
|
|
3
|
+
import { measuredValues } from "../facts/measures.js";
|
|
4
|
+
import { withoutEdgeMarks } from "../facts/trim-marks.js";
|
|
5
|
+
import { linesOf } from "./lines.js";
|
|
6
|
+
/** Fewer rows than this that scale exactly are no evidence that the table scales at all. */
|
|
7
|
+
export const MIN_SCALED_ROWS = 3;
|
|
8
|
+
const SAME = 1e-9;
|
|
9
|
+
const MIN_COLUMNS = 2;
|
|
10
|
+
const NUMBER_TEXT = "[0-9]+(?:\\.[0-9]+)?";
|
|
11
|
+
/** The number of servings a column heading names (4人分, Serves 8, ×2), or undefined. */
|
|
12
|
+
export const servingsOf = (heading, marks) => {
|
|
13
|
+
const text = withoutEdgeMarks(heading.normalize("NFKC").trim()).toLowerCase();
|
|
14
|
+
const read = marks
|
|
15
|
+
.map((mark) => {
|
|
16
|
+
const word = escapeRegExp(mark.pattern.normalize("NFKC").toLowerCase());
|
|
17
|
+
const pattern = mark.position === "before" ? `^${word}\\s*(${NUMBER_TEXT})$` : `^(${NUMBER_TEXT})\\s*${word}$`;
|
|
18
|
+
return new RegExp(pattern, "u").exec(text)?.[1];
|
|
19
|
+
})
|
|
20
|
+
.find((number) => number !== undefined);
|
|
21
|
+
const servings = read === undefined ? undefined : Number(read);
|
|
22
|
+
return servings === undefined || !Number.isFinite(servings) || servings <= 0 ? undefined : servings;
|
|
23
|
+
};
|
|
24
|
+
/** A whole or decimal number (1,000 and 1.5), with a fraction after it (1 1/2) or as a fraction (1/2, ½). */
|
|
25
|
+
const WHOLE = String.raw `[0-9]+(?:,[0-9]{3})*(?:\.[0-9]+)?`;
|
|
26
|
+
const FRACTION = String.raw `(?:\s([0-9]+)[/⁄]([0-9]+)|[/⁄]([0-9]+))?`;
|
|
27
|
+
const AMOUNT = new RegExp(String.raw `(?<![\p{N}.,/⁄])(${WHOLE})${FRACTION}(?![\p{N}/⁄])`, "gu");
|
|
28
|
+
const valueOf = (match) => {
|
|
29
|
+
const whole = Number((match[1] ?? "").replace(/,/gu, ""));
|
|
30
|
+
if (match[4] !== undefined)
|
|
31
|
+
return whole / Number(match[4]);
|
|
32
|
+
return match[2] === undefined ? whole : whole + Number(match[2]) / Number(match[3]);
|
|
33
|
+
};
|
|
34
|
+
const LETTER_BEFORE = "(?<!\\p{L})";
|
|
35
|
+
const LETTER_AFTER = "(?!\\p{L})";
|
|
36
|
+
/** The cell's text with its number taken out and each spelling of a unit written as its group: "2 teaspoons" is "#teaspoon". */
|
|
37
|
+
const unitKey = (text, numberAt, forms) => {
|
|
38
|
+
const rest = `${text.slice(0, numberAt.start)}#${text.slice(numberAt.end)}`.toLowerCase();
|
|
39
|
+
const groups = new Map(forms.map((form) => [form.pattern.toLowerCase(), form.group]));
|
|
40
|
+
const spellings = [...groups.keys()].filter((pattern) => pattern !== "").toSorted((left, right) => right.length - left.length);
|
|
41
|
+
const grouped = spellings.length === 0
|
|
42
|
+
? rest
|
|
43
|
+
: rest.replace(new RegExp(`${LETTER_BEFORE}(?:${spellings.map(escapeRegExp).join("|")})${LETTER_AFTER}`, "gu"), (spelling) => `<${groups.get(spelling) ?? spelling}>`);
|
|
44
|
+
return grouped.replace(/\s+/gu, "");
|
|
45
|
+
};
|
|
46
|
+
/** NFKC writes ½ as 1⁄2, so 1½ would read as 11⁄2: a space keeps the whole number apart (1 1⁄2). */
|
|
47
|
+
const VULGAR_AFTER_DIGIT = /([0-90-9])([¼½¾⅐-⅞])/gu;
|
|
48
|
+
const normalized = (cellText) => withoutEdgeMarks(cellText.replace(VULGAR_AFTER_DIGIT, "$1 $2").normalize("NFKC").trim());
|
|
49
|
+
/** One cell's amount and the unit it is in. undefined when the cell holds no number, or more than one (1と1/2, 2 (300 g)). */
|
|
50
|
+
export const amountOf = (cellText, words) => {
|
|
51
|
+
const text = normalized(cellText);
|
|
52
|
+
const numbers = [...text.matchAll(AMOUNT)];
|
|
53
|
+
const [only] = numbers;
|
|
54
|
+
if (numbers.length !== 1 || only === undefined)
|
|
55
|
+
return undefined;
|
|
56
|
+
const written = valueOf(only);
|
|
57
|
+
if (!Number.isFinite(written))
|
|
58
|
+
return undefined;
|
|
59
|
+
const [measured] = measuredValues(text, words.measures);
|
|
60
|
+
const factor = measured?.factors[0];
|
|
61
|
+
if (measured !== undefined && factor !== undefined && measured.start === only.index && measured.end === text.length) {
|
|
62
|
+
return { amount: measured.amount * factor, written: measured.amount, unit: `=${measured.dimension}` };
|
|
63
|
+
}
|
|
64
|
+
return { amount: written, written, unit: unitKey(text, { start: only.index, end: only.index + only[0].length }, words.unitForms) };
|
|
65
|
+
};
|
|
66
|
+
const isUnscaled = (text, unscaled) => {
|
|
67
|
+
const lower = text.normalize("NFKC").toLowerCase();
|
|
68
|
+
return unscaled.some((word) => word !== "" && lower.includes(word.normalize("NFKC").toLowerCase()));
|
|
69
|
+
};
|
|
70
|
+
/** The rows of one table whose item is named, as cells. */
|
|
71
|
+
const rowsOf = (rows) => rows.flatMap((line) => {
|
|
72
|
+
const cells = cellsOf(line);
|
|
73
|
+
const [item] = cells;
|
|
74
|
+
return item === undefined || withoutEdgeMarks(item.text) === "" ? [] : [{ item, cells }];
|
|
75
|
+
});
|
|
76
|
+
/** Each row's two cells, when both are amounts in one unit and the row is not left to the cook. */
|
|
77
|
+
const readablePairs = (rows, base, other, words) => rows.flatMap((row) => {
|
|
78
|
+
const [baseCell, cell] = [row.cells[base.index], row.cells[other.index]];
|
|
79
|
+
if (baseCell === undefined || cell === undefined)
|
|
80
|
+
return [];
|
|
81
|
+
if (isUnscaled(baseCell.text, words.unscaled) || isUnscaled(cell.text, words.unscaled))
|
|
82
|
+
return [];
|
|
83
|
+
const [from, to] = [amountOf(baseCell.text, words), amountOf(cell.text, words)];
|
|
84
|
+
if (from === undefined || to === undefined || from.unit !== to.unit)
|
|
85
|
+
return [];
|
|
86
|
+
const scaled = (from.amount * other.servings) / base.servings;
|
|
87
|
+
return [{ row, baseCell, cell, from, to, scales: Math.abs(to.amount - scaled) <= SAME * Math.max(Math.abs(scaled), 1) }];
|
|
88
|
+
});
|
|
89
|
+
/** The one row of a column that departs from the base column while at least MIN_SCALED_ROWS others scale exactly. */
|
|
90
|
+
const departureOf = (rows, base, other, words) => {
|
|
91
|
+
const pairs = readablePairs(rows, base, other, words);
|
|
92
|
+
const departing = pairs.filter((pair) => !pair.scales);
|
|
93
|
+
const [only] = departing;
|
|
94
|
+
const scaled = pairs.length - departing.length;
|
|
95
|
+
return departing.length === 1 && only !== undefined && scaled >= MIN_SCALED_ROWS ? { pair: only, scaled } : undefined;
|
|
96
|
+
};
|
|
97
|
+
/** What `amount` would be if it were `ratio` times `from`, in the unit `amount` is written in. */
|
|
98
|
+
export const expectedOf = (from, amount, ratio) => {
|
|
99
|
+
const perWritten = amount.written === 0 || amount.amount === 0 ? 1 : amount.amount / amount.written;
|
|
100
|
+
return (from.amount * ratio) / perWritten;
|
|
101
|
+
};
|
|
102
|
+
const columnSlip = (base, other, { pair, scaled }) => ({
|
|
103
|
+
item: pair.row.item,
|
|
104
|
+
cell: pair.cell,
|
|
105
|
+
heading: other.heading,
|
|
106
|
+
other: pair.baseCell,
|
|
107
|
+
otherHeading: base.heading,
|
|
108
|
+
expected: expectedOf(pair.from, pair.to, other.servings / base.servings),
|
|
109
|
+
scaledRows: scaled,
|
|
110
|
+
});
|
|
111
|
+
const baseSlip = (base, other, { pair, scaled }) => ({
|
|
112
|
+
item: pair.row.item,
|
|
113
|
+
cell: pair.baseCell,
|
|
114
|
+
heading: base.heading,
|
|
115
|
+
other: pair.cell,
|
|
116
|
+
otherHeading: other.heading,
|
|
117
|
+
expected: expectedOf(pair.to, pair.from, base.servings / other.servings),
|
|
118
|
+
scaledRows: scaled,
|
|
119
|
+
});
|
|
120
|
+
/** Whether the row's cells outside the first column scale with each other (a row fixed in every column does not). */
|
|
121
|
+
const othersAgree = (found) => {
|
|
122
|
+
const perServing = found.map(({ other, departure }) => (departure === undefined ? Number.NaN : departure.pair.to.amount / other.servings));
|
|
123
|
+
const [first] = perServing;
|
|
124
|
+
return first !== undefined && perServing.every((value) => Math.abs(value - first) <= SAME * Math.max(Math.abs(first), 1));
|
|
125
|
+
};
|
|
126
|
+
/**
|
|
127
|
+
* One table's slips. Each column is compared with the first servings column. When the same row departs in every other column
|
|
128
|
+
* (three or more columns) and those columns scale with each other, it is the first column's cell that is off, and that cell is
|
|
129
|
+
* reported once; a row that departs everywhere without that (the same amount in every column) may be fixed on purpose.
|
|
130
|
+
*/
|
|
131
|
+
const tableSlips = (columns, rows, words) => {
|
|
132
|
+
const [base, ...others] = columns;
|
|
133
|
+
if (base === undefined)
|
|
134
|
+
return [];
|
|
135
|
+
const found = others.map((other) => ({ other, departure: departureOf(rows, base, other, words) }));
|
|
136
|
+
const [first] = found;
|
|
137
|
+
const offRows = new Set(found.map(({ departure }) => departure?.pair.row));
|
|
138
|
+
if (others.length > 1 && offRows.size === 1 && first?.departure !== undefined) {
|
|
139
|
+
return othersAgree(found) ? [baseSlip(base, first.other, first.departure)] : [];
|
|
140
|
+
}
|
|
141
|
+
return found.flatMap(({ other, departure }) => (departure === undefined ? [] : [columnSlip(base, other, departure)]));
|
|
142
|
+
};
|
|
143
|
+
const columnsOf = (header, marks) => cellsOf(header).flatMap((cell, index) => {
|
|
144
|
+
const servings = index === 0 ? undefined : servingsOf(cell.text, marks);
|
|
145
|
+
return servings === undefined ? [] : [{ index, servings, heading: withoutEdgeMarks(cell.text.trim()) }];
|
|
146
|
+
});
|
|
147
|
+
/** Every table of the source with two or more servings columns, and the cells in them that do not scale. */
|
|
148
|
+
export const scaleSlips = (source, words) => tablesOf(linesOf(source)).flatMap((table) => {
|
|
149
|
+
const columns = columnsOf(table.header, words.columns);
|
|
150
|
+
const distinct = new Set(columns.map((column) => column.servings));
|
|
151
|
+
return distinct.size === columns.length && columns.length >= MIN_COLUMNS ? tableSlips(columns, rowsOf(table.rows), words) : [];
|
|
152
|
+
});
|
|
153
|
+
//# sourceMappingURL=scaled-quantities.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scaled-quantities.js","sourceRoot":"","sources":["../../src/structure/scaled-quantities.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAa,MAAM,yBAAyB,CAAC;AACvE,OAAO,EAAE,cAAc,EAAoB,MA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AC,CAAC,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC;AAC1G,CAAC,CAAC,CAAC;AAEL,4GAA4G;AAC5G,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,MAAc,EAAE,KAAiB,EAAe,EAAE,CAC3E,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;IAC1C,MAAM,OAAO,GAAG,SAAS,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;IACvD,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC;IACnE,OAAO,QAAQ,CAAC,IAAI,KAAK,OAAO,CAAC,MAAM,IAAI,OAAO,CAAC,MAAM,IAAI,WAAW,CAAC,CAAC,CAAC,UAAU,CAAC,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AACjI,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { DatedSpan } from "./date-range.ts";
|
|
2
|
+
import type { StructureIssue } from "./issues.ts";
|
|
3
|
+
/**
|
|
4
|
+
* A document's stamp dates out of order: an established date (2024年10月1日 制定, Established: April 1, 2023) later than an
|
|
5
|
+
* update (2024年9月1日 最終改定, Last updated: September 1, 2024). A stamp line (or one part of a line that holds several dates)
|
|
6
|
+
* holds one full date and, once the date is taken out, nothing but one stamp word (with colons, brackets, emphasis or a list
|
|
7
|
+
* marker around it). Only stamps written together are compared. Both stamps are reported, each naming the other: nothing tells
|
|
8
|
+
* which of the two dates is the wrong one. Pure; the stamp words come from the caller.
|
|
9
|
+
*/
|
|
10
|
+
export type StampWords = {
|
|
11
|
+
readonly established: readonly string[];
|
|
12
|
+
readonly updated: readonly string[];
|
|
13
|
+
};
|
|
14
|
+
/** Each established stamp later than an update of its block, and each such update, the one naming the other. */
|
|
15
|
+
export declare const stampOrderIssues: (source: string, dates: readonly DatedSpan[], words: StampWords) => StructureIssue[];
|
|
16
|
+
//# sourceMappingURL=stamp-order.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stamp-order.d.ts","sourceRoot":"","sources":["../../src/structure/stamp-order.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAGlD;;;;;;GAMG;AACH,MAAM,MAAM,UAAU,GAAG;IAAE,QAAQ,CAAC,WAAW,EAAE,SAAS,MAAM,EAAE,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,CAAC;AAkF1G,gHAAgH;AAChH,eAAO,MAAM,gBAAgB,GAAI,QAAQ,MAAM,EAAE,OAAO,SAAS,SAAS,EAAE,EAAE,OAAO,UAAU,KAAG,cAAc,EAK/G,CAAC"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { linesOf } from "./lines.js";
|
|
2
|
+
const FULL_DATE = /^\d{4}-\d{2}-\d{2}$/u;
|
|
3
|
+
/** How many lines apart two stamps may be and still be one document's stamp block; further apart, they date two documents. */
|
|
4
|
+
const MAX_LINE_GAP = 6;
|
|
5
|
+
/** What may stand around a stamp word: spaces, colons, brackets, table bars, Markdown emphasis and list markers. */
|
|
6
|
+
const AROUND_WORD = /[\s::*_()()[\]「」【】||\-‐−・]/u;
|
|
7
|
+
/** A part of a line between a wide space, a tab or a bar. */
|
|
8
|
+
const FIELD = /[^\t\u3000||]+/gu;
|
|
9
|
+
const bareWord = (text) => {
|
|
10
|
+
const chars = [...text];
|
|
11
|
+
const first = chars.findIndex((char) => !AROUND_WORD.test(char));
|
|
12
|
+
const last = chars.findLastIndex((char) => !AROUND_WORD.test(char));
|
|
13
|
+
return first === -1
|
|
14
|
+
? ""
|
|
15
|
+
: chars
|
|
16
|
+
.slice(first, last + 1)
|
|
17
|
+
.join("")
|
|
18
|
+
.toLowerCase();
|
|
19
|
+
};
|
|
20
|
+
const kindOf = (word, words) => {
|
|
21
|
+
const isOne = (list) => list.some((entry) => entry.toLowerCase() === word);
|
|
22
|
+
if (isOne(words.established))
|
|
23
|
+
return "established";
|
|
24
|
+
return isOne(words.updated) ? "updated" : undefined;
|
|
25
|
+
};
|
|
26
|
+
const datesIn = (dates, field) => dates.filter((date) => date.offset >= field.start && date.end <= field.end);
|
|
27
|
+
/** A line, or, when it holds more than one date, its parts between wide spaces, tabs and bars (作成:平成16年2月4日, a wide space, 最終改定:令和3年11月19日). */
|
|
28
|
+
const fieldsOf = (source, dates) => linesOf(source).flatMap((line) => {
|
|
29
|
+
const whole = { start: line.start, end: line.start + line.text.length, line: line.number };
|
|
30
|
+
if (datesIn(dates, whole).length < 2)
|
|
31
|
+
return [whole];
|
|
32
|
+
return [...line.text.matchAll(FIELD)].map((match) => ({
|
|
33
|
+
start: line.start + match.index,
|
|
34
|
+
end: line.start + match.index + match[0].length,
|
|
35
|
+
line: line.number,
|
|
36
|
+
}));
|
|
37
|
+
});
|
|
38
|
+
/** The stamps of a text: a line or field holding one full date and one stamp word, nothing else. */
|
|
39
|
+
const stampsOf = (source, dates, words) => fieldsOf(source, dates).flatMap((field) => {
|
|
40
|
+
const [date, ...more] = datesIn(dates, field);
|
|
41
|
+
if (date === undefined || more.length > 0 || !FULL_DATE.test(date.value))
|
|
42
|
+
return [];
|
|
43
|
+
const rest = `${source.slice(field.start, date.offset)} ${source.slice(date.end, field.end)}`;
|
|
44
|
+
const kind = kindOf(bareWord(rest), words);
|
|
45
|
+
return kind === undefined ? [] : [{ kind, date, line: field.line }];
|
|
46
|
+
});
|
|
47
|
+
/** Stamps written together, each within MAX_LINE_GAP lines of the one before: one document's stamp block. */
|
|
48
|
+
const blocksOf = (stamps) => stamps.reduce((blocks, stamp, index) => {
|
|
49
|
+
const previous = stamps[index - 1];
|
|
50
|
+
const last = blocks.at(-1);
|
|
51
|
+
if (previous === undefined || last === undefined || stamp.line - previous.line > MAX_LINE_GAP)
|
|
52
|
+
return [...blocks, [stamp]];
|
|
53
|
+
return [...blocks.slice(0, -1), [...last, stamp]];
|
|
54
|
+
}, []);
|
|
55
|
+
const valuesOf = (established, updated) => ({ established: established.date.value, updated: updated.date.value });
|
|
56
|
+
/** In one block: each established stamp later than an update, against the latest such update, and each such update against the first such established stamp. */
|
|
57
|
+
const blockIssues = (block) => {
|
|
58
|
+
const established = block.filter((stamp) => stamp.kind === "established");
|
|
59
|
+
const updates = block.filter((stamp) => stamp.kind === "updated").toSorted((a, b) => b.date.value.localeCompare(a.date.value));
|
|
60
|
+
const ofEstablished = established.flatMap((stamp) => {
|
|
61
|
+
const latest = updates.find((updated) => updated.date.value < stamp.date.value);
|
|
62
|
+
return latest === undefined ? [] : [{ offset: stamp.date.offset, values: valuesOf(stamp, latest) }];
|
|
63
|
+
});
|
|
64
|
+
const ofUpdates = updates.flatMap((updated) => {
|
|
65
|
+
const later = established.find((stamp) => stamp.date.value > updated.date.value);
|
|
66
|
+
return later === undefined ? [] : [{ offset: updated.date.offset, values: { ...valuesOf(later, updated), side: "updated" } }];
|
|
67
|
+
});
|
|
68
|
+
return [...ofEstablished, ...ofUpdates];
|
|
69
|
+
};
|
|
70
|
+
/** Each established stamp later than an update of its block, and each such update, the one naming the other. */
|
|
71
|
+
export const stampOrderIssues = (source, dates, words) => {
|
|
72
|
+
if (words.established.length === 0 || words.updated.length === 0)
|
|
73
|
+
return [];
|
|
74
|
+
return blocksOf(stampsOf(source, dates, words))
|
|
75
|
+
.flatMap(blockIssues)
|
|
76
|
+
.toSorted((a, b) => a.offset - b.offset);
|
|
77
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span } from "../plugin.ts";
|
|
2
|
+
import { type LengthWords } from "../derived/time-lengths.ts";
|
|
3
|
+
import { type Mark } from "./time-marks.ts";
|
|
4
|
+
/**
|
|
5
|
+
* A stated total time (所要時間:80分, Total time: 1 hr 20 min) against the sum of the times written in the numbered steps
|
|
6
|
+
* ((10分), bake for 40 minutes). The words come from the language packages; nothing here knows a language. Pure.
|
|
7
|
+
*/
|
|
8
|
+
export type StepTimeWords = {
|
|
9
|
+
readonly lengths: LengthWords;
|
|
10
|
+
/** Labels of a total time (所要時間, Total time), written before the length. */
|
|
11
|
+
readonly totals: readonly Mark[];
|
|
12
|
+
/** Marks of a rough figure (約, about, 程度): the total or a step that carries one is compared with a margin. */
|
|
13
|
+
readonly approximate: readonly Mark[];
|
|
14
|
+
/** Marks of a time that is not how long the step takes (10分後, every 5 minutes, after 10 minutes). */
|
|
15
|
+
readonly notOwn: readonly Mark[];
|
|
16
|
+
/** What joins the two ends of a range (10〜15分, 10 to 15 minutes): a step or total with a range is not read. */
|
|
17
|
+
readonly rangeJoiners: readonly string[];
|
|
18
|
+
};
|
|
19
|
+
/** A length of time with whether it was written as a rough figure. */
|
|
20
|
+
export type ReadTime = Span & {
|
|
21
|
+
readonly minutes: number;
|
|
22
|
+
readonly approximate: boolean;
|
|
23
|
+
};
|
|
24
|
+
export type StepTimeSlip = {
|
|
25
|
+
readonly total: ReadTime;
|
|
26
|
+
readonly sum: number;
|
|
27
|
+
readonly steps: number;
|
|
28
|
+
/** How far the sum may be from the total and still agree, in minutes: 0 unless a rough figure is involved. */
|
|
29
|
+
readonly margin: number;
|
|
30
|
+
};
|
|
31
|
+
/** A rough total agrees with a sum within this share of the total, and never less than ROUGH_MINUTES. */
|
|
32
|
+
export declare const ROUGH_SHARE = 0.1;
|
|
33
|
+
export declare const ROUGH_MINUTES = 5;
|
|
34
|
+
/** The numbered lists of the source, each a run of items with only blank or indented lines between them. An item holds its line and the indented lines right under it. */
|
|
35
|
+
export declare const stepLists: (source: string) => Span[][];
|
|
36
|
+
/** Every numbered step of the source. */
|
|
37
|
+
export declare const stepItems: (source: string) => Span[];
|
|
38
|
+
/** How long one step takes: its one own length of time. undefined when it has none, more than one, or a range. */
|
|
39
|
+
export declare const stepTime: (text: string, words: StepTimeWords) => ReadTime | undefined;
|
|
40
|
+
/** The total time the source states outside its steps: a length with a total label right before it. Only one value is read. */
|
|
41
|
+
export declare const statedTotal: (source: string, items: readonly Span[], words: StepTimeWords) => ReadTime | undefined;
|
|
42
|
+
/** The margin a rough figure allows: ROUGH_SHARE of the total, at least ROUGH_MINUTES. */
|
|
43
|
+
export declare const marginOf: (total: number, rough: boolean) => number;
|
|
44
|
+
/**
|
|
45
|
+
* The stated total against the sum of the steps' times, when the document has one numbered list, every step's time is readable,
|
|
46
|
+
* and they do not agree. Two lists may be two procedures, or one of them no procedure, so a document with two is not read.
|
|
47
|
+
*/
|
|
48
|
+
export declare const stepTimeSlip: (source: string, words: StepTimeWords) => StepTimeSlip | undefined;
|
|
49
|
+
//# sourceMappingURL=step-times.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"step-times.d.ts","sourceRoot":"","sources":["../../src/structure/step-times.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAwB,KAAK,WAAW,EAAmB,MAAM,4BAA4B,CAAC;AACrG,OAAO,EAAY,KAAK,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAGtD;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC;IAC9B,4EAA4E;IAC5E,QAAQ,CAAC,MAAM,EAAE,SAAS,IAAI,EAAE,CAAC;IACjC,8GAA8G;IAC9G,QAAQ,CAAC,WAAW,EAAE,SAAS,IAAI,EAAE,CAAC;IACtC,qGAAqG;IACrG,QAAQ,CAAC,MAAM,EAAE,SAAS,IAAI,EAAE,CAAC;IACjC,+G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