chaffjs 0.30.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/time-lengths.d.ts.map +1 -1
- package/dist/derived/time-lengths.js +12 -9
- package/dist/derived/time-lengths.js.map +1 -1
- 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/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/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 +2 -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 +9 -1
- package/dist/detectors/derived-numbers.d.ts.map +1 -1
- package/dist/detectors/derived-numbers.js +2 -2
- 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 +25 -4
- 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/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/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/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/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/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/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 +22 -5
- 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 +1 -0
- package/dist/detectors/time-order.d.ts.map +1 -1
- package/dist/detectors/time-order.js +3 -1
- package/dist/detectors/time-order.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/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/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 +3 -2
- package/dist/name-variants.d.ts.map +1 -1
- package/dist/name-variants.js +4 -7
- package/dist/name-variants.js.map +1 -1
- 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 +5 -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/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/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-outside-period.d.ts +3 -1
- package/dist/structure/date-outside-period.d.ts.map +1 -1
- package/dist/structure/date-outside-period.js +8 -5
- package/dist/structure/date-outside-period.js.map +1 -1
- package/dist/structure/date-range.d.ts +1 -0
- package/dist/structure/date-range.d.ts.map +1 -1
- package/dist/structure/date-range.js +1 -1
- 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/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/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/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-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/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/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/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/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 +8 -2
- package/rules/no-em-dash.yaml +2 -2
- 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/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/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/time-lengths.ts +12 -9
- package/src/derived/use-interval.ts +151 -0
- package/src/detectors/announced-count.ts +1 -0
- package/src/detectors/capacity-runtime.ts +128 -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 +2 -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 +3 -3
- 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 +32 -6
- package/src/detectors/orthographic-variant.ts +78 -9
- package/src/detectors/orthography.ts +16 -6
- 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/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/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/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/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/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 +30 -5
- package/src/detectors/structure.ts +1 -1
- package/src/detectors/technical-docs.ts +12 -0
- package/src/detectors/time-order.ts +5 -1
- 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/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/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 +8 -7
- package/src/phone-numbers.ts +26 -6
- package/src/place-names.ts +53 -14
- package/src/plugin.ts +2 -0
- package/src/preamble-paragraphs.ts +21 -2
- package/src/profile/parse.ts +10 -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/counted-amounts.ts +5 -4
- package/src/structure/date-outside-period.ts +11 -6
- package/src/structure/date-range.ts +1 -1
- 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/measured-amounts.ts +138 -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/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-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/walk-time.ts +285 -0
|
@@ -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,MAAM,sBAAsB,CAAC;AACxE,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAa,MAAM,YAAY,CAAC;AAmChD,4FAA4F;AAC5F,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAC;AACjC,MAAM,IAAI,GAAG,IAAI,CAAC;AAClB,MAAM,WAAW,GAAG,CAAC,CAAC;AAEtB,MAAM,WAAW,GAAG,sBAAsB,CAAC;AAE3C,uFAAuF;AACvF,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,OAAe,EAAE,KAAsB,EAAsB,EAAE;IACxF,MAAM,IAAI,GAAG,gBAAgB,CAAC,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;IAC9E,MAAM,IAAI,GAAG,KAAK;SACf,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QACZ,MAAM,IAAI,GAAG,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC;QACxE,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,IAAI,QAAQ,WAAW,IAAI,CAAC,CAAC,CAAC,KAAK,WA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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
|
+
};
|
|
78
|
+
//# sourceMappingURL=stamp-order.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stamp-order.js","sourceRoot":"","sources":["../../src/structure/stamp-order.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAarC,MAAM,SAAS,GAAG,sBAAsB,CAAC;AACzC,8HAA8H;AAC9H,MAAM,YAAY,GAAG,CAAC,CAAC;AACvB,oHAAoH;AACpH,MAAM,WAAW,GAAG,6BAA6B,CAAC;AAClD,6DAA6D;AAC7D,MAAM,KAAK,GAAG,kBAAkB,CAAC;AAEjC,MAAM,QAAQ,GAAG,CAAC,IAAY,EAAU,EAAE;IACxC,MAAM,KAAK,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC;IACxB,MAAM,KAAK,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IACjE,MAAM,IAAI,GAAG,KAAK,CAAC,aAAa,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IACpE,OAAO,KAAK,KAAK,CAAC,CAAC;QACjB,CAAC,CAAC,EAAE;QAC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,CAAC,WAAW,CAAC,MAAM,KAAK,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IAC5E,OAAO,QAAQ,CAAC,QAAQ,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;SAC5C,OAAO,CAAC,WAAW,CAAC;SACpB,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC;AAC7C,CAAC,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { 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,KAA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SAKxE,CAAC;AAeF,+HAA+H;AAC/H,eAAO,MAAM,WAAW,GAAI,QAAQ,MAAM,EAAE,OAAO,SAAS,IAAI,EAAE,EAAE,OAAO,aAAa,KAAG,QAAQ,GAAG,SAMrG,CAAC;AAEF,0FAA0F;AAC1F,eAAO,MAAM,QAAQ,GAAI,OAAO,MAAM,EAAE,OAAO,OAAO,KAAG,MAAoE,CAAC;AAE9H;;;GAGG;AACH,eAAO,MAAM,YAAY,GAAI,QAAQ,MAAM,EAAE,OAAO,aAAa,KAAG,YAAY,GAAG,SAWlF,CAAC"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { labelOf, timeLengths } from "../derived/time-lengths.js";
|
|
2
|
+
import { isWordAt } from "./time-marks.js";
|
|
3
|
+
import { linesOf } from "./lines.js";
|
|
4
|
+
/** A rough total agrees with a sum within this share of the total, and never less than ROUGH_MINUTES. */
|
|
5
|
+
export const ROUGH_SHARE = 0.1;
|
|
6
|
+
export const ROUGH_MINUTES = 5;
|
|
7
|
+
const MIN_STEPS = 2;
|
|
8
|
+
/** 1. or 1) with a space after it (so 1.5 hours is no step); the full-width 1.or 1)may run straight on. */
|
|
9
|
+
const STEP_ITEM = /^\s*\p{Nd}{1,3}(?:[.)]\s|[.)])/u;
|
|
10
|
+
const INDENTED = /^\s+\S/u;
|
|
11
|
+
/** One line's place in the numbered lists: a new item, a line under the last item, a blank, or the end of the list. */
|
|
12
|
+
const readLine = (read, line) => {
|
|
13
|
+
const end = line.start + line.text.length;
|
|
14
|
+
const list = read.lists[read.lists.length - 1];
|
|
15
|
+
const last = list?.[list.length - 1];
|
|
16
|
+
if (STEP_ITEM.test(line.text)) {
|
|
17
|
+
if (read.open && list !== undefined)
|
|
18
|
+
list.push({ start: line.start, end });
|
|
19
|
+
else
|
|
20
|
+
read.lists.push([{ start: line.start, end }]);
|
|
21
|
+
return { lists: read.lists, open: true, lastLine: line.number };
|
|
22
|
+
}
|
|
23
|
+
if (line.text.trim() === "")
|
|
24
|
+
return read;
|
|
25
|
+
if (read.open && list !== undefined && last !== undefined && INDENTED.test(line.text)) {
|
|
26
|
+
if (read.lastLine === line.number - 1)
|
|
27
|
+
list[list.length - 1] = { start: last.start, end };
|
|
28
|
+
return { ...read, lastLine: line.number };
|
|
29
|
+
}
|
|
30
|
+
return { ...read, open: false };
|
|
31
|
+
};
|
|
32
|
+
/** 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. */
|
|
33
|
+
export const stepLists = (source) => linesOf(source).reduce(readLine, { lists: [], open: false, lastLine: 0 }).lists;
|
|
34
|
+
/** Every numbered step of the source. */
|
|
35
|
+
export const stepItems = (source) => stepLists(source).flat();
|
|
36
|
+
const lower = (text) => text.toLowerCase();
|
|
37
|
+
const sideOf = (marks, side) => marks
|
|
38
|
+
.filter((mark) => (mark.position ?? "before") === side)
|
|
39
|
+
.map((mark) => lower(mark.pattern))
|
|
40
|
+
.filter((pattern) => pattern !== "")
|
|
41
|
+
.toSorted((left, right) => right.length - left.length);
|
|
42
|
+
/** The mark written right before at (white space between only), and where it starts. */
|
|
43
|
+
const markEndingAt = (text, at, patterns) => {
|
|
44
|
+
const head = lower(text.slice(0, at)).trimEnd();
|
|
45
|
+
const found = patterns.find((pattern) => isWordAt(head, head.length - pattern.length, pattern));
|
|
46
|
+
return found === undefined ? undefined : head.length - found.length;
|
|
47
|
+
};
|
|
48
|
+
/** Whether a mark is written right after at (white space between only). */
|
|
49
|
+
const markStartingAt = (text, at, patterns) => {
|
|
50
|
+
const tail = lower(text.slice(at));
|
|
51
|
+
const gap = tail.length - tail.trimStart().length;
|
|
52
|
+
return patterns.some((pattern) => isWordAt(tail, gap, pattern));
|
|
53
|
+
};
|
|
54
|
+
const DIGIT_BEFORE = /\p{Nd}\s*$/u;
|
|
55
|
+
/** Whether the length is the second end of a range: a joiner right before it, after a number, a number word or a unit (10〜15分, one to two hours, 10 minutes to 15 minutes). */
|
|
56
|
+
const endsRange = (text, at, words) => {
|
|
57
|
+
const start = markEndingAt(text, at, words.rangeJoiners.map(lower));
|
|
58
|
+
if (start === undefined)
|
|
59
|
+
return false;
|
|
60
|
+
const { numberWords, hourUnits, minuteUnits } = words.lengths;
|
|
61
|
+
const ends = [...numberWords, ...hourUnits, ...minuteUnits].map(lower).filter((word) => word !== "");
|
|
62
|
+
return DIGIT_BEFORE.test(text.slice(0, start)) || markEndingAt(text, start, ends) !== undefined;
|
|
63
|
+
};
|
|
64
|
+
/** Each length in text, with where its rough-figure mark starts, whether it is the step's own time, and whether it ends a range. */
|
|
65
|
+
const readingsOf = (text, words) => timeLengths(text, words.lengths).map((length) => {
|
|
66
|
+
const roughBefore = markEndingAt(text, length.start, sideOf(words.approximate, "before"));
|
|
67
|
+
const roughAfter = markStartingAt(text, length.end, sideOf(words.approximate, "after"));
|
|
68
|
+
const from = roughBefore ?? length.start;
|
|
69
|
+
const notOwn = markEndingAt(text, from, sideOf(words.notOwn, "before")) !== undefined ||
|
|
70
|
+
(!roughAfter && markStartingAt(text, length.end, sideOf(words.notOwn, "after")));
|
|
71
|
+
return {
|
|
72
|
+
time: { start: length.start, end: length.end, minutes: length.minutes, approximate: roughBefore !== undefined || roughAfter },
|
|
73
|
+
from,
|
|
74
|
+
own: !notOwn,
|
|
75
|
+
range: endsRange(text, length.start, words),
|
|
76
|
+
};
|
|
77
|
+
});
|
|
78
|
+
/** How long one step takes: its one own length of time. undefined when it has none, more than one, or a range. */
|
|
79
|
+
export const stepTime = (text, words) => {
|
|
80
|
+
const readings = readingsOf(text, words);
|
|
81
|
+
if (readings.some((reading) => reading.range))
|
|
82
|
+
return undefined;
|
|
83
|
+
const own = readings.filter((reading) => reading.own);
|
|
84
|
+
return own.length === 1 ? own[0]?.time : undefined;
|
|
85
|
+
};
|
|
86
|
+
const outside = (offset, items) => !items.some((item) => offset >= item.start && offset < item.end);
|
|
87
|
+
/** The totals written on one line. A line with a range (Total time: 10 to 15 minutes) states no exact total. */
|
|
88
|
+
const totalsOn = (line, words) => {
|
|
89
|
+
const readings = readingsOf(line.text, words);
|
|
90
|
+
if (readings.some((reading) => reading.range))
|
|
91
|
+
return [];
|
|
92
|
+
return readings.flatMap((reading) => {
|
|
93
|
+
const label = labelOf(line.text, { start: reading.from, end: reading.time.end }, words.totals);
|
|
94
|
+
if (label === undefined || !reading.own)
|
|
95
|
+
return [];
|
|
96
|
+
return [{ ...reading.time, start: line.start + reading.time.start, end: line.start + reading.time.end }];
|
|
97
|
+
});
|
|
98
|
+
};
|
|
99
|
+
/** The total time the source states outside its steps: a length with a total label right before it. Only one value is read. */
|
|
100
|
+
export const statedTotal = (source, items, words) => {
|
|
101
|
+
const totals = linesOf(source)
|
|
102
|
+
.filter((line) => outside(line.start, items))
|
|
103
|
+
.flatMap((line) => totalsOn(line, words));
|
|
104
|
+
const values = new Set(totals.map((total) => total.minutes));
|
|
105
|
+
return values.size === 1 ? totals[0] : undefined;
|
|
106
|
+
};
|
|
107
|
+
/** The margin a rough figure allows: ROUGH_SHARE of the total, at least ROUGH_MINUTES. */
|
|
108
|
+
export const marginOf = (total, rough) => (rough ? Math.max(ROUGH_MINUTES, total * ROUGH_SHARE) : 0);
|
|
109
|
+
/**
|
|
110
|
+
* The stated total against the sum of the steps' times, when the document has one numbered list, every step's time is readable,
|
|
111
|
+
* 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.
|
|
112
|
+
*/
|
|
113
|
+
export const stepTimeSlip = (source, words) => {
|
|
114
|
+
const lists = stepLists(source);
|
|
115
|
+
const [items] = lists;
|
|
116
|
+
if (lists.length !== 1 || items === undefined || items.length < MIN_STEPS)
|
|
117
|
+
return undefined;
|
|
118
|
+
const total = statedTotal(source, items, words);
|
|
119
|
+
if (total === undefined)
|
|
120
|
+
return undefined;
|
|
121
|
+
const times = items.map((item) => stepTime(source.slice(item.start, item.end), words));
|
|
122
|
+
if (times.some((time) => time === undefined))
|
|
123
|
+
return undefined;
|
|
124
|
+
const sum = times.reduce((minutes, time) => minutes + (time?.minutes ?? 0), 0);
|
|
125
|
+
const margin = marginOf(total.minutes, total.approximate || times.some((time) => time?.approximate === true));
|
|
126
|
+
return Math.abs(sum - total.minutes) <= margin ? undefined : { total, sum, steps: items.length, margin };
|
|
127
|
+
};
|
|
128
|
+
//# sourceMappingURL=step-times.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"step-times.js","sourceRoot":"","sources":["../../src/structure/step-times.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,WAAW,EAAqC,MAAM,4BAA4B,CAAC;AACrG,OAAO,EAAE,QAAQ,EAAa,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AA6BrC,yGAAyG;AACzG,MAAM,CAAC,MAAM,WAAW,GAAG,GAAG,CAAC;AAC/B,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAC;AAC/B,MAAM,SAAS,GAAG,CAAC,CAAC;AAEpB,2GAA2G;AAC3G,MAAM,SAAS,GAAG,iCAAiC,CAAC;AACpD,MAAM,QAAQ,GAAG,SAAS,CAAC;AAI3B,uHAAuH;AACvH,MAAM,QAAQ,GAAG,CAAC,IAAc,EAAE,IAAgF,EAAY,EAAE;IAC9H,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC;IAC1C,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAC/C,MAAM,IAAI,GAAG,IAAI,EAAE,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACrC,IAAI,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QAC9B,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI,KAAK,SAAS;YAAE,IAAI,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,KA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GAAG,WAAW,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;IAChD,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAC1C,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC;IACvF,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,SAAS,CAAC;QAAE,OAAO,SAAS,CAAC;IAC/D,MAAM,GAAG,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC,OAAO,GAAG,CAAC,IAAI,EAAE,OAAO,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAC/E,MAAM,MAAM,GAAG,QAAQ,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,WAAW,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,IAAI,CAAC,CAAC,CAAC;IAC9G,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC;AAC3G,CAAC,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 文書の仕事の期間(開講期間、Term)と、後ろの節の締め切りの日付を比べた結果。語の有無は呼ぶ側が読んで渡す。
|
|
3
|
+
* 年の無い締め切りは、期間の始まりと終わりが同じ年のときだけその年と読む。年をまたぐ期間では、期間の外の月日は始まりの前とも終わりの後とも読める。
|
|
4
|
+
*/
|
|
5
|
+
export type TermDates = {
|
|
6
|
+
readonly start: string;
|
|
7
|
+
readonly end: string;
|
|
8
|
+
};
|
|
9
|
+
/** 締め切りの日付を囲む項目か文の語: 締め切りの語、期間の外に置く語、期間の後に来てよい仕事の語(成績発表、再試験)。 */
|
|
10
|
+
export type DeadlineMarks = {
|
|
11
|
+
readonly deadline: boolean;
|
|
12
|
+
readonly aside: boolean;
|
|
13
|
+
readonly afterTerm: boolean;
|
|
14
|
+
};
|
|
15
|
+
export type DeadlineVerdict = "late" | "within" | "before" | "no-year" | "not-deadline" | "aside" | "after-term";
|
|
16
|
+
/** 締め切りの日付を年月日で。年が無ければ、期間の始まりと終わりの年が同じときだけその年を足す。 */
|
|
17
|
+
export declare const deadlineDate: (value: string, term: TermDates) => string | undefined;
|
|
18
|
+
export declare const deadlineVerdict: (value: string, term: TermDates, marks: DeadlineMarks) => DeadlineVerdict;
|
|
19
|
+
//# sourceMappingURL=term-deadline.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"term-deadline.d.ts","sourceRoot":"","sources":["../../src/structure/term-deadline.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,MAAM,SAAS,GAAG;IAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC;AAEzE,iEAAiE;AACjE,MAAM,MAAM,aAAa,GAAG;IAAE,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAA;CAAE,CAAC;AAEjH,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,cAAc,GAAG,OAAO,GAAG,YAAY,CAAC;AAMjH,qDAAqD;AACrD,eAAO,MAAM,YAAY,GAAI,OAAO,MAAM,EAAE,MAAM,SAAS,KAAG,MAAM,GAAG,SAKtE,CAAC;AAOF,eAAO,MAAM,eAAe,GAAI,OAAO,MAAM,EAAE,MAAM,SAAS,EAAE,OAAO,aAAa,KAAG,eAMtF,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const YEAR_LENGTH = "2026".length;
|
|
2
|
+
const DATED = /^\d{4}-\d{2}-\d{2}$/u;
|
|
3
|
+
const MONTH_DAY = /^\d{2}-\d{2}$/u;
|
|
4
|
+
/** 締め切りの日付を年月日で。年が無ければ、期間の始まりと終わりの年が同じときだけその年を足す。 */
|
|
5
|
+
export const deadlineDate = (value, term) => {
|
|
6
|
+
if (DATED.test(value))
|
|
7
|
+
return value;
|
|
8
|
+
if (!MONTH_DAY.test(value) || !DATED.test(term.start) || !DATED.test(term.end))
|
|
9
|
+
return undefined;
|
|
10
|
+
const year = term.start.slice(0, YEAR_LENGTH);
|
|
11
|
+
return year === term.end.slice(0, YEAR_LENGTH) ? `${year}-${value}` : undefined;
|
|
12
|
+
};
|
|
13
|
+
const placeOf = (date, term) => {
|
|
14
|
+
if (date > term.end)
|
|
15
|
+
return "late";
|
|
16
|
+
return date < term.start ? "before" : "within";
|
|
17
|
+
};
|
|
18
|
+
export const deadlineVerdict = (value, term, marks) => {
|
|
19
|
+
if (!marks.deadline)
|
|
20
|
+
return "not-deadline";
|
|
21
|
+
if (marks.afterTerm)
|
|
22
|
+
return "after-term";
|
|
23
|
+
if (marks.aside)
|
|
24
|
+
return "aside";
|
|
25
|
+
const date = deadlineDate(value, term);
|
|
26
|
+
return date === undefined || !DATED.test(term.end) ? "no-year" : placeOf(date, term);
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=term-deadline.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"term-deadline.js","sourceRoot":"","sources":["../../src/structure/term-deadline.ts"],"names":[],"mappings":"AAWA,MAAM,WAAW,GAAG,MAAM,CAAC,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M,IAAI,GAAG,YAAY,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IACvC,OAAO,IAAI,KAAK,SAAS,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AACvF,CAAC,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { StructureIssue } from "./issues.ts";
|
|
2
|
+
import { type RangeWords } from "./date-range.ts";
|
|
3
|
+
import { type TimeSpan, type TimeWords } from "./time-marks.ts";
|
|
4
|
+
type Reading = {
|
|
5
|
+
readonly from: number;
|
|
6
|
+
readonly to: number;
|
|
7
|
+
readonly borrowed: boolean;
|
|
8
|
+
};
|
|
9
|
+
/** 範囲の二つの時刻を秒で。片方にだけ午前・午後があれば、もう片方もそれで読む。 */
|
|
10
|
+
export declare const rangeReading: (source: string, start: TimeSpan, end: TimeSpan) => Reading;
|
|
11
|
+
/** 終わりが始まりより前で、その戻りが打ち間違いの幅に収まるか。 */
|
|
12
|
+
export declare const isReversed: (reading: Reading) => boolean;
|
|
13
|
+
/** 隣り合う二つの時刻のうち、範囲をなし、終わりが始まりより前のもの。範囲の書き出しを指し、書いたままの範囲を見せる。 */
|
|
14
|
+
export declare const reversedTimeRanges: (source: string, times: readonly TimeSpan[], range: RangeWords, words: TimeWords) => StructureIssue[];
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=time-range.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"time-range.d.ts","sourceRoot":"","sources":["../../src/structure/time-range.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAW,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EAAc,KAAK,QAAQ,EAAE,KAAK,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAmC5E,KAAK,OAAO,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAA;CAAE,CAAC;AAE1F,6CAA6C;AAC7C,eAAO,MAAM,YAAY,GAAI,QAAQ,MAAM,EAAE,OAAO,QAAQ,EAAE,KAAK,QAAQ,KAAG,OAK7E,CAAC;AAEF,qCAAqC;AACrC,eAAO,MAAM,UAAU,GAAI,SAAS,OAAO,KAAG,OAG7C,CAAC;AAIF,gEAAgE;AAChE,eAAO,MAAM,kBAAkB,GAAI,QAAQ,MAAM,EAAE,OAAO,SAAS,QAAQ,EAAE,EAAE,OAAO,UAAU,EAAE,OAAO,SAAS,KAAG,cAAc,EAO/H,CAAC"}
|